@wecode-team/we0-cms 1.1.13 → 1.1.14

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/index.esm.js CHANGED
@@ -1,17 +1,11 @@
1
- import*as e from"react";import t,{forwardRef as n,createElement as r,useState as i,useLayoutEffect as o,useMemo as s,useEffect as a,useContext as l,createContext as c,useRef as u,useImperativeHandle as h,useCallback as d}from"react";import{jsx as f,jsxs as p,Fragment as m}from"react/jsx-runtime";import*as g from"react-dom";import v from"react-dom";import{createRoot as b}from"react-dom/client";import y from"dayjs";function w(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function x(e,t,n,r,i,o,s){try{var a=e[o](s),l=a.value}catch(e){return void n(e)}a.done?t(l):Promise.resolve(l).then(r,i)}function k(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var o=e.apply(t,n);function s(e){x(o,r,i,s,a,"next",e)}function a(e){x(o,r,i,s,a,"throw",e)}s(void 0)})}}function S(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=T(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){a=!0,o=e},f:function(){try{s||null==n.return||n.return()}finally{if(a)throw o}}}}function E(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function C(){
1
+ import*as e from"react";import t,{forwardRef as n,createElement as r,useState as i,useLayoutEffect as o,useMemo as s,useEffect as a,useContext as l,createContext as c,useRef as u,useImperativeHandle as h,useCallback as f}from"react";import{jsx as d,Fragment as p,jsxs as m}from"react/jsx-runtime";import*as g from"react-dom";import v from"react-dom";import{createRoot as y}from"react-dom/client";import b from"dayjs";function w(e,t){this.v=e,this.k=t}function k(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function x(e){var t={},n=!1;function r(t,r){return n=!0,r=new Promise(function(n){n(e[t](r))}),{done:!1,value:new w(r,1)}}return t["undefined"!=typeof Symbol&&Symbol.iterator||"@@iterator"]=function(){return this},t.next=function(e){return n?(n=!1,e):r("next",e)},"function"==typeof e.throw&&(t.throw=function(e){if(n)throw n=!1,e;return r("throw",e)}),"function"==typeof e.return&&(t.return=function(e){return n?(n=!1,e):r("return",e)}),t}function S(e){var t,n,r,i=2;for("undefined"!=typeof Symbol&&(n=Symbol.asyncIterator,r=Symbol.iterator);i--;){if(n&&null!=(t=e[n]))return t.call(e);if(r&&null!=(t=e[r]))return new C(t.call(e));n="@@asyncIterator",r="@@iterator"}throw new TypeError("Object is not async iterable")}function C(e){function t(e){if(Object(e)!==e)return Promise.reject(new TypeError(e+" is not an object."));var t=e.done;return Promise.resolve(e.value).then(function(e){return{value:e,done:t}})}return C=function(e){this.s=e,this.n=e.next},C.prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(e){var n=this.s.return;return void 0===n?Promise.resolve({value:e,done:!0}):t(n.apply(this.s,arguments))},throw:function(e){var n=this.s.return;return void 0===n?Promise.reject(e):t(n.apply(this.s,arguments))}},new C(e)}function E(e,t,n,r,i,o,s){try{var a=e[o](s),l=a.value}catch(e){return void n(e)}a.done?t(l):Promise.resolve(l).then(r,i)}function A(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var o=e.apply(t,n);function s(e){E(o,r,i,s,a,"next",e)}function a(e){E(o,r,i,s,a,"throw",e)}s(void 0)})}}function M(e){return new w(e,0)}function O(e,t,n){return t=B(t),function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,_()?Reflect.construct(t,n||[],B(e).constructor):t.apply(e,n))}function N(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function T(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,G(r.key),r)}}function R(e,t,n){return t&&T(e.prototype,t),n&&T(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function D(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=$(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){a=!0,o=e},f:function(){try{s||null==n.return||n.return()}finally{if(a)throw o}}}}function P(e,t,n){return(t=G(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function L(){return L="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=B(e)););return e}(e,t);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i.get?i.get.call(arguments.length<3?e:n):i.value}},L.apply(null,arguments)}function B(e){return B=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},B(e)}function I(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&V(e,t)}function _(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(_=function(){return!!e})()}function F(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function W(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?F(Object(n),!0).forEach(function(t){P(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):F(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function j(){
2
2
  /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
3
- var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var l=r&&r.prototype instanceof a?r:a,c=Object.create(l.prototype);return N(c,"_invoke",function(n,r,i){var o,a,l,c=0,u=i||[],h=!1,d={p:0,n:0,v:e,a:f,f:f.bind(e,4),d:function(t,n){return o=t,a=0,l=e,d.n=n,s}};function f(n,r){for(a=n,l=r,t=0;!h&&c&&!i&&t<u.length;t++){var i,o=u[t],f=d.p,p=o[2];n>3?(i=p===r)&&(l=o[(a=o[4])?5:(a=3,3)],o[4]=o[5]=e):o[0]<=f&&((i=n<2&&f<o[1])?(a=0,d.v=r,d.n=o[1]):f<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,d.n=p,a=0))}if(i||n>1)return s;throw h=!0,r}return function(i,u,p){if(c>1)throw TypeError("Generator is already running");for(h&&1===u&&f(u,p),a=u,l=p;(t=a<2?e:l)||!h;){o||(a?a<3?(a>1&&(d.n=-1),f(a,l)):d.n=l:d.v=l);try{if(c=2,o){if(a||(i="next"),t=o[i]){if(!(t=t.call(o,l)))throw TypeError("iterator result is not an object");if(!t.done)return t;l=t.value,a<2&&(a=0)}else 1===a&&(t=o.return)&&t.call(o),a<2&&(l=TypeError("The iterator does not provide a '"+i+"' method"),a=1);o=e}else if((t=(h=d.n<0)?l:n.call(r,d))!==s)break}catch(t){o=e,a=1,l=t}finally{c=1}}return{value:t,done:h}}}(n,i,o),!0),c}var s={};function a(){}function l(){}function c(){}t=Object.getPrototypeOf;var u=[][r]?t(t([][r]())):(N(t={},r,function(){return this}),t),h=c.prototype=a.prototype=Object.create(u);function d(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,N(e,i,"GeneratorFunction")),e.prototype=Object.create(h),e}return l.prototype=c,N(h,"constructor",c),N(c,"constructor",l),l.displayName="GeneratorFunction",N(c,i,"GeneratorFunction"),N(h),N(h,i,"Generator"),N(h,r,function(){return this}),N(h,"toString",function(){return"[object Generator]"}),(C=function(){return{w:o,m:d}})()}function N(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}N=function(e,t,n,r){function o(t,n){N(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},N(e,t,n,r)}function O(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o,s,a=[],l=!0,c=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(a.push(r.value),a.length!==t);l=!0);}catch(e){c=!0,i=e}finally{try{if(!l&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(c)throw i}}return a}}(e,t)||T(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function A(e){return function(e){if(Array.isArray(e))return w(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||T(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function M(e){return M="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},M(e)}function T(e,t){if(e){if("string"==typeof e)return w(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?w(e,t):void 0}}var R=function(){return R=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},R.apply(this,arguments)};function D(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n}"function"==typeof SuppressedError&&SuppressedError;
3
+ var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var l=r&&r.prototype instanceof a?r:a,c=Object.create(l.prototype);return H(c,"_invoke",function(n,r,i){var o,a,l,c=0,u=i||[],h=!1,f={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,n){return o=t,a=0,l=e,f.n=n,s}};function d(n,r){for(a=n,l=r,t=0;!h&&c&&!i&&t<u.length;t++){var i,o=u[t],d=f.p,p=o[2];n>3?(i=p===r)&&(l=o[(a=o[4])?5:(a=3,3)],o[4]=o[5]=e):o[0]<=d&&((i=n<2&&d<o[1])?(a=0,f.v=r,f.n=o[1]):d<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,f.n=p,a=0))}if(i||n>1)return s;throw h=!0,r}return function(i,u,p){if(c>1)throw TypeError("Generator is already running");for(h&&1===u&&d(u,p),a=u,l=p;(t=a<2?e:l)||!h;){o||(a?a<3?(a>1&&(f.n=-1),d(a,l)):f.n=l:f.v=l);try{if(c=2,o){if(a||(i="next"),t=o[i]){if(!(t=t.call(o,l)))throw TypeError("iterator result is not an object");if(!t.done)return t;l=t.value,a<2&&(a=0)}else 1===a&&(t=o.return)&&t.call(o),a<2&&(l=TypeError("The iterator does not provide a '"+i+"' method"),a=1);o=e}else if((t=(h=f.n<0)?l:n.call(r,f))!==s)break}catch(t){o=e,a=1,l=t}finally{c=1}}return{value:t,done:h}}}(n,i,o),!0),c}var s={};function a(){}function l(){}function c(){}t=Object.getPrototypeOf;var u=[][r]?t(t([][r]())):(H(t={},r,function(){return this}),t),h=c.prototype=a.prototype=Object.create(u);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,H(e,i,"GeneratorFunction")),e.prototype=Object.create(h),e}return l.prototype=c,H(h,"constructor",c),H(c,"constructor",l),l.displayName="GeneratorFunction",H(c,i,"GeneratorFunction"),H(h),H(h,i,"Generator"),H(h,r,function(){return this}),H(h,"toString",function(){return"[object Generator]"}),(j=function(){return{w:o,m:f}})()}function H(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}H=function(e,t,n,r){function o(t,n){H(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},H(e,t,n,r)}function z(e){if(null!=e){var t=e["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],n=0;if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}}throw new TypeError(typeof e+" is not iterable")}function V(e,t){return V=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},V(e,t)}function q(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o,s,a=[],l=!0,c=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(a.push(r.value),a.length!==t);l=!0);}catch(e){c=!0,i=e}finally{try{if(!l&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(c)throw i}}return a}}(e,t)||$(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function U(e,t,n,r){var i=L(B(1&r?e.prototype:e),t,n);return 2&r&&"function"==typeof i?function(e){return i.apply(n,e)}:i}function K(e){return function(e){if(Array.isArray(e))return k(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||$(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function G(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}function Y(e){return Y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Y(e)}function $(e,t){if(e){if("string"==typeof e)return k(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?k(e,t):void 0}}function X(e){return function(){return new J(e.apply(this,arguments))}}function J(e){var t,n;function r(t,n){try{var o=e[t](n),s=o.value,a=s instanceof w;Promise.resolve(a?s.v:s).then(function(n){if(a){var l="return"===t?"return":"next";if(!s.k||n.done)return r(l,n);n=e[l](n).value}i(o.done?"return":"normal",n)},function(e){r("throw",e)})}catch(e){i("throw",e)}}function i(e,i){switch(e){case"return":t.resolve({value:i,done:!0});break;case"throw":t.reject(i);break;default:t.resolve({value:i,done:!1})}(t=t.next)?r(t.key,t.arg):n=null}this._invoke=function(e,i){return new Promise(function(o,s){var a={key:e,arg:i,resolve:o,reject:s,next:null};n?n=n.next=a:(t=n=a,r(e,i))})},"function"!=typeof e.return&&(this.return=void 0)}J.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},J.prototype.next=function(e){return this._invoke("next",e)},J.prototype.throw=function(e){return this._invoke("throw",e)},J.prototype.return=function(e){return this._invoke("return",e)};var Q=function(){return Q=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Q.apply(this,arguments)};function Z(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n}"function"==typeof SuppressedError&&SuppressedError;
4
4
  /**
5
5
  * @license lucide-react v0.344.0 - ISC
6
6
  *
7
7
  * This source code is licensed under the ISC license.
8
8
  * See the LICENSE file in the root directory of this source tree.
9
9
  */
10
- var P={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};
11
- /**
12
- * @license lucide-react v0.344.0 - ISC
13
- *
14
- * This source code is licensed under the ISC license.
15
- * See the LICENSE file in the root directory of this source tree.
16
- */const L=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase().trim(),I=(e,t)=>{const i=n(({color:n="currentColor",size:i=24,strokeWidth:o=2,absoluteStrokeWidth:s,className:a="",children:l,...c},u)=>r("svg",{ref:u,...P,width:i,height:i,stroke:n,strokeWidth:s?24*Number(o)/Number(i):o,className:["lucide",`lucide-${L(e)}`,a].join(" "),...c},[...t.map(([e,t])=>r(e,t)),...Array.isArray(l)?l:[l]]));return i.displayName=`${e}`,i},_=I("AlertCircle",[["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"}]]),B=I("CheckCircle2",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),F=I("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]),j=I("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]),W=I("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]),z=I("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]),H=I("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]),V=I("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]),q=I("Crown",[["path",{d:"m2 4 3 12h14l3-12-6 7-4-7-4 7-6-7zm3 16h14",key:"zkxr6b"}]]),U=I("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]),$=I("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]),K=I("Filter",[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]]),Y=I("Home",[["path",{d:"m3 9 9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"y5dka4"}],["polyline",{points:"9 22 9 12 15 12 15 22",key:"e2us08"}]]),G=I("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]),X=I("Languages",[["path",{d:"m5 8 6 6",key:"1wu5hv"}],["path",{d:"m4 14 6-6 2-3",key:"1k1g8d"}],["path",{d:"M2 5h12",key:"or177f"}],["path",{d:"M7 2h1",key:"1t2jsx"}],["path",{d:"m22 22-5-10-5 10",key:"don7ne"}],["path",{d:"M14 18h6",key:"1m8k6r"}]]),J=I("Loader2",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]),Q=I("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]),Z=I("LogIn",[["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}],["polyline",{points:"10 17 15 12 10 7",key:"1ail0h"}],["line",{x1:"15",x2:"3",y1:"12",y2:"12",key:"v6grx8"}]]),ee=I("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]),te=I("PanelLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),ne=I("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]),re=I("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]),ie=I("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),oe=I("SquarePen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a2.121 2.121 0 1 1 3 3L12 15l-4 1 1-4Z",key:"1lpok0"}]]),se=I("Table",[["path",{d:"M12 3v18",key:"108xh3"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}]]),ae=I("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]),le=I("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]),ce=I("XCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]),ue=I("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function he(e){var t,n,r="";if("string"==typeof e||"number"==typeof e)r+=e;else if("object"==typeof e)if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=he(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function de(){for(var e,t,n=0,r="",i=arguments.length;n<i;n++)(e=arguments[n])&&(t=he(e))&&(r&&(r+=" "),r+=t);return r}const fe=e=>{const t=ve(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{const n=e.split("-");return""===n[0]&&1!==n.length&&n.shift(),pe(n,t)||ge(e)},getConflictingClassGroupIds:(e,t)=>{const i=n[e]||[];return t&&r[e]?[...i,...r[e]]:i}}},pe=(e,t)=>{if(0===e.length)return t.classGroupId;const n=e[0],r=t.nextPart.get(n),i=r?pe(e.slice(1),r):void 0;if(i)return i;if(0===t.validators.length)return;const o=e.join("-");return t.validators.find(({validator:e})=>e(o))?.classGroupId},me=/^\[(.+)\]$/,ge=e=>{if(me.test(e)){const t=me.exec(e)[1],n=t?.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},ve=e=>{const{theme:t,prefix:n}=e,r={nextPart:new Map,validators:[]};return xe(Object.entries(e.classGroups),n).forEach(([e,n])=>{be(n,r,e,t)}),r},be=(e,t,n,r)=>{e.forEach(e=>{if("string"==typeof e){return void((""===e?t:ye(t,e)).classGroupId=n)}if("function"==typeof e)return we(e)?void be(e(r),t,n,r):void t.validators.push({validator:e,classGroupId:n});Object.entries(e).forEach(([e,i])=>{be(i,ye(t,e),n,r)})})},ye=(e,t)=>{let n=e;return t.split("-").forEach(e=>{n.nextPart.has(e)||n.nextPart.set(e,{nextPart:new Map,validators:[]}),n=n.nextPart.get(e)}),n},we=e=>e.isThemeGetter,xe=(e,t)=>t?e.map(([e,n])=>[e,n.map(e=>"string"==typeof e?t+e:"object"==typeof e?Object.fromEntries(Object.entries(e).map(([e,n])=>[t+e,n])):e)]):e,ke=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=new Map,r=new Map;const i=(i,o)=>{n.set(i,o),t++,t>e&&(t=0,r=n,n=new Map)};return{get(e){let t=n.get(e);return void 0!==t?t:void 0!==(t=r.get(e))?(i(e,t),t):void 0},set(e,t){n.has(e)?n.set(e,t):i(e,t)}}},Se=e=>{const{separator:t,experimentalParseClassName:n}=e,r=1===t.length,i=t[0],o=t.length,s=e=>{const n=[];let s,a=0,l=0;for(let c=0;c<e.length;c++){let u=e[c];if(0===a){if(u===i&&(r||e.slice(c,c+o)===t)){n.push(e.slice(l,c)),l=c+o;continue}if("/"===u){s=c;continue}}"["===u?a++:"]"===u&&a--}const c=0===n.length?e:e.substring(l),u=c.startsWith("!");return{modifiers:n,hasImportantModifier:u,baseClassName:u?c.substring(1):c,maybePostfixModifierPosition:s&&s>l?s-l:void 0}};return n?e=>n({className:e,parseClassName:s}):s},Ee=e=>{if(e.length<=1)return e;const t=[];let n=[];return e.forEach(e=>{"["===e[0]?(t.push(...n.sort(),e),n=[]):n.push(e)}),t.push(...n.sort()),t},Ce=/\s+/;function Ne(){let e,t,n=0,r="";for(;n<arguments.length;)(e=arguments[n++])&&(t=Oe(e))&&(r&&(r+=" "),r+=t);return r}const Oe=e=>{if("string"==typeof e)return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=Oe(e[r]))&&(n&&(n+=" "),n+=t);return n};function Ae(e,...t){let n,r,i,o=function(a){const l=t.reduce((e,t)=>t(e),e());return n=(e=>({cache:ke(e.cacheSize),parseClassName:Se(e),...fe(e)}))(l),r=n.cache.get,i=n.cache.set,o=s,s(a)};function s(e){const t=r(e);if(t)return t;const o=((e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i}=t,o=[],s=e.trim().split(Ce);let a="";for(let e=s.length-1;e>=0;e-=1){const t=s[e],{modifiers:l,hasImportantModifier:c,baseClassName:u,maybePostfixModifierPosition:h}=n(t);let d=Boolean(h),f=r(d?u.substring(0,h):u);if(!f){if(!d){a=t+(a.length>0?" "+a:a);continue}if(f=r(u),!f){a=t+(a.length>0?" "+a:a);continue}d=!1}const p=Ee(l).join(":"),m=c?p+"!":p,g=m+f;if(o.includes(g))continue;o.push(g);const v=i(f,d);for(let e=0;e<v.length;++e){const t=v[e];o.push(m+t)}a=t+(a.length>0?" "+a:a)}return a})(e,n);return i(e,o),o}return function(){return o(Ne.apply(null,arguments))}}const Me=e=>{const t=t=>t[e]||[];return t.isThemeGetter=!0,t},Te=/^\[(?:([a-z-]+):)?(.+)\]$/i,Re=/^\d+\/\d+$/,De=new Set(["px","full","screen"]),Pe=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Le=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Ie=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,_e=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Be=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Fe=e=>We(e)||De.has(e)||Re.test(e),je=e=>Ze(e,"length",et),We=e=>Boolean(e)&&!Number.isNaN(Number(e)),ze=e=>Ze(e,"number",We),He=e=>Boolean(e)&&Number.isInteger(Number(e)),Ve=e=>e.endsWith("%")&&We(e.slice(0,-1)),qe=e=>Te.test(e),Ue=e=>Pe.test(e),$e=new Set(["length","size","percentage"]),Ke=e=>Ze(e,$e,tt),Ye=e=>Ze(e,"position",tt),Ge=new Set(["image","url"]),Xe=e=>Ze(e,Ge,rt),Je=e=>Ze(e,"",nt),Qe=()=>!0,Ze=(e,t,n)=>{const r=Te.exec(e);return!!r&&(r[1]?"string"==typeof t?r[1]===t:t.has(r[1]):n(r[2]))},et=e=>Le.test(e)&&!Ie.test(e),tt=()=>!1,nt=e=>_e.test(e),rt=e=>Be.test(e),it=Ae(()=>{const e=Me("colors"),t=Me("spacing"),n=Me("blur"),r=Me("brightness"),i=Me("borderColor"),o=Me("borderRadius"),s=Me("borderSpacing"),a=Me("borderWidth"),l=Me("contrast"),c=Me("grayscale"),u=Me("hueRotate"),h=Me("invert"),d=Me("gap"),f=Me("gradientColorStops"),p=Me("gradientColorStopPositions"),m=Me("inset"),g=Me("margin"),v=Me("opacity"),b=Me("padding"),y=Me("saturate"),w=Me("scale"),x=Me("sepia"),k=Me("skew"),S=Me("space"),E=Me("translate"),C=()=>["auto",qe,t],N=()=>[qe,t],O=()=>["",Fe,je],A=()=>["auto",We,qe],M=()=>["","0",qe],T=()=>[We,qe];return{cacheSize:500,separator:":",theme:{colors:[Qe],spacing:[Fe,je],blur:["none","",Ue,qe],brightness:T(),borderColor:[e],borderRadius:["none","","full",Ue,qe],borderSpacing:N(),borderWidth:O(),contrast:T(),grayscale:M(),hueRotate:T(),invert:M(),gap:N(),gradientColorStops:[e],gradientColorStopPositions:[Ve,je],inset:C(),margin:C(),opacity:T(),padding:N(),saturate:T(),scale:T(),sepia:M(),skew:T(),space:N(),translate:N()},classGroups:{aspect:[{aspect:["auto","square","video",qe]}],container:["container"],columns:[{columns:[Ue]}],"break-after":[{"break-after":["auto","avoid","all","avoid-page","page","left","right","column"]}],"break-before":[{"break-before":["auto","avoid","all","avoid-page","page","left","right","column"]}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top",qe]}],overflow:[{overflow:["auto","hidden","clip","visible","scroll"]}],"overflow-x":[{"overflow-x":["auto","hidden","clip","visible","scroll"]}],"overflow-y":[{"overflow-y":["auto","hidden","clip","visible","scroll"]}],overscroll:[{overscroll:["auto","contain","none"]}],"overscroll-x":[{"overscroll-x":["auto","contain","none"]}],"overscroll-y":[{"overscroll-y":["auto","contain","none"]}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[m]}],"inset-x":[{"inset-x":[m]}],"inset-y":[{"inset-y":[m]}],start:[{start:[m]}],end:[{end:[m]}],top:[{top:[m]}],right:[{right:[m]}],bottom:[{bottom:[m]}],left:[{left:[m]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",He,qe]}],basis:[{basis:C()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",qe]}],grow:[{grow:M()}],shrink:[{shrink:M()}],order:[{order:["first","last","none",He,qe]}],"grid-cols":[{"grid-cols":[Qe]}],"col-start-end":[{col:["auto",{span:["full",He,qe]},qe]}],"col-start":[{"col-start":A()}],"col-end":[{"col-end":A()}],"grid-rows":[{"grid-rows":[Qe]}],"row-start-end":[{row:["auto",{span:[He,qe]},qe]}],"row-start":[{"row-start":A()}],"row-end":[{"row-end":A()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",qe]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",qe]}],gap:[{gap:[d]}],"gap-x":[{"gap-x":[d]}],"gap-y":[{"gap-y":[d]}],"justify-content":[{justify:["normal","start","end","center","between","around","evenly","stretch"]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal","start","end","center","between","around","evenly","stretch","baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":["start","end","center","between","around","evenly","stretch","baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[b]}],px:[{px:[b]}],py:[{py:[b]}],ps:[{ps:[b]}],pe:[{pe:[b]}],pt:[{pt:[b]}],pr:[{pr:[b]}],pb:[{pb:[b]}],pl:[{pl:[b]}],m:[{m:[g]}],mx:[{mx:[g]}],my:[{my:[g]}],ms:[{ms:[g]}],me:[{me:[g]}],mt:[{mt:[g]}],mr:[{mr:[g]}],mb:[{mb:[g]}],ml:[{ml:[g]}],"space-x":[{"space-x":[S]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[S]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",qe,t]}],"min-w":[{"min-w":[qe,t,"min","max","fit"]}],"max-w":[{"max-w":[qe,t,"none","full","min","max","fit","prose",{screen:[Ue]},Ue]}],h:[{h:[qe,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[qe,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[qe,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[qe,t,"auto","min","max","fit"]}],"font-size":[{text:["base",Ue,je]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",ze]}],"font-family":[{font:[Qe]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",qe]}],"line-clamp":[{"line-clamp":["none",We,ze]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Fe,qe]}],"list-image":[{"list-image":["none",qe]}],"list-style-type":[{list:["none","disc","decimal",qe]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[v]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[v]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:["solid","dashed","dotted","double","none","wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Fe,je]}],"underline-offset":[{"underline-offset":["auto",Fe,qe]}],"text-decoration-color":[{decoration:[e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:N()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",qe]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",qe]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[v]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top",Ye]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",Ke]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},Xe]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[p]}],"gradient-via-pos":[{via:[p]}],"gradient-to-pos":[{to:[p]}],"gradient-from":[{from:[f]}],"gradient-via":[{via:[f]}],"gradient-to":[{to:[f]}],rounded:[{rounded:[o]}],"rounded-s":[{"rounded-s":[o]}],"rounded-e":[{"rounded-e":[o]}],"rounded-t":[{"rounded-t":[o]}],"rounded-r":[{"rounded-r":[o]}],"rounded-b":[{"rounded-b":[o]}],"rounded-l":[{"rounded-l":[o]}],"rounded-ss":[{"rounded-ss":[o]}],"rounded-se":[{"rounded-se":[o]}],"rounded-ee":[{"rounded-ee":[o]}],"rounded-es":[{"rounded-es":[o]}],"rounded-tl":[{"rounded-tl":[o]}],"rounded-tr":[{"rounded-tr":[o]}],"rounded-br":[{"rounded-br":[o]}],"rounded-bl":[{"rounded-bl":[o]}],"border-w":[{border:[a]}],"border-w-x":[{"border-x":[a]}],"border-w-y":[{"border-y":[a]}],"border-w-s":[{"border-s":[a]}],"border-w-e":[{"border-e":[a]}],"border-w-t":[{"border-t":[a]}],"border-w-r":[{"border-r":[a]}],"border-w-b":[{"border-b":[a]}],"border-w-l":[{"border-l":[a]}],"border-opacity":[{"border-opacity":[v]}],"border-style":[{border:["solid","dashed","dotted","double","none","hidden"]}],"divide-x":[{"divide-x":[a]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[a]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[v]}],"divide-style":[{divide:["solid","dashed","dotted","double","none"]}],"border-color":[{border:[i]}],"border-color-x":[{"border-x":[i]}],"border-color-y":[{"border-y":[i]}],"border-color-s":[{"border-s":[i]}],"border-color-e":[{"border-e":[i]}],"border-color-t":[{"border-t":[i]}],"border-color-r":[{"border-r":[i]}],"border-color-b":[{"border-b":[i]}],"border-color-l":[{"border-l":[i]}],"divide-color":[{divide:[i]}],"outline-style":[{outline:["","solid","dashed","dotted","double","none"]}],"outline-offset":[{"outline-offset":[Fe,qe]}],"outline-w":[{outline:[Fe,je]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:O()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[v]}],"ring-offset-w":[{"ring-offset":[Fe,je]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",Ue,Je]}],"shadow-color":[{shadow:[Qe]}],opacity:[{opacity:[v]}],"mix-blend":[{"mix-blend":["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity","plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"]}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[r]}],contrast:[{contrast:[l]}],"drop-shadow":[{"drop-shadow":["","none",Ue,qe]}],grayscale:[{grayscale:[c]}],"hue-rotate":[{"hue-rotate":[u]}],invert:[{invert:[h]}],saturate:[{saturate:[y]}],sepia:[{sepia:[x]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[l]}],"backdrop-grayscale":[{"backdrop-grayscale":[c]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[u]}],"backdrop-invert":[{"backdrop-invert":[h]}],"backdrop-opacity":[{"backdrop-opacity":[v]}],"backdrop-saturate":[{"backdrop-saturate":[y]}],"backdrop-sepia":[{"backdrop-sepia":[x]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[s]}],"border-spacing-x":[{"border-spacing-x":[s]}],"border-spacing-y":[{"border-spacing-y":[s]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",qe]}],duration:[{duration:T()}],ease:[{ease:["linear","in","out","in-out",qe]}],delay:[{delay:T()}],animate:[{animate:["none","spin","ping","pulse","bounce",qe]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[w]}],"scale-x":[{"scale-x":[w]}],"scale-y":[{"scale-y":[w]}],rotate:[{rotate:[He,qe]}],"translate-x":[{"translate-x":[E]}],"translate-y":[{"translate-y":[E]}],"skew-x":[{"skew-x":[k]}],"skew-y":[{"skew-y":[k]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",qe]}],accent:[{accent:["auto",e]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",qe]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":N()}],"scroll-mx":[{"scroll-mx":N()}],"scroll-my":[{"scroll-my":N()}],"scroll-ms":[{"scroll-ms":N()}],"scroll-me":[{"scroll-me":N()}],"scroll-mt":[{"scroll-mt":N()}],"scroll-mr":[{"scroll-mr":N()}],"scroll-mb":[{"scroll-mb":N()}],"scroll-ml":[{"scroll-ml":N()}],"scroll-p":[{"scroll-p":N()}],"scroll-px":[{"scroll-px":N()}],"scroll-py":[{"scroll-py":N()}],"scroll-ps":[{"scroll-ps":N()}],"scroll-pe":[{"scroll-pe":N()}],"scroll-pt":[{"scroll-pt":N()}],"scroll-pr":[{"scroll-pr":N()}],"scroll-pb":[{"scroll-pb":N()}],"scroll-pl":[{"scroll-pl":N()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",qe]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[Fe,je,ze]}],stroke:[{stroke:[e,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}});function ot(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return it(de(t))}function st(t){var n=t.className,r=D(t,["className"]);return e.createElement("div",Object.assign({className:ot("animate-pulse rounded-md bg-muted",n)},r))}function at(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function lt(...e){return t=>{let n=!1;const r=e.map(e=>{const r=at(e,t);return n||"function"!=typeof r||(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){const n=r[t];"function"==typeof n?n():at(e[t],null)}}}}function ct(...t){return e.useCallback(lt(...t),t)}var ut=Symbol.for("react.lazy"),ht=e[" use ".trim().toString()];function dt(e){return null!=e&&"object"==typeof e&&"$$typeof"in e&&e.$$typeof===ut&&"_payload"in e&&("object"==typeof(t=e._payload)&&null!==t&&"then"in t);var t}function ft(t){const n=mt(t),r=e.forwardRef((t,r)=>{let{children:i,...o}=t;dt(i)&&"function"==typeof ht&&(i=ht(i._payload));const s=e.Children.toArray(i),a=s.find(vt);if(a){const t=a.props.children,i=s.map(n=>n===a?e.Children.count(t)>1?e.Children.only(null):e.isValidElement(t)?t.props.children:null:n);return f(n,{...o,ref:r,children:e.isValidElement(t)?e.cloneElement(t,void 0,i):null})}return f(n,{...o,ref:r,children:i})});return r.displayName=`${t}.Slot`,r}var pt=ft("Slot");function mt(t){const n=e.forwardRef((t,n)=>{let{children:r,...i}=t;if(dt(r)&&"function"==typeof ht&&(r=ht(r._payload)),e.isValidElement(r)){const t=function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;if(n)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(r),o=function(e,t){const n={...t};for(const r in t){const i=e[r],o=t[r];/^on[A-Z]/.test(r)?i&&o?n[r]=(...e)=>{const t=o(...e);return i(...e),t}:i&&(n[r]=i):"style"===r?n[r]={...i,...o}:"className"===r&&(n[r]=[i,o].filter(Boolean).join(" "))}return{...e,...n}}(i,r.props);return r.type!==e.Fragment&&(o.ref=n?lt(n,t):t),e.cloneElement(r,o)}return e.Children.count(r)>1?e.Children.only(null):null});return n.displayName=`${t}.SlotClone`,n}var gt=Symbol("radix.slottable");function vt(t){return e.isValidElement(t)&&"function"==typeof t.type&&"__radixId"in t.type&&t.type.__radixId===gt}const bt=e=>"boolean"==typeof e?`${e}`:0===e?"0":e,yt=de,wt=(e,t)=>n=>{var r;if(null==(null==t?void 0:t.variants))return yt(e,null==n?void 0:n.class,null==n?void 0:n.className);const{variants:i,defaultVariants:o}=t,s=Object.keys(i).map(e=>{const t=null==n?void 0:n[e],r=null==o?void 0:o[e];if(null===t)return null;const s=bt(t)||bt(r);return i[e][s]}),a=n&&Object.entries(n).reduce((e,t)=>{let[n,r]=t;return void 0===r||(e[n]=r),e},{}),l=null==t||null===(r=t.compoundVariants)||void 0===r?void 0:r.reduce((e,t)=>{let{class:n,className:r,...i}=t;return Object.entries(i).every(e=>{let[t,n]=e;return Array.isArray(n)?n.includes({...o,...a}[t]):{...o,...a}[t]===n})?[...e,n,r]:e},[]);return yt(e,s,l,null==n?void 0:n.class,null==n?void 0:n.className)};var xt=wt("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-full text-sm font-bold transition-all duration-300 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[hsl(var(--primary))]/30 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-[0_4px_20px_-2px_rgba(93,112,82,0.15)] hover:scale-105 hover:shadow-[0_6px_24px_-4px_rgba(93,112,82,0.25)] active:scale-95",destructive:"bg-destructive text-destructive-foreground shadow-[0_4px_20px_-2px_rgba(168,84,72,0.15)] hover:scale-105 hover:shadow-[0_6px_24px_-4px_rgba(168,84,72,0.25)] active:scale-95",outline:"border-2 border-secondary bg-transparent text-secondary hover:bg-secondary/10 hover:scale-105 active:scale-95",secondary:"bg-secondary text-secondary-foreground shadow-[0_4px_20px_-2px_rgba(193,140,93,0.15)] hover:scale-105 hover:shadow-[0_6px_24px_-4px_rgba(193,140,93,0.25)] active:scale-95",ghost:"bg-transparent text-primary hover:bg-primary/10 hover:scale-105 active:scale-95",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-12 px-8 py-2",sm:"h-10 px-6 text-sm",lg:"h-14 px-10 text-base",icon:"h-12 w-12"}},defaultVariants:{variant:"default",size:"default"}}),kt=e.forwardRef(function(t,n){var r=t.className,i=t.variant,o=t.size,s=t.asChild,a=void 0!==s&&s,l=D(t,["className","variant","size","asChild"]),c=a?pt:"button";return e.createElement(c,Object.assign({className:ot(xt({variant:i,size:o,className:r})),ref:n},l))});kt.displayName="Button";var St=e.forwardRef(function(t,n){var r=t.className,i=t.type,o=D(t,["className","type"]);return e.createElement("input",Object.assign({type:i,className:ot("flex h-12 w-full rounded-full border border-input bg-white/50 px-6 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[hsl(var(--primary))]/30 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 transition-all duration-300 md:text-sm",r),ref:n},o))});St.displayName="Input";var Et=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((t,n)=>{const r=ft(`Primitive.${n}`),i=e.forwardRef((e,t)=>{const{asChild:i,...o}=e,s=i?r:n;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),f(s,{...o,ref:t})});return i.displayName=`Primitive.${n}`,{...t,[n]:i}},{}),Ct="horizontal",Nt=["horizontal","vertical"],Ot=e.forwardRef((e,t)=>{const{decorative:n,orientation:r=Ct,...i}=e,o=function(e){return Nt.includes(e)}(r)?r:Ct,s=n?{role:"none"}:{"aria-orientation":"vertical"===o?o:void 0,role:"separator"};return f(Et.div,{"data-orientation":o,...s,...i,ref:t})});Ot.displayName="Separator";var At=Ot,Mt=e.forwardRef(function(t,n){var r=t.className,i=t.orientation,o=void 0===i?"horizontal":i,s=t.decorative,a=void 0===s||s,l=D(t,["className","orientation","decorative"]);return e.createElement(At,Object.assign({ref:n,decorative:a,orientation:o,className:ot("shrink-0 bg-border","horizontal"===o?"h-[1px] w-full":"h-full w-[1px]",r)},l))});function Tt(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),!1===n||!r.defaultPrevented)return t?.(r)}}function Rt(t,n=[]){let r=[];const i=()=>{const n=r.map(t=>e.createContext(t));return function(r){const i=r?.[t]||n;return e.useMemo(()=>({[`__scope${t}`]:{...r,[t]:i}}),[r,i])}};return i.scopeName=t,[function(n,i){const o=e.createContext(i),s=r.length;r=[...r,i];const a=n=>{const{scope:r,children:i,...a}=n,l=r?.[t]?.[s]||o,c=e.useMemo(()=>a,Object.values(a));return f(l.Provider,{value:c,children:i})};return a.displayName=n+"Provider",[a,function(r,a){const l=a?.[t]?.[s]||o,c=e.useContext(l);if(c)return c;if(void 0!==i)return i;throw new Error(`\`${r}\` must be used within \`${n}\``)}]},Dt(i,...n)]}function Dt(...t){const n=t[0];if(1===t.length)return n;const r=()=>{const r=t.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(t){const i=r.reduce((e,{useScope:n,scopeName:r})=>({...e,...n(t)[`__scope${r}`]}),{});return e.useMemo(()=>({[`__scope${n.scopeName}`]:i}),[i])}};return r.scopeName=n.scopeName,r}Mt.displayName=At.displayName;var Pt=globalThis?.document?e.useLayoutEffect:()=>{},Lt=e[" useId ".trim().toString()]||(()=>{}),It=0;function _t(t){const[n,r]=e.useState(Lt());return Pt(()=>{t||r(e=>e??String(It++))},[t]),t||(n?`radix-${n}`:"")}var Bt=e[" useInsertionEffect ".trim().toString()]||Pt;function Ft({prop:t,defaultProp:n,onChange:r=()=>{},caller:i}){const[o,s,a]=function({defaultProp:t,onChange:n}){const[r,i]=e.useState(t),o=e.useRef(r),s=e.useRef(n);return Bt(()=>{s.current=n},[n]),e.useEffect(()=>{o.current!==r&&(s.current?.(r),o.current=r)},[r,o]),[r,i,s]}({defaultProp:n,onChange:r}),l=void 0!==t,c=l?t:o;{const n=e.useRef(void 0!==t);e.useEffect(()=>{const e=n.current;if(e!==l){}n.current=l},[l,i])}const u=e.useCallback(e=>{if(l){const n=function(e){return"function"==typeof e}(e)?e(t):e;n!==t&&a.current?.(n)}else s(e)},[l,t,s,a]);return[c,u]}function jt(t){const n=Wt(t),r=e.forwardRef((t,r)=>{const{children:i,...o}=t,s=e.Children.toArray(i),a=s.find(Ht);if(a){const t=a.props.children,i=s.map(n=>n===a?e.Children.count(t)>1?e.Children.only(null):e.isValidElement(t)?t.props.children:null:n);return f(n,{...o,ref:r,children:e.isValidElement(t)?e.cloneElement(t,void 0,i):null})}return f(n,{...o,ref:r,children:i})});return r.displayName=`${t}.Slot`,r}function Wt(t){const n=e.forwardRef((t,n)=>{const{children:r,...i}=t;if(e.isValidElement(r)){const t=function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;if(n)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(r),o=function(e,t){const n={...t};for(const r in t){const i=e[r],o=t[r];/^on[A-Z]/.test(r)?i&&o?n[r]=(...e)=>{const t=o(...e);return i(...e),t}:i&&(n[r]=i):"style"===r?n[r]={...i,...o}:"className"===r&&(n[r]=[i,o].filter(Boolean).join(" "))}return{...e,...n}}(i,r.props);return r.type!==e.Fragment&&(o.ref=n?lt(n,t):t),e.cloneElement(r,o)}return e.Children.count(r)>1?e.Children.only(null):null});return n.displayName=`${t}.SlotClone`,n}var zt=Symbol("radix.slottable");function Ht(t){return e.isValidElement(t)&&"function"==typeof t.type&&"__radixId"in t.type&&t.type.__radixId===zt}var Vt=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((t,n)=>{const r=jt(`Primitive.${n}`),i=e.forwardRef((e,t)=>{const{asChild:i,...o}=e,s=i?r:n;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),f(s,{...o,ref:t})});return i.displayName=`Primitive.${n}`,{...t,[n]:i}},{});function qt(t){const n=e.useRef(t);return e.useEffect(()=>{n.current=t}),e.useMemo(()=>(...e)=>n.current?.(...e),[])}function Ut(t,n=globalThis?.document){const r=qt(t);e.useEffect(()=>{const e=e=>{"Escape"===e.key&&r(e)};return n.addEventListener("keydown",e,{capture:!0}),()=>n.removeEventListener("keydown",e,{capture:!0})},[r,n])}var $t,Kt="dismissableLayer.update",Yt="dismissableLayer.pointerDownOutside",Gt="dismissableLayer.focusOutside",Xt=e.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Jt=e.forwardRef((t,n)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:a,onDismiss:l,...c}=t,u=e.useContext(Xt),[h,d]=e.useState(null),p=h?.ownerDocument??globalThis?.document,[,m]=e.useState({}),g=ct(n,e=>d(e)),v=Array.from(u.layers),[b]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),y=v.indexOf(b),w=h?v.indexOf(h):-1,x=u.layersWithOutsidePointerEventsDisabled.size>0,k=w>=y,S=function(t,n=globalThis?.document){const r=qt(t),i=e.useRef(!1),o=e.useRef(()=>{});return e.useEffect(()=>{const e=e=>{if(e.target&&!i.current){let t=function(){Zt(Yt,r,i,{discrete:!0})};const i={originalEvent:e};"touch"===e.pointerType?(n.removeEventListener("click",o.current),o.current=t,n.addEventListener("click",o.current,{once:!0})):t()}else n.removeEventListener("click",o.current);i.current=!1},t=window.setTimeout(()=>{n.addEventListener("pointerdown",e)},0);return()=>{window.clearTimeout(t),n.removeEventListener("pointerdown",e),n.removeEventListener("click",o.current)}},[n,r]),{onPointerDownCapture:()=>i.current=!0}}(e=>{const t=e.target,n=[...u.branches].some(e=>e.contains(t));k&&!n&&(o?.(e),a?.(e),e.defaultPrevented||l?.())},p),E=function(t,n=globalThis?.document){const r=qt(t),i=e.useRef(!1);return e.useEffect(()=>{const e=e=>{if(e.target&&!i.current){Zt(Gt,r,{originalEvent:e},{discrete:!1})}};return n.addEventListener("focusin",e),()=>n.removeEventListener("focusin",e)},[n,r]),{onFocusCapture:()=>i.current=!0,onBlurCapture:()=>i.current=!1}}(e=>{const t=e.target;[...u.branches].some(e=>e.contains(t))||(s?.(e),a?.(e),e.defaultPrevented||l?.())},p);return Ut(e=>{w===u.layers.size-1&&(i?.(e),!e.defaultPrevented&&l&&(e.preventDefault(),l()))},p),e.useEffect(()=>{if(h)return r&&(0===u.layersWithOutsidePointerEventsDisabled.size&&($t=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(h)),u.layers.add(h),Qt(),()=>{r&&1===u.layersWithOutsidePointerEventsDisabled.size&&(p.body.style.pointerEvents=$t)}},[h,p,r,u]),e.useEffect(()=>()=>{h&&(u.layers.delete(h),u.layersWithOutsidePointerEventsDisabled.delete(h),Qt())},[h,u]),e.useEffect(()=>{const e=()=>m({});return document.addEventListener(Kt,e),()=>document.removeEventListener(Kt,e)},[]),f(Vt.div,{...c,ref:g,style:{pointerEvents:x?k?"auto":"none":void 0,...t.style},onFocusCapture:Tt(t.onFocusCapture,E.onFocusCapture),onBlurCapture:Tt(t.onBlurCapture,E.onBlurCapture),onPointerDownCapture:Tt(t.onPointerDownCapture,S.onPointerDownCapture)})});Jt.displayName="DismissableLayer";function Qt(){const e=new CustomEvent(Kt);document.dispatchEvent(e)}function Zt(e,t,n,{discrete:r}){const i=n.originalEvent.target,o=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?function(e,t){e&&g.flushSync(()=>e.dispatchEvent(t))}(i,o):i.dispatchEvent(o)}e.forwardRef((t,n)=>{const r=e.useContext(Xt),i=e.useRef(null),o=ct(n,i);return e.useEffect(()=>{const e=i.current;if(e)return r.branches.add(e),()=>{r.branches.delete(e)}},[r.branches]),f(Vt.div,{...t,ref:o})}).displayName="DismissableLayerBranch";var en="focusScope.autoFocusOnMount",tn="focusScope.autoFocusOnUnmount",nn={bubbles:!1,cancelable:!0},rn=e.forwardRef((t,n)=>{const{loop:r=!1,trapped:i=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...a}=t,[l,c]=e.useState(null),u=qt(o),h=qt(s),d=e.useRef(null),p=ct(n,e=>c(e)),m=e.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;e.useEffect(()=>{if(i){let e=function(e){if(m.paused||!l)return;const t=e.target;l.contains(t)?d.current=t:ln(d.current,{select:!0})},t=function(e){if(m.paused||!l)return;const t=e.relatedTarget;null!==t&&(l.contains(t)||ln(d.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(const t of e)t.removedNodes.length>0&&ln(l)};document.addEventListener("focusin",e),document.addEventListener("focusout",t);const r=new MutationObserver(n);return l&&r.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",e),document.removeEventListener("focusout",t),r.disconnect()}}},[i,l,m.paused]),e.useEffect(()=>{if(l){cn.add(m);const t=document.activeElement;if(!l.contains(t)){const n=new CustomEvent(en,nn);l.addEventListener(en,u),l.dispatchEvent(n),n.defaultPrevented||(!function(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(ln(r,{select:t}),document.activeElement!==n)return}((e=on(l),e.filter(e=>"A"!==e.tagName)),{select:!0}),document.activeElement===t&&ln(l))}return()=>{l.removeEventListener(en,u),setTimeout(()=>{const e=new CustomEvent(tn,nn);l.addEventListener(tn,h),l.dispatchEvent(e),e.defaultPrevented||ln(t??document.body,{select:!0}),l.removeEventListener(tn,h),cn.remove(m)},0)}}var e},[l,u,h,m]);const g=e.useCallback(e=>{if(!r&&!i)return;if(m.paused)return;const t="Tab"===e.key&&!e.altKey&&!e.ctrlKey&&!e.metaKey,n=document.activeElement;if(t&&n){const t=e.currentTarget,[i,o]=function(e){const t=on(e),n=sn(t,e),r=sn(t.reverse(),e);return[n,r]}(t);i&&o?e.shiftKey||n!==o?e.shiftKey&&n===i&&(e.preventDefault(),r&&ln(o,{select:!0})):(e.preventDefault(),r&&ln(i,{select:!0})):n===t&&e.preventDefault()}},[r,i,m.paused]);return f(Vt.div,{tabIndex:-1,...a,ref:p,onKeyDown:g})});function on(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{const t="INPUT"===e.tagName&&"hidden"===e.type;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function sn(e,t){for(const n of e)if(!an(n,{upTo:t}))return n}function an(e,{upTo:t}){if("hidden"===getComputedStyle(e).visibility)return!0;for(;e;){if(void 0!==t&&e===t)return!1;if("none"===getComputedStyle(e).display)return!0;e=e.parentElement}return!1}function ln(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&function(e){return e instanceof HTMLInputElement&&"select"in e}(e)&&t&&e.select()}}rn.displayName="FocusScope";var cn=function(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=un(e,t),e.unshift(t)},remove(t){e=un(e,t),e[0]?.resume()}}}();function un(e,t){const n=[...e],r=n.indexOf(t);return-1!==r&&n.splice(r,1),n}var hn=e.forwardRef((t,n)=>{const{container:r,...i}=t,[o,s]=e.useState(!1);Pt(()=>s(!0),[]);const a=r||o&&globalThis?.document?.body;return a?v.createPortal(f(Vt.div,{...i,ref:n}),a):null});hn.displayName="Portal";var dn=t=>{const{present:n,children:r}=t,i=function(t){const[n,r]=e.useState(),i=e.useRef(null),o=e.useRef(t),s=e.useRef("none"),a=t?"mounted":"unmounted",[l,c]=function(t,n){return e.useReducer((e,t)=>n[e][t]??e,t)}(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return e.useEffect(()=>{const e=fn(i.current);s.current="mounted"===l?e:"none"},[l]),Pt(()=>{const e=i.current,n=o.current;if(n!==t){const r=s.current,i=fn(e);if(t)c("MOUNT");else if("none"===i||"none"===e?.display)c("UNMOUNT");else{c(n&&r!==i?"ANIMATION_OUT":"UNMOUNT")}o.current=t}},[t,c]),Pt(()=>{if(n){let e;const t=n.ownerDocument.defaultView??window,r=r=>{const s=fn(i.current).includes(CSS.escape(r.animationName));if(r.target===n&&s&&(c("ANIMATION_END"),!o.current)){const r=n.style.animationFillMode;n.style.animationFillMode="forwards",e=t.setTimeout(()=>{"forwards"===n.style.animationFillMode&&(n.style.animationFillMode=r)})}},a=e=>{e.target===n&&(s.current=fn(i.current))};return n.addEventListener("animationstart",a),n.addEventListener("animationcancel",r),n.addEventListener("animationend",r),()=>{t.clearTimeout(e),n.removeEventListener("animationstart",a),n.removeEventListener("animationcancel",r),n.removeEventListener("animationend",r)}}c("ANIMATION_END")},[n,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:e.useCallback(e=>{i.current=e?getComputedStyle(e):null,r(e)},[])}}(n),o="function"==typeof r?r({present:i.isPresent}):e.Children.only(r),s=ct(i.ref,function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;if(n)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(o));return"function"==typeof r||i.isPresent?e.cloneElement(o,{ref:s}):null};function fn(e){return e?.animationName||"none"}dn.displayName="Presence";var pn=0;function mn(){e.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??gn()),document.body.insertAdjacentElement("beforeend",e[1]??gn()),pn++,()=>{1===pn&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),pn--}},[])}function gn(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var vn="right-scroll-bar-position",bn="width-before-scroll-bar";function yn(e,t){return"function"==typeof e?e(t):e&&(e.current=t),e}var wn="undefined"!=typeof window?e.useLayoutEffect:e.useEffect,xn=new WeakMap;function kn(e,t){var n,r,o,s=(n=t||null,r=function(t){return e.forEach(function(e){return yn(e,t)})},(o=i(function(){return{value:n,callback:r,facade:{get current(){return o.value},set current(e){var t=o.value;t!==e&&(o.value=e,o.callback(e,t))}}}})[0]).callback=r,o.facade);return wn(function(){var t=xn.get(s);if(t){var n=new Set(t),r=new Set(e),i=s.current;n.forEach(function(e){r.has(e)||yn(e,null)}),r.forEach(function(e){n.has(e)||yn(e,i)})}xn.set(s,e)},[e]),s}function Sn(e){return e}var En=function(t){var n=t.sideCar,r=D(t,["sideCar"]);if(!n)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var i=n.read();if(!i)throw new Error("Sidecar medium not found");return e.createElement(i,R({},r))};En.isSideCarExport=!0;var Cn=function(e){void 0===e&&(e={});var t=function(e,t){void 0===t&&(t=Sn);var n=[],r=!1;return{read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var i=t(e,r);return n.push(i),function(){n=n.filter(function(e){return e!==i})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var i=n;n=[],i.forEach(e),t=n}var o=function(){var n=t;t=[],n.forEach(e)},s=function(){return Promise.resolve().then(o)};s(),n={push:function(e){t.push(e),s()},filter:function(e){return t=t.filter(e),n}}}}}(null);return t.options=R({async:!0,ssr:!1},e),t}(),Nn=function(){},On=e.forwardRef(function(t,n){var r=e.useRef(null),i=e.useState({onScrollCapture:Nn,onWheelCapture:Nn,onTouchMoveCapture:Nn}),o=i[0],s=i[1],a=t.forwardProps,l=t.children,c=t.className,u=t.removeScrollBar,h=t.enabled,d=t.shards,f=t.sideCar,p=t.noRelative,m=t.noIsolation,g=t.inert,v=t.allowPinchZoom,b=t.as,y=void 0===b?"div":b,w=t.gapMode,x=D(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),k=f,S=kn([r,n]),E=R(R({},x),o);return e.createElement(e.Fragment,null,h&&e.createElement(k,{sideCar:Cn,removeScrollBar:u,shards:d,noRelative:p,noIsolation:m,inert:g,setCallbacks:s,allowPinchZoom:!!v,lockRef:r,gapMode:w}),a?e.cloneElement(e.Children.only(l),R(R({},E),{ref:S})):e.createElement(y,R({},E,{className:c,ref:S}),l))});On.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},On.classNames={fullWidth:bn,zeroRight:vn};function An(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=function(){if("undefined"!=typeof __webpack_nonce__)return __webpack_nonce__}();return t&&e.setAttribute("nonce",t),e}var Mn=function(){var e=0,t=null;return{add:function(n){var r,i;0==e&&(t=An())&&(i=n,(r=t).styleSheet?r.styleSheet.cssText=i:r.appendChild(document.createTextNode(i)),function(e){(document.head||document.getElementsByTagName("head")[0]).appendChild(e)}(t)),e++},remove:function(){! --e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Tn=function(){var t,n=(t=Mn(),function(n,r){e.useEffect(function(){return t.add(n),function(){t.remove()}},[n&&r])});return function(e){var t=e.styles,r=e.dynamic;return n(t,r),null}},Rn={left:0,top:0,right:0,gap:0},Dn=function(e){return parseInt(e||"",10)||0},Pn=function(e){if(void 0===e&&(e="margin"),"undefined"==typeof window)return Rn;var t=function(e){var t=window.getComputedStyle(document.body),n=t["padding"===e?"paddingLeft":"marginLeft"],r=t["padding"===e?"paddingTop":"marginTop"],i=t["padding"===e?"paddingRight":"marginRight"];return[Dn(n),Dn(r),Dn(i)]}(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},Ln=Tn(),In="data-scroll-locked",_n=function(e,t,n,r){var i=e.left,o=e.top,s=e.right,a=e.gap;return void 0===n&&(n="margin"),"\n .".concat("with-scroll-bars-hidden"," {\n overflow: hidden ").concat(r,";\n padding-right: ").concat(a,"px ").concat(r,";\n }\n body[").concat(In,"] {\n overflow: hidden ").concat(r,";\n overscroll-behavior: contain;\n ").concat([t&&"position: relative ".concat(r,";"),"margin"===n&&"\n padding-left: ".concat(i,"px;\n padding-top: ").concat(o,"px;\n padding-right: ").concat(s,"px;\n margin-left:0;\n margin-top:0;\n margin-right: ").concat(a,"px ").concat(r,";\n "),"padding"===n&&"padding-right: ".concat(a,"px ").concat(r,";")].filter(Boolean).join(""),"\n }\n \n .").concat(vn," {\n right: ").concat(a,"px ").concat(r,";\n }\n \n .").concat(bn," {\n margin-right: ").concat(a,"px ").concat(r,";\n }\n \n .").concat(vn," .").concat(vn," {\n right: 0 ").concat(r,";\n }\n \n .").concat(bn," .").concat(bn," {\n margin-right: 0 ").concat(r,";\n }\n \n body[").concat(In,"] {\n ").concat("--removed-body-scroll-bar-size",": ").concat(a,"px;\n }\n")},Bn=function(){var e=parseInt(document.body.getAttribute(In)||"0",10);return isFinite(e)?e:0},Fn=function(t){var n=t.noRelative,r=t.noImportant,i=t.gapMode,o=void 0===i?"margin":i;e.useEffect(function(){return document.body.setAttribute(In,(Bn()+1).toString()),function(){var e=Bn()-1;e<=0?document.body.removeAttribute(In):document.body.setAttribute(In,e.toString())}},[]);var s=e.useMemo(function(){return Pn(o)},[o]);return e.createElement(Ln,{styles:_n(s,!n,o,r?"":"!important")})},jn=!1;if("undefined"!=typeof window)try{var Wn=Object.defineProperty({},"passive",{get:function(){return jn=!0,!0}});window.addEventListener("test",Wn,Wn),window.removeEventListener("test",Wn,Wn)}catch(e){jn=!1}var zn=!!jn&&{passive:!1},Hn=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return"hidden"!==n[t]&&!(n.overflowY===n.overflowX&&!function(e){return"TEXTAREA"===e.tagName}(e)&&"visible"===n[t])},Vn=function(e,t){var n=t.ownerDocument,r=t;do{if("undefined"!=typeof ShadowRoot&&r instanceof ShadowRoot&&(r=r.host),qn(e,r)){var i=Un(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},qn=function(e,t){return"v"===e?function(e){return Hn(e,"overflowY")}(t):function(e){return Hn(e,"overflowX")}(t)},Un=function(e,t){return"v"===e?function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]}(t):function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]}(t)},$n=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Kn=function(e){return[e.deltaX,e.deltaY]},Yn=function(e){return e&&"current"in e?e.current:e},Gn=function(e){return"\n .block-interactivity-".concat(e," {pointer-events: none;}\n .allow-interactivity-").concat(e," {pointer-events: all;}\n")},Xn=0,Jn=[];function Qn(e){for(var t=null;null!==e;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var Zn,er=(Zn=function(t){var n=e.useRef([]),r=e.useRef([0,0]),i=e.useRef(),o=e.useState(Xn++)[0],s=e.useState(Tn)[0],a=e.useRef(t);e.useEffect(function(){a.current=t},[t]),e.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(o));var e=function(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}([t.lockRef.current],(t.shards||[]).map(Yn),!0).filter(Boolean);return e.forEach(function(e){return e.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),e.forEach(function(e){return e.classList.remove("allow-interactivity-".concat(o))})}}},[t.inert,t.lockRef.current,t.shards]);var l=e.useCallback(function(e,t){if("touches"in e&&2===e.touches.length||"wheel"===e.type&&e.ctrlKey)return!a.current.allowPinchZoom;var n,o=$n(e),s=r.current,l="deltaX"in e?e.deltaX:s[0]-o[0],c="deltaY"in e?e.deltaY:s[1]-o[1],u=e.target,h=Math.abs(l)>Math.abs(c)?"h":"v";if("touches"in e&&"h"===h&&"range"===u.type)return!1;var d=window.getSelection(),f=d&&d.anchorNode;if(f&&(f===u||f.contains(u)))return!1;var p=Vn(h,u);if(!p)return!0;if(p?n=h:(n="v"===h?"h":"v",p=Vn(h,u)),!p)return!1;if(!i.current&&"changedTouches"in e&&(l||c)&&(i.current=n),!n)return!0;var m=i.current||n;return function(e,t,n,r,i){var o=function(e,t){return"h"===e&&"rtl"===t?-1:1}(e,window.getComputedStyle(t).direction),s=o*r,a=n.target,l=t.contains(a),c=!1,u=s>0,h=0,d=0;do{if(!a)break;var f=Un(e,a),p=f[0],m=f[1]-f[2]-o*p;(p||m)&&qn(e,a)&&(h+=m,d+=p);var g=a.parentNode;a=g&&g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.host:g}while(!l&&a!==document.body||l&&(t.contains(a)||t===a));return(u&&(i&&Math.abs(h)<1||!i&&s>h)||!u&&(i&&Math.abs(d)<1||!i&&-s>d))&&(c=!0),c}(m,t,e,"h"===m?l:c,!0)},[]),c=e.useCallback(function(e){var t=e;if(Jn.length&&Jn[Jn.length-1]===s){var r="deltaY"in t?Kn(t):$n(t),i=n.current.filter(function(e){return e.name===t.type&&(e.target===t.target||t.target===e.shadowParent)&&(n=e.delta,i=r,n[0]===i[0]&&n[1]===i[1]);var n,i})[0];if(i&&i.should)t.cancelable&&t.preventDefault();else if(!i){var o=(a.current.shards||[]).map(Yn).filter(Boolean).filter(function(e){return e.contains(t.target)});(o.length>0?l(t,o[0]):!a.current.noIsolation)&&t.cancelable&&t.preventDefault()}}},[]),u=e.useCallback(function(e,t,r,i){var o={name:e,delta:t,target:r,should:i,shadowParent:Qn(r)};n.current.push(o),setTimeout(function(){n.current=n.current.filter(function(e){return e!==o})},1)},[]),h=e.useCallback(function(e){r.current=$n(e),i.current=void 0},[]),d=e.useCallback(function(e){u(e.type,Kn(e),e.target,l(e,t.lockRef.current))},[]),f=e.useCallback(function(e){u(e.type,$n(e),e.target,l(e,t.lockRef.current))},[]);e.useEffect(function(){return Jn.push(s),t.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener("wheel",c,zn),document.addEventListener("touchmove",c,zn),document.addEventListener("touchstart",h,zn),function(){Jn=Jn.filter(function(e){return e!==s}),document.removeEventListener("wheel",c,zn),document.removeEventListener("touchmove",c,zn),document.removeEventListener("touchstart",h,zn)}},[]);var p=t.removeScrollBar,m=t.inert;return e.createElement(e.Fragment,null,m?e.createElement(s,{styles:Gn(o)}):null,p?e.createElement(Fn,{noRelative:t.noRelative,gapMode:t.gapMode}):null)},Cn.useMedium(Zn),En),tr=e.forwardRef(function(t,n){return e.createElement(On,R({},t,{ref:n,sideCar:er}))});tr.classNames=On.classNames;var nr=tr,rr=new WeakMap,ir=new WeakMap,or={},sr=0,ar=function(e){return e&&(e.host||ar(e.parentNode))},lr=function(e,t,n,r){var i=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=ar(t);return n&&e.contains(n)?n:null}).filter(function(e){return Boolean(e)})}(t,Array.isArray(e)?e:[e]);or[n]||(or[n]=new WeakMap);var o=or[n],s=[],a=new Set,l=new Set(i),c=function(e){e&&!a.has(e)&&(a.add(e),c(e.parentNode))};i.forEach(c);var u=function(e){e&&!l.has(e)&&Array.prototype.forEach.call(e.children,function(e){if(a.has(e))u(e);else try{var t=e.getAttribute(r),i=null!==t&&"false"!==t,l=(rr.get(e)||0)+1,c=(o.get(e)||0)+1;rr.set(e,l),o.set(e,c),s.push(e),1===l&&i&&ir.set(e,!0),1===c&&e.setAttribute(n,"true"),i||e.setAttribute(r,"true")}catch(e){}})};return u(t),a.clear(),sr++,function(){s.forEach(function(e){var t=rr.get(e)-1,i=o.get(e)-1;rr.set(e,t),o.set(e,i),t||(ir.has(e)||e.removeAttribute(r),ir.delete(e)),i||e.removeAttribute(n)}),--sr||(rr=new WeakMap,rr=new WeakMap,ir=new WeakMap,or={})}},cr=function(e,t,n){void 0===n&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),i=t||function(e){return"undefined"==typeof document?null:(Array.isArray(e)?e[0]:e).ownerDocument.body}(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll("[aria-live], script"))),lr(r,i,n,"aria-hidden")):function(){return null}},ur="Dialog",[hr,dr]=Rt(ur),[fr,pr]=hr(ur),mr=t=>{const{__scopeDialog:n,children:r,open:i,defaultOpen:o,onOpenChange:s,modal:a=!0}=t,l=e.useRef(null),c=e.useRef(null),[u,h]=Ft({prop:i,defaultProp:o??!1,onChange:s,caller:ur});return f(fr,{scope:n,triggerRef:l,contentRef:c,contentId:_t(),titleId:_t(),descriptionId:_t(),open:u,onOpenChange:h,onOpenToggle:e.useCallback(()=>h(e=>!e),[h]),modal:a,children:r})};mr.displayName=ur;var gr="DialogTrigger",vr=e.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=pr(gr,n),o=ct(t,i.triggerRef);return f(Vt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":Br(i.open),...r,ref:o,onClick:Tt(e.onClick,i.onOpenToggle)})});vr.displayName=gr;var br="DialogPortal",[yr,wr]=hr(br,{forceMount:void 0}),xr=t=>{const{__scopeDialog:n,forceMount:r,children:i,container:o}=t,s=pr(br,n);return f(yr,{scope:n,forceMount:r,children:e.Children.map(i,e=>f(dn,{present:r||s.open,children:f(hn,{asChild:!0,container:o,children:e})}))})};xr.displayName=br;var kr="DialogOverlay",Sr=e.forwardRef((e,t)=>{const n=wr(kr,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,o=pr(kr,e.__scopeDialog);return o.modal?f(dn,{present:r||o.open,children:f(Cr,{...i,ref:t})}):null});Sr.displayName=kr;var Er=jt("DialogOverlay.RemoveScroll"),Cr=e.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=pr(kr,n);return f(nr,{as:Er,allowPinchZoom:!0,shards:[i.contentRef],children:f(Vt.div,{"data-state":Br(i.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),Nr="DialogContent",Or=e.forwardRef((e,t)=>{const n=wr(Nr,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,o=pr(Nr,e.__scopeDialog);return f(dn,{present:r||o.open,children:o.modal?f(Ar,{...i,ref:t}):f(Mr,{...i,ref:t})})});Or.displayName=Nr;var Ar=e.forwardRef((t,n)=>{const r=pr(Nr,t.__scopeDialog),i=e.useRef(null),o=ct(n,r.contentRef,i);return e.useEffect(()=>{const e=i.current;if(e)return cr(e)},[]),f(Tr,{...t,ref:o,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Tt(t.onCloseAutoFocus,e=>{e.preventDefault(),r.triggerRef.current?.focus()}),onPointerDownOutside:Tt(t.onPointerDownOutside,e=>{const t=e.detail.originalEvent,n=0===t.button&&!0===t.ctrlKey;(2===t.button||n)&&e.preventDefault()}),onFocusOutside:Tt(t.onFocusOutside,e=>e.preventDefault())})}),Mr=e.forwardRef((t,n)=>{const r=pr(Nr,t.__scopeDialog),i=e.useRef(!1),o=e.useRef(!1);return f(Tr,{...t,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:e=>{t.onCloseAutoFocus?.(e),e.defaultPrevented||(i.current||r.triggerRef.current?.focus(),e.preventDefault()),i.current=!1,o.current=!1},onInteractOutside:e=>{t.onInteractOutside?.(e),e.defaultPrevented||(i.current=!0,"pointerdown"===e.detail.originalEvent.type&&(o.current=!0));const n=e.target,s=r.triggerRef.current?.contains(n);s&&e.preventDefault(),"focusin"===e.detail.originalEvent.type&&o.current&&e.preventDefault()}})}),Tr=e.forwardRef((t,n)=>{const{__scopeDialog:r,trapFocus:i,onOpenAutoFocus:o,onCloseAutoFocus:s,...a}=t,l=pr(Nr,r),c=e.useRef(null),u=ct(n,c);return mn(),p(m,{children:[f(rn,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:o,onUnmountAutoFocus:s,children:f(Jt,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":Br(l.open),...a,ref:u,onDismiss:()=>l.onOpenChange(!1)})}),p(m,{children:[f(zr,{titleId:l.titleId}),f(Hr,{contentRef:c,descriptionId:l.descriptionId})]})]})}),Rr="DialogTitle",Dr=e.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=pr(Rr,n);return f(Vt.h2,{id:i.titleId,...r,ref:t})});Dr.displayName=Rr;var Pr="DialogDescription",Lr=e.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=pr(Pr,n);return f(Vt.p,{id:i.descriptionId,...r,ref:t})});Lr.displayName=Pr;var Ir="DialogClose",_r=e.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=pr(Ir,n);return f(Vt.button,{type:"button",...r,ref:t,onClick:Tt(e.onClick,()=>i.onOpenChange(!1))})});function Br(e){return e?"open":"closed"}_r.displayName=Ir;var Fr="DialogTitleWarning",[jr,Wr]=function(t,n){const r=e.createContext(n),i=t=>{const{children:n,...i}=t,o=e.useMemo(()=>i,Object.values(i));return f(r.Provider,{value:o,children:n})};return i.displayName=t+"Provider",[i,function(i){const o=e.useContext(r);if(o)return o;if(void 0!==n)return n;throw new Error(`\`${i}\` must be used within \`${t}\``)}]}(Fr,{contentName:Nr,titleName:Rr,docsSlug:"dialog"}),zr=({titleId:t})=>{const n=Wr(Fr),r=`\`${n.contentName}\` requires a \`${n.titleName}\` for the component to be accessible for screen reader users.\n\nIf you want to hide the \`${n.titleName}\`, you can wrap it with our VisuallyHidden component.\n\nFor more information, see https://radix-ui.com/primitives/docs/components/${n.docsSlug}`;return e.useEffect(()=>{if(t){document.getElementById(t)}},[r,t]),null},Hr=({contentRef:t,descriptionId:n})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Wr("DialogDescriptionWarning").contentName}}.`;return e.useEffect(()=>{const e=t.current?.getAttribute("aria-describedby");if(n&&e){document.getElementById(n)}},[r,t,n]),null},Vr=mr,qr=vr,Ur=xr,$r=Sr,Kr=Or,Yr=Dr,Gr=Lr,Xr=_r,Jr=Vr,Qr=Ur,Zr=e.forwardRef(function(t,n){var r=t.className,i=D(t,["className"]);return e.createElement($r,Object.assign({className:ot("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",r)},i,{ref:n}))});Zr.displayName=$r.displayName;var ei=wt("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),ti=e.forwardRef(function(t,n){var r=t.side,i=void 0===r?"right":r,o=t.className,s=t.children,a=D(t,["side","className","children"]);return e.createElement(Qr,null,e.createElement(Zr,null),e.createElement(Kr,Object.assign({ref:n,className:ot(ei({side:i}),o)},a),s,e.createElement(Xr,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary"},e.createElement(ue,{className:"h-4 w-4"}),e.createElement("span",{className:"sr-only"},"Close"))))});ti.displayName=Kr.displayName;var ni=function(t){var n=t.className,r=D(t,["className"]);return e.createElement("div",Object.assign({className:ot("flex flex-col space-y-2 text-center sm:text-left",n)},r))};ni.displayName="SheetHeader";var ri=e.forwardRef(function(t,n){var r=t.className,i=D(t,["className"]);return e.createElement(Yr,Object.assign({ref:n,className:ot("text-lg font-semibold text-foreground",r)},i))});ri.displayName=Yr.displayName;var ii=e.forwardRef(function(t,n){var r=t.className,i=D(t,["className"]);return e.createElement(Gr,Object.assign({ref:n,className:ot("text-sm text-muted-foreground",r)},i))});function oi(t){const n=e.forwardRef((t,n)=>{const{children:r,...i}=t;if(e.isValidElement(r)){const t=function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;if(n)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(r),o=function(e,t){const n={...t};for(const r in t){const i=e[r],o=t[r];/^on[A-Z]/.test(r)?i&&o?n[r]=(...e)=>{const t=o(...e);return i(...e),t}:i&&(n[r]=i):"style"===r?n[r]={...i,...o}:"className"===r&&(n[r]=[i,o].filter(Boolean).join(" "))}return{...e,...n}}(i,r.props);return r.type!==e.Fragment&&(o.ref=n?lt(n,t):t),e.cloneElement(r,o)}return e.Children.count(r)>1?e.Children.only(null):null});return n.displayName=`${t}.SlotClone`,n}ii.displayName=Gr.displayName;var si=Symbol("radix.slottable");function ai(t){return e.isValidElement(t)&&"function"==typeof t.type&&"__radixId"in t.type&&t.type.__radixId===si}var li=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((t,n)=>{const r=function(t){const n=oi(t),r=e.forwardRef((t,r)=>{const{children:i,...o}=t,s=e.Children.toArray(i),a=s.find(ai);if(a){const t=a.props.children,i=s.map(n=>n===a?e.Children.count(t)>1?e.Children.only(null):e.isValidElement(t)?t.props.children:null:n);return f(n,{...o,ref:r,children:e.isValidElement(t)?e.cloneElement(t,void 0,i):null})}return f(n,{...o,ref:r,children:i})});return r.displayName=`${t}.Slot`,r}(`Primitive.${n}`),i=e.forwardRef((e,t)=>{const{asChild:i,...o}=e,s=i?r:n;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),f(s,{...o,ref:t})});return i.displayName=`Primitive.${n}`,{...t,[n]:i}},{});var ci,ui="dismissableLayer.update",hi="dismissableLayer.pointerDownOutside",di="dismissableLayer.focusOutside",fi=e.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),pi=e.forwardRef((t,n)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:a,onDismiss:l,...c}=t,u=e.useContext(fi),[h,d]=e.useState(null),p=h?.ownerDocument??globalThis?.document,[,m]=e.useState({}),g=ct(n,e=>d(e)),v=Array.from(u.layers),[b]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),y=v.indexOf(b),w=h?v.indexOf(h):-1,x=u.layersWithOutsidePointerEventsDisabled.size>0,k=w>=y,S=function(t,n=globalThis?.document){const r=qt(t),i=e.useRef(!1),o=e.useRef(()=>{});return e.useEffect(()=>{const e=e=>{if(e.target&&!i.current){let t=function(){gi(hi,r,i,{discrete:!0})};const i={originalEvent:e};"touch"===e.pointerType?(n.removeEventListener("click",o.current),o.current=t,n.addEventListener("click",o.current,{once:!0})):t()}else n.removeEventListener("click",o.current);i.current=!1},t=window.setTimeout(()=>{n.addEventListener("pointerdown",e)},0);return()=>{window.clearTimeout(t),n.removeEventListener("pointerdown",e),n.removeEventListener("click",o.current)}},[n,r]),{onPointerDownCapture:()=>i.current=!0}}(e=>{const t=e.target,n=[...u.branches].some(e=>e.contains(t));k&&!n&&(o?.(e),a?.(e),e.defaultPrevented||l?.())},p),E=function(t,n=globalThis?.document){const r=qt(t),i=e.useRef(!1);return e.useEffect(()=>{const e=e=>{if(e.target&&!i.current){gi(di,r,{originalEvent:e},{discrete:!1})}};return n.addEventListener("focusin",e),()=>n.removeEventListener("focusin",e)},[n,r]),{onFocusCapture:()=>i.current=!0,onBlurCapture:()=>i.current=!1}}(e=>{const t=e.target;[...u.branches].some(e=>e.contains(t))||(s?.(e),a?.(e),e.defaultPrevented||l?.())},p);return Ut(e=>{w===u.layers.size-1&&(i?.(e),!e.defaultPrevented&&l&&(e.preventDefault(),l()))},p),e.useEffect(()=>{if(h)return r&&(0===u.layersWithOutsidePointerEventsDisabled.size&&(ci=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(h)),u.layers.add(h),mi(),()=>{r&&1===u.layersWithOutsidePointerEventsDisabled.size&&(p.body.style.pointerEvents=ci)}},[h,p,r,u]),e.useEffect(()=>()=>{h&&(u.layers.delete(h),u.layersWithOutsidePointerEventsDisabled.delete(h),mi())},[h,u]),e.useEffect(()=>{const e=()=>m({});return document.addEventListener(ui,e),()=>document.removeEventListener(ui,e)},[]),f(li.div,{...c,ref:g,style:{pointerEvents:x?k?"auto":"none":void 0,...t.style},onFocusCapture:Tt(t.onFocusCapture,E.onFocusCapture),onBlurCapture:Tt(t.onBlurCapture,E.onBlurCapture),onPointerDownCapture:Tt(t.onPointerDownCapture,S.onPointerDownCapture)})});pi.displayName="DismissableLayer";function mi(){const e=new CustomEvent(ui);document.dispatchEvent(e)}function gi(e,t,n,{discrete:r}){const i=n.originalEvent.target,o=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?function(e,t){e&&g.flushSync(()=>e.dispatchEvent(t))}(i,o):i.dispatchEvent(o)}e.forwardRef((t,n)=>{const r=e.useContext(fi),i=e.useRef(null),o=ct(n,i);return e.useEffect(()=>{const e=i.current;if(e)return r.branches.add(e),()=>{r.branches.delete(e)}},[r.branches]),f(li.div,{...t,ref:o})}).displayName="DismissableLayerBranch";const vi=["top","right","bottom","left"],bi=Math.min,yi=Math.max,wi=Math.round,xi=Math.floor,ki=e=>({x:e,y:e}),Si={left:"right",right:"left",bottom:"top",top:"bottom"},Ei={start:"end",end:"start"};function Ci(e,t,n){return yi(e,bi(t,n))}function Ni(e,t){return"function"==typeof e?e(t):e}function Oi(e){return e.split("-")[0]}function Ai(e){return e.split("-")[1]}function Mi(e){return"x"===e?"y":"x"}function Ti(e){return"y"===e?"height":"width"}const Ri=new Set(["top","bottom"]);function Di(e){return Ri.has(Oi(e))?"y":"x"}function Pi(e){return Mi(Di(e))}function Li(e){return e.replace(/start|end/g,e=>Ei[e])}const Ii=["left","right"],_i=["right","left"],Bi=["top","bottom"],Fi=["bottom","top"];function ji(e,t,n,r){const i=Ai(e);let o=function(e,t,n){switch(e){case"top":case"bottom":return n?t?_i:Ii:t?Ii:_i;case"left":case"right":return t?Bi:Fi;default:return[]}}(Oi(e),"start"===n,r);return i&&(o=o.map(e=>e+"-"+i),t&&(o=o.concat(o.map(Li)))),o}function Wi(e){return e.replace(/left|right|bottom|top/g,e=>Si[e])}function zi(e){return"number"!=typeof e?function(e){return{top:0,right:0,bottom:0,left:0,...e}}(e):{top:e,right:e,bottom:e,left:e}}function Hi(e){const{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function Vi(e,t,n){let{reference:r,floating:i}=e;const o=Di(t),s=Pi(t),a=Ti(s),l=Oi(t),c="y"===o,u=r.x+r.width/2-i.width/2,h=r.y+r.height/2-i.height/2,d=r[a]/2-i[a]/2;let f;switch(l){case"top":f={x:u,y:r.y-i.height};break;case"bottom":f={x:u,y:r.y+r.height};break;case"right":f={x:r.x+r.width,y:h};break;case"left":f={x:r.x-i.width,y:h};break;default:f={x:r.x,y:r.y}}switch(Ai(t)){case"start":f[s]-=d*(n&&c?-1:1);break;case"end":f[s]+=d*(n&&c?-1:1)}return f}async function qi(e,t){var n;void 0===t&&(t={});const{x:r,y:i,platform:o,rects:s,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:h="floating",altBoundary:d=!1,padding:f=0}=Ni(t,e),p=zi(f),m=a[d?"floating"===h?"reference":"floating":h],g=Hi(await o.getClippingRect({element:null==(n=await(null==o.isElement?void 0:o.isElement(m)))||n?m:m.contextElement||await(null==o.getDocumentElement?void 0:o.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),v="floating"===h?{x:r,y:i,width:s.floating.width,height:s.floating.height}:s.reference,b=await(null==o.getOffsetParent?void 0:o.getOffsetParent(a.floating)),y=await(null==o.isElement?void 0:o.isElement(b))&&await(null==o.getScale?void 0:o.getScale(b))||{x:1,y:1},w=Hi(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:v,offsetParent:b,strategy:l}):v);return{top:(g.top-w.top+p.top)/y.y,bottom:(w.bottom-g.bottom+p.bottom)/y.y,left:(g.left-w.left+p.left)/y.x,right:(w.right-g.right+p.right)/y.x}}function Ui(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function $i(e){return vi.some(t=>e[t]>=0)}const Ki=new Set(["left","top"]);function Yi(){return"undefined"!=typeof window}function Gi(e){return Qi(e)?(e.nodeName||"").toLowerCase():"#document"}function Xi(e){var t;return(null==e||null==(t=e.ownerDocument)?void 0:t.defaultView)||window}function Ji(e){var t;return null==(t=(Qi(e)?e.ownerDocument:e.document)||window.document)?void 0:t.documentElement}function Qi(e){return!!Yi()&&(e instanceof Node||e instanceof Xi(e).Node)}function Zi(e){return!!Yi()&&(e instanceof Element||e instanceof Xi(e).Element)}function eo(e){return!!Yi()&&(e instanceof HTMLElement||e instanceof Xi(e).HTMLElement)}function to(e){return!(!Yi()||"undefined"==typeof ShadowRoot)&&(e instanceof ShadowRoot||e instanceof Xi(e).ShadowRoot)}const no=new Set(["inline","contents"]);function ro(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=go(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!no.has(i)}const io=new Set(["table","td","th"]);function oo(e){return io.has(Gi(e))}const so=[":popover-open",":modal"];function ao(e){return so.some(t=>{try{return e.matches(t)}catch(e){return!1}})}const lo=["transform","translate","scale","rotate","perspective"],co=["transform","translate","scale","rotate","perspective","filter"],uo=["paint","layout","strict","content"];function ho(e){const t=fo(),n=Zi(e)?go(e):e;return lo.some(e=>!!n[e]&&"none"!==n[e])||!!n.containerType&&"normal"!==n.containerType||!t&&!!n.backdropFilter&&"none"!==n.backdropFilter||!t&&!!n.filter&&"none"!==n.filter||co.some(e=>(n.willChange||"").includes(e))||uo.some(e=>(n.contain||"").includes(e))}function fo(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}const po=new Set(["html","body","#document"]);function mo(e){return po.has(Gi(e))}function go(e){return Xi(e).getComputedStyle(e)}function vo(e){return Zi(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function bo(e){if("html"===Gi(e))return e;const t=e.assignedSlot||e.parentNode||to(e)&&e.host||Ji(e);return to(t)?t.host:t}function yo(e){const t=bo(e);return mo(t)?e.ownerDocument?e.ownerDocument.body:e.body:eo(t)&&ro(t)?t:yo(t)}function wo(e,t,n){var r;void 0===t&&(t=[]),void 0===n&&(n=!0);const i=yo(e),o=i===(null==(r=e.ownerDocument)?void 0:r.body),s=Xi(i);if(o){const e=xo(s);return t.concat(s,s.visualViewport||[],ro(i)?i:[],e&&n?wo(e):[])}return t.concat(i,wo(i,[],n))}function xo(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function ko(e){const t=go(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=eo(e),o=i?e.offsetWidth:n,s=i?e.offsetHeight:r,a=wi(n)!==o||wi(r)!==s;return a&&(n=o,r=s),{width:n,height:r,$:a}}function So(e){return Zi(e)?e:e.contextElement}function Eo(e){const t=So(e);if(!eo(t))return ki(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:o}=ko(t);let s=(o?wi(n.width):n.width)/r,a=(o?wi(n.height):n.height)/i;return s&&Number.isFinite(s)||(s=1),a&&Number.isFinite(a)||(a=1),{x:s,y:a}}const Co=ki(0);function No(e){const t=Xi(e);return fo()&&t.visualViewport?{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}:Co}function Oo(e,t,n,r){void 0===t&&(t=!1),void 0===n&&(n=!1);const i=e.getBoundingClientRect(),o=So(e);let s=ki(1);t&&(r?Zi(r)&&(s=Eo(r)):s=Eo(e));const a=function(e,t,n){return void 0===t&&(t=!1),!(!n||t&&n!==Xi(e))&&t}(o,n,r)?No(o):ki(0);let l=(i.left+a.x)/s.x,c=(i.top+a.y)/s.y,u=i.width/s.x,h=i.height/s.y;if(o){const e=Xi(o),t=r&&Zi(r)?Xi(r):r;let n=e,i=xo(n);for(;i&&r&&t!==n;){const e=Eo(i),t=i.getBoundingClientRect(),r=go(i),o=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,s=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;l*=e.x,c*=e.y,u*=e.x,h*=e.y,l+=o,c+=s,n=Xi(i),i=xo(n)}}return Hi({width:u,height:h,x:l,y:c})}function Ao(e,t){const n=vo(e).scrollLeft;return t?t.left+n:Oo(Ji(e)).left+n}function Mo(e,t){const n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-Ao(e,n),y:n.top+t.scrollTop}}const To=new Set(["absolute","fixed"]);function Ro(e,t,n){let r;if("viewport"===t)r=function(e,t){const n=Xi(e),r=Ji(e),i=n.visualViewport;let o=r.clientWidth,s=r.clientHeight,a=0,l=0;if(i){o=i.width,s=i.height;const e=fo();(!e||e&&"fixed"===t)&&(a=i.offsetLeft,l=i.offsetTop)}const c=Ao(r);if(c<=0){const e=r.ownerDocument,t=e.body,n=getComputedStyle(t),i="CSS1Compat"===e.compatMode&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,s=Math.abs(r.clientWidth-t.clientWidth-i);s<=25&&(o-=s)}else c<=25&&(o+=c);return{width:o,height:s,x:a,y:l}}(e,n);else if("document"===t)r=function(e){const t=Ji(e),n=vo(e),r=e.ownerDocument.body,i=yi(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),o=yi(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let s=-n.scrollLeft+Ao(e);const a=-n.scrollTop;return"rtl"===go(r).direction&&(s+=yi(t.clientWidth,r.clientWidth)-i),{width:i,height:o,x:s,y:a}}(Ji(e));else if(Zi(t))r=function(e,t){const n=Oo(e,!0,"fixed"===t),r=n.top+e.clientTop,i=n.left+e.clientLeft,o=eo(e)?Eo(e):ki(1);return{width:e.clientWidth*o.x,height:e.clientHeight*o.y,x:i*o.x,y:r*o.y}}(t,n);else{const n=No(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return Hi(r)}function Do(e,t){const n=bo(e);return!(n===t||!Zi(n)||mo(n))&&("fixed"===go(n).position||Do(n,t))}function Po(e,t,n){const r=eo(t),i=Ji(t),o="fixed"===n,s=Oo(e,!0,o,t);let a={scrollLeft:0,scrollTop:0};const l=ki(0);function c(){l.x=Ao(i)}if(r||!r&&!o)if(("body"!==Gi(t)||ro(i))&&(a=vo(t)),r){const e=Oo(t,!0,o,t);l.x=e.x+t.clientLeft,l.y=e.y+t.clientTop}else i&&c();o&&!r&&i&&c();const u=!i||r||o?ki(0):Mo(i,a);return{x:s.left+a.scrollLeft-l.x-u.x,y:s.top+a.scrollTop-l.y-u.y,width:s.width,height:s.height}}function Lo(e){return"static"===go(e).position}function Io(e,t){if(!eo(e)||"fixed"===go(e).position)return null;if(t)return t(e);let n=e.offsetParent;return Ji(e)===n&&(n=n.ownerDocument.body),n}function _o(e,t){const n=Xi(e);if(ao(e))return n;if(!eo(e)){let t=bo(e);for(;t&&!mo(t);){if(Zi(t)&&!Lo(t))return t;t=bo(t)}return n}let r=Io(e,t);for(;r&&oo(r)&&Lo(r);)r=Io(r,t);return r&&mo(r)&&Lo(r)&&!ho(r)?n:r||function(e){let t=bo(e);for(;eo(t)&&!mo(t);){if(ho(t))return t;if(ao(t))return null;t=bo(t)}return null}(e)||n}const Bo={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const o="fixed"===i,s=Ji(r),a=!!t&&ao(t.floating);if(r===s||a&&o)return n;let l={scrollLeft:0,scrollTop:0},c=ki(1);const u=ki(0),h=eo(r);if((h||!h&&!o)&&(("body"!==Gi(r)||ro(s))&&(l=vo(r)),eo(r))){const e=Oo(r);c=Eo(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}const d=!s||h||o?ki(0):Mo(s,l);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+u.x+d.x,y:n.y*c.y-l.scrollTop*c.y+u.y+d.y}},getDocumentElement:Ji,getClippingRect:function(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const o=[..."clippingAncestors"===n?ao(t)?[]:function(e,t){const n=t.get(e);if(n)return n;let r=wo(e,[],!1).filter(e=>Zi(e)&&"body"!==Gi(e)),i=null;const o="fixed"===go(e).position;let s=o?bo(e):e;for(;Zi(s)&&!mo(s);){const t=go(s),n=ho(s);n||"fixed"!==t.position||(i=null),(o?!n&&!i:!n&&"static"===t.position&&i&&To.has(i.position)||ro(s)&&!n&&Do(e,s))?r=r.filter(e=>e!==s):i=t,s=bo(s)}return t.set(e,r),r}(t,this._c):[].concat(n),r],s=o[0],a=o.reduce((e,n)=>{const r=Ro(t,n,i);return e.top=yi(r.top,e.top),e.right=bi(r.right,e.right),e.bottom=bi(r.bottom,e.bottom),e.left=yi(r.left,e.left),e},Ro(t,s,i));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}},getOffsetParent:_o,getElementRects:async function(e){const t=this.getOffsetParent||_o,n=this.getDimensions,r=await n(e.floating);return{reference:Po(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}},getClientRects:function(e){return Array.from(e.getClientRects())},getDimensions:function(e){const{width:t,height:n}=ko(e);return{width:t,height:n}},getScale:Eo,isElement:Zi,isRTL:function(e){return"rtl"===go(e).direction}};function Fo(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function jo(e,t,n,r){void 0===r&&(r={});const{ancestorScroll:i=!0,ancestorResize:o=!0,elementResize:s="function"==typeof ResizeObserver,layoutShift:a="function"==typeof IntersectionObserver,animationFrame:l=!1}=r,c=So(e),u=i||o?[...c?wo(c):[],...wo(t)]:[];u.forEach(e=>{i&&e.addEventListener("scroll",n,{passive:!0}),o&&e.addEventListener("resize",n)});const h=c&&a?function(e,t){let n,r=null;const i=Ji(e);function o(){var e;clearTimeout(n),null==(e=r)||e.disconnect(),r=null}return function s(a,l){void 0===a&&(a=!1),void 0===l&&(l=1),o();const c=e.getBoundingClientRect(),{left:u,top:h,width:d,height:f}=c;if(a||t(),!d||!f)return;const p={rootMargin:-xi(h)+"px "+-xi(i.clientWidth-(u+d))+"px "+-xi(i.clientHeight-(h+f))+"px "+-xi(u)+"px",threshold:yi(0,bi(1,l))||1};let m=!0;function g(t){const r=t[0].intersectionRatio;if(r!==l){if(!m)return s();r?s(!1,r):n=setTimeout(()=>{s(!1,1e-7)},1e3)}1!==r||Fo(c,e.getBoundingClientRect())||s(),m=!1}try{r=new IntersectionObserver(g,{...p,root:i.ownerDocument})}catch(e){r=new IntersectionObserver(g,p)}r.observe(e)}(!0),o}(c,n):null;let d,f=-1,p=null;s&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===c&&p&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;null==(e=p)||e.observe(t)})),n()}),c&&!l&&p.observe(c),p.observe(t));let m=l?Oo(e):null;return l&&function t(){const r=Oo(e);m&&!Fo(m,r)&&n();m=r,d=requestAnimationFrame(t)}(),n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener("scroll",n),o&&e.removeEventListener("resize",n)}),null==h||h(),null==(e=p)||e.disconnect(),p=null,l&&cancelAnimationFrame(d)}}const Wo=function(e){return void 0===e&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:i,y:o,placement:s,middlewareData:a}=t,l=await async function(e,t){const{placement:n,platform:r,elements:i}=e,o=await(null==r.isRTL?void 0:r.isRTL(i.floating)),s=Oi(n),a=Ai(n),l="y"===Di(n),c=Ki.has(s)?-1:1,u=o&&l?-1:1,h=Ni(t,e);let{mainAxis:d,crossAxis:f,alignmentAxis:p}="number"==typeof h?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return a&&"number"==typeof p&&(f="end"===a?-1*p:p),l?{x:f*u,y:d*c}:{x:d*c,y:f*u}}(t,e);return s===(null==(n=a.offset)?void 0:n.placement)&&null!=(r=a.arrow)&&r.alignmentOffset?{}:{x:i+l.x,y:o+l.y,data:{...l,placement:s}}}}},zo=function(e){return void 0===e&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:i}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:a={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=Ni(e,t),c={x:n,y:r},u=await qi(t,l),h=Di(Oi(i)),d=Mi(h);let f=c[d],p=c[h];if(o){const e="y"===d?"bottom":"right";f=Ci(f+u["y"===d?"top":"left"],f,f-u[e])}if(s){const e="y"===h?"bottom":"right";p=Ci(p+u["y"===h?"top":"left"],p,p-u[e])}const m=a.fn({...t,[d]:f,[h]:p});return{...m,data:{x:m.x-n,y:m.y-r,enabled:{[d]:o,[h]:s}}}}}},Ho=function(e){return void 0===e&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:i,middlewareData:o,rects:s,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:u=!0,crossAxis:h=!0,fallbackPlacements:d,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:m=!0,...g}=Ni(e,t);if(null!=(n=o.arrow)&&n.alignmentOffset)return{};const v=Oi(i),b=Di(a),y=Oi(a)===a,w=await(null==l.isRTL?void 0:l.isRTL(c.floating)),x=d||(y||!m?[Wi(a)]:function(e){const t=Wi(e);return[Li(e),t,Li(t)]}(a)),k="none"!==p;!d&&k&&x.push(...ji(a,m,p,w));const S=[a,...x],E=await qi(t,g),C=[];let N=(null==(r=o.flip)?void 0:r.overflows)||[];if(u&&C.push(E[v]),h){const e=function(e,t,n){void 0===n&&(n=!1);const r=Ai(e),i=Pi(e),o=Ti(i);let s="x"===i?r===(n?"end":"start")?"right":"left":"start"===r?"bottom":"top";return t.reference[o]>t.floating[o]&&(s=Wi(s)),[s,Wi(s)]}(i,s,w);C.push(E[e[0]],E[e[1]])}if(N=[...N,{placement:i,overflows:C}],!C.every(e=>e<=0)){var O,A;const e=((null==(O=o.flip)?void 0:O.index)||0)+1,t=S[e];if(t){if(!("alignment"===h&&b!==Di(t))||N.every(e=>Di(e.placement)!==b||e.overflows[0]>0))return{data:{index:e,overflows:N},reset:{placement:t}}}let n=null==(A=N.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0])?void 0:A.placement;if(!n)switch(f){case"bestFit":{var M;const e=null==(M=N.filter(e=>{if(k){const t=Di(e.placement);return t===b||"y"===t}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0])?void 0:M[0];e&&(n=e);break}case"initialPlacement":n=a}if(i!==n)return{reset:{placement:n}}}return{}}}},Vo=function(e){return void 0===e&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:i,rects:o,platform:s,elements:a}=t,{apply:l=()=>{},...c}=Ni(e,t),u=await qi(t,c),h=Oi(i),d=Ai(i),f="y"===Di(i),{width:p,height:m}=o.floating;let g,v;"top"===h||"bottom"===h?(g=h,v=d===(await(null==s.isRTL?void 0:s.isRTL(a.floating))?"start":"end")?"left":"right"):(v=h,g="end"===d?"top":"bottom");const b=m-u.top-u.bottom,y=p-u.left-u.right,w=bi(m-u[g],b),x=bi(p-u[v],y),k=!t.middlewareData.shift;let S=w,E=x;if(null!=(n=t.middlewareData.shift)&&n.enabled.x&&(E=y),null!=(r=t.middlewareData.shift)&&r.enabled.y&&(S=b),k&&!d){const e=yi(u.left,0),t=yi(u.right,0),n=yi(u.top,0),r=yi(u.bottom,0);f?E=p-2*(0!==e||0!==t?e+t:yi(u.left,u.right)):S=m-2*(0!==n||0!==r?n+r:yi(u.top,u.bottom))}await l({...t,availableWidth:E,availableHeight:S});const C=await s.getDimensions(a.floating);return p!==C.width||m!==C.height?{reset:{rects:!0}}:{}}}},qo=function(e){return void 0===e&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...i}=Ni(e,t);switch(r){case"referenceHidden":{const e=Ui(await qi(t,{...i,elementContext:"reference"}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:$i(e)}}}case"escaped":{const e=Ui(await qi(t,{...i,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:$i(e)}}}default:return{}}}}},Uo=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:i,rects:o,platform:s,elements:a,middlewareData:l}=t,{element:c,padding:u=0}=Ni(e,t)||{};if(null==c)return{};const h=zi(u),d={x:n,y:r},f=Pi(i),p=Ti(f),m=await s.getDimensions(c),g="y"===f,v=g?"top":"left",b=g?"bottom":"right",y=g?"clientHeight":"clientWidth",w=o.reference[p]+o.reference[f]-d[f]-o.floating[p],x=d[f]-o.reference[f],k=await(null==s.getOffsetParent?void 0:s.getOffsetParent(c));let S=k?k[y]:0;S&&await(null==s.isElement?void 0:s.isElement(k))||(S=a.floating[y]||o.floating[p]);const E=w/2-x/2,C=S/2-m[p]/2-1,N=bi(h[v],C),O=bi(h[b],C),A=N,M=S-m[p]-O,T=S/2-m[p]/2+E,R=Ci(A,T,M),D=!l.arrow&&null!=Ai(i)&&T!==R&&o.reference[p]/2-(T<A?N:O)-m[p]/2<0,P=D?T<A?T-A:T-M:0;return{[f]:d[f]+P,data:{[f]:R,centerOffset:T-R-P,...D&&{alignmentOffset:P}},reset:D}}}),$o=function(e){return void 0===e&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:i,rects:o,middlewareData:s}=t,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=Ni(e,t),u={x:n,y:r},h=Di(i),d=Mi(h);let f=u[d],p=u[h];const m=Ni(a,t),g="number"==typeof m?{mainAxis:m,crossAxis:0}:{mainAxis:0,crossAxis:0,...m};if(l){const e="y"===d?"height":"width",t=o.reference[d]-o.floating[e]+g.mainAxis,n=o.reference[d]+o.reference[e]-g.mainAxis;f<t?f=t:f>n&&(f=n)}if(c){var v,b;const e="y"===d?"width":"height",t=Ki.has(Oi(i)),n=o.reference[h]-o.floating[e]+(t&&(null==(v=s.offset)?void 0:v[h])||0)+(t?0:g.crossAxis),r=o.reference[h]+o.reference[e]+(t?0:(null==(b=s.offset)?void 0:b[h])||0)-(t?g.crossAxis:0);p<n?p=n:p>r&&(p=r)}return{[d]:f,[h]:p}}}},Ko=(e,t,n)=>{const r=new Map,i={platform:Bo,...n},o={...i.platform,_c:r};return(async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:o=[],platform:s}=n,a=o.filter(Boolean),l=await(null==s.isRTL?void 0:s.isRTL(t));let c=await s.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:h}=Vi(c,r,l),d=r,f={},p=0;for(let n=0;n<a.length;n++){const{name:o,fn:m}=a[n],{x:g,y:v,data:b,reset:y}=await m({x:u,y:h,initialPlacement:r,placement:d,strategy:i,middlewareData:f,rects:c,platform:s,elements:{reference:e,floating:t}});u=null!=g?g:u,h=null!=v?v:h,f={...f,[o]:{...f[o],...b}},y&&p<=50&&(p++,"object"==typeof y&&(y.placement&&(d=y.placement),y.rects&&(c=!0===y.rects?await s.getElementRects({reference:e,floating:t,strategy:i}):y.rects),({x:u,y:h}=Vi(c,d,l))),n=-1)}return{x:u,y:h,placement:d,strategy:i,middlewareData:f}})(e,t,{...i,platform:o})};var Yo="undefined"!=typeof document?o:function(){};function Go(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if("function"==typeof e&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&"object"==typeof e){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;0!==r--;)if(!Go(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;0!==r--;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;0!==r--;){const n=i[r];if(("_owner"!==n||!e.$$typeof)&&!Go(e[n],t[n]))return!1}return!0}return e!=e&&t!=t}function Xo(e){if("undefined"==typeof window)return 1;return(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Jo(e,t){const n=Xo(e);return Math.round(t*n)/n}function Qo(t){const n=e.useRef(t);return Yo(()=>{n.current=t}),n}function Zo(t){void 0===t&&(t={});const{placement:n="bottom",strategy:r="absolute",middleware:i=[],platform:o,elements:{reference:s,floating:a}={},transform:l=!0,whileElementsMounted:c,open:u}=t,[h,d]=e.useState({x:0,y:0,strategy:r,placement:n,middlewareData:{},isPositioned:!1}),[f,p]=e.useState(i);Go(f,i)||p(i);const[m,v]=e.useState(null),[b,y]=e.useState(null),w=e.useCallback(e=>{e!==E.current&&(E.current=e,v(e))},[]),x=e.useCallback(e=>{e!==C.current&&(C.current=e,y(e))},[]),k=s||m,S=a||b,E=e.useRef(null),C=e.useRef(null),N=e.useRef(h),O=null!=c,A=Qo(c),M=Qo(o),T=Qo(u),R=e.useCallback(()=>{if(!E.current||!C.current)return;const e={placement:n,strategy:r,middleware:f};M.current&&(e.platform=M.current),Ko(E.current,C.current,e).then(e=>{const t={...e,isPositioned:!1!==T.current};D.current&&!Go(N.current,t)&&(N.current=t,g.flushSync(()=>{d(t)}))})},[f,n,r,M,T]);Yo(()=>{!1===u&&N.current.isPositioned&&(N.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[u]);const D=e.useRef(!1);Yo(()=>(D.current=!0,()=>{D.current=!1}),[]),Yo(()=>{if(k&&(E.current=k),S&&(C.current=S),k&&S){if(A.current)return A.current(k,S,R);R()}},[k,S,R,A,O]);const P=e.useMemo(()=>({reference:E,floating:C,setReference:w,setFloating:x}),[w,x]),L=e.useMemo(()=>({reference:k,floating:S}),[k,S]),I=e.useMemo(()=>{const e={position:r,left:0,top:0};if(!L.floating)return e;const t=Jo(L.floating,h.x),n=Jo(L.floating,h.y);return l?{...e,transform:"translate("+t+"px, "+n+"px)",...Xo(L.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:t,top:n}},[r,l,L.floating,h.x,h.y]);return e.useMemo(()=>({...h,update:R,refs:P,elements:L,floatingStyles:I}),[h,R,P,L,I])}const es=e=>({name:"arrow",options:e,fn(t){const{element:n,padding:r}="function"==typeof e?e(t):e;return n&&(i=n,{}.hasOwnProperty.call(i,"current"))?null!=n.current?Uo({element:n.current,padding:r}).fn(t):{}:n?Uo({element:n,padding:r}).fn(t):{};var i}}),ts=(e,t)=>({...Wo(e),options:[e,t]}),ns=(e,t)=>({...zo(e),options:[e,t]}),rs=(e,t)=>({...$o(e),options:[e,t]}),is=(e,t)=>({...Ho(e),options:[e,t]}),os=(e,t)=>({...Vo(e),options:[e,t]}),ss=(e,t)=>({...qo(e),options:[e,t]}),as=(e,t)=>({...es(e),options:[e,t]});var ls=e.forwardRef((e,t)=>{const{children:n,width:r=10,height:i=5,...o}=e;return f(li.svg,{...o,ref:t,width:r,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:f("polygon",{points:"0,0 30,0 15,10"})})});ls.displayName="Arrow";var cs=ls;function us(t){const[n,r]=e.useState(void 0);return Pt(()=>{if(t){r({width:t.offsetWidth,height:t.offsetHeight});const e=new ResizeObserver(e=>{if(!Array.isArray(e))return;if(!e.length)return;const n=e[0];let i,o;if("borderBoxSize"in n){const e=n.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,o=t.blockSize}else i=t.offsetWidth,o=t.offsetHeight;r({width:i,height:o})});return e.observe(t,{box:"border-box"}),()=>e.unobserve(t)}r(void 0)},[t]),n}var hs="Popper",[ds,fs]=Rt(hs),[ps,ms]=ds(hs),gs=t=>{const{__scopePopper:n,children:r}=t,[i,o]=e.useState(null);return f(ps,{scope:n,anchor:i,onAnchorChange:o,children:r})};gs.displayName=hs;var vs="PopperAnchor",bs=e.forwardRef((t,n)=>{const{__scopePopper:r,virtualRef:i,...o}=t,s=ms(vs,r),a=e.useRef(null),l=ct(n,a),c=e.useRef(null);return e.useEffect(()=>{const e=c.current;c.current=i?.current||a.current,e!==c.current&&s.onAnchorChange(c.current)}),i?null:f(li.div,{...o,ref:l})});bs.displayName=vs;var ys="PopperContent",[ws,xs]=ds(ys),ks=e.forwardRef((t,n)=>{const{__scopePopper:r,side:i="bottom",sideOffset:o=0,align:s="center",alignOffset:a=0,arrowPadding:l=0,avoidCollisions:c=!0,collisionBoundary:u=[],collisionPadding:h=0,sticky:d="partial",hideWhenDetached:p=!1,updatePositionStrategy:m="optimized",onPlaced:g,...v}=t,b=ms(ys,r),[y,w]=e.useState(null),x=ct(n,e=>w(e)),[k,S]=e.useState(null),E=us(k),C=E?.width??0,N=E?.height??0,O=i+("center"!==s?"-"+s:""),A="number"==typeof h?h:{top:0,right:0,bottom:0,left:0,...h},M=Array.isArray(u)?u:[u],T=M.length>0,R={padding:A,boundary:M.filter(Ns),altBoundary:T},{refs:D,floatingStyles:P,placement:L,isPositioned:I,middlewareData:_}=Zo({strategy:"fixed",placement:O,whileElementsMounted:(...e)=>jo(...e,{animationFrame:"always"===m}),elements:{reference:b.anchor},middleware:[ts({mainAxis:o+N,alignmentAxis:a}),c&&ns({mainAxis:!0,crossAxis:!1,limiter:"partial"===d?rs():void 0,...R}),c&&is({...R}),os({...R,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{const{width:i,height:o}=t.reference,s=e.floating.style;s.setProperty("--radix-popper-available-width",`${n}px`),s.setProperty("--radix-popper-available-height",`${r}px`),s.setProperty("--radix-popper-anchor-width",`${i}px`),s.setProperty("--radix-popper-anchor-height",`${o}px`)}}),k&&as({element:k,padding:l}),Os({arrowWidth:C,arrowHeight:N}),p&&ss({strategy:"referenceHidden",...R})]}),[B,F]=As(L),j=qt(g);Pt(()=>{I&&j?.()},[I,j]);const W=_.arrow?.x,z=_.arrow?.y,H=0!==_.arrow?.centerOffset,[V,q]=e.useState();return Pt(()=>{y&&q(window.getComputedStyle(y).zIndex)},[y]),f("div",{ref:D.setFloating,"data-radix-popper-content-wrapper":"",style:{...P,transform:I?P.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:V,"--radix-popper-transform-origin":[_.transformOrigin?.x,_.transformOrigin?.y].join(" "),..._.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:f(ws,{scope:r,placedSide:B,onArrowChange:S,arrowX:W,arrowY:z,shouldHideArrow:H,children:f(li.div,{"data-side":B,"data-align":F,...v,ref:x,style:{...v.style,animation:I?void 0:"none"}})})})});ks.displayName=ys;var Ss="PopperArrow",Es={top:"bottom",right:"left",bottom:"top",left:"right"},Cs=e.forwardRef(function(e,t){const{__scopePopper:n,...r}=e,i=xs(Ss,n),o=Es[i.placedSide];return f("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:f(cs,{...r,ref:t,style:{...r.style,display:"block"}})})});function Ns(e){return null!==e}Cs.displayName=Ss;var Os=e=>({name:"transformOrigin",options:e,fn(t){const{placement:n,rects:r,middlewareData:i}=t,o=0!==i.arrow?.centerOffset,s=o?0:e.arrowWidth,a=o?0:e.arrowHeight,[l,c]=As(n),u={start:"0%",center:"50%",end:"100%"}[c],h=(i.arrow?.x??0)+s/2,d=(i.arrow?.y??0)+a/2;let f="",p="";return"bottom"===l?(f=o?u:`${h}px`,p=-a+"px"):"top"===l?(f=o?u:`${h}px`,p=`${r.floating.height+a}px`):"right"===l?(f=-a+"px",p=o?u:`${d}px`):"left"===l&&(f=`${r.floating.width+a}px`,p=o?u:`${d}px`),{data:{x:f,y:p}}}});function As(e){const[t,n="center"]=e.split("-");return[t,n]}var Ms=gs,Ts=bs,Rs=ks,Ds=Cs;var Ps=t=>{const{present:n,children:r}=t,i=function(t){const[n,r]=e.useState(),i=e.useRef(null),o=e.useRef(t),s=e.useRef("none"),a=t?"mounted":"unmounted",[l,c]=function(t,n){return e.useReducer((e,t)=>n[e][t]??e,t)}(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return e.useEffect(()=>{const e=Ls(i.current);s.current="mounted"===l?e:"none"},[l]),Pt(()=>{const e=i.current,n=o.current;if(n!==t){const r=s.current,i=Ls(e);if(t)c("MOUNT");else if("none"===i||"none"===e?.display)c("UNMOUNT");else{c(n&&r!==i?"ANIMATION_OUT":"UNMOUNT")}o.current=t}},[t,c]),Pt(()=>{if(n){let e;const t=n.ownerDocument.defaultView??window,r=r=>{const s=Ls(i.current).includes(CSS.escape(r.animationName));if(r.target===n&&s&&(c("ANIMATION_END"),!o.current)){const r=n.style.animationFillMode;n.style.animationFillMode="forwards",e=t.setTimeout(()=>{"forwards"===n.style.animationFillMode&&(n.style.animationFillMode=r)})}},a=e=>{e.target===n&&(s.current=Ls(i.current))};return n.addEventListener("animationstart",a),n.addEventListener("animationcancel",r),n.addEventListener("animationend",r),()=>{t.clearTimeout(e),n.removeEventListener("animationstart",a),n.removeEventListener("animationcancel",r),n.removeEventListener("animationend",r)}}c("ANIMATION_END")},[n,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:e.useCallback(e=>{i.current=e?getComputedStyle(e):null,r(e)},[])}}(n),o="function"==typeof r?r({present:i.isPresent}):e.Children.only(r),s=ct(i.ref,function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;if(n)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(o));return"function"==typeof r||i.isPresent?e.cloneElement(o,{ref:s}):null};function Ls(e){return e?.animationName||"none"}Ps.displayName="Presence";var Is=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),_s=e.forwardRef((e,t)=>f(li.span,{...e,ref:t,style:{...Is,...e.style}}));_s.displayName="VisuallyHidden";var Bs=_s,[Fs,js]=Rt("Tooltip",[fs]),Ws=fs(),zs="TooltipProvider",Hs=700,Vs="tooltip.open",[qs,Us]=Fs(zs),$s=t=>{const{__scopeTooltip:n,delayDuration:r=Hs,skipDelayDuration:i=300,disableHoverableContent:o=!1,children:s}=t,a=e.useRef(!0),l=e.useRef(!1),c=e.useRef(0);return e.useEffect(()=>{const e=c.current;return()=>window.clearTimeout(e)},[]),f(qs,{scope:n,isOpenDelayedRef:a,delayDuration:r,onOpen:e.useCallback(()=>{window.clearTimeout(c.current),a.current=!1},[]),onClose:e.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>a.current=!0,i)},[i]),isPointerInTransitRef:l,onPointerInTransitChange:e.useCallback(e=>{l.current=e},[]),disableHoverableContent:o,children:s})};$s.displayName=zs;var Ks="Tooltip",[Ys,Gs]=Fs(Ks),Xs=t=>{const{__scopeTooltip:n,children:r,open:i,defaultOpen:o,onOpenChange:s,disableHoverableContent:a,delayDuration:l}=t,c=Us(Ks,t.__scopeTooltip),u=Ws(n),[h,d]=e.useState(null),p=_t(),m=e.useRef(0),g=a??c.disableHoverableContent,v=l??c.delayDuration,b=e.useRef(!1),[y,w]=Ft({prop:i,defaultProp:o??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(Vs))):c.onClose(),s?.(e)},caller:Ks}),x=e.useMemo(()=>y?b.current?"delayed-open":"instant-open":"closed",[y]),k=e.useCallback(()=>{window.clearTimeout(m.current),m.current=0,b.current=!1,w(!0)},[w]),S=e.useCallback(()=>{window.clearTimeout(m.current),m.current=0,w(!1)},[w]),E=e.useCallback(()=>{window.clearTimeout(m.current),m.current=window.setTimeout(()=>{b.current=!0,w(!0),m.current=0},v)},[v,w]);return e.useEffect(()=>()=>{m.current&&(window.clearTimeout(m.current),m.current=0)},[]),f(Ms,{...u,children:f(Ys,{scope:n,contentId:p,open:y,stateAttribute:x,trigger:h,onTriggerChange:d,onTriggerEnter:e.useCallback(()=>{c.isOpenDelayedRef.current?E():k()},[c.isOpenDelayedRef,E,k]),onTriggerLeave:e.useCallback(()=>{g?S():(window.clearTimeout(m.current),m.current=0)},[S,g]),onOpen:k,onClose:S,disableHoverableContent:g,children:r})})};Xs.displayName=Ks;var Js="TooltipTrigger",Qs=e.forwardRef((t,n)=>{const{__scopeTooltip:r,...i}=t,o=Gs(Js,r),s=Us(Js,r),a=Ws(r),l=ct(n,e.useRef(null),o.onTriggerChange),c=e.useRef(!1),u=e.useRef(!1),h=e.useCallback(()=>c.current=!1,[]);return e.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),f(Ts,{asChild:!0,...a,children:f(li.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...i,ref:l,onPointerMove:Tt(t.onPointerMove,e=>{"touch"!==e.pointerType&&(u.current||s.isPointerInTransitRef.current||(o.onTriggerEnter(),u.current=!0))}),onPointerLeave:Tt(t.onPointerLeave,()=>{o.onTriggerLeave(),u.current=!1}),onPointerDown:Tt(t.onPointerDown,()=>{o.open&&o.onClose(),c.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:Tt(t.onFocus,()=>{c.current||o.onOpen()}),onBlur:Tt(t.onBlur,o.onClose),onClick:Tt(t.onClick,o.onClose)})})});Qs.displayName=Js;var[Zs,ea]=Fs("TooltipPortal",{forceMount:void 0}),ta="TooltipContent",na=e.forwardRef((e,t)=>{const n=ea(ta,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...o}=e,s=Gs(ta,e.__scopeTooltip);return f(Ps,{present:r||s.open,children:s.disableHoverableContent?f(aa,{side:i,...o,ref:t}):f(ra,{side:i,...o,ref:t})})}),ra=e.forwardRef((t,n)=>{const r=Gs(ta,t.__scopeTooltip),i=Us(ta,t.__scopeTooltip),o=e.useRef(null),s=ct(n,o),[a,l]=e.useState(null),{trigger:c,onClose:u}=r,h=o.current,{onPointerInTransitChange:d}=i,p=e.useCallback(()=>{l(null),d(!1)},[d]),m=e.useCallback((e,t)=>{const n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=function(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),o=Math.abs(t.left-e.x);switch(Math.min(n,r,i,o)){case o:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}(r,n.getBoundingClientRect()),o=function(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n})}return r}(r,i),s=function(e){const{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}(t.getBoundingClientRect()),a=function(e){const t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:e.y>t.y?1:0),function(e){if(e.length<=1)return e.slice();const t=[];for(let n=0;n<e.length;n++){const r=e[n];for(;t.length>=2;){const e=t[t.length-1],n=t[t.length-2];if(!((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x)))break;t.pop()}t.push(r)}t.pop();const n=[];for(let t=e.length-1;t>=0;t--){const r=e[t];for(;n.length>=2;){const e=n[n.length-1],t=n[n.length-2];if(!((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x)))break;n.pop()}n.push(r)}return n.pop(),1===t.length&&1===n.length&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}(t)}([...o,...s]);l(a),d(!0)},[d]);return e.useEffect(()=>()=>p(),[p]),e.useEffect(()=>{if(c&&h){const e=e=>m(e,h),t=e=>m(e,c);return c.addEventListener("pointerleave",e),h.addEventListener("pointerleave",t),()=>{c.removeEventListener("pointerleave",e),h.removeEventListener("pointerleave",t)}}},[c,h,m,p]),e.useEffect(()=>{if(a){const e=e=>{const t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||h?.contains(t),i=!function(e,t){const{x:n,y:r}=e;let i=!1;for(let e=0,o=t.length-1;e<t.length;o=e++){const s=t[e],a=t[o],l=s.x,c=s.y,u=a.x,h=a.y;c>r!=h>r&&n<(u-l)*(r-c)/(h-c)+l&&(i=!i)}return i}(n,a);r?p():i&&(p(),u())};return document.addEventListener("pointermove",e),()=>document.removeEventListener("pointermove",e)}},[c,h,a,u,p]),f(aa,{...t,ref:s})}),[ia,oa]=Fs(Ks,{isInside:!1}),sa=function(e){const t=({children:e})=>f(m,{children:e});return t.displayName=`${e}.Slottable`,t.__radixId=si,t}("TooltipContent"),aa=e.forwardRef((t,n)=>{const{__scopeTooltip:r,children:i,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:a,...l}=t,c=Gs(ta,r),u=Ws(r),{onClose:h}=c;return e.useEffect(()=>(document.addEventListener(Vs,h),()=>document.removeEventListener(Vs,h)),[h]),e.useEffect(()=>{if(c.trigger){const e=e=>{const t=e.target;t?.contains(c.trigger)&&h()};return window.addEventListener("scroll",e,{capture:!0}),()=>window.removeEventListener("scroll",e,{capture:!0})}},[c.trigger,h]),f(pi,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:e=>e.preventDefault(),onDismiss:h,children:p(Rs,{"data-state":c.stateAttribute,...u,...l,ref:n,style:{...l.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[f(sa,{children:i}),f(ia,{scope:r,isInside:!0,children:f(Bs,{id:c.contentId,role:"tooltip",children:o||i})})]})})});na.displayName=ta;var la="TooltipArrow";e.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=Ws(n);return oa(la,n).isInside?null:f(Ds,{...i,...r,ref:t})}).displayName=la;var ca=na,ua=$s,ha=Xs,da=Qs,fa=e.forwardRef(function(t,n){var r=t.className,i=t.sideOffset,o=void 0===i?4:i,s=D(t,["className","sideOffset"]);return e.createElement(ca,Object.assign({ref:n,sideOffset:o,className:ot("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-tooltip-content-transform-origin]",r)},s))});fa.displayName=ca.displayName;var pa=e.createContext(null);function ma(){var t=e.useContext(pa);if(!t)throw new Error("useSidebar must be used within a SidebarProvider.");return t}function ga(t){var n=t.defaultOpen,r=void 0===n||n,i=t.open,o=t.onOpenChange,s=t.className,a=t.style,l=t.children,c=D(t,["defaultOpen","open","onOpenChange","className","style","children"]),u=function(){var t=O(e.useState(void 0),2),n=t[0],r=t[1];return e.useEffect(function(){var e=window.matchMedia("(max-width: ".concat(767,"px)")),t=function(){r(window.innerWidth<768)};return e.addEventListener("change",t),r(window.innerWidth<768),function(){return e.removeEventListener("change",t)}},[]),!!n}(),h=O(e.useState(!1),2),d=h[0],f=h[1],p=O(e.useState(r),2),m=p[0],g=p[1],v=null!=i?i:m,b=e.useCallback(function(e){var t="function"==typeof e?e(v):e;o?o(t):g(t),document.cookie="".concat("sidebar_state","=").concat(t,"; path=/; max-age=").concat(604800)},[o,v]),y=e.useCallback(function(){return u?f(function(e){return!e}):b(function(e){return!e})},[u,b,f]);e.useEffect(function(){var e=function(e){"b"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),y())};return window.addEventListener("keydown",e),function(){return window.removeEventListener("keydown",e)}},[y]);var w=v?"expanded":"collapsed",x=e.useMemo(function(){return{state:w,open:v,setOpen:b,isMobile:u,openMobile:d,setOpenMobile:f,toggleSidebar:y}},[w,v,b,u,d,f,y]);return e.createElement(pa.Provider,{value:x},e.createElement(ua,{delayDuration:0},e.createElement("div",Object.assign({style:Object.assign({"--sidebar-width":"16rem","--sidebar-width-icon":"3rem"},a),className:ot("group/sidebar-wrapper flex min-h-svh w-full",s)},c),l)))}function va(t){var n=t.side,r=void 0===n?"left":n,i=t.variant,o=void 0===i?"sidebar":i,s=t.collapsible,a=void 0===s?"offcanvas":s,l=t.className,c=t.children,u=D(t,["side","variant","collapsible","className","children"]),h=ma(),d=h.isMobile,f=h.state,p=h.openMobile,m=h.setOpenMobile;return"none"===a?e.createElement("div",Object.assign({className:ot("bg-sidebar text-sidebar-foreground flex h-full w-[var(--sidebar-width)] flex-col",l)},u),c):d?e.createElement(Jr,Object.assign({open:p,onOpenChange:m},u),e.createElement(ti,{className:"bg-sidebar text-sidebar-foreground w-[var(--sidebar-width)] p-0 [&>button]:hidden",style:{"--sidebar-width":"18rem"},side:r},e.createElement(ni,{className:"sr-only"},e.createElement(ri,null,"Sidebar"),e.createElement(ii,null,"Displays the mobile sidebar.")),e.createElement("div",{className:"flex h-full w-full flex-col"},c))):e.createElement("div",{className:"group peer text-sidebar-foreground hidden md:block","data-state":f,"data-collapsible":"collapsed"===f?a:"","data-variant":o,"data-side":r},e.createElement("div",{className:ot("relative w-[var(--sidebar-width)] bg-transparent transition-[width] duration-200 ease-linear","group-data-[collapsible=offcanvas]:w-0","floating"===o||"inset"===o?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+1rem)]":"group-data-[collapsible=icon]:w-[var(--sidebar-width-icon)]")}),e.createElement("div",Object.assign({className:ot("fixed inset-y-0 z-10 hidden h-svh w-[var(--sidebar-width)] transition-[left,right,width] duration-200 ease-linear md:flex","left"===r?"left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]":"right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]","floating"===o||"inset"===o?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+1rem+2px)]":"group-data-[collapsible=icon]:w-[var(--sidebar-width-icon)] group-data-[side=left]:border-r group-data-[side=right]:border-l",l)},u),e.createElement("div",{className:"bg-sidebar group-data-[variant=floating]:border-sidebar-border flex h-full w-full flex-col group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:shadow-sm"},c)))}function ba(t){var n=t.className,r=t.onClick,i=D(t,["className","onClick"]),o=ma().toggleSidebar;return e.createElement(kt,Object.assign({variant:"ghost",size:"icon",className:ot("h-7 w-7",n),onClick:function(e){null==r||r(e),o()}},i),e.createElement(te,null),e.createElement("span",{className:"sr-only"},"Toggle Sidebar"))}function ya(t){var n=t.className,r=D(t,["className"]);return e.createElement("main",Object.assign({className:ot("bg-background relative flex w-full flex-1 flex-col min-w-0 overflow-x-hidden","md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2",n)},r))}function wa(t){var n=t.className,r=D(t,["className"]);return e.createElement("div",Object.assign({className:ot("flex flex-col gap-2 p-2",n)},r))}function xa(t){var n=t.className,r=D(t,["className"]);return e.createElement("div",Object.assign({className:ot("flex flex-col gap-2 p-2",n)},r))}function ka(t){var n=t.className,r=D(t,["className"]);return e.createElement("div",Object.assign({className:ot("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",n)},r))}function Sa(t){var n=t.className,r=D(t,["className"]);return e.createElement("div",Object.assign({className:ot("relative flex w-full min-w-0 flex-col p-2",n)},r))}function Ea(t){var n=t.className,r=t.asChild,i=void 0!==r&&r,o=D(t,["className","asChild"]),s=i?pt:"div";return e.createElement(s,Object.assign({className:ot("text-sidebar-foreground/70 flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium transition-[margin,opacity] duration-200 ease-linear [&>svg]:size-4 [&>svg]:shrink-0","group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",n)},o))}function Ca(t){var n=t.className,r=D(t,["className"]);return e.createElement("div",Object.assign({className:ot("w-full text-sm",n)},r))}function Na(t){var n=t.className,r=D(t,["className"]);return e.createElement("ul",Object.assign({className:ot("flex w-full min-w-0 flex-col gap-1",n)},r))}function Oa(t){var n=t.className,r=D(t,["className"]);return e.createElement("li",Object.assign({className:ot("group/menu-item relative",n)},r))}var Aa=wt("peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"},size:{default:"h-8 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:p-0!"}},defaultVariants:{variant:"default",size:"default"}});function Ma(t){var n=t.asChild,r=void 0!==n&&n,i=t.isActive,o=void 0!==i&&i,s=t.variant,a=void 0===s?"default":s,l=t.size,c=void 0===l?"default":l,u=t.tooltip,h=t.className,d=D(t,["asChild","isActive","variant","size","tooltip","className"]),f=r?pt:"button",p=ma(),m=p.isMobile,g=p.state,v=e.createElement(f,Object.assign({"data-size":c,"data-active":o,className:ot(Aa({variant:a,size:c}),h)},d));return u?("string"==typeof u&&(u={children:u}),e.createElement(ha,null,e.createElement(da,{asChild:!0},v),e.createElement(fa,Object.assign({side:"right",align:"center",hidden:"collapsed"!==g||m},u)))):v}function Ta(t){const n=Ra(t),r=e.forwardRef((t,r)=>{const{children:i,...o}=t,s=e.Children.toArray(i),a=s.find(Pa);if(a){const t=a.props.children,i=s.map(n=>n===a?e.Children.count(t)>1?e.Children.only(null):e.isValidElement(t)?t.props.children:null:n);return f(n,{...o,ref:r,children:e.isValidElement(t)?e.cloneElement(t,void 0,i):null})}return f(n,{...o,ref:r,children:i})});return r.displayName=`${t}.Slot`,r}function Ra(t){const n=e.forwardRef((t,n)=>{const{children:r,...i}=t;if(e.isValidElement(r)){const t=function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;if(n)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(r),o=function(e,t){const n={...t};for(const r in t){const i=e[r],o=t[r];/^on[A-Z]/.test(r)?i&&o?n[r]=(...e)=>{const t=o(...e);return i(...e),t}:i&&(n[r]=i):"style"===r?n[r]={...i,...o}:"className"===r&&(n[r]=[i,o].filter(Boolean).join(" "))}return{...e,...n}}(i,r.props);return r.type!==e.Fragment&&(o.ref=n?lt(n,t):t),e.cloneElement(r,o)}return e.Children.count(r)>1?e.Children.only(null):null});return n.displayName=`${t}.SlotClone`,n}var Da=Symbol("radix.slottable");function Pa(t){return e.isValidElement(t)&&"function"==typeof t.type&&"__radixId"in t.type&&t.type.__radixId===Da}var La=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((t,n)=>{const r=Ta(`Primitive.${n}`),i=e.forwardRef((e,t)=>{const{asChild:i,...o}=e,s=i?r:n;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),f(s,{...o,ref:t})});return i.displayName=`Primitive.${n}`,{...t,[n]:i}},{});function Ia(e,t){e&&g.flushSync(()=>e.dispatchEvent(t))}function _a(e){const n=e+"CollectionProvider",[r,i]=Rt(n),[o,s]=r(n,{collectionRef:{current:null},itemMap:new Map}),a=e=>{const{scope:n,children:r}=e,i=t.useRef(null),s=t.useRef(new Map).current;return f(o,{scope:n,itemMap:s,collectionRef:i,children:r})};a.displayName=n;const l=e+"CollectionSlot",c=Ta(l),u=t.forwardRef((e,t)=>{const{scope:n,children:r}=e,i=ct(t,s(l,n).collectionRef);return f(c,{ref:i,children:r})});u.displayName=l;const h=e+"CollectionItemSlot",d="data-radix-collection-item",p=Ta(h),m=t.forwardRef((e,n)=>{const{scope:r,children:i,...o}=e,a=t.useRef(null),l=ct(n,a),c=s(h,r);return t.useEffect(()=>(c.itemMap.set(a,{ref:a,...o}),()=>{c.itemMap.delete(a)})),f(p,{[d]:"",ref:l,children:i})});return m.displayName=h,[{Provider:a,Slot:u,ItemSlot:m},function(n){const r=s(e+"CollectionConsumer",n);return t.useCallback(()=>{const e=r.collectionRef.current;if(!e)return[];const t=Array.from(e.querySelectorAll(`[${d}]`));return Array.from(r.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[r.collectionRef,r.itemMap])},i]}var Ba=e.createContext(void 0);function Fa(t){const n=e.useContext(Ba);return t||n||"ltr"}var ja,Wa="dismissableLayer.update",za="dismissableLayer.pointerDownOutside",Ha="dismissableLayer.focusOutside",Va=e.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),qa=e.forwardRef((t,n)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:a,onDismiss:l,...c}=t,u=e.useContext(Va),[h,d]=e.useState(null),p=h?.ownerDocument??globalThis?.document,[,m]=e.useState({}),g=ct(n,e=>d(e)),v=Array.from(u.layers),[b]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),y=v.indexOf(b),w=h?v.indexOf(h):-1,x=u.layersWithOutsidePointerEventsDisabled.size>0,k=w>=y,S=function(t,n=globalThis?.document){const r=qt(t),i=e.useRef(!1),o=e.useRef(()=>{});return e.useEffect(()=>{const e=e=>{if(e.target&&!i.current){let t=function(){$a(za,r,i,{discrete:!0})};const i={originalEvent:e};"touch"===e.pointerType?(n.removeEventListener("click",o.current),o.current=t,n.addEventListener("click",o.current,{once:!0})):t()}else n.removeEventListener("click",o.current);i.current=!1},t=window.setTimeout(()=>{n.addEventListener("pointerdown",e)},0);return()=>{window.clearTimeout(t),n.removeEventListener("pointerdown",e),n.removeEventListener("click",o.current)}},[n,r]),{onPointerDownCapture:()=>i.current=!0}}(e=>{const t=e.target,n=[...u.branches].some(e=>e.contains(t));k&&!n&&(o?.(e),a?.(e),e.defaultPrevented||l?.())},p),E=function(t,n=globalThis?.document){const r=qt(t),i=e.useRef(!1);return e.useEffect(()=>{const e=e=>{if(e.target&&!i.current){$a(Ha,r,{originalEvent:e},{discrete:!1})}};return n.addEventListener("focusin",e),()=>n.removeEventListener("focusin",e)},[n,r]),{onFocusCapture:()=>i.current=!0,onBlurCapture:()=>i.current=!1}}(e=>{const t=e.target;[...u.branches].some(e=>e.contains(t))||(s?.(e),a?.(e),e.defaultPrevented||l?.())},p);return Ut(e=>{w===u.layers.size-1&&(i?.(e),!e.defaultPrevented&&l&&(e.preventDefault(),l()))},p),e.useEffect(()=>{if(h)return r&&(0===u.layersWithOutsidePointerEventsDisabled.size&&(ja=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(h)),u.layers.add(h),Ua(),()=>{r&&1===u.layersWithOutsidePointerEventsDisabled.size&&(p.body.style.pointerEvents=ja)}},[h,p,r,u]),e.useEffect(()=>()=>{h&&(u.layers.delete(h),u.layersWithOutsidePointerEventsDisabled.delete(h),Ua())},[h,u]),e.useEffect(()=>{const e=()=>m({});return document.addEventListener(Wa,e),()=>document.removeEventListener(Wa,e)},[]),f(La.div,{...c,ref:g,style:{pointerEvents:x?k?"auto":"none":void 0,...t.style},onFocusCapture:Tt(t.onFocusCapture,E.onFocusCapture),onBlurCapture:Tt(t.onBlurCapture,E.onBlurCapture),onPointerDownCapture:Tt(t.onPointerDownCapture,S.onPointerDownCapture)})});qa.displayName="DismissableLayer";function Ua(){const e=new CustomEvent(Wa);document.dispatchEvent(e)}function $a(e,t,n,{discrete:r}){const i=n.originalEvent.target,o=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?Ia(i,o):i.dispatchEvent(o)}e.forwardRef((t,n)=>{const r=e.useContext(Va),i=e.useRef(null),o=ct(n,i);return e.useEffect(()=>{const e=i.current;if(e)return r.branches.add(e),()=>{r.branches.delete(e)}},[r.branches]),f(La.div,{...t,ref:o})}).displayName="DismissableLayerBranch";var Ka="focusScope.autoFocusOnMount",Ya="focusScope.autoFocusOnUnmount",Ga={bubbles:!1,cancelable:!0},Xa=e.forwardRef((t,n)=>{const{loop:r=!1,trapped:i=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...a}=t,[l,c]=e.useState(null),u=qt(o),h=qt(s),d=e.useRef(null),p=ct(n,e=>c(e)),m=e.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;e.useEffect(()=>{if(i){let e=function(e){if(m.paused||!l)return;const t=e.target;l.contains(t)?d.current=t:el(d.current,{select:!0})},t=function(e){if(m.paused||!l)return;const t=e.relatedTarget;null!==t&&(l.contains(t)||el(d.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(const t of e)t.removedNodes.length>0&&el(l)};document.addEventListener("focusin",e),document.addEventListener("focusout",t);const r=new MutationObserver(n);return l&&r.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",e),document.removeEventListener("focusout",t),r.disconnect()}}},[i,l,m.paused]),e.useEffect(()=>{if(l){tl.add(m);const t=document.activeElement;if(!l.contains(t)){const n=new CustomEvent(Ka,Ga);l.addEventListener(Ka,u),l.dispatchEvent(n),n.defaultPrevented||(!function(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(el(r,{select:t}),document.activeElement!==n)return}((e=Ja(l),e.filter(e=>"A"!==e.tagName)),{select:!0}),document.activeElement===t&&el(l))}return()=>{l.removeEventListener(Ka,u),setTimeout(()=>{const e=new CustomEvent(Ya,Ga);l.addEventListener(Ya,h),l.dispatchEvent(e),e.defaultPrevented||el(t??document.body,{select:!0}),l.removeEventListener(Ya,h),tl.remove(m)},0)}}var e},[l,u,h,m]);const g=e.useCallback(e=>{if(!r&&!i)return;if(m.paused)return;const t="Tab"===e.key&&!e.altKey&&!e.ctrlKey&&!e.metaKey,n=document.activeElement;if(t&&n){const t=e.currentTarget,[i,o]=function(e){const t=Ja(e),n=Qa(t,e),r=Qa(t.reverse(),e);return[n,r]}(t);i&&o?e.shiftKey||n!==o?e.shiftKey&&n===i&&(e.preventDefault(),r&&el(o,{select:!0})):(e.preventDefault(),r&&el(i,{select:!0})):n===t&&e.preventDefault()}},[r,i,m.paused]);return f(La.div,{tabIndex:-1,...a,ref:p,onKeyDown:g})});function Ja(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{const t="INPUT"===e.tagName&&"hidden"===e.type;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Qa(e,t){for(const n of e)if(!Za(n,{upTo:t}))return n}function Za(e,{upTo:t}){if("hidden"===getComputedStyle(e).visibility)return!0;for(;e;){if(void 0!==t&&e===t)return!1;if("none"===getComputedStyle(e).display)return!0;e=e.parentElement}return!1}function el(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&function(e){return e instanceof HTMLInputElement&&"select"in e}(e)&&t&&e.select()}}Xa.displayName="FocusScope";var tl=function(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=nl(e,t),e.unshift(t)},remove(t){e=nl(e,t),e[0]?.resume()}}}();function nl(e,t){const n=[...e],r=n.indexOf(t);return-1!==r&&n.splice(r,1),n}var rl=e.forwardRef((e,t)=>{const{children:n,width:r=10,height:i=5,...o}=e;return f(La.svg,{...o,ref:t,width:r,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:f("polygon",{points:"0,0 30,0 15,10"})})});rl.displayName="Arrow";var il=rl,ol="Popper",[sl,al]=Rt(ol),[ll,cl]=sl(ol),ul=t=>{const{__scopePopper:n,children:r}=t,[i,o]=e.useState(null);return f(ll,{scope:n,anchor:i,onAnchorChange:o,children:r})};ul.displayName=ol;var hl="PopperAnchor",dl=e.forwardRef((t,n)=>{const{__scopePopper:r,virtualRef:i,...o}=t,s=cl(hl,r),a=e.useRef(null),l=ct(n,a),c=e.useRef(null);return e.useEffect(()=>{const e=c.current;c.current=i?.current||a.current,e!==c.current&&s.onAnchorChange(c.current)}),i?null:f(La.div,{...o,ref:l})});dl.displayName=hl;var fl="PopperContent",[pl,ml]=sl(fl),gl=e.forwardRef((t,n)=>{const{__scopePopper:r,side:i="bottom",sideOffset:o=0,align:s="center",alignOffset:a=0,arrowPadding:l=0,avoidCollisions:c=!0,collisionBoundary:u=[],collisionPadding:h=0,sticky:d="partial",hideWhenDetached:p=!1,updatePositionStrategy:m="optimized",onPlaced:g,...v}=t,b=cl(fl,r),[y,w]=e.useState(null),x=ct(n,e=>w(e)),[k,S]=e.useState(null),E=us(k),C=E?.width??0,N=E?.height??0,O=i+("center"!==s?"-"+s:""),A="number"==typeof h?h:{top:0,right:0,bottom:0,left:0,...h},M=Array.isArray(u)?u:[u],T=M.length>0,R={padding:A,boundary:M.filter(wl),altBoundary:T},{refs:D,floatingStyles:P,placement:L,isPositioned:I,middlewareData:_}=Zo({strategy:"fixed",placement:O,whileElementsMounted:(...e)=>jo(...e,{animationFrame:"always"===m}),elements:{reference:b.anchor},middleware:[ts({mainAxis:o+N,alignmentAxis:a}),c&&ns({mainAxis:!0,crossAxis:!1,limiter:"partial"===d?rs():void 0,...R}),c&&is({...R}),os({...R,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{const{width:i,height:o}=t.reference,s=e.floating.style;s.setProperty("--radix-popper-available-width",`${n}px`),s.setProperty("--radix-popper-available-height",`${r}px`),s.setProperty("--radix-popper-anchor-width",`${i}px`),s.setProperty("--radix-popper-anchor-height",`${o}px`)}}),k&&as({element:k,padding:l}),xl({arrowWidth:C,arrowHeight:N}),p&&ss({strategy:"referenceHidden",...R})]}),[B,F]=kl(L),j=qt(g);Pt(()=>{I&&j?.()},[I,j]);const W=_.arrow?.x,z=_.arrow?.y,H=0!==_.arrow?.centerOffset,[V,q]=e.useState();return Pt(()=>{y&&q(window.getComputedStyle(y).zIndex)},[y]),f("div",{ref:D.setFloating,"data-radix-popper-content-wrapper":"",style:{...P,transform:I?P.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:V,"--radix-popper-transform-origin":[_.transformOrigin?.x,_.transformOrigin?.y].join(" "),..._.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:f(pl,{scope:r,placedSide:B,onArrowChange:S,arrowX:W,arrowY:z,shouldHideArrow:H,children:f(La.div,{"data-side":B,"data-align":F,...v,ref:x,style:{...v.style,animation:I?void 0:"none"}})})})});gl.displayName=fl;var vl="PopperArrow",bl={top:"bottom",right:"left",bottom:"top",left:"right"},yl=e.forwardRef(function(e,t){const{__scopePopper:n,...r}=e,i=ml(vl,n),o=bl[i.placedSide];return f("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:f(il,{...r,ref:t,style:{...r.style,display:"block"}})})});function wl(e){return null!==e}yl.displayName=vl;var xl=e=>({name:"transformOrigin",options:e,fn(t){const{placement:n,rects:r,middlewareData:i}=t,o=0!==i.arrow?.centerOffset,s=o?0:e.arrowWidth,a=o?0:e.arrowHeight,[l,c]=kl(n),u={start:"0%",center:"50%",end:"100%"}[c],h=(i.arrow?.x??0)+s/2,d=(i.arrow?.y??0)+a/2;let f="",p="";return"bottom"===l?(f=o?u:`${h}px`,p=-a+"px"):"top"===l?(f=o?u:`${h}px`,p=`${r.floating.height+a}px`):"right"===l?(f=-a+"px",p=o?u:`${d}px`):"left"===l&&(f=`${r.floating.width+a}px`,p=o?u:`${d}px`),{data:{x:f,y:p}}}});function kl(e){const[t,n="center"]=e.split("-");return[t,n]}var Sl=ul,El=dl,Cl=gl,Nl=yl,Ol=e.forwardRef((t,n)=>{const{container:r,...i}=t,[o,s]=e.useState(!1);Pt(()=>s(!0),[]);const a=r||o&&globalThis?.document?.body;return a?v.createPortal(f(La.div,{...i,ref:n}),a):null});Ol.displayName="Portal";var Al=t=>{const{present:n,children:r}=t,i=function(t){const[n,r]=e.useState(),i=e.useRef(null),o=e.useRef(t),s=e.useRef("none"),a=t?"mounted":"unmounted",[l,c]=function(t,n){return e.useReducer((e,t)=>n[e][t]??e,t)}(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return e.useEffect(()=>{const e=Ml(i.current);s.current="mounted"===l?e:"none"},[l]),Pt(()=>{const e=i.current,n=o.current;if(n!==t){const r=s.current,i=Ml(e);if(t)c("MOUNT");else if("none"===i||"none"===e?.display)c("UNMOUNT");else{c(n&&r!==i?"ANIMATION_OUT":"UNMOUNT")}o.current=t}},[t,c]),Pt(()=>{if(n){let e;const t=n.ownerDocument.defaultView??window,r=r=>{const s=Ml(i.current).includes(CSS.escape(r.animationName));if(r.target===n&&s&&(c("ANIMATION_END"),!o.current)){const r=n.style.animationFillMode;n.style.animationFillMode="forwards",e=t.setTimeout(()=>{"forwards"===n.style.animationFillMode&&(n.style.animationFillMode=r)})}},a=e=>{e.target===n&&(s.current=Ml(i.current))};return n.addEventListener("animationstart",a),n.addEventListener("animationcancel",r),n.addEventListener("animationend",r),()=>{t.clearTimeout(e),n.removeEventListener("animationstart",a),n.removeEventListener("animationcancel",r),n.removeEventListener("animationend",r)}}c("ANIMATION_END")},[n,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:e.useCallback(e=>{i.current=e?getComputedStyle(e):null,r(e)},[])}}(n),o="function"==typeof r?r({present:i.isPresent}):e.Children.only(r),s=ct(i.ref,function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;if(n)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(o));return"function"==typeof r||i.isPresent?e.cloneElement(o,{ref:s}):null};function Ml(e){return e?.animationName||"none"}Al.displayName="Presence";var Tl="rovingFocusGroup.onEntryFocus",Rl={bubbles:!1,cancelable:!0},Dl="RovingFocusGroup",[Pl,Ll,Il]=_a(Dl),[_l,Bl]=Rt(Dl,[Il]),[Fl,jl]=_l(Dl),Wl=e.forwardRef((e,t)=>f(Pl.Provider,{scope:e.__scopeRovingFocusGroup,children:f(Pl.Slot,{scope:e.__scopeRovingFocusGroup,children:f(zl,{...e,ref:t})})}));Wl.displayName=Dl;var zl=e.forwardRef((t,n)=>{const{__scopeRovingFocusGroup:r,orientation:i,loop:o=!1,dir:s,currentTabStopId:a,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:c,onEntryFocus:u,preventScrollOnEntryFocus:h=!1,...d}=t,p=e.useRef(null),m=ct(n,p),g=Fa(s),[v,b]=Ft({prop:a,defaultProp:l??null,onChange:c,caller:Dl}),[y,w]=e.useState(!1),x=qt(u),k=Ll(r),S=e.useRef(!1),[E,C]=e.useState(0);return e.useEffect(()=>{const e=p.current;if(e)return e.addEventListener(Tl,x),()=>e.removeEventListener(Tl,x)},[x]),f(Fl,{scope:r,orientation:i,dir:g,loop:o,currentTabStopId:v,onItemFocus:e.useCallback(e=>b(e),[b]),onItemShiftTab:e.useCallback(()=>w(!0),[]),onFocusableItemAdd:e.useCallback(()=>C(e=>e+1),[]),onFocusableItemRemove:e.useCallback(()=>C(e=>e-1),[]),children:f(La.div,{tabIndex:y||0===E?-1:0,"data-orientation":i,...d,ref:m,style:{outline:"none",...t.style},onMouseDown:Tt(t.onMouseDown,()=>{S.current=!0}),onFocus:Tt(t.onFocus,e=>{const t=!S.current;if(e.target===e.currentTarget&&t&&!y){const t=new CustomEvent(Tl,Rl);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){const e=k().filter(e=>e.focusable);Ul([e.find(e=>e.active),e.find(e=>e.id===v),...e].filter(Boolean).map(e=>e.ref.current),h)}}S.current=!1}),onBlur:Tt(t.onBlur,()=>w(!1))})})}),Hl="RovingFocusGroupItem",Vl=e.forwardRef((t,n)=>{const{__scopeRovingFocusGroup:r,focusable:i=!0,active:o=!1,tabStopId:s,children:a,...l}=t,c=_t(),u=s||c,h=jl(Hl,r),d=h.currentTabStopId===u,p=Ll(r),{onFocusableItemAdd:m,onFocusableItemRemove:g,currentTabStopId:v}=h;return e.useEffect(()=>{if(i)return m(),()=>g()},[i,m,g]),f(Pl.ItemSlot,{scope:r,id:u,focusable:i,active:o,children:f(La.span,{tabIndex:d?0:-1,"data-orientation":h.orientation,...l,ref:n,onMouseDown:Tt(t.onMouseDown,e=>{i?h.onItemFocus(u):e.preventDefault()}),onFocus:Tt(t.onFocus,()=>h.onItemFocus(u)),onKeyDown:Tt(t.onKeyDown,e=>{if("Tab"===e.key&&e.shiftKey)return void h.onItemShiftTab();if(e.target!==e.currentTarget)return;const t=function(e,t,n){const r=function(e,t){return"rtl"!==t?e:"ArrowLeft"===e?"ArrowRight":"ArrowRight"===e?"ArrowLeft":e}(e.key,n);return"vertical"===t&&["ArrowLeft","ArrowRight"].includes(r)||"horizontal"===t&&["ArrowUp","ArrowDown"].includes(r)?void 0:ql[r]}(e,h.orientation,h.dir);if(void 0!==t){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let i=p().filter(e=>e.focusable).map(e=>e.ref.current);if("last"===t)i.reverse();else if("prev"===t||"next"===t){"prev"===t&&i.reverse();const o=i.indexOf(e.currentTarget);i=h.loop?(r=o+1,(n=i).map((e,t)=>n[(r+t)%n.length])):i.slice(o+1)}setTimeout(()=>Ul(i))}var n,r}),children:"function"==typeof a?a({isCurrentTabStop:d,hasTabStop:null!=v}):a})})});Vl.displayName=Hl;var ql={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Ul(e,t=!1){const n=document.activeElement;for(const r of e){if(r===n)return;if(r.focus({preventScroll:t}),document.activeElement!==n)return}}var $l=Wl,Kl=Vl,Yl=["Enter"," "],Gl=["ArrowUp","PageDown","End"],Xl=["ArrowDown","PageUp","Home",...Gl],Jl={ltr:[...Yl,"ArrowRight"],rtl:[...Yl,"ArrowLeft"]},Ql={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Zl="Menu",[ec,tc,nc]=_a(Zl),[rc,ic]=Rt(Zl,[nc,al,Bl]),oc=al(),sc=Bl(),[ac,lc]=rc(Zl),[cc,uc]=rc(Zl),hc=t=>{const{__scopeMenu:n,open:r=!1,children:i,dir:o,onOpenChange:s,modal:a=!0}=t,l=oc(n),[c,u]=e.useState(null),h=e.useRef(!1),d=qt(s),p=Fa(o);return e.useEffect(()=>{const e=()=>{h.current=!0,document.addEventListener("pointerdown",t,{capture:!0,once:!0}),document.addEventListener("pointermove",t,{capture:!0,once:!0})},t=()=>h.current=!1;return document.addEventListener("keydown",e,{capture:!0}),()=>{document.removeEventListener("keydown",e,{capture:!0}),document.removeEventListener("pointerdown",t,{capture:!0}),document.removeEventListener("pointermove",t,{capture:!0})}},[]),f(Sl,{...l,children:f(ac,{scope:n,open:r,onOpenChange:d,content:c,onContentChange:u,children:f(cc,{scope:n,onClose:e.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:h,dir:p,modal:a,children:i})})})};hc.displayName=Zl;var dc=e.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=oc(n);return f(El,{...i,...r,ref:t})});dc.displayName="MenuAnchor";var fc="MenuPortal",[pc,mc]=rc(fc,{forceMount:void 0}),gc=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:i}=e,o=lc(fc,t);return f(pc,{scope:t,forceMount:n,children:f(Al,{present:n||o.open,children:f(Ol,{asChild:!0,container:i,children:r})})})};gc.displayName=fc;var vc="MenuContent",[bc,yc]=rc(vc),wc=e.forwardRef((e,t)=>{const n=mc(vc,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,o=lc(vc,e.__scopeMenu),s=uc(vc,e.__scopeMenu);return f(ec.Provider,{scope:e.__scopeMenu,children:f(Al,{present:r||o.open,children:f(ec.Slot,{scope:e.__scopeMenu,children:s.modal?f(xc,{...i,ref:t}):f(kc,{...i,ref:t})})})})}),xc=e.forwardRef((t,n)=>{const r=lc(vc,t.__scopeMenu),i=e.useRef(null),o=ct(n,i);return e.useEffect(()=>{const e=i.current;if(e)return cr(e)},[]),f(Ec,{...t,ref:o,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:Tt(t.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})}),kc=e.forwardRef((e,t)=>{const n=lc(vc,e.__scopeMenu);return f(Ec,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Sc=Ta("MenuContent.ScrollLock"),Ec=e.forwardRef((t,n)=>{const{__scopeMenu:r,loop:i=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:a,disableOutsidePointerEvents:l,onEntryFocus:c,onEscapeKeyDown:u,onPointerDownOutside:h,onFocusOutside:d,onInteractOutside:p,onDismiss:m,disableOutsideScroll:g,...v}=t,b=lc(vc,r),y=uc(vc,r),w=oc(r),x=sc(r),k=tc(r),[S,E]=e.useState(null),C=e.useRef(null),N=ct(n,C,b.onContentChange),O=e.useRef(0),A=e.useRef(""),M=e.useRef(0),T=e.useRef(null),R=e.useRef("right"),D=e.useRef(0),P=g?nr:e.Fragment,L=g?{as:Sc,allowPinchZoom:!0}:void 0,I=e=>{const t=A.current+e,n=k().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,o=function(e,t,n){const r=t.length>1&&Array.from(t).every(e=>e===t[0]),i=r?t[0]:t,o=n?e.indexOf(n):-1;let s=(a=e,l=Math.max(o,0),a.map((e,t)=>a[(l+t)%a.length]));var a,l;1===i.length&&(s=s.filter(e=>e!==n));const c=s.find(e=>e.toLowerCase().startsWith(i.toLowerCase()));return c!==n?c:void 0}(n.map(e=>e.textValue),t,i),s=n.find(e=>e.textValue===o)?.ref.current;!function e(t){A.current=t,window.clearTimeout(O.current),""!==t&&(O.current=window.setTimeout(()=>e(""),1e3))}(t),s&&setTimeout(()=>s.focus())};e.useEffect(()=>()=>window.clearTimeout(O.current),[]),mn();const _=e.useCallback(e=>R.current===T.current?.side&&function(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return function(e,t){const{x:n,y:r}=e;let i=!1;for(let e=0,o=t.length-1;e<t.length;o=e++){const s=t[e],a=t[o],l=s.x,c=s.y,u=a.x,h=a.y;c>r!=h>r&&n<(u-l)*(r-c)/(h-c)+l&&(i=!i)}return i}(n,t)}(e,T.current?.area),[]);return f(bc,{scope:r,searchRef:A,onItemEnter:e.useCallback(e=>{_(e)&&e.preventDefault()},[_]),onItemLeave:e.useCallback(e=>{_(e)||(C.current?.focus(),E(null))},[_]),onTriggerLeave:e.useCallback(e=>{_(e)&&e.preventDefault()},[_]),pointerGraceTimerRef:M,onPointerGraceIntentChange:e.useCallback(e=>{T.current=e},[]),children:f(P,{...L,children:f(Xa,{asChild:!0,trapped:o,onMountAutoFocus:Tt(s,e=>{e.preventDefault(),C.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:a,children:f(qa,{asChild:!0,disableOutsidePointerEvents:l,onEscapeKeyDown:u,onPointerDownOutside:h,onFocusOutside:d,onInteractOutside:p,onDismiss:m,children:f($l,{asChild:!0,...x,dir:y.dir,orientation:"vertical",loop:i,currentTabStopId:S,onCurrentTabStopIdChange:E,onEntryFocus:Tt(c,e=>{y.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:f(Cl,{role:"menu","aria-orientation":"vertical","data-state":Xc(b.open),"data-radix-menu-content":"",dir:y.dir,...w,...v,ref:N,style:{outline:"none",...v.style},onKeyDown:Tt(v.onKeyDown,e=>{const t=e.target.closest("[data-radix-menu-content]")===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=1===e.key.length;t&&("Tab"===e.key&&e.preventDefault(),!n&&r&&I(e.key));const i=C.current;if(e.target!==i)return;if(!Xl.includes(e.key))return;e.preventDefault();const o=k().filter(e=>!e.disabled).map(e=>e.ref.current);Gl.includes(e.key)&&o.reverse(),function(e){const t=document.activeElement;for(const n of e){if(n===t)return;if(n.focus(),document.activeElement!==t)return}}(o)}),onBlur:Tt(t.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(O.current),A.current="")}),onPointerMove:Tt(t.onPointerMove,Zc(e=>{const t=e.target,n=D.current!==e.clientX;if(e.currentTarget.contains(t)&&n){const t=e.clientX>D.current?"right":"left";R.current=t,D.current=e.clientX}}))})})})})})})});wc.displayName=vc;var Cc=e.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return f(La.div,{role:"group",...r,ref:t})});Cc.displayName="MenuGroup";var Nc=e.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return f(La.div,{...r,ref:t})});Nc.displayName="MenuLabel";var Oc="MenuItem",Ac="menu.itemSelect",Mc=e.forwardRef((t,n)=>{const{disabled:r=!1,onSelect:i,...o}=t,s=e.useRef(null),a=uc(Oc,t.__scopeMenu),l=yc(Oc,t.__scopeMenu),c=ct(n,s),u=e.useRef(!1);return f(Tc,{...o,ref:c,disabled:r,onClick:Tt(t.onClick,()=>{const e=s.current;if(!r&&e){const t=new CustomEvent(Ac,{bubbles:!0,cancelable:!0});e.addEventListener(Ac,e=>i?.(e),{once:!0}),Ia(e,t),t.defaultPrevented?u.current=!1:a.onClose()}}),onPointerDown:e=>{t.onPointerDown?.(e),u.current=!0},onPointerUp:Tt(t.onPointerUp,e=>{u.current||e.currentTarget?.click()}),onKeyDown:Tt(t.onKeyDown,e=>{const t=""!==l.searchRef.current;r||t&&" "===e.key||Yl.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});Mc.displayName=Oc;var Tc=e.forwardRef((t,n)=>{const{__scopeMenu:r,disabled:i=!1,textValue:o,...s}=t,a=yc(Oc,r),l=sc(r),c=e.useRef(null),u=ct(n,c),[h,d]=e.useState(!1),[p,m]=e.useState("");return e.useEffect(()=>{const e=c.current;e&&m((e.textContent??"").trim())},[s.children]),f(ec.ItemSlot,{scope:r,disabled:i,textValue:o??p,children:f(Kl,{asChild:!0,...l,focusable:!i,children:f(La.div,{role:"menuitem","data-highlighted":h?"":void 0,"aria-disabled":i||void 0,"data-disabled":i?"":void 0,...s,ref:u,onPointerMove:Tt(t.onPointerMove,Zc(e=>{if(i)a.onItemLeave(e);else if(a.onItemEnter(e),!e.defaultPrevented){e.currentTarget.focus({preventScroll:!0})}})),onPointerLeave:Tt(t.onPointerLeave,Zc(e=>a.onItemLeave(e))),onFocus:Tt(t.onFocus,()=>d(!0)),onBlur:Tt(t.onBlur,()=>d(!1))})})})}),Rc=e.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...i}=e;return f(jc,{scope:e.__scopeMenu,checked:n,children:f(Mc,{role:"menuitemcheckbox","aria-checked":Jc(n)?"mixed":n,...i,ref:t,"data-state":Qc(n),onSelect:Tt(i.onSelect,()=>r?.(!!Jc(n)||!n),{checkForDefaultPrevented:!1})})})});Rc.displayName="MenuCheckboxItem";var Dc="MenuRadioGroup",[Pc,Lc]=rc(Dc,{value:void 0,onValueChange:()=>{}}),Ic=e.forwardRef((e,t)=>{const{value:n,onValueChange:r,...i}=e,o=qt(r);return f(Pc,{scope:e.__scopeMenu,value:n,onValueChange:o,children:f(Cc,{...i,ref:t})})});Ic.displayName=Dc;var _c="MenuRadioItem",Bc=e.forwardRef((e,t)=>{const{value:n,...r}=e,i=Lc(_c,e.__scopeMenu),o=n===i.value;return f(jc,{scope:e.__scopeMenu,checked:o,children:f(Mc,{role:"menuitemradio","aria-checked":o,...r,ref:t,"data-state":Qc(o),onSelect:Tt(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});Bc.displayName=_c;var Fc="MenuItemIndicator",[jc,Wc]=rc(Fc,{checked:!1}),zc=e.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...i}=e,o=Wc(Fc,n);return f(Al,{present:r||Jc(o.checked)||!0===o.checked,children:f(La.span,{...i,ref:t,"data-state":Qc(o.checked)})})});zc.displayName=Fc;var Hc=e.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return f(La.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});Hc.displayName="MenuSeparator";var Vc=e.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=oc(n);return f(Nl,{...i,...r,ref:t})});Vc.displayName="MenuArrow";var[qc,Uc]=rc("MenuSub"),$c="MenuSubTrigger",Kc=e.forwardRef((t,n)=>{const r=lc($c,t.__scopeMenu),i=uc($c,t.__scopeMenu),o=Uc($c,t.__scopeMenu),s=yc($c,t.__scopeMenu),a=e.useRef(null),{pointerGraceTimerRef:l,onPointerGraceIntentChange:c}=s,u={__scopeMenu:t.__scopeMenu},h=e.useCallback(()=>{a.current&&window.clearTimeout(a.current),a.current=null},[]);return e.useEffect(()=>h,[h]),e.useEffect(()=>{const e=l.current;return()=>{window.clearTimeout(e),c(null)}},[l,c]),f(dc,{asChild:!0,...u,children:f(Tc,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":r.open,"aria-controls":o.contentId,"data-state":Xc(r.open),...t,ref:lt(n,o.onTriggerChange),onClick:e=>{t.onClick?.(e),t.disabled||e.defaultPrevented||(e.currentTarget.focus(),r.open||r.onOpenChange(!0))},onPointerMove:Tt(t.onPointerMove,Zc(e=>{s.onItemEnter(e),e.defaultPrevented||t.disabled||r.open||a.current||(s.onPointerGraceIntentChange(null),a.current=window.setTimeout(()=>{r.onOpenChange(!0),h()},100))})),onPointerLeave:Tt(t.onPointerLeave,Zc(e=>{h();const t=r.content?.getBoundingClientRect();if(t){const n=r.content?.dataset.side,i="right"===n,o=i?-5:5,a=t[i?"left":"right"],c=t[i?"right":"left"];s.onPointerGraceIntentChange({area:[{x:e.clientX+o,y:e.clientY},{x:a,y:t.top},{x:c,y:t.top},{x:c,y:t.bottom},{x:a,y:t.bottom}],side:n}),window.clearTimeout(l.current),l.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(e),e.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:Tt(t.onKeyDown,e=>{const n=""!==s.searchRef.current;t.disabled||n&&" "===e.key||Jl[i.dir].includes(e.key)&&(r.onOpenChange(!0),r.content?.focus(),e.preventDefault())})})})});Kc.displayName=$c;var Yc="MenuSubContent",Gc=e.forwardRef((t,n)=>{const r=mc(vc,t.__scopeMenu),{forceMount:i=r.forceMount,...o}=t,s=lc(vc,t.__scopeMenu),a=uc(vc,t.__scopeMenu),l=Uc(Yc,t.__scopeMenu),c=e.useRef(null),u=ct(n,c);return f(ec.Provider,{scope:t.__scopeMenu,children:f(Al,{present:i||s.open,children:f(ec.Slot,{scope:t.__scopeMenu,children:f(Ec,{id:l.contentId,"aria-labelledby":l.triggerId,...o,ref:u,align:"start",side:"rtl"===a.dir?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{a.isUsingKeyboardRef.current&&c.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:Tt(t.onFocusOutside,e=>{e.target!==l.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:Tt(t.onEscapeKeyDown,e=>{a.onClose(),e.preventDefault()}),onKeyDown:Tt(t.onKeyDown,e=>{const t=e.currentTarget.contains(e.target),n=Ql[a.dir].includes(e.key);t&&n&&(s.onOpenChange(!1),l.trigger?.focus(),e.preventDefault())})})})})})});function Xc(e){return e?"open":"closed"}function Jc(e){return"indeterminate"===e}function Qc(e){return Jc(e)?"indeterminate":e?"checked":"unchecked"}function Zc(e){return t=>"mouse"===t.pointerType?e(t):void 0}Gc.displayName=Yc;var eu=hc,tu=dc,nu=gc,ru=wc,iu=Cc,ou=Nc,su=Mc,au=Rc,lu=Ic,cu=Bc,uu=zc,hu=Hc,du=Vc,fu=Kc,pu=Gc,mu="DropdownMenu",[gu,vu]=Rt(mu,[ic]),bu=ic(),[yu,wu]=gu(mu),xu=t=>{const{__scopeDropdownMenu:n,children:r,dir:i,open:o,defaultOpen:s,onOpenChange:a,modal:l=!0}=t,c=bu(n),u=e.useRef(null),[h,d]=Ft({prop:o,defaultProp:s??!1,onChange:a,caller:mu});return f(yu,{scope:n,triggerId:_t(),triggerRef:u,contentId:_t(),open:h,onOpenChange:d,onOpenToggle:e.useCallback(()=>d(e=>!e),[d]),modal:l,children:f(eu,{...c,open:h,onOpenChange:d,dir:i,modal:l,children:r})})};xu.displayName=mu;var ku="DropdownMenuTrigger",Su=e.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,o=wu(ku,n),s=bu(n);return f(tu,{asChild:!0,...s,children:f(La.button,{type:"button",id:o.triggerId,"aria-haspopup":"menu","aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":o.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...i,ref:lt(t,o.triggerRef),onPointerDown:Tt(e.onPointerDown,e=>{r||0!==e.button||!1!==e.ctrlKey||(o.onOpenToggle(),o.open||e.preventDefault())}),onKeyDown:Tt(e.onKeyDown,e=>{r||(["Enter"," "].includes(e.key)&&o.onOpenToggle(),"ArrowDown"===e.key&&o.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(e.key)&&e.preventDefault())})})})});Su.displayName=ku;var Eu=e=>{const{__scopeDropdownMenu:t,...n}=e,r=bu(t);return f(nu,{...r,...n})};Eu.displayName="DropdownMenuPortal";var Cu="DropdownMenuContent",Nu=e.forwardRef((t,n)=>{const{__scopeDropdownMenu:r,...i}=t,o=wu(Cu,r),s=bu(r),a=e.useRef(!1);return f(ru,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...i,ref:n,onCloseAutoFocus:Tt(t.onCloseAutoFocus,e=>{a.current||o.triggerRef.current?.focus(),a.current=!1,e.preventDefault()}),onInteractOutside:Tt(t.onInteractOutside,e=>{const t=e.detail.originalEvent,n=0===t.button&&!0===t.ctrlKey,r=2===t.button||n;o.modal&&!r||(a.current=!0)}),style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Nu.displayName=Cu;e.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=bu(n);return f(iu,{...i,...r,ref:t})}).displayName="DropdownMenuGroup";var Ou=e.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=bu(n);return f(ou,{...i,...r,ref:t})});Ou.displayName="DropdownMenuLabel";var Au=e.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=bu(n);return f(su,{...i,...r,ref:t})});Au.displayName="DropdownMenuItem";var Mu=e.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=bu(n);return f(au,{...i,...r,ref:t})});Mu.displayName="DropdownMenuCheckboxItem";e.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=bu(n);return f(lu,{...i,...r,ref:t})}).displayName="DropdownMenuRadioGroup";var Tu=e.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=bu(n);return f(cu,{...i,...r,ref:t})});Tu.displayName="DropdownMenuRadioItem";var Ru=e.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=bu(n);return f(uu,{...i,...r,ref:t})});Ru.displayName="DropdownMenuItemIndicator";var Du=e.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=bu(n);return f(hu,{...i,...r,ref:t})});Du.displayName="DropdownMenuSeparator";e.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=bu(n);return f(du,{...i,...r,ref:t})}).displayName="DropdownMenuArrow";var Pu=e.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=bu(n);return f(fu,{...i,...r,ref:t})});Pu.displayName="DropdownMenuSubTrigger";var Lu=e.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=bu(n);return f(pu,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Lu.displayName="DropdownMenuSubContent";var Iu=Eu,_u=Nu,Bu=Ou,Fu=Au,ju=Mu,Wu=Tu,zu=Ru,Hu=Du,Vu=Pu,qu=Lu,Uu=xu,$u=Su,Ku=e.forwardRef(function(t,n){var r=t.className,i=t.inset,o=t.children,s=D(t,["className","inset","children"]);return e.createElement(Vu,Object.assign({ref:n,className:ot("flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",i&&"pl-8",r)},s),o,e.createElement(z,{className:"ml-auto"}))});Ku.displayName=Vu.displayName;var Yu=e.forwardRef(function(t,n){var r=t.className,i=D(t,["className"]);return e.createElement(qu,Object.assign({ref:n,className:ot("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]",r)},i))});Yu.displayName=qu.displayName;var Gu=e.forwardRef(function(t,n){var r=t.className,i=t.sideOffset,o=void 0===i?4:i,s=D(t,["className","sideOffset"]);return e.createElement(Iu,null,e.createElement(_u,Object.assign({ref:n,sideOffset:o,className:ot("z-50 max-h-[var(--radix-dropdown-menu-content-available-height)] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]",r)},s)))});Gu.displayName=_u.displayName;var Xu=e.forwardRef(function(t,n){var r=t.className,i=t.inset,o=D(t,["className","inset"]);return e.createElement(Fu,Object.assign({ref:n,className:ot("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",i&&"pl-8",r)},o))});Xu.displayName=Fu.displayName;var Ju=e.forwardRef(function(t,n){var r=t.className,i=t.children,o=t.checked,s=D(t,["className","children","checked"]);return e.createElement(ju,Object.assign({ref:n,className:ot("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",r),checked:o},s),e.createElement("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center"},e.createElement(zu,null,e.createElement(F,{className:"h-4 w-4"}))),i)});Ju.displayName=ju.displayName;var Qu=e.forwardRef(function(t,n){var r=t.className,i=t.children,o=D(t,["className","children"]);return e.createElement(Wu,Object.assign({ref:n,className:ot("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",r)},o),e.createElement("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center"},e.createElement(zu,null,e.createElement(V,{className:"h-2 w-2 fill-current"}))),i)});Qu.displayName=Wu.displayName;var Zu=e.forwardRef(function(t,n){var r=t.className,i=t.inset,o=D(t,["className","inset"]);return e.createElement(Bu,Object.assign({ref:n,className:ot("px-2 py-1.5 text-sm font-semibold",i&&"pl-8",r)},o))});Zu.displayName=Bu.displayName;var eh=e.forwardRef(function(t,n){var r=t.className,i=D(t,["className"]);return e.createElement(Hu,Object.assign({ref:n,className:ot("-mx-1 my-1 h-px bg-muted",r)},i))});eh.displayName=Hu.displayName;var th=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((t,n)=>{const r=ft(`Primitive.${n}`),i=e.forwardRef((e,t)=>{const{asChild:i,...o}=e,s=i?r:n;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),f(s,{...o,ref:t})});return i.displayName=`Primitive.${n}`,{...t,[n]:i}},{}),nh=e.forwardRef((e,t)=>f(th.label,{...e,ref:t,onMouseDown:t=>{t.target.closest("button, input, select, textarea")||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));nh.displayName="Label";var rh=nh,ih=wt("text-sm font-bold leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 text-foreground"),oh=e.forwardRef(function(t,n){var r=t.className,i=D(t,["className"]);return e.createElement(rh,Object.assign({ref:n,className:ot(ih(),r)},i))});oh.displayName=rh.displayName;var sh=e.forwardRef(function(t,n){var r=t.className,i=D(t,["className"]);return e.createElement("div",Object.assign({ref:n,className:ot("rounded-[2rem] border border-[hsl(var(--border))]/50 bg-card text-card-foreground shadow-[0_4px_20px_-2px_rgba(93,112,82,0.15)] transition-all duration-300",r)},i))});sh.displayName="Card";var ah=e.forwardRef(function(t,n){var r=t.className,i=D(t,["className"]);return e.createElement("div",Object.assign({ref:n,className:ot("flex flex-col space-y-1.5 p-6",r)},i))});ah.displayName="CardHeader";var lh=e.forwardRef(function(t,n){var r=t.className,i=D(t,["className"]);return e.createElement("div",Object.assign({ref:n,className:ot("text-2xl font-bold leading-none tracking-tight",r)},i))});lh.displayName="CardTitle";var ch=e.forwardRef(function(t,n){var r=t.className,i=D(t,["className"]);return e.createElement("div",Object.assign({ref:n,className:ot("text-sm text-muted-foreground",r)},i))});ch.displayName="CardDescription";var uh=e.forwardRef(function(t,n){var r=t.className,i=D(t,["className"]);return e.createElement("div",Object.assign({ref:n,className:ot("p-6 pt-0",r)},i))});uh.displayName="CardContent";var hh=e.forwardRef(function(t,n){var r=t.className,i=D(t,["className"]);return e.createElement("div",Object.assign({ref:n,className:ot("flex items-center p-6 pt-0",r)},i))});hh.displayName="CardFooter";var dh={items:[],config:Object.assign({},{top:24,duration:3,maxCount:5})},fh=new Set;function ph(){fh.forEach(function(e){return e(dh.items.slice())})}function mh(e){switch(e){case"success":return t.createElement(B,null);case"error":return t.createElement(ce,null);case"warning":return t.createElement(_,null);case"loading":return t.createElement(J,{className:"animate-spin"});default:return t.createElement(G,null)}}function gh(e){var t,n,r;wh();var i=Date.now(),o=null!==(t=e.key)&&void 0!==t?t:"msg_".concat(i,"_").concat(Math.random().toString(36).slice(2)),s=dh.items.findIndex(function(e){return e.key===o}),a={key:o,content:e.content,duration:null!==(n=e.duration)&&void 0!==n?n:dh.config.duration,type:e.type,onClose:e.onClose,icon:null!==(r=e.icon)&&void 0!==r?r:mh(e.type),className:e.className,createdAt:i};return s>=0?dh.items[s]=Object.assign({},dh.items[s],a):(dh.items.length>=dh.config.maxCount&&dh.items.shift(),dh.items.push(a)),ph(),a.duration>0&&"loading"!==a.type&&window.setTimeout(function(){vh(o)},1e3*a.duration),{close:function(){return vh(o)}}}function vh(e){var t;if(void 0===e)return dh.items.forEach(function(e){var t;return null===(t=e.onClose)||void 0===t?void 0:t.call(e)}),dh.items=[],void ph();var n=dh.items.findIndex(function(t){return t.key===e});if(n>=0){var r=O(dh.items.splice(n,1),1)[0];null===(t=null==r?void 0:r.onClose)||void 0===t||t.call(r),ph()}}var bh=null,yh=null;function wh(){"undefined"!=typeof window&&(yh||((yh=document.createElement("div")).setAttribute("data-custom-message-holder",""),document.body.appendChild(yh)),bh||(bh=b(yh)).render(t.createElement(xh,null)))}function xh(){var e=function(){var e=O(i(dh.items),2),t=e[0],n=e[1];return a(function(){var e=n;return fh.add(e),function(){fh.delete(e)}},[]),t}(),n=dh.config.top;return t.createElement("div",{className:"fixed left-1/2 -translate-x-1/2 z-[1000] w-80 pointer-events-none",style:{top:n}},t.createElement("div",{className:"mx-auto flex w-full max-w-xl flex-col items-center gap-2 px-4"},e.map(function(e){var n,r,i=function(e){switch(e){case"success":return{container:"border-green-200 bg-green-50/90 text-green-800 border-l-4 border-l-green-500",icon:"text-green-500",text:"text-green-800"};case"error":return{container:"border-red-200 bg-red-50/90 text-red-800 border-l-4 border-l-red-500",icon:"text-red-500",text:"text-red-800"};case"warning":return{container:"border-yellow-200 bg-yellow-50/90 text-yellow-800 border-l-4 border-l-yellow-500",icon:"text-yellow-500",text:"text-yellow-800"};default:return{container:"border-blue-200 bg-blue-50/90 text-blue-800 border-l-4 border-l-blue-500",icon:"text-blue-500",text:"text-blue-800"}}}(e.type);return t.createElement("div",{key:e.key,className:"pointer-events-auto flex w-full items-center gap-2 rounded-md border px-3 py-2 backdrop-blur ".concat(i.container," ").concat(null!==(n=e.className)&&void 0!==n?n:"")},t.createElement("span",{className:"text-[18px] leading-none ".concat(i.icon)},null!==(r=e.icon)&&void 0!==r?r:mh(e.type)),t.createElement("div",{className:"min-w-0 flex-1 text-[14px] leading-normal ".concat(i.text)},"string"==typeof e.content?t.createElement("span",{className:"break-words align-middle"},e.content):e.content))})))}function kh(e,n,r,i){if(t.isValidElement(n)||"string"==typeof n||"number"==typeof n)return{type:e,content:n,duration:r,onClose:i};var o=n;return Object.assign({},o,{type:e})}var Sh,Eh,Ch=(Eh={open:function(e){var t;return gh(Object.assign({},e,{type:null!==(t=e.type)&&void 0!==t?t:"info"}))},info:function(e,t,n){return gh(kh("info",e,t,n))},success:function(e,t,n){return gh(kh("success",e,t,n))},error:function(e,t,n){return gh(kh("error",e,t,n))},warning:function(e,t,n){return gh(kh("warning",e,t,n))},loading:function(e,t,n){return gh(kh("loading",e,null!=t?t:0,n))},destroy:function(e){return vh(e)},config:function(e){return t=e,dh.config=Object.assign({},dh.config,t),void ph();var t},useMessage:function(){var e=s(function(){return"undefined"!=typeof window&&wh(),t.createElement(t.Fragment,null)},[]);return[Sh.current,e]}},(Sh={}).current=Eh,Eh);function Nh(e,t){return function(){return e.apply(t,arguments)}}const{toString:Oh}=Object.prototype,{getPrototypeOf:Ah}=Object,{iterator:Mh,toStringTag:Th}=Symbol,Rh=(Dh=Object.create(null),e=>{const t=Oh.call(e);return Dh[t]||(Dh[t]=t.slice(8,-1).toLowerCase())});var Dh;const Ph=e=>(e=e.toLowerCase(),t=>Rh(t)===e),Lh=e=>t=>typeof t===e,{isArray:Ih}=Array,_h=Lh("undefined");function Bh(e){return null!==e&&!_h(e)&&null!==e.constructor&&!_h(e.constructor)&&Wh(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Fh=Ph("ArrayBuffer");const jh=Lh("string"),Wh=Lh("function"),zh=Lh("number"),Hh=e=>null!==e&&"object"==typeof e,Vh=e=>{if("object"!==Rh(e))return!1;const t=Ah(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Th in e||Mh in e)},qh=Ph("Date"),Uh=Ph("File"),$h=Ph("Blob"),Kh=Ph("FileList"),Yh=Ph("URLSearchParams"),[Gh,Xh,Jh,Qh]=["ReadableStream","Request","Response","Headers"].map(Ph);function Zh(e,t,{allOwnKeys:n=!1}={}){if(null==e)return;let r,i;if("object"!=typeof e&&(e=[e]),Ih(e))for(r=0,i=e.length;r<i;r++)t.call(null,e[r],r,e);else{if(Bh(e))return;const i=n?Object.getOwnPropertyNames(e):Object.keys(e),o=i.length;let s;for(r=0;r<o;r++)s=i[r],t.call(null,e[s],s,e)}}function ed(e,t){if(Bh(e))return null;t=t.toLowerCase();const n=Object.keys(e);let r,i=n.length;for(;i-- >0;)if(r=n[i],t===r.toLowerCase())return r;return null}const td="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,nd=e=>!_h(e)&&e!==td;const rd=(id="undefined"!=typeof Uint8Array&&Ah(Uint8Array),e=>id&&e instanceof id);var id;const od=Ph("HTMLFormElement"),sd=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),ad=Ph("RegExp"),ld=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Zh(n,(n,i)=>{let o;!1!==(o=t(n,i,e))&&(r[i]=o||n)}),Object.defineProperties(e,r)};const cd=Ph("AsyncFunction"),ud=(hd="function"==typeof setImmediate,dd=Wh(td.postMessage),hd?setImmediate:dd?(fd=`axios@${Math.random()}`,pd=[],td.addEventListener("message",({source:e,data:t})=>{e===td&&t===fd&&pd.length&&pd.shift()()},!1),e=>{pd.push(e),td.postMessage(fd,"*")}):e=>setTimeout(e));var hd,dd,fd,pd;const md="undefined"!=typeof queueMicrotask?queueMicrotask.bind(td):"undefined"!=typeof process&&process.nextTick||ud;var gd={isArray:Ih,isArrayBuffer:Fh,isBuffer:Bh,isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||Wh(e.append)&&("formdata"===(t=Rh(e))||"object"===t&&Wh(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&Fh(e.buffer),t},isString:jh,isNumber:zh,isBoolean:e=>!0===e||!1===e,isObject:Hh,isPlainObject:Vh,isEmptyObject:e=>{if(!Hh(e)||Bh(e))return!1;try{return 0===Object.keys(e).length&&Object.getPrototypeOf(e)===Object.prototype}catch(e){return!1}},isReadableStream:Gh,isRequest:Xh,isResponse:Jh,isHeaders:Qh,isUndefined:_h,isDate:qh,isFile:Uh,isBlob:$h,isRegExp:ad,isFunction:Wh,isStream:e=>Hh(e)&&Wh(e.pipe),isURLSearchParams:Yh,isTypedArray:rd,isFileList:Kh,forEach:Zh,merge:function e(){const{caseless:t,skipUndefined:n}=nd(this)&&this||{},r={},i=(i,o)=>{const s=t&&ed(r,o)||o;Vh(r[s])&&Vh(i)?r[s]=e(r[s],i):Vh(i)?r[s]=e({},i):Ih(i)?r[s]=i.slice():n&&_h(i)||(r[s]=i)};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&Zh(arguments[e],i);return r},extend:(e,t,n,{allOwnKeys:r}={})=>(Zh(t,(t,r)=>{n&&Wh(t)?e[r]=Nh(t,n):e[r]=t},{allOwnKeys:r}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},toFlatObject:(e,t,n,r)=>{let i,o,s;const a={};if(t=t||{},null==e)return t;do{for(i=Object.getOwnPropertyNames(e),o=i.length;o-- >0;)s=i[o],r&&!r(s,e,t)||a[s]||(t[s]=e[s],a[s]=!0);e=!1!==n&&Ah(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kindOf:Rh,kindOfTest:Ph,endsWith:(e,t,n)=>{e=String(e),(void 0===n||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return-1!==r&&r===n},toArray:e=>{if(!e)return null;if(Ih(e))return e;let t=e.length;if(!zh(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},forEachEntry:(e,t)=>{const n=(e&&e[Mh]).call(e);let r;for(;(r=n.next())&&!r.done;){const n=r.value;t.call(e,n[0],n[1])}},matchAll:(e,t)=>{let n;const r=[];for(;null!==(n=e.exec(t));)r.push(n);return r},isHTMLForm:od,hasOwnProperty:sd,hasOwnProp:sd,reduceDescriptors:ld,freezeMethods:e=>{ld(e,(t,n)=>{if(Wh(e)&&-1!==["arguments","caller","callee"].indexOf(n))return!1;const r=e[n];Wh(r)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")}))})},toObjectSet:(e,t)=>{const n={},r=e=>{e.forEach(e=>{n[e]=!0})};return Ih(e)?r(e):r(String(e).split(t)),n},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,t,n){return t.toUpperCase()+n}),noop:()=>{},toFiniteNumber:(e,t)=>null!=e&&Number.isFinite(e=+e)?e:t,findKey:ed,global:td,isContextDefined:nd,isSpecCompliantForm:function(e){return!!(e&&Wh(e.append)&&"FormData"===e[Th]&&e[Mh])},toJSONObject:e=>{const t=new Array(10),n=(e,r)=>{if(Hh(e)){if(t.indexOf(e)>=0)return;if(Bh(e))return e;if(!("toJSON"in e)){t[r]=e;const i=Ih(e)?[]:{};return Zh(e,(e,t)=>{const o=n(e,r+1);!_h(o)&&(i[t]=o)}),t[r]=void 0,i}}return e};return n(e,0)},isAsyncFn:cd,isThenable:e=>e&&(Hh(e)||Wh(e))&&Wh(e.then)&&Wh(e.catch),setImmediate:ud,asap:md,isIterable:e=>null!=e&&Wh(e[Mh])};function vd(e,t,n,r,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),i&&(this.response=i,this.status=i.status?i.status:null)}gd.inherits(vd,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:gd.toJSONObject(this.config),code:this.code,status:this.status}}});const bd=vd.prototype,yd={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{yd[e]={value:e}}),Object.defineProperties(vd,yd),Object.defineProperty(bd,"isAxiosError",{value:!0}),vd.from=(e,t,n,r,i,o)=>{const s=Object.create(bd);gd.toFlatObject(e,s,function(e){return e!==Error.prototype},e=>"isAxiosError"!==e);const a=e&&e.message?e.message:"Error",l=null==t&&e?e.code:t;return vd.call(s,a,l,n,r,i),e&&null==s.cause&&Object.defineProperty(s,"cause",{value:e,configurable:!0}),s.name=e&&e.name||"Error",o&&Object.assign(s,o),s};function wd(e){return gd.isPlainObject(e)||gd.isArray(e)}function xd(e){return gd.endsWith(e,"[]")?e.slice(0,-2):e}function kd(e,t,n){return e?e.concat(t).map(function(e,t){return e=xd(e),!n&&t?"["+e+"]":e}).join(n?".":""):t}const Sd=gd.toFlatObject(gd,{},null,function(e){return/^is[A-Z]/.test(e)});function Ed(e,t,n){if(!gd.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const r=(n=gd.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(e,t){return!gd.isUndefined(t[e])})).metaTokens,i=n.visitor||c,o=n.dots,s=n.indexes,a=(n.Blob||"undefined"!=typeof Blob&&Blob)&&gd.isSpecCompliantForm(t);if(!gd.isFunction(i))throw new TypeError("visitor must be a function");function l(e){if(null===e)return"";if(gd.isDate(e))return e.toISOString();if(gd.isBoolean(e))return e.toString();if(!a&&gd.isBlob(e))throw new vd("Blob is not supported. Use a Buffer instead.");return gd.isArrayBuffer(e)||gd.isTypedArray(e)?a&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function c(e,n,i){let a=e;if(e&&!i&&"object"==typeof e)if(gd.endsWith(n,"{}"))n=r?n:n.slice(0,-2),e=JSON.stringify(e);else if(gd.isArray(e)&&function(e){return gd.isArray(e)&&!e.some(wd)}(e)||(gd.isFileList(e)||gd.endsWith(n,"[]"))&&(a=gd.toArray(e)))return n=xd(n),a.forEach(function(e,r){!gd.isUndefined(e)&&null!==e&&t.append(!0===s?kd([n],r,o):null===s?n:n+"[]",l(e))}),!1;return!!wd(e)||(t.append(kd(i,n,o),l(e)),!1)}const u=[],h=Object.assign(Sd,{defaultVisitor:c,convertValue:l,isVisitable:wd});if(!gd.isObject(e))throw new TypeError("data must be an object");return function e(n,r){if(!gd.isUndefined(n)){if(-1!==u.indexOf(n))throw Error("Circular reference detected in "+r.join("."));u.push(n),gd.forEach(n,function(n,o){!0===(!(gd.isUndefined(n)||null===n)&&i.call(t,n,gd.isString(o)?o.trim():o,r,h))&&e(n,r?r.concat(o):[o])}),u.pop()}}(e),t}function Cd(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(e){return t[e]})}function Nd(e,t){this._pairs=[],e&&Ed(e,this,t)}const Od=Nd.prototype;function Ad(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Md(e,t,n){if(!t)return e;const r=n&&n.encode||Ad;gd.isFunction(n)&&(n={serialize:n});const i=n&&n.serialize;let o;if(o=i?i(t,n):gd.isURLSearchParams(t)?t.toString():new Nd(t,n).toString(r),o){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+o}return e}Od.append=function(e,t){this._pairs.push([e,t])},Od.toString=function(e){const t=e?function(t){return e.call(this,t,Cd)}:Cd;return this._pairs.map(function(e){return t(e[0])+"="+t(e[1])},"").join("&")};var Td=class{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){gd.forEach(this.handlers,function(t){null!==t&&e(t)})}},Rd={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Dd={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:Nd,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]};const Pd="undefined"!=typeof window&&"undefined"!=typeof document,Ld="object"==typeof navigator&&navigator||void 0,Id=Pd&&(!Ld||["ReactNative","NativeScript","NS"].indexOf(Ld.product)<0),_d="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,Bd=Pd&&window.location.href||"http://localhost";var Fd={...Object.freeze({__proto__:null,hasBrowserEnv:Pd,hasStandardBrowserEnv:Id,hasStandardBrowserWebWorkerEnv:_d,navigator:Ld,origin:Bd}),...Dd};function jd(e){function t(e,n,r,i){let o=e[i++];if("__proto__"===o)return!0;const s=Number.isFinite(+o),a=i>=e.length;if(o=!o&&gd.isArray(r)?r.length:o,a)return gd.hasOwnProp(r,o)?r[o]=[r[o],n]:r[o]=n,!s;r[o]&&gd.isObject(r[o])||(r[o]=[]);return t(e,n,r[o],i)&&gd.isArray(r[o])&&(r[o]=function(e){const t={},n=Object.keys(e);let r;const i=n.length;let o;for(r=0;r<i;r++)o=n[r],t[o]=e[o];return t}(r[o])),!s}if(gd.isFormData(e)&&gd.isFunction(e.entries)){const n={};return gd.forEachEntry(e,(e,r)=>{t(function(e){return gd.matchAll(/\w+|\[(\w*)]/g,e).map(e=>"[]"===e[0]?"":e[1]||e[0])}(e),r,n,0)}),n}return null}const Wd={transitional:Rd,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const n=t.getContentType()||"",r=n.indexOf("application/json")>-1,i=gd.isObject(e);i&&gd.isHTMLForm(e)&&(e=new FormData(e));if(gd.isFormData(e))return r?JSON.stringify(jd(e)):e;if(gd.isArrayBuffer(e)||gd.isBuffer(e)||gd.isStream(e)||gd.isFile(e)||gd.isBlob(e)||gd.isReadableStream(e))return e;if(gd.isArrayBufferView(e))return e.buffer;if(gd.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let o;if(i){if(n.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return Ed(e,new Fd.classes.URLSearchParams,{visitor:function(e,t,n,r){return Fd.isNode&&gd.isBuffer(e)?(this.append(t,e.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)},...t})}(e,this.formSerializer).toString();if((o=gd.isFileList(e))||n.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return Ed(o?{"files[]":e}:e,t&&new t,this.formSerializer)}}return i||r?(t.setContentType("application/json",!1),function(e,t,n){if(gd.isString(e))try{return(t||JSON.parse)(e),gd.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(n||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||Wd.transitional,n=t&&t.forcedJSONParsing,r="json"===this.responseType;if(gd.isResponse(e)||gd.isReadableStream(e))return e;if(e&&gd.isString(e)&&(n&&!this.responseType||r)){const n=!(t&&t.silentJSONParsing)&&r;try{return JSON.parse(e,this.parseReviver)}catch(e){if(n){if("SyntaxError"===e.name)throw vd.from(e,vd.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Fd.classes.FormData,Blob:Fd.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};gd.forEach(["delete","get","head","post","put","patch"],e=>{Wd.headers[e]={}});var zd=Wd;const Hd=gd.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]);const Vd=Symbol("internals");function qd(e){return e&&String(e).trim().toLowerCase()}function Ud(e){return!1===e||null==e?e:gd.isArray(e)?e.map(Ud):String(e)}function $d(e,t,n,r,i){return gd.isFunction(r)?r.call(this,t,n):(i&&(t=n),gd.isString(t)?gd.isString(r)?-1!==t.indexOf(r):gd.isRegExp(r)?r.test(t):void 0:void 0)}class Kd{constructor(e){e&&this.set(e)}set(e,t,n){const r=this;function i(e,t,n){const i=qd(t);if(!i)throw new Error("header name must be a non-empty string");const o=gd.findKey(r,i);(!o||void 0===r[o]||!0===n||void 0===n&&!1!==r[o])&&(r[o||t]=Ud(e))}const o=(e,t)=>gd.forEach(e,(e,n)=>i(e,n,t));if(gd.isPlainObject(e)||e instanceof this.constructor)o(e,t);else if(gd.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim()))o((e=>{const t={};let n,r,i;return e&&e.split("\n").forEach(function(e){i=e.indexOf(":"),n=e.substring(0,i).trim().toLowerCase(),r=e.substring(i+1).trim(),!n||t[n]&&Hd[n]||("set-cookie"===n?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t})(e),t);else if(gd.isObject(e)&&gd.isIterable(e)){let n,r,i={};for(const t of e){if(!gd.isArray(t))throw TypeError("Object iterator must return a key-value pair");i[r=t[0]]=(n=i[r])?gd.isArray(n)?[...n,t[1]]:[n,t[1]]:t[1]}o(i,t)}else null!=e&&i(t,e,n);return this}get(e,t){if(e=qd(e)){const n=gd.findKey(this,e);if(n){const e=this[n];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}(e);if(gd.isFunction(t))return t.call(this,e,n);if(gd.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=qd(e)){const n=gd.findKey(this,e);return!(!n||void 0===this[n]||t&&!$d(0,this[n],n,t))}return!1}delete(e,t){const n=this;let r=!1;function i(e){if(e=qd(e)){const i=gd.findKey(n,e);!i||t&&!$d(0,n[i],i,t)||(delete n[i],r=!0)}}return gd.isArray(e)?e.forEach(i):i(e),r}clear(e){const t=Object.keys(this);let n=t.length,r=!1;for(;n--;){const i=t[n];e&&!$d(0,this[i],i,e,!0)||(delete this[i],r=!0)}return r}normalize(e){const t=this,n={};return gd.forEach(this,(r,i)=>{const o=gd.findKey(n,i);if(o)return t[o]=Ud(r),void delete t[i];const s=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,n)=>t.toUpperCase()+n)}(i):String(i).trim();s!==i&&delete t[i],t[s]=Ud(r),n[s]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return gd.forEach(this,(n,r)=>{null!=n&&!1!==n&&(t[r]=e&&gd.isArray(n)?n.join(", "):n)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join("\n")}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const n=new this(e);return t.forEach(e=>n.set(e)),n}static accessor(e){const t=(this[Vd]=this[Vd]={accessors:{}}).accessors,n=this.prototype;function r(e){const r=qd(e);t[r]||(!function(e,t){const n=gd.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(e,n,i){return this[r].call(this,t,e,n,i)},configurable:!0})})}(n,e),t[r]=!0)}return gd.isArray(e)?e.forEach(r):r(e),this}}Kd.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),gd.reduceDescriptors(Kd.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[n]=e}}}),gd.freezeMethods(Kd);var Yd=Kd;function Gd(e,t){const n=this||zd,r=t||n,i=Yd.from(r.headers);let o=r.data;return gd.forEach(e,function(e){o=e.call(n,o,i.normalize(),t?t.status:void 0)}),i.normalize(),o}function Xd(e){return!(!e||!e.__CANCEL__)}function Jd(e,t,n){vd.call(this,null==e?"canceled":e,vd.ERR_CANCELED,t,n),this.name="CanceledError"}function Qd(e,t,n){const r=n.config.validateStatus;n.status&&r&&!r(n.status)?t(new vd("Request failed with status code "+n.status,[vd.ERR_BAD_REQUEST,vd.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n)):e(n)}gd.inherits(Jd,vd,{__CANCEL__:!0});const Zd=(e,t,n=3)=>{let r=0;const i=function(e,t){e=e||10;const n=new Array(e),r=new Array(e);let i,o=0,s=0;return t=void 0!==t?t:1e3,function(a){const l=Date.now(),c=r[s];i||(i=l),n[o]=a,r[o]=l;let u=s,h=0;for(;u!==o;)h+=n[u++],u%=e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),l-i<t)return;const d=c&&l-c;return d?Math.round(1e3*h/d):void 0}}(50,250);return function(e,t){let n,r,i=0,o=1e3/t;const s=(t,o=Date.now())=>{i=o,n=null,r&&(clearTimeout(r),r=null),e(...t)};return[(...e)=>{const t=Date.now(),a=t-i;a>=o?s(e,t):(n=e,r||(r=setTimeout(()=>{r=null,s(n)},o-a)))},()=>n&&s(n)]}(n=>{const o=n.loaded,s=n.lengthComputable?n.total:void 0,a=o-r,l=i(a);r=o;e({loaded:o,total:s,progress:s?o/s:void 0,bytes:a,rate:l||void 0,estimated:l&&s&&o<=s?(s-o)/l:void 0,event:n,lengthComputable:null!=s,[t?"download":"upload"]:!0})},n)},ef=(e,t)=>{const n=null!=e;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},tf=e=>(...t)=>gd.asap(()=>e(...t));var nf=Fd.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,Fd.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(Fd.origin),Fd.navigator&&/(msie|trident)/i.test(Fd.navigator.userAgent)):()=>!0,rf=Fd.hasStandardBrowserEnv?{write(e,t,n,r,i,o,s){if("undefined"==typeof document)return;const a=[`${e}=${encodeURIComponent(t)}`];gd.isNumber(n)&&a.push(`expires=${new Date(n).toUTCString()}`),gd.isString(r)&&a.push(`path=${r}`),gd.isString(i)&&a.push(`domain=${i}`),!0===o&&a.push("secure"),gd.isString(s)&&a.push(`SameSite=${s}`),document.cookie=a.join("; ")},read(e){if("undefined"==typeof document)return null;const t=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return t?decodeURIComponent(t[1]):null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read:()=>null,remove(){}};function of(e,t,n){let r=!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t);return e&&(r||0==n)?function(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}const sf=e=>e instanceof Yd?{...e}:e;function af(e,t){t=t||{};const n={};function r(e,t,n,r){return gd.isPlainObject(e)&&gd.isPlainObject(t)?gd.merge.call({caseless:r},e,t):gd.isPlainObject(t)?gd.merge({},t):gd.isArray(t)?t.slice():t}function i(e,t,n,i){return gd.isUndefined(t)?gd.isUndefined(e)?void 0:r(void 0,e,0,i):r(e,t,0,i)}function o(e,t){if(!gd.isUndefined(t))return r(void 0,t)}function s(e,t){return gd.isUndefined(t)?gd.isUndefined(e)?void 0:r(void 0,e):r(void 0,t)}function a(n,i,o){return o in t?r(n,i):o in e?r(void 0,n):void 0}const l={url:o,method:o,data:o,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:a,headers:(e,t,n)=>i(sf(e),sf(t),0,!0)};return gd.forEach(Object.keys({...e,...t}),function(r){const o=l[r]||i,s=o(e[r],t[r],r);gd.isUndefined(s)&&o!==a||(n[r]=s)}),n}var lf=e=>{const t=af({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:i,xsrfCookieName:o,headers:s,auth:a}=t;if(t.headers=s=Yd.from(s),t.url=Md(of(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&s.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),gd.isFormData(n))if(Fd.hasStandardBrowserEnv||Fd.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if(gd.isFunction(n.getHeaders)){const e=n.getHeaders(),t=["content-type","content-length"];Object.entries(e).forEach(([e,n])=>{t.includes(e.toLowerCase())&&s.set(e,n)})}if(Fd.hasStandardBrowserEnv&&(r&&gd.isFunction(r)&&(r=r(t)),r||!1!==r&&nf(t.url))){const e=i&&o&&rf.read(o);e&&s.set(i,e)}return t};var cf="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise(function(t,n){const r=lf(e);let i=r.data;const o=Yd.from(r.headers).normalize();let s,a,l,c,u,{responseType:h,onUploadProgress:d,onDownloadProgress:f}=r;function p(){c&&c(),u&&u(),r.cancelToken&&r.cancelToken.unsubscribe(s),r.signal&&r.signal.removeEventListener("abort",s)}let m=new XMLHttpRequest;function g(){if(!m)return;const r=Yd.from("getAllResponseHeaders"in m&&m.getAllResponseHeaders());Qd(function(e){t(e),p()},function(e){n(e),p()},{data:h&&"text"!==h&&"json"!==h?m.response:m.responseText,status:m.status,statusText:m.statusText,headers:r,config:e,request:m}),m=null}m.open(r.method.toUpperCase(),r.url,!0),m.timeout=r.timeout,"onloadend"in m?m.onloadend=g:m.onreadystatechange=function(){m&&4===m.readyState&&(0!==m.status||m.responseURL&&0===m.responseURL.indexOf("file:"))&&setTimeout(g)},m.onabort=function(){m&&(n(new vd("Request aborted",vd.ECONNABORTED,e,m)),m=null)},m.onerror=function(t){const r=new vd(t&&t.message?t.message:"Network Error",vd.ERR_NETWORK,e,m);r.event=t||null,n(r),m=null},m.ontimeout=function(){let t=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const i=r.transitional||Rd;r.timeoutErrorMessage&&(t=r.timeoutErrorMessage),n(new vd(t,i.clarifyTimeoutError?vd.ETIMEDOUT:vd.ECONNABORTED,e,m)),m=null},void 0===i&&o.setContentType(null),"setRequestHeader"in m&&gd.forEach(o.toJSON(),function(e,t){m.setRequestHeader(t,e)}),gd.isUndefined(r.withCredentials)||(m.withCredentials=!!r.withCredentials),h&&"json"!==h&&(m.responseType=r.responseType),f&&([l,u]=Zd(f,!0),m.addEventListener("progress",l)),d&&m.upload&&([a,c]=Zd(d),m.upload.addEventListener("progress",a),m.upload.addEventListener("loadend",c)),(r.cancelToken||r.signal)&&(s=t=>{m&&(n(!t||t.type?new Jd(null,e,m):t),m.abort(),m=null)},r.cancelToken&&r.cancelToken.subscribe(s),r.signal&&(r.signal.aborted?s():r.signal.addEventListener("abort",s)));const v=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(r.url);v&&-1===Fd.protocols.indexOf(v)?n(new vd("Unsupported protocol "+v+":",vd.ERR_BAD_REQUEST,e)):m.send(i||null)})};var uf=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let n,r=new AbortController;const i=function(e){if(!n){n=!0,s();const t=e instanceof Error?e:this.reason;r.abort(t instanceof vd?t:new Jd(t instanceof Error?t.message:t))}};let o=t&&setTimeout(()=>{o=null,i(new vd(`timeout ${t} of ms exceeded`,vd.ETIMEDOUT))},t);const s=()=>{e&&(o&&clearTimeout(o),o=null,e.forEach(e=>{e.unsubscribe?e.unsubscribe(i):e.removeEventListener("abort",i)}),e=null)};e.forEach(e=>e.addEventListener("abort",i));const{signal:a}=r;return a.unsubscribe=()=>gd.asap(s),a}};const hf=function*(e,t){let n=e.byteLength;if(!t||n<t)return void(yield e);let r,i=0;for(;i<n;)r=i+t,yield e.slice(i,r),i=r},df=async function*(e){if(e[Symbol.asyncIterator])return void(yield*e);const t=e.getReader();try{for(;;){const{done:e,value:n}=await t.read();if(e)break;yield n}}finally{await t.cancel()}},ff=(e,t,n,r)=>{const i=async function*(e,t){for await(const n of df(e))yield*hf(n,t)}(e,t);let o,s=0,a=e=>{o||(o=!0,r&&r(e))};return new ReadableStream({async pull(e){try{const{done:t,value:r}=await i.next();if(t)return a(),void e.close();let o=r.byteLength;if(n){let e=s+=o;n(e)}e.enqueue(new Uint8Array(r))}catch(e){throw a(e),e}},cancel:e=>(a(e),i.return())},{highWaterMark:2})},{isFunction:pf}=gd,mf=(({Request:e,Response:t})=>({Request:e,Response:t}))(gd.global),{ReadableStream:gf,TextEncoder:vf}=gd.global,bf=(e,...t)=>{try{return!!e(...t)}catch(e){return!1}},yf=e=>{e=gd.merge.call({skipUndefined:!0},mf,e);const{fetch:t,Request:n,Response:r}=e,i=t?pf(t):"function"==typeof fetch,o=pf(n),s=pf(r);if(!i)return!1;const a=i&&pf(gf),l=i&&("function"==typeof vf?(c=new vf,e=>c.encode(e)):async e=>new Uint8Array(await new n(e).arrayBuffer()));var c;const u=o&&a&&bf(()=>{let e=!1;const t=new n(Fd.origin,{body:new gf,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),h=s&&a&&bf(()=>gd.isReadableStream(new r("").body)),d={stream:h&&(e=>e.body)};i&&["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!d[e]&&(d[e]=(t,n)=>{let r=t&&t[e];if(r)return r.call(t);throw new vd(`Response type '${e}' is not supported`,vd.ERR_NOT_SUPPORT,n)})});const f=async(e,t)=>{const r=gd.toFiniteNumber(e.getContentLength());return null==r?(async e=>{if(null==e)return 0;if(gd.isBlob(e))return e.size;if(gd.isSpecCompliantForm(e)){const t=new n(Fd.origin,{method:"POST",body:e});return(await t.arrayBuffer()).byteLength}return gd.isArrayBufferView(e)||gd.isArrayBuffer(e)?e.byteLength:(gd.isURLSearchParams(e)&&(e+=""),gd.isString(e)?(await l(e)).byteLength:void 0)})(t):r};return async e=>{let{url:i,method:s,data:a,signal:l,cancelToken:c,timeout:p,onDownloadProgress:m,onUploadProgress:g,responseType:v,headers:b,withCredentials:y="same-origin",fetchOptions:w}=lf(e),x=t||fetch;v=v?(v+"").toLowerCase():"text";let k=uf([l,c&&c.toAbortSignal()],p),S=null;const E=k&&k.unsubscribe&&(()=>{k.unsubscribe()});let C;try{if(g&&u&&"get"!==s&&"head"!==s&&0!==(C=await f(b,a))){let e,t=new n(i,{method:"POST",body:a,duplex:"half"});if(gd.isFormData(a)&&(e=t.headers.get("content-type"))&&b.setContentType(e),t.body){const[e,n]=ef(C,Zd(tf(g)));a=ff(t.body,65536,e,n)}}gd.isString(y)||(y=y?"include":"omit");const t=o&&"credentials"in n.prototype,l={...w,signal:k,method:s.toUpperCase(),headers:b.normalize().toJSON(),body:a,duplex:"half",credentials:t?y:void 0};S=o&&new n(i,l);let c=await(o?x(S,w):x(i,l));const p=h&&("stream"===v||"response"===v);if(h&&(m||p&&E)){const e={};["status","statusText","headers"].forEach(t=>{e[t]=c[t]});const t=gd.toFiniteNumber(c.headers.get("content-length")),[n,i]=m&&ef(t,Zd(tf(m),!0))||[];c=new r(ff(c.body,65536,n,()=>{i&&i(),E&&E()}),e)}v=v||"text";let N=await d[gd.findKey(d,v)||"text"](c,e);return!p&&E&&E(),await new Promise((t,n)=>{Qd(t,n,{data:N,headers:Yd.from(c.headers),status:c.status,statusText:c.statusText,config:e,request:S})})}catch(t){if(E&&E(),t&&"TypeError"===t.name&&/Load failed|fetch/i.test(t.message))throw Object.assign(new vd("Network Error",vd.ERR_NETWORK,e,S),{cause:t.cause||t});throw vd.from(t,t&&t.code,e,S)}}},wf=new Map,xf=e=>{let t=e&&e.env||{};const{fetch:n,Request:r,Response:i}=t,o=[r,i,n];let s,a,l=o.length,c=wf;for(;l--;)s=o[l],a=c.get(s),void 0===a&&c.set(s,a=l?new Map:yf(t)),c=a;return a};xf();const kf={http:null,xhr:cf,fetch:{get:xf}};gd.forEach(kf,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}});const Sf=e=>`- ${e}`,Ef=e=>gd.isFunction(e)||null===e||!1===e;var Cf={getAdapter:function(e,t){e=gd.isArray(e)?e:[e];const{length:n}=e;let r,i;const o={};for(let s=0;s<n;s++){let n;if(r=e[s],i=r,!Ef(r)&&(i=kf[(n=String(r)).toLowerCase()],void 0===i))throw new vd(`Unknown adapter '${n}'`);if(i&&(gd.isFunction(i)||(i=i.get(t))))break;o[n||"#"+s]=i}if(!i){const e=Object.entries(o).map(([e,t])=>`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build"));throw new vd("There is no suitable adapter to dispatch the request "+(n?e.length>1?"since :\n"+e.map(Sf).join("\n"):" "+Sf(e[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return i},adapters:kf};function Nf(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Jd(null,e)}function Of(e){Nf(e),e.headers=Yd.from(e.headers),e.data=Gd.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1);return Cf.getAdapter(e.adapter||zd.adapter,e)(e).then(function(t){return Nf(e),t.data=Gd.call(e,e.transformResponse,t),t.headers=Yd.from(t.headers),t},function(t){return Xd(t)||(Nf(e),t&&t.response&&(t.response.data=Gd.call(e,e.transformResponse,t.response),t.response.headers=Yd.from(t.response.headers))),Promise.reject(t)})}const Af="1.13.2",Mf={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Mf[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});const Tf={};Mf.transitional=function(e,t,n){return(r,i,o)=>{if(!1===e)throw new vd(function(e,t){return"[Axios v"+Af+"] Transitional option '"+e+"'"+t+(n?". "+n:"")}(i," has been removed"+(t?" in "+t:"")),vd.ERR_DEPRECATED);return t&&!Tf[i]&&(Tf[i]=!0),!e||e(r,i,o)}},Mf.spelling=function(e){return(e,t)=>!0};var Rf={assertOptions:function(e,t,n){if("object"!=typeof e)throw new vd("options must be an object",vd.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let i=r.length;for(;i-- >0;){const o=r[i],s=t[o];if(s){const t=e[o],n=void 0===t||s(t,o,e);if(!0!==n)throw new vd("option "+o+" must be "+n,vd.ERR_BAD_OPTION_VALUE);continue}if(!0!==n)throw new vd("Unknown option "+o,vd.ERR_BAD_OPTION)}},validators:Mf};const Df=Rf.validators;class Pf{constructor(e){this.defaults=e||{},this.interceptors={request:new Td,response:new Td}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t={};Error.captureStackTrace?Error.captureStackTrace(t):t=new Error;const n=t.stack?t.stack.replace(/^.+\n/,""):"";try{e.stack?n&&!String(e.stack).endsWith(n.replace(/^.+\n.+\n/,""))&&(e.stack+="\n"+n):e.stack=n}catch(e){}}throw e}}_request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=af(this.defaults,t);const{transitional:n,paramsSerializer:r,headers:i}=t;void 0!==n&&Rf.assertOptions(n,{silentJSONParsing:Df.transitional(Df.boolean),forcedJSONParsing:Df.transitional(Df.boolean),clarifyTimeoutError:Df.transitional(Df.boolean)},!1),null!=r&&(gd.isFunction(r)?t.paramsSerializer={serialize:r}:Rf.assertOptions(r,{encode:Df.function,serialize:Df.function},!0)),void 0!==t.allowAbsoluteUrls||(void 0!==this.defaults.allowAbsoluteUrls?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),Rf.assertOptions(t,{baseUrl:Df.spelling("baseURL"),withXsrfToken:Df.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let o=i&&gd.merge(i.common,i[t.method]);i&&gd.forEach(["delete","get","head","post","put","patch","common"],e=>{delete i[e]}),t.headers=Yd.concat(o,i);const s=[];let a=!0;this.interceptors.request.forEach(function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(a=a&&e.synchronous,s.unshift(e.fulfilled,e.rejected))});const l=[];let c;this.interceptors.response.forEach(function(e){l.push(e.fulfilled,e.rejected)});let u,h=0;if(!a){const e=[Of.bind(this),void 0];for(e.unshift(...s),e.push(...l),u=e.length,c=Promise.resolve(t);h<u;)c=c.then(e[h++],e[h++]);return c}u=s.length;let d=t;for(;h<u;){const e=s[h++],t=s[h++];try{d=e(d)}catch(e){t.call(this,e);break}}try{c=Of.call(this,d)}catch(e){return Promise.reject(e)}for(h=0,u=l.length;h<u;)c=c.then(l[h++],l[h++]);return c}getUri(e){return Md(of((e=af(this.defaults,e)).baseURL,e.url,e.allowAbsoluteUrls),e.params,e.paramsSerializer)}}gd.forEach(["delete","get","head","options"],function(e){Pf.prototype[e]=function(t,n){return this.request(af(n||{},{method:e,url:t,data:(n||{}).data}))}}),gd.forEach(["post","put","patch"],function(e){function t(t){return function(n,r,i){return this.request(af(i||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:n,data:r}))}}Pf.prototype[e]=t(),Pf.prototype[e+"Form"]=t(!0)});var Lf=Pf;class If{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(e){t=e});const n=this;this.promise.then(e=>{if(!n._listeners)return;let t=n._listeners.length;for(;t-- >0;)n._listeners[t](e);n._listeners=null}),this.promise.then=e=>{let t;const r=new Promise(e=>{n.subscribe(e),t=e}).then(e);return r.cancel=function(){n.unsubscribe(t)},r},e(function(e,r,i){n.reason||(n.reason=new Jd(e,r,i),t(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new If(function(t){e=t}),cancel:e}}}var _f=If;const Bf={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Bf).forEach(([e,t])=>{Bf[t]=e});var Ff=Bf;const jf=function e(t){const n=new Lf(t),r=Nh(Lf.prototype.request,n);return gd.extend(r,Lf.prototype,n,{allOwnKeys:!0}),gd.extend(r,n,null,{allOwnKeys:!0}),r.create=function(n){return e(af(t,n))},r}(zd);jf.Axios=Lf,jf.CanceledError=Jd,jf.CancelToken=_f,jf.isCancel=Xd,jf.VERSION=Af,jf.toFormData=Ed,jf.AxiosError=vd,jf.Cancel=jf.CanceledError,jf.all=function(e){return Promise.all(e)},jf.spread=function(e){return function(t){return e.apply(null,t)}},jf.isAxiosError=function(e){return gd.isObject(e)&&!0===e.isAxiosError},jf.mergeConfig=af,jf.AxiosHeaders=Yd,jf.formToJSON=e=>jd(gd.isHTMLForm(e)?new FormData(e):e),jf.getAdapter=Cf.getAdapter,jf.HttpStatusCode=Ff,jf.default=jf;var Wf=jf.create({baseURL:"/api/cms",timeout:1e4,headers:{"Content-Type":"application/json"}}),zf=new Map;Wf.interceptors.request.use(function(e){e.url&&e.url.startsWith("http")&&(e.baseURL="");var t=localStorage.getItem("cms_token");t&&(e.headers.Authorization="Bearer ".concat(t));var n=localStorage.getItem("cms_session_id");return n&&(e.headers["X-Session-Id"]=n),e},function(e){return Promise.reject(e)}),Wf.interceptors.response.use(function(e){return e},function(e){var t="请求错误",n=!1;if(e.response){var r=e.response.status,i=e.response.data;401===r?"登录已过期,请重新登录"===(null==i?void 0:i.message)?(t="登录已过期,请重新登录",n=!0):"认证信息无效"===(null==i?void 0:i.message)?(t="认证信息无效,请重新登录",n=!0):(t="认证失败,请登录",n=!0):t=(null==i?void 0:i.message)||"HTTP ".concat(r,": ").concat(e.response.statusText)}else t=e.request?"网络连接失败,请检查网络状态":e.message||"请求错误";return n?(localStorage.removeItem("cms_token"),localStorage.removeItem("cms_user"),"/login"!==window.location.pathname&&"/"!==window.location.pathname&&(Ch.error(t),setTimeout(function(){window.location.reload()},1e3))):Ch.error(t),Promise.reject(e)});var Hf,Vf=function(e,t,n){var r=e;if(t){var i=new URLSearchParams(t).toString();r=r+(r.includes("?")?"&":"?")+i}var o="GET ".concat(r),s=zf.get(o);if(s)return s;var a=Wf.get(r,n).then(function(e){return e.data}).finally(function(){zf.delete(o)});return zf.set(o,a),a},qf=function(e,t,n){return Wf.post(e,t,n).then(function(e){return e.data})},Uf=function(e,t,n){return Wf.put(e,t,n).then(function(e){return e.data})},$f=function(e,t){return Wf.delete(e,t).then(function(e){return e.data})};try{var Kf=localStorage.getItem("cms_session_id")||void 0;Hf=Kf}catch(FN){}function Yf(e){Hf=e;try{localStorage.setItem("cms_session_id",e)}catch(e){}}var Gf=function(){return Vf("/models")},Xf=function(){return Vf("/auth/signup/status/".concat(Hf?Hf+"_":"","cms_users"))},Jf=function(e){return qf("/auth/signup/".concat(Hf?Hf+"_":"","cms_users"),e)},Qf=function(e){return qf("/auth/login/".concat(Hf?Hf+"_":"","cms_users"),e)},Zf=function(){return qf("/auth/verify/".concat(Hf?Hf+"_":"","cms_users"))},ep=function(){return Vf("/auth/user/".concat(Hf?Hf+"_":"","cms_users"))},tp=function(){localStorage.removeItem("cms_token"),localStorage.removeItem("cms_user")},np=function(){return localStorage.getItem("cms_token")},rp=function(){var e=localStorage.getItem("cms_user");return e?JSON.parse(e):null},ip=function(e,t){var n=t?Object.assign({},t):void 0;return(null==n?void 0:n.filters)&&Array.isArray(n.filters)&&(n.filters=JSON.stringify(n.filters)),Vf("/data/".concat(Hf?Hf+"_":"").concat(e),n)},op=function(e,t){return Vf("/relation/".concat(Hf?Hf+"_":"").concat(e,"/options"),t)},sp=function(e,t){return qf("/data/".concat(Hf?Hf+"_":"").concat(e),t)},ap=function(e,t){return Uf("/data/".concat(Hf?Hf+"_":"").concat(e),t)},lp=function(e,t){return $f("/data/".concat(Hf?Hf+"_":"").concat(e,"?id=").concat(t))},cp={"zh-CN":{common:{confirm:"确认",cancel:"取消",save:"保存",delete:"删除",edit:"编辑",add:"添加",search:"搜索",filter:"筛选",reset:"重置",submit:"提交",back:"返回",next:"下一页",previous:"上一页",loading:"加载中...",success:"成功",error:"错误",warning:"警告",info:"信息",close:"关闭",refresh:"刷新",export:"导出",import:"导入",view:"查看",create:"创建",update:"更新",actions:"操作",operation:"操作",total:"共",page:"页",pageSize:"每页",goto:"跳转"},auth:{login:"登录",logout:"登出",username:"用户名",password:"密码",email:"邮箱",signup:"注册",welcome:"欢迎",loginSuccess:"登录成功",loginFailed:"登录失败",logoutSuccess:"已成功登出",logoutConfirm:"确定要登出系统吗?",pleaseLogin:"请登录",invalidCredentials:"用户名或密码错误",createAdminAccount:"创建管理员账号",adminCreatedSuccess:"管理员账号创建成功",noAdmin:"系统中还没有管理员账号",firstTimeSetup:"首次使用,请创建管理员账号"},data:{dataManagement:"数据管理",dataList:"数据列表",addData:"新增数据",editData:"编辑数据",deleteData:"删除数据",deleteConfirm:"确定要删除这条数据吗?",deleteSuccess:"删除成功",deleteFailed:"删除失败",createSuccess:"创建成功",createFailed:"创建失败",updateSuccess:"更新成功",updateFailed:"更新失败",loadFailed:"加载失败",noData:"暂无数据",selectModel:"选择模型",selectModelFirst:"请先选择一个模型",searchPlaceholder:"搜索...",filterTitle:"筛选条件",addFilter:"添加筛选",clearFilters:"清除筛选",totalRecords:"条记录",perPage:"条/页"},model:{modelManagement:"模型管理",modelList:"模型列表",addModel:"新增模型",editModel:"编辑模型",deleteModel:"删除模型",deleteConfirm:"确定要删除这个模型吗?",modelName:"模型名称",tableName:"表名",fields:"字段",fieldName:"字段名",fieldType:"字段类型",fieldComment:"字段说明",required:"必填",unique:"唯一",maxLength:"最大长度",defaultValue:"默认值",addField:"添加字段",removeField:"移除字段",createSuccess:"模型创建成功",createFailed:"模型创建失败",updateSuccess:"模型更新成功",updateFailed:"模型更新失败",deleteSuccess:"模型删除成功",deleteFailed:"模型删除失败",loadFailed:"模型加载失败",noModels:"暂无模型"},field:{string:"字符串",number:"数字",boolean:"布尔值",date:"日期",datetime:"日期时间",text:"文本",email:"邮箱",url:"链接",json:"JSON",relation:"关联"},validation:{required:"此字段为必填项",invalidEmail:"请输入有效的邮箱地址",invalidUrl:"请输入有效的URL",maxLength:"超过最大长度限制",minLength:"未达到最小长度要求",invalidFormat:"格式不正确"},settings:{settings:"设置",language:"语言",theme:"主题",general:"通用",advanced:"高级"}},"en-US":{common:{confirm:"Confirm",cancel:"Cancel",save:"Save",delete:"Delete",edit:"Edit",add:"Add",search:"Search",filter:"Filter",reset:"Reset",submit:"Submit",back:"Back",next:"Next",previous:"Previous",loading:"Loading...",success:"Success",error:"Error",warning:"Warning",info:"Info",close:"Close",refresh:"Refresh",export:"Export",import:"Import",view:"View",create:"Create",update:"Update",actions:"Actions",operation:"Operation",total:"Total",page:"Page",pageSize:"Page Size",goto:"Go to"},auth:{login:"Login",logout:"Logout",username:"Username",password:"Password",email:"Email",signup:"Sign Up",welcome:"Welcome",loginSuccess:"Login successful",loginFailed:"Login failed",logoutSuccess:"Logout successful",logoutConfirm:"Are you sure you want to logout?",pleaseLogin:"Please login",invalidCredentials:"Invalid username or password",createAdminAccount:"Create Admin Account",adminCreatedSuccess:"Admin account created successfully",noAdmin:"No admin account exists",firstTimeSetup:"First time setup, please create admin account"},data:{dataManagement:"Data Management",dataList:"Data List",addData:"Add Data",editData:"Edit Data",deleteData:"Delete Data",deleteConfirm:"Are you sure you want to delete this record?",deleteSuccess:"Delete successful",deleteFailed:"Delete failed",createSuccess:"Create successful",createFailed:"Create failed",updateSuccess:"Update successful",updateFailed:"Update failed",loadFailed:"Load failed",noData:"No data",selectModel:"Select Model",selectModelFirst:"Please select a model first",searchPlaceholder:"Search...",filterTitle:"Filters",addFilter:"Add Filter",clearFilters:"Clear Filters",totalRecords:"records",perPage:"per page"},model:{modelManagement:"Model Management",modelList:"Model List",addModel:"Add Model",editModel:"Edit Model",deleteModel:"Delete Model",deleteConfirm:"Are you sure you want to delete this model?",modelName:"Model Name",tableName:"Table Name",fields:"Fields",fieldName:"Field Name",fieldType:"Field Type",fieldComment:"Field Comment",required:"Required",unique:"Unique",maxLength:"Max Length",defaultValue:"Default Value",addField:"Add Field",removeField:"Remove Field",createSuccess:"Model created successfully",createFailed:"Model creation failed",updateSuccess:"Model updated successfully",updateFailed:"Model update failed",deleteSuccess:"Model deleted successfully",deleteFailed:"Model deletion failed",loadFailed:"Model loading failed",noModels:"No models"},field:{string:"String",number:"Number",boolean:"Boolean",date:"Date",datetime:"Datetime",text:"Text",email:"Email",url:"URL",json:"JSON",relation:"Relation"},validation:{required:"This field is required",invalidEmail:"Please enter a valid email address",invalidUrl:"Please enter a valid URL",maxLength:"Exceeded maximum length",minLength:"Below minimum length",invalidFormat:"Invalid format"},settings:{settings:"Settings",language:"Language",theme:"Theme",general:"General",advanced:"Advanced"}}},up=c(void 0);function hp(e){var n=e.children,r=e.defaultLocale,o=O(i(r||function(){try{var e=localStorage.getItem("cms_locale");if(e&&("zh-CN"===e||"en-US"===e))return e}catch(e){}return"zh-CN"}()),2),s=o[0],a=o[1],l={locale:s,setLocale:function(e){a(e),function(e){try{localStorage.setItem("cms_locale",e)}catch(e){}}(e)},t:function(e){var t,n=e.split("."),r=cp[s],i=S(n);try{for(i.s();!(t=i.n()).done;){var o=t.value;if(!r||"object"!==M(r)||!(o in r))return e;r=r[o]}}catch(e){i.e(e)}finally{i.f()}return"string"==typeof r?r:e},messages:cp[s]};return t.createElement(up.Provider,{value:l},n)}function dp(){var e=l(up);if(!e)throw new Error("useTranslation must be used within I18nProvider");return e}function fp(){return dp().t}function pp(){var e=dp();return{locale:e.locale,setLocale:e.setLocale}}function mp(e){var n=e.onLoginSuccess,r=fp(),o=O(i(""),2),s=o[0],l=o[1],c=O(i(""),2),u=c[0],h=c[1],d=O(i(!1),2),f=d[0],p=d[1],m=O(i("login"),2),g=m[0],v=m[1];a(function(){var e=np();if(e){var t=function(){var t=k(C().m(function t(){var r;return C().w(function(t){for(;;)switch(t.p=t.n){case 0:return p(!0),t.p=1,t.n=2,Zf();case 2:if(t.v.success){t.n=3;break}throw new Error("token验证失败");case 3:return t.n=4,ep();case 4:if(!(r=t.v).success||!r.data){t.n=5;break}localStorage.setItem("cms_user",JSON.stringify(r.data)),null==n||n(e,r.data),t.n=6;break;case 5:throw new Error("获取用户信息失败");case 6:t.n=8;break;case 7:t.p=7,t.v,tp();case 8:return t.p=8,p(!1),t.f(8);case 9:return t.a(2)}},t,null,[[1,7,8,9]])}));return function(){return t.apply(this,arguments)}}();t()}},[n]),a(function(){if(!np()){var e=function(){var e=k(C().m(function e(){var t,n;return C().w(function(e){for(;;)switch(e.p=e.n){case 0:return p(!0),e.p=1,e.n=2,Xf();case 2:(n=e.v).success&&(null===(t=n.data)||void 0===t?void 0:t.allowSignup)?v("signup"):v("login"),e.n=4;break;case 3:e.p=3,e.v,v("login");case 4:return e.p=4,p(!1),e.f(4);case 5:return e.a(2)}},e,null,[[1,3,4,5]])}));return function(){return e.apply(this,arguments)}}();e()}},[]);var b=function(){var e=k(C().m(function e(t){var i,o,a,l,c;return C().w(function(e){for(;;)switch(e.p=e.n){case 0:if(t.preventDefault(),s&&u){e.n=1;break}return Ch.error(r("validation.required")),e.a(2);case 1:if(p(!0),e.p=2,"signup"!==g){e.n=4;break}return e.n=3,Jf({username:s,password:u});case 3:l=e.v,e.n=6;break;case 4:return e.n=5,Qf({username:s,password:u});case 5:l=e.v;case 6:if((a=l).success&&(null===(i=a.data)||void 0===i?void 0:i.token)){e.n=7;break}return Ch.error(a.message||r("auth.loginFailed")),"signup"===g&&(null===(o=a.message)||void 0===o?void 0:o.includes("已存在管理员"))&&v("login"),e.a(2);case 7:localStorage.setItem("cms_token",a.data.token),localStorage.setItem("cms_user",JSON.stringify(a.data.user)),null==n||n(a.data.token,a.data.user),e.n=9;break;case 8:e.p=8,c=e.v,Ch.error("".concat(r("auth.loginFailed"),", ").concat(c.message||r("common.error")));case 9:return e.p=9,p(!1),e.f(9);case 10:return e.a(2)}},e,null,[[2,8,9,10]])}));return function(t){return e.apply(this,arguments)}}();return t.createElement("div",{className:"we0-cms-root"},t.createElement("div",{className:"min-h-screen flex relative overflow-hidden bg-white"},t.createElement("div",{className:"pointer-events-none absolute inset-0"},t.createElement("div",{className:"absolute inset-0 bg-[linear-gradient(110deg,#ffffff_0%,#f7fbff_40%,#edf6ff_70%,#eaf3ff_100%)]"}),t.createElement("div",{className:"absolute inset-0 bg-[radial-gradient(1200px_600px_at_-10%_-10%,rgba(59,130,246,0.12),transparent),radial-gradient(900px_500px_at_110%_20%,rgba(147,51,234,0.10),transparent),radial-gradient(700px_400px_at_60%_120%,rgba(99,102,241,0.10),transparent)]"}),t.createElement("div",{className:"absolute inset-0 bg-[linear-gradient(115deg,rgba(255,255,255,0.6)_0%,rgba(255,255,255,0.15)_32%,transparent_32%,transparent_68%,rgba(255,255,255,0.15)_68%,rgba(255,255,255,0.6)_100%)]"})),t.createElement("div",{className:"flex-1 relative flex items-center justify-center"},t.createElement("div",{className:"relative z-10 max-w-4xl w-full px-16 text-left"},t.createElement("div",{className:"mb-12"},t.createElement("div",{className:"inline-flex items-center rounded-2xl px-4 py-2 bg-white/70 backdrop-blur border border-white/60"},t.createElement("span",{className:"text-2xl font-semibold tracking-tight text-gray-900"},r("data.dataManagement"))),t.createElement("h1",{className:"mt-8 text-5xl md:text-6xl font-extrabold leading-tight text-gray-900"},"WE0-CMS"),t.createElement("p",{className:"mt-6 text-2xl text-gray-600"},r("auth.welcome"))))),t.createElement("div",{className:"w-[480px] min-w-[380px] flex items-center justify-center p-8 mt-30"},t.createElement("div",{className:"w-full max-w-sm"},f?t.createElement(sh,{className:"bg-white/30 backdrop-blur-xl border border-white/50 shadow-none rounded-3xl overflow-hidden"},t.createElement(uh,{className:"p-8"},t.createElement("div",{className:"space-y-4"},t.createElement(st,{className:"h-12 w-48"}),t.createElement(st,{className:"h-4 w-64"}),t.createElement(st,{className:"h-10 w-full"}),t.createElement(st,{className:"h-10 w-full"})))):t.createElement(sh,{className:"bg-white/30 backdrop-blur-xl border border-white/50 shadow-none rounded-3xl overflow-hidden"},t.createElement(ah,{className:"p-8 pb-6"},t.createElement(lh,{className:"text-center text-2xl mb-2 text-gray-800"},r("signup"===g?"auth.createAdminAccount":"auth.welcome")),t.createElement(ch,{className:"text-center text-gray-500"},r("signup"===g?"auth.firstTimeSetup":"auth.pleaseLogin"))),t.createElement(uh,{className:"p-8 pt-0"},t.createElement("form",{onSubmit:b,className:"space-y-6"},t.createElement("div",{className:"space-y-2"},t.createElement(oh,{htmlFor:"username"},r("auth.username"),"/",r("auth.email")),t.createElement("div",{className:"relative"},t.createElement(le,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400"}),t.createElement(St,{id:"username",type:"text",placeholder:r("auth.email"),value:s,onChange:function(e){return l(e.target.value)},className:"pl-10 h-12 rounded-xl border-gray-200 hover:border-blue-400 focus:border-blue-500 transition-colors",required:!0,minLength:2}))),t.createElement("div",{className:"space-y-2"},t.createElement(oh,{htmlFor:"password"},r("auth.password")),t.createElement("div",{className:"relative"},t.createElement(Q,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400"}),t.createElement(St,{id:"password",type:"password",placeholder:r("auth.password"),value:u,onChange:function(e){return h(e.target.value)},className:"pl-10 h-12 rounded-xl border-gray-200 hover:border-blue-400 focus:border-blue-500 transition-colors",required:!0,minLength:6}))),t.createElement(kt,{type:"submit",className:"w-full h-12 rounded-xl transition-all duration-200 font-semibold text-base shadow-lg hover:brightness-[1.03] active:scale-[0.99]",style:{backgroundImage:"linear-gradient(135deg, rgba(236, 248, 255, 0.78) 0%, rgba(221, 238, 255, 0.78) 100%)",color:"rgba(0, 0, 0, 0.7)",border:"none",boxShadow:"0 6px 24px rgba(37, 99, 235, 0.12)"},disabled:f},t.createElement(Z,{className:"h-4 w-4 mr-2"}),r(f?"common.loading":"signup"===g?"auth.signup":"auth.login")))))))))}function gp(e,[t,n]){return Math.min(n,Math.max(t,e))}function vp(t){const n=bp(t),r=e.forwardRef((t,r)=>{const{children:i,...o}=t,s=e.Children.toArray(i),a=s.find(wp);if(a){const t=a.props.children,i=s.map(n=>n===a?e.Children.count(t)>1?e.Children.only(null):e.isValidElement(t)?t.props.children:null:n);return f(n,{...o,ref:r,children:e.isValidElement(t)?e.cloneElement(t,void 0,i):null})}return f(n,{...o,ref:r,children:i})});return r.displayName=`${t}.Slot`,r}function bp(t){const n=e.forwardRef((t,n)=>{const{children:r,...i}=t;if(e.isValidElement(r)){const t=function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;if(n)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(r),o=function(e,t){const n={...t};for(const r in t){const i=e[r],o=t[r];/^on[A-Z]/.test(r)?i&&o?n[r]=(...e)=>{const t=o(...e);return i(...e),t}:i&&(n[r]=i):"style"===r?n[r]={...i,...o}:"className"===r&&(n[r]=[i,o].filter(Boolean).join(" "))}return{...e,...n}}(i,r.props);return r.type!==e.Fragment&&(o.ref=n?lt(n,t):t),e.cloneElement(r,o)}return e.Children.count(r)>1?e.Children.only(null):null});return n.displayName=`${t}.SlotClone`,n}var yp=Symbol("radix.slottable");function wp(t){return e.isValidElement(t)&&"function"==typeof t.type&&"__radixId"in t.type&&t.type.__radixId===yp}var xp=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((t,n)=>{const r=vp(`Primitive.${n}`),i=e.forwardRef((e,t)=>{const{asChild:i,...o}=e,s=i?r:n;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),f(s,{...o,ref:t})});return i.displayName=`Primitive.${n}`,{...t,[n]:i}},{});var kp,Sp="dismissableLayer.update",Ep="dismissableLayer.pointerDownOutside",Cp="dismissableLayer.focusOutside",Np=e.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Op=e.forwardRef((t,n)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:a,onDismiss:l,...c}=t,u=e.useContext(Np),[h,d]=e.useState(null),p=h?.ownerDocument??globalThis?.document,[,m]=e.useState({}),g=ct(n,e=>d(e)),v=Array.from(u.layers),[b]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),y=v.indexOf(b),w=h?v.indexOf(h):-1,x=u.layersWithOutsidePointerEventsDisabled.size>0,k=w>=y,S=function(t,n=globalThis?.document){const r=qt(t),i=e.useRef(!1),o=e.useRef(()=>{});return e.useEffect(()=>{const e=e=>{if(e.target&&!i.current){let t=function(){Mp(Ep,r,i,{discrete:!0})};const i={originalEvent:e};"touch"===e.pointerType?(n.removeEventListener("click",o.current),o.current=t,n.addEventListener("click",o.current,{once:!0})):t()}else n.removeEventListener("click",o.current);i.current=!1},t=window.setTimeout(()=>{n.addEventListener("pointerdown",e)},0);return()=>{window.clearTimeout(t),n.removeEventListener("pointerdown",e),n.removeEventListener("click",o.current)}},[n,r]),{onPointerDownCapture:()=>i.current=!0}}(e=>{const t=e.target,n=[...u.branches].some(e=>e.contains(t));k&&!n&&(o?.(e),a?.(e),e.defaultPrevented||l?.())},p),E=function(t,n=globalThis?.document){const r=qt(t),i=e.useRef(!1);return e.useEffect(()=>{const e=e=>{if(e.target&&!i.current){Mp(Cp,r,{originalEvent:e},{discrete:!1})}};return n.addEventListener("focusin",e),()=>n.removeEventListener("focusin",e)},[n,r]),{onFocusCapture:()=>i.current=!0,onBlurCapture:()=>i.current=!1}}(e=>{const t=e.target;[...u.branches].some(e=>e.contains(t))||(s?.(e),a?.(e),e.defaultPrevented||l?.())},p);return Ut(e=>{w===u.layers.size-1&&(i?.(e),!e.defaultPrevented&&l&&(e.preventDefault(),l()))},p),e.useEffect(()=>{if(h)return r&&(0===u.layersWithOutsidePointerEventsDisabled.size&&(kp=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(h)),u.layers.add(h),Ap(),()=>{r&&1===u.layersWithOutsidePointerEventsDisabled.size&&(p.body.style.pointerEvents=kp)}},[h,p,r,u]),e.useEffect(()=>()=>{h&&(u.layers.delete(h),u.layersWithOutsidePointerEventsDisabled.delete(h),Ap())},[h,u]),e.useEffect(()=>{const e=()=>m({});return document.addEventListener(Sp,e),()=>document.removeEventListener(Sp,e)},[]),f(xp.div,{...c,ref:g,style:{pointerEvents:x?k?"auto":"none":void 0,...t.style},onFocusCapture:Tt(t.onFocusCapture,E.onFocusCapture),onBlurCapture:Tt(t.onBlurCapture,E.onBlurCapture),onPointerDownCapture:Tt(t.onPointerDownCapture,S.onPointerDownCapture)})});Op.displayName="DismissableLayer";function Ap(){const e=new CustomEvent(Sp);document.dispatchEvent(e)}function Mp(e,t,n,{discrete:r}){const i=n.originalEvent.target,o=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?function(e,t){e&&g.flushSync(()=>e.dispatchEvent(t))}(i,o):i.dispatchEvent(o)}e.forwardRef((t,n)=>{const r=e.useContext(Np),i=e.useRef(null),o=ct(n,i);return e.useEffect(()=>{const e=i.current;if(e)return r.branches.add(e),()=>{r.branches.delete(e)}},[r.branches]),f(xp.div,{...t,ref:o})}).displayName="DismissableLayerBranch";var Tp="focusScope.autoFocusOnMount",Rp="focusScope.autoFocusOnUnmount",Dp={bubbles:!1,cancelable:!0},Pp=e.forwardRef((t,n)=>{const{loop:r=!1,trapped:i=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...a}=t,[l,c]=e.useState(null),u=qt(o),h=qt(s),d=e.useRef(null),p=ct(n,e=>c(e)),m=e.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;e.useEffect(()=>{if(i){let e=function(e){if(m.paused||!l)return;const t=e.target;l.contains(t)?d.current=t:Bp(d.current,{select:!0})},t=function(e){if(m.paused||!l)return;const t=e.relatedTarget;null!==t&&(l.contains(t)||Bp(d.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(const t of e)t.removedNodes.length>0&&Bp(l)};document.addEventListener("focusin",e),document.addEventListener("focusout",t);const r=new MutationObserver(n);return l&&r.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",e),document.removeEventListener("focusout",t),r.disconnect()}}},[i,l,m.paused]),e.useEffect(()=>{if(l){Fp.add(m);const t=document.activeElement;if(!l.contains(t)){const n=new CustomEvent(Tp,Dp);l.addEventListener(Tp,u),l.dispatchEvent(n),n.defaultPrevented||(!function(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Bp(r,{select:t}),document.activeElement!==n)return}((e=Lp(l),e.filter(e=>"A"!==e.tagName)),{select:!0}),document.activeElement===t&&Bp(l))}return()=>{l.removeEventListener(Tp,u),setTimeout(()=>{const e=new CustomEvent(Rp,Dp);l.addEventListener(Rp,h),l.dispatchEvent(e),e.defaultPrevented||Bp(t??document.body,{select:!0}),l.removeEventListener(Rp,h),Fp.remove(m)},0)}}var e},[l,u,h,m]);const g=e.useCallback(e=>{if(!r&&!i)return;if(m.paused)return;const t="Tab"===e.key&&!e.altKey&&!e.ctrlKey&&!e.metaKey,n=document.activeElement;if(t&&n){const t=e.currentTarget,[i,o]=function(e){const t=Lp(e),n=Ip(t,e),r=Ip(t.reverse(),e);return[n,r]}(t);i&&o?e.shiftKey||n!==o?e.shiftKey&&n===i&&(e.preventDefault(),r&&Bp(o,{select:!0})):(e.preventDefault(),r&&Bp(i,{select:!0})):n===t&&e.preventDefault()}},[r,i,m.paused]);return f(xp.div,{tabIndex:-1,...a,ref:p,onKeyDown:g})});function Lp(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{const t="INPUT"===e.tagName&&"hidden"===e.type;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Ip(e,t){for(const n of e)if(!_p(n,{upTo:t}))return n}function _p(e,{upTo:t}){if("hidden"===getComputedStyle(e).visibility)return!0;for(;e;){if(void 0!==t&&e===t)return!1;if("none"===getComputedStyle(e).display)return!0;e=e.parentElement}return!1}function Bp(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&function(e){return e instanceof HTMLInputElement&&"select"in e}(e)&&t&&e.select()}}Pp.displayName="FocusScope";var Fp=function(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=jp(e,t),e.unshift(t)},remove(t){e=jp(e,t),e[0]?.resume()}}}();function jp(e,t){const n=[...e],r=n.indexOf(t);return-1!==r&&n.splice(r,1),n}var Wp=e.forwardRef((e,t)=>{const{children:n,width:r=10,height:i=5,...o}=e;return f(xp.svg,{...o,ref:t,width:r,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:f("polygon",{points:"0,0 30,0 15,10"})})});Wp.displayName="Arrow";var zp=Wp,Hp="Popper",[Vp,qp]=Rt(Hp),[Up,$p]=Vp(Hp),Kp=t=>{const{__scopePopper:n,children:r}=t,[i,o]=e.useState(null);return f(Up,{scope:n,anchor:i,onAnchorChange:o,children:r})};Kp.displayName=Hp;var Yp="PopperAnchor",Gp=e.forwardRef((t,n)=>{const{__scopePopper:r,virtualRef:i,...o}=t,s=$p(Yp,r),a=e.useRef(null),l=ct(n,a),c=e.useRef(null);return e.useEffect(()=>{const e=c.current;c.current=i?.current||a.current,e!==c.current&&s.onAnchorChange(c.current)}),i?null:f(xp.div,{...o,ref:l})});Gp.displayName=Yp;var Xp="PopperContent",[Jp,Qp]=Vp(Xp),Zp=e.forwardRef((t,n)=>{const{__scopePopper:r,side:i="bottom",sideOffset:o=0,align:s="center",alignOffset:a=0,arrowPadding:l=0,avoidCollisions:c=!0,collisionBoundary:u=[],collisionPadding:h=0,sticky:d="partial",hideWhenDetached:p=!1,updatePositionStrategy:m="optimized",onPlaced:g,...v}=t,b=$p(Xp,r),[y,w]=e.useState(null),x=ct(n,e=>w(e)),[k,S]=e.useState(null),E=us(k),C=E?.width??0,N=E?.height??0,O=i+("center"!==s?"-"+s:""),A="number"==typeof h?h:{top:0,right:0,bottom:0,left:0,...h},M=Array.isArray(u)?u:[u],T=M.length>0,R={padding:A,boundary:M.filter(rm),altBoundary:T},{refs:D,floatingStyles:P,placement:L,isPositioned:I,middlewareData:_}=Zo({strategy:"fixed",placement:O,whileElementsMounted:(...e)=>jo(...e,{animationFrame:"always"===m}),elements:{reference:b.anchor},middleware:[ts({mainAxis:o+N,alignmentAxis:a}),c&&ns({mainAxis:!0,crossAxis:!1,limiter:"partial"===d?rs():void 0,...R}),c&&is({...R}),os({...R,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{const{width:i,height:o}=t.reference,s=e.floating.style;s.setProperty("--radix-popper-available-width",`${n}px`),s.setProperty("--radix-popper-available-height",`${r}px`),s.setProperty("--radix-popper-anchor-width",`${i}px`),s.setProperty("--radix-popper-anchor-height",`${o}px`)}}),k&&as({element:k,padding:l}),im({arrowWidth:C,arrowHeight:N}),p&&ss({strategy:"referenceHidden",...R})]}),[B,F]=om(L),j=qt(g);Pt(()=>{I&&j?.()},[I,j]);const W=_.arrow?.x,z=_.arrow?.y,H=0!==_.arrow?.centerOffset,[V,q]=e.useState();return Pt(()=>{y&&q(window.getComputedStyle(y).zIndex)},[y]),f("div",{ref:D.setFloating,"data-radix-popper-content-wrapper":"",style:{...P,transform:I?P.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:V,"--radix-popper-transform-origin":[_.transformOrigin?.x,_.transformOrigin?.y].join(" "),..._.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:f(Jp,{scope:r,placedSide:B,onArrowChange:S,arrowX:W,arrowY:z,shouldHideArrow:H,children:f(xp.div,{"data-side":B,"data-align":F,...v,ref:x,style:{...v.style,animation:I?void 0:"none"}})})})});Zp.displayName=Xp;var em="PopperArrow",tm={top:"bottom",right:"left",bottom:"top",left:"right"},nm=e.forwardRef(function(e,t){const{__scopePopper:n,...r}=e,i=Qp(em,n),o=tm[i.placedSide];return f("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:f(zp,{...r,ref:t,style:{...r.style,display:"block"}})})});function rm(e){return null!==e}nm.displayName=em;var im=e=>({name:"transformOrigin",options:e,fn(t){const{placement:n,rects:r,middlewareData:i}=t,o=0!==i.arrow?.centerOffset,s=o?0:e.arrowWidth,a=o?0:e.arrowHeight,[l,c]=om(n),u={start:"0%",center:"50%",end:"100%"}[c],h=(i.arrow?.x??0)+s/2,d=(i.arrow?.y??0)+a/2;let f="",p="";return"bottom"===l?(f=o?u:`${h}px`,p=-a+"px"):"top"===l?(f=o?u:`${h}px`,p=`${r.floating.height+a}px`):"right"===l?(f=-a+"px",p=o?u:`${d}px`):"left"===l&&(f=`${r.floating.width+a}px`,p=o?u:`${d}px`),{data:{x:f,y:p}}}});function om(e){const[t,n="center"]=e.split("-");return[t,n]}var sm=Kp,am=Gp,lm=Zp,cm=nm,um=e.forwardRef((t,n)=>{const{container:r,...i}=t,[o,s]=e.useState(!1);Pt(()=>s(!0),[]);const a=r||o&&globalThis?.document?.body;return a?v.createPortal(f(xp.div,{...i,ref:n}),a):null});function hm(t){const n=e.useRef({value:t,previous:t});return e.useMemo(()=>(n.current.value!==t&&(n.current.previous=n.current.value,n.current.value=t),n.current.previous),[t])}um.displayName="Portal";var dm=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"});e.forwardRef((e,t)=>f(xp.span,{...e,ref:t,style:{...dm,...e.style}})).displayName="VisuallyHidden";var fm=[" ","Enter","ArrowUp","ArrowDown"],pm=[" ","Enter"],mm="Select",[gm,vm,bm]=function(e){const n=e+"CollectionProvider",[r,i]=Rt(n),[o,s]=r(n,{collectionRef:{current:null},itemMap:new Map}),a=e=>{const{scope:n,children:r}=e,i=t.useRef(null),s=t.useRef(new Map).current;return f(o,{scope:n,itemMap:s,collectionRef:i,children:r})};a.displayName=n;const l=e+"CollectionSlot",c=vp(l),u=t.forwardRef((e,t)=>{const{scope:n,children:r}=e,i=ct(t,s(l,n).collectionRef);return f(c,{ref:i,children:r})});u.displayName=l;const h=e+"CollectionItemSlot",d="data-radix-collection-item",p=vp(h),m=t.forwardRef((e,n)=>{const{scope:r,children:i,...o}=e,a=t.useRef(null),l=ct(n,a),c=s(h,r);return t.useEffect(()=>(c.itemMap.set(a,{ref:a,...o}),()=>{c.itemMap.delete(a)})),f(p,{[d]:"",ref:l,children:i})});return m.displayName=h,[{Provider:a,Slot:u,ItemSlot:m},function(n){const r=s(e+"CollectionConsumer",n);return t.useCallback(()=>{const e=r.collectionRef.current;if(!e)return[];const t=Array.from(e.querySelectorAll(`[${d}]`));return Array.from(r.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[r.collectionRef,r.itemMap])},i]}(mm),[ym,wm]=Rt(mm,[bm,qp]),xm=qp(),[km,Sm]=ym(mm),[Em,Cm]=ym(mm),Nm=t=>{const{__scopeSelect:n,children:r,open:i,defaultOpen:o,onOpenChange:s,value:a,defaultValue:l,onValueChange:c,dir:u,name:h,autoComplete:d,disabled:m,required:g,form:v}=t,b=xm(n),[y,w]=e.useState(null),[x,k]=e.useState(null),[S,E]=e.useState(!1),C=Fa(u),[N,O]=Ft({prop:i,defaultProp:o??!1,onChange:s,caller:mm}),[A,M]=Ft({prop:a,defaultProp:l,onChange:c,caller:mm}),T=e.useRef(null),R=!y||(v||!!y.closest("form")),[D,P]=e.useState(new Set),L=Array.from(D).map(e=>e.props.value).join(";");return f(sm,{...b,children:p(km,{required:g,scope:n,trigger:y,onTriggerChange:w,valueNode:x,onValueNodeChange:k,valueNodeHasChildren:S,onValueNodeHasChildrenChange:E,contentId:_t(),value:A,onValueChange:M,open:N,onOpenChange:O,dir:C,triggerPointerDownPosRef:T,disabled:m,children:[f(gm.Provider,{scope:n,children:f(Em,{scope:t.__scopeSelect,onNativeOptionAdd:e.useCallback(e=>{P(t=>new Set(t).add(e))},[]),onNativeOptionRemove:e.useCallback(e=>{P(t=>{const n=new Set(t);return n.delete(e),n})},[]),children:r})}),R?p(dg,{"aria-hidden":!0,required:g,tabIndex:-1,name:h,autoComplete:d,value:A,onChange:e=>M(e.target.value),disabled:m,form:v,children:[void 0===A?f("option",{value:""}):null,Array.from(D)]},L):null]})})};Nm.displayName=mm;var Om="SelectTrigger",Am=e.forwardRef((t,n)=>{const{__scopeSelect:r,disabled:i=!1,...o}=t,s=xm(r),a=Sm(Om,r),l=a.disabled||i,c=ct(n,a.onTriggerChange),u=vm(r),h=e.useRef("touch"),[d,p,m]=pg(e=>{const t=u().filter(e=>!e.disabled),n=t.find(e=>e.value===a.value),r=mg(t,e,n);void 0!==r&&a.onValueChange(r.value)}),g=e=>{l||(a.onOpenChange(!0),m()),e&&(a.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return f(am,{asChild:!0,...s,children:f(xp.button,{type:"button",role:"combobox","aria-controls":a.contentId,"aria-expanded":a.open,"aria-required":a.required,"aria-autocomplete":"none",dir:a.dir,"data-state":a.open?"open":"closed",disabled:l,"data-disabled":l?"":void 0,"data-placeholder":fg(a.value)?"":void 0,...o,ref:c,onClick:Tt(o.onClick,e=>{e.currentTarget.focus(),"mouse"!==h.current&&g(e)}),onPointerDown:Tt(o.onPointerDown,e=>{h.current=e.pointerType;const t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),0===e.button&&!1===e.ctrlKey&&"mouse"===e.pointerType&&(g(e),e.preventDefault())}),onKeyDown:Tt(o.onKeyDown,e=>{const t=""!==d.current;e.ctrlKey||e.altKey||e.metaKey||1!==e.key.length||p(e.key),t&&" "===e.key||fm.includes(e.key)&&(g(),e.preventDefault())})})})});Am.displayName=Om;var Mm="SelectValue",Tm=e.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:i,children:o,placeholder:s="",...a}=e,l=Sm(Mm,n),{onValueNodeHasChildrenChange:c}=l,u=void 0!==o,h=ct(t,l.onValueNodeChange);return Pt(()=>{c(u)},[c,u]),f(xp.span,{...a,ref:h,style:{pointerEvents:"none"},children:fg(l.value)?f(m,{children:s}):o})});Tm.displayName=Mm;var Rm=e.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...i}=e;return f(xp.span,{"aria-hidden":!0,...i,ref:t,children:r||"▼"})});Rm.displayName="SelectIcon";var Dm=e=>f(um,{asChild:!0,...e});Dm.displayName="SelectPortal";var Pm="SelectContent",Lm=e.forwardRef((t,n)=>{const r=Sm(Pm,t.__scopeSelect),[i,o]=e.useState();if(Pt(()=>{o(new DocumentFragment)},[]),!r.open){const e=i;return e?g.createPortal(f(_m,{scope:t.__scopeSelect,children:f(gm.Slot,{scope:t.__scopeSelect,children:f("div",{children:t.children})})}),e):null}return f(jm,{...t,ref:n})});Lm.displayName=Pm;var Im=10,[_m,Bm]=ym(Pm),Fm=vp("SelectContent.RemoveScroll"),jm=e.forwardRef((t,n)=>{const{__scopeSelect:r,position:i="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:a,side:l,sideOffset:c,align:u,alignOffset:h,arrowPadding:d,collisionBoundary:p,collisionPadding:m,sticky:g,hideWhenDetached:v,avoidCollisions:b,...y}=t,w=Sm(Pm,r),[x,k]=e.useState(null),[S,E]=e.useState(null),C=ct(n,e=>k(e)),[N,O]=e.useState(null),[A,M]=e.useState(null),T=vm(r),[R,D]=e.useState(!1),P=e.useRef(!1);e.useEffect(()=>{if(x)return cr(x)},[x]),mn();const L=e.useCallback(e=>{const[t,...n]=T().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(const n of e){if(n===i)return;if(n?.scrollIntoView({block:"nearest"}),n===t&&S&&(S.scrollTop=0),n===r&&S&&(S.scrollTop=S.scrollHeight),n?.focus(),document.activeElement!==i)return}},[T,S]),I=e.useCallback(()=>L([N,x]),[L,N,x]);e.useEffect(()=>{R&&I()},[R,I]);const{onOpenChange:_,triggerPointerDownPosRef:B}=w;e.useEffect(()=>{if(x){let e={x:0,y:0};const t=t=>{e={x:Math.abs(Math.round(t.pageX)-(B.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(B.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():x.contains(n.target)||_(!1),document.removeEventListener("pointermove",t),B.current=null};return null!==B.current&&(document.addEventListener("pointermove",t),document.addEventListener("pointerup",n,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",t),document.removeEventListener("pointerup",n,{capture:!0})}}},[x,_,B]),e.useEffect(()=>{const e=()=>_(!1);return window.addEventListener("blur",e),window.addEventListener("resize",e),()=>{window.removeEventListener("blur",e),window.removeEventListener("resize",e)}},[_]);const[F,j]=pg(e=>{const t=T().filter(e=>!e.disabled),n=t.find(e=>e.ref.current===document.activeElement),r=mg(t,e,n);r&&setTimeout(()=>r.ref.current.focus())}),W=e.useCallback((e,t,n)=>{const r=!P.current&&!n;(void 0!==w.value&&w.value===t||r)&&(O(e),r&&(P.current=!0))},[w.value]),z=e.useCallback(()=>x?.focus(),[x]),H=e.useCallback((e,t,n)=>{const r=!P.current&&!n;(void 0!==w.value&&w.value===t||r)&&M(e)},[w.value]),V="popper"===i?zm:Wm,q=V===zm?{side:l,sideOffset:c,align:u,alignOffset:h,arrowPadding:d,collisionBoundary:p,collisionPadding:m,sticky:g,hideWhenDetached:v,avoidCollisions:b}:{};return f(_m,{scope:r,content:x,viewport:S,onViewportChange:E,itemRefCallback:W,selectedItem:N,onItemLeave:z,itemTextRefCallback:H,focusSelectedItem:I,selectedItemText:A,position:i,isPositioned:R,searchRef:F,children:f(nr,{as:Fm,allowPinchZoom:!0,children:f(Pp,{asChild:!0,trapped:w.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:Tt(o,e=>{w.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:f(Op,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:f(V,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:e=>e.preventDefault(),...y,...q,onPlaced:()=>D(!0),ref:C,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:Tt(y.onKeyDown,e=>{const t=e.ctrlKey||e.altKey||e.metaKey;if("Tab"===e.key&&e.preventDefault(),t||1!==e.key.length||j(e.key),["ArrowUp","ArrowDown","Home","End"].includes(e.key)){let t=T().filter(e=>!e.disabled).map(e=>e.ref.current);if(["ArrowUp","End"].includes(e.key)&&(t=t.slice().reverse()),["ArrowUp","ArrowDown"].includes(e.key)){const n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>L(t)),e.preventDefault()}})})})})})})});jm.displayName="SelectContentImpl";var Wm=e.forwardRef((t,n)=>{const{__scopeSelect:r,onPlaced:i,...o}=t,s=Sm(Pm,r),a=Bm(Pm,r),[l,c]=e.useState(null),[u,h]=e.useState(null),d=ct(n,e=>h(e)),p=vm(r),m=e.useRef(!1),g=e.useRef(!0),{viewport:v,selectedItem:b,selectedItemText:y,focusSelectedItem:w}=a,x=e.useCallback(()=>{if(s.trigger&&s.valueNode&&l&&u&&v&&b&&y){const e=s.trigger.getBoundingClientRect(),t=u.getBoundingClientRect(),n=s.valueNode.getBoundingClientRect(),r=y.getBoundingClientRect();if("rtl"!==s.dir){const i=r.left-t.left,o=n.left-i,s=e.left-o,a=e.width+s,c=Math.max(a,t.width),u=window.innerWidth-Im,h=gp(o,[Im,Math.max(Im,u-c)]);l.style.minWidth=a+"px",l.style.left=h+"px"}else{const i=t.right-r.right,o=window.innerWidth-n.right-i,s=window.innerWidth-e.right-o,a=e.width+s,c=Math.max(a,t.width),u=window.innerWidth-Im,h=gp(o,[Im,Math.max(Im,u-c)]);l.style.minWidth=a+"px",l.style.right=h+"px"}const o=p(),a=window.innerHeight-2*Im,c=v.scrollHeight,h=window.getComputedStyle(u),d=parseInt(h.borderTopWidth,10),f=parseInt(h.paddingTop,10),g=parseInt(h.borderBottomWidth,10),w=d+f+c+parseInt(h.paddingBottom,10)+g,x=Math.min(5*b.offsetHeight,w),k=window.getComputedStyle(v),S=parseInt(k.paddingTop,10),E=parseInt(k.paddingBottom,10),C=e.top+e.height/2-Im,N=a-C,O=b.offsetHeight/2,A=d+f+(b.offsetTop+O),M=w-A;if(A<=C){const e=o.length>0&&b===o[o.length-1].ref.current;l.style.bottom="0px";const t=u.clientHeight-v.offsetTop-v.offsetHeight,n=A+Math.max(N,O+(e?E:0)+t+g);l.style.height=n+"px"}else{const e=o.length>0&&b===o[0].ref.current;l.style.top="0px";const t=Math.max(C,d+v.offsetTop+(e?S:0)+O)+M;l.style.height=t+"px",v.scrollTop=A-C+v.offsetTop}l.style.margin=`${Im}px 0`,l.style.minHeight=x+"px",l.style.maxHeight=a+"px",i?.(),requestAnimationFrame(()=>m.current=!0)}},[p,s.trigger,s.valueNode,l,u,v,b,y,s.dir,i]);Pt(()=>x(),[x]);const[k,S]=e.useState();Pt(()=>{u&&S(window.getComputedStyle(u).zIndex)},[u]);const E=e.useCallback(e=>{e&&!0===g.current&&(x(),w?.(),g.current=!1)},[x,w]);return f(Hm,{scope:r,contentWrapper:l,shouldExpandOnScrollRef:m,onScrollButtonChange:E,children:f("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:k},children:f(xp.div,{...o,ref:d,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Wm.displayName="SelectItemAlignedPosition";var zm=e.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:i=Im,...o}=e,s=xm(n);return f(lm,{...s,...o,ref:t,align:r,collisionPadding:i,style:{boxSizing:"border-box",...o.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});zm.displayName="SelectPopperPosition";var[Hm,Vm]=ym(Pm,{}),qm="SelectViewport",Um=e.forwardRef((t,n)=>{const{__scopeSelect:r,nonce:i,...o}=t,s=Bm(qm,r),a=Vm(qm,r),l=ct(n,s.onViewportChange),c=e.useRef(0);return p(m,{children:[f("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:i}),f(gm.Slot,{scope:r,children:f(xp.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:Tt(o.onScroll,e=>{const t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=a;if(r?.current&&n){const e=Math.abs(c.current-t.scrollTop);if(e>0){const r=window.innerHeight-2*Im,i=parseFloat(n.style.minHeight),o=parseFloat(n.style.height),s=Math.max(i,o);if(s<r){const i=s+e,o=Math.min(r,i),a=i-o;n.style.height=o+"px","0px"===n.style.bottom&&(t.scrollTop=a>0?a:0,n.style.justifyContent="flex-end")}}}c.current=t.scrollTop})})})]})});Um.displayName=qm;var $m="SelectGroup",[Km,Ym]=ym($m);e.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,i=_t();return f(Km,{scope:n,id:i,children:f(xp.div,{role:"group","aria-labelledby":i,...r,ref:t})})}).displayName=$m;var Gm="SelectLabel",Xm=e.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,i=Ym(Gm,n);return f(xp.div,{id:i.id,...r,ref:t})});Xm.displayName=Gm;var Jm="SelectItem",[Qm,Zm]=ym(Jm),eg=e.forwardRef((t,n)=>{const{__scopeSelect:r,value:i,disabled:o=!1,textValue:s,...a}=t,l=Sm(Jm,r),c=Bm(Jm,r),u=l.value===i,[h,d]=e.useState(s??""),[p,m]=e.useState(!1),g=ct(n,e=>c.itemRefCallback?.(e,i,o)),v=_t(),b=e.useRef("touch"),y=()=>{o||(l.onValueChange(i),l.onOpenChange(!1))};if(""===i)throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return f(Qm,{scope:r,value:i,disabled:o,textId:v,isSelected:u,onItemTextChange:e.useCallback(e=>{d(t=>t||(e?.textContent??"").trim())},[]),children:f(gm.ItemSlot,{scope:r,value:i,disabled:o,textValue:h,children:f(xp.div,{role:"option","aria-labelledby":v,"data-highlighted":p?"":void 0,"aria-selected":u&&p,"data-state":u?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...a,ref:g,onFocus:Tt(a.onFocus,()=>m(!0)),onBlur:Tt(a.onBlur,()=>m(!1)),onClick:Tt(a.onClick,()=>{"mouse"!==b.current&&y()}),onPointerUp:Tt(a.onPointerUp,()=>{"mouse"===b.current&&y()}),onPointerDown:Tt(a.onPointerDown,e=>{b.current=e.pointerType}),onPointerMove:Tt(a.onPointerMove,e=>{b.current=e.pointerType,o?c.onItemLeave?.():"mouse"===b.current&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Tt(a.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:Tt(a.onKeyDown,e=>{""!==c.searchRef?.current&&" "===e.key||(pm.includes(e.key)&&y()," "===e.key&&e.preventDefault())})})})})});eg.displayName=Jm;var tg="SelectItemText",ng=e.forwardRef((t,n)=>{const{__scopeSelect:r,className:i,style:o,...s}=t,a=Sm(tg,r),l=Bm(tg,r),c=Zm(tg,r),u=Cm(tg,r),[h,d]=e.useState(null),v=ct(n,e=>d(e),c.onItemTextChange,e=>l.itemTextRefCallback?.(e,c.value,c.disabled)),b=h?.textContent,y=e.useMemo(()=>f("option",{value:c.value,disabled:c.disabled,children:b},c.value),[c.disabled,c.value,b]),{onNativeOptionAdd:w,onNativeOptionRemove:x}=u;return Pt(()=>(w(y),()=>x(y)),[w,x,y]),p(m,{children:[f(xp.span,{id:c.textId,...s,ref:v}),c.isSelected&&a.valueNode&&!a.valueNodeHasChildren?g.createPortal(s.children,a.valueNode):null]})});ng.displayName=tg;var rg="SelectItemIndicator",ig=e.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Zm(rg,n).isSelected?f(xp.span,{"aria-hidden":!0,...r,ref:t}):null});ig.displayName=rg;var og="SelectScrollUpButton",sg=e.forwardRef((t,n)=>{const r=Bm(og,t.__scopeSelect),i=Vm(og,t.__scopeSelect),[o,s]=e.useState(!1),a=ct(n,i.onScrollButtonChange);return Pt(()=>{if(r.viewport&&r.isPositioned){let e=function(){const e=t.scrollTop>0;s(e)};const t=r.viewport;return e(),t.addEventListener("scroll",e),()=>t.removeEventListener("scroll",e)}},[r.viewport,r.isPositioned]),o?f(cg,{...t,ref:a,onAutoScroll:()=>{const{viewport:e,selectedItem:t}=r;e&&t&&(e.scrollTop=e.scrollTop-t.offsetHeight)}}):null});sg.displayName=og;var ag="SelectScrollDownButton",lg=e.forwardRef((t,n)=>{const r=Bm(ag,t.__scopeSelect),i=Vm(ag,t.__scopeSelect),[o,s]=e.useState(!1),a=ct(n,i.onScrollButtonChange);return Pt(()=>{if(r.viewport&&r.isPositioned){let e=function(){const e=t.scrollHeight-t.clientHeight,n=Math.ceil(t.scrollTop)<e;s(n)};const t=r.viewport;return e(),t.addEventListener("scroll",e),()=>t.removeEventListener("scroll",e)}},[r.viewport,r.isPositioned]),o?f(cg,{...t,ref:a,onAutoScroll:()=>{const{viewport:e,selectedItem:t}=r;e&&t&&(e.scrollTop=e.scrollTop+t.offsetHeight)}}):null});lg.displayName=ag;var cg=e.forwardRef((t,n)=>{const{__scopeSelect:r,onAutoScroll:i,...o}=t,s=Bm("SelectScrollButton",r),a=e.useRef(null),l=vm(r),c=e.useCallback(()=>{null!==a.current&&(window.clearInterval(a.current),a.current=null)},[]);return e.useEffect(()=>()=>c(),[c]),Pt(()=>{const e=l().find(e=>e.ref.current===document.activeElement);e?.ref.current?.scrollIntoView({block:"nearest"})},[l]),f(xp.div,{"aria-hidden":!0,...o,ref:n,style:{flexShrink:0,...o.style},onPointerDown:Tt(o.onPointerDown,()=>{null===a.current&&(a.current=window.setInterval(i,50))}),onPointerMove:Tt(o.onPointerMove,()=>{s.onItemLeave?.(),null===a.current&&(a.current=window.setInterval(i,50))}),onPointerLeave:Tt(o.onPointerLeave,()=>{c()})})}),ug=e.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return f(xp.div,{"aria-hidden":!0,...r,ref:t})});ug.displayName="SelectSeparator";var hg="SelectArrow";e.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,i=xm(n),o=Sm(hg,n),s=Bm(hg,n);return o.open&&"popper"===s.position?f(cm,{...i,...r,ref:t}):null}).displayName=hg;var dg=e.forwardRef(({__scopeSelect:t,value:n,...r},i)=>{const o=e.useRef(null),s=ct(i,o),a=hm(n);return e.useEffect(()=>{const e=o.current;if(!e)return;const t=window.HTMLSelectElement.prototype,r=Object.getOwnPropertyDescriptor(t,"value").set;if(a!==n&&r){const t=new Event("change",{bubbles:!0});r.call(e,n),e.dispatchEvent(t)}},[a,n]),f(xp.select,{...r,style:{...dm,...r.style},ref:s,defaultValue:n})});function fg(e){return""===e||void 0===e}function pg(t){const n=qt(t),r=e.useRef(""),i=e.useRef(0),o=e.useCallback(e=>{const t=r.current+e;n(t),function e(t){r.current=t,window.clearTimeout(i.current),""!==t&&(i.current=window.setTimeout(()=>e(""),1e3))}(t)},[n]),s=e.useCallback(()=>{r.current="",window.clearTimeout(i.current)},[]);return e.useEffect(()=>()=>window.clearTimeout(i.current),[]),[r,o,s]}function mg(e,t,n){const r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1;let o=(s=e,a=Math.max(i,0),s.map((e,t)=>s[(a+t)%s.length]));var s,a;1===r.length&&(o=o.filter(e=>e!==n));const l=o.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return l!==n?l:void 0}dg.displayName="SelectBubbleInput";var gg=Am,vg=Rm,bg=Dm,yg=Lm,wg=Um,xg=Xm,kg=eg,Sg=ng,Eg=ig,Cg=sg,Ng=lg,Og=ug,Ag=Nm,Mg=Tm,Tg=e.forwardRef(function(t,n){var r=t.className,i=t.children,o=D(t,["className","children"]);return e.createElement(gg,Object.assign({ref:n,className:ot("flex h-12 w-full items-center justify-between rounded-full border border-input bg-white/50 px-6 py-2 text-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-[hsl(var(--primary))]/30 focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 transition-all duration-300 [&>span]:line-clamp-1",r)},o),i,e.createElement(vg,{asChild:!0},e.createElement(j,{className:"h-4 w-4 opacity-50"})))});Tg.displayName=gg.displayName;var Rg=e.forwardRef(function(t,n){var r=t.className,i=D(t,["className"]);return e.createElement(Cg,Object.assign({ref:n,className:ot("flex cursor-default items-center justify-center py-1",r)},i),e.createElement(H,{className:"h-4 w-4"}))});Rg.displayName=Cg.displayName;var Dg=e.forwardRef(function(t,n){var r=t.className,i=D(t,["className"]);return e.createElement(Ng,Object.assign({ref:n,className:ot("flex cursor-default items-center justify-center py-1",r)},i),e.createElement(j,{className:"h-4 w-4"}))});Dg.displayName=Ng.displayName;var Pg=e.forwardRef(function(t,n){var r=t.className,i=t.children,o=t.position,s=void 0===o?"popper":o,a=D(t,["className","children","position"]);return e.createElement(bg,null,e.createElement(yg,Object.assign({ref:n,className:ot("relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-2xl border bg-popover text-popover-foreground shadow-[0_10px_40px_-10px_rgba(93,112,82,0.2)] data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]","popper"===s&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",r),position:s},a),e.createElement(Rg,null),e.createElement(wg,{className:ot("p-1","popper"===s&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]")},i),e.createElement(Dg,null)))});Pg.displayName=yg.displayName;var Lg=e.forwardRef(function(t,n){var r=t.className,i=D(t,["className"]);return e.createElement(xg,Object.assign({ref:n,className:ot("py-1.5 pl-8 pr-2 text-sm font-semibold",r)},i))});Lg.displayName=xg.displayName;var Ig=e.forwardRef(function(t,n){var r=t.className,i=t.children,o=D(t,["className","children"]);return e.createElement(kg,Object.assign({ref:n,className:ot("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",r)},o),e.createElement("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center"},e.createElement(Eg,null,e.createElement(F,{className:"h-4 w-4"}))),e.createElement(Sg,null,i))});Ig.displayName=kg.displayName;var _g=e.forwardRef(function(t,n){var r=t.className,i=D(t,["className"]);return e.createElement(Og,Object.assign({ref:n,className:ot("-mx-1 my-1 h-px bg-muted",r)},i))});function Bg(t){const n=e.forwardRef((t,n)=>{const{children:r,...i}=t;if(e.isValidElement(r)){const t=function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;if(n)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(r),o=function(e,t){const n={...t};for(const r in t){const i=e[r],o=t[r];/^on[A-Z]/.test(r)?i&&o?n[r]=(...e)=>{const t=o(...e);return i(...e),t}:i&&(n[r]=i):"style"===r?n[r]={...i,...o}:"className"===r&&(n[r]=[i,o].filter(Boolean).join(" "))}return{...e,...n}}(i,r.props);return r.type!==e.Fragment&&(o.ref=n?lt(n,t):t),e.cloneElement(r,o)}return e.Children.count(r)>1?e.Children.only(null):null});return n.displayName=`${t}.SlotClone`,n}_g.displayName=Og.displayName;var Fg=Symbol("radix.slottable");function jg(t){return e.isValidElement(t)&&"function"==typeof t.type&&"__radixId"in t.type&&t.type.__radixId===Fg}var Wg=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((t,n)=>{const r=function(t){const n=Bg(t),r=e.forwardRef((t,r)=>{const{children:i,...o}=t,s=e.Children.toArray(i),a=s.find(jg);if(a){const t=a.props.children,i=s.map(n=>n===a?e.Children.count(t)>1?e.Children.only(null):e.isValidElement(t)?t.props.children:null:n);return f(n,{...o,ref:r,children:e.isValidElement(t)?e.cloneElement(t,void 0,i):null})}return f(n,{...o,ref:r,children:i})});return r.displayName=`${t}.Slot`,r}(`Primitive.${n}`),i=e.forwardRef((e,t)=>{const{asChild:i,...o}=e,s=i?r:n;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),f(s,{...o,ref:t})});return i.displayName=`Primitive.${n}`,{...t,[n]:i}},{}),zg="Switch",[Hg,Vg]=Rt(zg),[qg,Ug]=Hg(zg),$g=e.forwardRef((t,n)=>{const{__scopeSwitch:r,name:i,checked:o,defaultChecked:s,required:a,disabled:l,value:c="on",onCheckedChange:u,form:h,...d}=t,[m,g]=e.useState(null),v=ct(n,e=>g(e)),b=e.useRef(!1),y=!m||(h||!!m.closest("form")),[w,x]=Ft({prop:o,defaultProp:s??!1,onChange:u,caller:zg});return p(qg,{scope:r,checked:w,disabled:l,children:[f(Wg.button,{type:"button",role:"switch","aria-checked":w,"aria-required":a,"data-state":Xg(w),"data-disabled":l?"":void 0,disabled:l,value:c,...d,ref:v,onClick:Tt(t.onClick,e=>{x(e=>!e),y&&(b.current=e.isPropagationStopped(),b.current||e.stopPropagation())})}),y&&f(Gg,{control:m,bubbles:!b.current,name:i,value:c,checked:w,required:a,disabled:l,form:h,style:{transform:"translateX(-100%)"}})]})});$g.displayName=zg;var Kg="SwitchThumb",Yg=e.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,i=Ug(Kg,n);return f(Wg.span,{"data-state":Xg(i.checked),"data-disabled":i.disabled?"":void 0,...r,ref:t})});Yg.displayName=Kg;var Gg=e.forwardRef(({__scopeSwitch:t,control:n,checked:r,bubbles:i=!0,...o},s)=>{const a=e.useRef(null),l=ct(a,s),c=hm(r),u=us(n);return e.useEffect(()=>{const e=a.current;if(!e)return;const t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,"checked").set;if(c!==r&&n){const t=new Event("click",{bubbles:i});n.call(e,r),e.dispatchEvent(t)}},[c,r,i]),f("input",{type:"checkbox","aria-hidden":!0,defaultChecked:r,...o,tabIndex:-1,ref:l,style:{...o.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});function Xg(e){return e?"checked":"unchecked"}Gg.displayName="SwitchBubbleInput";var Jg=$g,Qg=Yg,Zg=e.forwardRef(function(t,n){var r=t.className,i=D(t,["className"]);return e.createElement(Jg,Object.assign({className:ot("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",r)},i,{ref:n}),e.createElement(Qg,{className:ot("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")}))});Zg.displayName=Jg.displayName;var ev=e.forwardRef(function(t,n){var r=t.className,i=D(t,["className"]);return e.createElement("textarea",Object.assign({className:ot("flex min-h-[120px] w-full rounded-3xl border border-input bg-white/50 px-6 py-4 text-base ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[hsl(var(--primary))]/30 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 transition-all duration-300 md:text-sm",r),ref:n},i))});ev.displayName="Textarea";var tv=Vr,nv=qr,rv=Ur,iv=e.forwardRef(function(t,n){var r=t.className,i=D(t,["className"]);return e.createElement($r,Object.assign({ref:n,className:ot("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",r)},i))});iv.displayName=$r.displayName;var ov=e.forwardRef(function(t,n){var r=t.className,i=t.children,o=D(t,["className","children"]);return e.createElement(rv,null,e.createElement(iv,null),e.createElement(Kr,Object.assign({ref:n,className:ot("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border border-[hsl(var(--border))]/50 bg-background p-6 shadow-[0_20px_60px_-10px_rgba(93,112,82,0.2)] duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] rounded-[2rem]",r)},o),i,e.createElement(Xr,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground"},e.createElement(ue,{className:"h-4 w-4"}),e.createElement("span",{className:"sr-only"},"Close"))))});ov.displayName=Kr.displayName;var sv=function(t){var n=t.className,r=D(t,["className"]);return e.createElement("div",Object.assign({className:ot("flex flex-col space-y-1.5 text-center sm:text-left",n)},r))};sv.displayName="DialogHeader";var av=function(t){var n=t.className,r=D(t,["className"]);return e.createElement("div",Object.assign({className:ot("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",n)},r))};av.displayName="DialogFooter";var lv=e.forwardRef(function(t,n){var r=t.className,i=D(t,["className"]);return e.createElement(Yr,Object.assign({ref:n,className:ot("text-lg font-semibold leading-none tracking-tight",r)},i))});lv.displayName=Yr.displayName;var cv,uv=e.forwardRef(function(t,n){var r=t.className,i=D(t,["className"]);return e.createElement(Gr,Object.assign({ref:n,className:ot("text-sm text-muted-foreground",r)},i))});function hv(e,t=!1){const n=e.length;let r=0,i="",o=0,s=16,a=0,l=0,c=0,u=0,h=0;function d(t,n){let i=0,o=0;for(;i<t||!n;){let t=e.charCodeAt(r);if(t>=48&&t<=57)o=16*o+t-48;else if(t>=65&&t<=70)o=16*o+t-65+10;else{if(!(t>=97&&t<=102))break;o=16*o+t-97+10}r++,i++}return i<t&&(o=-1),o}function f(){if(i="",h=0,o=r,l=a,u=c,r>=n)return o=n,s=17;let t=e.charCodeAt(r);if(dv(t)){do{r++,i+=String.fromCharCode(t),t=e.charCodeAt(r)}while(dv(t));return s=15}if(fv(t))return r++,i+=String.fromCharCode(t),13===t&&10===e.charCodeAt(r)&&(r++,i+="\n"),a++,c=r,s=14;switch(t){case 123:return r++,s=1;case 125:return r++,s=2;case 91:return r++,s=3;case 93:return r++,s=4;case 58:return r++,s=6;case 44:return r++,s=5;case 34:return r++,i=function(){let t="",i=r;for(;;){if(r>=n){t+=e.substring(i,r),h=2;break}const o=e.charCodeAt(r);if(34===o){t+=e.substring(i,r),r++;break}if(92!==o){if(o>=0&&o<=31){if(fv(o)){t+=e.substring(i,r),h=2;break}h=6}r++}else{if(t+=e.substring(i,r),r++,r>=n){h=2;break}switch(e.charCodeAt(r++)){case 34:t+='"';break;case 92:t+="\\";break;case 47:t+="/";break;case 98:t+="\b";break;case 102:t+="\f";break;case 110:t+="\n";break;case 114:t+="\r";break;case 116:t+="\t";break;case 117:const e=d(4,!0);e>=0?t+=String.fromCharCode(e):h=4;break;default:h=5}i=r}}return t}(),s=10;case 47:const l=r-1;if(47===e.charCodeAt(r+1)){for(r+=2;r<n&&!fv(e.charCodeAt(r));)r++;return i=e.substring(l,r),s=12}if(42===e.charCodeAt(r+1)){r+=2;const t=n-1;let o=!1;for(;r<t;){const t=e.charCodeAt(r);if(42===t&&47===e.charCodeAt(r+1)){r+=2,o=!0;break}r++,fv(t)&&(13===t&&10===e.charCodeAt(r)&&r++,a++,c=r)}return o||(r++,h=1),i=e.substring(l,r),s=13}return i+=String.fromCharCode(t),r++,s=16;case 45:if(i+=String.fromCharCode(t),r++,r===n||!pv(e.charCodeAt(r)))return s=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return i+=function(){let t=r;if(48===e.charCodeAt(r))r++;else for(r++;r<e.length&&pv(e.charCodeAt(r));)r++;if(r<e.length&&46===e.charCodeAt(r)){if(r++,!(r<e.length&&pv(e.charCodeAt(r))))return h=3,e.substring(t,r);for(r++;r<e.length&&pv(e.charCodeAt(r));)r++}let n=r;if(r<e.length&&(69===e.charCodeAt(r)||101===e.charCodeAt(r)))if(r++,(r<e.length&&43===e.charCodeAt(r)||45===e.charCodeAt(r))&&r++,r<e.length&&pv(e.charCodeAt(r))){for(r++;r<e.length&&pv(e.charCodeAt(r));)r++;n=r}else h=3;return e.substring(t,n)}(),s=11;default:for(;r<n&&p(t);)r++,t=e.charCodeAt(r);if(o!==r){switch(i=e.substring(o,r),i){case"true":return s=8;case"false":return s=9;case"null":return s=7}return s=16}return i+=String.fromCharCode(t),r++,s=16}}function p(e){if(dv(e)||fv(e))return!1;switch(e){case 125:case 93:case 123:case 91:case 34:case 58:case 44:case 47:return!1}return!0}return{setPosition:function(e){r=e,i="",o=0,s=16,h=0},getPosition:()=>r,scan:t?function(){let e;do{e=f()}while(e>=12&&e<=15);return e}:f,getToken:()=>s,getTokenValue:()=>i,getTokenOffset:()=>o,getTokenLength:()=>r-o,getTokenStartLine:()=>l,getTokenStartCharacter:()=>o-u,getTokenError:()=>h}}function dv(e){return 32===e||9===e}function fv(e){return 10===e||13===e}function pv(e){return e>=48&&e<=57}uv.displayName=Gr.displayName,function(e){e[e.lineFeed=10]="lineFeed",e[e.carriageReturn=13]="carriageReturn",e[e.space=32]="space",e[e._0=48]="_0",e[e._1=49]="_1",e[e._2=50]="_2",e[e._3=51]="_3",e[e._4=52]="_4",e[e._5=53]="_5",e[e._6=54]="_6",e[e._7=55]="_7",e[e._8=56]="_8",e[e._9=57]="_9",e[e.a=97]="a",e[e.b=98]="b",e[e.c=99]="c",e[e.d=100]="d",e[e.e=101]="e",e[e.f=102]="f",e[e.g=103]="g",e[e.h=104]="h",e[e.i=105]="i",e[e.j=106]="j",e[e.k=107]="k",e[e.l=108]="l",e[e.m=109]="m",e[e.n=110]="n",e[e.o=111]="o",e[e.p=112]="p",e[e.q=113]="q",e[e.r=114]="r",e[e.s=115]="s",e[e.t=116]="t",e[e.u=117]="u",e[e.v=118]="v",e[e.w=119]="w",e[e.x=120]="x",e[e.y=121]="y",e[e.z=122]="z",e[e.A=65]="A",e[e.B=66]="B",e[e.C=67]="C",e[e.D=68]="D",e[e.E=69]="E",e[e.F=70]="F",e[e.G=71]="G",e[e.H=72]="H",e[e.I=73]="I",e[e.J=74]="J",e[e.K=75]="K",e[e.L=76]="L",e[e.M=77]="M",e[e.N=78]="N",e[e.O=79]="O",e[e.P=80]="P",e[e.Q=81]="Q",e[e.R=82]="R",e[e.S=83]="S",e[e.T=84]="T",e[e.U=85]="U",e[e.V=86]="V",e[e.W=87]="W",e[e.X=88]="X",e[e.Y=89]="Y",e[e.Z=90]="Z",e[e.asterisk=42]="asterisk",e[e.backslash=92]="backslash",e[e.closeBrace=125]="closeBrace",e[e.closeBracket=93]="closeBracket",e[e.colon=58]="colon",e[e.comma=44]="comma",e[e.dot=46]="dot",e[e.doubleQuote=34]="doubleQuote",e[e.minus=45]="minus",e[e.openBrace=123]="openBrace",e[e.openBracket=91]="openBracket",e[e.plus=43]="plus",e[e.slash=47]="slash",e[e.formFeed=12]="formFeed",e[e.tab=9]="tab"}(cv||(cv={}));const mv=new Array(20).fill(0).map((e,t)=>" ".repeat(t)),gv=200,vv={" ":{"\n":new Array(gv).fill(0).map((e,t)=>"\n"+" ".repeat(t)),"\r":new Array(gv).fill(0).map((e,t)=>"\r"+" ".repeat(t)),"\r\n":new Array(gv).fill(0).map((e,t)=>"\r\n"+" ".repeat(t))},"\t":{"\n":new Array(gv).fill(0).map((e,t)=>"\n"+"\t".repeat(t)),"\r":new Array(gv).fill(0).map((e,t)=>"\r"+"\t".repeat(t)),"\r\n":new Array(gv).fill(0).map((e,t)=>"\r\n"+"\t".repeat(t))}},bv=["\n","\r","\r\n"];function yv(e,t,n){let r,i,o,s,a;if(t){for(s=t.offset,a=s+t.length,o=s;o>0&&!xv(e,o-1);)o--;let l=a;for(;l<e.length&&!xv(e,l);)l++;i=e.substring(o,l),r=function(e,t){let n=0,r=0;const i=t.tabSize||4;for(;n<e.length;){let t=e.charAt(n);if(t===mv[1])r++;else{if("\t"!==t)break;r+=i}n++}return Math.floor(r/i)}(i,n)}else i=e,r=0,o=0,s=0,a=e.length;const l=function(e,t){for(let e=0;e<t.length;e++){const n=t.charAt(e);if("\r"===n)return e+1<t.length&&"\n"===t.charAt(e+1)?"\r\n":"\r";if("\n"===n)return"\n"}return e&&e.eol||"\n"}(n,e),c=bv.includes(l);let u,h=0,d=0;u=n.insertSpaces?mv[n.tabSize||4]??wv(mv[1],n.tabSize||4):"\t";const f="\t"===u?"\t":" ";let p=hv(i,!1),m=!1;function g(){if(h>1)return wv(l,h)+wv(u,r+d);const e=u.length*(r+d);return!c||e>vv[f][l].length?l+wv(u,r+d):e<=0?l:vv[f][l][e]}function v(){let e=p.scan();for(h=0;15===e||14===e;)14===e&&n.keepLines?h+=1:14===e&&(h=1),e=p.scan();return m=16===e||0!==p.getTokenError(),e}const b=[];function y(n,r,i){m||t&&!(r<a&&i>s)||e.substring(r,i)===n||b.push({offset:r,length:i-r,content:n})}let w=v();if(n.keepLines&&h>0&&y(wv(l,h),0,0),17!==w){let e=p.getTokenOffset()+o;y(u.length*r<20&&n.insertSpaces?mv[u.length*r]:wv(u,r),o,e)}for(;17!==w;){let e=p.getTokenOffset()+p.getTokenLength()+o,t=v(),r="",i=!1;for(;0===h&&(12===t||13===t);){let n=p.getTokenOffset()+o;y(mv[1],e,n),e=p.getTokenOffset()+p.getTokenLength()+o,i=12===t,r=i?g():"",t=v()}if(2===t)1!==w&&d--,n.keepLines&&h>0||!n.keepLines&&1!==w?r=g():n.keepLines&&(r=mv[1]);else if(4===t)3!==w&&d--,n.keepLines&&h>0||!n.keepLines&&3!==w?r=g():n.keepLines&&(r=mv[1]);else{switch(w){case 3:case 1:d++,r=n.keepLines&&h>0||!n.keepLines?g():mv[1];break;case 5:r=n.keepLines&&h>0||!n.keepLines?g():mv[1];break;case 12:r=g();break;case 13:h>0?r=g():i||(r=mv[1]);break;case 6:n.keepLines&&h>0?r=g():i||(r=mv[1]);break;case 10:n.keepLines&&h>0?r=g():6!==t||i||(r="");break;case 7:case 8:case 9:case 11:case 2:case 4:n.keepLines&&h>0?r=g():12!==t&&13!==t||i?5!==t&&17!==t&&(m=!0):r=mv[1];break;case 16:m=!0}h>0&&(12===t||13===t)&&(r=g())}17===t&&(r=n.keepLines&&h>0?g():n.insertFinalNewline?l:"");y(r,e,p.getTokenOffset()+o),w=t}return b}function wv(e,t){let n="";for(let r=0;r<t;r++)n+=e;return n}function xv(e,t){return-1!=="\r\n".indexOf(e.charAt(t))}var kv,Sv,Ev;!function(e){e.DEFAULT={allowTrailingComma:!1}}(kv||(kv={})),function(e){e[e.None=0]="None",e[e.UnexpectedEndOfComment=1]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=2]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=3]="UnexpectedEndOfNumber",e[e.InvalidUnicode=4]="InvalidUnicode",e[e.InvalidEscapeCharacter=5]="InvalidEscapeCharacter",e[e.InvalidCharacter=6]="InvalidCharacter"}(Sv||(Sv={})),function(e){e[e.OpenBraceToken=1]="OpenBraceToken",e[e.CloseBraceToken=2]="CloseBraceToken",e[e.OpenBracketToken=3]="OpenBracketToken",e[e.CloseBracketToken=4]="CloseBracketToken",e[e.CommaToken=5]="CommaToken",e[e.ColonToken=6]="ColonToken",e[e.NullKeyword=7]="NullKeyword",e[e.TrueKeyword=8]="TrueKeyword",e[e.FalseKeyword=9]="FalseKeyword",e[e.StringLiteral=10]="StringLiteral",e[e.NumericLiteral=11]="NumericLiteral",e[e.LineCommentTrivia=12]="LineCommentTrivia",e[e.BlockCommentTrivia=13]="BlockCommentTrivia",e[e.LineBreakTrivia=14]="LineBreakTrivia",e[e.Trivia=15]="Trivia",e[e.Unknown=16]="Unknown",e[e.EOF=17]="EOF"}(Ev||(Ev={}));const Cv=function(e,t=[],n=kv.DEFAULT){let r=null,i=[];const o=[];function s(e){Array.isArray(i)?i.push(e):null!==r&&(i[r]=e)}const a={onObjectBegin:()=>{const e={};s(e),o.push(i),i=e,r=null},onObjectProperty:e=>{r=e},onObjectEnd:()=>{i=o.pop()},onArrayBegin:()=>{const e=[];s(e),o.push(i),i=e,r=null},onArrayEnd:()=>{i=o.pop()},onLiteralValue:s,onError:(e,n,r)=>{t.push({error:e,offset:n,length:r})}};return function(e,t,n=kv.DEFAULT){const r=hv(e,!1),i=[];let o=0;function s(e){return e?()=>0===o&&e(r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter()):()=>!0}function a(e){return e?t=>0===o&&e(t,r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter()):()=>!0}function l(e){return e?t=>0===o&&e(t,r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter(),()=>i.slice()):()=>!0}function c(e){return e?()=>{if(o>0)o++;else{!1===e(r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter(),()=>i.slice())&&(o=1)}}:()=>!0}function u(e){return e?()=>{o>0&&o--,0===o&&e(r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter())}:()=>!0}const h=c(t.onObjectBegin),d=l(t.onObjectProperty),f=u(t.onObjectEnd),p=c(t.onArrayBegin),m=u(t.onArrayEnd),g=l(t.onLiteralValue),v=a(t.onSeparator),b=s(t.onComment),y=a(t.onError),w=n&&n.disallowComments,x=n&&n.allowTrailingComma;function k(){for(;;){const e=r.scan();switch(r.getTokenError()){case 4:S(14);break;case 5:S(15);break;case 3:S(13);break;case 1:w||S(11);break;case 2:S(12);break;case 6:S(16)}switch(e){case 12:case 13:w?S(10):b();break;case 16:S(1);break;case 15:case 14:break;default:return e}}}function S(e,t=[],n=[]){if(y(e),t.length+n.length>0){let e=r.getToken();for(;17!==e;){if(-1!==t.indexOf(e)){k();break}if(-1!==n.indexOf(e))break;e=k()}}}function E(e){const t=r.getTokenValue();return e?g(t):(d(t),i.push(t)),k(),!0}function C(){switch(r.getToken()){case 11:const e=r.getTokenValue();let t=Number(e);isNaN(t)&&(S(2),t=0),g(t);break;case 7:g(null);break;case 8:g(!0);break;case 9:g(!1);break;default:return!1}return k(),!0}function N(){return 10!==r.getToken()?(S(3,[],[2,5]),!1):(E(!1),6===r.getToken()?(v(":"),k(),M()||S(4,[],[2,5])):S(5,[],[2,5]),i.pop(),!0)}function O(){h(),k();let e=!1;for(;2!==r.getToken()&&17!==r.getToken();){if(5===r.getToken()){if(e||S(4,[],[]),v(","),k(),2===r.getToken()&&x)break}else e&&S(6,[],[]);N()||S(4,[],[2,5]),e=!0}return f(),2!==r.getToken()?S(7,[2],[]):k(),!0}function A(){p(),k();let e=!0,t=!1;for(;4!==r.getToken()&&17!==r.getToken();){if(5===r.getToken()){if(t||S(4,[],[]),v(","),k(),4===r.getToken()&&x)break}else t&&S(6,[],[]);e?(i.push(0),e=!1):i[i.length-1]++,M()||S(4,[],[4,5]),t=!0}return m(),e||i.pop(),4!==r.getToken()?S(8,[4],[]):k(),!0}function M(){switch(r.getToken()){case 3:return A();case 1:return O();case 10:return E(!0);default:return C()}}if(k(),17===r.getToken())return!!n.allowEmptyContent||(S(4,[],[]),!1);if(!M())return S(4,[],[]),!1;17!==r.getToken()&&S(9,[],[])}(e,a,n),i[0]};var Nv;function Ov(e,t){if(!t.length)return"JSON 格式不正确";var n=t[0],r=function(e,t){for(var n=1,r=1,i=Math.max(0,Math.min(t,e.length)),o=0;o<i;o++){"\n"===e.charAt(o)?(n++,r=1):r++}return{line:n,col:r}}(e,n.offset),i=r.line,o=r.col,s=function(e){switch(e){case 1:return"InvalidSymbol";case 2:return"InvalidNumberFormat";case 3:return"PropertyNameExpected";case 4:return"ValueExpected";case 5:return"ColonExpected";case 6:return"CommaExpected";case 7:return"CloseBraceExpected";case 8:return"CloseBracketExpected";case 9:return"EndOfFileExpected";case 10:return"InvalidCommentToken";case 11:return"UnexpectedEndOfComment";case 12:return"UnexpectedEndOfString";case 13:return"UnexpectedEndOfNumber";case 14:return"InvalidUnicode";case 15:return"InvalidEscapeCharacter";case 16:return"InvalidCharacter"}return"<unknown ParseErrorCode>"}(n.error);return"JSON 格式不正确(".concat(s,",行 ").concat(i," 列 ").concat(o,")")}function Av(e){if(null==e||""===e)return{ok:!0,value:null,pretty:"null",compact:"null"};try{if("string"!=typeof e)return{ok:!0,value:e,pretty:JSON.stringify(e,null,2),compact:JSON.stringify(e)};var t=e,n=[],r=Cv(t,n,{allowTrailingComma:!0,disallowComments:!1});return n.length?{ok:!1,message:Ov(t,n),pretty:t,compact:t}:{ok:!0,value:r,pretty:JSON.stringify(r,null,2),compact:JSON.stringify(r)}}catch(t){var i="string"==typeof e?e:String(e);return{ok:!1,message:"JSON 格式不正确",pretty:i,compact:i}}}function Mv(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,n=(e||"").toString(),r=[];if(Cv(n,r,{allowTrailingComma:!0,disallowComments:!1}),r.length)return{ok:!1,message:Ov(n,r)};for(var i=function(e,t,n){return yv(e,t,n)}(n,void 0,{insertSpaces:!0,tabSize:t}),o=n,s=i.length-1;s>=0;s--){var a=i[s];o=o.slice(0,a.offset)+a.content+o.slice(a.offset+a.length)}return{ok:!0,formatted:o}}function Tv(){return Tv=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Tv.apply(null,arguments)}!function(e){e[e.InvalidSymbol=1]="InvalidSymbol",e[e.InvalidNumberFormat=2]="InvalidNumberFormat",e[e.PropertyNameExpected=3]="PropertyNameExpected",e[e.ValueExpected=4]="ValueExpected",e[e.ColonExpected=5]="ColonExpected",e[e.CommaExpected=6]="CommaExpected",e[e.CloseBraceExpected=7]="CloseBraceExpected",e[e.CloseBracketExpected=8]="CloseBracketExpected",e[e.EndOfFileExpected=9]="EndOfFileExpected",e[e.InvalidCommentToken=10]="InvalidCommentToken",e[e.UnexpectedEndOfComment=11]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=12]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=13]="UnexpectedEndOfNumber",e[e.InvalidUnicode=14]="InvalidUnicode",e[e.InvalidEscapeCharacter=15]="InvalidEscapeCharacter",e[e.InvalidCharacter=16]="InvalidCharacter"}(Nv||(Nv={}));let Rv=[],Dv=[];function Pv(e){if(e<768)return!1;for(let t=0,n=Rv.length;;){let r=t+n>>1;if(e<Rv[r])n=r;else{if(!(e>=Dv[r]))return!0;t=r+1}if(t==n)return!1}}function Lv(e){return e>=127462&&e<=127487}(()=>{let e="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let t=0,n=0;t<e.length;t++)(t%2?Dv:Rv).push(n+=e[t])})();function Iv(e,t,n=!0,r=!0){return(n?_v:Bv)(e,t,r)}function _v(e,t,n){if(t==e.length)return t;t&&jv(e.charCodeAt(t))&&Wv(e.charCodeAt(t-1))&&t--;let r=Fv(e,t);for(t+=zv(r);t<e.length;){let i=Fv(e,t);if(8205==r||8205==i||n&&Pv(i))t+=zv(i),r=i;else{if(!Lv(i))break;{let n=0,r=t-2;for(;r>=0&&Lv(Fv(e,r));)n++,r-=2;if(n%2==0)break;t+=2}}}return t}function Bv(e,t,n){for(;t>0;){let r=_v(e,t-2,n);if(r<t)return r;t--}return 0}function Fv(e,t){let n=e.charCodeAt(t);if(!Wv(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return jv(r)?r-56320+(n-55296<<10)+65536:n}function jv(e){return e>=56320&&e<57344}function Wv(e){return e>=55296&&e<56320}function zv(e){return e<65536?1:2}class Hv{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=Jv(this,e,t);let r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(t,this.length,r,1),qv.from(r,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=Jv(this,e,t);let n=[];return this.decompose(e,t,n,0),qv.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),r=new Kv(this),i=new Kv(e);for(let e=t,o=t;;){if(r.next(e),i.next(e),e=0,r.lineBreak!=i.lineBreak||r.done!=i.done||r.value!=i.value)return!1;if(o+=r.value.length,r.done||o>=n)return!0}}iter(e=1){return new Kv(this,e)}iterRange(e,t=this.length){return new Yv(this,e,t)}iterLines(e,t){let n;if(null==e)n=this.iter();else{null==t&&(t=this.lines+1);let r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new Gv(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(0==e.length)throw new RangeError("A document must have at least one line");return 1!=e.length||e[0]?e.length<=32?new Vv(e):qv.from(Vv.split(e,[])):Hv.empty}}class Vv extends Hv{constructor(e,t=function(e){let t=-1;for(let n of e)t+=n.length+1;return t}(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,r){for(let i=0;;i++){let o=this.text[i],s=r+o.length;if((t?n:s)>=e)return new Xv(r,s,n,o);r=s+1,n++}}decompose(e,t,n,r){let i=e<=0&&t>=this.length?this:new Vv($v(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(1&r){let e=n.pop(),t=Uv(i.text,e.text.slice(),0,i.length);if(t.length<=32)n.push(new Vv(t,e.length+i.length));else{let e=t.length>>1;n.push(new Vv(t.slice(0,e)),new Vv(t.slice(e)))}}else n.push(i)}replace(e,t,n){if(!(n instanceof Vv))return super.replace(e,t,n);[e,t]=Jv(this,e,t);let r=Uv(this.text,Uv(n.text,$v(this.text,0,e)),t),i=this.length+n.length-(t-e);return r.length<=32?new Vv(r,i):qv.from(Vv.split(r,[]),i)}sliceString(e,t=this.length,n="\n"){[e,t]=Jv(this,e,t);let r="";for(let i=0,o=0;i<=t&&o<this.text.length;o++){let s=this.text[o],a=i+s.length;i>e&&o&&(r+=n),e<a&&t>i&&(r+=s.slice(Math.max(0,e-i),t-i)),i=a+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let n=[],r=-1;for(let i of e)n.push(i),r+=i.length+1,32==n.length&&(t.push(new Vv(n,r)),n=[],r=-1);return r>-1&&t.push(new Vv(n,r)),t}}class qv extends Hv{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let t of e)this.lines+=t.lines}lineInner(e,t,n,r){for(let i=0;;i++){let o=this.children[i],s=r+o.length,a=n+o.lines-1;if((t?a:s)>=e)return o.lineInner(e,t,n,r);r=s+1,n=a+1}}decompose(e,t,n,r){for(let i=0,o=0;o<=t&&i<this.children.length;i++){let s=this.children[i],a=o+s.length;if(e<=a&&t>=o){let i=r&((o<=e?1:0)|(a>=t?2:0));o>=e&&a<=t&&!i?n.push(s):s.decompose(e-o,t-o,n,i)}o=a+1}}replace(e,t,n){if([e,t]=Jv(this,e,t),n.lines<this.lines)for(let r=0,i=0;r<this.children.length;r++){let o=this.children[r],s=i+o.length;if(e>=i&&t<=s){let a=o.replace(e-i,t-i,n),l=this.lines-o.lines+a.lines;if(a.lines<l>>4&&a.lines>l>>6){let i=this.children.slice();return i[r]=a,new qv(i,this.length-(t-e)+n.length)}return super.replace(i,s,a)}i=s+1}return super.replace(e,t,n)}sliceString(e,t=this.length,n="\n"){[e,t]=Jv(this,e,t);let r="";for(let i=0,o=0;i<this.children.length&&o<=t;i++){let s=this.children[i],a=o+s.length;o>e&&i&&(r+=n),e<a&&t>o&&(r+=s.sliceString(e-o,t-o,n)),o=a+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof qv))return 0;let n=0,[r,i,o,s]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;r+=t,i+=t){if(r==o||i==s)return n;let a=this.children[r],l=e.children[i];if(a!=l)return n+a.scanIdentical(l,t);n+=a.length+1}}static from(e,t=e.reduce((e,t)=>e+t.length+1,-1)){let n=0;for(let t of e)n+=t.lines;if(n<32){let n=[];for(let t of e)t.flatten(n);return new Vv(n,t)}let r=Math.max(32,n>>5),i=r<<1,o=r>>1,s=[],a=0,l=-1,c=[];function u(e){let t;if(e.lines>i&&e instanceof qv)for(let t of e.children)u(t);else e.lines>o&&(a>o||!a)?(h(),s.push(e)):e instanceof Vv&&a&&(t=c[c.length-1])instanceof Vv&&e.lines+t.lines<=32?(a+=e.lines,l+=e.length+1,c[c.length-1]=new Vv(t.text.concat(e.text),t.length+1+e.length)):(a+e.lines>r&&h(),a+=e.lines,l+=e.length+1,c.push(e))}function h(){0!=a&&(s.push(1==c.length?c[0]:qv.from(c,l)),l=-1,a=c.length=0)}for(let t of e)u(t);return h(),1==s.length?s[0]:new qv(s,t)}}function Uv(e,t,n=0,r=1e9){for(let i=0,o=0,s=!0;o<e.length&&i<=r;o++){let a=e[o],l=i+a.length;l>=n&&(l>r&&(a=a.slice(0,r-i)),i<n&&(a=a.slice(n-i)),s?(t[t.length-1]+=a,s=!1):t.push(a)),i=l+1}return t}function $v(e,t,n){return Uv(e,[""],t,n)}Hv.empty=new Vv([""],0);class Kv{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof Vv?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,r=this.nodes[n],i=this.offsets[n],o=i>>1,s=r instanceof Vv?r.text.length:r.children.length;if(o==(t>0?s:0)){if(0==n)return this.done=!0,this.value="",this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&i)==(t>0?0:1)){if(this.offsets[n]+=t,0==e)return this.lineBreak=!0,this.value="\n",this;e--}else if(r instanceof Vv){let i=r.text[o+(t<0?-1:0)];if(this.offsets[n]+=t,i.length>Math.max(0,e))return this.value=0==e?i:t>0?i.slice(e):i.slice(0,i.length-e),this;e-=i.length}else{let i=r.children[o+(t<0?-1:0)];e>i.length?(e-=i.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(i),this.offsets.push(t>0?1:(i instanceof Vv?i.text.length:i.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Yv{constructor(e,t,n){this.value="",this.done=!1,this.cursor=new Kv(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=n?r:t<0?r.slice(r.length-n):r.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&""!=this.value}}class Gv{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:n,value:r}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):n?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}}"undefined"!=typeof Symbol&&(Hv.prototype[Symbol.iterator]=function(){return this.iter()},Kv.prototype[Symbol.iterator]=Yv.prototype[Symbol.iterator]=Gv.prototype[Symbol.iterator]=function(){return this});class Xv{constructor(e,t,n,r){this.from=e,this.to=t,this.number=n,this.text=r}get length(){return this.to-this.from}}function Jv(e,t,n){return[t=Math.max(0,Math.min(e.length,t)),Math.max(t,Math.min(e.length,n))]}function Qv(e,t,n=!0,r=!0){return Iv(e,t,n,r)}function Zv(e,t){let n=e.charCodeAt(t);if(!(r=n,r>=55296&&r<56320&&t+1!=e.length))return n;var r;let i=e.charCodeAt(t+1);return function(e){return e>=56320&&e<57344}(i)?i-56320+(n-55296<<10)+65536:n}function eb(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode(55296+(e>>10),56320+(1023&e)))}function tb(e){return e<65536?1:2}const nb=/\r\n?|\n/;var rb=function(e){return e[e.Simple=0]="Simple",e[e.TrackDel=1]="TrackDel",e[e.TrackBefore=2]="TrackBefore",e[e.TrackAfter=3]="TrackAfter",e}(rb||(rb={}));class ib{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t+1];e+=n<0?this.sections[t]:n}return e}get empty(){return 0==this.sections.length||2==this.sections.length&&this.sections[1]<0}iterGaps(e){for(let t=0,n=0,r=0;t<this.sections.length;){let i=this.sections[t++],o=this.sections[t++];o<0?(e(n,r,i),r+=i):r+=o,n+=i}}iterChangedRanges(e,t=!1){lb(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let n=this.sections[t++],r=this.sections[t++];r<0?e.push(n,r):e.push(r,n)}return new ib(e)}composeDesc(e){return this.empty?e:e.empty?this:ub(this,e)}mapDesc(e,t=!1){return e.empty?this:cb(this,e,t)}mapPos(e,t=-1,n=rb.Simple){let r=0,i=0;for(let o=0;o<this.sections.length;){let s=this.sections[o++],a=this.sections[o++],l=r+s;if(a<0){if(l>e)return i+(e-r);i+=s}else{if(n!=rb.Simple&&l>=e&&(n==rb.TrackDel&&r<e&&l>e||n==rb.TrackBefore&&r<e||n==rb.TrackAfter&&l>e))return null;if(l>e||l==e&&t<0&&!s)return e==r||t<0?i:i+a;i+=a}r=l}if(e>r)throw new RangeError(`Position ${e} is out of range for changeset of length ${r}`);return i}touchesRange(e,t=e){for(let n=0,r=0;n<this.sections.length&&r<=t;){let i=r+this.sections[n++];if(this.sections[n++]>=0&&r<=t&&i>=e)return!(r<e&&i>t)||"cover";r=i}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let n=this.sections[t++],r=this.sections[t++];e+=(e?" ":"")+n+(r>=0?":"+r:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(e=>"number"!=typeof e))throw new RangeError("Invalid JSON representation of ChangeDesc");return new ib(e)}static create(e){return new ib(e)}}class ob extends ib{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return lb(this,(t,n,r,i,o)=>e=e.replace(r,r+(n-t),o),!1),e}mapDesc(e,t=!1){return cb(this,e,t,!0)}invert(e){let t=this.sections.slice(),n=[];for(let r=0,i=0;r<t.length;r+=2){let o=t[r],s=t[r+1];if(s>=0){t[r]=s,t[r+1]=o;let a=r>>1;for(;n.length<a;)n.push(Hv.empty);n.push(o?e.slice(i,i+o):Hv.empty)}i+=o}return new ob(t,n)}compose(e){return this.empty?e:e.empty?this:ub(this,e,!0)}map(e,t=!1){return e.empty?this:cb(this,e,t,!0)}iterChanges(e,t=!1){lb(this,e,t)}get desc(){return ib.create(this.sections)}filter(e){let t=[],n=[],r=[],i=new hb(this);e:for(let o=0,s=0;;){let a=o==e.length?1e9:e[o++];for(;s<a||s==a&&0==i.len;){if(i.done)break e;let e=Math.min(i.len,a-s);sb(r,e,-1);let o=-1==i.ins?-1:0==i.off?i.ins:0;sb(t,e,o),o>0&&ab(n,t,i.text),i.forward(e),s+=e}let l=e[o++];for(;s<l;){if(i.done)break e;let e=Math.min(i.len,l-s);sb(t,e,-1),sb(r,e,-1==i.ins?-1:0==i.off?i.ins:0),i.forward(e),s+=e}}return{changes:new ob(t,n),filtered:ib.create(r)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t],r=this.sections[t+1];r<0?e.push(n):0==r?e.push([n]):e.push([n].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,n){let r=[],i=[],o=0,s=null;function a(e=!1){if(!e&&!r.length)return;o<t&&sb(r,t-o,-1);let n=new ob(r,i);s=s?s.compose(n.map(s)):n,r=[],i=[],o=0}return function e(l){if(Array.isArray(l))for(let t of l)e(t);else if(l instanceof ob){if(l.length!=t)throw new RangeError(`Mismatched change set length (got ${l.length}, expected ${t})`);a(),s=s?s.compose(l.map(s)):l}else{let{from:e,to:s=e,insert:c}=l;if(e>s||e<0||s>t)throw new RangeError(`Invalid change range ${e} to ${s} (in doc of length ${t})`);let u=c?"string"==typeof c?Hv.of(c.split(n||nb)):c:Hv.empty,h=u.length;if(e==s&&0==h)return;e<o&&a(),e>o&&sb(r,e-o,-1),sb(r,s-e,h),ab(i,r,u),o=s}}(e),a(!s),s}static empty(e){return new ob(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],n=[];for(let r=0;r<e.length;r++){let i=e[r];if("number"==typeof i)t.push(i,-1);else{if(!Array.isArray(i)||"number"!=typeof i[0]||i.some((e,t)=>t&&"string"!=typeof e))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==i.length)t.push(i[0],0);else{for(;n.length<r;)n.push(Hv.empty);n[r]=Hv.of(i.slice(1)),t.push(i[0],n[r].length)}}}return new ob(t,n)}static createSet(e,t){return new ob(e,t)}}function sb(e,t,n,r=!1){if(0==t&&n<=0)return;let i=e.length-2;i>=0&&n<=0&&n==e[i+1]?e[i]+=t:i>=0&&0==t&&0==e[i]?e[i+1]+=n:r?(e[i]+=t,e[i+1]+=n):e.push(t,n)}function ab(e,t,n){if(0==n.length)return;let r=t.length-2>>1;if(r<e.length)e[e.length-1]=e[e.length-1].append(n);else{for(;e.length<r;)e.push(Hv.empty);e.push(n)}}function lb(e,t,n){let r=e.inserted;for(let i=0,o=0,s=0;s<e.sections.length;){let a=e.sections[s++],l=e.sections[s++];if(l<0)i+=a,o+=a;else{let c=i,u=o,h=Hv.empty;for(;c+=a,u+=l,l&&r&&(h=h.append(r[s-2>>1])),!(n||s==e.sections.length||e.sections[s+1]<0);)a=e.sections[s++],l=e.sections[s++];t(i,c,o,u,h),i=c,o=u}}}function cb(e,t,n,r=!1){let i=[],o=r?[]:null,s=new hb(e),a=new hb(t);for(let e=-1;;){if(s.done&&a.len||a.done&&s.len)throw new Error("Mismatched change set lengths");if(-1==s.ins&&-1==a.ins){let e=Math.min(s.len,a.len);sb(i,e,-1),s.forward(e),a.forward(e)}else if(a.ins>=0&&(s.ins<0||e==s.i||0==s.off&&(a.len<s.len||a.len==s.len&&!n))){let t=a.len;for(sb(i,a.ins,-1);t;){let n=Math.min(s.len,t);s.ins>=0&&e<s.i&&s.len<=n&&(sb(i,0,s.ins),o&&ab(o,i,s.text),e=s.i),s.forward(n),t-=n}a.next()}else{if(!(s.ins>=0)){if(s.done&&a.done)return o?ob.createSet(i,o):ib.create(i);throw new Error("Mismatched change set lengths")}{let t=0,n=s.len;for(;n;)if(-1==a.ins){let e=Math.min(n,a.len);t+=e,n-=e,a.forward(e)}else{if(!(0==a.ins&&a.len<n))break;n-=a.len,a.next()}sb(i,t,e<s.i?s.ins:0),o&&e<s.i&&ab(o,i,s.text),e=s.i,s.forward(s.len-n)}}}}function ub(e,t,n=!1){let r=[],i=n?[]:null,o=new hb(e),s=new hb(t);for(let e=!1;;){if(o.done&&s.done)return i?ob.createSet(r,i):ib.create(r);if(0==o.ins)sb(r,o.len,0,e),o.next();else if(0!=s.len||s.done){if(o.done||s.done)throw new Error("Mismatched change set lengths");{let t=Math.min(o.len2,s.len),n=r.length;if(-1==o.ins){let n=-1==s.ins?-1:s.off?0:s.ins;sb(r,t,n,e),i&&n&&ab(i,r,s.text)}else-1==s.ins?(sb(r,o.off?0:o.len,t,e),i&&ab(i,r,o.textBit(t))):(sb(r,o.off?0:o.len,s.off?0:s.ins,e),i&&!s.off&&ab(i,r,s.text));e=(o.ins>t||s.ins>=0&&s.len>t)&&(e||r.length>n),o.forward2(t),s.forward(t)}}else sb(r,0,s.ins,e),i&&ab(i,r,s.text),s.next()}}class hb{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return-2==this.ins}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?Hv.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?Hv.empty:t[n].slice(this.off,null==e?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){-1==this.ins?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class db{constructor(e,t,n){this.from=e,this.to=t,this.flags=n}get anchor(){return 32&this.flags?this.to:this.from}get head(){return 32&this.flags?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return 8&this.flags?-1:16&this.flags?1:0}get bidiLevel(){let e=7&this.flags;return 7==e?null:e}get goalColumn(){let e=this.flags>>6;return 16777215==e?void 0:e}map(e,t=-1){let n,r;return this.empty?n=r=e.mapPos(this.from,t):(n=e.mapPos(this.from,1),r=e.mapPos(this.to,-1)),n==this.from&&r==this.to?this:new db(n,r,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return fb.range(e,t);let n=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return fb.range(this.anchor,n)}eq(e,t=!1){return!(this.anchor!=e.anchor||this.head!=e.head||this.goalColumn!=e.goalColumn||t&&this.empty&&this.assoc!=e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||"number"!=typeof e.anchor||"number"!=typeof e.head)throw new RangeError("Invalid JSON representation for SelectionRange");return fb.range(e.anchor,e.head)}static create(e,t,n){return new db(e,t,n)}}class fb{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:fb.create(this.ranges.map(n=>n.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return 1==this.ranges.length?this:new fb([this.main],0)}addRange(e,t=!0){return fb.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let n=this.ranges.slice();return n[t]=e,fb.create(n,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||"number"!=typeof e.main||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new fb(e.ranges.map(e=>db.fromJSON(e)),e.main)}static single(e,t=e){return new fb([fb.range(e,t)],0)}static create(e,t=0){if(0==e.length)throw new RangeError("A selection needs at least one range");for(let n=0,r=0;r<e.length;r++){let i=e[r];if(i.empty?i.from<=n:i.from<n)return fb.normalized(e.slice(),t);n=i.to}return new fb(e,t)}static cursor(e,t=0,n,r){return db.create(e,e,(0==t?0:t<0?8:16)|(null==n?7:Math.min(6,n))|(null!=r?r:16777215)<<6)}static range(e,t,n,r){let i=(null!=n?n:16777215)<<6|(null==r?7:Math.min(6,r));return t<e?db.create(t,e,48|i):db.create(e,t,(t>e?8:0)|i)}static normalized(e,t=0){let n=e[t];e.sort((e,t)=>e.from-t.from),t=e.indexOf(n);for(let n=1;n<e.length;n++){let r=e[n],i=e[n-1];if(r.empty?r.from<=i.to:r.from<i.to){let o=i.from,s=Math.max(r.to,i.to);n<=t&&t--,e.splice(--n,2,r.anchor>r.head?fb.range(s,o):fb.range(o,s))}}return new fb(e,t)}}function pb(e,t){for(let n of e.ranges)if(n.to>t)throw new RangeError("Selection points outside of document")}let mb=0;class gb{constructor(e,t,n,r,i){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=r,this.id=mb++,this.default=e([]),this.extensions="function"==typeof i?i(this):i}get reader(){return this}static define(e={}){return new gb(e.combine||(e=>e),e.compareInput||((e,t)=>e===t),e.compare||(e.combine?(e,t)=>e===t:vb),!!e.static,e.enables)}of(e){return new bb([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new bb(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new bb(e,this,2,t)}from(e,t){return t||(t=e=>e),this.compute([e],n=>t(n.field(e)))}}function vb(e,t){return e==t||e.length==t.length&&e.every((e,n)=>e===t[n])}class bb{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=mb++}dynamicSlot(e){var t;let n=this.value,r=this.facet.compareInput,i=this.id,o=e[i]>>1,s=2==this.type,a=!1,l=!1,c=[];for(let n of this.dependencies)"doc"==n?a=!0:"selection"==n?l=!0:1&(null!==(t=e[n.id])&&void 0!==t?t:1)||c.push(e[n.id]);return{create:e=>(e.values[o]=n(e),1),update(e,t){if(a&&t.docChanged||l&&(t.docChanged||t.selection)||wb(e,c)){let t=n(e);if(s?!yb(t,e.values[o],r):!r(t,e.values[o]))return e.values[o]=t,1}return 0},reconfigure:(e,t)=>{let a,l=t.config.address[i];if(null!=l){let i=Ib(t,l);if(this.dependencies.every(n=>n instanceof gb?t.facet(n)===e.facet(n):!(n instanceof Sb)||t.field(n,!1)==e.field(n,!1))||(s?yb(a=n(e),i,r):r(a=n(e),i)))return e.values[o]=i,0}else a=n(e);return e.values[o]=a,1}}}}function yb(e,t,n){if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!n(e[r],t[r]))return!1;return!0}function wb(e,t){let n=!1;for(let r of t)1&Lb(e,r)&&(n=!0);return n}function xb(e,t,n){let r=n.map(t=>e[t.id]),i=n.map(e=>e.type),o=r.filter(e=>!(1&e)),s=e[t.id]>>1;function a(e){let n=[];for(let t=0;t<r.length;t++){let o=Ib(e,r[t]);if(2==i[t])for(let e of o)n.push(e);else n.push(o)}return t.combine(n)}return{create(e){for(let t of r)Lb(e,t);return e.values[s]=a(e),1},update(e,n){if(!wb(e,o))return 0;let r=a(e);return t.compare(r,e.values[s])?0:(e.values[s]=r,1)},reconfigure(e,i){let o=wb(e,r),l=i.config.facets[t.id],c=i.facet(t);if(l&&!o&&vb(n,l))return e.values[s]=c,0;let u=a(e);return t.compare(u,c)?(e.values[s]=c,0):(e.values[s]=u,1)}}}const kb=gb.define({static:!0});class Sb{constructor(e,t,n,r,i){this.id=e,this.createF=t,this.updateF=n,this.compareF=r,this.spec=i,this.provides=void 0}static define(e){let t=new Sb(mb++,e.create,e.update,e.compare||((e,t)=>e===t),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(kb).find(e=>e.field==this);return((null==t?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:e=>(e.values[t]=this.create(e),1),update:(e,n)=>{let r=e.values[t],i=this.updateF(r,n);return this.compareF(r,i)?0:(e.values[t]=i,1)},reconfigure:(e,n)=>{let r,i=e.facet(kb),o=n.facet(kb);return(r=i.find(e=>e.field==this))&&r!=o.find(e=>e.field==this)?(e.values[t]=r.create(e),1):null!=n.config.address[this.id]?(e.values[t]=n.field(this),0):(e.values[t]=this.create(e),1)}}}init(e){return[this,kb.of({field:this,create:e})]}get extension(){return this}}const Eb=4,Cb=3,Nb=2,Ob=1;function Ab(e){return t=>new Tb(t,e)}const Mb={highest:Ab(0),high:Ab(Ob),default:Ab(Nb),low:Ab(Cb),lowest:Ab(Eb)};class Tb{constructor(e,t){this.inner=e,this.prec=t}}class Rb{of(e){return new Db(this,e)}reconfigure(e){return Rb.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Db{constructor(e,t){this.compartment=e,this.inner=t}}class Pb{constructor(e,t,n,r,i,o){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=r,this.staticValues=i,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return null==t?e.default:this.staticValues[t>>1]}static resolve(e,t,n){let r=[],i=Object.create(null),o=new Map;for(let n of function(e,t,n){let r=[[],[],[],[],[]],i=new Map;function o(e,s){let a=i.get(e);if(null!=a){if(a<=s)return;let t=r[a].indexOf(e);t>-1&&r[a].splice(t,1),e instanceof Db&&n.delete(e.compartment)}if(i.set(e,s),Array.isArray(e))for(let t of e)o(t,s);else if(e instanceof Db){if(n.has(e.compartment))throw new RangeError("Duplicate use of compartment in extensions");let r=t.get(e.compartment)||e.inner;n.set(e.compartment,r),o(r,s)}else if(e instanceof Tb)o(e.inner,e.prec);else if(e instanceof Sb)r[s].push(e),e.provides&&o(e.provides,s);else if(e instanceof bb)r[s].push(e),e.facet.extensions&&o(e.facet.extensions,Nb);else{let t=e.extension;if(!t)throw new Error(`Unrecognized extension value in extension set (${e}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);o(t,s)}}return o(e,Nb),r.reduce((e,t)=>e.concat(t))}(e,t,o))n instanceof Sb?r.push(n):(i[n.facet.id]||(i[n.facet.id]=[])).push(n);let s=Object.create(null),a=[],l=[];for(let e of r)s[e.id]=l.length<<1,l.push(t=>e.slot(t));let c=null==n?void 0:n.config.facets;for(let e in i){let t=i[e],r=t[0].facet,o=c&&c[e]||[];if(t.every(e=>0==e.type))if(s[r.id]=a.length<<1|1,vb(o,t))a.push(n.facet(r));else{let e=r.combine(t.map(e=>e.value));a.push(n&&r.compare(e,n.facet(r))?n.facet(r):e)}else{for(let e of t)0==e.type?(s[e.id]=a.length<<1|1,a.push(e.value)):(s[e.id]=l.length<<1,l.push(t=>e.dynamicSlot(t)));s[r.id]=l.length<<1,l.push(e=>xb(e,r,t))}}let u=l.map(e=>e(s));return new Pb(e,o,u,s,a,i)}}function Lb(e,t){if(1&t)return 2;let n=t>>1,r=e.status[n];if(4==r)throw new Error("Cyclic dependency between fields and/or facets");if(2&r)return r;e.status[n]=4;let i=e.computeSlot(e,e.config.dynamicSlots[n]);return e.status[n]=2|i}function Ib(e,t){return 1&t?e.config.staticValues[t>>1]:e.values[t>>1]}const _b=gb.define(),Bb=gb.define({combine:e=>e.some(e=>e),static:!0}),Fb=gb.define({combine:e=>e.length?e[0]:void 0,static:!0}),jb=gb.define(),Wb=gb.define(),zb=gb.define(),Hb=gb.define({combine:e=>!!e.length&&e[0]});class Vb{constructor(e,t){this.type=e,this.value=t}static define(){return new qb}}class qb{of(e){return new Vb(this,e)}}class Ub{constructor(e){this.map=e}of(e){return new $b(this,e)}}class $b{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return void 0===t?void 0:t==this.value?this:new $b(this.type,t)}is(e){return this.type==e}static define(e={}){return new Ub(e.map||(e=>e))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let r of e){let e=r.map(t);e&&n.push(e)}return n}}$b.reconfigure=$b.define(),$b.appendConfig=$b.define();class Kb{constructor(e,t,n,r,i,o){this.startState=e,this.changes=t,this.selection=n,this.effects=r,this.annotations=i,this.scrollIntoView=o,this._doc=null,this._state=null,n&&pb(n,t.newLength),i.some(e=>e.type==Kb.time)||(this.annotations=i.concat(Kb.time.of(Date.now())))}static create(e,t,n,r,i,o){return new Kb(e,t,n,r,i,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(Kb.userEvent);return!(!t||!(t==e||t.length>e.length&&t.slice(0,e.length)==e&&"."==t[e.length]))}}function Yb(e,t){let n=[];for(let r=0,i=0;;){let o,s;if(r<e.length&&(i==t.length||t[i]>=e[r]))o=e[r++],s=e[r++];else{if(!(i<t.length))return n;o=t[i++],s=t[i++]}!n.length||n[n.length-1]<o?n.push(o,s):n[n.length-1]<s&&(n[n.length-1]=s)}}function Gb(e,t,n){var r;let i,o,s;return n?(i=t.changes,o=ob.empty(t.changes.length),s=e.changes.compose(t.changes)):(i=t.changes.map(e.changes),o=e.changes.mapDesc(t.changes,!0),s=e.changes.compose(i)),{changes:s,selection:t.selection?t.selection.map(o):null===(r=e.selection)||void 0===r?void 0:r.map(i),effects:$b.mapEffects(e.effects,i).concat($b.mapEffects(t.effects,o)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function Xb(e,t,n){let r=t.selection,i=Zb(t.annotations);return t.userEvent&&(i=i.concat(Kb.userEvent.of(t.userEvent))),{changes:t.changes instanceof ob?t.changes:ob.of(t.changes||[],n,e.facet(Fb)),selection:r&&(r instanceof fb?r:fb.single(r.anchor,r.head)),effects:Zb(t.effects),annotations:i,scrollIntoView:!!t.scrollIntoView}}function Jb(e,t,n){let r=Xb(e,t.length?t[0]:{},e.doc.length);t.length&&!1===t[0].filter&&(n=!1);for(let i=1;i<t.length;i++){!1===t[i].filter&&(n=!1);let o=!!t[i].sequential;r=Gb(r,Xb(e,t[i],o?r.changes.newLength:e.doc.length),o)}let i=Kb.create(e,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return function(e){let t=e.startState,n=t.facet(zb),r=e;for(let i=n.length-1;i>=0;i--){let o=n[i](e);o&&Object.keys(o).length&&(r=Gb(r,Xb(t,o,e.changes.newLength),!0))}return r==e?e:Kb.create(t,e.changes,e.selection,r.effects,r.annotations,r.scrollIntoView)}(n?function(e){let t=e.startState,n=!0;for(let r of t.facet(jb)){let t=r(e);if(!1===t){n=!1;break}Array.isArray(t)&&(n=!0===n?t:Yb(n,t))}if(!0!==n){let r,i;if(!1===n)i=e.changes.invertedDesc,r=ob.empty(t.doc.length);else{let t=e.changes.filter(n);r=t.changes,i=t.filtered.mapDesc(t.changes).invertedDesc}e=Kb.create(t,r,e.selection&&e.selection.map(i),$b.mapEffects(e.effects,i),e.annotations,e.scrollIntoView)}let r=t.facet(Wb);for(let n=r.length-1;n>=0;n--){let i=r[n](e);e=i instanceof Kb?i:Array.isArray(i)&&1==i.length&&i[0]instanceof Kb?i[0]:Jb(t,Zb(i),!1)}return e}(i):i)}Kb.time=Vb.define(),Kb.userEvent=Vb.define(),Kb.addToHistory=Vb.define(),Kb.remote=Vb.define();const Qb=[];function Zb(e){return null==e?Qb:Array.isArray(e)?e:[e]}var ey=function(e){return e[e.Word=0]="Word",e[e.Space=1]="Space",e[e.Other=2]="Other",e}(ey||(ey={}));const ty=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let ny;try{ny=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(e){}function ry(e){return t=>{if(!/\S/.test(t))return ey.Space;if(function(e){if(ny)return ny.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>"€"&&(n.toUpperCase()!=n.toLowerCase()||ty.test(n)))return!0}return!1}(t))return ey.Word;for(let n=0;n<e.length;n++)if(t.indexOf(e[n])>-1)return ey.Word;return ey.Other}}class iy{constructor(e,t,n,r,i,o){this.config=e,this.doc=t,this.selection=n,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=i,o&&(o._state=this);for(let e=0;e<this.config.dynamicSlots.length;e++)Lb(this,e<<1);this.computeSlot=null}field(e,t=!0){let n=this.config.address[e.id];if(null!=n)return Lb(this,n),Ib(this,n);if(t)throw new RangeError("Field is not present in this state")}update(...e){return Jb(this,e,!0)}applyTransaction(e){let t,n=this.config,{base:r,compartments:i}=n;for(let t of e.effects)t.is(Rb.reconfigure)?(n&&(i=new Map,n.compartments.forEach((e,t)=>i.set(t,e)),n=null),i.set(t.value.compartment,t.value.extension)):t.is($b.reconfigure)?(n=null,r=t.value):t.is($b.appendConfig)&&(n=null,r=Zb(r).concat(t.value));if(n)t=e.startState.values.slice();else{n=Pb.resolve(r,i,this);let e=new iy(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(e,t)=>t.reconfigure(e,this),null);t=e.values}let o=e.startState.facet(Bb)?e.newSelection:e.newSelection.asSingle();new iy(n,e.newDoc,o,t,(t,n)=>n.update(t,e),e)}replaceSelection(e){return"string"==typeof e&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:fb.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),r=this.changes(n.changes),i=[n.range],o=Zb(n.effects);for(let n=1;n<t.ranges.length;n++){let s=e(t.ranges[n]),a=this.changes(s.changes),l=a.map(r);for(let e=0;e<n;e++)i[e]=i[e].map(l);let c=r.mapDesc(a,!0);i.push(s.range.map(c)),r=r.compose(l),o=$b.mapEffects(o,l).concat($b.mapEffects(Zb(s.effects),c))}return{changes:r,selection:fb.create(i,t.mainIndex),effects:o}}changes(e=[]){return e instanceof ob?e:ob.of(e,this.doc.length,this.facet(iy.lineSeparator))}toText(e){return Hv.of(e.split(this.facet(iy.lineSeparator)||nb))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return null==t?e.default:(Lb(this,t),Ib(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let r=e[n];r instanceof Sb&&null!=this.config.address[r.id]&&(t[n]=r.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(e,t={},n){if(!e||"string"!=typeof e.doc)throw new RangeError("Invalid JSON representation for EditorState");let r=[];if(n)for(let t in n)if(Object.prototype.hasOwnProperty.call(e,t)){let i=n[t],o=e[t];r.push(i.init(e=>i.spec.fromJSON(o,e)))}return iy.create({doc:e.doc,selection:fb.fromJSON(e.selection),extensions:t.extensions?r.concat([t.extensions]):r})}static create(e={}){let t=Pb.resolve(e.extensions||[],new Map),n=e.doc instanceof Hv?e.doc:Hv.of((e.doc||"").split(t.staticFacet(iy.lineSeparator)||nb)),r=e.selection?e.selection instanceof fb?e.selection:fb.single(e.selection.anchor,e.selection.head):fb.single(0);return pb(r,n.length),t.staticFacet(Bb)||(r=r.asSingle()),new iy(t,n,r,t.dynamicSlots.map(()=>null),(e,t)=>t.create(e),null)}get tabSize(){return this.facet(iy.tabSize)}get lineBreak(){return this.facet(iy.lineSeparator)||"\n"}get readOnly(){return this.facet(Hb)}phrase(e,...t){for(let t of this.facet(iy.phrases))if(Object.prototype.hasOwnProperty.call(t,e)){e=t[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(e,n)=>{if("$"==n)return"$";let r=+(n||1);return!r||r>t.length?e:t[r-1]})),e}languageDataAt(e,t,n=-1){let r=[];for(let i of this.facet(_b))for(let o of i(this,t,n))Object.prototype.hasOwnProperty.call(o,e)&&r.push(o[e]);return r}charCategorizer(e){let t=this.languageDataAt("wordChars",e);return ry(t.length?t[0]:"")}wordAt(e){let{text:t,from:n,length:r}=this.doc.lineAt(e),i=this.charCategorizer(e),o=e-n,s=e-n;for(;o>0;){let e=Qv(t,o,!1);if(i(t.slice(e,o))!=ey.Word)break;o=e}for(;s<r;){let e=Qv(t,s);if(i(t.slice(s,e))!=ey.Word)break;s=e}return o==s?null:fb.range(o+n,s+n)}}function oy(e,t,n={}){let r={};for(let t of e)for(let e of Object.keys(t)){let i=t[e],o=r[e];if(void 0===o)r[e]=i;else if(o===i||void 0===i);else{if(!Object.hasOwnProperty.call(n,e))throw new Error("Config merge conflict for field "+e);r[e]=n[e](o,i)}}for(let e in t)void 0===r[e]&&(r[e]=t[e]);return r}iy.allowMultipleSelections=Bb,iy.tabSize=gb.define({combine:e=>e.length?e[0]:4}),iy.lineSeparator=Fb,iy.readOnly=Hb,iy.phrases=gb.define({compare(e,t){let n=Object.keys(e),r=Object.keys(t);return n.length==r.length&&n.every(n=>e[n]==t[n])}}),iy.languageData=_b,iy.changeFilter=jb,iy.transactionFilter=Wb,iy.transactionExtender=zb,Rb.reconfigure=$b.define();class sy{eq(e){return this==e}range(e,t=e){return ly.create(e,t,this)}}function ay(e,t){return e==t||e.constructor==t.constructor&&e.eq(t)}sy.prototype.startSide=sy.prototype.endSide=0,sy.prototype.point=!1,sy.prototype.mapMode=rb.TrackDel;let ly=class e{constructor(e,t,n){this.from=e,this.to=t,this.value=n}static create(t,n,r){return new e(t,n,r)}};function cy(e,t){return e.from-t.from||e.value.startSide-t.value.startSide}class uy{constructor(e,t,n,r){this.from=e,this.to=t,this.value=n,this.maxPoint=r}get length(){return this.to[this.to.length-1]}findIndex(e,t,n,r=0){let i=n?this.to:this.from;for(let o=r,s=i.length;;){if(o==s)return o;let r=o+s>>1,a=i[r]-e||(n?this.value[r].endSide:this.value[r].startSide)-t;if(r==o)return a>=0?o:s;a>=0?s=r:o=r+1}}between(e,t,n,r){for(let i=this.findIndex(t,-1e9,!0),o=this.findIndex(n,1e9,!1,i);i<o;i++)if(!1===r(this.from[i]+e,this.to[i]+e,this.value[i]))return!1}map(e,t){let n=[],r=[],i=[],o=-1,s=-1;for(let a=0;a<this.value.length;a++){let l,c,u=this.value[a],h=this.from[a]+e,d=this.to[a]+e;if(h==d){let e=t.mapPos(h,u.startSide,u.mapMode);if(null==e)continue;if(l=c=e,u.startSide!=u.endSide&&(c=t.mapPos(h,u.endSide),c<l))continue}else if(l=t.mapPos(h,u.startSide),c=t.mapPos(d,u.endSide),l>c||l==c&&u.startSide>0&&u.endSide<=0)continue;(c-l||u.endSide-u.startSide)<0||(o<0&&(o=l),u.point&&(s=Math.max(s,c-l)),n.push(u),r.push(l-o),i.push(c-o))}return{mapped:n.length?new uy(r,i,n,s):null,pos:o}}}class hy{constructor(e,t,n,r){this.chunkPos=e,this.chunk=t,this.nextLayer=n,this.maxPoint=r}static create(e,t,n,r){return new hy(e,t,n,r)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:n=!1,filterFrom:r=0,filterTo:i=this.length}=e,o=e.filter;if(0==t.length&&!o)return this;if(n&&(t=t.slice().sort(cy)),this.isEmpty)return t.length?hy.of(t):this;let s=new py(this,null,-1).goto(0),a=0,l=[],c=new dy;for(;s.value||a<t.length;)if(a<t.length&&(s.from-t[a].from||s.startSide-t[a].value.startSide)>=0){let e=t[a++];c.addInner(e.from,e.to,e.value)||l.push(e)}else 1==s.rangeIndex&&s.chunkIndex<this.chunk.length&&(a==t.length||this.chunkEnd(s.chunkIndex)<t[a].from)&&(!o||r>this.chunkEnd(s.chunkIndex)||i<this.chunkPos[s.chunkIndex])&&c.addChunk(this.chunkPos[s.chunkIndex],this.chunk[s.chunkIndex])?s.nextChunk():((!o||r>s.to||i<s.from||o(s.from,s.to,s.value))&&(c.addInner(s.from,s.to,s.value)||l.push(ly.create(s.from,s.to,s.value))),s.next());return c.finishInner(this.nextLayer.isEmpty&&!l.length?hy.empty:this.nextLayer.update({add:l,filter:o,filterFrom:r,filterTo:i}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],n=[],r=-1;for(let i=0;i<this.chunk.length;i++){let o=this.chunkPos[i],s=this.chunk[i],a=e.touchesRange(o,o+s.length);if(!1===a)r=Math.max(r,s.maxPoint),t.push(s),n.push(e.mapPos(o));else if(!0===a){let{mapped:i,pos:a}=s.map(o,e);i&&(r=Math.max(r,i.maxPoint),t.push(i),n.push(a))}}let i=this.nextLayer.map(e);return 0==t.length?i:new hy(n,t,i||hy.empty,r)}between(e,t,n){if(!this.isEmpty){for(let r=0;r<this.chunk.length;r++){let i=this.chunkPos[r],o=this.chunk[r];if(t>=i&&e<=i+o.length&&!1===o.between(i,e-i,t-i,n))return}this.nextLayer.between(e,t,n)}}iter(e=0){return my.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return my.from(e).goto(t)}static compare(e,t,n,r,i=-1){let o=e.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=i),s=t.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=i),a=fy(o,s,n),l=new vy(o,a,i),c=new vy(s,a,i);n.iterGaps((e,t,n)=>by(l,e,c,t,n,r)),n.empty&&0==n.length&&by(l,0,c,0,0,r)}static eq(e,t,n=0,r){null==r&&(r=999999999);let i=e.filter(e=>!e.isEmpty&&t.indexOf(e)<0),o=t.filter(t=>!t.isEmpty&&e.indexOf(t)<0);if(i.length!=o.length)return!1;if(!i.length)return!0;let s=fy(i,o),a=new vy(i,s,0).goto(n),l=new vy(o,s,0).goto(n);for(;;){if(a.to!=l.to||!yy(a.active,l.active)||a.point&&(!l.point||!ay(a.point,l.point)))return!1;if(a.to>r)return!0;a.next(),l.next()}}static spans(e,t,n,r,i=-1){let o=new vy(e,null,i).goto(t),s=t,a=o.openStart;for(;;){let e=Math.min(o.to,n);if(o.point){let n=o.activeForPoint(o.to),i=o.pointFrom<t?n.length+1:o.point.startSide<0?n.length:Math.min(n.length,a);r.point(s,e,o.point,n,i,o.pointRank),a=Math.min(o.openEnd(e),n.length)}else e>s&&(r.span(s,e,o.active,a),a=o.openEnd(e));if(o.to>n)return a+(o.point&&o.to>n?1:0);s=o.to,o.next()}}static of(e,t=!1){let n=new dy;for(let r of e instanceof ly?[e]:t?function(e){if(e.length>1)for(let t=e[0],n=1;n<e.length;n++){let r=e[n];if(cy(t,r)>0)return e.slice().sort(cy);t=r}return e}(e):e)n.add(r.from,r.to,r.value);return n.finish()}static join(e){if(!e.length)return hy.empty;let t=e[e.length-1];for(let n=e.length-2;n>=0;n--)for(let r=e[n];r!=hy.empty;r=r.nextLayer)t=new hy(r.chunkPos,r.chunk,t,Math.max(r.maxPoint,t.maxPoint));return t}}hy.empty=new hy([],[],null,-1),hy.empty.nextLayer=hy.empty;class dy{finishChunk(e){this.chunks.push(new uy(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,n){this.addInner(e,t,n)||(this.nextLayer||(this.nextLayer=new dy)).add(e,t,n)}addInner(e,t,n){let r=e-this.lastTo||n.startSide-this.last.endSide;if(r<=0&&(e-this.lastFrom||n.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return!(r<0)&&(250==this.from.length&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=n,this.lastFrom=e,this.lastTo=t,this.value.push(n),n.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let n=t.value.length-1;return this.last=t.value[n],this.lastFrom=t.from[n]+e,this.lastTo=t.to[n]+e,!0}finish(){return this.finishInner(hy.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return e;let t=hy.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function fy(e,t,n){let r=new Map;for(let t of e)for(let e=0;e<t.chunk.length;e++)t.chunk[e].maxPoint<=0&&r.set(t.chunk[e],t.chunkPos[e]);let i=new Set;for(let e of t)for(let t=0;t<e.chunk.length;t++){let o=r.get(e.chunk[t]);null==o||(n?n.mapPos(o):o)!=e.chunkPos[t]||(null==n?void 0:n.touchesRange(o,o+e.chunk[t].length))||i.add(e.chunk[t])}return i}class py{constructor(e,t,n,r=0){this.layer=e,this.skip=t,this.minPoint=n,this.rank=r}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,n){for(;this.chunkIndex<this.layer.chunk.length;){let t=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(t)||this.layer.chunkEnd(this.chunkIndex)<e||t.maxPoint<this.minPoint))break;this.chunkIndex++,n=!1}if(this.chunkIndex<this.layer.chunk.length){let r=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!n||this.rangeIndex<r)&&this.setRangeIndex(r)}this.next()}forward(e,t){(this.to-e||this.endSide-t)<0&&this.gotoInner(e,t,!0)}next(){for(;;){if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],n=e+t.from[this.rangeIndex];if(this.from=n,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}}class my{constructor(e){this.heap=e}static from(e,t=null,n=-1){let r=[];for(let i=0;i<e.length;i++)for(let o=e[i];!o.isEmpty;o=o.nextLayer)o.maxPoint>=n&&r.push(new py(o,t,n,i));return 1==r.length?r[0]:new my(r)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let n of this.heap)n.goto(e,t);for(let e=this.heap.length>>1;e>=0;e--)gy(this.heap,e);return this.next(),this}forward(e,t){for(let n of this.heap)n.forward(e,t);for(let e=this.heap.length>>1;e>=0;e--)gy(this.heap,e);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(0==this.heap.length)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),gy(this.heap,0)}}}function gy(e,t){for(let n=e[t];;){let r=1+(t<<1);if(r>=e.length)break;let i=e[r];if(r+1<e.length&&i.compare(e[r+1])>=0&&(i=e[r+1],r++),n.compare(i)<0)break;e[r]=n,e[t]=i,t=r}}class vy{constructor(e,t,n){this.minPoint=n,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=my.from(e,t,n)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){wy(this.active,e),wy(this.activeTo,e),wy(this.activeRank,e),this.minActive=ky(this.active,this.activeTo)}addActive(e){let t=0,{value:n,to:r,rank:i}=this.cursor;for(;t<this.activeRank.length&&(i-this.activeRank[t]||r-this.activeTo[t])>0;)t++;xy(this.active,t,n),xy(this.activeTo,t,r),xy(this.activeRank,t,i),e&&xy(e,t,this.cursor.from),this.minActive=ky(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let n=this.openStart<0?[]:null;for(;;){let r=this.minActive;if(r>-1&&(this.activeTo[r]-this.cursor.from||this.active[r].endSide-this.cursor.startSide)<0){if(this.activeTo[r]>e){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),n&&wy(n,r)}else{if(!this.cursor.value){this.to=this.endSide=1e9;break}if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}{let e=this.cursor.value;if(e.point){if(!(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)){this.point=e,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=e.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}this.cursor.next()}else this.addActive(n),this.cursor.next()}}}if(n){this.openStart=0;for(let t=n.length-1;t>=0&&n[t]<e;t--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let n=this.active.length-1;n>=0&&!(this.activeRank[n]<this.pointRank);n--)(this.activeTo[n]>e||this.activeTo[n]==e&&this.active[n].endSide>=this.point.endSide)&&t.push(this.active[n]);return t.reverse()}openEnd(e){let t=0;for(let n=this.activeTo.length-1;n>=0&&this.activeTo[n]>e;n--)t++;return t}}function by(e,t,n,r,i,o){e.goto(t),n.goto(r);let s=r+i,a=r,l=r-t,c=!!o.boundChange;for(let t=!1;;){let r=e.to+l-n.to,i=r||e.endSide-n.endSide,u=i<0?e.to+l:n.to,h=Math.min(u,s);if(e.point||n.point?(e.point&&n.point&&ay(e.point,n.point)&&yy(e.activeForPoint(e.to),n.activeForPoint(n.to))||o.comparePoint(a,h,e.point,n.point),t=!1):(t&&o.boundChange(a),h>a&&!yy(e.active,n.active)&&o.compareRange(a,h,e.active,n.active),c&&h<s&&(r||e.openEnd(u)!=n.openEnd(u))&&(t=!0)),u>s)break;a=u,i<=0&&e.next(),i>=0&&n.next()}}function yy(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n]&&!ay(e[n],t[n]))return!1;return!0}function wy(e,t){for(let n=t,r=e.length-1;n<r;n++)e[n]=e[n+1];e.pop()}function xy(e,t,n){for(let n=e.length-1;n>=t;n--)e[n+1]=e[n];e[t]=n}function ky(e,t){let n=-1,r=1e9;for(let i=0;i<t.length;i++)(t[i]-r||e[i].endSide-e[n].endSide)<0&&(n=i,r=t[i]);return n}function Sy(e,t,n=e.length){let r=0;for(let i=0;i<n&&i<e.length;)9==e.charCodeAt(i)?(r+=t-r%t,i++):(r++,i=Qv(e,i));return r}function Ey(e,t,n,r){for(let r=0,i=0;;){if(i>=t)return r;if(r==e.length)break;i+=9==e.charCodeAt(r)?n-i%n:1,r=Qv(e,r)}return!0===r?-1:e.length}const Cy="undefined"==typeof Symbol?"__ͼ":Symbol.for("ͼ"),Ny="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),Oy="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class Ay{constructor(e,t){this.rules=[];let{finish:n}=t||{};function r(e){return/^@/.test(e)?[e]:e.split(/,\s*/)}function i(e,t,o,s){let a=[],l=/^@(\w+)\b/.exec(e[0]),c=l&&"keyframes"==l[1];if(l&&null==t)return o.push(e[0]+";");for(let n in t){let s=t[n];if(/&/.test(n))i(n.split(/,\s*/).map(t=>e.map(e=>t.replace(/&/,e))).reduce((e,t)=>e.concat(t)),s,o);else if(s&&"object"==typeof s){if(!l)throw new RangeError("The value of a property ("+n+") should be a primitive value.");i(r(n),s,a,c)}else null!=s&&a.push(n.replace(/_.*/,"").replace(/[A-Z]/g,e=>"-"+e.toLowerCase())+": "+s+";")}(a.length||c)&&o.push((!n||l||s?e:e.map(n)).join(", ")+" {"+a.join(" ")+"}")}for(let t in e)i(r(t),e[t],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let e=Oy[Cy]||1;return Oy[Cy]=e+1,"ͼ"+e.toString(36)}static mount(e,t,n){let r=e[Ny],i=n&&n.nonce;r?i&&r.setNonce(i):r=new Ty(e,i),r.mount(Array.isArray(t)?t:[t],e)}}let My=new Map;class Ty{constructor(e,t){let n=e.ownerDocument||e,r=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let t=My.get(n);if(t)return e[Ny]=t;this.sheet=new r.CSSStyleSheet,My.set(n,this)}else this.styleTag=n.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[Ny]=this}mount(e,t){let n=this.sheet,r=0,i=0;for(let t=0;t<e.length;t++){let o=e[t],s=this.modules.indexOf(o);if(s<i&&s>-1&&(this.modules.splice(s,1),i--,s=-1),-1==s){if(this.modules.splice(i++,0,o),n)for(let e=0;e<o.rules.length;e++)n.insertRule(o.rules[e],r++)}else{for(;i<s;)r+=this.modules[i++].rules.length;r+=o.rules.length,i++}}if(n)t.adoptedStyleSheets.indexOf(this.sheet)<0&&(t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets]);else{let e="";for(let t=0;t<this.modules.length;t++)e+=this.modules[t].getRules()+"\n";this.styleTag.textContent=e;let n=t.head||t;this.styleTag.parentNode!=n&&n.insertBefore(this.styleTag,n.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}}for(var Ry={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Dy={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Py="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),Ly="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Iy=0;Iy<10;Iy++)Ry[48+Iy]=Ry[96+Iy]=String(Iy);for(Iy=1;Iy<=24;Iy++)Ry[Iy+111]="F"+Iy;for(Iy=65;Iy<=90;Iy++)Ry[Iy]=String.fromCharCode(Iy+32),Dy[Iy]=String.fromCharCode(Iy);for(var _y in Ry)Dy.hasOwnProperty(_y)||(Dy[_y]=Ry[_y]);function By(){var e=arguments[0];"string"==typeof e&&(e=document.createElement(e));var t=1,n=arguments[1];if(n&&"object"==typeof n&&null==n.nodeType&&!Array.isArray(n)){for(var r in n)if(Object.prototype.hasOwnProperty.call(n,r)){var i=n[r];"string"==typeof i?e.setAttribute(r,i):null!=i&&(e[r]=i)}t++}for(;t<arguments.length;t++)Fy(e,arguments[t]);return e}function Fy(e,t){if("string"==typeof t)e.appendChild(document.createTextNode(t));else if(null==t);else if(null!=t.nodeType)e.appendChild(t);else{if(!Array.isArray(t))throw new RangeError("Unsupported child node: "+t);for(var n=0;n<t.length;n++)Fy(e,t[n])}}let jy="undefined"!=typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},Wy="undefined"!=typeof document?document:{documentElement:{style:{}}};const zy=/Edge\/(\d+)/.exec(jy.userAgent),Hy=/MSIE \d/.test(jy.userAgent),Vy=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(jy.userAgent),qy=!!(Hy||Vy||zy),Uy=!qy&&/gecko\/(\d+)/i.test(jy.userAgent),$y=!qy&&/Chrome\/(\d+)/.exec(jy.userAgent),Ky="webkitFontSmoothing"in Wy.documentElement.style,Yy=!qy&&/Apple Computer/.test(jy.vendor),Gy=Yy&&(/Mobile\/\w+/.test(jy.userAgent)||jy.maxTouchPoints>2);var Xy={mac:Gy||/Mac/.test(jy.platform),windows:/Win/.test(jy.platform),linux:/Linux|X11/.test(jy.platform),ie:qy,ie_version:Hy?Wy.documentMode||6:Vy?+Vy[1]:zy?+zy[1]:0,gecko:Uy,gecko_version:Uy?+(/Firefox\/(\d+)/.exec(jy.userAgent)||[0,0])[1]:0,chrome:!!$y,chrome_version:$y?+$y[1]:0,ios:Gy,android:/Android\b/.test(jy.userAgent),webkit:Ky,webkit_version:Ky?+(/\bAppleWebKit\/(\d+)/.exec(jy.userAgent)||[0,0])[1]:0,safari:Yy,safari_version:Yy?+(/\bVersion\/(\d+(\.\d+)?)/.exec(jy.userAgent)||[0,0])[1]:0,tabSize:null!=Wy.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};function Jy(e,t){for(let n in e)"class"==n&&t.class?t.class+=" "+e.class:"style"==n&&t.style?t.style+=";"+e.style:t[n]=e[n];return t}const Qy=Object.create(null);function Zy(e,t,n){if(e==t)return!0;e||(e=Qy),t||(t=Qy);let r=Object.keys(e),i=Object.keys(t);if(r.length-(n&&r.indexOf(n)>-1?1:0)!=i.length-(n&&i.indexOf(n)>-1?1:0))return!1;for(let o of r)if(o!=n&&(-1==i.indexOf(o)||e[o]!==t[o]))return!1;return!0}function ew(e,t,n){let r=!1;if(t)for(let i in t)n&&i in n||(r=!0,"style"==i?e.style.cssText="":e.removeAttribute(i));if(n)for(let i in n)t&&t[i]==n[i]||(r=!0,"style"==i?e.style.cssText=n[i]:e.setAttribute(i,n[i]));return r}function tw(e){let t=Object.create(null);for(let n=0;n<e.attributes.length;n++){let r=e.attributes[n];t[r.name]=r.value}return t}class nw{eq(e){return!1}updateDOM(e,t){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,n){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}}var rw=function(e){return e[e.Text=0]="Text",e[e.WidgetBefore=1]="WidgetBefore",e[e.WidgetAfter=2]="WidgetAfter",e[e.WidgetRange=3]="WidgetRange",e}(rw||(rw={}));class iw extends sy{constructor(e,t,n,r){super(),this.startSide=e,this.endSide=t,this.widget=n,this.spec=r}get heightRelevant(){return!1}static mark(e){return new ow(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),n=!!e.block;return t+=n&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new aw(e,t,t,n,e.widget||null,!1)}static replace(e){let t,n,r=!!e.block;if(e.isBlockGap)t=-5e8,n=4e8;else{let{start:i,end:o}=lw(e,r);t=(i?r?-3e8:-1:5e8)-1,n=1+(o?r?2e8:1:-6e8)}return new aw(e,t,n,r,e.widget||null,!0)}static line(e){return new sw(e)}static set(e,t=!1){return hy.of(e,t)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}iw.none=hy.empty;class ow extends iw{constructor(e){let{start:t,end:n}=lw(e);super(t?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?Jy(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||Qy}eq(e){return this==e||e instanceof ow&&this.tagName==e.tagName&&Zy(this.attrs,e.attrs)}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}}ow.prototype.point=!1;class sw extends iw{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof sw&&this.spec.class==e.spec.class&&Zy(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}}sw.prototype.mapMode=rb.TrackBefore,sw.prototype.point=!0;class aw extends iw{constructor(e,t,n,r,i,o){super(t,n,i,e),this.block=r,this.isReplace=o,this.mapMode=r?t<=0?rb.TrackBefore:rb.TrackAfter:rb.TrackDel}get type(){return this.startSide!=this.endSide?rw.WidgetRange:this.startSide<=0?rw.WidgetBefore:rw.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof aw&&(t=this.widget,n=e.widget,t==n||!!(t&&n&&t.compare(n)))&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide;var t,n}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}}function lw(e,t=!1){let{inclusiveStart:n,inclusiveEnd:r}=e;return null==n&&(n=e.inclusive),null==r&&(r=e.inclusive),{start:null!=n?n:t,end:null!=r?r:t}}function cw(e,t,n,r=0){let i=n.length-1;i>=0&&n[i]+r>=e?n[i]=Math.max(n[i],t):n.push(e,t)}aw.prototype.point=!0;class uw extends sy{constructor(e,t){super(),this.tagName=e,this.attributes=t}eq(e){return e==this||e instanceof uw&&this.tagName==e.tagName&&Zy(this.attributes,e.attributes)}static create(e){return new uw(e.tagName,e.attributes||Qy)}static set(e,t=!1){return hy.of(e,t)}}function hw(e){let t;return t=11==e.nodeType?e.getSelection?e:e.ownerDocument:e,t.getSelection()}function dw(e,t){return!!t&&(e==t||e.contains(1!=t.nodeType?t.parentNode:t))}function fw(e,t){if(!t.anchorNode)return!1;try{return dw(e,t.anchorNode)}catch(e){return!1}}function pw(e){return 3==e.nodeType?Ow(e,0,e.nodeValue.length).getClientRects():1==e.nodeType?e.getClientRects():[]}function mw(e,t,n,r){return!!n&&(bw(e,t,n,r,-1)||bw(e,t,n,r,1))}function gw(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t}function vw(e){return 1==e.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(e.nodeName)}function bw(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:yw(e))){if("DIV"==e.nodeName)return!1;let n=e.parentNode;if(!n||1!=n.nodeType)return!1;t=gw(e)+(i<0?0:1),e=n}else{if(1!=e.nodeType)return!1;if(1==(e=e.childNodes[t+(i<0?-1:0)]).nodeType&&"false"==e.contentEditable)return!1;t=i<0?yw(e):0}}}function yw(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function ww(e,t){let n=t?e.left:e.right;return{left:n,right:n,top:e.top,bottom:e.bottom}}function xw(e){let t=e.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.innerWidth,top:0,bottom:e.innerHeight}}function kw(e,t){let n=t.width/e.offsetWidth,r=t.height/e.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(t.width-e.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(t.height-e.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}uw.prototype.startSide=uw.prototype.endSide=-1;class Sw{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:n}=e;this.set(t,Math.min(e.anchorOffset,t?yw(t):0),n,Math.min(e.focusOffset,n?yw(n):0))}set(e,t,n,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=r}}let Ew,Cw=null;function Nw(e){if(e.setActive)return e.setActive();if(Cw)return e.focus(Cw);let t=[];for(let n=e;n&&(t.push(n,n.scrollTop,n.scrollLeft),n!=n.ownerDocument);n=n.parentNode);if(e.focus(null==Cw?{get preventScroll(){return Cw={preventScroll:!0},!0}}:void 0),!Cw){Cw=!1;for(let e=0;e<t.length;){let n=t[e++],r=t[e++],i=t[e++];n.scrollTop!=r&&(n.scrollTop=r),n.scrollLeft!=i&&(n.scrollLeft=i)}}}function Ow(e,t,n=t){let r=Ew||(Ew=document.createRange());return r.setEnd(e,n),r.setStart(e,t),r}function Aw(e,t,n,r){let i={key:t,code:t,keyCode:n,which:n,cancelable:!0};r&&({altKey:i.altKey,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey,metaKey:i.metaKey}=r);let o=new KeyboardEvent("keydown",i);o.synthetic=!0,e.dispatchEvent(o);let s=new KeyboardEvent("keyup",i);return s.synthetic=!0,e.dispatchEvent(s),o.defaultPrevented||s.defaultPrevented}function Mw(e){return e.scrollTop>Math.max(1,e.scrollHeight-e.clientHeight-4)}function Tw(e,t){for(let n=e,r=t;;){if(3==n.nodeType&&r>0)return{node:n,offset:r};if(1==n.nodeType&&r>0){if("false"==n.contentEditable)return null;n=n.childNodes[r-1],r=yw(n)}else{if(!n.parentNode||vw(n))return null;r=gw(n),n=n.parentNode}}}function Rw(e,t){for(let n=e,r=t;;){if(3==n.nodeType&&r<n.nodeValue.length)return{node:n,offset:r};if(1==n.nodeType&&r<n.childNodes.length){if("false"==n.contentEditable)return null;n=n.childNodes[r],r=0}else{if(!n.parentNode||vw(n))return null;r=gw(n)+1,n=n.parentNode}}}Xy.safari&&Xy.safari_version>=26&&(Cw=!1);class Dw{constructor(e,t,n=!0){this.node=e,this.offset=t,this.precise=n}static before(e,t){return new Dw(e.parentNode,gw(e),t)}static after(e,t){return new Dw(e.parentNode,gw(e)+1,t)}}var Pw=function(e){return e[e.LTR=0]="LTR",e[e.RTL=1]="RTL",e}(Pw||(Pw={}));const Lw=Pw.LTR,Iw=Pw.RTL;function _w(e){let t=[];for(let n=0;n<e.length;n++)t.push(1<<+e[n]);return t}const Bw=_w("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),Fw=_w("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),jw=Object.create(null),Ww=[];for(let e of["()","[]","{}"]){let t=e.charCodeAt(0),n=e.charCodeAt(1);jw[t]=n,jw[n]=-t}function zw(e){return e<=247?Bw[e]:1424<=e&&e<=1524?2:1536<=e&&e<=1785?Fw[e-1536]:1774<=e&&e<=2220?4:8192<=e&&e<=8204?256:64336<=e&&e<=65023?4:1}const Hw=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class Vw{get dir(){return this.level%2?Iw:Lw}constructor(e,t,n){this.from=e,this.to=t,this.level=n}side(e,t){return this.dir==t==e?this.to:this.from}forward(e,t){return e==(this.dir==t)}static find(e,t,n,r){let i=-1;for(let o=0;o<e.length;o++){let s=e[o];if(s.from<=t&&s.to>=t){if(s.level==n)return o;(i<0||(0!=r?r<0?s.from<t:s.to>t:e[i].level>s.level))&&(i=o)}}if(i<0)throw new RangeError("Index out of range");return i}}function qw(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r.from!=i.from||r.to!=i.to||r.direction!=i.direction||!qw(r.inner,i.inner))return!1}return!0}const Uw=[];function $w(e,t,n,r,i,o,s){let a=r%2?2:1;if(r%2==i%2)for(let l=t,c=0;l<n;){let t=!0,u=!1;if(c==o.length||l<o[c].from){let e=Uw[l];e!=a&&(t=!1,u=16==e)}let h=t||1!=a?null:[],d=t?r:r+1,f=l;e:for(;;)if(c<o.length&&f==o[c].from){if(u)break e;let p=o[c];if(!t)for(let e=p.to,t=c+1;;){if(e==n)break e;if(!(t<o.length&&o[t].from==e)){if(Uw[e]==a)break e;break}e=o[t++].to}if(c++,h)h.push(p);else{p.from>l&&s.push(new Vw(l,p.from,d)),Kw(e,p.direction==Lw!=!(d%2)?r+1:r,i,p.inner,p.from,p.to,s),l=p.to}f=p.to}else{if(f==n||(t?Uw[f]!=a:Uw[f]==a))break;f++}h?$w(e,l,f,r+1,i,h,s):l<f&&s.push(new Vw(l,f,d)),l=f}else for(let l=n,c=o.length;l>t;){let n=!0,u=!1;if(!c||l>o[c-1].to){let e=Uw[l-1];e!=a&&(n=!1,u=16==e)}let h=n||1!=a?null:[],d=n?r:r+1,f=l;e:for(;;)if(c&&f==o[c-1].to){if(u)break e;let p=o[--c];if(!n)for(let e=p.from,n=c;;){if(e==t)break e;if(!n||o[n-1].to!=e){if(Uw[e-1]==a)break e;break}e=o[--n].from}if(h)h.push(p);else{p.to<l&&s.push(new Vw(p.to,l,d)),Kw(e,p.direction==Lw!=!(d%2)?r+1:r,i,p.inner,p.from,p.to,s),l=p.from}f=p.from}else{if(f==t||(n?Uw[f-1]!=a:Uw[f-1]==a))break;f--}h?$w(e,f,l,r+1,i,h,s):f<l&&s.push(new Vw(f,l,d)),l=f}}function Kw(e,t,n,r,i,o,s){let a=t%2?2:1;!function(e,t,n,r,i){for(let o=0;o<=r.length;o++){let s=o?r[o-1].to:t,a=o<r.length?r[o].from:n,l=o?256:i;for(let t=s,n=l,r=l;t<a;t++){let i=zw(e.charCodeAt(t));512==i?i=n:8==i&&4==r&&(i=16),Uw[t]=4==i?2:i,7&i&&(r=i),n=i}for(let e=s,t=l,r=l;e<a;e++){let i=Uw[e];if(128==i)e<a-1&&t==Uw[e+1]&&24&t?i=Uw[e]=t:Uw[e]=256;else if(64==i){let i=e+1;for(;i<a&&64==Uw[i];)i++;let o=e&&8==t||i<n&&8==Uw[i]?1==r?1:8:256;for(let t=e;t<i;t++)Uw[t]=o;e=i-1}else 8==i&&1==r&&(Uw[e]=1);t=i,7&i&&(r=i)}}}(e,i,o,r,a),function(e,t,n,r,i){let o=1==i?2:1;for(let s=0,a=0,l=0;s<=r.length;s++){let c=s?r[s-1].to:t,u=s<r.length?r[s].from:n;for(let t,n,r,s=c;s<u;s++)if(n=jw[t=e.charCodeAt(s)])if(n<0){for(let e=a-3;e>=0;e-=3)if(Ww[e+1]==-n){let t=Ww[e+2],n=2&t?i:4&t?1&t?o:i:0;n&&(Uw[s]=Uw[Ww[e]]=n),a=e;break}}else{if(189==Ww.length)break;Ww[a++]=s,Ww[a++]=t,Ww[a++]=l}else if(2==(r=Uw[s])||1==r){let e=r==i;l=e?0:1;for(let t=a-3;t>=0;t-=3){let n=Ww[t+2];if(2&n)break;if(e)Ww[t+2]|=2;else{if(4&n)break;Ww[t+2]|=4}}}}}(e,i,o,r,a),function(e,t,n,r){for(let i=0,o=r;i<=n.length;i++){let s=i?n[i-1].to:e,a=i<n.length?n[i].from:t;for(let l=s;l<a;){let s=Uw[l];if(256==s){let s=l+1;for(;;)if(s==a){if(i==n.length)break;s=n[i++].to,a=i<n.length?n[i].from:t}else{if(256!=Uw[s])break;s++}let c=1==o,u=c==(1==(s<t?Uw[s]:r))?c?1:2:r;for(let t=s,r=i,o=r?n[r-1].to:e;t>l;)t==o&&(t=n[--r].from,o=r?n[r-1].to:e),Uw[--t]=u;l=s}else o=s,l++}}}(i,o,r,a),$w(e,i,o,t,n,r,s)}function Yw(e){return[new Vw(0,e,0)]}let Gw="";function Xw(e,t,n,r,i){var o;let s=r.head-e.from,a=Vw.find(t,s,null!==(o=r.bidiLevel)&&void 0!==o?o:-1,r.assoc),l=t[a],c=l.side(i,n);if(s==c){let e=a+=i?1:-1;if(e<0||e>=t.length)return null;l=t[a=e],s=l.side(!i,n),c=l.side(i,n)}let u=Qv(e.text,s,l.forward(i,n));(u<l.from||u>l.to)&&(u=c),Gw=e.text.slice(Math.min(s,u),Math.max(s,u));let h=a==(i?t.length-1:0)?null:t[a+(i?1:-1)];return h&&u==c&&h.level+(i?0:1)<l.level?fb.cursor(h.side(!i,n)+e.from,h.forward(i,n)?1:-1,h.level):fb.cursor(u+e.from,l.forward(i,n)?-1:1,l.level)}function Jw(e,t,n){for(let r=t;r<n;r++){let t=zw(e.charCodeAt(r));if(1==t)return Lw;if(2==t||4==t)return Iw}return Lw}const Qw=gb.define(),Zw=gb.define(),ex=gb.define(),tx=gb.define(),nx=gb.define(),rx=gb.define(),ix=gb.define(),ox=gb.define(),sx=gb.define(),ax=gb.define({combine:e=>e.some(e=>e)}),lx=gb.define({combine:e=>e.some(e=>e)}),cx=gb.define();class ux{constructor(e,t="nearest",n="nearest",r=5,i=5,o=!1){this.range=e,this.y=t,this.x=n,this.yMargin=r,this.xMargin=i,this.isSnapshot=o}map(e){return e.empty?this:new ux(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new ux(fb.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const hx=$b.define({map:(e,t)=>e.map(t)}),dx=$b.define();function fx(e,t,n){let r=e.facet(tx);r.length?r[0](t):window.onerror&&window.onerror(String(t),n,void 0,void 0,t)}const px=gb.define({combine:e=>!e.length||e[0]});let mx=0;const gx=gb.define({combine:e=>e.filter((t,n)=>{for(let r=0;r<n;r++)if(e[r].plugin==t.plugin)return!1;return!0})});class vx{constructor(e,t,n,r,i){this.id=e,this.create=t,this.domEventHandlers=n,this.domEventObservers=r,this.baseExtensions=i(this),this.extension=this.baseExtensions.concat(gx.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(gx.of({plugin:this,arg:e}))}static define(e,t){const{eventHandlers:n,eventObservers:r,provide:i,decorations:o}=t||{};return new vx(mx++,e,n,r,e=>{let t=[];return o&&t.push(xx.of(t=>{let n=t.plugin(e);return n?o(n):iw.none})),i&&t.push(i(e)),t})}static fromClass(e,t){return vx.define((t,n)=>new e(t,n),t)}}class bx{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let e=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(e)}catch(t){if(fx(e.state,t,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(e){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){fx(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(null===(t=this.value)||void 0===t?void 0:t.destroy)try{this.value.destroy()}catch(t){fx(e.state,t,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const yx=gb.define(),wx=gb.define(),xx=gb.define(),kx=gb.define(),Sx=gb.define(),Ex=gb.define(),Cx=gb.define();function Nx(e,t){let n=e.state.facet(Cx);if(!n.length)return n;let r=n.map(t=>t instanceof Function?t(e):t),i=[];return hy.spans(r,t.from,t.to,{point(){},span(e,n,r,o){let s=e-t.from,a=n-t.from,l=i;for(let e=r.length-1;e>=0;e--,o--){let n,i=r[e].spec.bidiIsolate;if(null==i&&(i=Jw(t.text,s,a)),o>0&&l.length&&(n=l[l.length-1]).to==s&&n.direction==i)n.to=a,l=n.inner;else{let e={from:s,to:a,direction:i,inner:[]};l.push(e),l=e.inner}}}}),i}const Ox=gb.define();function Ax(e){let t=0,n=0,r=0,i=0;for(let o of e.state.facet(Ox)){let s=o(e);s&&(null!=s.left&&(t=Math.max(t,s.left)),null!=s.right&&(n=Math.max(n,s.right)),null!=s.top&&(r=Math.max(r,s.top)),null!=s.bottom&&(i=Math.max(i,s.bottom)))}return{left:t,right:n,top:r,bottom:i}}const Mx=gb.define();class Tx{constructor(e,t,n,r){this.fromA=e,this.toA=t,this.fromB=n,this.toB=r}join(e){return new Tx(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,n=this;for(;t>0;t--){let r=e[t-1];if(!(r.fromA>n.toA)){if(r.toA<n.fromA)break;n=n.join(r),e.splice(t-1,1)}}return e.splice(t,0,n),e}static extendWithRanges(e,t){if(0==t.length)return e;let n=[];for(let r=0,i=0,o=0;;){let s=r<e.length?e[r].fromB:1e9,a=i<t.length?t[i]:1e9,l=Math.min(s,a);if(1e9==l)break;let c=l+o,u=l,h=c;for(;;)if(i<t.length&&t[i]<=u){let n=t[i+1];i+=2,u=Math.max(u,n);for(let t=r;t<e.length&&e[t].fromB<=u;t++)o=e[t].toA-e[t].toB;h=Math.max(h,n+o)}else{if(!(r<e.length&&e[r].fromB<=u))break;{let t=e[r++];u=Math.max(u,t.toB),h=Math.max(h,t.toA),o=t.toA-t.toB}}n.push(new Tx(c,h,l,u))}return n}}class Rx{constructor(e,t,n){this.view=e,this.state=t,this.transactions=n,this.flags=0,this.startState=e.state,this.changes=ob.empty(this.startState.doc.length);for(let e of n)this.changes=this.changes.compose(e.changes);let r=[];this.changes.iterChangedRanges((e,t,n,i)=>r.push(new Tx(e,t,n,i))),this.changedRanges=r}static create(e,t,n){return new Rx(e,t,n)}get viewportChanged(){return(4&this.flags)>0}get viewportMoved(){return(8&this.flags)>0}get heightChanged(){return(2&this.flags)>0}get geometryChanged(){return this.docChanged||(18&this.flags)>0}get focusChanged(){return(1&this.flags)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return 0==this.flags&&0==this.transactions.length}}const Dx=[];class Px{constructor(e,t,n=0){this.dom=e,this.length=t,this.flags=n,this.parent=null,e.cmTile=this}get breakAfter(){return 1&this.flags}get children(){return Dx}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,4&this.flags){this.flags&=-5;let e=this.domAttrs;e&&function(e,t){for(let n=e.attributes.length-1;n>=0;n--){let r=e.attributes[n].name;null==t[r]&&e.removeAttribute(r)}for(let n in t){let r=t[n];"style"==n?e.style.cssText=r:e.getAttribute(n)!=r&&e.setAttribute(n,r)}}(this.dom,e)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,t=this.posAtStart){let n=t;for(let t of this.children){if(t==e)return n;n+=t.length+t.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,t){return null}domPosFor(e,t){let n=gw(this.dom),r=this.length?e>0:t>0;return new Dw(this.parent.dom,n+(r?1:0),0==e||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&2&this.parent.flags&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof _x)return e;return null}static get(e){return e.cmTile}}class Lx extends Px{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(2&this.flags)return;super.sync(e);let t,n=this.dom,r=null,i=(null==e?void 0:e.node)==n?e:null,o=0;for(let s of this.children){if(s.sync(e),o+=s.length+s.breakAfter,t=r?r.nextSibling:n.firstChild,i&&t!=s.dom&&(i.written=!0),s.dom.parentNode==n)for(;t&&t!=s.dom;)t=Ix(t);else n.insertBefore(s.dom,t);r=s.dom}for(t=r?r.nextSibling:n.firstChild,i&&t&&(i.written=!0);t;)t=Ix(t);this.length=o}}function Ix(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}class _x extends Lx{constructor(e,t){super(t),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let t=Px.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],n=this,r=0,i=0;;)if(r==n.children.length){if(!t.length)return;n=n.parent,n.breakAfter&&i++,r=t.pop()}else{let o=n.children[r++];if(o instanceof Bx)t.push(r),n=o,r=0;else{let t=i+o.length,n=e(o,i);if(void 0!==n)return n;i=t+o.breakAfter}}}resolveBlock(e,t){let n,r,i=-1,o=-1;if(this.blockTiles((s,a)=>{let l=a+s.length;if(e>=a&&e<=l){if(s.isWidget()&&t>=-1&&t<=1){if(32&s.flags)return!0;16&s.flags&&(n=void 0)}(a<e||e==l&&(t<-1?s.length:s.covers(1)))&&(!n||!s.isWidget()&&n.isWidget())&&(n=s,i=e-a),(l>e||e==a&&(t>1?s.length:s.covers(-1)))&&(!r||!s.isWidget()&&r.isWidget())&&(r=s,o=e-a)}}),!n&&!r)throw new Error("No tile at position "+e);return n&&t<0||!r?{tile:n,offset:i}:{tile:r,offset:o}}}class Bx extends Lx{constructor(e,t){super(e),this.wrapper=t}isBlock(){return!0}covers(e){return!!this.children.length&&(e<0?this.children[0].covers(-1):this.lastChild.covers(1))}get domAttrs(){return this.wrapper.attributes}static of(e,t){let n=new Bx(t||document.createElement(e.tagName),e);return t||(n.flags|=4),n}}class Fx extends Lx{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(e,t,n){let r=new Fx(t||document.createElement("div"),e);return t&&n||(r.flags|=4),r}get domAttrs(){return this.attrs}resolveInline(e,t,n){let r=null,i=-1,o=null,s=-1;!function e(a,l){for(let c=0,u=0;c<a.children.length&&u<=l;c++){let h=a.children[c],d=u+h.length;d>=l&&(h.isComposite()?e(h,l-u):(!o||o.isHidden&&(t>0||n&&jx(o,h)))&&(d>l||32&h.flags)?(o=h,s=l-u):(u<l||16&h.flags&&!h.isHidden)&&(r=h,i=l-u)),u=d}}(this,e);let a=(t<0?r:o)||r||o;return a?{tile:a,offset:a==r?i:s}:null}coordsIn(e,t){let n=this.resolveInline(e,t,!0);return n?n.tile.coordsIn(Math.max(0,n.offset),t):function(e){let t=e.dom.lastChild;if(!t)return e.dom.getBoundingClientRect();let n=pw(t);return n[n.length-1]||null}(this)}domIn(e,t){let n=this.resolveInline(e,t);if(n){let{tile:e,offset:r}=n;if(this.dom.contains(e.dom))return e.isText()?new Dw(e.dom,Math.min(e.dom.nodeValue.length,r)):e.domPosFor(r,16&e.flags?1:32&e.flags?-1:t);let i=n.tile.parent,o=!1;for(let e of i.children){if(o)return new Dw(e.dom,0);e==n.tile&&(o=!0)}}return new Dw(this.dom,0)}}function jx(e,t){let n=e.coordsIn(0,1),r=t.coordsIn(0,1);return n&&r&&r.top<n.bottom}class Wx extends Lx{constructor(e,t){super(e),this.mark=t}get domAttrs(){return this.mark.attrs}static of(e,t){let n=new Wx(t||document.createElement(e.tagName),e);return t||(n.flags|=4),n}}class zx extends Px{constructor(e,t){super(e,t.length),this.text=t}sync(e){2&this.flags||(super.sync(e),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text))}isText(){return!0}toString(){return JSON.stringify(this.text)}coordsIn(e,t){let n=this.dom.nodeValue.length;e>n&&(e=n);let r=e,i=e,o=0;0==e&&t<0||e==n&&t>=0?Xy.chrome||Xy.gecko||(e?(r--,o=1):i<n&&(i++,o=-1)):t<0?r--:i<n&&i++;let s=Ow(this.dom,r,i).getClientRects();if(!s.length)return null;let a=s[(o?o<0:t>=0)?0:s.length-1];return Xy.safari&&!o&&0==a.width&&(a=Array.prototype.find.call(s,e=>e.width)||a),o?ww(a,o<0):a||null}static of(e,t){let n=new zx(t||document.createTextNode(e),e);return t||(n.flags|=2),n}}class Hx extends Px{constructor(e,t,n,r){super(e,t,r),this.widget=n}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return!(48&this.flags)&&(this.flags&(e<0?64:128))>0}coordsIn(e,t){return this.coordsInWidget(e,t,!1)}coordsInWidget(e,t,n){let r=this.widget.coordsAt(this.dom,e,t);if(r)return r;if(n)return ww(this.dom.getBoundingClientRect(),this.length?0==e:t<=0);{let t=this.dom.getClientRects(),n=null;if(!t.length)return null;let r=!!(16&this.flags)||!(32&this.flags)&&e>0;for(let i=r?t.length-1:0;n=t[i],!(e>0?0==i:i==t.length-1||n.top<n.bottom);i+=r?-1:1);return ww(n,!r)}}get overrideDOMText(){if(!this.length)return Hv.empty;let{root:e}=this;if(!e)return Hv.empty;let t=this.posAtStart;return e.view.state.doc.slice(t,t+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(e,t,n,r,i){return i||(i=e.toDOM(t),e.editable||(i.contentEditable="false")),new Hx(i,n,e,r)}}class Vx extends Px{constructor(e){let t=document.createElement("img");t.className="cm-widgetBuffer",t.setAttribute("aria-hidden","true"),super(t,0,e)}get isHidden(){return!0}get overrideDOMText(){return Hv.empty}coordsIn(e){return this.dom.getBoundingClientRect()}}class qx{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,n){let{tile:r,index:i,beforeBreak:o,parents:s}=this;for(;e||t>0;)if(r.isComposite())if(o){if(!e)break;n&&n.break(),e--,o=!1}else if(i==r.children.length){if(!e&&!s.length)break;n&&n.leave(r),o=!!r.breakAfter,({tile:r,index:i}=s.pop()),i++}else{let a=r.children[i],l=a.breakAfter;!(t>0?a.length<=e:a.length<e)||n&&!1===n.skip(a,0,a.length)&&a.isComposite?(s.push({tile:r,index:i}),r=a,i=0,n&&a.isComposite()&&n.enter(a)):(o=!!l,i++,e-=a.length)}else if(i==r.length)o=!!r.breakAfter,({tile:r,index:i}=s.pop()),i++;else{if(!e)break;{let t=Math.min(e,r.length-i);n&&n.skip(r,i,i+t),e-=t,i+=t}}return this.tile=r,this.index=i,this.beforeBreak=o,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}}class Ux{constructor(e,t,n,r){this.from=e,this.to=t,this.wrapper=n,this.rank=r}}class $x{constructor(e,t,n){this.cache=e,this.root=t,this.blockWrappers=n,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(e,t,n,r){var i;this.flushBuffer();let o=this.ensureMarks(t,n),s=o.lastChild;if(!s||!s.isText()||8&s.flags)o.append(r||zx.of(e,null===(i=this.cache.find(zx))||void 0===i?void 0:i.dom));else{this.cache.reused.set(s,2),(o.children[o.children.length-1]=new zx(s.dom,s.text+e)).parent=o}this.pos+=e.length,this.afterWidget=null}addComposition(e,t){let n=this.curLine;n.dom!=t.line.dom&&(n.setDOM(this.cache.reused.has(t.line)?Zx(t.line.dom):t.line.dom),this.cache.reused.set(t.line,2));let r=n;for(let e=t.marks.length-1;e>=0;e--){let n=t.marks[e],i=r.lastChild;if(i instanceof Wx&&i.mark.eq(n.mark))i.dom!=n.dom&&i.setDOM(Zx(n.dom)),r=i;else{if(this.cache.reused.get(n)){let e=Px.get(n.dom);e&&e.setDOM(Zx(n.dom))}let e=Wx.of(n.mark,n.dom);r.append(e),r=e}this.cache.reused.set(n,2)}let i=Px.get(e.text);i&&this.cache.reused.set(i,2);let o=new zx(e.text,e.text.nodeValue);o.flags|=8,r.append(o)}addInlineWidget(e,t,n){let r=this.afterWidget&&48&e.flags&&(48&this.afterWidget.flags)==(48&e.flags);r||this.flushBuffer();let i=this.ensureMarks(t,n);r||16&e.flags||i.append(this.getBuffer(1)),i.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,n){this.flushBuffer(),this.ensureMarks(t,n).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){(this.afterWidget||this.lastBlock).length+=e,this.pos+=e}addLineStart(e,t){var n;e||(e=Qx);let r=Fx.start(e,t||(null===(n=this.cache.find(Fx))||void 0===n?void 0:n.dom),!!t);this.getBlockPos().append(this.lastBlock=this.curLine=r)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,t){var n;let r=this.curLine;for(let i=e.length-1;i>=0;i--){let o,s=e[i];if(t>0&&(o=r.lastChild)&&o instanceof Wx&&o.mark.eq(s))r=o,t--;else{let e=Wx.of(s,null===(n=this.cache.find(Wx,e=>e.mark.eq(s)))||void 0===n?void 0:n.dom);r.append(e),r=e,t=0}}return r}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;e&&Jx(this.curLine,!1)&&("BR"==e.dom.nodeName||!e.isWidget()||Xy.ios&&Jx(this.curLine,!0))||this.curLine.append(this.cache.findWidget(tk,0,32)||new Hx(tk.toDOM(),0,tk,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to<this.pos&&this.wrappers.splice(e,1);for(let e=this.blockWrappers;e.value&&e.from<=this.pos;e.next())if(e.to>=this.pos){let t=new Ux(e.from,e.to,e.value,e.rank),n=this.wrappers.length;for(;n>0&&(this.wrappers[n-1].rank-t.rank||this.wrappers[n-1].to-t.to)<0;)n--;this.wrappers.splice(n,0,t)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let t=this.root;for(let n of this.wrappers){let r=t.lastChild;if(n.from<this.pos&&r instanceof Bx&&r.wrapper.eq(n.wrapper))t=r;else{let r=Bx.of(n.wrapper,null===(e=this.cache.find(Bx,e=>e.wrapper.eq(n.wrapper)))||void 0===e?void 0:e.dom);t.append(r),t=r}}return t}blockPosCovered(){let e=this.lastBlock;return null!=e&&!e.breakAfter&&(!e.isWidget()||(160&e.flags)>0)}getBuffer(e){let t=2|(e<0?16:32),n=this.cache.find(Vx,void 0,1);return n&&(n.flags=t),n||new Vx(t)}flushBuffer(){!this.afterWidget||32&this.afterWidget.flags||(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class Kx{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:t,lineBreak:n,done:r}=this.cursor.next(this.skipCount);if(this.skipCount=0,r)throw new Error("Ran out of text content when drawing inline views");this.text=t;let i=this.textOff=Math.min(e,t.length);return n?null:t.slice(0,i)}let t=Math.min(this.text.length,this.textOff+e),n=this.text.slice(this.textOff,t);return this.textOff=t,n}}const Yx=[Hx,Fx,zx,Wx,Vx,Bx,_x];for(let e=0;e<Yx.length;e++)Yx[e].bucket=e;class Gx{constructor(e){this.view=e,this.buckets=Yx.map(()=>[]),this.index=Yx.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,n=this.buckets[t];n.length<6?n.push(e):n[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,n=2){let r=e.bucket,i=this.buckets[r],o=this.index[r];for(let e=i.length-1;e>=0;e--){let s=(e+o)%i.length,a=i[s];if((!t||t(a))&&!this.reused.has(a))return i.splice(s,1),s<o&&this.index[r]--,this.reused.set(a,n),a}return null}findWidget(e,t,n){let r=this.buckets[0];if(r.length)for(let i=0,o=0;;i++){if(i==r.length){if(o)return null;o=1,i=0}let s=r[i];if(!this.reused.has(s)&&(0==o?s.widget.compare(e):s.widget.constructor==e.constructor&&e.updateDOM(s.dom,this.view)))return r.splice(i,1),i<this.index[0]&&this.index[0]--,s.widget==e&&s.length==t&&(497&s.flags)==n?(this.reused.set(s,1),s):(this.reused.set(s,2),new Hx(s.dom,t,e,-498&s.flags|n))}}reuse(e){return this.reused.set(e,1),e}maybeReuse(e,t=2){if(!this.reused.has(e))return this.reused.set(e,t),e.dom}clear(){for(let e=0;e<this.buckets.length;e++)this.buckets[e].length=this.index[e]=0}}class Xx{constructor(e,t,n,r,i){this.view=e,this.decorations=r,this.disallowBlockEffectsFor=i,this.openWidget=!1,this.openMarks=0,this.cache=new Gx(e),this.text=new Kx(e.state.doc),this.builder=new $x(this.cache,new _x(e,e.contentDOM),hy.iter(n)),this.cache.reused.set(t,2),this.old=new qx(t),this.reuseWalker={skip:(e,t,n)=>{if(this.cache.add(e),e.isComposite())return!1},enter:e=>this.cache.add(e),leave:()=>{},break:()=>{}}}run(e,t){let n=t&&this.getCompositionContext(t.text);for(let r=0,i=0,o=0;;){let s=o<e.length?e[o++]:null,a=s?s.fromA:this.old.root.length;if(a>r){let e=a-r;this.preserve(e,!o,!s),r=a,i+=e}if(!s)break;t&&s.fromA<=t.range.fromA&&s.toA>=t.range.toA?(this.forward(s.fromA,t.range.fromA,t.range.fromA<t.range.toA?1:-1),this.emit(i,t.range.fromB),this.cache.clear(),this.builder.addComposition(t,n),this.text.skip(t.range.toB-t.range.fromB),this.forward(t.range.fromA,s.toA),this.emit(t.range.toB,s.toB)):(this.forward(s.fromA,s.toA),this.emit(i,s.toB)),i=s.toB,r=s.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(e,t,n){let r=function(e){let t=[];for(let n=e.parents.length;n>1;n--){let r=n==e.parents.length?e.tile:e.parents[n].tile;r instanceof Wx&&t.push(r.mark)}return t}(this.old),i=this.openMarks;this.old.advance(e,n?1:-1,{skip:(e,t,n)=>{if(e.isWidget())if(this.openWidget)this.builder.continueWidget(n-t);else{let o=n>0||t<e.length?Hx.of(e.widget,this.view,n-t,496&e.flags,this.cache.maybeReuse(e)):this.cache.reuse(e);256&o.flags?(o.flags&=-2,this.builder.addBlockWidget(o)):(this.builder.ensureLine(null),this.builder.addInlineWidget(o,r,i),i=r.length)}else if(e.isText())this.builder.ensureLine(null),t||n!=e.length?(this.cache.add(e),this.builder.addText(e.text.slice(t,n),r,i)):this.builder.addText(e.text,r,i,this.cache.reuse(e)),i=r.length;else if(e.isLine())e.flags&=-2,this.cache.reused.set(e,1),this.builder.addLine(e);else if(e instanceof Vx)this.cache.add(e);else{if(!(e instanceof Wx))return!1;this.builder.ensureLine(null),this.builder.addMark(e,r,i),this.cache.reused.set(e,1),i=r.length}this.openWidget=!1},enter:e=>{e.isLine()?this.builder.addLineStart(e.attrs,this.cache.maybeReuse(e)):(this.cache.add(e),e instanceof Wx&&r.unshift(e.mark)),this.openWidget=!1},leave:e=>{e.isLine()?r.length&&(r.length=i=0):e instanceof Wx&&(r.shift(),i=Math.min(i,r.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let n=null,r=this.builder,i=0,o=hy.spans(this.decorations,e,t,{point:(e,t,o,s,a,l)=>{if(o instanceof aw){if(this.disallowBlockEffectsFor[l]){if(o.block)throw new RangeError("Block decorations may not be specified via plugins");if(t>this.view.state.doc.lineAt(e).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(i=s.length,a>s.length)r.continueWidget(t-e);else{let i=o.widget||(o.block?ek.block:ek.inline),l=function(e){let t=e.isReplace?(e.startSide<0?64:0)|(e.endSide>0?128:0):e.startSide>0?32:16;e.block&&(t|=256);return t}(o),c=this.cache.findWidget(i,t-e,l)||Hx.of(i,this.view,t-e,l);o.block?(o.startSide>0&&r.addLineStartIfNotCovered(n),r.addBlockWidget(c)):(r.ensureLine(n),r.addInlineWidget(c,s,a))}n=null}else n=function(e,t){let n=t.spec.attributes,r=t.spec.class;if(!n&&!r)return e;e||(e={class:"cm-line"});n&&Jy(n,e);r&&(e.class+=" "+r);return e}(n,o);t>e&&this.text.skip(t-e)},span:(e,t,i,o)=>{for(let s=e;s<t;){let e=this.text.next(Math.min(512,t-s));null==e?(r.addLineStartIfNotCovered(n),r.addBreak(),s++):(r.ensureLine(n),r.addText(e,i,o),s+=e.length),n=null}}});r.addLineStartIfNotCovered(n),this.openWidget=o>i,this.openMarks=o}forward(e,t,n=1){t-e<=10?this.old.advance(t-e,n,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,n,this.reuseWalker))}getCompositionContext(e){let t=[],n=null;for(let r=e.parentNode;;r=r.parentNode){let e=Px.get(r);if(r==this.view.contentDOM)break;e instanceof Wx?t.push(e):(null==e?void 0:e.isLine())?n=e:"DIV"!=r.nodeName||n||r==this.view.contentDOM?t.push(Wx.of(new ow({tagName:r.nodeName.toLowerCase(),attributes:tw(r)}),r)):n=new Fx(r,Qx)}return{line:n,marks:t}}}function Jx(e,t){let n=e=>{for(let r of e.children)if((t?r.isText():r.length)||n(r))return!0;return!1};return n(e)}const Qx={class:"cm-line"};function Zx(e){let t=Px.get(e);return t&&t.setDOM(e.cloneNode()),e}class ek extends nw{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}ek.inline=new ek("span"),ek.block=new ek("div");const tk=new class extends nw{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class nk{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=iw.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new _x(e,e.contentDOM),this.updateInner([new Tx(0,0,0,e.state.doc.length)],null)}update(e){var t;let n=e.changedRanges;this.minWidth>0&&n.length&&(n.every(({fromA:e,toA:t})=>t<this.minWidthFrom||e>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let r=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&((null===(t=this.domChanged)||void 0===t?void 0:t.newSel)?r=this.domChanged.newSel.head:function(e,t){let n=!1;t&&e.iterChangedRanges((e,r)=>{e<t.to&&r>t.from&&(n=!0)});return n}(e.changes,this.hasComposition)||e.selectionSet||(r=e.state.selection.main.head));let i=r>-1?function(e,t,n){let r=ik(e,n);if(!r)return null;let{node:i,from:o,to:s}=r,a=i.nodeValue;if(/[\n\r]/.test(a))return null;if(e.state.doc.sliceString(r.from,r.to)!=a)return null;let l=t.invertedDesc;return{range:new Tx(l.mapPos(o),l.mapPos(s),o,s),text:i}}(this.view,e.changes,r):null;if(this.domChanged=null,this.hasComposition){let{from:t,to:r}=this.hasComposition;n=new Tx(t,r,e.changes.mapPos(t,-1),e.changes.mapPos(r,1)).addToSet(n.slice())}this.hasComposition=i?{from:i.range.fromB,to:i.range.toB}:null,(Xy.ie||Xy.chrome)&&!i&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,s=this.blockWrappers;this.updateDeco();let a=function(e,t,n){let r=new ok;return hy.compare(e,t,n,r),r.changes}(o,this.decorations,e.changes);a.length&&(n=Tx.extendWithRanges(n,a));let l=function(e,t,n){let r=new sk;return hy.compare(e,t,n,r),r.changes}(s,this.blockWrappers,e.changes);return l.length&&(n=Tx.extendWithRanges(n,l)),i&&!n.some(e=>e.fromA<=i.range.fromA&&e.toA>=i.range.toA)&&(n=i.range.addToSet(n.slice())),!(2&this.tile.flags&&0==n.length)&&(this.updateInner(n,i),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:n}=this.view;n.ignore(()=>{if(t||e.length){let n=this.tile,r=new Xx(this.view,n,this.blockWrappers,this.decorations,this.dynamicDecorationMap);this.tile=r.run(e,t),rk(n,r.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let r=Xy.chrome||Xy.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(r),!r||!r.written&&n.selectionRange.focusNode==r.node&&this.tile.dom.contains(r.node)||(this.forceSelection=!0),this.tile.dom.style.height=""});let r=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let e of this.tile.children)e.isWidget()&&e.widget instanceof ak&&r.push(e.dom);n.updateGaps(r)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let t of e.transactions)for(let e of t.effects)e.is(dx)&&(this.editContextFormatting=e.value)}updateSelection(e=!1,t=!1){!e&&this.view.observer.selectionRange.focusNode||this.view.observer.readSelectionRange();let{dom:n}=this.tile,r=this.view.root.activeElement,i=r==n,o=!i&&!(this.view.state.facet(px)||n.tabIndex>-1)&&fw(n,this.view.observer.selectionRange)&&!(r&&n.contains(r));if(!(i||t||o))return;let s=this.forceSelection;this.forceSelection=!1;let a,l,c=this.view.state.selection.main;if(c.empty?l=a=this.inlineDOMNearPos(c.anchor,c.assoc||1):(l=this.inlineDOMNearPos(c.head,c.head==c.from?1:-1),a=this.inlineDOMNearPos(c.anchor,c.anchor==c.from?1:-1)),Xy.gecko&&c.empty&&!this.hasComposition&&(1==(u=a).node.nodeType&&u.node.firstChild&&(0==u.offset||"false"==u.node.childNodes[u.offset-1].contentEditable)&&(u.offset==u.node.childNodes.length||"false"==u.node.childNodes[u.offset].contentEditable))){let e=document.createTextNode("");this.view.observer.ignore(()=>a.node.insertBefore(e,a.node.childNodes[a.offset]||null)),a=l=new Dw(e,0),s=!0}var u;let h=this.view.observer.selectionRange;!s&&h.focusNode&&(mw(a.node,a.offset,h.anchorNode,h.anchorOffset)&&mw(l.node,l.offset,h.focusNode,h.focusOffset)||this.suppressWidgetCursorChange(h,c))||(this.view.observer.ignore(()=>{Xy.android&&Xy.chrome&&n.contains(h.focusNode)&&function(e,t){for(let n=e;n&&n!=t;n=n.assignedSlot||n.parentNode)if(1==n.nodeType&&"false"==n.contentEditable)return!0;return!1}(h.focusNode,n)&&(n.blur(),n.focus({preventScroll:!0}));let e=hw(this.view.root);if(e)if(c.empty){if(Xy.gecko){let e=function(e,t){return 1!=e.nodeType?0:(t&&"false"==e.childNodes[t-1].contentEditable?1:0)|(t<e.childNodes.length&&"false"==e.childNodes[t].contentEditable?2:0)}(a.node,a.offset);if(e&&3!=e){let t=(1==e?Tw:Rw)(a.node,a.offset);t&&(a=new Dw(t.node,t.offset))}}e.collapse(a.node,a.offset),null!=c.bidiLevel&&void 0!==e.caretBidiLevel&&(e.caretBidiLevel=c.bidiLevel)}else if(e.extend){e.collapse(a.node,a.offset);try{e.extend(l.node,l.offset)}catch(e){}}else{let t=document.createRange();c.anchor>c.head&&([a,l]=[l,a]),t.setEnd(l.node,l.offset),t.setStart(a.node,a.offset),e.removeAllRanges(),e.addRange(t)}else;o&&this.view.root.activeElement==n&&(n.blur(),r&&r.focus())}),this.view.observer.setSelectionRange(a,l)),this.impreciseAnchor=a.precise?null:new Dw(h.anchorNode,h.anchorOffset),this.impreciseHead=l.precise?null:new Dw(h.focusNode,h.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&mw(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,n=hw(e.root),{anchorNode:r,anchorOffset:i}=e.observer.selectionRange;if(!(n&&t.empty&&t.assoc&&n.modify))return;let o=this.lineAt(t.head,t.assoc);if(!o)return;let s=o.posAtStart;if(t.head==s||t.head==s+o.length)return;let a=this.coordsAt(t.head,-1),l=this.coordsAt(t.head,1);if(!a||!l||a.bottom>l.top)return;let c=this.domAtPos(t.head+t.assoc,t.assoc);n.collapse(c.node,c.offset),n.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let u=e.observer.selectionRange;e.docView.posFromDOM(u.anchorNode,u.anchorOffset)!=t.from&&n.collapse(r,i)}posFromDOM(e,t){let n=this.tile.nearest(e);if(!n)return 2&this.tile.dom.compareDocumentPosition(e)?0:this.view.state.doc.length;let r=n.posAtStart;if(!n.isComposite())return n.isText()?e==n.dom?r+t:r+(t?n.length:0):r;{let i;if(e==n.dom)i=n.dom.childNodes[t];else{let r=0==yw(e)?0:0==t?-1:1;for(;;){let t=e.parentNode;if(t==n.dom)break;0==r&&t.firstChild!=t.lastChild&&(r=e==t.firstChild?-1:1),e=t}i=r<0?e:e.nextSibling}if(i==n.dom.firstChild)return r;for(;i&&!Px.get(i);)i=i.nextSibling;if(!i)return r+n.length;for(let e=0,t=r;;e++){let r=n.children[e];if(r.dom==i)return t;t+=r.length+r.breakAfter}}}domAtPos(e,t){let{tile:n,offset:r}=this.tile.resolveBlock(e,t);return n.isWidget()?n.domPosFor(e,t):n.domIn(r,t)}inlineDOMNearPos(e,t){let n,r,i=-1,o=!1,s=-1,a=!1;return this.tile.blockTiles((t,l)=>{if(t.isWidget()){if(32&t.flags&&l>=e)return!0;16&t.flags&&(o=!0)}else{let c=l+t.length;if(l<=e&&(n=t,i=e-l,o=c<e),c>=e&&!r&&(r=t,s=e-l,a=l>e),l>e&&r)return!0}}),n||r?(o&&r?n=null:a&&n&&(r=null),n&&t<0||!r?n.domIn(i,t):r.domIn(s,t)):this.domAtPos(e,t)}coordsAt(e,t){let{tile:n,offset:r}=this.tile.resolveBlock(e,t);return n.isWidget()?n.widget instanceof ak?null:n.coordsInWidget(r,t,!0):n.coordsIn(r,t)}lineAt(e,t){let{tile:n}=this.tile.resolveBlock(e,t);return n.isLine()?n:null}coordsForChar(e){let{tile:t,offset:n}=this.tile.resolveBlock(e,1);if(!t.isLine())return null;return function e(t,n){if(t.isComposite())for(let r of t.children){if(r.length>=n){let t=e(r,n);if(t)return t}if((n-=r.length)<0)break}else if(t.isText()&&n<t.length){let e=Qv(t.text,n);if(e==n)return null;let r=Ow(t.dom,n,e).getClientRects();for(let e=0;e<r.length;e++){let t=r[e];if(e==r.length-1||t.top<t.bottom&&t.left<t.right)return t}}return null}(t,n)}measureVisibleLineHeights(e){let t=[],{from:n,to:r}=e,i=this.view.contentDOM.clientWidth,o=i>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,s=-1,a=this.view.textDirection==Pw.LTR,l=0,c=(e,u,h)=>{for(let d=0;d<e.children.length&&!(u>r);d++){let r=e.children[d],f=u+r.length,p=r.dom.getBoundingClientRect(),{height:m}=p;if(h&&!d&&(l+=p.top-h.top),r instanceof Bx)f>n&&c(r,u,p);else if(u>=n&&(l>0&&t.push(-l),t.push(m+l),l=0,o)){let e=r.dom.lastChild,t=e?pw(e):[];if(t.length){let e=t[t.length-1],n=a?e.right-p.left:p.right-e.left;n>s&&(s=n,this.minWidth=i,this.minWidthFrom=u,this.minWidthTo=f)}}h&&d==e.children.length-1&&(l+=h.bottom-p.bottom),u=f+r.breakAfter}};return c(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return"rtl"==getComputedStyle(t.dom).direction?Pw.RTL:Pw.LTR}measureTextSize(){let e=this.tile.blockTiles(e=>{if(e.isLine()&&e.children.length&&e.length<=20){let t,n=0;for(let r of e.children){if(!r.isText()||/[^ -~]/.test(r.text))return;let e=pw(r.dom);if(1!=e.length)return;n+=e[0].width,t=e[0].height}if(n)return{lineHeight:e.dom.getBoundingClientRect().height,charWidth:n/e.length,textHeight:t}}});if(e)return e;let t,n,r,i=document.createElement("div");return i.className="cm-line",i.style.width="99999px",i.style.position="absolute",i.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(i);let e=pw(i.firstChild)[0];t=i.getBoundingClientRect().height,n=e&&e.width?e.width/27:7,r=e&&e.height?e.height:t,i.remove()}),{lineHeight:t,charWidth:n,textHeight:r}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let n=0,r=0;;r++){let i=r==t.viewports.length?null:t.viewports[r],o=i?i.from-1:this.view.state.doc.length;if(o>n){let r=(t.lineBlockAt(o).bottom-t.lineBlockAt(n).top)/this.view.scaleY;e.push(iw.replace({widget:new ak(r),block:!0,inclusive:!0,isBlockGap:!0}).range(n,o))}if(!i)break;n=i.to+1}return iw.set(e)}updateDeco(){let e=1,t=this.view.state.facet(xx).map(t=>(this.dynamicDecorationMap[e++]="function"==typeof t)?t(this.view):t),n=!1,r=this.view.state.facet(Sx).map((e,t)=>{let r="function"==typeof e;return r&&(n=!0),r?e(this.view):e});for(r.length&&(this.dynamicDecorationMap[e++]=n,t.push(hy.join(r))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;this.blockWrappers=this.view.state.facet(kx).map(e=>"function"==typeof e?e(this.view):e)}scrollIntoView(e){if(e.isSnapshot){let t=this.view.viewState.lineBlockAt(e.range.head);return this.view.scrollDOM.scrollTop=t.top-e.yMargin,void(this.view.scrollDOM.scrollLeft=e.xMargin)}for(let t of this.view.state.facet(cx))try{if(t(this.view,e.range,e))return!0}catch(e){fx(this.view.state,e,"scroll handler")}let t,{range:n}=e,r=this.coordsAt(n.head,n.empty?n.assoc:n.head>n.anchor?-1:1);if(!r)return;!n.empty&&(t=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(r={left:Math.min(r.left,t.left),top:Math.min(r.top,t.top),right:Math.max(r.right,t.right),bottom:Math.max(r.bottom,t.bottom)});let i=Ax(this.view),o={left:r.left-i.left,top:r.top-i.top,right:r.right+i.right,bottom:r.bottom+i.bottom},{offsetWidth:s,offsetHeight:a}=this.view.scrollDOM;!function(e,t,n,r,i,o,s,a){let l=e.ownerDocument,c=l.defaultView||window;for(let u=e,h=!1;u&&!h;)if(1==u.nodeType){let e,d=u==l.body,f=1,p=1;if(d)e=xw(c);else{if(/^(fixed|sticky)$/.test(getComputedStyle(u).position)&&(h=!0),u.scrollHeight<=u.clientHeight&&u.scrollWidth<=u.clientWidth){u=u.assignedSlot||u.parentNode;continue}let t=u.getBoundingClientRect();({scaleX:f,scaleY:p}=kw(u,t)),e={left:t.left,right:t.left+u.clientWidth*f,top:t.top,bottom:t.top+u.clientHeight*p}}let m=0,g=0;if("nearest"==i)t.top<e.top?(g=t.top-(e.top+s),n>0&&t.bottom>e.bottom+g&&(g=t.bottom-e.bottom+s)):t.bottom>e.bottom&&(g=t.bottom-e.bottom+s,n<0&&t.top-g<e.top&&(g=t.top-(e.top+s)));else{let r=t.bottom-t.top,o=e.bottom-e.top;g=("center"==i&&r<=o?t.top+r/2-o/2:"start"==i||"center"==i&&n<0?t.top-s:t.bottom-o+s)-e.top}if("nearest"==r?t.left<e.left?(m=t.left-(e.left+o),n>0&&t.right>e.right+m&&(m=t.right-e.right+o)):t.right>e.right&&(m=t.right-e.right+o,n<0&&t.left<e.left+m&&(m=t.left-(e.left+o))):m=("center"==r?t.left+(t.right-t.left)/2-(e.right-e.left)/2:"start"==r==a?t.left-o:t.right-(e.right-e.left)+o)-e.left,m||g)if(d)c.scrollBy(m,g);else{let e=0,n=0;if(g){let e=u.scrollTop;u.scrollTop+=g/p,n=(u.scrollTop-e)*p}if(m){let t=u.scrollLeft;u.scrollLeft+=m/f,e=(u.scrollLeft-t)*f}t={left:t.left-e,top:t.top-n,right:t.right-e,bottom:t.bottom-n},e&&Math.abs(e-m)<1&&(r="nearest"),n&&Math.abs(n-g)<1&&(i="nearest")}if(d)break;(t.top<e.top||t.bottom>e.bottom||t.left<e.left||t.right>e.right)&&(t={left:Math.max(t.left,e.left),right:Math.min(t.right,e.right),top:Math.max(t.top,e.top),bottom:Math.min(t.bottom,e.bottom)}),u=u.assignedSlot||u.parentNode}else{if(11!=u.nodeType)break;u=u.host}}(this.view.scrollDOM,o,n.head<n.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,s),-s),Math.max(Math.min(e.yMargin,a),-a),this.view.textDirection==Pw.LTR)}lineHasWidget(e){let t=e=>e.isWidget()||e.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){rk(this.tile)}}function rk(e,t){let n=null==t?void 0:t.get(e);if(1!=n){null==n&&e.destroy();for(let n of e.children)rk(n,t)}}function ik(e,t){let n=e.observer.selectionRange;if(!n.focusNode)return null;let r=Tw(n.focusNode,n.focusOffset),i=Rw(n.focusNode,n.focusOffset),o=r||i;if(i&&r&&i.node!=r.node){let t=Px.get(i.node);if(!t||t.isText()&&t.text!=i.node.nodeValue)o=i;else if(e.docView.lastCompositionAfterCursor){let e=Px.get(r.node);!e||e.isText()&&e.text!=r.node.nodeValue||(o=i)}}if(e.docView.lastCompositionAfterCursor=o!=r,!o)return null;let s=t-o.offset;return{from:s,to:s+o.node.nodeValue.length,node:o.node}}let ok=class{constructor(){this.changes=[]}compareRange(e,t){cw(e,t,this.changes)}comparePoint(e,t){cw(e,t,this.changes)}boundChange(e){cw(e,e,this.changes)}};class sk{constructor(){this.changes=[]}compareRange(e,t){cw(e,t,this.changes)}comparePoint(){}boundChange(e){cw(e,e,this.changes)}}class ak extends nw{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function lk(e,t,n){let r=e.lineBlockAt(t);if(Array.isArray(r.type)){let e;for(let i of r.type){if(i.from>t)break;if(!(i.to<t)){if(i.from<t&&i.to>t)return i;e&&(i.type!=rw.Text||e.type==i.type&&!(n<0?i.from<t:i.to>t))||(e=i)}}return e||r}return r}function ck(e,t,n,r){let i=e.state.doc.lineAt(t.head),o=e.bidiSpans(i),s=e.textDirectionAt(i.from);for(let a=t,l=null;;){let t=Xw(i,o,s,a,n),c=Gw;if(!t){if(i.number==(n?e.state.doc.lines:1))return a;c="\n",i=e.state.doc.line(i.number+(n?1:-1)),o=e.bidiSpans(i),t=e.visualLineSide(i,!n)}if(l){if(!l(c))return a}else{if(!r)return t;l=r(c)}a=t}}function uk(e,t,n){for(;;){let r=0;for(let i of e)i.between(t-1,t+1,(e,i,o)=>{if(t>e&&t<i){let o=r||n||(t-e<i-t?-1:1);t=o<0?e:i,r=o}});if(!r)return t}}function hk(e,t){let n=null;for(let r=0;r<t.ranges.length;r++){let i=t.ranges[r],o=null;if(i.empty){let t=uk(e,i.from,0);t!=i.from&&(o=fb.cursor(t,-1))}else{let t=uk(e,i.from,-1),n=uk(e,i.to,1);t==i.from&&n==i.to||(o=fb.range(i.from==i.anchor?t:n,i.from==i.head?t:n))}o&&(n||(n=t.ranges.slice()),n[r]=o)}return n?fb.create(n,t.mainIndex):t}function dk(e,t,n){let r=uk(e.state.facet(Ex).map(t=>t(e)),n.from,t.head>n.from?-1:1);return r==n.from?n:fb.cursor(r,r<n.from?1:-1)}class fk{constructor(e,t){this.pos=e,this.assoc=t}}function pk(e,t,n,r){let i,o=e.contentDOM.getBoundingClientRect(),s=o.top+e.viewState.paddingTop,{x:a,y:l}=t,c=l-s;for(;;){if(c<0)return new fk(0,1);if(c>e.viewState.docHeight)return new fk(e.state.doc.length,-1);if(i=e.elementAtHeight(c),null==r)break;if(i.type==rw.Text){let t=e.docView.coordsAt(r<0?i.from:i.to,r);if(t&&(r<0?t.top<=c+s:t.bottom>=c+s))break}let t=e.viewState.heightOracle.textHeight/2;c=r>0?i.bottom+t:i.top-t}if(e.viewport.from>=i.to||e.viewport.to<=i.from){if(n)return null;if(i.type==rw.Text){let t=function(e,t,n,r,i){let o=Math.round((r-t.left)*e.defaultCharacterWidth);if(e.lineWrapping&&n.height>1.5*e.defaultLineHeight){let t=e.viewState.heightOracle.textHeight;o+=Math.floor((i-n.top-.5*(e.defaultLineHeight-t))/t)*e.viewState.heightOracle.lineLength}let s=e.state.sliceDoc(n.from,n.to);return n.from+Ey(s,o,e.state.tabSize)}(e,o,i,a,l);return new fk(t,t==i.from?1:-1)}}if(i.type!=rw.Text)return c<(i.top+i.bottom)/2?new fk(i.from,1):new fk(i.to,-1);let u=e.docView.lineAt(i.from,2);return u&&u.length==i.length||(u=e.docView.lineAt(i.from,-2)),mk(e,u,i.from,a,l)}function mk(e,t,n,r,i){let o=-1,s=null,a=1e9,l=1e9,c=i,u=i,h=(e,t)=>{for(let n=0;n<e.length;n++){let h=e[n];if(h.top==h.bottom)continue;let d=h.left>r?h.left-r:h.right<r?r-h.right:0,f=h.top>i?h.top-i:h.bottom<i?i-h.bottom:0;h.top<=u&&h.bottom>=c&&(c=Math.min(h.top,c),u=Math.max(h.bottom,u),f=0),(o<0||(f-l||d-a)<0)&&(o>=0&&l&&a<d&&s.top<=u-2&&s.bottom>=c+2?l=0:(o=t,a=d,l=f,s=h))}};if(t.isText()){for(let e=0;e<t.length;){let n=Qv(t.text,e);if(h(Ow(t.dom,e,n).getClientRects(),e),!a&&!l)break;e=n}return r>(s.left+s.right)/2==(gk(e,o+n)==Pw.LTR)?new fk(n+Qv(t.text,o),-1):new fk(n+o,1)}{if(!t.length)return new fk(n,1);for(let e=0;e<t.children.length;e++){let n=t.children[e];if(!(48&n.flags)&&(h((1==n.dom.nodeType?n.dom:Ow(n.dom,0,n.length)).getClientRects(),e),!a&&!l))break}let c=t.children[o],u=t.posBefore(c,n);return c.isComposite()||c.isText()?mk(e,c,u,Math.max(s.left,Math.min(s.right,r)),i):r>(s.left+s.right)/2==(gk(e,o+n)==Pw.LTR)?new fk(u+c.length,-1):new fk(u,1)}}function gk(e,t){let n=e.state.doc.lineAt(t);return e.bidiSpans(n)[Vw.find(e.bidiSpans(n),t-n.from,-1,1)].dir}const vk="￿";class bk{constructor(e,t){this.points=e,this.view=t,this.text="",this.lineSeparator=t.state.facet(iy.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=vk}readRange(e,t){if(!e)return this;let n=e.parentNode;for(let r=e;;){this.findPointBefore(n,r);let e=this.text.length;this.readNode(r);let i=Px.get(r),o=r.nextSibling;if(o==t){(null==i?void 0:i.breakAfter)&&!o&&n!=this.view.contentDOM&&this.lineBreak();break}let s=Px.get(o);(i&&s?i.breakAfter:(i?i.breakAfter:vw(r))||vw(o)&&("BR"!=r.nodeName||(null==i?void 0:i.isWidget()))&&this.text.length>e)&&!wk(o,t)&&this.lineBreak(),r=o}return this.findPointBefore(n,t),this}readTextNode(e){let t=e.nodeValue;for(let n of this.points)n.node==e&&(n.pos=this.text.length+Math.min(n.offset,t.length));for(let n=0,r=this.lineSeparator?null:/\r\n?|\n/g;;){let i,o=-1,s=1;if(this.lineSeparator?(o=t.indexOf(this.lineSeparator,n),s=this.lineSeparator.length):(i=r.exec(t))&&(o=i.index,s=i[0].length),this.append(t.slice(n,o<0?t.length:o)),o<0)break;if(this.lineBreak(),s>1)for(let t of this.points)t.node==e&&t.pos>this.text.length&&(t.pos-=s-1);n=o+s}}readNode(e){let t=Px.get(e),n=t&&t.overrideDOMText;if(null!=n){this.findPointInside(e,n.length);for(let e=n.iter();!e.next().done;)e.lineBreak?this.lineBreak():this.append(e.value)}else 3==e.nodeType?this.readTextNode(e):"BR"==e.nodeName?e.nextSibling&&this.lineBreak():1==e.nodeType&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let n of this.points)n.node==e&&e.childNodes[n.offset]==t&&(n.pos=this.text.length)}findPointInside(e,t){for(let n of this.points)(3==e.nodeType?n.node==e:e.contains(n.node))&&(n.pos=this.text.length+(yk(e,n.node,n.offset)?t:0))}}function yk(e,t,n){for(;;){if(!t||n<yw(t))return!1;if(t==e)return!0;n=gw(t)+1,t=t.parentNode}}function wk(e,t){let n;for(;e!=t&&e;e=e.nextSibling){let t=Px.get(e);if(!(null==t?void 0:t.isWidget()))return!1;t&&(n||(n=[])).push(t)}if(n)for(let e of n){let t=e.overrideDOMText;if(null==t?void 0:t.length)return!1}return!0}class xk{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}}class kk{constructor(e,t,n,r){this.typeOver=r,this.bounds=null,this.text="",this.domChanged=t>-1;let{impreciseHead:i,impreciseAnchor:o}=e.docView;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=Sk(e.docView.tile,t,n,0))){let t=i||o?[]:function(e){let t=[];if(e.root.activeElement!=e.contentDOM)return t;let{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:o}=e.observer.selectionRange;n&&(t.push(new xk(n,r)),i==n&&o==r||t.push(new xk(i,o)));return t}(e),n=new bk(t,e);n.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=n.text,this.newSel=function(e,t){if(0==e.length)return null;let n=e[0].pos,r=2==e.length?e[1].pos:n;return n>-1&&r>-1?fb.single(n+t,r+t):null}(t,this.bounds.from)}else{let t=e.observer.selectionRange,n=i&&i.node==t.focusNode&&i.offset==t.focusOffset||!dw(e.contentDOM,t.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(t.focusNode,t.focusOffset),r=o&&o.node==t.anchorNode&&o.offset==t.anchorOffset||!dw(e.contentDOM,t.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(t.anchorNode,t.anchorOffset),s=e.viewport;if((Xy.ios||Xy.chrome)&&e.state.selection.main.empty&&n!=r&&(s.from>0||s.to<e.state.doc.length)){let t=Math.min(n,r),i=Math.max(n,r),o=s.from-t,a=s.to-i;0!=o&&1!=o&&0!=t||0!=a&&-1!=a&&i!=e.state.doc.length||(n=0,r=e.state.doc.length)}e.inputState.composing>-1&&e.state.selection.ranges.length>1?this.newSel=e.state.selection.replaceRange(fb.range(r,n)):this.newSel=fb.single(r,n)}}}function Sk(e,t,n,r){if(e.isComposite()){let i=-1,o=-1,s=-1,a=-1;for(let l=0,c=r,u=r;l<e.children.length;l++){let r=e.children[l],h=c+r.length;if(c<t&&h>n)return Sk(r,t,n,c);if(h>=t&&-1==i&&(i=l,o=c),c>n&&r.dom.parentNode==e.dom){s=l,a=u;break}u=h,c=h+r.breakAfter}return{from:o,to:a<0?r+e.length:a,startDOM:(i?e.children[i-1].dom.nextSibling:null)||e.dom.firstChild,endDOM:s<e.children.length&&s>=0?e.children[s].dom:null}}return e.isText()?{from:r,to:r+e.length,startDOM:e.dom,endDOM:e.dom.nextSibling}:null}function Ek(e,t){let n,{newSel:r}=t,i=e.state.selection.main,o=e.inputState.lastKeyTime>Date.now()-100?e.inputState.lastKeyCode:-1;if(t.bounds){let{from:r,to:s}=t.bounds,a=i.from,l=null;(8===o||Xy.android&&t.text.length<s-r)&&(a=i.to,l="end");let c=Nk(e.state.doc.sliceString(r,s,vk),t.text,a-r,l);c&&(Xy.chrome&&13==o&&c.toB==c.from+2&&t.text.slice(c.from,c.toB)==vk+vk&&c.toB--,n={from:r+c.from,to:r+c.toA,insert:Hv.of(t.text.slice(c.from,c.toB).split(vk))})}else r&&(!e.hasFocus&&e.state.facet(px)||Ok(r,i))&&(r=null);if(!n&&!r)return!1;if(!n&&t.typeOver&&!i.empty&&r&&r.main.empty?n={from:i.from,to:i.to,insert:e.state.doc.slice(i.from,i.to)}:(Xy.mac||Xy.android)&&n&&n.from==n.to&&n.from==i.head-1&&/^\. ?$/.test(n.insert.toString())&&"off"==e.contentDOM.getAttribute("autocorrect")?(r&&2==n.insert.length&&(r=fb.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:Hv.of([n.insert.toString().replace("."," ")])}):n&&n.from>=i.from&&n.to<=i.to&&(n.from!=i.from||n.to!=i.to)&&i.to-i.from-(n.to-n.from)<=4?n={from:i.from,to:i.to,insert:e.state.doc.slice(i.from,n.from).append(n.insert).append(e.state.doc.slice(n.to,i.to))}:e.state.doc.lineAt(i.from).to<i.to&&e.docView.lineHasWidget(i.to)&&e.inputState.insertingTextAt>Date.now()-50?n={from:i.from,to:i.to,insert:e.state.toText(e.inputState.insertingText)}:Xy.chrome&&n&&n.from==n.to&&n.from==i.head&&"\n "==n.insert.toString()&&e.lineWrapping&&(r&&(r=fb.single(r.main.anchor-1,r.main.head-1)),n={from:i.from,to:i.to,insert:Hv.of([" "])}),n)return Ck(e,n,r,o);if(r&&!Ok(r,i)){let t=!1,n="select";return e.inputState.lastSelectionTime>Date.now()-50&&("select"==e.inputState.lastSelectionOrigin&&(t=!0),n=e.inputState.lastSelectionOrigin,"select.pointer"==n&&(r=hk(e.state.facet(Ex).map(t=>t(e)),r))),e.dispatch({selection:r,scrollIntoView:t,userEvent:n}),!0}return!1}function Ck(e,t,n,r=-1){if(Xy.ios&&e.inputState.flushIOSKey(t))return!0;let i=e.state.selection.main;if(Xy.android&&(t.to==i.to&&(t.from==i.from||t.from==i.from-1&&" "==e.state.sliceDoc(t.from,i.from))&&1==t.insert.length&&2==t.insert.lines&&Aw(e.contentDOM,"Enter",13)||(t.from==i.from-1&&t.to==i.to&&0==t.insert.length||8==r&&t.insert.length<t.to-t.from&&t.to>i.head)&&Aw(e.contentDOM,"Backspace",8)||t.from==i.from&&t.to==i.to+1&&0==t.insert.length&&Aw(e.contentDOM,"Delete",46)))return!0;let o,s=t.insert.toString();e.inputState.composing>=0&&e.inputState.composing++;let a=()=>o||(o=function(e,t,n){let r,i=e.state,o=i.selection.main,s=-1;if(t.from==t.to&&t.from<o.from||t.from>o.to){let n=t.from<o.from?-1:1,r=n<0?o.from:o.to,a=uk(i.facet(Ex).map(t=>t(e)),r,n);t.from==a&&(s=a)}if(s>-1)r={changes:t,selection:fb.cursor(t.from+t.insert.length,-1)};else if(t.from>=o.from&&t.to<=o.to&&t.to-t.from>=(o.to-o.from)/3&&(!n||n.main.empty&&n.main.from==t.from+t.insert.length)&&e.inputState.composing<0){let n=o.from<t.from?i.sliceDoc(o.from,t.from):"",s=o.to>t.to?i.sliceDoc(t.to,o.to):"";r=i.replaceSelection(e.state.toText(n+t.insert.sliceString(0,void 0,e.state.lineBreak)+s))}else{let s=i.changes(t),a=n&&n.main.to<=s.newLength?n.main:void 0;if(i.selection.ranges.length>1&&(e.inputState.composing>=0||e.inputState.compositionPendingChange)&&t.to<=o.to+10&&t.to>=o.to-10){let l,c=e.state.sliceDoc(t.from,t.to),u=n&&ik(e,n.main.head);if(u){let e=t.insert.length-(t.to-t.from);l={from:u.from,to:u.to-e}}else l=e.state.doc.lineAt(o.head);let h=o.to-t.to;r=i.changeByRange(n=>{if(n.from==o.from&&n.to==o.to)return{changes:s,range:a||n.map(s)};let r=n.to-h,u=r-c.length;if(e.state.sliceDoc(u,r)!=c||r>=l.from&&u<=l.to)return{range:n};let d=i.changes({from:u,to:r,insert:t.insert}),f=n.to-o.to;return{changes:d,range:a?fb.range(Math.max(0,a.anchor+f),Math.max(0,a.head+f)):n.map(d)}})}else r={changes:s,selection:a&&i.selection.replaceRange(a)}}let a="input.type";(e.composing||e.inputState.compositionPendingChange&&e.inputState.compositionEndedAt>Date.now()-50)&&(e.inputState.compositionPendingChange=!1,a+=".compose",e.inputState.compositionFirstChange&&(a+=".start",e.inputState.compositionFirstChange=!1));return i.update(r,{userEvent:a,scrollIntoView:!0})}(e,t,n));return e.state.facet(rx).some(n=>n(e,t.from,t.to,s,a))||e.dispatch(a()),!0}function Nk(e,t,n,r){let i=Math.min(e.length,t.length),o=0;for(;o<i&&e.charCodeAt(o)==t.charCodeAt(o);)o++;if(o==i&&e.length==t.length)return null;let s=e.length,a=t.length;for(;s>0&&a>0&&e.charCodeAt(s-1)==t.charCodeAt(a-1);)s--,a--;if("end"==r){n-=s+Math.max(0,o-Math.min(s,a))-o}if(s<o&&e.length<t.length){o-=n<=o&&n>=s?o-n:0,a=o+(a-s),s=o}else if(a<o){o-=n<=o&&n>=a?o-n:0,s=o+(s-a),a=o}return{from:o,toA:s,toB:a}}function Ok(e,t){return t.head==e.main.head&&t.anchor==e.main.anchor}class Ak{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Xy.safari&&e.contentDOM.addEventListener("input",()=>null),Xy.gecko&&function(e){Qk.has(e)||(Qk.add(e),e.addEventListener("copy",()=>{}),e.addEventListener("cut",()=>{}))}(e.contentDOM.ownerDocument)}handleEvent(e){(function(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n,r=t.target;r!=e.contentDOM;r=r.parentNode)if(!r||11==r.nodeType||(n=Px.get(r))&&n.isWidget()&&!n.isHidden&&n.widget.ignoreEvent(t))return!1;return!0})(this.view,e)&&!this.ignoreDuringComposition(e)&&("keydown"==e.type&&this.keydown(e)||(0!=this.view.updateState?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e)))}runHandlers(e,t){let n=this.handlers[e];if(n){for(let e of n.observers)e(this.view,t);for(let e of n.handlers){if(t.defaultPrevented)break;if(e(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=Tk(e),n=this.handlers,r=this.view.contentDOM;for(let e in t)if("scroll"!=e){let i=!t[e].handlers.length,o=n[e];o&&i!=!o.handlers.length&&(r.removeEventListener(e,this.handleEvent),o=null),o||r.addEventListener(e,this.handleEvent,{passive:i})}for(let e in n)"scroll"==e||t[e]||r.removeEventListener(e,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),9==e.keyCode&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&27!=e.keyCode&&Pk.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Xy.android&&Xy.chrome&&!e.synthetic&&(13==e.keyCode||8==e.keyCode))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return!Xy.ios||e.synthetic||e.altKey||e.metaKey||!((t=Rk.find(t=>t.keyCode==e.keyCode))&&!e.ctrlKey||Dk.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey)?(229!=e.keyCode&&this.view.observer.forceFlush(),!1):(this.pendingIOSKey=t||e,setTimeout(()=>this.flushIOSKey(),250),!0)}flushIOSKey(e){let t=this.pendingIOSKey;return!!t&&(!("Enter"==t.key&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString()))&&(this.pendingIOSKey=void 0,Aw(this.view.contentDOM,t.key,t.keyCode,t instanceof KeyboardEvent?t:void 0)))}ignoreDuringComposition(e){return!(!/^key/.test(e.type)||e.synthetic)&&(this.composing>0||!!(Xy.safari&&!Xy.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100)&&(this.compositionPendingKey=!1,!0))}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function Mk(e,t){return(n,r)=>{try{return t.call(e,r,n)}catch(e){fx(n.state,e)}}}function Tk(e){let t=Object.create(null);function n(e){return t[e]||(t[e]={observers:[],handlers:[]})}for(let t of e){let e=t.spec,r=e&&e.plugin.domEventHandlers,i=e&&e.plugin.domEventObservers;if(r)for(let e in r){let i=r[e];i&&n(e).handlers.push(Mk(t.value,i))}if(i)for(let e in i){let r=i[e];r&&n(e).observers.push(Mk(t.value,r))}}for(let e in _k)n(e).handlers.push(_k[e]);for(let e in Bk)n(e).observers.push(Bk[e]);return t}const Rk=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],Dk="dthko",Pk=[16,17,18,20,91,92,224,225];function Lk(e){return.7*Math.max(0,e)+8}class Ik{constructor(e,t,n,r){this.view=e,this.startEvent=t,this.style=n,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=function(e){let t,n,r=e.ownerDocument;for(let i=e.parentNode;i&&!(i==r.body||t&&n);)if(1==i.nodeType)!n&&i.scrollHeight>i.clientHeight&&(n=i),!t&&i.scrollWidth>i.clientWidth&&(t=i),i=i.assignedSlot||i.parentNode;else{if(11!=i.nodeType)break;i=i.host}return{x:t,y:n}}(e.contentDOM),this.atoms=e.state.facet(Ex).map(t=>t(e));let i=e.contentDOM.ownerDocument;i.addEventListener("mousemove",this.move=this.move.bind(this)),i.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(iy.allowMultipleSelections)&&function(e,t){let n=e.state.facet(Qw);return n.length?n[0](t):Xy.mac?t.metaKey:t.ctrlKey}(e,t),this.dragging=!(!function(e,t){let{main:n}=e.state.selection;if(n.empty)return!1;let r=hw(e.root);if(!r||0==r.rangeCount)return!0;let i=r.getRangeAt(0).getClientRects();for(let e=0;e<i.length;e++){let n=i[e];if(n.left<=t.clientX&&n.right>=t.clientX&&n.top<=t.clientY&&n.bottom>=t.clientY)return!0}return!1}(e,t)||1!=$k(t))&&null}start(e){!1===this.dragging&&this.select(e)}move(e){if(0==e.buttons)return this.destroy();if(this.dragging||null==this.dragging&&(t=this.startEvent,n=e,Math.max(Math.abs(t.clientX-n.clientX),Math.abs(t.clientY-n.clientY))<10))return;var t,n;this.select(this.lastEvent=e);let r=0,i=0,o=0,s=0,a=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:o,right:a}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:l}=this.scrollParents.y.getBoundingClientRect());let c=Ax(this.view);e.clientX-c.left<=o+6?r=-Lk(o-e.clientX):e.clientX+c.right>=a-6&&(r=Lk(e.clientX-a)),e.clientY-c.top<=s+6?i=-Lk(s-e.clientY):e.clientY+c.bottom>=l-6&&(i=Lk(e.clientY-l)),this.setScrollSpeed(r,i)}up(e){null==this.dragging&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),!1===this.dragging&&this.select(this.lastEvent)}select(e){let{view:t}=this,n=hk(this.atoms,this.style.get(e,this.extend,this.multiple));!this.mustSelect&&n.eq(t.state.selection,!1===this.dragging)||this.view.dispatch({selection:n,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(e=>e.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}const _k=Object.create(null),Bk=Object.create(null),Fk=Xy.ie&&Xy.ie_version<15||Xy.ios&&Xy.webkit_version<604;function jk(e,t,n){for(let r of e.facet(t))n=r(n,e);return n}function Wk(e,t){t=jk(e.state,ox,t);let n,{state:r}=e,i=1,o=r.toText(t),s=o.lines==r.selection.ranges.length,a=null!=Yk&&r.selection.ranges.every(e=>e.empty)&&Yk==o.toString();if(a){let e=-1;n=r.changeByRange(n=>{let a=r.doc.lineAt(n.from);if(a.from==e)return{range:n};e=a.from;let l=r.toText((s?o.line(i++).text:t)+r.lineBreak);return{changes:{from:a.from,insert:l},range:fb.cursor(n.from+l.length)}})}else n=s?r.changeByRange(e=>{let t=o.line(i++);return{changes:{from:e.from,to:e.to,insert:t.text},range:fb.cursor(e.from+t.length)}}):r.replaceSelection(o);e.dispatch(n,{userEvent:"input.paste",scrollIntoView:!0})}function zk(e,t,n,r){if(1==r)return fb.cursor(t,n);if(2==r)return function(e,t,n=1){let r=e.charCategorizer(t),i=e.doc.lineAt(t),o=t-i.from;if(0==i.length)return fb.cursor(t);0==o?n=1:o==i.length&&(n=-1);let s=o,a=o;n<0?s=Qv(i.text,o,!1):a=Qv(i.text,o);let l=r(i.text.slice(s,a));for(;s>0;){let e=Qv(i.text,s,!1);if(r(i.text.slice(e,s))!=l)break;s=e}for(;a<i.length;){let e=Qv(i.text,a);if(r(i.text.slice(a,e))!=l)break;a=e}return fb.range(s+i.from,a+i.from)}(e.state,t,n);{let r=e.docView.lineAt(t,n),i=e.state.doc.lineAt(r?r.posAtEnd:t),o=r?r.posAtStart:i.from,s=r?r.posAtEnd:i.to;return s<e.state.doc.length&&s==i.to&&s++,fb.range(o,s)}}Bk.scroll=e=>{e.inputState.lastScrollTop=e.scrollDOM.scrollTop,e.inputState.lastScrollLeft=e.scrollDOM.scrollLeft},_k.keydown=(e,t)=>(e.inputState.setSelectionOrigin("select"),27==t.keyCode&&0!=e.inputState.tabFocusMode&&(e.inputState.tabFocusMode=Date.now()+2e3),!1),Bk.touchstart=(e,t)=>{e.inputState.lastTouchTime=Date.now(),e.inputState.setSelectionOrigin("select.pointer")},Bk.touchmove=e=>{e.inputState.setSelectionOrigin("select.pointer")},_k.mousedown=(e,t)=>{if(e.observer.flush(),e.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of e.state.facet(ex))if(n=r(e,t),n)break;if(n||0!=t.button||(n=function(e,t){let n=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),r=$k(t),i=e.state.selection;return{update(e){e.docChanged&&(n.pos=e.changes.mapPos(n.pos),i=i.map(e.changes))},get(t,o,s){let a,l=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),c=zk(e,l.pos,l.assoc,r);if(n.pos!=l.pos&&!o){let t=zk(e,n.pos,n.assoc,r),i=Math.min(t.from,c.from),o=Math.max(t.to,c.to);c=i<c.from?fb.range(i,o):fb.range(o,i)}return o?i.replaceRange(i.main.extend(c.from,c.to)):s&&1==r&&i.ranges.length>1&&(a=function(e,t){for(let n=0;n<e.ranges.length;n++){let{from:r,to:i}=e.ranges[n];if(r<=t&&i>=t)return fb.create(e.ranges.slice(0,n).concat(e.ranges.slice(n+1)),e.mainIndex==n?0:e.mainIndex-(e.mainIndex>n?1:0))}return null}(i,l.pos))?a:s?i.addRange(c):fb.create([c])}}}(e,t)),n){let r=!e.hasFocus;e.inputState.startMouseSelection(new Ik(e,t,n,r)),r&&e.observer.ignore(()=>{Nw(e.contentDOM);let t=e.root.activeElement;t&&!t.contains(e.contentDOM)&&t.blur()});let i=e.inputState.mouseSelection;if(i)return i.start(t),!1===i.dragging}else e.inputState.setSelectionOrigin("select.pointer");return!1};const Hk=Xy.ie&&Xy.ie_version<=11;let Vk=null,qk=0,Uk=0;function $k(e){if(!Hk)return e.detail;let t=Vk,n=Uk;return Vk=e,Uk=Date.now(),qk=!t||n>Date.now()-400&&Math.abs(t.clientX-e.clientX)<2&&Math.abs(t.clientY-e.clientY)<2?(qk+1)%3:1}function Kk(e,t,n,r){if(!(n=jk(e.state,ox,n)))return;let i=e.posAtCoords({x:t.clientX,y:t.clientY},!1),{draggedContent:o}=e.inputState,s=r&&o&&function(e,t){let n=e.state.facet(Zw);return n.length?n[0](t):Xy.mac?!t.altKey:!t.ctrlKey}(e,t)?{from:o.from,to:o.to}:null,a={from:i,insert:n},l=e.state.changes(s?[s,a]:a);e.focus(),e.dispatch({changes:l,selection:{anchor:l.mapPos(i,-1),head:l.mapPos(i,1)},userEvent:s?"move.drop":"input.drop"}),e.inputState.draggedContent=null}_k.dragstart=(e,t)=>{let{selection:{main:n}}=e.state;if(t.target.draggable){let r=e.docView.tile.nearest(t.target);if(r&&r.isWidget()){let e=r.posAtStart,t=e+r.length;(e>=n.to||t<=n.from)&&(n=fb.range(e,t))}}let{inputState:r}=e;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,t.dataTransfer&&(t.dataTransfer.setData("Text",jk(e.state,sx,e.state.sliceDoc(n.from,n.to))),t.dataTransfer.effectAllowed="copyMove"),!1},_k.dragend=e=>(e.inputState.draggedContent=null,!1),_k.drop=(e,t)=>{if(!t.dataTransfer)return!1;if(e.state.readOnly)return!0;let n=t.dataTransfer.files;if(n&&n.length){let r=Array(n.length),i=0,o=()=>{++i==n.length&&Kk(e,t,r.filter(e=>null!=e).join(e.state.lineBreak),!1)};for(let e=0;e<n.length;e++){let t=new FileReader;t.onerror=o,t.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(t.result)||(r[e]=t.result),o()},t.readAsText(n[e])}return!0}{let n=t.dataTransfer.getData("Text");if(n)return Kk(e,t,n,!0),!0}return!1},_k.paste=(e,t)=>{if(e.state.readOnly)return!0;e.observer.flush();let n=Fk?null:t.clipboardData;return n?(Wk(e,n.getData("text/plain")||n.getData("text/uri-list")),!0):(function(e){let t=e.dom.parentNode;if(!t)return;let n=t.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{e.focus(),n.remove(),Wk(e,n.value)},50)}(e),!1)};let Yk=null;_k.copy=_k.cut=(e,t)=>{let n=hw(e.root);if(n&&!fw(e.contentDOM,n))return!1;let{text:r,ranges:i,linewise:o}=function(e){let t=[],n=[],r=!1;for(let r of e.selection.ranges)r.empty||(t.push(e.sliceDoc(r.from,r.to)),n.push(r));if(!t.length){let i=-1;for(let{from:r}of e.selection.ranges){let o=e.doc.lineAt(r);o.number>i&&(t.push(o.text),n.push({from:o.from,to:Math.min(e.doc.length,o.to+1)})),i=o.number}r=!0}return{text:jk(e,sx,t.join(e.lineBreak)),ranges:n,linewise:r}}(e.state);if(!r&&!o)return!1;Yk=o?r:null,"cut"!=t.type||e.state.readOnly||e.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let s=Fk?null:t.clipboardData;return s?(s.clearData(),s.setData("text/plain",r),!0):(function(e,t){let n=e.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement("textarea"));r.style.cssText="position: fixed; left: -10000px; top: 10px",r.value=t,r.focus(),r.selectionEnd=t.length,r.selectionStart=0,setTimeout(()=>{r.remove(),e.focus()},50)}(e,r),!1)};const Gk=Vb.define();function Xk(e,t){let n=[];for(let r of e.facet(ix)){let i=r(e,t);i&&n.push(i)}return n.length?e.update({effects:n,annotations:Gk.of(!0)}):null}function Jk(e){setTimeout(()=>{let t=e.hasFocus;if(t!=e.inputState.notifiedFocused){let n=Xk(e.state,t);n?e.dispatch(n):e.update([])}},10)}Bk.focus=e=>{e.inputState.lastFocusTime=Date.now(),e.scrollDOM.scrollTop||!e.inputState.lastScrollTop&&!e.inputState.lastScrollLeft||(e.scrollDOM.scrollTop=e.inputState.lastScrollTop,e.scrollDOM.scrollLeft=e.inputState.lastScrollLeft),Jk(e)},Bk.blur=e=>{e.observer.clearSelectionRange(),Jk(e)},Bk.compositionstart=Bk.compositionupdate=e=>{e.observer.editContext||(null==e.inputState.compositionFirstChange&&(e.inputState.compositionFirstChange=!0),e.inputState.composing<0&&(e.inputState.composing=0))},Bk.compositionend=e=>{e.observer.editContext||(e.inputState.composing=-1,e.inputState.compositionEndedAt=Date.now(),e.inputState.compositionPendingKey=!0,e.inputState.compositionPendingChange=e.observer.pendingRecords().length>0,e.inputState.compositionFirstChange=null,Xy.chrome&&Xy.android?e.observer.flushSoon():e.inputState.compositionPendingChange?Promise.resolve().then(()=>e.observer.flush()):setTimeout(()=>{e.inputState.composing<0&&e.docView.hasComposition&&e.update([])},50))},Bk.contextmenu=e=>{e.inputState.lastContextMenu=Date.now()},_k.beforeinput=(e,t)=>{var n,r;if("insertText"!=t.inputType&&"insertCompositionText"!=t.inputType||(e.inputState.insertingText=t.data,e.inputState.insertingTextAt=Date.now()),"insertReplacementText"==t.inputType&&e.observer.editContext){let r=null===(n=t.dataTransfer)||void 0===n?void 0:n.getData("text/plain"),i=t.getTargetRanges();if(r&&i.length){let t=i[0],n=e.posAtDOM(t.startContainer,t.startOffset),o=e.posAtDOM(t.endContainer,t.endOffset);return Ck(e,{from:n,to:o,insert:e.state.toText(r)},null),!0}}let i;if(Xy.chrome&&Xy.android&&(i=Rk.find(e=>e.inputType==t.inputType))&&(e.observer.delayAndroidKey(i.key,i.keyCode),"Backspace"==i.key||"Delete"==i.key)){let t=(null===(r=window.visualViewport)||void 0===r?void 0:r.height)||0;setTimeout(()=>{var n;((null===(n=window.visualViewport)||void 0===n?void 0:n.height)||0)>t+10&&e.hasFocus&&(e.contentDOM.blur(),e.focus())},100)}return Xy.ios&&"deleteContentForward"==t.inputType&&e.observer.flushSoon(),Xy.safari&&"insertText"==t.inputType&&e.inputState.composing>=0&&setTimeout(()=>Bk.compositionend(e,t),20),!1};const Qk=new Set;const Zk=["pre-wrap","normal","pre-line","break-spaces"];let eS=!1;function tS(){eS=!1}class nS{constructor(e){this.lineWrapping=e,this.doc=Hv.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let n=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(n+=Math.max(0,Math.ceil((t-e-n*this.lineLength*.5)/this.lineLength))),this.lineHeight*n}heightForLine(e){if(!this.lineWrapping)return this.lineHeight;return(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return Zk.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let n=0;n<e.length;n++){let r=e[n];r<0?n++:this.heightSamples[Math.floor(10*r)]||(t=!0,this.heightSamples[Math.floor(10*r)]=!0)}return t}refresh(e,t,n,r,i,o){let s=Zk.indexOf(e)>-1,a=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=s||Math.abs(n-this.charWidth)>.1;if(this.lineWrapping=s,this.lineHeight=t,this.charWidth=n,this.textHeight=r,this.lineLength=i,a){this.heightSamples={};for(let e=0;e<o.length;e++){let t=o[e];t<0?e++:this.heightSamples[Math.floor(10*t)]=!0}}return a}}class rS{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}}class iS{constructor(e,t,n,r,i){this.from=e,this.length=t,this.top=n,this.height=r,this._content=i}get type(){return"number"==typeof this._content?rw.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof aw?this._content.widget:null}get widgetLineBreaks(){return"number"==typeof this._content?this._content:0}join(e){let t=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new iS(this.from,this.length+e.length,this.top,this.height+e.height,t)}}var oS=function(e){return e[e.ByPos=0]="ByPos",e[e.ByHeight=1]="ByHeight",e[e.ByPosNoHeight=2]="ByPosNoHeight",e}(oS||(oS={}));const sS=.001;class aS{constructor(e,t,n=2){this.length=e,this.height=t,this.flags=n}get outdated(){return(2&this.flags)>0}set outdated(e){this.flags=(e?2:0)|-3&this.flags}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>sS&&(eS=!0),this.height=e)}replace(e,t,n){return aS.of(n)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,n,r){let i=this,o=n.doc;for(let s=r.length-1;s>=0;s--){let{fromA:a,toA:l,fromB:c,toB:u}=r[s],h=i.lineAt(a,oS.ByPosNoHeight,n.setDoc(t),0,0),d=h.to>=l?h:i.lineAt(l,oS.ByPosNoHeight,n,0,0);for(u+=d.to-l,l=d.to;s>0&&h.from<=r[s-1].toA;)a=r[s-1].fromA,c=r[s-1].fromB,s--,a<h.from&&(h=i.lineAt(a,oS.ByPosNoHeight,n,0,0));c+=h.from-a,a=h.from;let f=mS.build(n.setDoc(o),e,c,u);i=lS(i,i.replace(a,l,f))}return i.updateHeight(n,0)}static empty(){return new hS(0,0,0)}static of(e){if(1==e.length)return e[0];let t=0,n=e.length,r=0,i=0;for(;;)if(t==n)if(r>2*i){let i=e[t-1];i.break?e.splice(--t,1,i.left,null,i.right):e.splice(--t,1,i.left,i.right),n+=1+i.break,r-=i.size}else{if(!(i>2*r))break;{let t=e[n];t.break?e.splice(n,1,t.left,null,t.right):e.splice(n,1,t.left,t.right),n+=2+t.break,i-=t.size}}else if(r<i){let n=e[t++];n&&(r+=n.size)}else{let t=e[--n];t&&(i+=t.size)}let o=0;return null==e[t-1]?(o=1,t--):null==e[t]&&(o=1,n++),new fS(aS.of(e.slice(0,t)),o,aS.of(e.slice(n)))}}function lS(e,t){return e==t?e:(e.constructor!=t.constructor&&(eS=!0),t)}aS.prototype.size=1;const cS=iw.replace({});class uS extends aS{constructor(e,t,n){super(e,t),this.deco=n,this.spaceAbove=0}mainBlock(e,t){return new iS(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(e,t,n,r){return this.spaceAbove&&e<n+this.spaceAbove?new iS(r,0,n,this.spaceAbove,cS):this.mainBlock(n,r)}lineAt(e,t,n,r,i){let o=this.mainBlock(r,i);return this.spaceAbove?this.blockAt(0,n,r,i).join(o):o}forEachLine(e,t,n,r,i,o){e<=i+this.length&&t>=i&&o(this.lineAt(0,oS.ByPos,n,r,i))}setMeasuredHeight(e){let t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more&&this.setMeasuredHeight(r),this.outdated=!1,this}toString(){return`block(${this.length})`}}class hS extends uS{constructor(e,t,n){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=n}mainBlock(e,t){return new iS(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,t,n){let r=n[0];return 1==n.length&&(r instanceof hS||r instanceof dS&&4&r.flags)&&Math.abs(this.length-r.length)<10?(r instanceof dS?r=new hS(r.length,this.height,this.spaceAbove):r.height=this.height,this.outdated||(r.outdated=!1),r):aS.of(n)}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more?this.setMeasuredHeight(r):(n||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class dS extends aS{constructor(e){super(e,0)}heightMetrics(e,t){let n,r=e.doc.lineAt(t).number,i=e.doc.lineAt(t+this.length).number,o=i-r+1,s=0;if(e.lineWrapping){let t=Math.min(this.height,e.lineHeight*o);n=t/o,this.length>o+1&&(s=(this.height-t)/(this.length-o-1))}else n=this.height/o;return{firstLine:r,lastLine:i,perLine:n,perChar:s}}blockAt(e,t,n,r){let{firstLine:i,lastLine:o,perLine:s,perChar:a}=this.heightMetrics(t,r);if(t.lineWrapping){let i=r+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-n)/this.height))*this.length)),o=t.doc.lineAt(i),l=s+o.length*a,c=Math.max(n,e-l/2);return new iS(o.from,o.length,c,l,0)}{let r=Math.max(0,Math.min(o-i,Math.floor((e-n)/s))),{from:a,length:l}=t.doc.line(i+r);return new iS(a,l,n+s*r,s,0)}}lineAt(e,t,n,r,i){if(t==oS.ByHeight)return this.blockAt(e,n,r,i);if(t==oS.ByPosNoHeight){let{from:t,to:r}=n.doc.lineAt(e);return new iS(t,r-t,0,0,0)}let{firstLine:o,perLine:s,perChar:a}=this.heightMetrics(n,i),l=n.doc.lineAt(e),c=s+l.length*a,u=l.number-o,h=r+s*u+a*(l.from-i-u);return new iS(l.from,l.length,Math.max(r,Math.min(h,r+this.height-c)),c,0)}forEachLine(e,t,n,r,i,o){e=Math.max(e,i),t=Math.min(t,i+this.length);let{firstLine:s,perLine:a,perChar:l}=this.heightMetrics(n,i);for(let c=e,u=r;c<=t;){let t=n.doc.lineAt(c);if(c==e){let n=t.number-s;u+=a*n+l*(e-i-n)}let r=a+l*t.length;o(new iS(t.from,t.length,u,r,0)),u+=r,c=t.to+1}}replace(e,t,n){let r=this.length-t;if(r>0){let e=n[n.length-1];e instanceof dS?n[n.length-1]=new dS(e.length+r):n.push(null,new dS(r-1))}if(e>0){let t=n[0];t instanceof dS?n[0]=new dS(e+t.length):n.unshift(new dS(e-1),null)}return aS.of(n)}decomposeLeft(e,t){t.push(new dS(e-1),null)}decomposeRight(e,t){t.push(null,new dS(this.length-e-1))}updateHeight(e,t=0,n=!1,r){let i=t+this.length;if(r&&r.from<=t+this.length&&r.more){let n=[],o=Math.max(t,r.from),s=-1;for(r.from>t&&n.push(new dS(r.from-t-1).updateHeight(e,t));o<=i&&r.more;){let t=e.doc.lineAt(o).length;n.length&&n.push(null);let i=r.heights[r.index++],a=0;i<0&&(a=-i,i=r.heights[r.index++]),-1==s?s=i:Math.abs(i-s)>=sS&&(s=-2);let l=new hS(t,i,a);l.outdated=!1,n.push(l),o+=t+1}o<=i&&n.push(null,new dS(i-o).updateHeight(e,o));let a=aS.of(n);return(s<0||Math.abs(a.height-this.height)>=sS||Math.abs(s-this.heightMetrics(e,t).perLine)>=sS)&&(eS=!0),lS(this,a)}return(n||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class fS extends aS{constructor(e,t,n){super(e.length+t+n.length,e.height+n.height,t|(e.outdated||n.outdated?2:0)),this.left=e,this.right=n,this.size=e.size+n.size}get break(){return 1&this.flags}blockAt(e,t,n,r){let i=n+this.left.height;return e<i?this.left.blockAt(e,t,n,r):this.right.blockAt(e,t,i,r+this.left.length+this.break)}lineAt(e,t,n,r,i){let o=r+this.left.height,s=i+this.left.length+this.break,a=t==oS.ByHeight?e<o:e<s,l=a?this.left.lineAt(e,t,n,r,i):this.right.lineAt(e,t,n,o,s);if(this.break||(a?l.to<s:l.from>s))return l;let c=t==oS.ByPosNoHeight?oS.ByPosNoHeight:oS.ByPos;return a?l.join(this.right.lineAt(s,c,n,o,s)):this.left.lineAt(s,c,n,r,i).join(l)}forEachLine(e,t,n,r,i,o){let s=r+this.left.height,a=i+this.left.length+this.break;if(this.break)e<a&&this.left.forEachLine(e,t,n,r,i,o),t>=a&&this.right.forEachLine(e,t,n,s,a,o);else{let l=this.lineAt(a,oS.ByPos,n,r,i);e<l.from&&this.left.forEachLine(e,l.from-1,n,r,i,o),l.to>=e&&l.from<=t&&o(l),t>l.to&&this.right.forEachLine(l.to+1,t,n,s,a,o)}}replace(e,t,n){let r=this.left.length+this.break;if(t<r)return this.balanced(this.left.replace(e,t,n),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-r,t-r,n));let i=[];e>0&&this.decomposeLeft(e,i);let o=i.length;for(let e of n)i.push(e);if(e>0&&pS(i,o-1),t<this.length){let e=i.length;this.decomposeRight(t,i),pS(i,e)}return aS.of(i)}decomposeLeft(e,t){let n=this.left.length;if(e<=n)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(n++,e>=n&&t.push(null)),e>n&&this.right.decomposeLeft(e-n,t)}decomposeRight(e,t){let n=this.left.length,r=n+this.break;if(e>=r)return this.right.decomposeRight(e-r,t);e<n&&this.left.decomposeRight(e,t),this.break&&e<r&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?aS.of(this.break?[e,null,t]:[e,t]):(this.left=lS(this.left,e),this.right=lS(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,n=!1,r){let{left:i,right:o}=this,s=t+i.length+this.break,a=null;return r&&r.from<=t+i.length&&r.more?a=i=i.updateHeight(e,t,n,r):i.updateHeight(e,t,n),r&&r.from<=s+o.length&&r.more?a=o=o.updateHeight(e,s,n,r):o.updateHeight(e,s,n),a?this.balanced(i,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function pS(e,t){let n,r;null==e[t]&&(n=e[t-1])instanceof dS&&(r=e[t+1])instanceof dS&&e.splice(t-1,3,new dS(n.length+1+r.length))}class mS{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let e=Math.min(t,this.lineEnd),n=this.nodes[this.nodes.length-1];n instanceof hS?n.length+=e-this.pos:(e>this.pos||!this.isCovered)&&this.nodes.push(new hS(e-this.pos,-1,0)),this.writtenTo=e,t>e&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,n){if(e<t||n.heightRelevant){let r=n.widget?n.widget.estimatedHeight:0,i=n.widget?n.widget.lineBreaks:0;r<0&&(r=this.oracle.lineHeight);let o=t-e;n.block?this.addBlock(new uS(o,r,n)):(o||i||r>=5)&&this.addLineDeco(r,i,o)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||null==this.nodes[this.nodes.length-1])&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new hS(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let n=new dS(t-e);return this.oracle.doc.lineAt(e).to==t&&(n.flags|=4),n}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof hS)return e;let t=new hS(0,-1,0);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,n){let r=this.ensureLine();r.length+=n,r.collapsed+=n,r.widgetHeight=Math.max(r.widgetHeight,e),r.breaks+=t,this.writtenTo=this.pos=this.pos+n}finish(e){let t=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||t instanceof hS||this.isCovered?(this.writtenTo<this.pos||null==t)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new hS(0,-1,0));let n=e;for(let e of this.nodes)e instanceof hS&&e.updateHeight(this.oracle,n),n+=e?e.length:1;return this.nodes}static build(e,t,n,r){let i=new mS(n,e);return hy.spans(t,n,r,i,0),i.finish(n)}}class gS{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,n,r){(e<t||n&&n.heightRelevant||r&&r.heightRelevant)&&cw(e,t,this.changes,5)}}function vS(e,t){let n=e.getBoundingClientRect(),r=e.ownerDocument,i=r.defaultView||window,o=Math.max(0,n.left),s=Math.min(i.innerWidth,n.right),a=Math.max(0,n.top),l=Math.min(i.innerHeight,n.bottom);for(let t=e.parentNode;t&&t!=r.body;)if(1==t.nodeType){let n=t,r=window.getComputedStyle(n);if((n.scrollHeight>n.clientHeight||n.scrollWidth>n.clientWidth)&&"visible"!=r.overflow){let r=n.getBoundingClientRect();o=Math.max(o,r.left),s=Math.min(s,r.right),a=Math.max(a,r.top),l=Math.min(t==e.parentNode?i.innerHeight:l,r.bottom)}t="absolute"==r.position||"fixed"==r.position?n.offsetParent:n.parentNode}else{if(11!=t.nodeType)break;t=t.host}return{left:o-n.left,right:Math.max(o,s)-n.left,top:a-(n.top+t),bottom:Math.max(a,l)-(n.top+t)}}function bS(e,t){let n=e.getBoundingClientRect();return{left:0,right:n.right-n.left,top:t,bottom:n.bottom-(n.top+t)}}class yS{constructor(e,t,n,r){this.from=e,this.to=t,this.size=n,this.displaySize=r}static same(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r.from!=i.from||r.to!=i.to||r.size!=i.size)return!1}return!0}draw(e,t){return iw.replace({widget:new wS(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}}class wS extends nw{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}}class xS{constructor(e){this.state=e,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scrollTop=0,this.scrolledToBottom=!1,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=CS,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=Pw.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let t=e.facet(wx).some(e=>"function"!=typeof e&&"cm-lineWrapping"==e.class);this.heightOracle=new nS(t),this.stateDeco=NS(e),this.heightMap=aS.empty().applyChanges(this.stateDeco,Hv.empty,this.heightOracle.setDoc(e.doc),[new Tx(0,0,0,e.doc.length)]);for(let e=0;e<2&&(this.viewport=this.getViewport(0,null),this.updateForViewport());e++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=iw.set(this.lineGaps.map(e=>e.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let n=0;n<=1;n++){let r=n?t.head:t.anchor;if(!e.some(({from:e,to:t})=>r>=e&&r<=t)){let{from:t,to:n}=this.lineBlockAt(r);e.push(new kS(t,n))}}return this.viewports=e.sort((e,t)=>e.from-t.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?CS:new OS(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(AS(e,this.scaler))})}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=NS(this.state);let r=e.changedRanges,i=Tx.extendWithRanges(r,function(e,t,n){let r=new gS;return hy.compare(e,t,n,r,0),r.changes}(n,this.stateDeco,e?e.changes:ob.empty(this.state.doc.length))),o=this.heightMap.height,s=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);tS(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),i),(this.heightMap.height!=o||eS)&&(e.flags|=2),s?(this.scrollAnchorPos=e.changes.mapPos(s.from,-1),this.scrollAnchorHeight=s.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let a=i.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<a.from||t.range.head>a.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,t));let l=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,e.flags|=this.updateForViewport(),(l||!e.changes.empty||2&e.flags)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(lx)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,n=window.getComputedStyle(t),r=this.heightOracle,i=n.whiteSpace;this.defaultTextDirection="rtl"==n.direction?Pw.RTL:Pw.LTR;let o=this.heightOracle.mustRefreshForWrapping(i)||this.mustMeasureContent,s=t.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=s.height;this.contentDOMHeight=s.height,this.mustMeasureContent=!1;let l=0,c=0;if(s.width&&s.height){let{scaleX:e,scaleY:n}=kw(t,s);(e>.005&&Math.abs(this.scaleX-e)>.005||n>.005&&Math.abs(this.scaleY-n)>.005)&&(this.scaleX=e,this.scaleY=n,l|=16,o=a=!0)}let u=(parseInt(n.paddingTop)||0)*this.scaleY,h=(parseInt(n.paddingBottom)||0)*this.scaleY;this.paddingTop==u&&this.paddingBottom==h||(this.paddingTop=u,this.paddingBottom=h,l|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,l|=16);let d=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=d&&(this.scrollAnchorHeight=-1,this.scrollTop=d),this.scrolledToBottom=Mw(e.scrollDOM);let f=(this.printing?bS:vS)(t,this.paddingTop),p=f.top-this.pixelViewport.top,m=f.bottom-this.pixelViewport.bottom;this.pixelViewport=f;let g=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(g!=this.inView&&(this.inView=g,g&&(a=!0)),!this.inView&&!this.scrollTarget&&!function(e){let t=e.getBoundingClientRect(),n=e.ownerDocument.defaultView||window;return t.left<n.innerWidth&&t.right>0&&t.top<n.innerHeight&&t.bottom>0}(e.dom))return 0;let v=s.width;if(this.contentDOMWidth==v&&this.editorHeight==e.scrollDOM.clientHeight||(this.contentDOMWidth=s.width,this.editorHeight=e.scrollDOM.clientHeight,l|=16),a){let t=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(t)&&(o=!0),o||r.lineWrapping&&Math.abs(v-this.contentDOMWidth)>r.charWidth){let{lineHeight:n,charWidth:s,textHeight:a}=e.docView.measureTextSize();o=n>0&&r.refresh(i,n,s,a,Math.max(5,v/s),t),o&&(e.docView.minWidth=0,l|=16)}p>0&&m>0?c=Math.max(p,m):p<0&&m<0&&(c=Math.min(p,m)),tS();for(let n of this.viewports){let i=n.from==this.viewport.from?t:e.docView.measureVisibleLineHeights(n);this.heightMap=(o?aS.empty().applyChanges(this.stateDeco,Hv.empty,this.heightOracle,[new Tx(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,o,new rS(n.from,i))}eS&&(l|=2)}let b=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return b&&(2&l&&(l|=this.updateScaler()),this.viewport=this.getViewport(c,this.scrollTarget),l|=this.updateForViewport()),(2&l||b)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),l|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),l}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let n=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),r=this.heightMap,i=this.heightOracle,{visibleTop:o,visibleBottom:s}=this,a=new kS(r.lineAt(o-1e3*n,oS.ByHeight,i,0,0).from,r.lineAt(s+1e3*(1-n),oS.ByHeight,i,0,0).to);if(t){let{head:e}=t.range;if(e<a.from||e>a.to){let n,o=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),s=r.lineAt(e,oS.ByPos,i,0,0);n="center"==t.y?(s.top+s.bottom)/2-o/2:"start"==t.y||"nearest"==t.y&&e<a.from?s.top:s.bottom-o,a=new kS(r.lineAt(n-500,oS.ByHeight,i,0,0).from,r.lineAt(n+o+500,oS.ByHeight,i,0,0).to)}}return a}mapViewport(e,t){let n=t.mapPos(e.from,-1),r=t.mapPos(e.to,1);return new kS(this.heightMap.lineAt(n,oS.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(r,oS.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},n=0){if(!this.inView)return!0;let{top:r}=this.heightMap.lineAt(e,oS.ByPos,this.heightOracle,0,0),{bottom:i}=this.heightMap.lineAt(t,oS.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:s}=this;return(0==e||r<=o-Math.max(10,Math.min(-n,250)))&&(t==this.state.doc.length||i>=s+Math.max(10,Math.min(n,250)))&&r>o-2e3&&i<s+2e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let n=[];for(let r of e)t.touchesRange(r.from,r.to)||n.push(new yS(t.mapPos(r.from),t.mapPos(r.to),r.size,r.displaySize));return n}ensureLineGaps(e,t){let n=this.heightOracle.lineWrapping,r=n?1e4:2e3,i=r>>1,o=r<<1;if(this.defaultTextDirection!=Pw.LTR&&!n)return[];let s=[],a=(r,o,l,c)=>{if(o-r<i)return;let u=this.state.selection.main,h=[u.from];u.empty||h.push(u.to);for(let e of h)if(e>r&&e<o)return a(r,e-10,l,c),void a(e+10,o,l,c);let d=function(e,t){for(let n of e)if(t(n))return n;return}(e,e=>e.from>=l.from&&e.to<=l.to&&Math.abs(e.from-r)<i&&Math.abs(e.to-o)<i&&!h.some(t=>e.from<t&&e.to>t));if(!d){if(o<l.to&&t&&n&&t.visibleRanges.some(e=>e.from<=o&&e.to>=o)){let e=t.moveToLineBoundary(fb.cursor(o),!1,!0).head;e>r&&(o=e)}let e=this.gapSize(l,r,o,c);d=new yS(r,o,e,n||e<2e6?e:2e6)}s.push(d)},l=t=>{if(t.length<o||t.type!=rw.Text)return;let i=function(e,t,n){let r=[],i=e,o=0;hy.spans(n,e,t,{span(){},point(e,t){e>i&&(r.push({from:i,to:e}),o+=e-i),i=t}},20),i<t&&(r.push({from:i,to:t}),o+=t-i);return{total:o,ranges:r}}(t.from,t.to,this.stateDeco);if(i.total<o)return;let s,l,c=this.scrollTarget?this.scrollTarget.range.head:null;if(n){let e,n,o=r/this.heightOracle.lineLength*this.heightOracle.lineHeight;if(null!=c){let r=ES(i,c),s=((this.visibleBottom-this.visibleTop)/2+o)/t.height;e=r-s,n=r+s}else e=(this.visibleTop-t.top-o)/t.height,n=(this.visibleBottom-t.top+o)/t.height;s=SS(i,e),l=SS(i,n)}else{let n=i.total*this.heightOracle.charWidth,o=r*this.heightOracle.charWidth,a=0;if(n>2e6)for(let n of e)n.from>=t.from&&n.from<t.to&&n.size!=n.displaySize&&n.from*this.heightOracle.charWidth+a<this.pixelViewport.left&&(a=n.size-n.displaySize);let u,h,d=this.pixelViewport.left+a,f=this.pixelViewport.right+a;if(null!=c){let e=ES(i,c),t=((f-d)/2+o)/n;u=e-t,h=e+t}else u=(d-o)/n,h=(f+o)/n;s=SS(i,u),l=SS(i,h)}s>t.from&&a(t.from,s,t,i),l<t.to&&a(l,t.to,t,i)};for(let e of this.viewportLines)Array.isArray(e.type)?e.type.forEach(l):l(e);return s}gapSize(e,t,n,r){let i=ES(r,n)-ES(r,t);return this.heightOracle.lineWrapping?e.height*i:r.total*this.heightOracle.charWidth*i}updateLineGaps(e){yS.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=iw.set(e.map(e=>e.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let n=[];hy.spans(t,this.viewport.from,this.viewport.to,{span(e,t){n.push({from:e,to:t})},point(){}},20);let r=0;if(n.length!=this.visibleRanges.length)r=12;else for(let t=0;t<n.length&&!(8&r);t++){let i=this.visibleRanges[t],o=n[t];i.from==o.from&&i.to==o.to||(r|=4,e&&e.mapPos(i.from,-1)==o.from&&e.mapPos(i.to,1)==o.to||(r|=8))}return this.visibleRanges=n,r}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||AS(this.heightMap.lineAt(e,oS.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||AS(this.heightMap.lineAt(this.scaler.fromDOM(e),oS.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return AS(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class kS{constructor(e,t){this.from=e,this.to=t}}function SS({total:e,ranges:t},n){if(n<=0)return t[0].from;if(n>=1)return t[t.length-1].to;let r=Math.floor(e*n);for(let e=0;;e++){let{from:n,to:i}=t[e],o=i-n;if(r<=o)return n+r;r-=o}}function ES(e,t){let n=0;for(let{from:r,to:i}of e.ranges){if(t<=i){n+=t-r;break}n+=i-r}return n/e.total}const CS={toDOM:e=>e,fromDOM:e=>e,scale:1,eq(e){return e==this}};function NS(e){let t=e.facet(xx).filter(e=>"function"!=typeof e),n=e.facet(Sx).filter(e=>"function"!=typeof e);return n.length&&t.push(hy.join(n)),t}class OS{constructor(e,t,n){let r=0,i=0,o=0;this.viewports=n.map(({from:n,to:i})=>{let o=t.lineAt(n,oS.ByPos,e,0,0).top,s=t.lineAt(i,oS.ByPos,e,0,0).bottom;return r+=s-o,{from:n,to:i,top:o,bottom:s,domTop:0,domBottom:0}}),this.scale=(7e6-r)/(t.height-r);for(let e of this.viewports)e.domTop=o+(e.top-i)*this.scale,o=e.domBottom=e.domTop+(e.bottom-e.top),i=e.bottom}toDOM(e){for(let t=0,n=0,r=0;;t++){let i=t<this.viewports.length?this.viewports[t]:null;if(!i||e<i.top)return r+(e-n)*this.scale;if(e<=i.bottom)return i.domTop+(e-i.top);n=i.bottom,r=i.domBottom}}fromDOM(e){for(let t=0,n=0,r=0;;t++){let i=t<this.viewports.length?this.viewports[t]:null;if(!i||e<i.domTop)return n+(e-r)/this.scale;if(e<=i.domBottom)return i.top+(e-i.domTop);n=i.bottom,r=i.domBottom}}eq(e){return e instanceof OS&&(this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every((t,n)=>t.from==e.viewports[n].from&&t.to==e.viewports[n].to))}}function AS(e,t){if(1==t.scale)return e;let n=t.toDOM(e.top),r=t.toDOM(e.bottom);return new iS(e.from,e.length,n,r-n,Array.isArray(e._content)?e._content.map(e=>AS(e,t)):e._content)}const MS=gb.define({combine:e=>e.join(" ")}),TS=gb.define({combine:e=>e.indexOf(!0)>-1}),RS=Ay.newName(),DS=Ay.newName(),PS=Ay.newName(),LS={"&light":"."+DS,"&dark":"."+PS};function IS(e,t,n){return new Ay(t,{finish:t=>/&/.test(t)?t.replace(/&\w*/,t=>{if("&"==t)return e;if(!n||!n[t])throw new RangeError(`Unsupported selector: ${t}`);return n[t]}):e+" "+t})}const _S=IS("."+RS,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:'url(\'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>\')',backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},LS),BS={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},FS=Xy.ie&&Xy.ie_version<=11;class jS{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new Sw,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let e of t)this.queue.push(e);(Xy.ie&&Xy.ie_version<=11||Xy.ios&&e.composing)&&t.some(e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():this.flush()}),!window.EditContext||!Xy.android||!1===e.constructor.EDIT_CONTEXT||Xy.chrome&&Xy.chrome_version<126||(this.editContext=new HS(e),e.state.facet(px)&&(e.contentDOM.editContext=this.editContext.editContext)),FS&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),"function"==typeof ResizeObserver&&(this.resizeScroll=new ResizeObserver(()=>{var e;(null===(e=this.view.docView)||void 0===e?void 0:e.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),"function"==typeof IntersectionObserver&&(this.intersection=new IntersectionObserver(e=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),e.length>0&&e[e.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(e=>{e.length>0&&e[e.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){("change"!=e.type&&e.type||e.matches)&&(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,n)=>t!=e[n]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:n}=this,r=this.selectionRange;if(n.state.facet(px)?n.root.activeElement!=this.dom:!fw(this.dom,r))return;let i=r.anchorNode&&n.docView.tile.nearest(r.anchorNode);i&&i.isWidget()&&i.widget.ignoreEvent(e)?t||(this.selectionChanged=!1):(Xy.ie&&Xy.ie_version<=11||Xy.android&&Xy.chrome)&&!n.state.selection.main.empty&&r.focusNode&&mw(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=hw(e.root);if(!t)return!1;let n=Xy.safari&&11==e.root.nodeType&&e.root.activeElement==this.dom&&function(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return zS(e,n)}let n=null;function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.contentDOM.addEventListener("beforeinput",r,!0),e.dom.ownerDocument.execCommand("indent"),e.contentDOM.removeEventListener("beforeinput",r,!0),n?zS(e,n):null}(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;let r=fw(this.dom,n);return r&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&function(e,t){let n=t.focusNode,r=t.focusOffset;if(!n||t.anchorNode!=n||t.anchorOffset!=r)return!1;for(r=Math.min(r,yw(n));;)if(r){if(1!=n.nodeType)return!1;let e=n.childNodes[r-1];"false"==e.contentEditable?r--:(n=e,r=yw(n))}else{if(n==e)return!0;r=gw(n),n=n.parentNode}}(this.dom,n)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(n),r&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let n=this.dom;n;)if(1==n.nodeType)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==n?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(n),n=n.assignedSlot||n.parentNode;else{if(11!=n.nodeType)break;n=n.host}if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let e of this.scrollTargets)e.removeEventListener("scroll",this.onScroll);for(let e of this.scrollTargets=t)e.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,BS),FS&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),FS&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){var n;if(!this.delayedAndroidKey){let e=()=>{let e=this.delayedAndroidKey;if(e){this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=e.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&e.force&&Aw(this.dom,e.key,e.keyCode)}};this.flushingAndroidKey=this.view.win.requestAnimationFrame(e)}this.delayedAndroidKey&&"Enter"!=e||(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(null===(n=this.delayedAndroidKey)||void 0===n?void 0:n.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,n=-1,r=!1;for(let i of e){let e=this.readMutation(i);e&&(e.typeOver&&(r=!0),-1==t?({from:t,to:n}=e):(t=Math.min(e.from,t),n=Math.max(e.to,n)))}return{from:t,to:n,typeOver:r}}readChange(){let{from:e,to:t,typeOver:n}=this.processRecords(),r=this.selectionChanged&&fw(this.dom,this.selectionRange);if(e<0&&!r)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let i=new kk(this.view,e,t,n);return this.view.docView.domChanged={newSel:i.newSel?i.newSel.main:null},i}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let n=this.view.state,r=Ek(this.view,t);return this.view.state==n&&(t.domChanged||t.newSel&&!Ok(this.view.state.selection,t.newSel.main))&&this.view.update([]),r}readMutation(e){let t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty("attributes"==e.type),"childList"==e.type){let n=WS(t,e.previousSibling||e.target.previousSibling,-1),r=WS(t,e.nextSibling||e.target.nextSibling,1);return{from:n?t.posAfter(n):t.posAtStart,to:r?t.posBefore(r):t.posAtEnd,typeOver:!1}}return"characterData"==e.type?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(px)!=e.state.facet(px)&&(e.view.contentDOM.editContext=e.state.facet(px)?this.editContext.editContext:null))}destroy(){var e,t,n;this.stop(),null===(e=this.intersection)||void 0===e||e.disconnect(),null===(t=this.gapIntersection)||void 0===t||t.disconnect(),null===(n=this.resizeScroll)||void 0===n||n.disconnect();for(let e of this.scrollTargets)e.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function WS(e,t,n){for(;t;){let r=Px.get(t);if(r&&r.parent==e)return r;let i=t.parentNode;t=i!=e.dom?i:n>0?t.nextSibling:t.previousSibling}return null}function zS(e,t){let n=t.startContainer,r=t.startOffset,i=t.endContainer,o=t.endOffset,s=e.docView.domAtPos(e.state.selection.main.anchor,1);return mw(s.node,s.offset,i,o)&&([n,r,i,o]=[i,o,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:o}}class HS{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=n=>{let r=e.state.selection.main,{anchor:i,head:o}=r,s=this.toEditorPos(n.updateRangeStart),a=this.toEditorPos(n.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:n.updateRangeStart,editorBase:s,drifted:!1});let l=a-s>n.text.length;s==this.from&&i<this.from?s=i:a==this.to&&i>this.to&&(a=i);let c=Nk(e.state.sliceDoc(s,a),n.text,(l?r.from:r.to)-s,l?"end":null);if(!c){let t=fb.single(this.toEditorPos(n.selectionStart),this.toEditorPos(n.selectionEnd));return void(Ok(t,r)||e.dispatch({selection:t,userEvent:"select"}))}let u={from:c.from+s,to:c.toA+s,insert:Hv.of(n.text.slice(c.from,c.toB).split("\n"))};if((Xy.mac||Xy.android)&&u.from==o-1&&/^\. ?$/.test(n.text)&&"off"==e.contentDOM.getAttribute("autocorrect")&&(u={from:s,to:a,insert:Hv.of([n.text.replace("."," ")])}),this.pendingContextChange=u,!e.state.readOnly){let t=this.to-this.from+(u.to-u.from+u.insert.length);Ck(e,u,fb.single(this.toEditorPos(n.selectionStart,t),this.toEditorPos(n.selectionEnd,t)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),u.from<u.to&&!u.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,n.updateRangeStart-1),Math.min(t.text.length,n.updateRangeStart+1)))&&this.handlers.compositionend(n)},this.handlers.characterboundsupdate=n=>{let r=[],i=null;for(let t=this.toEditorPos(n.rangeStart),o=this.toEditorPos(n.rangeEnd);t<o;t++){let n=e.coordsForChar(t);i=n&&new DOMRect(n.left,n.top,n.right-n.left,n.bottom-n.top)||i||new DOMRect,r.push(i)}t.updateCharacterBounds(n.rangeStart,r)},this.handlers.textformatupdate=t=>{let n=[];for(let e of t.getTextFormats()){let t=e.underlineStyle,r=e.underlineThickness;if(!/none/i.test(t)&&!/none/i.test(r)){let i=this.toEditorPos(e.rangeStart),o=this.toEditorPos(e.rangeEnd);if(i<o){let e=`text-decoration: underline ${/^[a-z]/.test(t)?t+" ":"Dashed"==t?"dashed ":"Squiggle"==t?"wavy ":""}${/thin/i.test(r)?1:2}px`;n.push(iw.mark({attributes:{style:e}}).range(i,o))}}}e.dispatch({effects:dx.of(iw.set(n))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:t}=this.composing;this.composing=null,t&&this.reset(e.state)}};for(let e in this.handlers)t.addEventListener(e,this.handlers[e]);this.measureReq={read:e=>{this.editContext.updateControlBounds(e.contentDOM.getBoundingClientRect());let t=hw(e.root);t&&t.rangeCount&&this.editContext.updateSelectionBounds(t.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,n=!1,r=this.pendingContextChange;return e.changes.iterChanges((i,o,s,a,l)=>{if(n)return;let c=l.length-(o-i);if(r&&o>=r.to){if(r.from==i&&r.to==o&&r.insert.eq(l))return r=this.pendingContextChange=null,t+=c,void(this.to+=c);r=null,this.revertPending(e.state)}if(i+=t,(o+=t)<=this.from)this.from+=c,this.to+=c;else if(i<this.to){if(i<this.from||o>this.to||this.to-this.from+l.length>3e4)return void(n=!0);this.editContext.updateText(this.toContextPos(i),this.toContextPos(o),l.toString()),this.to+=c}t+=c}),r&&!n&&this.revertPending(e.state),!n}update(e){let t=this.pendingContextChange,n=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(n.from,n.to)&&e.transactions.some(e=>!e.isUserEvent("input.type")&&e.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):this.applyEdits(e)&&this.rangeIsValid(e.state)?(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state):(this.pendingContextChange=null,this.reset(e.state)),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,n=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),r=this.toContextPos(t.head);this.editContext.selectionStart==n&&this.editContext.selectionEnd==r||this.editContext.updateSelection(n,r)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>3e4)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let n=this.composing;return n&&n.drifted?n.editorBase+(e-n.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class VS{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:n}=e;this.dispatchTransactions=e.dispatchTransactions||n&&(e=>e.forEach(e=>n(e,this)))||(e=>this.update(e)),this.dispatch=this.dispatch.bind(this),this._root=e.root||function(e){for(;e;){if(e&&(9==e.nodeType||11==e.nodeType&&e.host))return e;e=e.assignedSlot||e.parentNode}return null}(e.parent)||document,this.viewState=new xS(e.state||iy.create(e)),e.scrollTo&&e.scrollTo.is(hx)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(gx).map(e=>new bx(e));for(let e of this.plugins)e.update(this);this.observer=new jS(this),this.inputState=new Ak(this),this.inputState.ensureHandlers(this.plugins),this.docView=new nk(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),(null===(t=document.fonts)||void 0===t?void 0:t.ready)&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent=!0,this.requestMeasure()})}dispatch(...e){let t=1==e.length&&e[0]instanceof Kb?e:1==e.length&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(0!=this.updateState)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t,n=!1,r=!1,i=this.state;for(let t of e){if(t.startState!=i)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");i=t.state}if(this.destroyed)return void(this.viewState.state=i);let o=this.hasFocus,s=0,a=null;e.some(e=>e.annotation(Gk))?(this.inputState.notifiedFocused=o,s=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=Xk(i,o),a||(s=1));let l=this.observer.delayedAndroidKey,c=null;if(l?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(i.doc)||!this.state.selection.eq(i.selection))&&(c=null)):this.observer.clear(),i.facet(iy.phrases)!=this.state.facet(iy.phrases))return this.setState(i);t=Rx.create(this,i,e),t.flags|=s;let u=this.viewState.scrollTarget;try{this.updateState=2;for(let t of e){if(u&&(u=u.map(t.changes)),t.scrollIntoView){let{main:e}=t.state.selection;u=new ux(e.empty?e:fb.cursor(e.head,e.head>e.anchor?-1:1))}for(let e of t.effects)e.is(hx)&&(u=e.value.clip(this.state))}this.viewState.update(t,u),this.bidiCache=$S.update(this.bidiCache,t.changes),t.empty||(this.updatePlugins(t),this.inputState.update(t)),n=this.docView.update(t),this.state.facet(Mx)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(e=>e.isUserEvent("select.pointer")))}finally{this.updateState=0}if(t.startState.facet(MS)!=t.state.facet(MS)&&(this.viewState.mustMeasureContent=!0),(n||r||u||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!t.empty)for(let e of this.state.facet(nx))try{e(t)}catch(e){fx(this.state,e,"update listener")}(a||c)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!Ek(this,c)&&l.force&&Aw(this.contentDOM,l.key,l.keyCode)})}setState(e){if(0!=this.updateState)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed)return void(this.viewState.state=e);this.updateState=2;let t=this.hasFocus;try{for(let e of this.plugins)e.destroy(this);this.viewState=new xS(e),this.plugins=e.facet(gx).map(e=>new bx(e)),this.pluginMap.clear();for(let e of this.plugins)e.update(this);this.docView.destroy(),this.docView=new nk(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(gx),n=e.state.facet(gx);if(t!=n){let r=[];for(let i of n){let n=t.indexOf(i);if(n<0)r.push(new bx(i));else{let t=this.plugins[n];t.mustUpdate=e,r.push(t)}}for(let t of this.plugins)t.mustUpdate!=e&&t.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let t of this.plugins)t.mustUpdate=e;for(let e=0;e<this.plugins.length;e++)this.plugins[e].update(this);t!=n&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(e){fx(this.state,e,"doc view update listener")}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey)return this.measureScheduled=-1,void this.requestMeasure();this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,n=this.scrollDOM,r=n.scrollTop*this.scaleY,{scrollAnchorPos:i,scrollAnchorHeight:o}=this.viewState;Math.abs(r-this.viewState.scrollTop)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let e=0;;e++){if(o<0)if(Mw(n))i=-1,o=this.viewState.heightMap.height;else{let e=this.viewState.scrollAnchorAt(r);i=e.from,o=e.top}this.updateState=1;let s=this.viewState.measure(this);if(!s&&!this.measureRequests.length&&null==this.viewState.scrollTarget)break;if(e>5)break;let a=[];4&s||([this.measureRequests,a]=[a,this.measureRequests]);let l=a.map(e=>{try{return e.read(this)}catch(e){return fx(this.state,e),US}}),c=Rx.create(this,this.state,[]),u=!1;c.flags|=s,t?t.flags|=s:t=c,this.updateState=2,c.empty||(this.updatePlugins(c),this.inputState.update(c),this.updateAttrs(),u=this.docView.update(c),u&&this.docViewUpdate());for(let e=0;e<a.length;e++)if(l[e]!=US)try{let t=a[e];t.write&&t.write(l[e],this)}catch(e){fx(this.state,e)}if(u&&this.docView.updateSelection(!0),!c.viewportChanged&&0==this.measureRequests.length){if(this.viewState.editorHeight){if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}{let e=(i<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(i).top)-o;if(e>1||e<-1){r+=e,n.scrollTop=r/this.scaleY,o=-1;continue}}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let e of this.state.facet(nx))e(t)}get themeClasses(){return RS+" "+(this.state.facet(TS)?PS:DS)+" "+this.state.facet(MS)}updateAttrs(){let e=KS(this,yx,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(px)?"true":"false",class:"cm-content",style:`${Xy.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),KS(this,wx,t);let n=this.observer.ignore(()=>{let n=ew(this.contentDOM,this.contentAttrs,t),r=ew(this.dom,this.editorAttrs,e);return n||r});return this.editorAttrs=e,this.contentAttrs=t,n}showAnnouncements(e){let t=!0;for(let n of e)for(let e of n.effects)if(e.is(VS.announce)){t&&(this.announceDOM.textContent=""),t=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=e.value}}mountStyles(){this.styleModules=this.state.facet(Mx);let e=this.state.facet(VS.cspNonce);Ay.mount(this.root,this.styleModules.concat(_S).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(2==this.updateState)throw new Error("Reading the editor layout isn't allowed during an update");0==this.updateState&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(null!=e.key)for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key)return void(this.measureRequests[t]=e);this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(void 0===t||t&&t.plugin!=e)&&this.pluginMap.set(e,t=this.plugins.find(t=>t.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,n){return dk(this,e,ck(this,e,t,n))}moveByGroup(e,t){return dk(this,e,ck(this,e,t,t=>function(e,t,n){let r=e.state.charCategorizer(t),i=r(n);return e=>{let t=r(e);return i==ey.Space&&(i=t),i==t}}(this,e.head,t)))}visualLineSide(e,t){let n=this.bidiSpans(e),r=this.textDirectionAt(e.from),i=n[t?n.length-1:0];return fb.cursor(i.side(t,r)+e.from,i.forward(!t,r)?1:-1)}moveToLineBoundary(e,t,n=!0){return function(e,t,n,r){let i=lk(e,t.head,t.assoc||-1),o=r&&i.type==rw.Text&&(e.lineWrapping||i.widgetLineBreaks)?e.coordsAtPos(t.assoc<0&&t.head>i.from?t.head-1:t.head):null;if(o){let t=e.dom.getBoundingClientRect(),r=e.textDirectionAt(i.from),s=e.posAtCoords({x:n==(r==Pw.LTR)?t.right-1:t.left+1,y:(o.top+o.bottom)/2});if(null!=s)return fb.cursor(s,n?-1:1)}return fb.cursor(n?i.to:i.from,n?-1:1)}(this,e,t,n)}moveVertically(e,t,n){return dk(this,e,function(e,t,n,r){let i=t.head,o=n?1:-1;if(i==(n?e.state.doc.length:0))return fb.cursor(i,t.assoc);let s,a=t.goalColumn,l=e.contentDOM.getBoundingClientRect(),c=e.coordsAtPos(i,t.assoc||-1),u=e.documentTop;if(c)null==a&&(a=c.left-l.left),s=o<0?c.top:c.bottom;else{let t=e.viewState.lineBlockAt(i);null==a&&(a=Math.min(l.right-l.left,e.defaultCharacterWidth*(i-t.from))),s=(o<0?t.top:t.bottom)+u}let h=pk(e,{x:l.left+a,y:s+(null!=r?r:e.viewState.heightOracle.textHeight>>1)*o},!1,o);return fb.cursor(h.pos,h.assoc,void 0,a)}(this,e,t,n))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let n=pk(this,e,t);return n&&n.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),pk(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let n=this.docView.coordsAt(e,t);if(!n||n.left==n.right)return n;let r=this.state.doc.lineAt(e),i=this.bidiSpans(r);return ww(n,i[Vw.find(i,e-r.from,-1,t)].dir==Pw.LTR==t>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(ax)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>qS)return Yw(e.length);let t,n=this.textDirectionAt(e.from);for(let r of this.bidiCache)if(r.from==e.from&&r.dir==n&&(r.fresh||qw(r.isolates,t=Nx(this,e))))return r.order;t||(t=Nx(this,e));let r=function(e,t,n){if(!e)return[new Vw(0,0,t==Iw?1:0)];if(t==Lw&&!n.length&&!Hw.test(e))return Yw(e.length);if(n.length)for(;e.length>Uw.length;)Uw[Uw.length]=256;let r=[],i=t==Lw?0:1;return Kw(e,i,i,n,0,e.length,r),r}(e.text,n,t);return this.bidiCache.push(new $S(e.from,e.to,n,t,!0,r)),r}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Xy.safari&&(null===(e=this.inputState)||void 0===e?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Nw(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((9==e.nodeType?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return hx.of(new ux("number"==typeof e?fb.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,n=this.viewState.scrollAnchorAt(e);return hx.of(new ux(fb.cursor(n.from),"start","start",n.top-e,t,!0))}setTabFocusMode(e){null==e?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:"boolean"==typeof e?this.inputState.tabFocusMode=e?0:-1:0!=this.inputState.tabFocusMode&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return vx.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return vx.define(()=>({}),{eventObservers:e})}static theme(e,t){let n=Ay.newName(),r=[MS.of(n),Mx.of(IS(`.${n}`,e))];return t&&t.dark&&r.push(TS.of(!0)),r}static baseTheme(e){return Mb.lowest(Mx.of(IS("."+RS,e,LS)))}static findFromDOM(e){var t;let n=e.querySelector(".cm-content"),r=n&&Px.get(n)||Px.get(e);return(null===(t=null==r?void 0:r.root)||void 0===t?void 0:t.view)||null}}VS.styleModule=Mx,VS.inputHandler=rx,VS.clipboardInputFilter=ox,VS.clipboardOutputFilter=sx,VS.scrollHandler=cx,VS.focusChangeEffect=ix,VS.perLineTextDirection=ax,VS.exceptionSink=tx,VS.updateListener=nx,VS.editable=px,VS.mouseSelectionStyle=ex,VS.dragMovesSelection=Zw,VS.clickAddsSelectionRange=Qw,VS.decorations=xx,VS.blockWrappers=kx,VS.outerDecorations=Sx,VS.atomicRanges=Ex,VS.bidiIsolatedRanges=Cx,VS.scrollMargins=Ox,VS.darkTheme=TS,VS.cspNonce=gb.define({combine:e=>e.length?e[0]:""}),VS.contentAttributes=wx,VS.editorAttributes=yx,VS.lineWrapping=VS.contentAttributes.of({class:"cm-lineWrapping"}),VS.announce=$b.define();const qS=4096,US={};class $S{constructor(e,t,n,r,i,o){this.from=e,this.to=t,this.dir=n,this.isolates=r,this.fresh=i,this.order=o}static update(e,t){if(t.empty&&!e.some(e=>e.fresh))return e;let n=[],r=e.length?e[e.length-1].dir:Pw.LTR;for(let i=Math.max(0,e.length-10);i<e.length;i++){let o=e[i];o.dir!=r||t.touchesRange(o.from,o.to)||n.push(new $S(t.mapPos(o.from,1),t.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return n}}function KS(e,t,n){for(let r=e.state.facet(t),i=r.length-1;i>=0;i--){let t=r[i],o="function"==typeof t?t(e):t;o&&Jy(o,n)}return n}const YS=Xy.mac?"mac":Xy.windows?"win":Xy.linux?"linux":"key";function GS(e,t,n){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),!1!==n&&t.shiftKey&&(e="Shift-"+e),e}const XS=Mb.default(VS.domEventHandlers({keydown:(e,t)=>rE(ZS(t.state),e,t,"editor")})),JS=gb.define({enables:XS}),QS=new WeakMap;function ZS(e){let t=e.facet(JS),n=QS.get(t);return n||QS.set(t,n=function(e,t=YS){let n=Object.create(null),r=Object.create(null),i=(e,t)=>{let n=r[e];if(null==n)r[e]=t;else if(n!=t)throw new Error("Key binding "+e+" is used both as a regular binding and as a multi-stroke prefix")},o=(e,r,o,s,a)=>{var l,c;let u=n[e]||(n[e]=Object.create(null)),h=r.split(/ (?!$)/).map(e=>function(e,t){const n=e.split(/-(?!$)/);let r,i,o,s,a=n[n.length-1];"Space"==a&&(a=" ");for(let e=0;e<n.length-1;++e){const a=n[e];if(/^(cmd|meta|m)$/i.test(a))s=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))i=!0;else if(/^s(hift)?$/i.test(a))o=!0;else{if(!/^mod$/i.test(a))throw new Error("Unrecognized modifier name: "+a);"mac"==t?s=!0:i=!0}}return r&&(a="Alt-"+a),i&&(a="Ctrl-"+a),s&&(a="Meta-"+a),o&&(a="Shift-"+a),a}(e,t));for(let t=1;t<h.length;t++){let n=h.slice(0,t).join(" ");i(n,!0),u[n]||(u[n]={preventDefault:!0,stopPropagation:!1,run:[t=>{let r=eE={view:t,prefix:n,scope:e};return setTimeout(()=>{eE==r&&(eE=null)},tE),!0}]})}let d=h.join(" ");i(d,!1);let f=u[d]||(u[d]={preventDefault:!1,stopPropagation:!1,run:(null===(c=null===(l=u._any)||void 0===l?void 0:l.run)||void 0===c?void 0:c.slice())||[]});o&&f.run.push(o),s&&(f.preventDefault=!0),a&&(f.stopPropagation=!0)};for(let r of e){let e=r.scope?r.scope.split(" "):["editor"];if(r.any)for(let t of e){let e=n[t]||(n[t]=Object.create(null));e._any||(e._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:i}=r;for(let t in e)e[t].run.push(e=>i(e,nE))}let i=r[t]||r.key;if(i)for(let t of e)o(t,i,r.run,r.preventDefault,r.stopPropagation),r.shift&&o(t,"Shift-"+i,r.shift,r.preventDefault,r.stopPropagation)}return n}(t.reduce((e,t)=>e.concat(t),[]))),n}let eE=null;const tE=4e3;let nE=null;function rE(e,t,n,r){nE=t;let i=function(e){var t=!(Py&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||Ly&&e.shiftKey&&e.key&&1==e.key.length||"Unidentified"==e.key)&&e.key||(e.shiftKey?Dy:Ry)[e.keyCode]||e.key||"Unidentified";return"Esc"==t&&(t="Escape"),"Del"==t&&(t="Delete"),"Left"==t&&(t="ArrowLeft"),"Up"==t&&(t="ArrowUp"),"Right"==t&&(t="ArrowRight"),"Down"==t&&(t="ArrowDown"),t}(t),o=tb(Zv(i,0))==i.length&&" "!=i,s="",a=!1,l=!1,c=!1;eE&&eE.view==n&&eE.scope==r&&(s=eE.prefix+" ",Pk.indexOf(t.keyCode)<0&&(l=!0,eE=null));let u,h,d=new Set,f=e=>{if(e){for(let t of e.run)if(!d.has(t)&&(d.add(t),t(n)))return e.stopPropagation&&(c=!0),!0;e.preventDefault&&(e.stopPropagation&&(c=!0),l=!0)}return!1},p=e[r];return p&&(f(p[s+GS(i,t,!o)])?a=!0:!o||!(t.altKey||t.metaKey||t.ctrlKey)||Xy.windows&&t.ctrlKey&&t.altKey||Xy.mac&&t.altKey&&!t.ctrlKey&&!t.metaKey||!(u=Ry[t.keyCode])||u==i?o&&t.shiftKey&&f(p[s+GS(i,t,!0)])&&(a=!0):(f(p[s+GS(u,t,!0)])||t.shiftKey&&(h=Dy[t.keyCode])!=i&&h!=u&&f(p[s+GS(h,t,!1)]))&&(a=!0),!a&&f(p._any)&&(a=!0)),l&&(a=!0),a&&c&&t.stopPropagation(),nE=null,a}class iE{constructor(e,t,n,r,i){this.className=e,this.left=t,this.top=n,this.width=r,this.height=i}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className==this.className&&(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",null!=this.width&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,n){if(n.empty){let r=e.coordsAtPos(n.head,n.assoc||1);if(!r)return[];let i=oE(e);return[new iE(t,r.left-i.left,r.top-i.top,null,r.bottom-r.top)]}return function(e,t,n){if(n.to<=e.viewport.from||n.from>=e.viewport.to)return[];let r=Math.max(n.from,e.viewport.from),i=Math.min(n.to,e.viewport.to),o=e.textDirection==Pw.LTR,s=e.contentDOM,a=s.getBoundingClientRect(),l=oE(e),c=s.querySelector(".cm-line"),u=c&&window.getComputedStyle(c),h=a.left+(u?parseInt(u.paddingLeft)+Math.min(0,parseInt(u.textIndent)):0),d=a.right-(u?parseInt(u.paddingRight):0),f=lk(e,r,1),p=lk(e,i,-1),m=f.type==rw.Text?f:null,g=p.type==rw.Text?p:null;m&&(e.lineWrapping||f.widgetLineBreaks)&&(m=sE(e,r,1,m));g&&(e.lineWrapping||p.widgetLineBreaks)&&(g=sE(e,i,-1,g));if(m&&g&&m.from==g.from&&m.to==g.to)return b(y(n.from,n.to,m));{let t=m?y(n.from,null,m):w(f,!1),r=g?y(null,n.to,g):w(p,!0),i=[];return(m||f).to<(g||p).from-(m&&g?1:0)||f.widgetLineBreaks>1&&t.bottom+e.defaultLineHeight/2<r.top?i.push(v(h,t.bottom,d,r.top)):t.bottom<r.top&&e.elementAtHeight((t.bottom+r.top)/2).type==rw.Text&&(t.bottom=r.top=(t.bottom+r.top)/2),b(t).concat(i).concat(b(r))}function v(e,n,r,i){return new iE(t,e-l.left,n-l.top,r-e,i-n)}function b({top:e,bottom:t,horizontal:n}){let r=[];for(let i=0;i<n.length;i+=2)r.push(v(n[i],e,n[i+1],t));return r}function y(t,n,r){let i=1e9,s=-1e9,a=[];function l(t,n,l,c,u){let f=e.coordsAtPos(t,t==r.to?-2:2),p=e.coordsAtPos(l,l==r.from?2:-2);f&&p&&(i=Math.min(f.top,p.top,i),s=Math.max(f.bottom,p.bottom,s),u==Pw.LTR?a.push(o&&n?h:f.left,o&&c?d:p.right):a.push(!o&&c?h:p.left,!o&&n?d:f.right))}let c=null!=t?t:r.from,u=null!=n?n:r.to;for(let r of e.visibleRanges)if(r.to>c&&r.from<u)for(let i=Math.max(r.from,c),o=Math.min(r.to,u);;){let r=e.state.doc.lineAt(i);for(let s of e.bidiSpans(r)){let e=s.from+r.from,a=s.to+r.from;if(e>=o)break;a>i&&l(Math.max(e,i),null==t&&e<=c,Math.min(a,o),null==n&&a>=u,s.dir)}if(i=r.to+1,i>=o)break}return 0==a.length&&l(c,null==t,u,null==n,e.textDirection),{top:i,bottom:s,horizontal:a}}function w(e,t){let n=a.top+(t?e.top:e.bottom);return{top:n,bottom:n,horizontal:[]}}}(e,t,n)}}function oE(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==Pw.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function sE(e,t,n,r){let i=e.coordsAtPos(t,2*n);if(!i)return r;let o=e.dom.getBoundingClientRect(),s=(i.top+i.bottom)/2,a=e.posAtCoords({x:o.left+1,y:s}),l=e.posAtCoords({x:o.right-1,y:s});return null==a||null==l?r:{from:Math.max(r.from,Math.min(a,l)),to:Math.min(r.to,Math.max(a,l))}}class aE{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(lE)!=e.state.facet(lE)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){!1!==this.layer.updateOnDocViewUpdate&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,n=e.facet(lE);for(;t<n.length&&n[t]!=this.layer;)t++;this.dom.style.zIndex=String((this.layer.above?150:-1)-t)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:t}=this.view;e==this.scaleX&&t==this.scaleY||(this.scaleX=e,this.scaleY=t,this.dom.style.transform=`scale(${1/e}, ${1/t})`)}draw(e){if(e.length!=this.drawn.length||e.some((e,t)=>{return n=e,r=this.drawn[t],!(n.constructor==r.constructor&&n.eq(r));var n,r})){let t=this.dom.firstChild,n=0;for(let r of e)r.update&&t&&r.constructor&&this.drawn[n].constructor&&r.update(t,this.drawn[n])?(t=t.nextSibling,n++):this.dom.insertBefore(r.draw(),t);for(;t;){let e=t.nextSibling;t.remove(),t=e}this.drawn=e,Xy.safari&&Xy.safari_version>=26&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const lE=gb.define();function cE(e){return[vx.define(t=>new aE(t,e)),lE.of(e)]}const uE=gb.define({combine:e=>oy(e,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})});function hE(e){return e.startState.facet(uE)!=e.state.facet(uE)}const dE=cE({above:!0,markers(e){let{state:t}=e,n=t.facet(uE),r=[];for(let i of t.selection.ranges){let o=i==t.selection.main;if(i.empty||n.drawRangeCursor){let t=o?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",n=i.empty?i:fb.cursor(i.head,i.head>i.anchor?-1:1);for(let i of iE.forRange(e,t,n))r.push(i)}}return r},update(e,t){e.transactions.some(e=>e.selection)&&(t.style.animationName="cm-blink"==t.style.animationName?"cm-blink2":"cm-blink");let n=hE(e);return n&&fE(e.state,t),e.docChanged||e.selectionSet||n},mount(e,t){fE(t.state,e)},class:"cm-cursorLayer"});function fE(e,t){t.style.animationDuration=e.facet(uE).cursorBlinkRate+"ms"}const pE=cE({above:!1,markers:e=>e.state.selection.ranges.map(t=>t.empty?[]:iE.forRange(e,"cm-selectionBackground",t)).reduce((e,t)=>e.concat(t)),update:(e,t)=>e.docChanged||e.selectionSet||e.viewportChanged||hE(e),class:"cm-selectionLayer"}),mE=Mb.highest(VS.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),gE=$b.define({map:(e,t)=>null==e?null:t.mapPos(e)}),vE=Sb.define({create:()=>null,update:(e,t)=>(null!=e&&(e=t.changes.mapPos(e)),t.effects.reduce((e,t)=>t.is(gE)?t.value:e,e))}),bE=vx.fromClass(class{constructor(e){this.view=e,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(e){var t;let n=e.state.field(vE);null==n?null!=this.cursor&&(null===(t=this.cursor)||void 0===t||t.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(e.startState.field(vE)!=n||e.docChanged||e.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:e}=this,t=e.state.field(vE),n=null!=t&&e.coordsAtPos(t);if(!n)return null;let r=e.scrollDOM.getBoundingClientRect();return{left:n.left-r.left+e.scrollDOM.scrollLeft*e.scaleX,top:n.top-r.top+e.scrollDOM.scrollTop*e.scaleY,height:n.bottom-n.top}}drawCursor(e){if(this.cursor){let{scaleX:t,scaleY:n}=this.view;e?(this.cursor.style.left=e.left/t+"px",this.cursor.style.top=e.top/n+"px",this.cursor.style.height=e.height/n+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(e){this.view.state.field(vE)!=e&&this.view.dispatch({effects:gE.of(e)})}},{eventObservers:{dragover(e){this.setDropPos(this.view.posAtCoords({x:e.clientX,y:e.clientY}))},dragleave(e){e.target!=this.view.contentDOM&&this.view.contentDOM.contains(e.relatedTarget)||this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function yE(e,t,n,r,i){t.lastIndex=0;for(let o,s=e.iterRange(n,r),a=n;!s.next().done;a+=s.value.length)if(!s.lineBreak)for(;o=t.exec(s.value);)i(a+o.index,o)}class wE{constructor(e){const{regexp:t,decoration:n,decorate:r,boundary:i,maxLength:o=1e3}=e;if(!t.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,r)this.addMatch=(e,t,n,i)=>r(i,n,n+e[0].length,e,t);else if("function"==typeof n)this.addMatch=(e,t,r,i)=>{let o=n(e,t,r);o&&i(r,r+e[0].length,o)};else{if(!n)throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.addMatch=(e,t,r,i)=>i(r,r+e[0].length,n)}this.boundary=i,this.maxLength=o}createDeco(e){let t=new dy,n=t.add.bind(t);for(let{from:t,to:r}of function(e,t){let n=e.visibleRanges;if(1==n.length&&n[0].from==e.viewport.from&&n[0].to==e.viewport.to)return n;let r=[];for(let{from:i,to:o}of n)i=Math.max(e.state.doc.lineAt(i).from,i-t),o=Math.min(e.state.doc.lineAt(o).to,o+t),r.length&&r[r.length-1].to>=i?r[r.length-1].to=o:r.push({from:i,to:o});return r}(e,this.maxLength))yE(e.state.doc,this.regexp,t,r,(t,r)=>this.addMatch(r,e,t,n));return t.finish()}updateDeco(e,t){let n=1e9,r=-1;return e.docChanged&&e.changes.iterChanges((t,i,o,s)=>{s>=e.view.viewport.from&&o<=e.view.viewport.to&&(n=Math.min(o,n),r=Math.max(s,r))}),e.viewportMoved||r-n>1e3?this.createDeco(e.view):r>-1?this.updateRange(e.view,t.map(e.changes),n,r):t}updateRange(e,t,n,r){for(let i of e.visibleRanges){let o=Math.max(i.from,n),s=Math.min(i.to,r);if(s>=o){let n=e.state.doc.lineAt(o),r=n.to<s?e.state.doc.lineAt(s):n,a=Math.max(i.from,n.from),l=Math.min(i.to,r.to);if(this.boundary){for(;o>n.from;o--)if(this.boundary.test(n.text[o-1-n.from])){a=o;break}for(;s<r.to;s++)if(this.boundary.test(r.text[s-r.from])){l=s;break}}let c,u=[],h=(e,t,n)=>u.push(n.range(e,t));if(n==r)for(this.regexp.lastIndex=a-n.from;(c=this.regexp.exec(n.text))&&c.index<l-n.from;)this.addMatch(c,e,c.index+n.from,h);else yE(e.state.doc,this.regexp,a,l,(t,n)=>this.addMatch(n,e,t,h));t=t.update({filterFrom:a,filterTo:l,filter:(e,t)=>e<a||t>l,add:u})}}return t}}const xE=null!=/x/.unicode?"gu":"g",kE=new RegExp("[\0-\b\n--Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\ufeff-]",xE),SE={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let EE=null;const CE=gb.define({combine(e){let t=oy(e,{render:null,specialChars:kE,addSpecialChars:null});return(t.replaceTabs=!function(){var e;if(null==EE&&"undefined"!=typeof document&&document.body){let t=document.body.style;EE=null!=(null!==(e=t.tabSize)&&void 0!==e?e:t.MozTabSize)}return EE||!1}())&&(t.specialChars=new RegExp("\t|"+t.specialChars.source,xE)),t.addSpecialChars&&(t.specialChars=new RegExp(t.specialChars.source+"|"+t.addSpecialChars.source,xE)),t}});let NE=null;class OE extends nw{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=function(e){return e>=32?"•":10==e?"␤":String.fromCharCode(9216+e)}(this.code),n=e.state.phrase("Control character")+" "+(SE[this.code]||"0x"+this.code.toString(16)),r=this.options.render&&this.options.render(this.code,n,t);if(r)return r;let i=document.createElement("span");return i.textContent=t,i.title=n,i.setAttribute("aria-label",n),i.className="cm-specialChar",i}ignoreEvent(){return!1}}class AE extends nw{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent="\t",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}}const ME=iw.line({class:"cm-activeLine"}),TE=vx.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.docChanged||e.selectionSet)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=-1,n=[];for(let r of e.state.selection.ranges){let i=e.lineBlockAt(r.head);i.from>t&&(n.push(ME.range(i.from)),t=i.from)}return iw.set(n)}},{decorations:e=>e.decorations});class RE extends nw{constructor(e){super(),this.content=e}toDOM(e){let t=document.createElement("span");return t.className="cm-placeholder",t.style.pointerEvents="none",t.appendChild("string"==typeof this.content?document.createTextNode(this.content):"function"==typeof this.content?this.content(e):this.content.cloneNode(!0)),t.setAttribute("aria-hidden","true"),t}coordsAt(e){let t=e.firstChild?pw(e.firstChild):[];if(!t.length)return null;let n=window.getComputedStyle(e.parentNode),r=ww(t[0],"rtl"!=n.direction),i=parseInt(n.lineHeight);return r.bottom-r.top>1.5*i?{left:r.left,right:r.right,top:r.top,bottom:r.top+i}:r}ignoreEvent(){return!1}}const DE=2e3;function PE(e,t){let n=e.posAtCoords({x:t.clientX,y:t.clientY},!1),r=e.state.doc.lineAt(n),i=n-r.from,o=i>DE?-1:i==r.length?function(e,t){let n=e.coordsAtPos(e.viewport.from);return n?Math.round(Math.abs((n.left-t)/e.defaultCharacterWidth)):-1}(e,t.clientX):Sy(r.text,e.state.tabSize,n-r.from);return{line:r.number,col:o,off:i}}function LE(e,t){let n=PE(e,t),r=e.state.selection;return n?{update(e){if(e.docChanged){let t=e.changes.mapPos(e.startState.doc.line(n.line).from),i=e.state.doc.lineAt(t);n={line:i.number,col:n.col,off:Math.min(n.off,i.length)},r=r.map(e.changes)}},get(t,i,o){let s=PE(e,t);if(!s)return r;let a=function(e,t,n){let r=Math.min(t.line,n.line),i=Math.max(t.line,n.line),o=[];if(t.off>DE||n.off>DE||t.col<0||n.col<0){let s=Math.min(t.off,n.off),a=Math.max(t.off,n.off);for(let t=r;t<=i;t++){let n=e.doc.line(t);n.length<=a&&o.push(fb.range(n.from+s,n.to+a))}}else{let s=Math.min(t.col,n.col),a=Math.max(t.col,n.col);for(let t=r;t<=i;t++){let n=e.doc.line(t),r=Ey(n.text,s,e.tabSize,!0);if(r<0)o.push(fb.cursor(n.to));else{let t=Ey(n.text,a,e.tabSize);o.push(fb.range(n.from+r,n.from+t))}}}return o}(e.state,n,s);return a.length?o?fb.create(a.concat(r.ranges)):fb.create(a):r}}:null}const IE={Alt:[18,e=>!!e.altKey],Control:[17,e=>!!e.ctrlKey],Shift:[16,e=>!!e.shiftKey],Meta:[91,e=>!!e.metaKey]},_E={style:"cursor: crosshair"};const BE="-10000px";class FE{constructor(e,t,n,r){this.facet=t,this.createTooltipView=n,this.removeTooltipView=r,this.input=e.state.facet(t),this.tooltips=this.input.filter(e=>e);let i=null;this.tooltipViews=this.tooltips.map(e=>i=n(e,i))}update(e,t){var n;let r=e.state.facet(this.facet),i=r.filter(e=>e);if(r===this.input){for(let t of this.tooltipViews)t.update&&t.update(e);return!1}let o=[],s=t?[]:null;for(let n=0;n<i.length;n++){let r=i[n],a=-1;if(r){for(let e=0;e<this.tooltips.length;e++){let t=this.tooltips[e];t&&t.create==r.create&&(a=e)}if(a<0)o[n]=this.createTooltipView(r,n?o[n-1]:null),s&&(s[n]=!!r.above);else{let r=o[n]=this.tooltipViews[a];s&&(s[n]=t[a]),r.update&&r.update(e)}}}for(let e of this.tooltipViews)o.indexOf(e)<0&&(this.removeTooltipView(e),null===(n=e.destroy)||void 0===n||n.call(e));return t&&(s.forEach((e,n)=>t[n]=e),t.length=s.length),this.input=r,this.tooltips=i,this.tooltipViews=o,!0}}function jE(e){let t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}const WE=gb.define({combine:e=>{var t,n,r;return{position:Xy.ios?"absolute":(null===(t=e.find(e=>e.position))||void 0===t?void 0:t.position)||"fixed",parent:(null===(n=e.find(e=>e.parent))||void 0===n?void 0:n.parent)||null,tooltipSpace:(null===(r=e.find(e=>e.tooltipSpace))||void 0===r?void 0:r.tooltipSpace)||jE}}}),zE=new WeakMap,HE=vx.fromClass(class{constructor(e){this.view=e,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let t=e.state.facet(WE);this.position=t.position,this.parent=t.parent,this.classes=e.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver="function"==typeof ResizeObserver?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new FE(e,$E,(e,t)=>this.createTooltip(e,t),e=>{this.resizeObserver&&this.resizeObserver.unobserve(e.dom),e.dom.remove()}),this.above=this.manager.tooltips.map(e=>!!e.above),this.intersectionObserver="function"==typeof IntersectionObserver?new IntersectionObserver(e=>{Date.now()>this.lastTransaction-50&&e.length>0&&e[e.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),e.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let e of this.manager.tooltipViews)this.intersectionObserver.observe(e.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(e){e.transactions.length&&(this.lastTransaction=Date.now());let t=this.manager.update(e,this.above);t&&this.observeIntersection();let n=t||e.geometryChanged,r=e.state.facet(WE);if(r.position!=this.position&&!this.madeAbsolute){this.position=r.position;for(let e of this.manager.tooltipViews)e.dom.style.position=this.position;n=!0}if(r.parent!=this.parent){this.parent&&this.container.remove(),this.parent=r.parent,this.createContainer();for(let e of this.manager.tooltipViews)this.container.appendChild(e.dom);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(e,t){let n=e.create(this.view),r=t?t.dom:null;if(n.dom.classList.add("cm-tooltip"),e.arrow&&!n.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let e=document.createElement("div");e.className="cm-tooltip-arrow",n.dom.appendChild(e)}return n.dom.style.position=this.position,n.dom.style.top=BE,n.dom.style.left="0px",this.container.insertBefore(n.dom,r),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}destroy(){var e,t,n;this.view.win.removeEventListener("resize",this.measureSoon);for(let t of this.manager.tooltipViews)t.dom.remove(),null===(e=t.destroy)||void 0===e||e.call(t);this.parent&&this.container.remove(),null===(t=this.resizeObserver)||void 0===t||t.disconnect(),null===(n=this.intersectionObserver)||void 0===n||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let e=1,t=1,n=!1;if("fixed"==this.position&&this.manager.tooltipViews.length){let{dom:e}=this.manager.tooltipViews[0];if(Xy.safari){let t=e.getBoundingClientRect();n=Math.abs(t.top+1e4)>1||Math.abs(t.left)>1}else n=!!e.offsetParent&&e.offsetParent!=this.container.ownerDocument.body}if(n||"absolute"==this.position)if(this.parent){let n=this.parent.getBoundingClientRect();n.width&&n.height&&(e=n.width/this.parent.offsetWidth,t=n.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:t}=this.view.viewState);let r=this.view.scrollDOM.getBoundingClientRect(),i=Ax(this.view);return{visible:{left:r.left+i.left,top:r.top+i.top,right:r.right-i.right,bottom:r.bottom-i.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((e,t)=>{let n=this.manager.tooltipViews[t];return n.getCoords?n.getCoords(e.pos):this.view.coordsAtPos(e.pos)}),size:this.manager.tooltipViews.map(({dom:e})=>e.getBoundingClientRect()),space:this.view.state.facet(WE).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:n}}writeMeasure(e){var t;if(e.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let e of this.manager.tooltipViews)e.dom.style.position="absolute"}let{visible:n,space:r,scaleX:i,scaleY:o}=e,s=[];for(let a=0;a<this.manager.tooltips.length;a++){let l=this.manager.tooltips[a],c=this.manager.tooltipViews[a],{dom:u}=c,h=e.pos[a],d=e.size[a];if(!h||!1!==l.clip&&(h.bottom<=Math.max(n.top,r.top)||h.top>=Math.min(n.bottom,r.bottom)||h.right<Math.max(n.left,r.left)-.1||h.left>Math.min(n.right,r.right)+.1)){u.style.top=BE;continue}let f=l.arrow?c.dom.querySelector(".cm-tooltip-arrow"):null,p=f?7:0,m=d.right-d.left,g=null!==(t=zE.get(c))&&void 0!==t?t:d.bottom-d.top,v=c.offset||UE,b=this.view.textDirection==Pw.LTR,y=d.width>r.right-r.left?b?r.left:r.right-d.width:b?Math.max(r.left,Math.min(h.left-(f?14:0)+v.x,r.right-m)):Math.min(Math.max(r.left,h.left-m+(f?14:0)-v.x),r.right-m),w=this.above[a];!l.strictSide&&(w?h.top-g-p-v.y<r.top:h.bottom+g+p+v.y>r.bottom)&&w==r.bottom-h.bottom>h.top-r.top&&(w=this.above[a]=!w);let x=(w?h.top-r.top:r.bottom-h.bottom)-p;if(x<g&&!1!==c.resize){if(x<this.view.defaultLineHeight){u.style.top=BE;continue}zE.set(c,g),u.style.height=(g=x)/o+"px"}else u.style.height&&(u.style.height="");let k=w?h.top-g-p-v.y:h.bottom+p+v.y,S=y+m;if(!0!==c.overlap)for(let e of s)e.left<S&&e.right>y&&e.top<k+g&&e.bottom>k&&(k=w?e.top-g-2-p:e.bottom+p+2);if("absolute"==this.position?(u.style.top=(k-e.parent.top)/o+"px",VE(u,(y-e.parent.left)/i)):(u.style.top=k/o+"px",VE(u,y/i)),f){let e=h.left+(b?v.x:-v.x)-(y+14-7);f.style.left=e/i+"px"}!0!==c.overlap&&s.push({left:y,top:k,right:S,bottom:k+g}),u.classList.toggle("cm-tooltip-above",w),u.classList.toggle("cm-tooltip-below",!w),c.positioned&&c.positioned(e.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let e of this.manager.tooltipViews)e.dom.style.top=BE}},{eventObservers:{scroll(){this.maybeMeasure()}}});function VE(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+"px")}const qE=VS.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:"14px",position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),UE={x:0,y:0},$E=gb.define({enables:[HE,qE]}),KE=gb.define({combine:e=>e.reduce((e,t)=>e.concat(t),[])});class YE{static create(e){return new YE(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new FE(e,KE,(e,t)=>this.createHostedView(e,t),e=>e.dom.remove())}createHostedView(e,t){let n=e.create(this.view);return n.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(n.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&n.mount&&n.mount(this.view),n}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)null===(e=t.destroy)||void 0===e||e.call(t)}passProp(e){let t;for(let n of this.manager.tooltipViews){let r=n[e];if(void 0!==r)if(void 0===t)t=r;else if(t!==r)return}return t}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const GE=$E.compute([KE],e=>{let t=e.facet(KE);return 0===t.length?null:{pos:Math.min(...t.map(e=>e.pos)),end:Math.max(...t.map(e=>{var t;return null!==(t=e.end)&&void 0!==t?t:e.pos})),create:YE.create,above:t[0].above,arrow:t.some(e=>e.arrow)}});class XE{constructor(e,t,n,r,i){this.view=e,this.source=t,this.field=n,this.setHover=r,this.hoverTime=i,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;e<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-e):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:e,lastMove:t}=this,n=e.docView.tile.nearest(t.target);if(!n)return;let r,i=1;if(n.isWidget())r=n.posAtStart;else{if(r=e.posAtCoords(t),null==r)return;let n=e.coordsAtPos(r);if(!n||t.y<n.top||t.y>n.bottom||t.x<n.left-e.defaultCharacterWidth||t.x>n.right+e.defaultCharacterWidth)return;let o=e.bidiSpans(e.state.doc.lineAt(r)).find(e=>e.from<=r&&e.to>=r),s=o&&o.dir==Pw.RTL?-1:1;i=t.x<n.left?-s:s}let o=this.source(e,r,i);if(null==o?void 0:o.then){let t=this.pending={pos:r};o.then(n=>{this.pending==t&&(this.pending=null,!n||Array.isArray(n)&&!n.length||e.dispatch({effects:this.setHover.of(Array.isArray(n)?n:[n])}))},t=>fx(e.state,t,"hover tooltip"))}else!o||Array.isArray(o)&&!o.length||e.dispatch({effects:this.setHover.of(Array.isArray(o)?o:[o])})}get tooltip(){let e=this.view.plugin(HE),t=e?e.manager.tooltips.findIndex(e=>e.create==YE.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t,n;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:r,tooltip:i}=this;if(r.length&&i&&!function(e,t){let n,{left:r,right:i,top:o,bottom:s}=e.getBoundingClientRect();if(n=e.querySelector(".cm-tooltip-arrow")){let e=n.getBoundingClientRect();o=Math.min(e.top,o),s=Math.max(e.bottom,s)}return t.clientX>=r-JE&&t.clientX<=i+JE&&t.clientY>=o-JE&&t.clientY<=s+JE}(i.dom,e)||this.pending){let{pos:i}=r[0]||this.pending,o=null!==(n=null===(t=r[0])||void 0===t?void 0:t.end)&&void 0!==n?n:i;(i==o?this.view.posAtCoords(this.lastMove)==i:function(e,t,n,r,i){let o=e.scrollDOM.getBoundingClientRect(),s=e.documentTop+e.documentPadding.top+e.contentHeight;if(o.left>r||o.right<r||o.top>i||Math.min(o.bottom,s)<i)return!1;let a=e.posAtCoords({x:r,y:i},!1);return a>=t&&a<=n}(this.view,i,o,e.clientX,e.clientY))||(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t.length){let{tooltip:t}=this;t&&t.dom.contains(e.relatedTarget)?this.watchTooltipLeave(t.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=n=>{e.removeEventListener("mouseleave",t),this.active.length&&!this.view.dom.contains(n.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const JE=4;function QE(e,t={}){let n=$b.define(),r=Sb.define({create:()=>[],update(e,r){if(e.length&&(t.hideOnChange&&(r.docChanged||r.selection)?e=[]:t.hideOn&&(e=e.filter(e=>!t.hideOn(r,e))),r.docChanged)){let t=[];for(let n of e){let e=r.changes.mapPos(n.pos,-1,rb.TrackDel);if(null!=e){let i=Object.assign(Object.create(null),n);i.pos=e,null!=i.end&&(i.end=r.changes.mapPos(i.end)),t.push(i)}}e=t}for(let t of r.effects)t.is(n)&&(e=t.value),t.is(eC)&&(e=[]);return e},provide:e=>KE.from(e)});return{active:r,extension:[r,vx.define(i=>new XE(i,e,r,n,t.hoverTime||300)),GE]}}function ZE(e,t){let n=e.plugin(HE);if(!n)return null;let r=n.manager.tooltips.indexOf(t);return r<0?null:n.manager.tooltipViews[r]}const eC=$b.define(),tC=gb.define({combine(e){let t,n;for(let r of e)t=t||r.topContainer,n=n||r.bottomContainer;return{topContainer:t,bottomContainer:n}}});function nC(e,t){let n=e.plugin(rC),r=n?n.specs.indexOf(t):-1;return r>-1?n.panels[r]:null}const rC=vx.fromClass(class{constructor(e){this.input=e.state.facet(sC),this.specs=this.input.filter(e=>e),this.panels=this.specs.map(t=>t(e));let t=e.state.facet(tC);this.top=new iC(e,!0,t.topContainer),this.bottom=new iC(e,!1,t.bottomContainer),this.top.sync(this.panels.filter(e=>e.top)),this.bottom.sync(this.panels.filter(e=>!e.top));for(let e of this.panels)e.dom.classList.add("cm-panel"),e.mount&&e.mount()}update(e){let t=e.state.facet(tC);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new iC(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new iC(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(sC);if(n!=this.input){let t=n.filter(e=>e),r=[],i=[],o=[],s=[];for(let n of t){let t,a=this.specs.indexOf(n);a<0?(t=n(e.view),s.push(t)):(t=this.panels[a],t.update&&t.update(e)),r.push(t),(t.top?i:o).push(t)}this.specs=t,this.panels=r,this.top.sync(i),this.bottom.sync(o);for(let e of s)e.dom.classList.add("cm-panel"),e.mount&&e.mount()}else for(let t of this.panels)t.update&&t.update(e)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:e=>VS.scrollMargins.of(t=>{let n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})});class iC{constructor(e,t,n){this.view=e,this.top=t,this.container=n,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(0==this.panels.length)return void(this.dom&&(this.dom.remove(),this.dom=void 0));if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let e=this.container||this.view.dom;e.insertBefore(this.dom,this.top?e.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=oC(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=oC(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(this.container&&this.classes!=this.view.themeClasses){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}}function oC(e){let t=e.nextSibling;return e.remove(),t}const sC=gb.define({enables:rC});function aC(e,t){let n,r=new Promise(e=>n=e),i=e=>function(e,t,n){let r=t.content?t.content(e,()=>s(null)):null;if(!r){if(r=By("form"),t.input){let e=By("input",t.input);/^(text|password|number|email|tel|url)$/.test(e.type)&&e.classList.add("cm-textfield"),e.name||(e.name="input"),r.appendChild(By("label",(t.label||"")+": ",e))}else r.appendChild(document.createTextNode(t.label||""));r.appendChild(document.createTextNode(" ")),r.appendChild(By("button",{class:"cm-button",type:"submit"},t.submitLabel||"OK"))}let i="FORM"==r.nodeName?[r]:r.querySelectorAll("form");for(let e=0;e<i.length;e++){let t=i[e];t.addEventListener("keydown",e=>{27==e.keyCode?(e.preventDefault(),s(null)):13==e.keyCode&&(e.preventDefault(),s(t))}),t.addEventListener("submit",e=>{e.preventDefault(),s(t)})}let o=By("div",r,By("button",{onclick:()=>s(null),"aria-label":e.state.phrase("close"),class:"cm-dialog-close",type:"button"},["×"]));t.class&&(o.className=t.class);function s(t){o.contains(o.ownerDocument.activeElement)&&e.focus(),n(t)}return o.classList.add("cm-dialog"),{dom:o,top:t.top,mount:()=>{if(t.focus){let e;e="string"==typeof t.focus?r.querySelector(t.focus):r.querySelector("input")||r.querySelector("button"),e&&"select"in e?e.select():e&&"focus"in e&&e.focus()}}}}(e,t,n);e.state.field(lC,!1)?e.dispatch({effects:cC.of(i)}):e.dispatch({effects:$b.appendConfig.of(lC.init(()=>[i]))});let o=uC.of(i);return{close:o,result:r.then(t=>((e.win.queueMicrotask||(t=>e.win.setTimeout(t,10)))(()=>{e.state.field(lC).indexOf(i)>-1&&e.dispatch({effects:o})}),t))}}const lC=Sb.define({create:()=>[],update(e,t){for(let n of t.effects)n.is(cC)?e=[n.value].concat(e):n.is(uC)&&(e=e.filter(e=>e!=n.value));return e},provide:e=>sC.computeN([e],t=>t.field(e))}),cC=$b.define(),uC=$b.define();class hC extends sy{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}hC.prototype.elementClass="",hC.prototype.toDOM=void 0,hC.prototype.mapMode=rb.TrackBefore,hC.prototype.startSide=hC.prototype.endSide=-1,hC.prototype.point=!0;const dC=gb.define(),fC=gb.define(),pC={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>hy.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},mC=gb.define();function gC(e){return[bC(),mC.of({...pC,...e})]}const vC=gb.define({combine:e=>e.some(e=>e)});function bC(e){let t=[yC];return e&&!1===e.fixed&&t.push(vC.of(!0)),t}const yC=vx.fromClass(class{constructor(e){this.view=e,this.domAfter=null,this.prevViewport=e.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=e.state.facet(mC).map(t=>new SC(e,t)),this.fixed=!e.state.facet(vC);for(let e of this.gutters)"after"==e.config.side?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),e.scrollDOM.insertBefore(this.dom,e.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(e){if(this.updateGutters(e)){let t=this.prevViewport,n=e.view.viewport,r=Math.min(t.to,n.to)-Math.max(t.from,n.from);this.syncGutters(r<.8*(n.to-n.from))}if(e.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(vC)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=e.view.viewport}syncGutters(e){let t=this.dom.nextSibling;e&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=hy.iter(this.view.state.facet(dC),this.view.viewport.from),r=[],i=this.gutters.map(e=>new kC(e,this.view.viewport,-this.view.documentPadding.top));for(let e of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(e.type)){let t=!0;for(let o of e.type)if(o.type==rw.Text&&t){xC(n,r,o.from);for(let e of i)e.line(this.view,o,r);t=!1}else if(o.widget)for(let e of i)e.widget(this.view,o)}else if(e.type==rw.Text){xC(n,r,e.from);for(let t of i)t.line(this.view,e,r)}else if(e.widget)for(let t of i)t.widget(this.view,e);for(let e of i)e.finish();e&&(this.view.scrollDOM.insertBefore(this.dom,t),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(e){let t=e.startState.facet(mC),n=e.state.facet(mC),r=e.docChanged||e.heightChanged||e.viewportChanged||!hy.eq(e.startState.facet(dC),e.state.facet(dC),e.view.viewport.from,e.view.viewport.to);if(t==n)for(let t of this.gutters)t.update(e)&&(r=!0);else{r=!0;let i=[];for(let r of n){let n=t.indexOf(r);n<0?i.push(new SC(this.view,r)):(this.gutters[n].update(e),i.push(this.gutters[n]))}for(let e of this.gutters)e.dom.remove(),i.indexOf(e)<0&&e.destroy();for(let e of i)"after"==e.config.side?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.gutters=i}return r}destroy(){for(let e of this.gutters)e.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:e=>VS.scrollMargins.of(t=>{let n=t.plugin(e);if(!n||0==n.gutters.length||!n.fixed)return null;let r=n.dom.offsetWidth*t.scaleX,i=n.domAfter?n.domAfter.offsetWidth*t.scaleX:0;return t.textDirection==Pw.LTR?{left:r,right:i}:{right:r,left:i}})});function wC(e){return Array.isArray(e)?e:[e]}function xC(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}class kC{constructor(e,t,n){this.gutter=e,this.height=n,this.i=0,this.cursor=hy.iter(e.markers,t.from)}addElement(e,t,n){let{gutter:r}=this,i=(t.top-this.height)/e.scaleY,o=t.height/e.scaleY;if(this.i==r.elements.length){let t=new EC(e,o,i,n);r.elements.push(t),r.dom.appendChild(t.dom)}else r.elements[this.i].update(e,o,i,n);this.height=t.bottom,this.i++}line(e,t,n){let r=[];xC(this.cursor,r,t.from),n.length&&(r=r.concat(n));let i=this.gutter.config.lineMarker(e,t,r);i&&r.unshift(i);let o=this.gutter;(0!=r.length||o.config.renderEmptyElements)&&this.addElement(e,t,r)}widget(e,t){let n=this.gutter.config.widgetMarker(e,t.widget,t),r=n?[n]:null;for(let n of e.state.facet(fC)){let i=n(e,t.widget,t);i&&(r||(r=[])).push(i)}r&&this.addElement(e,t,r)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class SC{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let n in t.domEventHandlers)this.dom.addEventListener(n,r=>{let i,o=r.target;if(o!=this.dom&&this.dom.contains(o)){for(;o.parentNode!=this.dom;)o=o.parentNode;let e=o.getBoundingClientRect();i=(e.top+e.bottom)/2}else i=r.clientY;let s=e.lineBlockAtHeight(i-e.documentTop);t.domEventHandlers[n](e,s,r)&&r.preventDefault()});this.markers=wC(t.markers(e)),t.initialSpacer&&(this.spacer=new EC(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=wC(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let t=this.config.updateSpacer(this.spacer.markers[0],e);t!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[t])}let n=e.view.viewport;return!hy.eq(this.markers,t,n.from,n.to)||!!this.config.lineMarkerChange&&this.config.lineMarkerChange(e)}destroy(){for(let e of this.elements)e.destroy()}}class EC{constructor(e,t,n,r){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,n,r)}update(e,t,n,r){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=n&&(this.dom.style.marginTop=(this.above=n)?n+"px":""),function(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].compare(t[n]))return!1;return!0}(this.markers,r)||this.setMarkers(e,r)}setMarkers(e,t){let n="cm-gutterElement",r=this.dom.firstChild;for(let i=0,o=0;;){let s=o,a=i<t.length?t[i++]:null,l=!1;if(a){let e=a.elementClass;e&&(n+=" "+e);for(let e=o;e<this.markers.length;e++)if(this.markers[e].compare(a)){s=e,l=!0;break}}else s=this.markers.length;for(;o<s;){let e=this.markers[o++];if(e.toDOM){e.destroy(r);let t=r.nextSibling;r.remove(),r=t}}if(!a)break;a.toDOM&&(l?r=r.nextSibling:this.dom.insertBefore(a.toDOM(e),r)),l&&o++}this.dom.className=n,this.markers=t}destroy(){this.setMarkers(null,[])}}const CC=gb.define(),NC=gb.define(),OC=gb.define({combine:e=>oy(e,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let n=Object.assign({},e);for(let e in t){let r=n[e],i=t[e];n[e]=r?(e,t,n)=>r(e,t,n)||i(e,t,n):i}return n}})});class AC extends hC{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function MC(e,t){return e.state.facet(OC).formatNumber(t,e.state)}const TC=mC.compute([OC],e=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers:e=>e.state.facet(CC),lineMarker:(e,t,n)=>n.some(e=>e.toDOM)?null:new AC(MC(e,e.state.doc.lineAt(t.from).number)),widgetMarker:(e,t,n)=>{for(let r of e.state.facet(NC)){let i=r(e,t,n);if(i)return i}return null},lineMarkerChange:e=>e.startState.facet(OC)!=e.state.facet(OC),initialSpacer:e=>new AC(MC(e,RC(e.state.doc.lines))),updateSpacer(e,t){let n=MC(t.view,RC(t.view.state.doc.lines));return n==e.number?e:new AC(n)},domEventHandlers:e.facet(OC).domEventHandlers,side:"before"}));function RC(e){let t=9;for(;t<e;)t=10*t+9;return t}const DC=new class extends hC{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},PC=dC.compute(["selection"],e=>{let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.head).from;i>n&&(n=i,t.push(DC.range(i)))}return hy.of(t)});const LC=1024;let IC=0;class _C{constructor(e,t){this.from=e,this.to=t}}class BC{constructor(e={}){this.id=IC++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return"function"!=typeof e&&(e=WC.match(e)),t=>{let n=e(t);return void 0===n?null:[this,n]}}}BC.closedBy=new BC({deserialize:e=>e.split(" ")}),BC.openedBy=new BC({deserialize:e=>e.split(" ")}),BC.group=new BC({deserialize:e=>e.split(" ")}),BC.isolate=new BC({deserialize:e=>{if(e&&"rtl"!=e&&"ltr"!=e&&"auto"!=e)throw new RangeError("Invalid value for isolate: "+e);return e||"auto"}}),BC.contextHash=new BC({perNode:!0}),BC.lookAhead=new BC({perNode:!0}),BC.mounted=new BC({perNode:!0});class FC{constructor(e,t,n,r=!1){this.tree=e,this.overlay=t,this.parser=n,this.bracketed=r}static get(e){return e&&e.props&&e.props[BC.mounted.id]}}const jC=Object.create(null);class WC{constructor(e,t,n,r=0){this.name=e,this.props=t,this.id=n,this.flags=r}static define(e){let t=e.props&&e.props.length?Object.create(null):jC,n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(null==e.name?8:0),r=new WC(e.name||"",t,e.id,n);if(e.props)for(let n of e.props)if(Array.isArray(n)||(n=n(r)),n){if(n[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[n[0].id]=n[1]}return r}prop(e){return this.props[e.id]}get isTop(){return(1&this.flags)>0}get isSkipped(){return(2&this.flags)>0}get isError(){return(4&this.flags)>0}get isAnonymous(){return(8&this.flags)>0}is(e){if("string"==typeof e){if(this.name==e)return!0;let t=this.prop(BC.group);return!!t&&t.indexOf(e)>-1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let r of n.split(" "))t[r]=e[n];return e=>{for(let n=e.prop(BC.group),r=-1;r<(n?n.length:0);r++){let i=t[r<0?e.name:n[r]];if(i)return i}}}}WC.none=new WC("",Object.create(null),0,8);class zC{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let n of this.types){let r=null;for(let t of e){let e=t(n);if(e){r||(r=Object.assign({},n.props));let t=e[1],i=e[0];i.combine&&i.id in r&&(t=i.combine(r[i.id],t)),r[i.id]=t}}t.push(r?new WC(n.name,r,n.id,n.flags):n)}return new zC(t)}}const HC=new WeakMap,VC=new WeakMap;var qC;!function(e){e[e.ExcludeBuffers=1]="ExcludeBuffers",e[e.IncludeAnonymous=2]="IncludeAnonymous",e[e.IgnoreMounts=4]="IgnoreMounts",e[e.IgnoreOverlays=8]="IgnoreOverlays",e[e.EnterBracketed=16]="EnterBracketed"}(qC||(qC={}));class UC{constructor(e,t,n,r,i){if(this.type=e,this.children=t,this.positions=n,this.length=r,this.props=null,i&&i.length){this.props=Object.create(null);for(let[e,t]of i)this.props["number"==typeof e?e:e.id]=t}}toString(){let e=FC.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let e of this.children){let n=e.toString();n&&(t&&(t+=","),t+=n)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new iN(this.topNode,e)}cursorAt(e,t=0,n=0){let r=HC.get(this)||this.topNode,i=new iN(r);return i.moveTo(e,t),HC.set(this,i._tree),i}get topNode(){return new JC(this,0,0,null)}resolve(e,t=0){let n=GC(HC.get(this)||this.topNode,e,t,!1);return HC.set(this,n),n}resolveInner(e,t=0){let n=GC(VC.get(this)||this.topNode,e,t,!0);return VC.set(this,n),n}resolveStack(e,t=0){return function(e,t,n){let r=e.resolveInner(t,n),i=null;for(let e=r instanceof JC?r:r.context.parent;e;e=e.parent)if(e.index<0){let o=e.parent;(i||(i=[r])).push(o.resolve(t,n)),e=o}else{let o=FC.get(e.tree);if(o&&o.overlay&&o.overlay[0].from<=t&&o.overlay[o.overlay.length-1].to>=t){let s=new JC(o.tree,o.overlay[0].from+e.from,-1,e);(i||(i=[r])).push(GC(s,t,n,!1))}}return i?nN(i):r}(this,e,t)}iterate(e){let{enter:t,leave:n,from:r=0,to:i=this.length}=e,o=e.mode||0,s=(o&qC.IncludeAnonymous)>0;for(let e=this.cursor(o|qC.IncludeAnonymous);;){let o=!1;if(e.from<=i&&e.to>=r&&(!s&&e.type.isAnonymous||!1!==t(e))){if(e.firstChild())continue;o=!0}for(;o&&n&&(s||!e.type.isAnonymous)&&n(e),!e.nextSibling();){if(!e.parent())return;o=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:lN(WC.none,this.children,this.positions,0,this.children.length,0,this.length,(e,t,n)=>new UC(this.type,e,t,n,this.propValues),e.makeTree||((e,t,n)=>new UC(WC.none,e,t,n)))}static build(e){return function(e){var t;let{buffer:n,nodeSet:r,maxBufferLength:i=LC,reused:o=[],minRepeatType:s=r.types.length}=e,a=Array.isArray(n)?new $C(n,n.length):n,l=r.types,c=0,u=0;function h(e,t,n,b,y,w){let{id:x,start:k,end:S,size:E}=a,C=u,N=c;if(E<0){if(a.next(),-1==E){let t=o[x];return n.push(t),void b.push(k-e)}if(-3==E)return void(c=x);if(-4==E)return void(u=x);throw new RangeError(`Unrecognized record size: ${E}`)}let O,A,M=l[x],T=k-e;if(S-k<=i&&(A=g(a.pos-t,y))){let t=new Uint16Array(A.size-A.skip),n=a.pos-A.size,i=t.length;for(;a.pos>n;)i=v(A.start,t,i);O=new KC(t,S-A.start,r),T=A.start-e}else{let e=a.pos-E;a.next();let t=[],n=[],r=x>=s?x:-1,o=0,l=S;for(;a.pos>e;)r>=0&&a.id==r&&a.size>=0?(a.end<=l-i&&(p(t,n,k,o,a.end,l,r,C,N),o=t.length,l=a.end),a.next()):w>2500?d(k,e,t,n):h(k,e,t,n,r,w+1);if(r>=0&&o>0&&o<t.length&&p(t,n,k,o,k,l,r,C,N),t.reverse(),n.reverse(),r>-1&&o>0){let e=f(M,N);O=lN(M,t,n,0,t.length,0,S-k,e,e)}else O=m(M,t,n,S-k,C-S,N)}n.push(O),b.push(T)}function d(e,t,n,o){let s=[],l=0,c=-1;for(;a.pos>t;){let{id:e,start:t,end:n,size:r}=a;if(r>4)a.next();else{if(c>-1&&t<c)break;c<0&&(c=n-i),s.push(e,t,n),l++,a.next()}}if(l){let t=new Uint16Array(4*l),i=s[s.length-2];for(let e=s.length-3,n=0;e>=0;e-=3)t[n++]=s[e],t[n++]=s[e+1]-i,t[n++]=s[e+2]-i,t[n++]=n;n.push(new KC(t,s[2]-i,r)),o.push(i-e)}}function f(e,t){return(n,r,i)=>{let o,s,a=0,l=n.length-1;if(l>=0&&(o=n[l])instanceof UC){if(!l&&o.type==e&&o.length==i)return o;(s=o.prop(BC.lookAhead))&&(a=r[l]+o.length+s)}return m(e,n,r,i,a,t)}}function p(e,t,n,i,o,s,a,l,c){let u=[],h=[];for(;e.length>i;)u.push(e.pop()),h.push(t.pop()+n-o);e.push(m(r.types[a],u,h,s-o,l-s,c)),t.push(o-n)}function m(e,t,n,r,i,o,s){if(o){let e=[BC.contextHash,o];s=s?[e].concat(s):[e]}if(i>25){let e=[BC.lookAhead,i];s=s?[e].concat(s):[e]}return new UC(e,t,n,r,s)}function g(e,t){let n=a.fork(),r=0,o=0,l=0,c=n.end-i,u={size:0,start:0,skip:0};e:for(let i=n.pos-e;n.pos>i;){let e=n.size;if(n.id==t&&e>=0){u.size=r,u.start=o,u.skip=l,l+=4,r+=4,n.next();continue}let a=n.pos-e;if(e<0||a<i||n.start<c)break;let h=n.id>=s?4:0,d=n.start;for(n.next();n.pos>a;){if(n.size<0){if(-3!=n.size&&-4!=n.size)break e;h+=4}else n.id>=s&&(h+=4);n.next()}o=d,r+=e,l+=h}return(t<0||r==e)&&(u.size=r,u.start=o,u.skip=l),u.size>4?u:void 0}function v(e,t,n){let{id:r,start:i,end:o,size:l}=a;if(a.next(),l>=0&&r<s){let s=n;if(l>4){let r=a.pos-(l-4);for(;a.pos>r;)n=v(e,t,n)}t[--n]=s,t[--n]=o-e,t[--n]=i-e,t[--n]=r}else-3==l?c=r:-4==l&&(u=r);return n}let b=[],y=[];for(;a.pos>0;)h(e.start||0,e.bufferStart||0,b,y,-1,0);let w=null!==(t=e.length)&&void 0!==t?t:b.length?y[0]+b[0].length:0;return new UC(l[e.topID],b.reverse(),y.reverse(),w)}(e)}}UC.empty=new UC(WC.none,[],[],0);class $C{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new $C(this.buffer,this.index)}}class KC{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return WC.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],n=this.buffer[e+3],r=this.set.types[t],i=r.name;if(/\W/.test(i)&&!r.isError&&(i=JSON.stringify(i)),n==(e+=4))return i;let o=[];for(;e<n;)o.push(this.childString(e)),e=this.buffer[e+3];return i+"("+o.join(",")+")"}findChild(e,t,n,r,i){let{buffer:o}=this,s=-1;for(let a=e;a!=t&&!(YC(i,r,o[a+1],o[a+2])&&(s=a,n>0));a=o[a+3]);return s}slice(e,t,n){let r=this.buffer,i=new Uint16Array(t-e),o=0;for(let s=e,a=0;s<t;){i[a++]=r[s++],i[a++]=r[s++]-n;let t=i[a++]=r[s++]-n;i[a++]=r[s++]-e,o=Math.max(o,t)}return new KC(i,o,this.set)}}function YC(e,t,n,r){switch(e){case-2:return n<t;case-1:return r>=t&&n<t;case 0:return n<t&&r>t;case 1:return n<=t&&r>t;case 2:return r>t;case 4:return!0}}function GC(e,t,n,r){for(var i;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to<t);){let t=!r&&e instanceof JC&&e.index<0?null:e.parent;if(!t)return e;e=t}let o=r?0:qC.IgnoreOverlays;if(r)for(let r=e,s=r.parent;s;r=s,s=r.parent)r instanceof JC&&r.index<0&&(null===(i=s.enter(t,n,o))||void 0===i?void 0:i.from)!=r.from&&(e=s);for(;;){let r=e.enter(t,n,o);if(!r)return e;e=r}}class XC{cursor(e=0){return new iN(this,e)}getChild(e,t=null,n=null){let r=QC(this,e,t,n);return r.length?r[0]:null}getChildren(e,t=null,n=null){return QC(this,e,t,n)}resolve(e,t=0){return GC(this,e,t,!1)}resolveInner(e,t=0){return GC(this,e,t,!0)}matchContext(e){return ZC(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),n=this;for(;t;){let e=t.lastChild;if(!e||e.to!=t.to)break;e.type.isError&&e.from==e.to?(n=t,t=e.prevSibling):t=e}return n}get node(){return this}get next(){return this.parent}}class JC extends XC{constructor(e,t,n,r){super(),this._tree=e,this.from=t,this.index=n,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,n,r,i=0){var o;for(let s=this;;){for(let{children:a,positions:l}=s._tree,c=t>0?a.length:-1;e!=c;e+=t){let c=a[e],u=l[e]+s.from;if(i&qC.EnterBracketed&&c instanceof UC&&null===(null===(o=FC.get(c))||void 0===o?void 0:o.overlay)&&(u>=n||u+c.length<=n)||YC(r,n,u,u+c.length))if(c instanceof KC){if(i&qC.ExcludeBuffers)continue;let o=c.findChild(0,c.buffer.length,t,n-u,r);if(o>-1)return new tN(new eN(s,c,e,u),null,o)}else if(i&qC.IncludeAnonymous||!c.type.isAnonymous||oN(c)){let o;if(!(i&qC.IgnoreMounts)&&(o=FC.get(c))&&!o.overlay)return new JC(o.tree,u,e,s);let a=new JC(c,u,e,s);return i&qC.IncludeAnonymous||!a.type.isAnonymous?a:a.nextChild(t<0?c.children.length-1:0,t,n,r,i)}}if(i&qC.IncludeAnonymous||!s.type.isAnonymous)return null;if(e=s.index>=0?s.index+t:t<0?-1:s._parent._tree.children.length,s=s._parent,!s)return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,t,n=0){let r;if(!(n&qC.IgnoreOverlays)&&(r=FC.get(this._tree))&&r.overlay){let i=e-this.from,o=n&qC.EnterBracketed&&r.bracketed;for(let{from:e,to:n}of r.overlay)if((t>0||o?e<=i:e<i)&&(t<0||o?n>=i:n>i))return new JC(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,n)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function QC(e,t,n,r){let i=e.cursor(),o=[];if(!i.firstChild())return o;if(null!=n)for(let e=!1;!e;)if(e=i.type.is(n),!i.nextSibling())return o;for(;;){if(null!=r&&i.type.is(r))return o;if(i.type.is(t)&&o.push(i.node),!i.nextSibling())return null==r?o:[]}}function ZC(e,t,n=t.length-1){for(let r=e;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}class eN{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}}class tN extends XC{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(e,t,n){let{buffer:r}=this.context,i=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.context.start,n);return i<0?null:new tN(this.context,this,i)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,t,n=0){if(n&qC.ExcludeBuffers)return null;let{buffer:r}=this.context,i=r.findChild(this.index+4,r.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return i<0?null:new tN(this.context,this,i)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new tN(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new tN(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,r=this.index+4,i=n.buffer[this.index+3];if(i>r){let o=n.buffer[this.index+1];e.push(n.slice(r,i,o)),t.push(0)}return new UC(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function nN(e){if(!e.length)return null;let t=0,n=e[0];for(let r=1;r<e.length;r++){let i=e[r];(i.from>n.from||i.to<n.to)&&(n=i,t=r)}let r=n instanceof JC&&n.index<0?null:n.parent,i=e.slice();return r?i[t]=r:i.splice(t,1),new rN(i,n)}class rN{constructor(e,t){this.heads=e,this.node=t}get next(){return nN(this.heads)}}class iN{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~qC.EnterBracketed,e instanceof JC)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return!!e&&(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0)}yieldBuf(e,t){this.index=e;let{start:n,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=n+r.buffer[e+1],this.to=n+r.buffer[e+2],!0}yield(e){return!!e&&(e instanceof JC?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)))}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:r}=this.buffer,i=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,n);return!(i<0)&&(this.stack.push(this.index),this.yieldBuf(i))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,n=this.mode){return this.buffer?!(n&qC.ExcludeBuffers)&&this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&qC.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&qC.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return!!this._tree._parent&&this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode));let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let e=n<0?0:this.stack[n]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(e)}return n<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let e=0;e<this.index;e++)if(r.buffer.buffer[e+3]<this.index)return!1;({index:t,parent:n}=r)}else({index:t,_parent:n}=this._tree);for(;n;({index:t,_parent:n}=n))if(t>-1)for(let r=t+e,i=e<0?-1:n._tree.children.length;r!=i;r+=e){let e=n._tree.children[r];if(this.mode&qC.IncludeAnonymous||e instanceof KC||!e.type.isAnonymous||oN(e))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,n=0;if(e&&e.context==this.buffer)e:for(let r=this.index,i=this.stack.length;i>=0;){for(let o=e;o;o=o._parent)if(o.index==r){if(r==this.index)return o;t=o,n=i+1;break e}r=this.stack[--i]}for(let e=n;e<this.stack.length;e++)t=new tN(this.buffer,t,this.stack[e]);return this.bufferNode=new tN(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let r=!1;if(this.type.isAnonymous||!1!==e(this)){if(this.firstChild()){n++;continue}this.type.isAnonymous||(r=!0)}for(;;){if(r&&t&&t(this),r=this.type.isAnonymous,!n)return;if(this.nextSibling())break;this.parent(),n--,r=!0}}}matchContext(e){if(!this.buffer)return ZC(this.node.parent,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let r=e.length-1,i=this.stack.length-1;r>=0;i--){if(i<0)return ZC(this._tree,e,r);let o=n[t.buffer[this.stack[i]]];if(!o.isAnonymous){if(e[r]&&e[r]!=o.name)return!1;r--}}return!0}}function oN(e){return e.children.some(e=>e instanceof KC||!e.type.isAnonymous||oN(e))}const sN=new WeakMap;function aN(e,t){if(!e.isAnonymous||t instanceof KC||t.type!=e)return 1;let n=sN.get(t);if(null==n){n=1;for(let r of t.children){if(r.type!=e||!(r instanceof UC)){n=1;break}n+=aN(e,r)}sN.set(t,n)}return n}function lN(e,t,n,r,i,o,s,a,l){let c=0;for(let n=r;n<i;n++)c+=aN(e,t[n]);let u=Math.ceil(1.5*c/8),h=[],d=[];return function t(n,r,i,s,a){for(let c=i;c<s;){let i=c,f=r[c],p=aN(e,n[c]);for(c++;c<s;c++){let t=aN(e,n[c]);if(p+t>=u)break;p+=t}if(c==i+1){if(p>u){let e=n[i];t(e.children,e.positions,0,e.children.length,r[i]+a);continue}h.push(n[i])}else{let t=r[c-1]+n[c-1].length-f;h.push(lN(e,n,r,i,c,f,t,null,l))}d.push(f+a-o)}}(t,n,r,i,0),(a||l)(h,d,s)}class cN{constructor(e,t,n,r,i=!1,o=!1){this.from=e,this.to=t,this.tree=n,this.offset=r,this.open=(i?1:0)|(o?2:0)}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(e,t=[],n=!1){let r=[new cN(0,e.length,e,0,!1,n)];for(let n of t)n.to>e.length&&r.push(n);return r}static applyChanges(e,t,n=128){if(!t.length)return e;let r=[],i=1,o=e.length?e[0]:null;for(let s=0,a=0,l=0;;s++){let c=s<t.length?t[s]:null,u=c?c.fromA:1e9;if(u-a>=n)for(;o&&o.from<u;){let t=o;if(a>=t.from||u<=t.to||l){let e=Math.max(t.from,a)-l,n=Math.min(t.to,u)-l;t=e>=n?null:new cN(e,n,t.tree,t.offset+l,s>0,!!c)}if(t&&r.push(t),o.to>u)break;o=i<e.length?e[i++]:null}if(!c)break;a=c.toA,l=c.toA-c.toB}return r}}class uN{startParse(e,t,n){return"string"==typeof e&&(e=new hN(e)),n=n?n.length?n.map(e=>new _C(e.from,e.to)):[new _C(0,0)]:[new _C(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let r=this.startParse(e,t,n);for(;;){let e=r.advance();if(e)return e}}}class hN{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}new BC({perNode:!0});let dN=0;class fN{constructor(e,t,n,r){this.name=e,this.set=t,this.base=n,this.modified=r,this.id=dN++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let n="string"==typeof e?e:"?";if(e instanceof fN&&(t=e),null==t?void 0:t.base)throw new Error("Can not derive from a modified tag");let r=new fN(n,[],null,[]);if(r.set.push(r),t)for(let e of t.set)r.set.push(e);return r}static defineModifier(e){let t=new mN(e);return e=>e.modified.indexOf(t)>-1?e:mN.get(e.base||e,e.modified.concat(t).sort((e,t)=>e.id-t.id))}}let pN=0;class mN{constructor(e){this.name=e,this.instances=[],this.id=pN++}static get(e,t){if(!t.length)return e;let n=t[0].instances.find(n=>{return n.base==e&&(r=t,i=n.modified,r.length==i.length&&r.every((e,t)=>e==i[t]));var r,i});if(n)return n;let r=[],i=new fN(e.name,r,e,t);for(let e of t)e.instances.push(i);let o=function(e){let t=[[]];for(let n=0;n<e.length;n++)for(let r=0,i=t.length;r<i;r++)t.push(t[r].concat(e[n]));return t.sort((e,t)=>t.length-e.length)}(t);for(let t of e.set)if(!t.modified.length)for(let e of o)r.push(mN.get(t,e));return i}}function gN(e){let t=Object.create(null);for(let n in e){let r=e[n];Array.isArray(r)||(r=[r]);for(let e of n.split(" "))if(e){let n=[],i=2,o=e;for(let t=0;;){if("..."==o&&t>0&&t+3==e.length){i=1;break}let r=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(o);if(!r)throw new RangeError("Invalid path: "+e);if(n.push("*"==r[0]?"":'"'==r[0][0]?JSON.parse(r[0]):r[0]),t+=r[0].length,t==e.length)break;let s=e[t++];if(t==e.length&&"!"==s){i=0;break}if("/"!=s)throw new RangeError("Invalid path: "+e);o=e.slice(t)}let s=n.length-1,a=n[s];if(!a)throw new RangeError("Invalid path: "+e);let l=new bN(r,i,s>0?n.slice(0,s):null);t[a]=l.sort(t[a])}}return vN.add(t)}const vN=new BC({combine(e,t){let n,r,i;for(;e||t;){if(!e||t&&e.depth>=t.depth?(i=t,t=t.next):(i=e,e=e.next),n&&n.mode==i.mode&&!i.context&&!n.context)continue;let o=new bN(i.tags,i.mode,i.context);n?n.next=o:r=o,n=o}return r}});class bN{constructor(e,t,n,r){this.tags=e,this.mode=t,this.context=n,this.next=r}get opaque(){return 0==this.mode}get inherit(){return 1==this.mode}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}}function yN(e,t){let n=Object.create(null);for(let t of e)if(Array.isArray(t.tag))for(let e of t.tag)n[e.id]=t.class;else n[t.tag.id]=t.class;let{scope:r,all:i=null}=t||{};return{style:e=>{let t=i;for(let r of e)for(let e of r.set){let r=n[e.id];if(r){t=t?t+" "+r:r;break}}return t},scope:r}}function wN(e,t,n,r=0,i=e.length){let o=new xN(r,Array.isArray(t)?t:[t],n);o.highlightRange(e.cursor(),r,i,"",o.highlighters),o.flush(i)}bN.empty=new bN([],2,null);class xN{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,n,r,i){let{type:o,from:s,to:a}=e;if(s>=n||a<=t)return;o.isTop&&(i=this.highlighters.filter(e=>!e.scope||e.scope(o)));let l=r,c=function(e){let t=e.type.prop(vN);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}(e)||bN.empty,u=function(e,t){let n=null;for(let r of e){let e=r.style(t);e&&(n=n?n+" "+e:e)}return n}(i,c.tags);if(u&&(l&&(l+=" "),l+=u,1==c.mode&&(r+=(r?" ":"")+u)),this.startSpan(Math.max(t,s),l),c.opaque)return;let h=e.tree&&e.tree.prop(BC.mounted);if(h&&h.overlay){let o=e.node.enter(h.overlay[0].from+s,1),c=this.highlighters.filter(e=>!e.scope||e.scope(h.tree.type)),u=e.firstChild();for(let d=0,f=s;;d++){let p=d<h.overlay.length?h.overlay[d]:null,m=p?p.from+s:a,g=Math.max(t,f),v=Math.min(n,m);if(g<v&&u)for(;e.from<v&&(this.highlightRange(e,g,v,r,i),this.startSpan(Math.min(v,e.to),l),!(e.to>=m)&&e.nextSibling()););if(!p||m>n)break;f=p.to+s,f>t&&(this.highlightRange(o.cursor(),Math.max(t,p.from+s),Math.min(n,f),"",c),this.startSpan(Math.min(n,f),l))}u&&e.parent()}else if(e.firstChild()){h&&(r="");do{if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,r,i),this.startSpan(Math.min(n,e.to),l)}}while(e.nextSibling());e.parent()}}}const kN=fN.define,SN=kN(),EN=kN(),CN=kN(EN),NN=kN(EN),ON=kN(),AN=kN(ON),MN=kN(ON),TN=kN(),RN=kN(TN),DN=kN(),PN=kN(),LN=kN(),IN=kN(LN),_N=kN(),BN={comment:SN,lineComment:kN(SN),blockComment:kN(SN),docComment:kN(SN),name:EN,variableName:kN(EN),typeName:CN,tagName:kN(CN),propertyName:NN,attributeName:kN(NN),className:kN(EN),labelName:kN(EN),namespace:kN(EN),macroName:kN(EN),literal:ON,string:AN,docString:kN(AN),character:kN(AN),attributeValue:kN(AN),number:MN,integer:kN(MN),float:kN(MN),bool:kN(ON),regexp:kN(ON),escape:kN(ON),color:kN(ON),url:kN(ON),keyword:DN,self:kN(DN),null:kN(DN),atom:kN(DN),unit:kN(DN),modifier:kN(DN),operatorKeyword:kN(DN),controlKeyword:kN(DN),definitionKeyword:kN(DN),moduleKeyword:kN(DN),operator:PN,derefOperator:kN(PN),arithmeticOperator:kN(PN),logicOperator:kN(PN),bitwiseOperator:kN(PN),compareOperator:kN(PN),updateOperator:kN(PN),definitionOperator:kN(PN),typeOperator:kN(PN),controlOperator:kN(PN),punctuation:LN,separator:kN(LN),bracket:IN,angleBracket:kN(IN),squareBracket:kN(IN),paren:kN(IN),brace:kN(IN),content:TN,heading:RN,heading1:kN(RN),heading2:kN(RN),heading3:kN(RN),heading4:kN(RN),heading5:kN(RN),heading6:kN(RN),contentSeparator:kN(TN),list:kN(TN),quote:kN(TN),emphasis:kN(TN),strong:kN(TN),link:kN(TN),monospace:kN(TN),strikethrough:kN(TN),inserted:kN(),deleted:kN(),changed:kN(),invalid:kN(),meta:_N,documentMeta:kN(_N),annotation:kN(_N),processingInstruction:kN(_N),definition:fN.defineModifier("definition"),constant:fN.defineModifier("constant"),function:fN.defineModifier("function"),standard:fN.defineModifier("standard"),local:fN.defineModifier("local"),special:fN.defineModifier("special")};for(let e in BN){let t=BN[e];t instanceof fN&&(t.name=e)}var FN;yN([{tag:BN.link,class:"tok-link"},{tag:BN.heading,class:"tok-heading"},{tag:BN.emphasis,class:"tok-emphasis"},{tag:BN.strong,class:"tok-strong"},{tag:BN.keyword,class:"tok-keyword"},{tag:BN.atom,class:"tok-atom"},{tag:BN.bool,class:"tok-bool"},{tag:BN.url,class:"tok-url"},{tag:BN.labelName,class:"tok-labelName"},{tag:BN.inserted,class:"tok-inserted"},{tag:BN.deleted,class:"tok-deleted"},{tag:BN.literal,class:"tok-literal"},{tag:BN.string,class:"tok-string"},{tag:BN.number,class:"tok-number"},{tag:[BN.regexp,BN.escape,BN.special(BN.string)],class:"tok-string2"},{tag:BN.variableName,class:"tok-variableName"},{tag:BN.local(BN.variableName),class:"tok-variableName tok-local"},{tag:BN.definition(BN.variableName),class:"tok-variableName tok-definition"},{tag:BN.special(BN.variableName),class:"tok-variableName2"},{tag:BN.definition(BN.propertyName),class:"tok-propertyName tok-definition"},{tag:BN.typeName,class:"tok-typeName"},{tag:BN.namespace,class:"tok-namespace"},{tag:BN.className,class:"tok-className"},{tag:BN.macroName,class:"tok-macroName"},{tag:BN.propertyName,class:"tok-propertyName"},{tag:BN.operator,class:"tok-operator"},{tag:BN.comment,class:"tok-comment"},{tag:BN.meta,class:"tok-meta"},{tag:BN.invalid,class:"tok-invalid"},{tag:BN.punctuation,class:"tok-punctuation"}]);const jN=new BC;const WN=new BC;class zN{constructor(e,t,n=[],r=""){this.data=e,this.name=r,iy.prototype.hasOwnProperty("tree")||Object.defineProperty(iy.prototype,"tree",{get(){return qN(this)}}),this.parser=t,this.extension=[ZN.of(this),iy.languageData.of((e,t,n)=>{let r=HN(e,t,n),i=r.type.prop(jN);if(!i)return[];let o=e.facet(i),s=r.type.prop(WN);if(s){let i=r.resolve(t-r.from,n);for(let t of s)if(t.test(i,e)){let n=e.facet(t.facet);return"replace"==t.type?n:n.concat(o)}}return o})].concat(n)}isActiveAt(e,t,n=-1){return HN(e,t,n).type.prop(jN)==this.data}findRegions(e){let t=e.facet(ZN);if((null==t?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],r=(e,t)=>{if(e.prop(jN)==this.data)return void n.push({from:t,to:t+e.length});let i=e.prop(BC.mounted);if(i){if(i.tree.prop(jN)==this.data){if(i.overlay)for(let e of i.overlay)n.push({from:e.from+t,to:e.to+t});else n.push({from:t,to:t+e.length});return}if(i.overlay){let e=n.length;if(r(i.tree,i.overlay[0].from+t),n.length>e)return}}for(let n=0;n<e.children.length;n++){let i=e.children[n];i instanceof UC&&r(i,e.positions[n]+t)}};return r(qN(e),0),n}get allowsNesting(){return!0}}function HN(e,t,n){let r=e.facet(ZN),i=qN(e).topNode;if(!r||r.allowsNesting)for(let e=i;e;e=e.enter(t,n,qC.ExcludeBuffers|qC.EnterBracketed))e.type.isTop&&(i=e);return i}zN.setState=$b.define();class VN extends zN{constructor(e,t,n){super(e,t,[],n),this.parser=t}static define(e){let t=(n=e.languageData,gb.define({combine:n?e=>e.concat(n):void 0}));var n;return new VN(t,e.parser.configure({props:[jN.add(e=>e.isTop?t:void 0)]}),e.name)}configure(e,t){return new VN(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function qN(e){let t=e.field(zN.state,!1);return t?t.tree:UC.empty}class UN{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let n=this.cursorPos-this.string.length;return e<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}}let $N=null;class KN{constructor(e,t,n=[],r,i,o,s,a){this.parser=e,this.state=t,this.fragments=n,this.tree=r,this.treeLen=i,this.viewport=o,this.skipped=s,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,n){return new KN(e,t,[],UC.empty,0,n,[],null)}startParse(){return this.parser.startParse(new UN(this.state.doc),this.fragments)}work(e,t){return null!=t&&t>=this.state.doc.length&&(t=void 0),this.tree!=UC.empty&&this.isDone(null!=t?t:this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var n;if("number"==typeof e){let t=Date.now()+e;e=()=>Date.now()>t}for(this.parse||(this.parse=this.startParse()),null!=t&&(null==this.parse.stoppedAt||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let r=this.parse.advance();if(r){if(this.fragments=this.withoutTempSkipped(cN.addTree(r,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!==(n=this.parse.stoppedAt)&&void 0!==n?n:this.state.doc.length,this.tree=r,this.parse=null,!(this.treeLen<(null!=t?t:this.state.doc.length)))return!0;this.parse=this.startParse()}if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((null==this.parse.stoppedAt||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(cN.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=$N;$N=this;try{return e()}finally{$N=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=YN(e,t.from,t.to);return e}changes(e,t){let{fragments:n,tree:r,treeLen:i,viewport:o,skipped:s}=this;if(this.takeTree(),!e.empty){let t=[];if(e.iterChangedRanges((e,n,r,i)=>t.push({fromA:e,toA:n,fromB:r,toB:i})),n=cN.applyChanges(n,t),r=UC.empty,i=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){s=[];for(let t of this.skipped){let n=e.mapPos(t.from,1),r=e.mapPos(t.to,-1);n<r&&s.push({from:n,to:r})}}}return new KN(this.parser,t,n,r,i,o,s,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let t=0;t<this.skipped.length;t++){let{from:n,to:r}=this.skipped[t];n<e.to&&r>e.from&&(this.fragments=YN(this.fragments,n,r),this.skipped.splice(t--,1))}return!(this.skipped.length>=t)&&(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends uN{createParse(t,n,r){let i=r[0].from,o=r[r.length-1].to,s={parsedPos:i,advance(){let t=$N;if(t){for(let e of r)t.tempSkipped.push(e);e&&(t.scheduleOn=t.scheduleOn?Promise.all([t.scheduleOn,e]):e)}return this.parsedPos=o,new UC(WC.none,[],[],o-i)},stoppedAt:null,stopAt(){}};return s}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&0==t[0].from&&t[0].to>=e}static get(){return $N}}function YN(e,t,n){return cN.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}class GN{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),n=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,n)||t.takeTree(),new GN(t)}static init(e){let t=Math.min(3e3,e.doc.length),n=KN.create(e.facet(ZN).parser,e,{from:0,to:t});return n.work(20,t)||n.takeTree(),new GN(n)}}zN.state=Sb.define({create:GN.init,update(e,t){for(let e of t.effects)if(e.is(zN.setState))return e.value;return t.startState.facet(ZN)!=t.state.facet(ZN)?GN.init(t.state):e.apply(t)}});let XN=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};"undefined"!=typeof requestIdleCallback&&(XN=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});const JN="undefined"!=typeof navigator&&(null===(FN=navigator.scheduling)||void 0===FN?void 0:FN.isInputPending)?()=>navigator.scheduling.isInputPending():null,QN=vx.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(zN.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(zN.state);t.tree==t.context.tree&&t.context.isDone(e.doc.length)||(this.working=XN(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:r}}=this.view,i=n.field(zN.state);if(i.tree==i.context.tree&&i.context.isDone(r+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!JN?Math.max(25,e.timeRemaining()-5):1e9),s=i.context.treeLen<r&&n.doc.length>r+1e3,a=i.context.work(()=>JN&&JN()||Date.now()>o,r+(s?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:zN.setState.of(new GN(i.context))})),this.chunkBudget>0&&(!a||s)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(e=>fx(this.view.state,e)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),ZN=gb.define({combine:e=>e.length?e[0]:null,enables:e=>[zN.state,QN,VS.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]});class eO{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}const tO=gb.define(),nO=gb.define({combine:e=>{if(!e.length)return" ";let t=e[0];if(!t||/\S/.test(t)||Array.from(t).some(e=>e!=t[0]))throw new Error("Invalid indent unit: "+JSON.stringify(e[0]));return t}});function rO(e){let t=e.facet(nO);return 9==t.charCodeAt(0)?e.tabSize*t.length:t.length}function iO(e,t){let n="",r=e.tabSize,i=e.facet(nO)[0];if("\t"==i){for(;t>=r;)n+="\t",t-=r;i=" "}for(let e=0;e<t;e++)n+=i;return n}function oO(e,t){e instanceof iy&&(e=new sO(e));for(let n of e.state.facet(tO)){let r=n(e,t);if(void 0!==r)return r}let n=qN(e.state);return n.length>=t?function(e,t,n){let r=t.resolveStack(n),i=t.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(i!=r.node){let e=[];for(let t=i;t&&!(t.from<r.node.from||t.to>r.node.to||t.from==r.node.from&&t.type==r.node.type);t=t.parent)e.push(t);for(let t=e.length-1;t>=0;t--)r={node:e[t],next:r}}return lO(r,e,n)}(e,n,t):null}class sO{constructor(e,t={}){this.state=e,this.options=t,this.unit=rO(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:i}=this.options;return null!=r&&r>=n.from&&r<=n.to?i&&r==e?{text:"",from:e}:(t<0?r<e:r<=e)?{text:n.text.slice(r-n.from),from:r}:{text:n.text.slice(0,r-n.from),from:n.from}:n}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:n,from:r}=this.lineAt(e,t);return n.slice(e-r,Math.min(n.length,e+100-r))}column(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.countColumn(n,e-r),o=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return o>-1&&(i+=o-this.countColumn(n,n.search(/\S|$/))),i}countColumn(e,t=e.length){return Sy(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.options.overrideIndentation;if(i){let e=i(r);if(e>-1)return e}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const aO=new BC;function lO(e,t,n){for(let r=e;r;r=r.next){let e=cO(r.node);if(e)return e(hO.create(t,n,r))}return 0}function cO(e){let t=e.type.prop(aO);if(t)return t;let n,r=e.firstChild;if(r&&(n=r.type.prop(BC.closedBy))){let t=e.lastChild,r=t&&n.indexOf(t.name)>-1;return e=>function(e,t,n,r,i){let o=e.textAfter,s=o.match(/^\s*/)[0].length,a=r&&o.slice(s,s+r.length)==r||i==e.pos+s,l=t?function(e){let t=e.node,n=t.childAfter(t.from),r=t.lastChild;if(!n)return null;let i=e.options.simulateBreak,o=e.state.doc.lineAt(n.from),s=null==i||i<=o.from?o.to:Math.min(o.to,i);for(let e=n.to;;){let i=t.childAfter(e);if(!i||i==r)return null;if(!i.type.isSkipped){if(i.from>=s)return null;let e=/^ */.exec(o.text.slice(n.to-o.from))[0].length;return{from:n.from,to:n.to+e}}e=i.to}}(e):null;return l?a?e.column(l.from):e.column(l.to):e.baseIndent+(a?0:e.unit*n)}(e,!0,1,void 0,r&&!function(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}(e)?t.from:void 0)}return null==e.parent?uO:null}function uO(){return 0}class hO extends sO{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.context=n}get node(){return this.context.node}static create(e,t,n){return new hO(e,t,n)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let n=e.resolve(t.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(dO(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return lO(this.context.next,this.base,this.pos)}}function dO(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function fO({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}const pO=gb.define(),mO=new BC;function gO(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function vO(e,t,n){for(let r of e.facet(pO)){let i=r(e,t,n);if(i)return i}return function(e,t,n){let r=qN(e);if(r.length<n)return null;let i=null;for(let o=r.resolveStack(n,1);o;o=o.next){let s=o.node;if(s.to<=n||s.from>n)continue;if(i&&s.from<t)break;let a=s.type.prop(mO);if(a&&(s.to<r.length-50||r.length==e.doc.length||!gO(s))){let r=a(s,e);r&&r.from<=n&&r.from>=t&&r.to>n&&(i=r)}}return i}(e,t,n)}function bO(e,t){let n=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);return n>=r?void 0:{from:n,to:r}}const yO=$b.define({map:bO}),wO=$b.define({map:bO});function xO(e){let t=[];for(let{head:n}of e.state.selection.ranges)t.some(e=>e.from<=n&&e.to>=n)||t.push(e.lineBlockAt(n));return t}const kO=Sb.define({create:()=>iw.none,update(e,t){t.isUserEvent("delete")&&t.changes.iterChangedRanges((t,n)=>e=SO(e,t,n)),e=e.map(t.changes);for(let n of t.effects)if(n.is(yO)&&!CO(e,n.value.from,n.value.to)){let{preparePlaceholder:r}=t.state.facet(TO),i=r?iw.replace({widget:new LO(r(t.state,n.value))}):PO;e=e.update({add:[i.range(n.value.from,n.value.to)]})}else n.is(wO)&&(e=e.update({filter:(e,t)=>n.value.from!=e||n.value.to!=t,filterFrom:n.value.from,filterTo:n.value.to}));return t.selection&&(e=SO(e,t.selection.main.head)),e},provide:e=>VS.decorations.from(e),toJSON(e,t){let n=[];return e.between(0,t.doc.length,(e,t)=>{n.push(e,t)}),n},fromJSON(e){if(!Array.isArray(e)||e.length%2)throw new RangeError("Invalid JSON for fold state");let t=[];for(let n=0;n<e.length;){let r=e[n++],i=e[n++];if("number"!=typeof r||"number"!=typeof i)throw new RangeError("Invalid JSON for fold state");t.push(PO.range(r,i))}return iw.set(t,!0)}});function SO(e,t,n=t){let r=!1;return e.between(t,n,(e,i)=>{e<n&&i>t&&(r=!0)}),r?e.update({filterFrom:t,filterTo:n,filter:(e,r)=>e>=n||r<=t}):e}function EO(e,t,n){var r;let i=null;return null===(r=e.field(kO,!1))||void 0===r||r.between(t,n,(e,t)=>{(!i||i.from>e)&&(i={from:e,to:t})}),i}function CO(e,t,n){let r=!1;return e.between(t,t,(e,i)=>{e==t&&i==n&&(r=!0)}),r}function NO(e,t){return e.field(kO,!1)?t:t.concat($b.appendConfig.of(RO()))}function OO(e,t,n=!0){let r=e.state.doc.lineAt(t.from).number,i=e.state.doc.lineAt(t.to).number;return VS.announce.of(`${e.state.phrase(n?"Folded lines":"Unfolded lines")} ${r} ${e.state.phrase("to")} ${i}.`)}const AO=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:e=>{for(let t of xO(e)){let n=vO(e.state,t.from,t.to);if(n)return e.dispatch({effects:NO(e.state,[yO.of(n),OO(e,n)])}),!0}return!1}},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:e=>{if(!e.state.field(kO,!1))return!1;let t=[];for(let n of xO(e)){let r=EO(e.state,n.from,n.to);r&&t.push(wO.of(r),OO(e,r,!1))}return t.length&&e.dispatch({effects:t}),t.length>0}},{key:"Ctrl-Alt-[",run:e=>{let{state:t}=e,n=[];for(let r=0;r<t.doc.length;){let i=e.lineBlockAt(r),o=vO(t,i.from,i.to);o&&n.push(yO.of(o)),r=(o?e.lineBlockAt(o.to):i).to+1}return n.length&&e.dispatch({effects:NO(e.state,n)}),!!n.length}},{key:"Ctrl-Alt-]",run:e=>{let t=e.state.field(kO,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,(e,t)=>{n.push(wO.of({from:e,to:t}))}),e.dispatch({effects:n}),!0}}],MO={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},TO=gb.define({combine:e=>oy(e,MO)});function RO(e){let t=[kO,BO];return e&&t.push(TO.of(e)),t}function DO(e,t){let{state:n}=e,r=n.facet(TO),i=t=>{let n=e.lineBlockAt(e.posAtDOM(t.target)),r=EO(e.state,n.from,n.to);r&&e.dispatch({effects:wO.of(r)}),t.preventDefault()};if(r.placeholderDOM)return r.placeholderDOM(e,i,t);let o=document.createElement("span");return o.textContent=r.placeholderText,o.setAttribute("aria-label",n.phrase("folded code")),o.title=n.phrase("unfold"),o.className="cm-foldPlaceholder",o.onclick=i,o}const PO=iw.replace({widget:new class extends nw{toDOM(e){return DO(e,null)}}});class LO extends nw{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return DO(e,this.value)}}const IO={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class _O extends hC{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement("span");return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?"Fold line":"Unfold line"),t}}const BO=VS.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class FO{constructor(e,t){let n;function r(e){let t=Ay.newName();return(n||(n=Object.create(null)))["."+t]=e,t}this.specs=e;const i="string"==typeof t.all?t.all:t.all?r(t.all):void 0,o=t.scope;this.scope=o instanceof zN?e=>e.prop(jN)==o.data:o?e=>e==o:void 0,this.style=yN(e.map(e=>({tag:e.tag,class:e.class||r(Object.assign({},e,{tag:null}))})),{all:i}).style,this.module=n?new Ay(n):null,this.themeType=t.themeType}static define(e,t){return new FO(e,t||{})}}const jO=gb.define(),WO=gb.define({combine:e=>e.length?[e[0]]:null});function zO(e){let t=e.facet(jO);return t.length?t:e.facet(WO)}function HO(e,t){let n,r=[qO];return e instanceof FO&&(e.module&&r.push(VS.styleModule.of(e.module)),n=e.themeType),(null==t?void 0:t.fallback)?r.push(WO.of(e)):n?r.push(jO.computeN([VS.darkTheme],t=>t.facet(VS.darkTheme)==("dark"==n)?[e]:[])):r.push(jO.of(e)),r}class VO{constructor(e){this.markCache=Object.create(null),this.tree=qN(e.state),this.decorations=this.buildDeco(e,zO(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=qN(e.state),n=zO(e.state),r=n!=zO(e.startState),{viewport:i}=e.view,o=e.changes.mapPos(this.decoratedTo,1);t.length<i.to&&!r&&t.type==this.tree.type&&o>=i.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=i.to)}buildDeco(e,t){if(!t||!this.tree.length)return iw.none;let n=new dy;for(let{from:r,to:i}of e.visibleRanges)wN(this.tree,t,(e,t,r)=>{n.add(e,t,this.markCache[r]||(this.markCache[r]=iw.mark({class:r})))},r,i);return n.finish()}}const qO=Mb.high(vx.fromClass(VO,{decorations:e=>e.decorations})),UO=FO.define([{tag:BN.meta,color:"#404740"},{tag:BN.link,textDecoration:"underline"},{tag:BN.heading,textDecoration:"underline",fontWeight:"bold"},{tag:BN.emphasis,fontStyle:"italic"},{tag:BN.strong,fontWeight:"bold"},{tag:BN.strikethrough,textDecoration:"line-through"},{tag:BN.keyword,color:"#708"},{tag:[BN.atom,BN.bool,BN.url,BN.contentSeparator,BN.labelName],color:"#219"},{tag:[BN.literal,BN.inserted],color:"#164"},{tag:[BN.string,BN.deleted],color:"#a11"},{tag:[BN.regexp,BN.escape,BN.special(BN.string)],color:"#e40"},{tag:BN.definition(BN.variableName),color:"#00f"},{tag:BN.local(BN.variableName),color:"#30a"},{tag:[BN.typeName,BN.namespace],color:"#085"},{tag:BN.className,color:"#167"},{tag:[BN.special(BN.variableName),BN.macroName],color:"#256"},{tag:BN.definition(BN.propertyName),color:"#00c"},{tag:BN.comment,color:"#940"},{tag:BN.invalid,color:"#f00"}]),$O=VS.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),KO="()[]{}",YO=gb.define({combine:e=>oy(e,{afterCursor:!0,brackets:KO,maxScanDistance:1e4,renderMatch:JO})}),GO=iw.mark({class:"cm-matchingBracket"}),XO=iw.mark({class:"cm-nonmatchingBracket"});function JO(e){let t=[],n=e.matched?GO:XO;return t.push(n.range(e.start.from,e.start.to)),e.end&&t.push(n.range(e.end.from,e.end.to)),t}const QO=Sb.define({create:()=>iw.none,update(e,t){if(!t.docChanged&&!t.selection)return e;let n=[],r=t.state.facet(YO);for(let e of t.state.selection.ranges){if(!e.empty)continue;let i=rA(t.state,e.head,-1,r)||e.head>0&&rA(t.state,e.head-1,1,r)||r.afterCursor&&(rA(t.state,e.head,1,r)||e.head<t.state.doc.length&&rA(t.state,e.head+1,-1,r));i&&(n=n.concat(r.renderMatch(i,t.state)))}return iw.set(n,!0)},provide:e=>VS.decorations.from(e)}),ZO=[QO,$O];const eA=new BC;function tA(e,t,n){let r=e.prop(t<0?BC.openedBy:BC.closedBy);if(r)return r;if(1==e.name.length){let r=n.indexOf(e.name);if(r>-1&&r%2==(t<0?1:0))return[n[r+t]]}return null}function nA(e){let t=e.type.prop(eA);return t?t(e.node):e}function rA(e,t,n,r={}){let i=r.maxScanDistance||1e4,o=r.brackets||KO,s=qN(e),a=s.resolveInner(t,n);for(let r=a;r;r=r.parent){let i=tA(r.type,n,o);if(i&&r.from<r.to){let s=nA(r);if(s&&(n>0?t>=s.from&&t<s.to:t>s.from&&t<=s.to))return iA(e,t,n,r,s,i,o)}}return function(e,t,n,r,i,o,s){let a=n<0?e.sliceDoc(t-1,t):e.sliceDoc(t,t+1),l=s.indexOf(a);if(l<0||l%2==0!=n>0)return null;let c={from:n<0?t-1:t,to:n>0?t+1:t},u=e.doc.iterRange(t,n>0?e.doc.length:0),h=0;for(let e=0;!u.next().done&&e<=o;){let o=u.value;n<0&&(e+=o.length);let a=t+e*n;for(let e=n>0?0:o.length-1,t=n>0?o.length:-1;e!=t;e+=n){let t=s.indexOf(o[e]);if(!(t<0||r.resolveInner(a+e,1).type!=i))if(t%2==0==n>0)h++;else{if(1==h)return{start:c,end:{from:a+e,to:a+e+1},matched:t>>1==l>>1};h--}}n>0&&(e+=o.length)}return u.done?{start:c,matched:!1}:null}(e,t,n,s,a.type,i,o)}function iA(e,t,n,r,i,o,s){let a=r.parent,l={from:i.from,to:i.to},c=0,u=null==a?void 0:a.cursor();if(u&&(n<0?u.childBefore(r.from):u.childAfter(r.to)))do{if(n<0?u.to<=r.from:u.from>=r.to){if(0==c&&o.indexOf(u.type.name)>-1&&u.from<u.to){let e=nA(u);return{start:l,end:e?{from:e.from,to:e.to}:void 0,matched:!0}}if(tA(u.type,n,s))c++;else if(tA(u.type,-n,s)){if(0==c){let e=nA(u);return{start:l,end:e&&e.from<e.to?{from:e.from,to:e.to}:void 0,matched:!1}}c--}}}while(n<0?u.prevSibling():u.nextSibling());return{start:l,matched:!1}}const oA=Object.create(null),sA=[WC.none],aA=[],lA=Object.create(null),cA=Object.create(null);for(let[e,t]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])cA[e]=hA(oA,t);function uA(e,t){aA.indexOf(e)>-1||aA.push(e)}function hA(e,t){let n=[];for(let r of t.split(" ")){let t=[];for(let n of r.split(".")){let r=e[n]||BN[n];r?"function"==typeof r?t.length?t=t.map(r):uA(n):t.length?uA(n):t=Array.isArray(r)?r:[r]:uA(n)}for(let e of t)n.push(e)}if(!n.length)return 0;let r=t.replace(/ /g,"_"),i=r+" "+n.map(e=>e.id),o=lA[i];if(o)return o.id;let s=lA[i]=WC.define({id:sA.length,name:r,props:[gN({[r]:n})]});return sA.push(s),s.id}Pw.RTL,Pw.LTR;function dA(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return!!i&&(r(n.update(i)),!0)}}const fA=dA(yA,0),pA=dA(bA,0),mA=dA((e,t)=>bA(e,t,function(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let o=t.length-1;o>=0&&t[o].to>r.from?t[o].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}(t)),0);function gA(e,t){let n=e.languageDataAt("commentTokens",t,1);return n.length?n[0]:{}}const vA=50;function bA(e,t,n=t.selection.ranges){let r=n.map(e=>gA(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>function(e,{open:t,close:n},r,i){let o,s,a=e.sliceDoc(r-vA,r),l=e.sliceDoc(i,i+vA),c=/\s*$/.exec(a)[0].length,u=/^\s*/.exec(l)[0].length,h=a.length-c;if(a.slice(h-t.length,h)==t&&l.slice(u,u+n.length)==n)return{open:{pos:r-c,margin:c&&1},close:{pos:i+u,margin:u&&1}};i-r<=2*vA?o=s=e.sliceDoc(r,i):(o=e.sliceDoc(r,r+vA),s=e.sliceDoc(i-vA,i));let d=/^\s*/.exec(o)[0].length,f=/\s*$/.exec(s)[0].length,p=s.length-f-n.length;return o.slice(d,d+t.length)==t&&s.slice(p,p+n.length)==n?{open:{pos:r+d+t.length,margin:/\s/.test(o.charAt(d+t.length))?1:0},close:{pos:i-f-n.length,margin:/\s/.test(s.charAt(p-1))?1:0}}:null}(t,r[n],e.from,e.to));if(2!=e&&!i.every(e=>e))return{changes:t.changes(n.map((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+" "},{from:e.to,insert:" "+r[t].close}]))};if(1!=e&&i.some(e=>e)){let e=[];for(let t,n=0;n<i.length;n++)if(t=i[n]){let i=r[n],{open:o,close:s}=t;e.push({from:o.pos-i.open.length,to:o.pos+o.margin},{from:s.pos-s.margin,to:s.pos+i.close.length})}return{changes:e}}return null}function yA(e,t,n=t.selection.ranges){let r=[],i=-1;for(let{from:e,to:o}of n){let n=r.length,s=1e9,a=gA(t,e).line;if(a){for(let n=e;n<=o;){let l=t.doc.lineAt(n);if(l.from>i&&(e==o||o>l.from)){i=l.from;let e=/^\s*/.exec(l.text)[0].length,t=e==l.length,n=l.text.slice(e,e+a.length)==a?e:-1;e<l.text.length&&e<s&&(s=e),r.push({line:l,comment:n,token:a,indent:e,empty:t,single:!1})}n=l.to+1}if(s<1e9)for(let e=n;e<r.length;e++)r[e].indent<r[e].line.text.length&&(r[e].indent=s);r.length==n+1&&(r[n].single=!0)}}if(2!=e&&r.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:i,empty:o,single:s}of r)!s&&o||e.push({from:t.from+i,insert:n+" "});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}if(1!=e&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,o=r+i.length;" "==t.text[o-t.from]&&o++,e.push({from:r,to:o})}return{changes:e}}return null}const wA=Vb.define(),xA=Vb.define(),kA=gb.define(),SA=gb.define({combine:e=>oy(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}),EA=Sb.define({create:()=>WA.empty,update(e,t){let n=t.state.facet(SA),r=t.annotation(wA);if(r){let i=TA.fromTransaction(t,r.selection),o=r.side,s=0==o?e.undone:e.done;return s=i?RA(s,s.length,n.minDepth,i):IA(s,t.startState.selection),new WA(0==o?r.rest:s,0==o?s:r.rest)}let i=t.annotation(xA);if("full"!=i&&"before"!=i||(e=e.isolate()),!1===t.annotation(Kb.addToHistory))return t.changes.empty?e:e.addMapping(t.changes.desc);let o=TA.fromTransaction(t),s=t.annotation(Kb.time),a=t.annotation(Kb.userEvent);return o?e=e.addChanges(o,s,a,n,t):t.selection&&(e=e.addSelection(t.startState.selection,s,a,n.newGroupDelay)),"full"!=i&&"after"!=i||(e=e.isolate()),e},toJSON:e=>({done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}),fromJSON:e=>new WA(e.done.map(TA.fromJSON),e.undone.map(TA.fromJSON))});function CA(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(EA,!1);if(!i)return!1;let o=i.pop(e,n,t);return!!o&&(r(o),!0)}}const NA=CA(0,!1),OA=CA(1,!1),AA=CA(0,!0),MA=CA(1,!0);class TA{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(e){return new TA(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,n;return{changes:null===(e=this.changes)||void 0===e?void 0:e.toJSON(),mapped:null===(t=this.mapped)||void 0===t?void 0:t.toJSON(),startSelection:null===(n=this.startSelection)||void 0===n?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(e){return new TA(e.changes&&ob.fromJSON(e.changes),[],e.mapped&&ib.fromJSON(e.mapped),e.startSelection&&fb.fromJSON(e.startSelection),e.selectionsAfter.map(fb.fromJSON))}static fromTransaction(e,t){let n=PA;for(let t of e.startState.facet(kA)){let r=t(e);r.length&&(n=n.concat(r))}return!n.length&&e.changes.empty?null:new TA(e.changes.invert(e.startState.doc),n,void 0,t||e.startState.selection,PA)}static selection(e){return new TA(void 0,PA,void 0,void 0,e)}}function RA(e,t,n,r){let i=t+1>n+20?t-n-1:0,o=e.slice(i,t);return o.push(r),o}function DA(e,t){return e.length?t.length?e.concat(t):e:t}const PA=[],LA=200;function IA(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-LA));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),RA(e,e.length-1,1e9,n.setSelAfter(r)))}return[TA.selection([t])]}function _A(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function BA(e,t){if(!e.length)return e;let n=e.length,r=PA;for(;n;){let i=FA(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}t=i.mapped,n--,r=i.selectionsAfter}return r.length?[TA.selection(r)]:PA}function FA(e,t,n){let r=DA(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):PA,n);if(!e.changes)return TA.selection(r);let i=e.changes.map(t),o=t.mapDesc(e.changes,!0),s=e.mapped?e.mapped.composeDesc(o):o;return new TA(i,$b.mapEffects(e.effects,t),s,e.startSelection.map(o),r)}const jA=/^(input\.type|delete)($|\.)/;class WA{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new WA(this.done,this.undone):this}addChanges(e,t,n,r,i){let o=this.done,s=o[o.length-1];return o=s&&s.changes&&!s.changes.empty&&e.changes&&(!n||jA.test(n))&&(!s.selectionsAfter.length&&t-this.prevTime<r.newGroupDelay&&r.joinToEvent(i,function(e,t){let n=[],r=!1;return e.iterChangedRanges((e,t)=>n.push(e,t)),t.iterChangedRanges((e,t,i,o)=>{for(let e=0;e<n.length;){let t=n[e++],s=n[e++];o>=t&&i<=s&&(r=!0)}}),r}(s.changes,e.changes))||"input.type.compose"==n)?RA(o,o.length-1,r.minDepth,new TA(e.changes.compose(s.changes),DA($b.mapEffects(e.effects,s.changes),s.effects),s.mapped,s.startSelection,PA)):RA(o,o.length,r.minDepth,e),new WA(o,PA,t,n)}addSelection(e,t,n,r){let i=this.done.length?this.done[this.done.length-1].selectionsAfter:PA;return i.length>0&&t-this.prevTime<r&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&(o=i[i.length-1],s=e,o.ranges.length==s.ranges.length&&0===o.ranges.filter((e,t)=>e.empty!=s.ranges[t].empty).length)?this:new WA(IA(this.done,e),this.undone,t,n);var o,s}addMapping(e){return new WA(BA(this.done,e),BA(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=0==e?this.done:this.undone;if(0==r.length)return null;let i=r[r.length-1],o=i.selectionsAfter[0]||t.selection;if(n&&i.selectionsAfter.length)return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:wA.of({side:e,rest:_A(r),selection:o}),userEvent:0==e?"select.undo":"select.redo",scrollIntoView:!0});if(i.changes){let n=1==r.length?PA:r.slice(0,r.length-1);return i.mapped&&(n=BA(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:wA.of({side:e,rest:n,selection:o}),filter:!1,userEvent:0==e?"undo":"redo",scrollIntoView:!0})}return null}}WA.empty=new WA(PA,PA);const zA=[{key:"Mod-z",run:NA,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:OA,preventDefault:!0},{linux:"Ctrl-Shift-z",run:OA,preventDefault:!0},{key:"Mod-u",run:AA,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:MA,preventDefault:!0}];function HA(e,t){return fb.create(e.ranges.map(t),e.mainIndex)}function VA(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function qA({state:e,dispatch:t},n){let r=HA(e.selection,n);return!r.eq(e.selection,!0)&&(t(VA(e,r)),!0)}function UA(e,t){return fb.cursor(t?e.to:e.from)}function $A(e,t){return qA(e,n=>n.empty?e.moveByChar(n,t):UA(n,t))}function KA(e){return e.textDirectionAt(e.state.selection.main.head)==Pw.LTR}const YA=e=>$A(e,!KA(e)),GA=e=>$A(e,KA(e));function XA(e,t){return qA(e,n=>n.empty?e.moveByGroup(n,t):UA(n,t))}function JA(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function QA(e,t,n){let r,i,o=qN(e).resolveInner(t.head),s=n?BC.closedBy:BC.openedBy;for(let r=t.head;;){let t=n?o.childAfter(r):o.childBefore(r);if(!t)break;JA(e,t,s)?o=t:r=n?t.to:t.from}return i=o.type.prop(s)&&(r=n?rA(e,o.from,1):rA(e,o.to,-1))&&r.matched?n?r.end.to:r.end.from:n?o.to:o.from,fb.cursor(i,n?-1:1)}function ZA(e,t){return qA(e,n=>{if(!n.empty)return UA(n,t);let r=e.moveVertically(n,t);return r.head!=n.head?r:e.moveToLineBoundary(n,t)})}const eM=e=>ZA(e,!1),tM=e=>ZA(e,!0);function nM(e){let t,n=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,r=0,i=0;if(n){for(let t of e.state.facet(VS.scrollMargins)){let n=t(e);(null==n?void 0:n.top)&&(r=Math.max(null==n?void 0:n.top,r)),(null==n?void 0:n.bottom)&&(i=Math.max(null==n?void 0:n.bottom,i))}t=e.scrollDOM.clientHeight-r-i}else t=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:r,marginBottom:i,selfScroll:n,height:Math.max(e.defaultLineHeight,t-5)}}function rM(e,t){let n,r=nM(e),{state:i}=e,o=HA(i.selection,n=>n.empty?e.moveVertically(n,t,r.height):UA(n,t));if(o.eq(i.selection))return!1;if(r.selfScroll){let t=e.coordsAtPos(i.selection.main.head),s=e.scrollDOM.getBoundingClientRect(),a=s.top+r.marginTop,l=s.bottom-r.marginBottom;t&&t.top>a&&t.bottom<l&&(n=VS.scrollIntoView(o.main.head,{y:"start",yMargin:t.top-a}))}return e.dispatch(VA(i,o),{effects:n}),!0}const iM=e=>rM(e,!1),oM=e=>rM(e,!0);function sM(e,t,n){let r=e.lineBlockAt(t.head),i=e.moveToLineBoundary(t,n);if(i.head==t.head&&i.head!=(n?r.to:r.from)&&(i=e.moveToLineBoundary(t,n,!1)),!n&&i.head==r.from&&r.length){let n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(i=fb.cursor(r.from+n))}return i}function aM(e,t){let n=HA(e.state.selection,e=>{let n=t(e);return fb.range(e.anchor,n.head,n.goalColumn,n.bidiLevel||void 0)});return!n.eq(e.state.selection)&&(e.dispatch(VA(e.state,n)),!0)}function lM(e,t){return aM(e,n=>e.moveByChar(n,t))}const cM=e=>lM(e,!KA(e)),uM=e=>lM(e,KA(e));function hM(e,t){return aM(e,n=>e.moveByGroup(n,t))}function dM(e,t){return aM(e,n=>e.moveVertically(n,t))}const fM=e=>dM(e,!1),pM=e=>dM(e,!0);function mM(e,t){return aM(e,n=>e.moveVertically(n,t,nM(e).height))}const gM=e=>mM(e,!1),vM=e=>mM(e,!0),bM=({state:e,dispatch:t})=>(t(VA(e,{anchor:0})),!0),yM=({state:e,dispatch:t})=>(t(VA(e,{anchor:e.doc.length})),!0),wM=({state:e,dispatch:t})=>(t(VA(e,{anchor:e.selection.main.anchor,head:0})),!0),xM=({state:e,dispatch:t})=>(t(VA(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0);function kM(e,t){let{state:n}=e,r=n.selection,i=n.selection.ranges.slice();for(let r of n.selection.ranges){let o=n.doc.lineAt(r.head);if(t?o.to<e.state.doc.length:o.from>0)for(let n=r;;){let r=e.moveVertically(n,t);if(r.head<o.from||r.head>o.to){i.some(e=>e.head==r.head)||i.push(r);break}if(r.head==n.head)break;n=r}}return i.length!=r.ranges.length&&(e.dispatch(VA(n,fb.create(i,i.length-1))),!0)}function SM(e,t){if(e.state.readOnly)return!1;let n="delete.selection",{state:r}=e,i=r.changeByRange(r=>{let{from:i,to:o}=r;if(i==o){let s=t(r);s<i?(n="delete.backward",s=EM(e,s,!1)):s>i&&(n="delete.forward",s=EM(e,s,!0)),i=Math.min(i,s),o=Math.max(o,s)}else i=EM(e,i,!1),o=EM(e,o,!0);return i==o?{range:r}:{changes:{from:i,to:o},range:fb.cursor(i,i<r.head?-1:1)}});return!i.changes.empty&&(e.dispatch(r.update(i,{scrollIntoView:!0,userEvent:n,effects:"delete.selection"==n?VS.announce.of(r.phrase("Selection deleted")):void 0})),!0)}function EM(e,t,n){if(e instanceof VS)for(let r of e.state.facet(VS.atomicRanges).map(t=>t(e)))r.between(t,t,(e,r)=>{e<t&&r>t&&(t=n?r:e)});return t}const CM=(e,t,n)=>SM(e,r=>{let i,o,s=r.from,{state:a}=e,l=a.doc.lineAt(s);if(n&&!t&&s>l.from&&s<l.from+200&&!/[^ \t]/.test(i=l.text.slice(0,s-l.from))){if("\t"==i[i.length-1])return s-1;let e=Sy(i,a.tabSize)%rO(a)||rO(a);for(let t=0;t<e&&" "==i[i.length-1-t];t++)s--;o=s}else o=Qv(l.text,s-l.from,t,t)+l.from,o==s&&l.number!=(t?a.doc.lines:1)?o+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(l.text.slice(o-l.from,s-l.from))&&(o=Qv(l.text,o-l.from,!1,!1)+l.from);return o}),NM=e=>CM(e,!1,!0),OM=e=>CM(e,!0,!1),AM=(e,t)=>SM(e,n=>{let r=n.head,{state:i}=e,o=i.doc.lineAt(r),s=i.charCategorizer(r);for(let e=null;;){if(r==(t?o.to:o.from)){r==n.head&&o.number!=(t?i.doc.lines:1)&&(r+=t?1:-1);break}let a=Qv(o.text,r-o.from,t)+o.from,l=o.text.slice(Math.min(r,a)-o.from,Math.max(r,a)-o.from),c=s(l);if(null!=e&&c!=e)break;" "==l&&r==n.head||(e=c),r=a}return r}),MM=e=>AM(e,!1);function TM(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),o=e.doc.lineAt(r.to);if(r.empty||r.to!=o.from||(o=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=o.to,e.ranges.push(r)}else t.push({from:i.from,to:o.to,ranges:[r]});n=o.number+1}return t}function RM(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let t of TM(e)){if(n?t.to==e.doc.length:0==t.from)continue;let o=e.doc.lineAt(n?t.to+1:t.from-1),s=o.length+1;if(n){r.push({from:t.to,to:o.to},{from:t.from,insert:o.text+e.lineBreak});for(let n of t.ranges)i.push(fb.range(Math.min(e.doc.length,n.anchor+s),Math.min(e.doc.length,n.head+s)))}else{r.push({from:o.from,to:t.from},{from:t.to,insert:e.lineBreak+o.text});for(let e of t.ranges)i.push(fb.range(e.anchor-s,e.head-s))}}return!!r.length&&(t(e.update({changes:r,scrollIntoView:!0,selection:fb.create(i,e.selection.mainIndex),userEvent:"move.line"})),!0)}function DM(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of TM(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let i=e.changes(r);return t(e.update({changes:i,selection:e.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const PM=IM(!1),LM=IM(!0);function IM(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{let{from:r,to:i}=n,o=t.doc.lineAt(r),s=!e&&r==i&&function(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n,r=qN(e).resolveInner(t),i=r.childBefore(t),o=r.childAfter(t);return i&&o&&i.to<=t&&o.from>=t&&(n=i.type.prop(BC.closedBy))&&n.indexOf(o.name)>-1&&e.doc.lineAt(i.to).from==e.doc.lineAt(o.from).from&&!/\S/.test(e.sliceDoc(i.to,o.from))?{from:i.to,to:o.from}:null}(t,r);e&&(r=i=(i<=o.to?o:t.doc.lineAt(i)).to);let a=new sO(t,{simulateBreak:r,simulateDoubleBreak:!!s}),l=oO(a,r);for(null==l&&(l=Sy(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize));i<o.to&&/\s/.test(o.text[i-o.from]);)i++;s?({from:r,to:i}=s):r>o.from&&r<o.from+100&&!/\S/.test(o.text.slice(0,r))&&(r=o.from);let c=["",iO(t,l)];return s&&c.push(iO(t,a.lineIndent(o.from,-1))),{changes:{from:r,to:i,insert:Hv.of(c)},range:fb.cursor(r+1+c[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:"input"})),!0}}function _M(e,t){let n=-1;return e.changeByRange(r=>{let i=[];for(let o=r.from;o<=r.to;){let s=e.doc.lineAt(o);s.number>n&&(r.empty||r.to>s.from)&&(t(s,i,r),n=s.number),o=s.to+1}let o=e.changes(i);return{changes:i,range:fb.range(o.mapPos(r.anchor,1),o.mapPos(r.head,1))}})}const BM=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(_M(e,(t,n)=>{n.push({from:t.from,insert:e.facet(nO)})}),{userEvent:"input.indent"})),!0),FM=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(_M(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=Sy(r,e.tabSize),o=0,s=iO(e,Math.max(0,i-rO(e)));for(;o<r.length&&o<s.length&&r.charCodeAt(o)==s.charCodeAt(o);)o++;n.push({from:t.from+o,to:t.from+r.length,insert:s.slice(o)})}),{userEvent:"delete.dedent"})),!0),jM=[{key:"Ctrl-b",run:YA,shift:cM,preventDefault:!0},{key:"Ctrl-f",run:GA,shift:uM},{key:"Ctrl-p",run:eM,shift:fM},{key:"Ctrl-n",run:tM,shift:pM},{key:"Ctrl-a",run:e=>qA(e,t=>fb.cursor(e.lineBlockAt(t.head).from,1)),shift:e=>aM(e,t=>fb.cursor(e.lineBlockAt(t.head).from))},{key:"Ctrl-e",run:e=>qA(e,t=>fb.cursor(e.lineBlockAt(t.head).to,-1)),shift:e=>aM(e,t=>fb.cursor(e.lineBlockAt(t.head).to))},{key:"Ctrl-d",run:OM},{key:"Ctrl-h",run:NM},{key:"Ctrl-k",run:e=>SM(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)})},{key:"Ctrl-Alt-h",run:MM},{key:"Ctrl-o",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:Hv.of(["",""])},range:fb.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}},{key:"Ctrl-t",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||0==t.from||t.from==e.doc.length)return{range:t};let n=t.from,r=e.doc.lineAt(n),i=n==r.from?n-1:Qv(r.text,n-r.from,!1)+r.from,o=n==r.to?n+1:Qv(r.text,n-r.from,!0)+r.from;return{changes:{from:i,to:o,insert:e.doc.slice(n,o).append(e.doc.slice(i,n))},range:fb.cursor(o)}});return!n.changes.empty&&(t(e.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)}},{key:"Ctrl-v",run:oM}],WM=[{key:"ArrowLeft",run:YA,shift:cM,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:e=>XA(e,!KA(e)),shift:e=>hM(e,!KA(e)),preventDefault:!0},{mac:"Cmd-ArrowLeft",run:e=>qA(e,t=>sM(e,t,!KA(e))),shift:e=>aM(e,t=>sM(e,t,!KA(e))),preventDefault:!0},{key:"ArrowRight",run:GA,shift:uM,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:e=>XA(e,KA(e)),shift:e=>hM(e,KA(e)),preventDefault:!0},{mac:"Cmd-ArrowRight",run:e=>qA(e,t=>sM(e,t,KA(e))),shift:e=>aM(e,t=>sM(e,t,KA(e))),preventDefault:!0},{key:"ArrowUp",run:eM,shift:fM,preventDefault:!0},{mac:"Cmd-ArrowUp",run:bM,shift:wM},{mac:"Ctrl-ArrowUp",run:iM,shift:gM},{key:"ArrowDown",run:tM,shift:pM,preventDefault:!0},{mac:"Cmd-ArrowDown",run:yM,shift:xM},{mac:"Ctrl-ArrowDown",run:oM,shift:vM},{key:"PageUp",run:iM,shift:gM},{key:"PageDown",run:oM,shift:vM},{key:"Home",run:e=>qA(e,t=>sM(e,t,!1)),shift:e=>aM(e,t=>sM(e,t,!1)),preventDefault:!0},{key:"Mod-Home",run:bM,shift:wM},{key:"End",run:e=>qA(e,t=>sM(e,t,!0)),shift:e=>aM(e,t=>sM(e,t,!0)),preventDefault:!0},{key:"Mod-End",run:yM,shift:xM},{key:"Enter",run:PM,shift:PM},{key:"Mod-a",run:({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0)},{key:"Backspace",run:NM,shift:NM,preventDefault:!0},{key:"Delete",run:OM,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:MM,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:e=>AM(e,!0),preventDefault:!0},{mac:"Mod-Backspace",run:e=>SM(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),preventDefault:!0},{mac:"Mod-Delete",run:e=>SM(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),preventDefault:!0}].concat(jM.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),zM=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:e=>qA(e,t=>QA(e.state,t,!KA(e))),shift:e=>aM(e,t=>QA(e.state,t,!KA(e)))},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:e=>qA(e,t=>QA(e.state,t,KA(e))),shift:e=>aM(e,t=>QA(e.state,t,KA(e)))},{key:"Alt-ArrowUp",run:({state:e,dispatch:t})=>RM(e,t,!1)},{key:"Shift-Alt-ArrowUp",run:({state:e,dispatch:t})=>DM(e,t,!1)},{key:"Alt-ArrowDown",run:({state:e,dispatch:t})=>RM(e,t,!0)},{key:"Shift-Alt-ArrowDown",run:({state:e,dispatch:t})=>DM(e,t,!0)},{key:"Mod-Alt-ArrowUp",run:e=>kM(e,!1)},{key:"Mod-Alt-ArrowDown",run:e=>kM(e,!0)},{key:"Escape",run:({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=fb.create([n.main]):n.main.empty||(r=fb.create([fb.cursor(n.main.head)])),!!r&&(t(VA(e,r)),!0)}},{key:"Mod-Enter",run:LM},{key:"Alt-l",mac:"Ctrl-l",run:({state:e,dispatch:t})=>{let n=TM(e).map(({from:t,to:n})=>fb.range(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:fb.create(n),userEvent:"select"})),!0}},{key:"Mod-i",run:({state:e,dispatch:t})=>{let n=HA(e.selection,t=>{let n=qN(e),r=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=r.node.from&&e.node.to<=r.node.to&&(r=e)}for(let e=r;e;e=e.next){let{node:n}=e;if((n.from<t.from&&n.to>=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return fb.range(n.to,n.from)}return t});return!n.eq(e.selection)&&(t(VA(e,n)),!0)},preventDefault:!0},{key:"Mod-[",run:FM},{key:"Mod-]",run:BM},{key:"Mod-Alt-\\",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new sO(e,{overrideIndentation:e=>{let t=n[e];return null==t?-1:t}}),i=_M(e,(t,i,o)=>{let s=oO(r,t.from);if(null==s)return;/\S/.test(t.text)||(s=0);let a=/^\s*/.exec(t.text)[0],l=iO(e,s);(a!=l||o.from<t.from+a.length)&&(n[t.from]=s,i.push({from:t.from,to:t.from+a.length,insert:l}))});return i.changes.empty||t(e.update(i,{userEvent:"indent"})),!0}},{key:"Shift-Mod-k",run:e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(TM(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=HA(t.selection,t=>{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=r.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0}},{key:"Shift-Mod-\\",run:({state:e,dispatch:t})=>function(e,t,n){let r=!1,i=HA(e.selection,t=>{let i=rA(e,t.head,-1)||rA(e,t.head,1)||t.head>0&&rA(e,t.head-1,1)||t.head<e.doc.length&&rA(e,t.head+1,-1);if(!i||!i.end)return t;r=!0;let o=i.start.from==t.head?i.end.to:i.end.from;return n?fb.range(t.anchor,o):fb.cursor(o)});return!!r&&(t(VA(e,i)),!0)}(e,t,!1)},{key:"Mod-/",run:e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=gA(e.state,n.from);return r.line?fA(e):!!r.block&&mA(e)}},{key:"Alt-A",run:pA},{key:"Ctrl-m",mac:"Shift-Alt-m",run:e=>(e.setTabFocusMode(),!0)}].concat(WM),HM={key:"Tab",run:BM,shift:FM},VM="function"==typeof String.prototype.normalize?e=>e.normalize("NFKD"):e=>e;class qM{constructor(e,t,n=0,r=e.length,i,o){this.test=o,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=i?e=>i(VM(e)):VM,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return Zv(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=eb(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=tb(e);let r=this.normalize(t);if(r.length)for(let e=0,i=n;;e++){let o=r.charCodeAt(e),s=this.match(o,i,this.bufferPos+this.bufferStart);if(e==r.length-1){if(s)return this.value=s,this;break}i==n&&e<t.length&&t.charCodeAt(e)==o&&i++}}}match(e,t,n){let r=null;for(let t=0;t<this.matches.length;t+=2){let i=this.matches[t],o=!1;this.query.charCodeAt(i)==e&&(i==this.query.length-1?r={from:this.matches[t+1],to:n}:(this.matches[t]++,o=!0)),o||(this.matches.splice(t,2),t-=2)}return this.query.charCodeAt(0)==e&&(1==this.query.length?r={from:t,to:n}:this.matches.push(1,t)),r&&this.test&&!this.test(r.from,r.to,this.buffer,this.bufferStart)&&(r=null),r}}"undefined"!=typeof Symbol&&(qM.prototype[Symbol.iterator]=function(){return this});const UM={from:-1,to:-1,match:/.*/.exec("")},$M="gm"+(null==/x/.unicode?"":"u");class KM{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine="",this.done=!1,this.value=UM,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new XM(e,t,n,r,i);this.re=new RegExp(t,$M+((null==n?void 0:n.ignoreCase)?"i":"")),this.test=null==n?void 0:n.test,this.iter=e.iter();let o=e.lineAt(r);this.curLineStart=o.from,this.matchPos=JM(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=JM(this.text,r+(n==r?1:0)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,match:t},this;e=this.matchPos-this.curLineStart}else{if(!(this.curLineStart+this.curLine.length<this.to))return this.done=!0,this;this.nextLine(),e=0}}}}const YM=new WeakMap;class GM{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,n){let r=YM.get(e);if(!r||r.from>=n||r.to<=t){let r=new GM(t,e.sliceString(t,n));return YM.set(e,r),r}if(r.from==t&&r.to==n)return r;let{text:i,from:o}=r;return o>t&&(i=e.sliceString(t,o)+i,o=t),r.to<n&&(i+=e.sliceString(r.to,n)),YM.set(e,new GM(o,i)),new GM(t,i.slice(t-o,n-o))}}class XM{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=UM,this.matchPos=JM(e,r),this.re=new RegExp(t,$M+((null==n?void 0:n.ignoreCase)?"i":"")),this.test=null==n?void 0:n.test,this.flat=GM.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,match:t},this.matchPos=JM(this.text,n+(e==n?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=GM.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+2*this.flat.text.length))}}}function JM(e,t){if(t>=e.length)return t;let n,r=e.lineAt(t);for(;t<r.to&&(n=r.text.charCodeAt(t-r.from))>=56320&&n<57344;)t++;return t}"undefined"!=typeof Symbol&&(KM.prototype[Symbol.iterator]=XM.prototype[Symbol.iterator]=function(){return this});const QM={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},ZM=gb.define({combine:e=>oy(e,QM,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})});const eT=iw.mark({class:"cm-selectionMatch"}),tT=iw.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function nT(e,t,n,r){return!(0!=n&&e(t.sliceDoc(n-1,n))==ey.Word||r!=t.doc.length&&e(t.sliceDoc(r,r+1))==ey.Word)}const rT=vx.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(ZM),{state:n}=e,r=n.selection;if(r.ranges.length>1)return iw.none;let i,o=r.main,s=null;if(o.empty){if(!t.highlightWordAroundCursor)return iw.none;let e=n.wordAt(o.head);if(!e)return iw.none;s=n.charCategorizer(o.head),i=n.sliceDoc(e.from,e.to)}else{let e=o.to-o.from;if(e<t.minSelectionLength||e>200)return iw.none;if(t.wholeWords){if(i=n.sliceDoc(o.from,o.to),s=n.charCategorizer(o.head),!nT(s,n,o.from,o.to)||!function(e,t,n,r){return e(t.sliceDoc(n,n+1))==ey.Word&&e(t.sliceDoc(r-1,r))==ey.Word}(s,n,o.from,o.to))return iw.none}else if(i=n.sliceDoc(o.from,o.to),!i)return iw.none}let a=[];for(let r of e.visibleRanges){let e=new qM(n.doc,i,r.from,r.to);for(;!e.next().done;){let{from:r,to:i}=e.value;if((!s||nT(s,n,r,i))&&(o.empty&&r<=o.from&&i>=o.to?a.push(tT.range(r,i)):(r>=o.to||i<=o.from)&&a.push(eT.range(r,i)),a.length>t.maxMatches))return iw.none}}return iw.set(a)}},{decorations:e=>e.decorations}),iT=VS.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}});const oT=gb.define({combine:e=>oy(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new LT(e),scrollToMatch:e=>VS.scrollIntoView(e)})});class sT{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||function(e){try{return new RegExp(e,$M),!0}catch(e){return!1}}(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>"n"==t?"\n":"r"==t?"\r":"t"==t?"\t":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new fT(this):new cT(this)}getCursor(e,t=0,n){let r=e.doc?e:iy.create({doc:e});return null==n&&(n=r.doc.length),this.regexp?uT(this,r,t,n):lT(this,r,t,n)}}class aT{constructor(e){this.spec=e}}function lT(e,t,n,r){let i;return e.wholeWord&&(i=function(e,t){return(n,r,i,o)=>((o>n||o+i.length<r)&&(o=Math.max(0,n-2),i=e.sliceString(o,Math.min(e.length,r+2))),!(t(hT(i,n-o))==ey.Word&&t(dT(i,n-o))==ey.Word||t(dT(i,r-o))==ey.Word&&t(hT(i,r-o))==ey.Word))}(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=function(e,t,n){return(r,i,o,s)=>{if(n&&!n(r,i,o,s))return!1;let a=r>=s&&i<=s+o.length?o.slice(r-s,i-s):t.doc.sliceString(r,i);return e(a,t,r,i)}}(e.test,t,i)),new qM(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}class cT extends aT{constructor(e){super(e)}nextMatch(e,t,n){let r=lT(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=lT(this.spec,e,0,n).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==n?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let n=Math.max(t,r-1e4-this.spec.unquoted.length),i=lT(this.spec,e,n,r),o=null;for(;!i.nextOverlapping().done;)o=i.value;if(o)return o;if(n==t)return null;r-=1e4}}prevMatch(e,t,n){let r=this.prevMatchInRange(e,0,t);return r||(r=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length)),!r||r.from==t&&r.to==n?null:r}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=lT(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=lT(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}}function uT(e,t,n,r){let i;var o;return e.wholeWord&&(o=t.charCategorizer(t.selection.main.head),i=(e,t,n)=>!n[0].length||(o(hT(n.input,n.index))!=ey.Word||o(dT(n.input,n.index))!=ey.Word)&&(o(dT(n.input,n.index+n[0].length))!=ey.Word||o(hT(n.input,n.index+n[0].length))!=ey.Word)),e.test&&(i=function(e,t,n){return(r,i,o)=>(!n||n(r,i,o))&&e(o[0],t,r,i)}(e.test,t,i)),new KM(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function hT(e,t){return e.slice(Qv(e,t,!1),t)}function dT(e,t){return e.slice(t,Qv(e,t))}class fT extends aT{nextMatch(e,t,n){let r=uT(this.spec,e,n,e.doc.length).next();return r.done&&(r=uT(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let i=Math.max(t,n-1e4*r),o=uT(this.spec,e,i,n),s=null;for(;!o.next().done;)s=o.value;if(s&&(i==t||s.from>i+10))return s;if(i==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if("&"==n)return e.match[0];if("$"==n)return"$";for(let t=n.length;t>0;t--){let r=+n.slice(0,t);if(r>0&&r<e.match.length)return e.match[r]+n.slice(t)}return t})}matchAll(e,t){let n=uT(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=uT(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}}const pT=$b.define(),mT=$b.define(),gT=Sb.define({create:e=>new vT(AT(e).create(),null),update(e,t){for(let n of t.effects)n.is(pT)?e=new vT(n.value.create(),e.panel):n.is(mT)&&(e=new vT(e.query,n.value?OT:null));return e},provide:e=>sC.from(e,e=>e.panel)});class vT{constructor(e,t){this.query=e,this.panel=t}}const bT=iw.mark({class:"cm-searchMatch"}),yT=iw.mark({class:"cm-searchMatch cm-searchMatch-selected"}),wT=vx.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(gT))}update(e){let t=e.state.field(gT);(t!=e.startState.field(gT)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return iw.none;let{view:n}=this,r=new dy;for(let t=0,i=n.visibleRanges,o=i.length;t<o;t++){let{from:s,to:a}=i[t];for(;t<o-1&&a>i[t+1].from-500;)a=i[++t].to;e.highlight(n.state,s,a,(e,t)=>{let i=n.state.selection.ranges.some(n=>n.from==e&&n.to==t);r.add(e,t,i?yT:bT)})}return r.finish()}},{decorations:e=>e.decorations});function xT(e){return t=>{let n=t.state.field(gT,!1);return n&&n.query.spec.valid?e(t,n):RT(t)}}const kT=xT((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let i=fb.single(r.from,r.to),o=e.state.facet(oT);return e.dispatch({selection:i,effects:[FT(e,r),o.scrollToMatch(i.main,e)],userEvent:"select.search"}),TT(e),!0}),ST=xT((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,i=t.prevMatch(n,r,r);if(!i)return!1;let o=fb.single(i.from,i.to),s=e.state.facet(oT);return e.dispatch({selection:o,effects:[FT(e,i),s.scrollToMatch(o.main,e)],userEvent:"select.search"}),TT(e),!0}),ET=xT((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!(!n||!n.length)&&(e.dispatch({selection:fb.create(n.map(e=>fb.range(e.from,e.to))),userEvent:"select.search.matches"}),!0)}),CT=xT((e,{query:t})=>{let{state:n}=e,{from:r,to:i}=n.selection.main;if(n.readOnly)return!1;let o=t.nextMatch(n,r,r);if(!o)return!1;let s,a,l=o,c=[],u=[];l.from==r&&l.to==i&&(a=n.toText(t.getReplacement(l)),c.push({from:l.from,to:l.to,insert:a}),l=t.nextMatch(n,l.from,l.to),u.push(VS.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(r).number)+".")));let h=e.state.changes(c);return l&&(s=fb.single(l.from,l.to).map(h),u.push(FT(e,l)),u.push(n.facet(oT).scrollToMatch(s.main,e))),e.dispatch({changes:h,selection:s,effects:u,userEvent:"input.replace"}),!0}),NT=xT((e,{query:t})=>{if(e.state.readOnly)return!1;let n=t.matchAll(e.state,1e9).map(e=>{let{from:n,to:r}=e;return{from:n,to:r,insert:t.getReplacement(e)}});if(!n.length)return!1;let r=e.state.phrase("replaced $ matches",n.length)+".";return e.dispatch({changes:n,effects:VS.announce.of(r),userEvent:"input.replace.all"}),!0});function OT(e){return e.state.facet(oT).createPanel(e)}function AT(e,t){var n,r,i,o,s;let a=e.selection.main,l=a.empty||a.to>a.from+100?"":e.sliceDoc(a.from,a.to);if(t&&!l)return t;let c=e.facet(oT);return new sT({search:(null!==(n=null==t?void 0:t.literal)&&void 0!==n?n:c.literal)?l:l.replace(/\n/g,"\\n"),caseSensitive:null!==(r=null==t?void 0:t.caseSensitive)&&void 0!==r?r:c.caseSensitive,literal:null!==(i=null==t?void 0:t.literal)&&void 0!==i?i:c.literal,regexp:null!==(o=null==t?void 0:t.regexp)&&void 0!==o?o:c.regexp,wholeWord:null!==(s=null==t?void 0:t.wholeWord)&&void 0!==s?s:c.wholeWord})}function MT(e){let t=nC(e,OT);return t&&t.dom.querySelector("[main-field]")}function TT(e){let t=MT(e);t&&t==e.root.activeElement&&t.select()}const RT=e=>{let t=e.state.field(gT,!1);if(t&&t.panel){let n=MT(e);if(n&&n!=e.root.activeElement){let r=AT(e.state,t.query.spec);r.valid&&e.dispatch({effects:pT.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[mT.of(!0),t?pT.of(AT(e.state,t.query.spec)):$b.appendConfig.of(WT)]});return!0},DT=e=>{let t=e.state.field(gT,!1);if(!t||!t.panel)return!1;let n=nC(e,OT);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:mT.of(!1)}),!0},PT=[{key:"Mod-f",run:RT,scope:"editor search-panel"},{key:"F3",run:kT,shift:ST,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:kT,shift:ST,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:DT,scope:"editor search-panel"},{key:"Mod-Shift-l",run:({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:i}=n.main,o=[],s=0;for(let t=new qM(e.doc,e.sliceDoc(r,i));!t.next().done;){if(o.length>1e3)return!1;t.value.from==r&&(s=o.length),o.push(fb.range(t.value.from,t.value.to))}return t(e.update({selection:fb.create(o,s),userEvent:"select.search.matches"})),!0}},{key:"Mod-Alt-g",run:e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:i}=aC(e,{label:t.phrase("Go to line"),input:{type:"text",name:"line",value:n},focus:!0,submitLabel:t.phrase("go")});return i.then(n=>{let i=n&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.elements.line.value);if(!i)return void e.dispatch({effects:r});let o=t.doc.lineAt(t.selection.main.head),[,s,a,l,c]=i,u=l?+l.slice(1):0,h=a?+a:o.number;if(a&&c){let e=h/100;s&&(e=e*("-"==s?-1:1)+o.number/t.doc.lines),h=Math.round(t.doc.lines*e)}else a&&s&&(h=h*("-"==s?-1:1)+o.number);let d=t.doc.line(Math.max(1,Math.min(t.doc.lines,h))),f=fb.cursor(d.from+Math.max(0,Math.min(u,d.length)));e.dispatch({effects:[r,VS.scrollIntoView(f.from,{y:"center"})],selection:f})}),!0}},{key:"Mod-d",run:({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return(({state:e,dispatch:t})=>{let{selection:n}=e,r=fb.create(n.ranges.map(t=>e.wordAt(t.head)||fb.cursor(t.head)),n.mainIndex);return!r.eq(n)&&(t(e.update({selection:r})),!0)})({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=r))return!1;let i=function(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),o=i&&i.from==n.from&&i.to==n.to;for(let n=!1,i=new qM(e.doc,t,r[r.length-1].to);;){if(i.next(),!i.done){if(n&&r.some(e=>e.from==i.value.from))continue;if(o){let t=e.wordAt(i.value.from);if(!t||t.from!=i.value.from||t.to!=i.value.to)continue}return i.value}if(n)return null;i=new qM(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),n=!0}}(e,r);return!!i&&(t(e.update({selection:e.selection.addRange(fb.range(i.from,i.to),!1),effects:VS.scrollIntoView(i.to)})),!0)},preventDefault:!0}];class LT{constructor(e){this.view=e;let t=this.query=e.state.field(gT).query.spec;function n(e,t,n){return By("button",{class:"cm-button",name:e,onclick:t,type:"button"},n)}this.commit=this.commit.bind(this),this.searchField=By("input",{value:t.search,placeholder:IT(e,"Find"),"aria-label":IT(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=By("input",{value:t.replace,placeholder:IT(e,"Replace"),"aria-label":IT(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=By("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=By("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=By("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit}),this.dom=By("div",{onkeydown:e=>this.keydown(e),class:"cm-search"},[this.searchField,n("next",()=>kT(e),[IT(e,"next")]),n("prev",()=>ST(e),[IT(e,"previous")]),n("select",()=>ET(e),[IT(e,"all")]),By("label",null,[this.caseField,IT(e,"match case")]),By("label",null,[this.reField,IT(e,"regexp")]),By("label",null,[this.wordField,IT(e,"by word")]),...e.state.readOnly?[]:[By("br"),this.replaceField,n("replace",()=>CT(e),[IT(e,"replace")]),n("replaceAll",()=>NT(e),[IT(e,"replace all")])],By("button",{name:"close",onclick:()=>DT(e),"aria-label":IT(e,"close"),type:"button"},["×"])])}commit(){let e=new sT({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:pT.of(e)}))}keydown(e){var t,n,r;t=this.view,n=e,r="search-panel",rE(ZS(t.state),n,t,r)?e.preventDefault():13==e.keyCode&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?ST:kT)(this.view)):13==e.keyCode&&e.target==this.replaceField&&(e.preventDefault(),CT(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(pT)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(oT).top}}function IT(e,t){return e.state.phrase(t)}const _T=30,BT=/[\s\.,:;?!]/;function FT(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),i=e.state.doc.lineAt(n).to,o=Math.max(r.from,t-_T),s=Math.min(i,n+_T),a=e.state.sliceDoc(o,s);if(o!=r.from)for(let e=0;e<_T;e++)if(!BT.test(a[e+1])&&BT.test(a[e])){a=a.slice(e);break}if(s!=i)for(let e=a.length-1;e>a.length-_T;e--)if(!BT.test(a[e-1])&&BT.test(a[e])){a=a.slice(0,e);break}return VS.announce.of(`${e.state.phrase("current match")}. ${a} ${e.state.phrase("on line")} ${r.number}.`)}const jT=VS.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),WT=[gT,Mb.low(wT),jT];class zT{constructor(e,t,n,r){this.state=e,this.pos=t,this.explicit=n,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=qN(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),r=t.text.slice(n-t.from,this.pos-t.from),i=r.search($T(e,!1));return i<0?null:{from:n+i,to:this.pos,text:r.slice(i)}}get aborted(){return null==this.abortListeners}addEventListener(e,t,n){"abort"==e&&this.abortListeners&&(this.abortListeners.push(t),n&&n.onDocChange&&(this.abortOnDocChange=!0))}}function HT(e){let t=Object.keys(e).join(""),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,"")),`[${n?"\\w":""}${t.replace(/[^\w\s]/g,"\\$&")}]`}function VT(e){let t=e.map(e=>"string"==typeof e?{label:e}:e),[n,r]=t.every(e=>/^\w+$/.test(e.label))?[/\w*$/,/\w+$/]:function(e){let t=Object.create(null),n=Object.create(null);for(let{label:r}of e){t[r[0]]=!0;for(let e=1;e<r.length;e++)n[r[e]]=!0}let r=HT(t)+HT(n)+"*$";return[new RegExp("^"+r),new RegExp(r)]}(t);return e=>{let i=e.matchBefore(r);return i||e.explicit?{from:i?i.from:e.pos,options:t,validFor:n}:null}}class qT{constructor(e,t,n,r){this.completion=e,this.source=t,this.match=n,this.score=r}}function UT(e){return e.selection.main.from}function $T(e,t){var n;let{source:r}=e,i=t&&"^"!=r[0],o="$"!=r[r.length-1];return i||o?new RegExp(`${i?"^":""}(?:${r})${o?"$":""}`,null!==(n=e.flags)&&void 0!==n?n:e.ignoreCase?"i":""):e}const KT=Vb.define();function YT(e,t,n,r){let{main:i}=e.selection,o=n-i.from,s=r-i.from;return{...e.changeByRange(a=>{if(a!=i&&n!=r&&e.sliceDoc(a.from+o,a.from+s)!=e.sliceDoc(n,r))return{range:a};let l=e.toText(t);return{changes:{from:a.from+o,to:r==i.from?a.to:a.from+s,insert:l},range:fb.cursor(a.from+o+l.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}const GT=new WeakMap;function XT(e){if(!Array.isArray(e))return e;let t=GT.get(e);return t||GT.set(e,t=VT(e)),t}const JT=$b.define(),QT=$b.define();class ZT{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let n=Zv(e,t),r=tb(n);this.chars.push(n);let i=e.slice(t,t+r),o=i.toUpperCase();this.folded.push(Zv(o==i?i.toLowerCase():o,0)),t+=r}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(0==this.pattern.length)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:n,any:r,precise:i,byWord:o}=this;if(1==t.length){let r=Zv(e,0),i=tb(r),o=i==e.length?0:-100;if(r==t[0]);else{if(r!=n[0])return null;o+=-200}return this.ret(o,[0,i])}let s=e.indexOf(this.pattern);if(0==s)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let a=t.length,l=0;if(s<0){for(let i=0,o=Math.min(e.length,200);i<o&&l<a;){let o=Zv(e,i);o!=t[l]&&o!=n[l]||(r[l++]=i),i+=tb(o)}if(l<a)return null}let c=0,u=0,h=!1,d=0,f=-1,p=-1,m=/[a-z]/.test(e),g=!0;for(let r=0,l=Math.min(e.length,200),v=0;r<l&&u<a;){let l=Zv(e,r);s<0&&(c<a&&l==t[c]&&(i[c++]=r),d<a&&(l==t[d]||l==n[d]?(0==d&&(f=r),p=r+1,d++):d=0));let b,y=l<255?l>=48&&l<=57||l>=97&&l<=122?2:l>=65&&l<=90?1:0:(b=eb(l))!=b.toLowerCase()?1:b!=b.toUpperCase()?2:0;(!r||1==y&&m||0==v&&0!=y)&&(t[u]==l||n[u]==l&&(h=!0)?o[u++]=r:o.length&&(g=!1)),v=y,r+=tb(l)}return u==a&&0==o[0]&&g?this.result((h?-200:0)-100,o,e):d==a&&0==f?this.ret(-200-e.length+(p==e.length?0:-100),[0,p]):s>-1?this.ret(-700-e.length,[s,s+this.pattern.length]):d==a?this.ret(-900-e.length,[f,p]):u==a?this.result((h?-200:0)-100-700+(g?0:-1100),o,e):2==t.length?null:this.result((r[0]?-700:0)-200-1100,r,e)}result(e,t,n){let r=[],i=0;for(let e of t){let t=e+(this.astral?tb(Zv(n,e)):1);i&&r[i-1]==e?r[i-1]=t:(r[i++]=e,r[i++]=t)}return this.ret(e-n.length,r)}}class eR{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let t=e.slice(0,this.pattern.length),n=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return null==n?null:(this.matched=[0,t.length],this.score=n+(e.length==this.pattern.length?0:-100),this)}}const tR=gb.define({combine:e=>oy(e,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:rR,filterStrict:!1,compareCompletions:(e,t)=>(e.sortText||e.label).localeCompare(t.sortText||t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>n=>nR(e(n),t(n)),optionClass:(e,t)=>n=>nR(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})});function nR(e,t){return e?t?e+" "+t:e:t}function rR(e,t,n,r,i,o){let s,a,l=e.textDirection==Pw.RTL,c=l,u=!1,h="top",d=t.left-i.left,f=i.right-t.right,p=r.right-r.left,m=r.bottom-r.top;if(c&&d<Math.min(p,f)?c=!1:!c&&f<Math.min(p,d)&&(c=!0),p<=(c?d:f))s=Math.max(i.top,Math.min(n.top,i.bottom-m))-t.top,a=Math.min(400,c?d:f);else{u=!0,a=Math.min(400,(l?t.right:i.right-t.left)-30);let e=i.bottom-t.bottom;e>=m||e>t.top?s=n.bottom-t.top:(h="bottom",s=t.bottom-n.top)}return{style:`${h}: ${s/((t.bottom-t.top)/o.offsetHeight)}px; max-width: ${a/((t.right-t.left)/o.offsetWidth)}px`,class:"cm-completionInfo-"+(u?l?"left-narrow":"right-narrow":c?"left":"right")}}function iR(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let e=Math.floor(t/n);return{from:e*n,to:(e+1)*n}}let r=Math.floor((e-t)/n);return{from:e-(r+1)*n,to:e-r*n}}class oR{constructor(e,t,n){this.view=e,this.stateField=t,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:e=>this.placeInfo(e),key:this},this.space=null,this.currentClass="";let r=e.state.field(t),{options:i,selected:o}=r.open,s=e.state.facet(tR);this.optionContent=function(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(e){let t=document.createElement("div");return t.classList.add("cm-completionIcon"),e.type&&t.classList.add(...e.type.split(/\s+/g).map(e=>"cm-completionIcon-"+e)),t.setAttribute("aria-hidden","true"),t},position:20}),t.push({render(e,t,n,r){let i=document.createElement("span");i.className="cm-completionLabel";let o=e.displayLabel||e.label,s=0;for(let e=0;e<r.length;){let t=r[e++],n=r[e++];t>s&&i.appendChild(document.createTextNode(o.slice(s,t)));let a=i.appendChild(document.createElement("span"));a.appendChild(document.createTextNode(o.slice(t,n))),a.className="cm-completionMatchedText",s=n}return s<o.length&&i.appendChild(document.createTextNode(o.slice(s))),i},position:50},{render(e){if(!e.detail)return null;let t=document.createElement("span");return t.className="cm-completionDetail",t.textContent=e.detail,t},position:80}),t.sort((e,t)=>e.position-t.position).map(e=>e.render)}(s),this.optionClass=s.optionClass,this.tooltipClass=s.tooltipClass,this.range=iR(i.length,o,s.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",n=>{let{options:r}=e.state.field(t).open;for(let t,i=n.target;i&&i!=this.dom;i=i.parentNode)if("LI"==i.nodeName&&(t=/-(\d+)$/.exec(i.id))&&+t[1]<r.length)return this.applyCompletion(e,r[+t[1]]),void n.preventDefault()}),this.dom.addEventListener("focusout",t=>{let n=e.state.field(this.stateField,!1);n&&n.tooltip&&e.state.facet(tR).closeOnBlur&&t.relatedTarget!=e.contentDOM&&e.dispatch({effects:QT.of(null)})}),this.showOptions(i,r.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var t;let n=e.state.field(this.stateField),r=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),n!=r){let{options:i,selected:o,disabled:s}=n.open;r.open&&r.open.options==i||(this.range=iR(i.length,o,e.state.facet(tR).maxRenderedOptions),this.showOptions(i,n.id)),this.updateSel(),s!=(null===(t=r.open)||void 0===t?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!s)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let e of this.currentClass.split(" "))e&&this.dom.classList.remove(e);for(let e of t.split(" "))e&&this.dom.classList.add(e);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=iR(t.options.length,t.selected,this.view.state.facet(tR).maxRenderedOptions),this.showOptions(t.options,e.id));let n=this.updateSelectedOption(t.selected);if(n){this.destroyInfo();let{completion:r}=t.options[t.selected],{info:i}=r;if(!i)return;let o="string"==typeof i?document.createTextNode(i):i(r);if(!o)return;"then"in o?o.then(t=>{t&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(t,r)}).catch(e=>fx(this.view.state,e,"completion info")):(this.addInfoPane(o,r),n.setAttribute("aria-describedby",this.info.id))}}addInfoPane(e,t){this.destroyInfo();let n=this.info=document.createElement("div");if(n.className="cm-tooltip cm-completionInfo",n.id="cm-completionInfo-"+Math.floor(65535*Math.random()).toString(16),null!=e.nodeType)n.appendChild(e),this.infoDestroy=null;else{let{dom:t,destroy:r}=e;n.appendChild(t),this.infoDestroy=r||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let n=this.list.firstChild,r=this.range.from;n;n=n.nextSibling,r++)"LI"==n.nodeName&&n.id?r==e?n.hasAttribute("aria-selected")||(n.setAttribute("aria-selected","true"),t=n):n.hasAttribute("aria-selected")&&(n.removeAttribute("aria-selected"),n.removeAttribute("aria-describedby")):r--;return t&&function(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=n.height/e.offsetHeight;r.top<n.top?e.scrollTop-=(n.top-r.top)/i:r.bottom>n.bottom&&(e.scrollTop+=(r.bottom-n.bottom)/i)}(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),r=e.getBoundingClientRect(),i=this.space;if(!i){let e=this.dom.ownerDocument.documentElement;i={left:0,top:0,right:e.clientWidth,bottom:e.clientHeight}}return r.top>Math.min(i.bottom,t.bottom)-10||r.bottom<Math.max(i.top,t.top)+10?null:this.view.state.facet(tR).positionInfo(this.view,t,r,n,i,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(e,t,n){const r=document.createElement("ul");r.id=t,r.setAttribute("role","listbox"),r.setAttribute("aria-expanded","true"),r.setAttribute("aria-label",this.view.state.phrase("Completions")),r.addEventListener("mousedown",e=>{e.target==r&&e.preventDefault()});let i=null;for(let o=n.from;o<n.to;o++){let{completion:s,match:a}=e[o],{section:l}=s;if(l){let e="string"==typeof l?l:l.name;if(e!=i&&(o>n.from||0==n.from))if(i=e,"string"!=typeof l&&l.header)r.appendChild(l.header(l));else{r.appendChild(document.createElement("completion-section")).textContent=e}}const c=r.appendChild(document.createElement("li"));c.id=t+"-"+o,c.setAttribute("role","option");let u=this.optionClass(s);u&&(c.className=u);for(let e of this.optionContent){let t=e(s,this.view.state,this.view,a);t&&c.appendChild(t)}}return n.from&&r.classList.add("cm-completionListIncompleteTop"),n.to<e.length&&r.classList.add("cm-completionListIncompleteBottom"),r}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function sR(e,t){return n=>new oR(n,e,t)}function aR(e){return 100*(e.boost||0)+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}class lR{constructor(e,t,n,r,i,o){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=r,this.selected=i,this.disabled=o}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new lR(this.options,dR(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,n,r,i,o){if(r&&!o&&e.some(e=>e.isPending))return r.setDisabled();let s=function(e,t){let n=[],r=null,i=null,o=e=>{n.push(e);let{section:t}=e.completion;if(t){r||(r=[]);let e="string"==typeof t?t:t.name;r.some(t=>t.name==e)||r.push("string"==typeof t?{name:e}:t)}},s=t.facet(tR);for(let r of e)if(r.hasResult()){let e=r.result.getMatch;if(!1===r.result.filter)for(let t of r.result.options)o(new qT(t,r.source,e?e(t):[],1e9-n.length));else{let n,a=t.sliceDoc(r.from,r.to),l=s.filterStrict?new eR(a):new ZT(a);for(let t of r.result.options)if(n=l.match(t.label)){let s=t.displayLabel?e?e(t,n.matched):[]:n.matched,a=n.score+(t.boost||0);if(o(new qT(t,r.source,s,a)),"object"==typeof t.section&&"dynamic"===t.section.rank){let{name:e}=t.section;i||(i=Object.create(null)),i[e]=Math.max(a,i[e]||-1e9)}}}}if(r){let e=Object.create(null),t=0,o=(e,t)=>("dynamic"===e.rank&&"dynamic"===t.rank?i[t.name]-i[e.name]:0)||("number"==typeof e.rank?e.rank:1e9)-("number"==typeof t.rank?t.rank:1e9)||(e.name<t.name?-1:1);for(let n of r.sort(o))t-=1e5,e[n.name]=t;for(let t of n){let{section:n}=t.completion;n&&(t.score+=e["string"==typeof n?n:n.name])}}let a=[],l=null,c=s.compareCompletions;for(let e of n.sort((e,t)=>t.score-e.score||c(e.completion,t.completion))){let t=e.completion;!l||l.label!=t.label||l.detail!=t.detail||null!=l.type&&null!=t.type&&l.type!=t.type||l.apply!=t.apply||l.boost!=t.boost?a.push(e):aR(e.completion)>aR(l)&&(a[a.length-1]=e),l=e.completion}return a}(e,t);if(!s.length)return r&&e.some(e=>e.isPending)?r.setDisabled():null;let a=t.facet(tR).selectOnOpen?0:-1;if(r&&r.selected!=a&&-1!=r.selected){let e=r.options[r.selected].completion;for(let t=0;t<s.length;t++)if(s[t].completion==e){a=t;break}}return new lR(s,dR(n,a),{pos:e.reduce((e,t)=>t.hasResult()?Math.min(e,t.from):e,1e8),create:xR,above:i.aboveCursor},r?r.timestamp:Date.now(),a,!1)}map(e){return new lR(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new lR(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class cR{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new cR(fR,"cm-ac-"+Math.floor(2e6*Math.random()).toString(36),null)}update(e){let{state:t}=e,n=t.facet(tR),r=(n.override||t.languageDataAt("autocomplete",UT(t)).map(XT)).map(t=>(this.active.find(e=>e.source==t)||new mR(t,this.active.some(e=>0!=e.state)?1:0)).update(e,n));r.length==this.active.length&&r.every((e,t)=>e==this.active[t])&&(r=this.active);let i=this.open,o=e.effects.some(e=>e.is(vR));i&&e.docChanged&&(i=i.map(e.changes)),e.selection||r.some(t=>t.hasResult()&&e.changes.touchesRange(t.from,t.to))||!function(e,t){if(e==t)return!0;for(let n=0,r=0;;){for(;n<e.length&&!e[n].hasResult();)n++;for(;r<t.length&&!t[r].hasResult();)r++;let i=n==e.length,o=r==t.length;if(i||o)return i==o;if(e[n++].result!=t[r++].result)return!1}}(r,this.active)||o?i=lR.build(r,t,this.id,i,n,o):i&&i.disabled&&!r.some(e=>e.isPending)&&(i=null),!i&&r.every(e=>!e.isPending)&&r.some(e=>e.hasResult())&&(r=r.map(e=>e.hasResult()?new mR(e.source,0):e));for(let t of e.effects)t.is(bR)&&(i=i&&i.setSelected(t.value,this.id));return r==this.active&&i==this.open?this:new cR(r,this.id,i)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?uR:hR}}const uR={"aria-autocomplete":"list"},hR={};function dR(e,t){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(n["aria-activedescendant"]=e+"-"+t),n}const fR=[];function pR(e,t){if(e.isUserEvent("input.complete")){let n=e.annotation(KT);if(n&&t.activateOnCompletion(n))return 12}let n=e.isUserEvent("input.type");return n&&t.activateOnTyping?5:n?1:e.isUserEvent("delete.backward")?2:e.selection?8:e.docChanged?16:0}class mR{constructor(e,t,n=!1){this.source=e,this.state=t,this.explicit=n}hasResult(){return!1}get isPending(){return 1==this.state}update(e,t){let n=pR(e,t),r=this;(8&n||16&n&&this.touches(e))&&(r=new mR(r.source,0)),4&n&&0==r.state&&(r=new mR(this.source,1)),r=r.updateFor(e,n);for(let t of e.effects)if(t.is(JT))r=new mR(r.source,1,t.value);else if(t.is(QT))r=new mR(r.source,0);else if(t.is(vR))for(let e of t.value)e.source==r.source&&(r=e);return r}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(UT(e.state))}}class gR extends mR{constructor(e,t,n,r,i,o){super(e,3,t),this.limit=n,this.result=r,this.from=i,this.to=o}hasResult(){return!0}updateFor(e,t){var n;if(!(3&t))return this.map(e.changes);let r=this.result;r.map&&!e.changes.empty&&(r=r.map(r,e.changes));let i=e.changes.mapPos(this.from),o=e.changes.mapPos(this.to,1),s=UT(e.state);if(s>o||!r||2&t&&(UT(e.startState)==this.from||s<this.limit))return new mR(this.source,4&t?1:0);let a=e.changes.mapPos(this.limit);return function(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return"function"==typeof e?e(i,n,r,t):$T(e,!0).test(i)}(r.validFor,e.state,i,o)?new gR(this.source,this.explicit,a,r,i,o):r.update&&(r=r.update(r,i,o,new zT(e.state,s,!1)))?new gR(this.source,this.explicit,a,r,r.from,null!==(n=r.to)&&void 0!==n?n:UT(e.state)):new mR(this.source,1,this.explicit)}map(e){if(e.empty)return this;return(this.result.map?this.result.map(this.result,e):this.result)?new gR(this.source,this.explicit,e.mapPos(this.limit),this.result,e.mapPos(this.from),e.mapPos(this.to,1)):new mR(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}}const vR=$b.define({map:(e,t)=>e.map(e=>e.map(t))}),bR=$b.define(),yR=Sb.define({create:()=>cR.start(),update:(e,t)=>e.update(t),provide:e=>[$E.from(e,e=>e.tooltip),VS.contentAttributes.from(e,e=>e.attrs)]});function wR(e,t){const n=t.completion.apply||t.completion.label;let r=e.state.field(yR).active.find(e=>e.source==t.source);return r instanceof gR&&("string"==typeof n?e.dispatch({...YT(e.state,n,r.from,r.to),annotations:KT.of(t.completion)}):n(e,t.completion,r.from,r.to),!0)}const xR=sR(yR,wR);function kR(e,t="option"){return n=>{let r=n.state.field(yR,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(tR).interactionDelay)return!1;let i,o=1;"page"==t&&(i=ZE(n,r.open.tooltip))&&(o=Math.max(2,Math.floor(i.dom.offsetHeight/i.dom.querySelector("li").offsetHeight)-1));let{length:s}=r.open.options,a=r.open.selected>-1?r.open.selected+o*(e?1:-1):e?0:s-1;return a<0?a="page"==t?0:s-1:a>=s&&(a="page"==t?s-1:0),n.dispatch({effects:bR.of(a)}),!0}}const SR=e=>!!e.state.field(yR,!1)&&(e.dispatch({effects:JT.of(!0)}),!0);class ER{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const CR=vx.fromClass(class{constructor(e){this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let t of e.state.field(yR).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(yR),n=e.state.facet(tR);if(!e.selectionSet&&!e.docChanged&&e.startState.field(yR)==t)return;let r=e.transactions.some(e=>{let t=pR(e,n);return 8&t||(e.selection||e.docChanged)&&!(3&t)});for(let t=0;t<this.running.length;t++){let n=this.running[t];if(r||n.context.abortOnDocChange&&e.docChanged||n.updates.length+e.transactions.length>50&&Date.now()-n.time>1e3){for(let e of n.context.abortListeners)try{e()}catch(e){fx(this.view.state,e)}n.context.abortListeners=null,this.running.splice(t--,1)}else n.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(e=>e.effects.some(e=>e.is(JT)))&&(this.pendingStart=!0);let i=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(e=>e.isPending&&!this.running.some(t=>t.active.source==e.source))?setTimeout(()=>this.startUpdate(),i):-1,0!=this.composing)for(let t of e.transactions)t.isUserEvent("input.type")?this.composing=2:2==this.composing&&t.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(yR);for(let e of t.active)e.isPending&&!this.running.some(t=>t.active.source==e.source)&&this.startQuery(e);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(tR).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=UT(t),r=new zT(t,n,e.explicit,this.view),i=new ER(e,r);this.running.push(i),Promise.resolve(e.source(r)).then(e=>{i.context.aborted||(i.done=e||null,this.scheduleAccept())},e=>{this.view.dispatch({effects:QT.of(null)}),fx(this.view.state,e)})}scheduleAccept(){this.running.every(e=>void 0!==e.done)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(tR).updateSyncTime))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],n=this.view.state.facet(tR),r=this.view.state.field(yR);for(let i=0;i<this.running.length;i++){let o=this.running[i];if(void 0===o.done)continue;if(this.running.splice(i--,1),o.done){let r=UT(o.updates.length?o.updates[0].startState:this.view.state),i=Math.min(r,o.done.from+(o.active.explicit?0:1)),s=new gR(o.active.source,o.active.explicit,i,o.done,o.done.from,null!==(e=o.done.to)&&void 0!==e?e:r);for(let e of o.updates)s=s.update(e,n);if(s.hasResult()){t.push(s);continue}}let s=r.active.find(e=>e.source==o.active.source);if(s&&s.isPending)if(null==o.done){let e=new mR(o.active.source,0);for(let t of o.updates)e=e.update(t,n);e.isPending||t.push(e)}else this.startQuery(s)}(t.length||r.open&&r.open.disabled)&&this.view.dispatch({effects:vR.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(yR,!1);if(t&&t.tooltip&&this.view.state.facet(tR).closeOnBlur){let n=t.open&&ZE(this.view,t.open.tooltip);n&&n.dom.contains(e.relatedTarget)||setTimeout(()=>this.view.dispatch({effects:QT.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){3==this.composing&&setTimeout(()=>this.view.dispatch({effects:JT.of(!1)}),20),this.composing=0}}}),NR="object"==typeof navigator&&/Win/.test(navigator.platform),OR=Mb.highest(VS.domEventHandlers({keydown(e,t){let n=t.state.field(yR,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&(!NR||!e.altKey)||e.metaKey)return!1;let r=n.open.options[n.open.selected],i=n.active.find(e=>e.source==r.source),o=r.completion.commitCharacters||i.result.commitCharacters;return o&&o.indexOf(e.key)>-1&&wR(t,r),!1}})),AR=VS.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}}),MR={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},TR=$b.define({map(e,t){let n=t.mapPos(e,-1,rb.TrackAfter);return null==n?void 0:n}}),RR=new class extends sy{};RR.startSide=1,RR.endSide=-1;const DR=Sb.define({create:()=>hy.empty,update(e,t){if(e=e.map(t.changes),t.selection){let n=t.state.doc.lineAt(t.selection.main.head);e=e.update({filter:e=>e>=n.from&&e<=n.to})}for(let n of t.effects)n.is(TR)&&(e=e.update({add:[RR.range(n.value,n.value+1)]}));return e}});const PR="()[]{}<>«»»«[]{}";function LR(e){for(let t=0;t<16;t+=2)if(PR.charCodeAt(t)==e)return PR.charAt(t+1);return eb(e<128?e:e+1)}function IR(e,t){return e.languageDataAt("closeBrackets",t)[0]||MR}const _R="object"==typeof navigator&&/Android\b/.test(navigator.userAgent),BR=VS.inputHandler.of((e,t,n,r)=>{if((_R?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||2==r.length&&1==tb(Zv(r,0))||t!=i.from||n!=i.to)return!1;let o=function(e,t){let n=IR(e,e.selection.main.head),r=n.brackets||MR.brackets;for(let i of r){let o=LR(Zv(i,0));if(t==i)return o==i?VR(e,i,r.indexOf(i+i+i)>-1,n):zR(e,i,o,n.before||MR.before);if(t==o&&jR(e,e.selection.main.from))return HR(e,i,o)}return null}(e.state,r);return!!o&&(e.dispatch(o),!0)}),FR=[{key:"Backspace",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=IR(e,e.selection.main.head).brackets||MR.brackets,r=null,i=e.changeByRange(t=>{if(t.empty){let r=function(e,t){let n=e.sliceString(t-2,t);return tb(Zv(n,0))==n.length?n:n.slice(1)}(e.doc,t.head);for(let i of n)if(i==r&&WR(e.doc,t.head)==LR(Zv(i,0)))return{changes:{from:t.head-i.length,to:t.head+i.length},range:fb.cursor(t.head-i.length)}}return{range:r=t}});return r||t(e.update(i,{scrollIntoView:!0,userEvent:"delete.backward"})),!r}}];function jR(e,t){let n=!1;return e.field(DR).between(0,e.doc.length,e=>{e==t&&(n=!0)}),n}function WR(e,t){let n=e.sliceString(t,t+2);return n.slice(0,tb(Zv(n,0)))}function zR(e,t,n,r){let i=null,o=e.changeByRange(o=>{if(!o.empty)return{changes:[{insert:t,from:o.from},{insert:n,from:o.to}],effects:TR.of(o.to+t.length),range:fb.range(o.anchor+t.length,o.head+t.length)};let s=WR(e.doc,o.head);return!s||/\s/.test(s)||r.indexOf(s)>-1?{changes:{insert:t+n,from:o.head},effects:TR.of(o.head+t.length),range:fb.cursor(o.head+t.length)}:{range:i=o}});return i?null:e.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function HR(e,t,n){let r=null,i=e.changeByRange(t=>t.empty&&WR(e.doc,t.head)==n?{changes:{from:t.head,to:t.head+n.length,insert:n},range:fb.cursor(t.head+n.length)}:r={range:t});return r?null:e.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function VR(e,t,n,r){let i=r.stringPrefixes||MR.stringPrefixes,o=null,s=e.changeByRange(r=>{if(!r.empty)return{changes:[{insert:t,from:r.from},{insert:t,from:r.to}],effects:TR.of(r.to+t.length),range:fb.range(r.anchor+t.length,r.head+t.length)};let s,a=r.head,l=WR(e.doc,a);if(l==t){if(qR(e,a))return{changes:{insert:t+t,from:a},effects:TR.of(a+t.length),range:fb.cursor(a+t.length)};if(jR(e,a)){let r=n&&e.sliceDoc(a,a+3*t.length)==t+t+t?t+t+t:t;return{changes:{from:a,to:a+r.length,insert:r},range:fb.cursor(a+r.length)}}}else{if(n&&e.sliceDoc(a-2*t.length,a)==t+t&&(s=UR(e,a-2*t.length,i))>-1&&qR(e,s))return{changes:{insert:t+t+t+t,from:a},effects:TR.of(a+t.length),range:fb.cursor(a+t.length)};if(e.charCategorizer(a)(l)!=ey.Word&&UR(e,a,i)>-1&&!function(e,t,n,r){let i=qN(e).resolveInner(t,-1),o=r.reduce((e,t)=>Math.max(e,t.length),0);for(let s=0;s<5;s++){let s=e.sliceDoc(i.from,Math.min(i.to,i.from+n.length+o)),a=s.indexOf(n);if(!a||a>-1&&r.indexOf(s.slice(0,a))>-1){let t=i.firstChild;for(;t&&t.from==i.from&&t.to-t.from>n.length+a;){if(e.sliceDoc(t.to-n.length,t.to)==n)return!1;t=t.firstChild}return!0}let l=i.to==t&&i.parent;if(!l)break;i=l}return!1}(e,a,t,i))return{changes:{insert:t+t,from:a},effects:TR.of(a+t.length),range:fb.cursor(a+t.length)}}return{range:o=r}});return o?null:e.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function qR(e,t){let n=qN(e).resolveInner(t+1);return n.parent&&n.from==t}function UR(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=ey.Word)return t;for(let i of n){let n=t-i.length;if(e.sliceDoc(n,t)==i&&r(e.sliceDoc(n-1,n))!=ey.Word)return n}return-1}const $R=[{key:"Ctrl-Space",run:SR},{mac:"Alt-`",run:SR},{mac:"Alt-i",run:SR},{key:"Escape",run:e=>{let t=e.state.field(yR,!1);return!(!t||!t.active.some(e=>0!=e.state))&&(e.dispatch({effects:QT.of(null)}),!0)}},{key:"ArrowDown",run:kR(!0)},{key:"ArrowUp",run:kR(!1)},{key:"PageDown",run:kR(!0,"page")},{key:"PageUp",run:kR(!1,"page")},{key:"Enter",run:e=>{let t=e.state.field(yR,!1);return!(e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(tR).interactionDelay)&&wR(e,t.open.options[t.open.selected])}}],KR=Mb.highest(JS.computeN([tR],e=>e.facet(tR).defaultKeymap?[$R]:[]));class YR{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}}class GR{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(e,t,n){let r=n.facet(aD).markerFilter;r&&(e=r(e,n));let i=e.slice().sort((e,t)=>e.from-t.from||e.to-t.to),o=new dy,s=[],a=0,l=n.doc.iter(),c=0,u=n.doc.length;for(let e=0;;){let t,n,r=e==i.length?null:i[e];if(!r&&!s.length)break;if(s.length)t=a,n=s.reduce((e,t)=>Math.min(e,t.to),r&&r.from>t?r.from:1e8);else{if(t=r.from,t>u)break;n=r.to,s.push(r),e++}for(;e<i.length;){let r=i[e];if(r.from!=t||!(r.to>r.from||r.to==t)){n=Math.min(r.from,n);break}s.push(r),e++,n=Math.min(r.to,n)}n=Math.min(n,u);let h=!1;if(s.some(e=>e.from==t&&(e.to==n||n==u))&&(h=t==n,!h&&n-t<10)){let e=t-(c+l.value.length);e>0&&(l.next(e),c=t);for(let e=t;;){if(e>=n){h=!0;break}if(!l.lineBreak&&c+l.value.length>e)break;e=c+l.value.length,c+=l.value.length,l.next()}}let d=vD(s);if(h)o.add(t,t,iw.widget({widget:new hD(d),diagnostics:s.slice()}));else{let e=s.reduce((e,t)=>t.markClass?e+" "+t.markClass:e,"");o.add(t,n,iw.mark({class:"cm-lintRange cm-lintRange-"+d+e,diagnostics:s.slice(),inclusiveEnd:s.some(e=>e.to>n)}))}if(a=n,a==u)break;for(let e=0;e<s.length;e++)s[e].to<=a&&s.splice(e--,1)}let h=o.finish();return new GR(h,t,XR(h))}}function XR(e,t=null,n=0){let r=null;return e.between(n,1e9,(e,n,{spec:i})=>{if(!(t&&i.diagnostics.indexOf(t)<0))if(r){if(i.diagnostics.indexOf(r.diagnostic)<0)return!1;r=new YR(r.from,n,r.diagnostic)}else r=new YR(e,n,t||i.diagnostics[0])}),r}function JR(e,t){return e.field(tD,!1)?t:t.concat($b.appendConfig.of(bD))}const QR=$b.define(),ZR=$b.define(),eD=$b.define(),tD=Sb.define({create:()=>new GR(iw.none,null,null),update(e,t){if(t.docChanged&&e.diagnostics.size){let n=e.diagnostics.map(t.changes),r=null,i=e.panel;if(e.selected){let i=t.changes.mapPos(e.selected.from,1);r=XR(n,e.selected.diagnostic,i)||XR(n,null,i)}!n.size&&i&&t.state.facet(aD).autoPanel&&(i=null),e=new GR(n,i,r)}for(let n of t.effects)if(n.is(QR)){let r=t.state.facet(aD).autoPanel?n.value.length?fD.open:null:e.panel;e=GR.init(n.value,r,t.state)}else n.is(ZR)?e=new GR(e.diagnostics,n.value?fD.open:null,e.selected):n.is(eD)&&(e=new GR(e.diagnostics,e.panel,n.value));return e},provide:e=>[sC.from(e,e=>e.panel),VS.decorations.from(e,e=>e.diagnostics)]}),nD=iw.mark({class:"cm-lintRange cm-lintRange-active"});function rD(e,t,n){let r,{diagnostics:i}=e.state.field(tD),o=-1,s=-1;i.between(t-(n<0?1:0),t+(n>0?1:0),(e,i,{spec:a})=>{if(t>=e&&t<=i&&(e==i||(t>e||n>0)&&(t<i||n<0)))return r=a.diagnostics,o=e,s=i,!1});let a=e.state.facet(aD).tooltipFilter;return r&&a&&(r=a(r,e.state)),r?{pos:o,end:s,above:e.state.doc.lineAt(o).to<s,create:()=>({dom:iD(e,r)})}:null}function iD(e,t){return By("ul",{class:"cm-tooltip-lint"},t.map(t=>uD(e,t,!1)))}const oD=e=>{let t=e.state.field(tD,!1);return!(!t||!t.panel)&&(e.dispatch({effects:ZR.of(!1)}),!0)},sD=[{key:"Mod-Shift-m",run:e=>{let t=e.state.field(tD,!1);t&&t.panel||e.dispatch({effects:JR(e.state,[ZR.of(!0)])});let n=nC(e,fD.open);return n&&n.dom.querySelector(".cm-panel-lint ul").focus(),!0},preventDefault:!0},{key:"F8",run:e=>{let t=e.state.field(tD,!1);if(!t)return!1;let n=e.state.selection.main,r=t.diagnostics.iter(n.to+1);return!(!r.value&&(r=t.diagnostics.iter(0),!r.value||r.from==n.from&&r.to==n.to))&&(e.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),!0)}}],aD=gb.define({combine:e=>({sources:e.map(e=>e.source).filter(e=>null!=e),...oy(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:lD,tooltipFilter:lD,needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t,hideOn:(e,t)=>e?t?(n,r,i)=>e(n,r,i)||t(n,r,i):e:t,autoPanel:(e,t)=>e||t})})});function lD(e,t){return e?t?(n,r)=>t(e(n,r),r):e:t}function cD(e){let t=[];if(e)e:for(let{name:n}of e){for(let e=0;e<n.length;e++){let r=n[e];if(/[a-zA-Z]/.test(r)&&!t.some(e=>e.toLowerCase()==r.toLowerCase())){t.push(r);continue e}}t.push("")}return t}function uD(e,t,n){var r;let i=n?cD(t.actions):[];return By("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},By("span",{class:"cm-diagnosticText"},t.renderMessage?t.renderMessage(e):t.message),null===(r=t.actions)||void 0===r?void 0:r.map((n,r)=>{let o=!1,s=r=>{if(r.preventDefault(),o)return;o=!0;let i=XR(e.state.field(tD).diagnostics,t);i&&n.apply(e,i.from,i.to)},{name:a}=n,l=i[r]?a.indexOf(i[r]):-1,c=l<0?a:[a.slice(0,l),By("u",a.slice(l,l+1)),a.slice(l+1)];return By("button",{type:"button",class:"cm-diagnosticAction"+(n.markClass?" "+n.markClass:""),onclick:s,onmousedown:s,"aria-label":` Action: ${a}${l<0?"":` (access key "${i[r]})"`}.`},c)}),t.source&&By("div",{class:"cm-diagnosticSource"},t.source))}class hD extends nw{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return By("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class dD{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(4294967295*Math.random()).toString(16),this.dom=uD(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class fD{constructor(e){this.view=e,this.items=[];this.list=By("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t=>{if(27==t.keyCode)oD(this.view),this.view.focus();else if(38==t.keyCode||33==t.keyCode)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(40==t.keyCode||34==t.keyCode)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(36==t.keyCode)this.moveSelection(0);else if(35==t.keyCode)this.moveSelection(this.items.length-1);else if(13==t.keyCode)this.view.focus();else{if(!(t.keyCode>=65&&t.keyCode<=90&&this.selectedIndex>=0))return;{let{diagnostic:n}=this.items[this.selectedIndex],r=cD(n.actions);for(let i=0;i<r.length;i++)if(r[i].toUpperCase().charCodeAt(0)==t.keyCode){let t=XR(this.view.state.field(tD).diagnostics,n);t&&n.actions[i].apply(e,t.from,t.to)}}}t.preventDefault()},onclick:e=>{for(let t=0;t<this.items.length;t++)this.items[t].dom.contains(e.target)&&this.moveSelection(t)}}),this.dom=By("div",{class:"cm-panel-lint"},this.list,By("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>oD(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(tD).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(tD),n=0,r=!1,i=null,o=new Set;for(e.between(0,this.view.state.doc.length,(e,s,{spec:a})=>{for(let e of a.diagnostics){if(o.has(e))continue;o.add(e);let s,a=-1;for(let t=n;t<this.items.length;t++)if(this.items[t].diagnostic==e){a=t;break}a<0?(s=new dD(this.view,e),this.items.splice(n,0,s),r=!0):(s=this.items[a],a>n&&(this.items.splice(n,a-n),r=!0)),t&&s.diagnostic==t.diagnostic?s.dom.hasAttribute("aria-selected")||(s.dom.setAttribute("aria-selected","true"),i=s):s.dom.hasAttribute("aria-selected")&&s.dom.removeAttribute("aria-selected"),n++}});n<this.items.length&&!(1==this.items.length&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();0==this.items.length&&(this.items.push(new dD(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),r=!0),i?(this.list.setAttribute("aria-activedescendant",i.id),this.view.requestMeasure({key:this,read:()=>({sel:i.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{let n=t.height/this.list.offsetHeight;e.top<t.top?this.list.scrollTop-=(t.top-e.top)/n:e.bottom>t.bottom&&(this.list.scrollTop+=(e.bottom-t.bottom)/n)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling,t.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=XR(this.view.state.field(tD).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:eD.of(t)})}static open(e){return new fD(e)}}function pD(e){return function(e,t='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const mD=VS.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:pD("#d11")},".cm-lintRange-warning":{backgroundImage:pD("orange")},".cm-lintRange-info":{backgroundImage:pD("#999")},".cm-lintRange-hint":{backgroundImage:pD("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}});function gD(e){return"error"==e?4:"warning"==e?3:"info"==e?2:1}function vD(e){let t="hint",n=1;for(let r of e){let e=gD(r.severity);e>n&&(n=e,t=r.severity)}return t}const bD=[tD,VS.decorations.compute([tD],e=>{let{selected:t,panel:n}=e.field(tD);return t&&n&&t.from!=t.to?iw.set([nD.range(t.from,t.to)]):iw.none}),QE(rD,{hideOn:function(e,t){let n=t.pos,r=t.end||n,i=e.state.facet(aD).hideOn(e,n,r);if(null!=i)return i;let o=e.startState.doc.lineAt(t.pos);return!(!e.effects.some(e=>e.is(QR))&&!e.changes.touchesRange(o.from,Math.max(o.to,r)))}}),mD];var yD=function(e){void 0===e&&(e={});var{crosshairCursor:t=!1}=e,n=[];!1!==e.closeBracketsKeymap&&(n=n.concat(FR)),!1!==e.defaultKeymap&&(n=n.concat(zM)),!1!==e.searchKeymap&&(n=n.concat(PT)),!1!==e.historyKeymap&&(n=n.concat(zA)),!1!==e.foldKeymap&&(n=n.concat(AO)),!1!==e.completionKeymap&&(n=n.concat($R)),!1!==e.lintKeymap&&(n=n.concat(sD));var r=[];return!1!==e.lineNumbers&&r.push(function(e={}){return[OC.of(e),bC(),TC]}()),!1!==e.highlightActiveLineGutter&&r.push(PC),!1!==e.highlightSpecialChars&&r.push(function(e={}){return[CE.of(e),NE||(NE=vx.fromClass(class{constructor(e){this.view=e,this.decorations=iw.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(e.state.facet(CE)),this.decorations=this.decorator.createDeco(e)}makeDecorator(e){return new wE({regexp:e.specialChars,decoration:(t,n,r)=>{let{doc:i}=n.state,o=Zv(t[0],0);if(9==o){let e=i.lineAt(r),t=n.state.tabSize,o=Sy(e.text,t,r-e.from);return iw.replace({widget:new AE((t-o%t)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[o]||(this.decorationCache[o]=iw.replace({widget:new OE(e,o)}))},boundary:e.replaceTabs?void 0:/[^]/})}update(e){let t=e.state.facet(CE);e.startState.facet(CE)!=t?(this.decorator=this.makeDecorator(t),this.decorations=this.decorator.createDeco(e.view)):this.decorations=this.decorator.updateDeco(e,this.decorations)}},{decorations:e=>e.decorations}))]}()),!1!==e.history&&r.push(function(e={}){return[EA,SA.of(e),VS.domEventHandlers({beforeinput(e,t){let n="historyUndo"==e.inputType?NA:"historyRedo"==e.inputType?OA:null;return!!n&&(e.preventDefault(),n(t))}})]}()),!1!==e.foldGutter&&r.push(function(e={}){let t={...IO,...e},n=new _O(t,!0),r=new _O(t,!1),i=vx.fromClass(class{constructor(e){this.from=e.viewport.from,this.markers=this.buildMarkers(e)}update(e){(e.docChanged||e.viewportChanged||e.startState.facet(ZN)!=e.state.facet(ZN)||e.startState.field(kO,!1)!=e.state.field(kO,!1)||qN(e.startState)!=qN(e.state)||t.foldingChanged(e))&&(this.markers=this.buildMarkers(e.view))}buildMarkers(e){let t=new dy;for(let i of e.viewportLineBlocks){let o=EO(e.state,i.from,i.to)?r:vO(e.state,i.from,i.to)?n:null;o&&t.add(i.from,i.from,o)}return t.finish()}}),{domEventHandlers:o}=t;return[i,gC({class:"cm-foldGutter",markers(e){var t;return(null===(t=e.plugin(i))||void 0===t?void 0:t.markers)||hy.empty},initialSpacer:()=>new _O(t,!1),domEventHandlers:{...o,click:(e,t,n)=>{if(o.click&&o.click(e,t,n))return!0;let r=EO(e.state,t.from,t.to);if(r)return e.dispatch({effects:wO.of(r)}),!0;let i=vO(e.state,t.from,t.to);return!!i&&(e.dispatch({effects:yO.of(i)}),!0)}}}),RO()]}()),!1!==e.drawSelection&&r.push(function(e={}){return[uE.of(e),dE,pE,mE,lx.of(!0)]}()),!1!==e.dropCursor&&r.push([vE,bE]),!1!==e.allowMultipleSelections&&r.push(iy.allowMultipleSelections.of(!0)),!1!==e.indentOnInput&&r.push(iy.transactionFilter.of(e=>{if(!e.docChanged||!e.isUserEvent("input.type")&&!e.isUserEvent("input.complete"))return e;let t=e.startState.languageDataAt("indentOnInput",e.startState.selection.main.head);if(!t.length)return e;let n=e.newDoc,{head:r}=e.newSelection.main,i=n.lineAt(r);if(r>i.from+200)return e;let o=n.sliceString(i.from,r);if(!t.some(e=>e.test(o)))return e;let{state:s}=e,a=-1,l=[];for(let{head:e}of s.selection.ranges){let t=s.doc.lineAt(e);if(t.from==a)continue;a=t.from;let n=oO(s,t.from);if(null==n)continue;let r=/^\s*/.exec(t.text)[0],i=iO(s,n);r!=i&&l.push({from:t.from,to:t.from+r.length,insert:i})}return l.length?[e,{changes:l,sequential:!0}]:e})),!1!==e.syntaxHighlighting&&r.push(HO(UO,{fallback:!0})),!1!==e.bracketMatching&&r.push(function(e={}){return[YO.of(e),ZO]}()),!1!==e.closeBrackets&&r.push([BR,DR]),!1!==e.autocompletion&&r.push(function(e={}){return[OR,yR,tR.of(e),CR,KR,AR]}()),!1!==e.rectangularSelection&&r.push(function(e){let t=(null==e?void 0:e.eventFilter)||(e=>e.altKey&&0==e.button);return VS.mouseSelectionStyle.of((e,n)=>t(n)?LE(e,n):null)}()),!1!==t&&r.push(function(e={}){let[t,n]=IE[e.key||"Alt"],r=vx.fromClass(class{constructor(e){this.view=e,this.isDown=!1}set(e){this.isDown!=e&&(this.isDown=e,this.view.update([]))}},{eventObservers:{keydown(e){this.set(e.keyCode==t||n(e))},keyup(e){e.keyCode!=t&&n(e)||this.set(!1)},mousemove(e){this.set(n(e))}}});return[r,VS.contentAttributes.of(e=>{var t;return(null===(t=e.plugin(r))||void 0===t?void 0:t.isDown)?_E:null})]}()),!1!==e.highlightActiveLine&&r.push(TE),!1!==e.highlightSelectionMatches&&r.push(function(e){let t=[iT,rT];return e&&t.push(ZM.of(e)),t}()),e.tabSize&&"number"==typeof e.tabSize&&r.push(nO.of(" ".repeat(e.tabSize))),r.concat([JS.of(n.flat())]).filter(Boolean)};const wD="#e06c75",xD="#abb2bf",kD="#7d8799",SD="#d19a66",ED="#2c313a",CD="#282c34",ND="#353a42",OD="#528bff",AD=[VS.theme({"&":{color:xD,backgroundColor:CD},".cm-content":{caretColor:OD},".cm-cursor, .cm-dropCursor":{borderLeftColor:OD},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:"#3E4451"},".cm-panels":{backgroundColor:"#21252b",color:xD},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:CD,color:kD,border:"none"},".cm-activeLineGutter":{backgroundColor:ED},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:ND},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:ND,borderBottomColor:ND},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:ED,color:xD}}},{dark:!0}),HO(FO.define([{tag:BN.keyword,color:"#c678dd"},{tag:[BN.name,BN.deleted,BN.character,BN.propertyName,BN.macroName],color:wD},{tag:[BN.function(BN.variableName),BN.labelName],color:"#61afef"},{tag:[BN.color,BN.constant(BN.name),BN.standard(BN.name)],color:SD},{tag:[BN.definition(BN.name),BN.separator],color:xD},{tag:[BN.typeName,BN.className,BN.number,BN.changed,BN.annotation,BN.modifier,BN.self,BN.namespace],color:"#e5c07b"},{tag:[BN.operator,BN.operatorKeyword,BN.url,BN.escape,BN.regexp,BN.link,BN.special(BN.string)],color:"#56b6c2"},{tag:[BN.meta,BN.comment],color:kD},{tag:BN.strong,fontWeight:"bold"},{tag:BN.emphasis,fontStyle:"italic"},{tag:BN.strikethrough,textDecoration:"line-through"},{tag:BN.link,color:kD,textDecoration:"underline"},{tag:BN.heading,fontWeight:"bold",color:wD},{tag:[BN.atom,BN.bool,BN.special(BN.variableName)],color:SD},{tag:[BN.processingInstruction,BN.string,BN.inserted],color:"#98c379"},{tag:BN.invalid,color:"#ffffff"}]))];var MD=VS.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),TD=function(e){void 0===e&&(e={});var{indentWithTab:t=!0,editable:n=!0,readOnly:r=!1,theme:i="light",placeholder:o="",basicSetup:s=!0}=e,a=[];switch(t&&a.unshift(JS.of([HM])),s&&("boolean"==typeof s?a.unshift(yD()):a.unshift(yD(s))),o&&a.unshift(function(e){let t=vx.fromClass(class{constructor(t){this.view=t,this.placeholder=e?iw.set([iw.widget({widget:new RE(e),side:1}).range(0)]):iw.none}get decorations(){return this.view.state.doc.length?iw.none:this.placeholder}},{decorations:e=>e.decorations});return"string"==typeof e?[t,VS.contentAttributes.of({"aria-placeholder":e})]:t}(o)),i){case"light":a.push(MD);break;case"dark":a.push(AD);break;case"none":break;default:a.push(i)}return!1===n&&a.push(VS.editable.of(!1)),r&&a.push(iy.readOnly.of(!0)),[...a]};class RD{constructor(e,t){this.timeLeftMS=void 0,this.timeoutMS=void 0,this.isCancelled=!1,this.isTimeExhausted=!1,this.callbacks=[],this.timeLeftMS=t,this.timeoutMS=t,this.callbacks.push(e)}tick(){if(!this.isCancelled&&!this.isTimeExhausted&&(this.timeLeftMS--,this.timeLeftMS<=0)){this.isTimeExhausted=!0;var e=this.callbacks.slice();this.callbacks.length=0,e.forEach(e=>{try{e()}catch(e){}})}}cancel(){this.isCancelled=!0,this.callbacks.length=0}reset(){this.timeLeftMS=this.timeoutMS,this.isCancelled=!1,this.isTimeExhausted=!1}get isDone(){return this.isCancelled||this.isTimeExhausted}}class DD{constructor(){this.interval=null,this.latches=new Set}add(e){this.latches.add(e),this.start()}remove(e){this.latches.delete(e),0===this.latches.size&&this.stop()}start(){null===this.interval&&(this.interval=setInterval(()=>{this.latches.forEach(e=>{e.tick(),e.isDone&&this.remove(e)})},1))}stop(){null!==this.interval&&(clearInterval(this.interval),this.interval=null)}}var PD=null,LD=Vb.define(),ID=[];function _D(e){var{value:t,selection:n,onChange:r,onStatistics:s,onCreateEditor:l,onUpdate:c,extensions:u=ID,autoFocus:h,theme:d="light",height:f=null,minHeight:p=null,maxHeight:m=null,width:g=null,minWidth:v=null,maxWidth:b=null,placeholder:y="",editable:w=!0,readOnly:x=!1,indentWithTab:k=!0,basicSetup:S=!0,root:E,initialState:C}=e,[N,O]=i(),[A,M]=i(),[T,R]=i(),D=i(()=>({current:null}))[0],P=i(()=>({current:null}))[0],L=VS.theme({"&":{height:f,minHeight:p,maxHeight:m,width:g,minWidth:v,maxWidth:b},"& .cm-scroller":{height:"100% !important"}}),I=VS.updateListener.of(e=>{if(e.docChanged&&"function"==typeof r&&!e.transactions.some(e=>e.annotation(LD))){D.current?D.current.reset():(D.current=new RD(()=>{if(P.current){var e=P.current;P.current=null,e()}D.current=null},200),("undefined"==typeof window?new DD:(PD||(PD=new DD),PD)).add(D.current));var t=e.state.doc.toString();r(t,e)}s&&s((e=>({line:e.state.doc.lineAt(e.state.selection.main.from),lineCount:e.state.doc.lines,lineBreak:e.state.lineBreak,length:e.state.doc.length,readOnly:e.state.readOnly,tabSize:e.state.tabSize,selection:e.state.selection,selectionAsSingle:e.state.selection.asSingle().main,ranges:e.state.selection.ranges,selectionCode:e.state.sliceDoc(e.state.selection.main.from,e.state.selection.main.to),selections:e.state.selection.ranges.map(t=>e.state.sliceDoc(t.from,t.to)),selectedText:e.state.selection.ranges.some(e=>!e.empty)}))(e))}),_=[I,L,...TD({theme:d,editable:w,readOnly:x,placeholder:y,indentWithTab:k,basicSetup:S})];return c&&"function"==typeof c&&_.push(VS.updateListener.of(c)),_=_.concat(u),o(()=>{if(N&&!T){var e={doc:t,selection:n,extensions:_},r=C?iy.fromJSON(C.json,e,C.fields):iy.create(e);if(R(r),!A){var i=new VS({state:r,parent:N,root:E});M(i),l&&l(i,r)}}return()=>{A&&(R(void 0),M(void 0))}},[N,T]),a(()=>{e.container&&O(e.container)},[e.container]),a(()=>()=>{A&&(A.destroy(),M(void 0)),D.current&&(D.current.cancel(),D.current=null)},[A]),a(()=>{h&&A&&A.focus()},[h,A]),a(()=>{A&&A.dispatch({effects:$b.reconfigure.of(_)})},[d,u,f,p,m,g,v,b,y,w,x,k,S,r,c]),a(()=>{if(void 0!==t){var e=A?A.state.doc.toString():"";if(A&&t!==e){var n=()=>{A&&t!==A.state.doc.toString()&&A.dispatch({changes:{from:0,to:A.state.doc.toString().length,insert:t||""},annotations:[LD.of(!0)]})};D.current&&!D.current.isDone?P.current=n:n()}}},[t,A]),{state:T,setState:R,view:A,setView:M,container:N,setContainer:O}}var BD=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],FD=n((e,t)=>{var{className:n,value:r="",selection:i,extensions:o=[],onChange:s,onStatistics:a,onCreateEditor:l,onUpdate:c,autoFocus:p,theme:m="light",height:g,minHeight:v,maxHeight:b,width:y,minWidth:w,maxWidth:x,basicSetup:k,placeholder:S,indentWithTab:E,editable:C,readOnly:N,root:O,initialState:A}=e,M=function(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,BD),T=u(null),{state:R,view:D,container:P,setContainer:L}=_D({root:O,value:r,autoFocus:p,theme:m,height:g,minHeight:v,maxHeight:b,width:y,minWidth:w,maxWidth:x,basicSetup:k,placeholder:S,indentWithTab:E,editable:C,readOnly:N,selection:i,onChange:s,onStatistics:a,onCreateEditor:l,onUpdate:c,extensions:o,initialState:A});h(t,()=>({editor:T.current,state:R,view:D}),[T,P,R,D]);var I=d(e=>{T.current=e,L(e)},[L]);if("string"!=typeof r)throw new Error("value must be typeof string but got "+typeof r);return f("div",Tv({ref:I,className:("string"==typeof m?"cm-theme-"+m:"cm-theme")+(n?" "+n:"")},M))});FD.displayName="CodeMirror";class jD{constructor(e,t,n,r,i,o,s,a,l,c=0,u){this.p=e,this.stack=t,this.state=n,this.reducePos=r,this.pos=i,this.score=o,this.buffer=s,this.bufferBase=a,this.curContext=l,this.lookAhead=c,this.parent=u}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,n=0){let r=e.parser.context;return new jD(e,[],t,n,n,0,[],0,r?new WD(r,r.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var t;let n=e>>19,r=65535&e,{parser:i}=this.p,o=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),s=i.dynamicPrecedence(r);if(s&&(this.score+=s),0==n)return this.pushState(i.getGoto(this.state,r,!0),this.reducePos),r<i.minRepeatTerm&&this.storeNode(r,this.reducePos,this.reducePos,o?8:4,!0),void this.reduceContext(r,this.reducePos);let a=this.stack.length-3*(n-1)-(262144&e?6:0),l=a?this.stack[a-2]:this.p.ranges[0].from,c=this.reducePos-l;c>=2e3&&!(null===(t=this.p.parser.nodeSet.types[r])||void 0===t?void 0:t.isAnonymous)&&(l==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSize<c&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=l,this.p.lastBigReductionSize=c));let u=a?this.stack[a-1]:0,h=this.bufferBase+this.buffer.length-u;if(r<i.minRepeatTerm||131072&e){let e=i.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(r,l,e,h+4,!0)}if(262144&e)this.state=this.stack[a];else{let e=this.stack[a-3];this.state=i.getGoto(e,r,!0)}for(;this.stack.length>a;)this.stack.pop();this.reduceContext(r,l)}storeNode(e,t,n,r=4,i=!1){if(0==e&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let e=this,r=this.buffer.length;if(0==r&&e.parent&&(r=e.bufferBase-e.parent.bufferBase,e=e.parent),r>0&&0==e.buffer[r-4]&&e.buffer[r-1]>-1){if(t==n)return;if(e.buffer[r-2]>=t)return void(e.buffer[r-2]=n)}}if(i&&this.pos!=n){let i=this.buffer.length;if(i>0&&(0!=this.buffer[i-4]||this.buffer[i-1]<0)){let e=!1;for(let t=i;t>0&&this.buffer[t-2]>n;t-=4)if(this.buffer[t-1]>=0){e=!0;break}if(e)for(;i>0&&this.buffer[i-2]>n;)this.buffer[i]=this.buffer[i-4],this.buffer[i+1]=this.buffer[i-3],this.buffer[i+2]=this.buffer[i-2],this.buffer[i+3]=this.buffer[i-1],i-=4,r>4&&(r-=4)}this.buffer[i]=e,this.buffer[i+1]=t,this.buffer[i+2]=n,this.buffer[i+3]=r}else this.buffer.push(e,t,n,r)}shift(e,t,n,r){if(131072&e)this.pushState(65535&e,this.pos);else if(262144&e)this.pos=r,this.shiftContext(t,n),t<=this.p.parser.maxNode&&this.buffer.push(t,n,r,4);else{let i=e,{parser:o}=this.p;this.pos=r;let s=o.stateFlag(i,1);!s&&(r>n||t<=o.maxNode)&&(this.reducePos=r),this.pushState(i,s?n:Math.min(n,this.reducePos)),this.shiftContext(t,n),t<=o.maxNode&&this.buffer.push(t,n,r,4)}}apply(e,t,n,r){65536&e?this.reduce(e):this.shift(e,t,n,r)}useNode(e,t){let n=this.p.reused.length-1;(n<0||this.p.reused[n]!=e)&&(this.p.reused.push(e),n++);let r=this.pos;this.reducePos=this.pos=r+e.length,this.pushState(t,r),this.buffer.push(n,r,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(;t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let n=e.buffer.slice(t),r=e.bufferBase+t;for(;e&&r==e.bufferBase;)e=e.parent;return new jD(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,n,r,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let n=e<=this.p.parser.maxNode;n&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,n?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new zD(this);;){let n=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(0==n)return!1;if(!(65536&n))return!0;t.reduce(n)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let n=[];for(let r,i=0;i<t.length;i+=2)(r=t[i+1])!=this.state&&this.p.parser.hasAction(r,e)&&n.push(t[i],r);if(this.stack.length<120)for(let e=0;n.length<8&&e<t.length;e+=2){let r=t[e+1];n.some((e,t)=>1&t&&e==r)||n.push(t[e],r)}t=n}let n=[];for(let e=0;e<t.length&&n.length<4;e+=2){let r=t[e+1];if(r==this.state)continue;let i=this.split();i.pushState(r,this.pos),i.storeNode(0,i.pos,i.pos,4,!0),i.shiftContext(t[e],this.pos),i.reducePos=this.pos,i.score-=200,n.push(i)}return n}forceReduce(){let{parser:e}=this.p,t=e.stateSlot(this.state,5);if(!(65536&t))return!1;if(!e.validAction(this.state,t)){let n=t>>19,r=65535&t,i=this.stack.length-3*n;if(i<0||e.getGoto(this.stack[i],r,!1)<0){let e=this.findForcedReduction();if(null==e)return!1;t=e}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],n=(r,i)=>{if(!t.includes(r))return t.push(r),e.allActions(r,t=>{if(393216&t);else if(65536&t){let n=(t>>19)-i;if(n>1){let r=65535&t,i=this.stack.length-3*n;if(i>=0&&e.getGoto(this.stack[i],r,!1)>=0)return n<<19|65536|r}}else{let e=n(t,i+1);if(null!=e)return e}})};return n(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(3!=this.stack.length)return!1;let{parser:e}=this.p;return 65535==e.data[e.stateSlot(this.state,1)]&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t<this.stack.length;t+=3)if(this.stack[t]!=e.stack[t])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(t)))}reduceContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(t)))}emitContext(){let e=this.buffer.length-1;(e<0||-3!=this.buffer[e])&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||-4!=this.buffer[e])&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let t=new WD(this.curContext.tracker,e);t.hash!=this.curContext.hash&&this.emitContext(),this.curContext=t}}setLookAhead(e){return!(e<=this.lookAhead)&&(this.emitLookAhead(),this.lookAhead=e,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class WD{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}class zD{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=65535&e,n=e>>19;0==n?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=3*(n-1);let r=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=r}}class HD{constructor(e,t,n){this.stack=e,this.pos=t,this.index=n,this.buffer=e.buffer,0==this.index&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new HD(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;null!=e&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,0==this.index&&this.maybeNext()}fork(){return new HD(this.stack,this.pos,this.index)}}function VD(e,t=Uint16Array){if("string"!=typeof e)return e;let n=null;for(let r=0,i=0;r<e.length;){let o=0;for(;;){let t=e.charCodeAt(r++),n=!1;if(126==t){o=65535;break}t>=92&&t--,t>=34&&t--;let i=t-32;if(i>=46&&(i-=46,n=!0),o+=i,n)break;o*=46}n?n[i++]=o:n=new t(o)}return n}class qD{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const UD=new qD;class $D{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=UD,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let n=this.range,r=this.rangeIndex,i=this.pos+e;for(;i<n.from;){if(!r)return null;let e=this.ranges[--r];i-=n.from-e.to,n=e}for(;t<0?i>n.to:i>=n.to;){if(r==this.ranges.length-1)return null;let e=this.ranges[++r];i+=e.from-n.to,n=e}return i}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let t of this.ranges)if(t.to>e)return Math.max(e,t.from);return this.end}peek(e){let t,n,r=this.chunkOff+e;if(r>=0&&r<this.chunk.length)t=this.pos+e,n=this.chunk.charCodeAt(r);else{let r=this.resolveOffset(e,1);if(null==r)return-1;if(t=r,t>=this.chunk2Pos&&t<this.chunk2Pos+this.chunk2.length)n=this.chunk2.charCodeAt(t-this.chunk2Pos);else{let e=this.rangeIndex,r=this.range;for(;r.to<=t;)r=this.ranges[++e];this.chunk2=this.input.chunk(this.chunk2Pos=t),t+this.chunk2.length>r.to&&(this.chunk2=this.chunk2.slice(0,r.to-t)),n=this.chunk2.charCodeAt(0)}}return t>=this.token.lookAhead&&(this.token.lookAhead=t+1),n}acceptToken(e,t=0){let n=t?this.resolveOffset(t,-1):this.pos;if(null==n||n<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=n}acceptTokenTo(e,t){this.token.value=e,this.token.end=t}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:t}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=t,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),t=this.pos+e.length;this.chunk=t>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=UD,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(e,t){if(e>=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let n="";for(let r of this.ranges){if(r.from>=t)break;r.to>e&&(n+=this.input.read(Math.max(r.from,e),Math.min(r.to,t)))}return n}}class KD{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:n}=t.p;!function(e,t,n,r,i,o){let s=0,a=1<<r,{dialect:l}=n.p.parser;e:for(;0!=(a&e[s]);){let n=e[s+1];for(let r=s+3;r<n;r+=2)if((e[r+1]&a)>0){let n=e[r];if(l.allows(n)&&(-1==t.token.value||t.token.value==n||GD(n,t.token.value,i,o))){t.acceptToken(n);break}}let r=t.next,c=0,u=e[s+2];if(!(t.next<0&&u>c&&65535==e[n+3*u-3])){for(;c<u;){let i=c+u>>1,o=n+i+(i<<1),a=e[o],l=e[o+1]||65536;if(r<a)u=i;else{if(!(r>=l)){s=e[o+2],t.advance();continue e}c=i+1}}break}s=e[n+3*u-1]}}(this.data,e,t,this.id,n.data,n.tokenPrecTable)}}function YD(e,t,n){for(let r,i=t;65535!=(r=e[i]);i++)if(r==n)return i-t;return-1}function GD(e,t,n,r){let i=YD(n,r,t);return i<0||YD(n,r,e)<i}KD.prototype.contextual=KD.prototype.fallback=KD.prototype.extend=!1,KD.prototype.fallback=KD.prototype.extend=!1;const XD="undefined"!=typeof process&&process.env&&/\bparse\b/.test(process.env.LOG);let JD=null;function QD(e,t,n){let r=e.cursor(qC.IncludeAnonymous);for(r.moveTo(t);;)if(!(n<0?r.childBefore(t):r.childAfter(t)))for(;;){if((n<0?r.to<t:r.from>t)&&!r.type.isError)return n<0?Math.max(0,Math.min(r.to-1,t-25)):Math.min(e.length,Math.max(r.from+1,t+25));if(n<0?r.prevSibling():r.nextSibling())break;if(!r.parent())return n<0?0:e.length}}class ZD{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?QD(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?QD(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let t=this.trees.length-1;if(t<0)return this.nextFragment(),null;let n=this.trees[t],r=this.index[t];if(r==n.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let i=n.children[r],o=this.start[t]+n.positions[r];if(o>e)return this.nextStart=o,null;if(i instanceof UC){if(o==e){if(o<this.safeFrom)return null;let e=o+i.length;if(e<=this.safeTo){let t=i.prop(BC.lookAhead);if(!t||e+t<this.fragment.to)return i}}this.index[t]++,o+i.length>=Math.max(this.safeFrom,e)&&(this.trees.push(i),this.start.push(o),this.index.push(0))}else this.index[t]++,this.nextStart=o+i.length}}}class eP{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(e=>new qD)}getActions(e){let t=0,n=null,{parser:r}=e.p,{tokenizers:i}=r,o=r.stateSlot(e.state,3),s=e.curContext?e.curContext.hash:0,a=0;for(let r=0;r<i.length;r++){if(!(1<<r&o))continue;let l=i[r],c=this.tokens[r];if((!n||l.fallback)&&((l.contextual||c.start!=e.pos||c.mask!=o||c.context!=s)&&(this.updateCachedToken(c,l,e),c.mask=o,c.context=s),c.lookAhead>c.end+25&&(a=Math.max(c.lookAhead,a)),0!=c.value)){let r=t;if(c.extended>-1&&(t=this.addActions(e,c.extended,c.end,t)),t=this.addActions(e,c.value,c.end,t),!l.extend&&(n=c,t>r))break}}for(;this.actions.length>t;)this.actions.pop();return a&&e.setLookAhead(a),n||e.pos!=this.stream.end||(n=new qD,n.value=e.p.parser.eofTerm,n.start=n.end=e.pos,t=this.addActions(e,n.value,n.end,t)),this.mainToken=n,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new qD,{pos:n,p:r}=e;return t.start=n,t.end=Math.min(n+1,r.stream.end),t.value=n==r.stream.end?r.parser.eofTerm:0,t}updateCachedToken(e,t,n){let r=this.stream.clipPos(n.pos);if(t.token(this.stream.reset(r,e),n),e.value>-1){let{parser:t}=n.p;for(let r=0;r<t.specialized.length;r++)if(t.specialized[r]==e.value){let i=t.specializers[r](this.stream.read(e.start,e.end),n);if(i>=0&&n.p.parser.dialect.allows(i>>1)){1&i?e.extended=i>>1:e.value=i>>1;break}}}else e.value=0,e.end=this.stream.clipPos(r+1)}putAction(e,t,n,r){for(let t=0;t<r;t+=3)if(this.actions[t]==e)return r;return this.actions[r++]=e,this.actions[r++]=t,this.actions[r++]=n,r}addActions(e,t,n,r){let{state:i}=e,{parser:o}=e.p,{data:s}=o;for(let e=0;e<2;e++)for(let a=o.stateSlot(i,e?2:1);;a+=3){if(65535==s[a]){if(1!=s[a+1]){0==r&&2==s[a+1]&&(r=this.putAction(oP(s,a+2),t,n,r));break}a=oP(s,a+2)}s[a]==t&&(r=this.putAction(oP(s,a+1),t,n,r))}return r}}class tP{constructor(e,t,n,r){this.parser=e,this.input=t,this.ranges=r,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new $D(t,r),this.tokens=new eP(e,this.stream),this.topTerm=e.top[1];let{from:i}=r[0];this.stacks=[jD.start(this,e.top[0],i)],this.fragments=n.length&&this.stream.end-i>4*e.bufferLength?new ZD(n,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e,t,n=this.stacks,r=this.minStackPos,i=this.stacks=[];if(this.bigReductionCount>300&&1==n.length){let[e]=n;for(;e.forceReduce()&&e.stack.length&&e.stack[e.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;o<n.length;o++){let s=n[o];for(;;){if(this.tokens.mainToken=null,s.pos>r)i.push(s);else{if(this.advanceStack(s,i,n))continue;{e||(e=[],t=[]),e.push(s);let n=this.tokens.getMainToken(s);t.push(n.value,n.end)}}break}}if(!i.length){let t=e&&function(e){let t=null;for(let n of e){let e=n.p.stoppedAt;(n.pos==n.p.stream.end||null!=e&&n.pos>e)&&n.p.parser.stateFlag(n.state,2)&&(!t||t.score<n.score)&&(t=n)}return t}(e);if(t)return this.stackToTree(t);if(this.parser.strict)throw new SyntaxError("No parse at "+r);this.recovering||(this.recovering=5)}if(this.recovering&&e){let n=null!=this.stoppedAt&&e[0].pos>this.stoppedAt?e[0]:this.runRecovery(e,t,i);if(n)return this.stackToTree(n.forceAll())}if(this.recovering){let e=1==this.recovering?1:3*this.recovering;if(i.length>e)for(i.sort((e,t)=>t.score-e.score);i.length>e;)i.pop();i.some(e=>e.reducePos>r)&&this.recovering--}else if(i.length>1){e:for(let e=0;e<i.length-1;e++){let t=i[e];for(let n=e+1;n<i.length;n++){let r=i[n];if(t.sameState(r)||t.buffer.length>500&&r.buffer.length>500){if(!((t.score-r.score||t.buffer.length-r.buffer.length)>0)){i.splice(e--,1);continue e}i.splice(n--,1)}}}i.length>12&&(i.sort((e,t)=>t.score-e.score),i.splice(12,i.length-12))}this.minStackPos=i[0].pos;for(let e=1;e<i.length;e++)i[e].pos<this.minStackPos&&(this.minStackPos=i[e].pos);return null}stopAt(e){if(null!=this.stoppedAt&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,t,n){let r=e.pos,{parser:i}=this;XD&&this.stackID(e);if(null!=this.stoppedAt&&r>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let t=e.curContext&&e.curContext.tracker.strict,n=t?e.curContext.hash:0;for(let o=this.fragments.nodeAt(r);o;){let r=this.parser.nodeSet.types[o.type.id]==o.type?i.getGoto(e.state,o.type.id):-1;if(r>-1&&o.length&&(!t||(o.prop(BC.contextHash)||0)==n))return e.useNode(o,r),!0;if(!(o instanceof UC)||0==o.children.length||o.positions[0]>0)break;let s=o.children[0];if(!(s instanceof UC&&0==o.positions[0]))break;o=s}}let o=i.stateSlot(e.state,4);if(o>0)return e.reduce(o),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let s=this.tokens.getActions(e);for(let i=0;i<s.length;){let o=s[i++],a=s[i++],l=s[i++],c=i==s.length||!n,u=c?e:e.split(),h=this.tokens.mainToken;if(u.apply(o,a,h?h.start:u.pos,l),c)return!0;u.pos>r?t.push(u):n.push(u)}return!1}advanceFully(e,t){let n=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>n)return nP(e,t),!0}}runRecovery(e,t,n){let r=null,i=!1;for(let o=0;o<e.length;o++){let s=e[o],a=t[o<<1],l=t[1+(o<<1)],c=XD?this.stackID(s)+" -> ":"";if(s.deadEnd){if(i)continue;if(i=!0,s.restart(),this.advanceFully(s,n))continue}let u=s.split(),h=c;for(let e=0;e<10&&u.forceReduce();e++){if(this.advanceFully(u,n))break;XD&&(h=this.stackID(u)+" -> ")}for(let e of s.recoverByInsert(a))this.advanceFully(e,n);this.stream.end>s.pos?(l==s.pos&&(l++,a=0),s.recoverByDelete(a,l),nP(s,n)):(!r||r.score<u.score)&&(r=u)}return r}stackToTree(e){return e.close(),UC.build({buffer:HD.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let t=(JD||(JD=new WeakMap)).get(e);return t||JD.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}}function nP(e,t){for(let n=0;n<t.length;n++){let r=t[n];if(r.pos==e.pos&&r.sameState(e))return void(t[n].score<e.score&&(t[n]=e))}t.push(e)}class rP{constructor(e,t,n){this.source=e,this.flags=t,this.disabled=n}allows(e){return!this.disabled||0==this.disabled[e]}}class iP extends uN{constructor(e){if(super(),this.wrappers=[],14!=e.version)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let n=0;n<e.repeatNodeCount;n++)t.push("");let n=Object.keys(e.topRules).map(t=>e.topRules[t][1]),r=[];for(let e=0;e<t.length;e++)r.push([]);function i(e,t,n){r[e].push([t,t.deserialize(String(n))])}if(e.nodeProps)for(let t of e.nodeProps){let e=t[0];"string"==typeof e&&(e=BC[e]);for(let n=1;n<t.length;){let r=t[n++];if(r>=0)i(r,e,t[n++]);else{let o=t[n+-r];for(let s=-r;s>0;s--)i(t[n++],e,o);n++}}}this.nodeSet=new zC(t.map((t,i)=>WC.define({name:i>=this.minRepeatTerm?void 0:t,id:i,props:r[i],top:n.indexOf(i)>-1,error:0==i,skipped:e.skippedNodes&&e.skippedNodes.indexOf(i)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=LC;let o=VD(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let e=0;e<this.specializerSpecs.length;e++)this.specialized[e]=this.specializerSpecs[e].term;this.specializers=this.specializerSpecs.map(sP),this.states=VD(e.states,Uint32Array),this.data=VD(e.stateData),this.goto=VD(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(e=>"number"==typeof e?new KD(o,e):e),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,n){let r=new tP(this,e,t,n);for(let i of this.wrappers)r=i(r,e,t,n);return r}getGoto(e,t,n=!1){let r=this.goto;if(t>=r[0])return-1;for(let i=r[t+1];;){let t=r[i++],o=1&t,s=r[i++];if(o&&n)return s;for(let n=i+(t>>1);i<n;i++)if(r[i]==e)return s;if(o)return-1}}hasAction(e,t){let n=this.data;for(let r=0;r<2;r++)for(let i,o=this.stateSlot(e,r?2:1);;o+=3){if(65535==(i=n[o])){if(1!=n[o+1]){if(2==n[o+1])return oP(n,o+2);break}i=n[o=oP(n,o+2)]}if(i==t||0==i)return oP(n,o+1)}return 0}stateSlot(e,t){return this.states[6*e+t]}stateFlag(e,t){return(this.stateSlot(e,0)&t)>0}validAction(e,t){return!!this.allActions(e,e=>e==t||null)}allActions(e,t){let n=this.stateSlot(e,4),r=n?t(n):void 0;for(let n=this.stateSlot(e,1);null==r;n+=3){if(65535==this.data[n]){if(1!=this.data[n+1])break;n=oP(this.data,n+2)}r=t(oP(this.data,n+1))}return r}nextStates(e){let t=[];for(let n=this.stateSlot(e,1);;n+=3){if(65535==this.data[n]){if(1!=this.data[n+1])break;n=oP(this.data,n+2)}if(!(1&this.data[n+2])){let e=this.data[n+1];t.some((t,n)=>1&n&&t==e)||t.push(this.data[n],e)}}return t}configure(e){let t=Object.assign(Object.create(iP.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let n=this.topRules[e.top];if(!n)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=n}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(t=>{let n=e.tokenizers.find(e=>e.from==t);return n?n.to:t})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((n,r)=>{let i=e.specializers.find(e=>e.from==n.external);if(!i)return n;let o=Object.assign(Object.assign({},n),{external:i.to});return t.specializers[r]=sP(o),o})),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),null!=e.strict&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),null!=e.bufferLength&&(t.bufferLength=e.bufferLength),t}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return null==t?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),n=t.map(()=>!1);if(e)for(let r of e.split(" ")){let e=t.indexOf(r);e>=0&&(n[e]=!0)}let r=null;for(let e=0;e<t.length;e++)if(!n[e])for(let n,i=this.dialects[t[e]];65535!=(n=this.data[i++]);)(r||(r=new Uint8Array(this.maxTerm+1)))[n]=1;return new rP(e,n,r)}static deserialize(e){return new iP(e)}}function oP(e,t){return e[t]|e[t+1]<<16}function sP(e){if(e.external){let t=e.extend?1:0;return(n,r)=>e.external(n,r)<<1|t}return e.get}const aP=gN({String:BN.string,Number:BN.number,"True False":BN.bool,PropertyName:BN.propertyName,Null:BN.null,", :":BN.separator,"[ ]":BN.squareBracket,"{ }":BN.brace}),lP=iP.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:"#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O",goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"⚠ JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array",maxTerm:25,nodeProps:[["isolate",-2,6,11,""],["openedBy",7,"{",14,"["],["closedBy",8,"}",15,"]"]],propSources:[aP],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0}),cP=VN.define({name:"json",parser:lP.configure({props:[aO.add({Object:fO({except:/^\s*\}/}),Array:fO({except:/^\s*\]/})}),mO.add({"Object Array":function(e){let t=e.firstChild,n=e.lastChild;return t&&t.to<n.from?{from:t.to,to:n.type.isError?e.to:n.from}:null}})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function uP(e){return hP.apply(this,arguments)}function hP(){return hP=k(C().m(function e(t){var n,r;return C().w(function(e){for(;;)switch(e.n){case 0:if(t){e.n=1;break}return e.a(2);case 1:if(!(null===(n=null===navigator||void 0===navigator?void 0:navigator.clipboard)||void 0===n?void 0:n.writeText)){e.n=3;break}return e.n=2,navigator.clipboard.writeText(t);case 2:return e.a(2);case 3:(r=document.createElement("textarea")).value=t,r.style.position="fixed",r.style.left="-9999px",document.body.appendChild(r),r.select(),document.execCommand("copy"),document.body.removeChild(r);case 4:return e.a(2)}},e)})),hP.apply(this,arguments)}function dP(t){var n=t.value,r=t.title;if(null==n||""===n)return e.createElement("span",null,"-");var i,o=Av(n),s=o.ok,a=o.pretty,l=o.compact,c=l.length>80?l.slice(0,80)+"…":l;return e.createElement(tv,null,e.createElement(nv,{asChild:!0},e.createElement("button",{type:"button",className:"max-w-xs truncate text-left font-mono text-xs text-muted-foreground hover:underline",title:"点击查看 JSON"},c)),e.createElement(ov,{className:"max-w-3xl"},e.createElement(sv,null,e.createElement(lv,null,r||"JSON")),e.createElement("div",{className:"flex items-center justify-end gap-2"},e.createElement(kt,{variant:"outline",size:"sm",onClick:(i=k(C().m(function e(){return C().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,uP(a);case 1:Ch.success("已复制 JSON"),e.n=3;break;case 2:e.p=2,e.v,Ch.error("复制失败");case 3:return e.a(2)}},e,null,[[0,2]])})),function(){return i.apply(this,arguments)})},"复制")),e.createElement("pre",{className:"max-h-[60vh] overflow-auto rounded-md bg-muted p-3 text-xs font-mono whitespace-pre-wrap break-all"},a),!s&&e.createElement("div",{className:"text-xs text-destructive"},o.ok?"":o.message)))}function fP(t){t.id;var n=t.value;t.required;var r,i=t.disabled,o=t.onChange,s=O(e.useState(null),2),a=s[0],l=s[1];return e.createElement("div",{className:"space-y-2"},e.createElement("div",{className:"flex items-center justify-end gap-2"},e.createElement(kt,{type:"button",variant:"outline",size:"sm",disabled:!!i,onClick:function(){if(!i){var e=(n||"").trim();if(e){var t=Mv(e,2);t.ok?(o(t.formatted),l(null)):l(t.message)}}}},"格式化"),e.createElement(kt,{type:"button",variant:"outline",size:"sm",onClick:(r=k(C().m(function e(){return C().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,uP(n||"");case 1:Ch.success("已复制"),e.n=3;break;case 2:e.p=2,e.v,Ch.error("复制失败");case 3:return e.a(2)}},e,null,[[0,2]])})),function(){return r.apply(this,arguments)})},"复制")),e.createElement("div",{className:"w-full max-w-full overflow-hidden rounded-md border bg-background"},e.createElement(FD,{className:"w-full max-w-full",editable:!i,value:n||"",height:"220px",basicSetup:{lineNumbers:!0,foldGutter:!0,highlightActiveLine:!0},extensions:[new eO(cP),VS.lineWrapping],onChange:function(e){i||(o(e),function(e){var t=(e||"").trim();if(!t)return l(null),!0;var n=Av(t);n.ok?l(null):l(n.message)}(e))}})),a&&e.createElement("div",{className:"text-xs text-destructive"},a))}var pP=e.forwardRef(function(t,n){var r=t.className,i=D(t,["className"]);return e.createElement("div",{className:"relative w-full overflow-x-auto"},e.createElement("table",Object.assign({ref:n,className:ot("w-full min-w-max caption-bottom text-sm",r)},i)))});pP.displayName="Table";var mP=e.forwardRef(function(t,n){var r=t.className,i=D(t,["className"]);return e.createElement("thead",Object.assign({ref:n,className:ot("[&_tr]:border-b",r)},i))});mP.displayName="TableHeader";var gP=e.forwardRef(function(t,n){var r=t.className,i=D(t,["className"]);return e.createElement("tbody",Object.assign({ref:n,className:ot("[&_tr:last-child]:border-0",r)},i))});gP.displayName="TableBody";var vP=e.forwardRef(function(t,n){var r=t.className,i=D(t,["className"]);return e.createElement("tfoot",Object.assign({ref:n,className:ot("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",r)},i))});vP.displayName="TableFooter";var bP=e.forwardRef(function(t,n){var r=t.className,i=D(t,["className"]);return e.createElement("tr",Object.assign({ref:n,className:ot("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",r)},i))});bP.displayName="TableRow";var yP=e.forwardRef(function(t,n){var r=t.className,i=D(t,["className"]);return e.createElement("th",Object.assign({ref:n,className:ot("h-12 px-4 text-left align-middle font-medium text-muted-foreground whitespace-nowrap [&:has([role=checkbox])]:pr-0",r)},i))});yP.displayName="TableHead";var wP=e.forwardRef(function(t,n){var r=t.className,i=D(t,["className"]);return e.createElement("td",Object.assign({ref:n,className:ot("p-4 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0",r)},i))});wP.displayName="TableCell";var xP=e.forwardRef(function(t,n){var r=t.className,i=D(t,["className"]);return e.createElement("caption",Object.assign({ref:n,className:ot("mt-4 text-sm text-muted-foreground",r)},i))});xP.displayName="TableCaption";var kP=wt("inline-flex items-center rounded-full border px-3 py-1 text-xs font-bold transition-all duration-300",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow-[0_2px_8px_-1px_rgba(93,112,82,0.15)] hover:scale-105",secondary:"border-transparent bg-secondary text-secondary-foreground shadow-[0_2px_8px_-1px_rgba(193,140,93,0.15)] hover:scale-105",destructive:"border-transparent bg-destructive text-destructive-foreground shadow-[0_2px_8px_-1px_rgba(168,84,72,0.15)] hover:scale-105",outline:"text-foreground border-border"}},defaultVariants:{variant:"default"}});function SP(t){var n=t.className,r=t.variant,i=D(t,["className","variant"]);return e.createElement("div",Object.assign({className:ot(kP({variant:r}),n)},i))}function EP(){return"".concat(Date.now(),"_").concat(Math.random().toString(16).slice(2))}function CP(e){return"integer"===e||"float"===e?[{value:"eq",label:"等于"},{value:"neq",label:"不等于"},{value:"gt",label:"大于"},{value:"gte",label:"大于等于"},{value:"lt",label:"小于"},{value:"lte",label:"小于等于"},{value:"in",label:"属于(多个)"},{value:"isNull",label:"为空(NULL)"}]:"boolean"===e?[{value:"eq",label:"等于"},{value:"neq",label:"不等于"},{value:"isNull",label:"为空(NULL)"}]:"date"===e||"datetime"===e?[{value:"eq",label:"等于"},{value:"neq",label:"不等于"},{value:"gt",label:"晚于/大于"},{value:"gte",label:"晚于等于/大于等于"},{value:"lt",label:"早于/小于"},{value:"lte",label:"早于等于/小于等于"},{value:"isNull",label:"为空(NULL)"}]:[{value:"contains",label:"包含"},{value:"startsWith",label:"开头是"},{value:"endsWith",label:"结尾是"},{value:"eq",label:"等于"},{value:"neq",label:"不等于"},{value:"in",label:"属于(多个)"},{value:"isNull",label:"为空(NULL)"}]}function NP(e){var n,r,o=s(function(){var t=[];t.push.apply(t,A([{column:"id",label:"ID",type:"id"},{column:"created_at",label:"创建时间",type:"datetime"},{column:"updated_at",label:"更新时间",type:"datetime"}]));var n,r=S(e.fields||[]);try{for(r.s();!(n=r.n()).done;){var i=n.value;if((null==i?void 0:i.name)&&("json"!==i.type&&"jsonb"!==i.type))if("relation"===i.type&&i.relation){var o=i.relation.foreignKey||"".concat(i.relation.target,"_id");t.push({column:o,label:"".concat(i.comment||i.name,"(关联)"),type:"relation"})}else t.push({column:i.name,label:i.comment||i.name,type:i.type})}}catch(e){r.e(e)}finally{r.f()}var s=new Set;return t.filter(function(e){return!s.has(e.column)&&(s.add(e.column),!0)})},[e.fields]),l=s(function(){return new Map(o.map(function(e){return[e.column,e]}))},[o]),c=s(function(){return new Map(o.map(function(e){return[e.column,e.type]}))},[o]),u=O(i([]),2),h=u[0],d=u[1];a(function(){d(function(e,t){return(e||[]).map(function(e){if(t.get(e.column),"is"===e.operator&&(null===e.value||"null"===e.value))return{id:EP(),column:e.column,operator:"isNull",value:""};if(("ilike"===e.operator||"like"===e.operator)&&"string"==typeof e.value){var n=e.value;if(n.startsWith("%")&&n.endsWith("%")&&n.length>=2)return{id:EP(),column:e.column,operator:"contains",value:n.slice(1,-1)};if(n.endsWith("%"))return{id:EP(),column:e.column,operator:"startsWith",value:n.slice(0,-1)};if(n.startsWith("%"))return{id:EP(),column:e.column,operator:"endsWith",value:n.slice(1)}}if("in"===e.operator){var r=Array.isArray(e.value)?e.value:[];return{id:EP(),column:e.column,operator:"in",value:r.join(",")}}return{id:EP(),column:e.column,operator:["eq","neq","gt","gte","lt","lte"].includes(e.operator)?e.operator:"eq",value:void 0===e.value||null===e.value?"":String(e.value)}})}(e.value||[],c))},[JSON.stringify(e.value),o.length]);var f=function(e,t){d(function(n){return n.map(function(n){var r,i;if(n.id!==e)return n;var o=Object.assign(Object.assign({},n),t);if(t.column&&t.column!==n.column){var s=CP((null===(r=l.get(t.column))||void 0===r?void 0:r.type)||"string");o.operator=(null===(i=s[0])||void 0===i?void 0:i.value)||"eq",o.value=""}return t.operator&&"isNull"===t.operator&&(o.value=""),o})})};return t.createElement("div",{className:"space-y-3"},t.createElement("div",{className:"flex items-center justify-between gap-3"},t.createElement(oh,{className:"text-base font-medium flex items-center gap-2"},t.createElement(K,{className:"h-4 w-4"}),"动态筛选"),t.createElement("div",{className:"flex items-center gap-2"},(null===(n=e.value)||void 0===n?void 0:n.length)>0&&t.createElement(SP,{variant:"secondary"},"已应用 ",e.value.length," 条"),t.createElement(kt,{type:"button",variant:"outline",size:"sm",onClick:function(){var e=o[0];if(e){var t=CP(e.type);d(function(n){var r;return[].concat(A(n),[{id:EP(),column:e.column,operator:(null===(r=t[0])||void 0===r?void 0:r.value)||"eq",value:""}])})}}},t.createElement(ne,{className:"h-4 w-4 mr-1"}),"添加条件"))),0===h.length?t.createElement("div",{className:"text-sm text-muted-foreground border rounded-lg p-3 bg-muted/20"},"暂无筛选条件(可添加条件后点击“应用”)"):t.createElement("div",{className:"space-y-2"},h.map(function(e){var n=l.get(e.column),r=(null==n?void 0:n.type)||"string",i=CP(r),s="isNull"!==e.operator;return t.createElement("div",{key:e.id,className:"grid grid-cols-12 gap-2 items-center"},t.createElement("div",{className:"col-span-5"},t.createElement(Ag,{value:e.column,onValueChange:function(t){return f(e.id,{column:t})}},t.createElement(Tg,{className:"h-10"},t.createElement(Mg,{placeholder:"字段"})),t.createElement(Pg,null,o.map(function(e){return t.createElement(Ig,{key:e.column,value:e.column},e.label," (",e.column,")")})))),t.createElement("div",{className:"col-span-3"},t.createElement(Ag,{value:e.operator,onValueChange:function(t){return f(e.id,{operator:t})}},t.createElement(Tg,{className:"h-10"},t.createElement(Mg,{placeholder:"操作符"})),t.createElement(Pg,null,i.map(function(e){return t.createElement(Ig,{key:e.value,value:e.value},e.label)})))),t.createElement("div",{className:"col-span-3"},s?"boolean"===r?t.createElement(Ag,{value:e.value,onValueChange:function(t){return f(e.id,{value:t})}},t.createElement(Tg,{className:"h-10"},t.createElement(Mg,{placeholder:"值"})),t.createElement(Pg,null,t.createElement(Ig,{value:"true"},"true"),t.createElement(Ig,{value:"false"},"false"))):t.createElement(St,{className:"h-10",placeholder:"in"===e.operator?"多个值用逗号分隔":"值",type:"integer"===r||"float"===r?"number":"date"===r?"date":"datetime"===r?"datetime-local":"text",value:e.value,onChange:function(t){return f(e.id,{value:t.target.value})}}):t.createElement("div",{className:"h-10 flex items-center text-sm text-muted-foreground"},"无需填写")),t.createElement("div",{className:"col-span-1 flex justify-end"},t.createElement(kt,{type:"button",variant:"ghost",size:"sm",className:"h-9 w-9 p-0",onClick:function(){return t=e.id,void d(function(e){return e.filter(function(e){return e.id!==t})});var t}},t.createElement(ue,{className:"h-4 w-4"}))))})),t.createElement("div",{className:"flex items-center justify-end gap-2"},t.createElement(kt,{type:"button",variant:"outline",onClick:function(){d([]),e.onChange([])},disabled:0===h.length&&0===((null===(r=e.value)||void 0===r?void 0:r.length)||0)},"清空"),t.createElement(kt,{type:"button",onClick:function(){var t=function(e,t){var n,r,i=[],o=S(e);try{for(o.s();!(r=o.n()).done;){var s=r.value,a=t.get(s.column);if(a&&s.operator)if("isNull"!==s.operator){var l=null!==(n=s.value)&&void 0!==n?n:"",c=String(l).trim();if(c)if("contains"!==s.operator)if("startsWith"!==s.operator)if("endsWith"!==s.operator)if("in"!==s.operator)i.push({column:a.column,operator:s.operator,value:c});else{var u=c.split(",").map(function(e){return e.trim()}).filter(Boolean);i.push({column:a.column,operator:"in",value:u})}else i.push({column:a.column,operator:"ilike",value:"%".concat(c)});else i.push({column:a.column,operator:"ilike",value:"".concat(c,"%")});else i.push({column:a.column,operator:"ilike",value:"%".concat(c,"%")})}else i.push({column:a.column,operator:"is",value:null})}}catch(e){o.e(e)}finally{o.f()}return i}(h,l);e.onChange(t)},disabled:0===h.length},"应用")))}function OP(){var e,n=O(i([]),2),r=n[0],o=n[1],s=O(i(null),2),l=s[0],c=s[1],u=O(i([]),2),h=u[0],d=u[1],f=O(i(!1),2),p=f[0],m=f[1],g=O(i(!1),2),v=g[0],b=g[1],w=O(i(null),2),x=w[0],S=w[1],N=O(i({}),2),A=N[0],M=N[1],T=O(i(1),2),R=T[0],D=T[1],P=O(i(10),2),L=P[0];P[1];var I=O(i(0),2),_=I[0],B=I[1],F=O(i(""),2),j=F[0],H=F[1],V=O(i(!1),2),q=V[0],U=V[1],$=O(i(null),2),Y=$[0],G=$[1],X=O(i(!0),2),Q=X[0],Z=X[1],ee=O(i([]),2),te=ee[0],ie=ee[1],se=O(i(!1),2),le=se[0],ce=se[1],ue=function(e){return Array.isArray(e)?e:Array.isArray(null==e?void 0:e.models)?e.models:Array.isArray(null==e?void 0:e.data)?e.data:Array.isArray(null==e?void 0:e.items)?e.items:[]},he=function(e){var t;if(e&&Array.isArray(e.data)){var n="number"==typeof e.total?e.total:"number"==typeof(null===(t=e.pagination)||void 0===t?void 0:t.total)?e.pagination.total:e.data.length;return{rows:e.data,total:n}}if(e&&Array.isArray(e.rows)){var r="number"==typeof e.total?e.total:e.rows.length;return{rows:e.rows,total:r}}return Array.isArray(e)?{rows:e,total:e.length}:{rows:[],total:0}},de=function(e){return!e||!e.readOnly&&!1!==e.editable};a(function(){fe()},[]),a(function(){l&&pe()},[l,R,L,j,te]);var fe=function(){var e=k(C().m(function e(){var t;return C().w(function(e){for(;;)switch(e.p=e.n){case 0:return Z(!0),e.p=1,e.n=2,Gf();case 2:t=e.v,o(ue(t.data)),e.n=4;break;case 3:e.p=3,e.v,Ch.error("加载模型列表失败");case 4:return e.p=4,Z(!1),e.f(4);case 5:return e.a(2)}},e,null,[[1,3,4,5]])}));return function(){return e.apply(this,arguments)}}(),pe=function(){var e=k(C().m(function e(){var t,n,r;return C().w(function(e){for(;;)switch(e.p=e.n){case 0:if(l){e.n=1;break}return e.a(2);case 1:return m(!0),e.p=2,t={page:R,limit:L},j&&(t.search=j),te.length>0&&(t.filters=te),e.n=3,ip(l.table_name,t);case 3:if((n=e.v).success){e.n=4;break}return Ch.error(n.message||"加载数据失败"),d([]),B(0),e.a(2);case 4:r=he(n.data),d(r.rows),B(r.total),e.n=6;break;case 5:e.p=5,e.v,Ch.error("加载数据失败"),d([]),B(0);case 6:return e.p=6,m(!1),e.f(6);case 7:return e.a(2)}},e,null,[[2,5,6,7]])}));return function(){return e.apply(this,arguments)}}(),me=function(){var e=k(C().m(function e(t){var n;return C().w(function(e){for(;;)switch(e.p=e.n){case 0:if(confirm("确定要删除这条数据吗?此操作不可撤销。")){e.n=1;break}return e.a(2);case 1:return G(t.id),e.p=2,e.n=3,lp(null==l?void 0:l.table_name,t.id);case 3:(n=e.v).success?(Ch.success("删除成功"),pe()):Ch.error(n.message||"删除失败"),e.n=5;break;case 4:e.p=4,e.v,Ch.error("删除失败");case 5:return e.p=5,G(null),e.f(5);case 6:return e.a(2)}},e,null,[[2,4,5,6]])}));return function(t){return e.apply(this,arguments)}}(),ge=function(){var e=k(C().m(function e(){var t,n,r,i,o;return C().w(function(e){for(;;)switch(e.p=e.n){case 0:if(l){e.n=1;break}return e.a(2);case 1:if(U(!0),e.p=2,t={},l.json_schema.fields.forEach(function(e){if("id"!==e.name&&de(e)){var n=A[e.name];if("date"!==e.type&&"datetime"!==e.type||(n=n?new Date(n).toISOString():null),"json"===e.type||"jsonb"===e.type){var r=(n||"").toString().trim();if(r){var i=Av(r);if(!i.ok)throw new Error("字段 ".concat(e.comment||e.name,":").concat(i.message));n=i.value}else n=null}t[e.name]=n}}),!x){e.n=4;break}return e.n=3,ap(l.table_name,Object.assign(Object.assign({},t),{id:x.id}));case 3:(n=e.v).success?(Ch.success("更新成功"),b(!1),pe()):Ch.error(n.message||"更新失败"),e.n=6;break;case 4:return e.n=5,sp(l.table_name,t);case 5:(r=e.v).success?(Ch.success("创建成功"),b(!1),pe()):Ch.error(r.message||"创建失败");case 6:e.n=8;break;case 7:e.p=7,o=e.v,i=o instanceof Error?o.message:"操作失败",Ch.error(i);case 8:return e.p=8,U(!1),e.f(8);case 9:return e.a(2)}},e,null,[[2,7,8,9]])}));return function(){return e.apply(this,arguments)}}();return t.createElement("div",{className:"min-h-[calc(100vh-4rem)] bg-gradient-to-br from-background via-background to-muted/20"},t.createElement("div",{className:"container mx-auto px-6 py-8 space-y-6"},t.createElement("div",{className:"space-y-2"},t.createElement("h1",{className:"text-3xl font-bold tracking-tight"},"数据列表"),t.createElement("p",{className:"text-muted-foreground"},"选择模型查看和管理数据")),t.createElement(sh,{className:"border-2 shadow-lg"},t.createElement(ah,{className:"bg-muted/30"},t.createElement("div",{className:"flex flex-col md:flex-row md:items-center md:justify-between gap-4"},t.createElement("div",null,t.createElement(lh,null,"数据管理"),t.createElement(ch,null,"选择数据模型进行查看和管理")),l&&t.createElement(kt,{onClick:function(){S(null),M({}),b(!0)},className:"w-full md:w-auto"},t.createElement(ne,{className:"h-4 w-4 mr-2"}),"新建数据"))),t.createElement(uh,{className:"space-y-6 pt-6"},t.createElement("div",{className:"flex flex-col md:flex-row gap-4"},t.createElement("div",{className:"flex-1 space-y-2"},t.createElement(oh,{htmlFor:"model",className:"text-base font-medium flex items-center gap-2"},t.createElement(K,{className:"h-4 w-4"}),"选择数据模型"),t.createElement(Ag,{value:(null===(e=null==l?void 0:l.id)||void 0===e?void 0:e.toString())||"",onValueChange:function(e){var t=r.find(function(t){return t.id.toString()===e});c(t||null),D(1),H(""),ie([])},disabled:Q},t.createElement(Tg,{className:"h-11"},Q?t.createElement("div",{className:"flex items-center gap-2"},t.createElement(J,{className:"h-4 w-4 animate-spin"}),t.createElement("span",null,"加载中...")):t.createElement(Mg,{placeholder:"请选择模型"})),t.createElement(Pg,null,r.map(function(e){return t.createElement(Ig,{key:e.id,value:e.id.toString()},e.name," (",e.table_name,")")})))),l&&t.createElement("div",{className:"flex-1 space-y-2"},t.createElement(oh,{htmlFor:"search",className:"text-base font-medium flex items-center gap-2"},t.createElement(re,{className:"h-4 w-4"}),"搜索"),t.createElement("div",{className:"relative"},t.createElement(re,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),t.createElement(St,{id:"search",placeholder:"搜索数据...",value:j,onChange:function(e){return H(e.target.value)},className:"pl-10 h-11"})))),l&&t.createElement(t.Fragment,null,t.createElement("div",{className:"flex items-center justify-end"},t.createElement(kt,{type:"button",variant:"outline",className:"h-10",onClick:function(){return ce(!0)}},t.createElement(K,{className:"h-4 w-4 mr-2"}),"筛选",te.length>0?"(".concat(te.length,")"):"")),t.createElement("div",{className:"flex items-center justify-between p-4 rounded-lg bg-muted/50 border"},t.createElement("div",{className:"text-sm text-muted-foreground"},"共 ",t.createElement("span",{className:"font-semibold text-foreground"},_)," 条数据"),t.createElement(SP,{variant:"outline"},l.name)),t.createElement("div",{className:"rounded-lg border overflow-hidden"},t.createElement("div",{className:"overflow-x-auto"},t.createElement(pP,null,t.createElement(mP,null,t.createElement(bP,{className:"bg-muted/50"},t.createElement(yP,{className:"font-semibold w-20"},"ID"),l.json_schema.fields.map(function(e){return t.createElement(yP,{key:e.name,className:"font-semibold"},e.comment||e.name)}),t.createElement(yP,{className:"font-semibold"},"创建时间"),t.createElement(yP,{className:"font-semibold"},"更新时间"),t.createElement(yP,{className:"font-semibold w-32 text-center"},"操作"))),t.createElement(gP,null,p?Array.from({length:3}).map(function(e,n){return t.createElement(bP,{key:n},t.createElement(wP,{colSpan:l.json_schema.fields.length+4},t.createElement("div",{className:"flex items-center gap-2 py-4"},t.createElement(J,{className:"h-4 w-4 animate-spin text-muted-foreground"}),t.createElement("span",{className:"text-sm text-muted-foreground"},"加载中..."))))}):0===h.length?t.createElement(bP,null,t.createElement(wP,{colSpan:l.json_schema.fields.length+4,className:"text-center py-12"},t.createElement("div",{className:"flex flex-col items-center gap-2 text-muted-foreground"},t.createElement(re,{className:"h-8 w-8"}),t.createElement("p",null,"暂无数据")))):h.map(function(e,n){return t.createElement(bP,{key:e.id,className:n%2==0?"bg-muted/20":""},t.createElement(wP,{className:"font-mono font-medium"},e.id),l.json_schema.fields.map(function(n){return t.createElement(wP,{key:n.name},function(e,n){return"boolean"===e.type?t.createElement(SP,{variant:n?"default":"secondary"},n?"是":"否"):"date"===e.type||"datetime"===e.type?n?y(n).format("YYYY-MM-DD HH:mm:ss"):"-":"text"===e.type&&n&&n.length>50?t.createElement("span",{className:"max-w-xs truncate block",title:n},n.substring(0,50),"..."):"json"===e.type||"jsonb"===e.type?t.createElement(dP,{value:n,title:e.comment||e.name}):n||"-"}(n,e[n.name]))}),t.createElement(wP,{className:"text-sm text-muted-foreground"},y(e.created_at).format("YYYY-MM-DD HH:mm")),t.createElement(wP,{className:"text-sm text-muted-foreground"},y(e.updated_at).format("YYYY-MM-DD HH:mm")),t.createElement(wP,null,t.createElement("div",{className:"flex items-center justify-center gap-2"},t.createElement(kt,{variant:"ghost",size:"sm",onClick:function(){return function(e){S(e);var t={};null==l||l.json_schema.fields.forEach(function(n){if("id"!==n.name){var r=e[n.name];"date"!==n.type&&"datetime"!==n.type||(r=r?y(r).format("YYYY-MM-DDTHH:mm"):""),"json"!==n.type&&"jsonb"!==n.type||(r=null==r||""===r?"":"string"==typeof r?r:JSON.stringify(r,null,2)),t[n.name]=r}}),M(t),b(!0)}(e)},className:"h-8 w-8 p-0"},t.createElement(oe,{className:"h-4 w-4"})),t.createElement(kt,{variant:"ghost",size:"sm",onClick:function(){return me(e)},disabled:Y===e.id,className:"h-8 w-8 p-0 text-destructive hover:text-destructive"},Y===e.id?t.createElement(J,{className:"h-4 w-4 animate-spin"}):t.createElement(ae,{className:"h-4 w-4"})))))}))))),_>L&&t.createElement("div",{className:"flex items-center justify-between p-4 rounded-lg bg-muted/50 border"},t.createElement("div",{className:"text-sm text-muted-foreground"},"第 ",t.createElement("span",{className:"font-semibold text-foreground"},R)," 页, 共 ",t.createElement("span",{className:"font-semibold text-foreground"},Math.ceil(_/L))," 页"),t.createElement("div",{className:"flex gap-2"},t.createElement(kt,{variant:"outline",size:"sm",onClick:function(){return D(Math.max(1,R-1))},disabled:1===R||p},t.createElement(W,{className:"h-4 w-4 mr-1"}),"上一页"),t.createElement(kt,{variant:"outline",size:"sm",onClick:function(){return D(Math.min(Math.ceil(_/L),R+1))},disabled:R>=Math.ceil(_/L)||p},"下一页",t.createElement(z,{className:"h-4 w-4 ml-1"}))))))),l&&t.createElement(tv,{open:le,onOpenChange:ce},t.createElement(ov,{className:"max-w-3xl"},t.createElement(sv,null,t.createElement(lv,{className:"text-xl"},"筛选"),t.createElement(uv,{className:"text-sm"},l.name," - ",l.table_name)),t.createElement("div",{className:"py-2"},t.createElement(NP,{fields:l.json_schema.fields,value:te,onChange:function(e){ie(e),D(1)}})),t.createElement(av,{className:"gap-2"},t.createElement(kt,{variant:"outline",onClick:function(){return ce(!1)}},"关闭")))),t.createElement(tv,{open:v,onOpenChange:b},t.createElement(ov,{className:"max-w-3xl max-h-[85vh] overflow-y-auto"},t.createElement(sv,null,t.createElement(lv,{className:"text-2xl"},x?"编辑数据":"新建数据"),t.createElement(uv,{className:"text-base"},null==l?void 0:l.name," - ",null==l?void 0:l.table_name)),t.createElement("div",{className:"space-y-4 py-4"},null==l?void 0:l.json_schema.fields.map(function(e){return function(e){if("id"===e.name)return null;var n=de(e);switch(e.type){case"boolean":return t.createElement("div",{key:e.name,className:"flex items-center space-x-3 p-4 rounded-lg border bg-card"},t.createElement(Zg,{id:e.name,checked:A[e.name]||!1,disabled:!n,onCheckedChange:function(t){return M(Object.assign(Object.assign({},A),E({},e.name,t)))}}),t.createElement(oh,{htmlFor:e.name,className:"text-base font-medium cursor-pointer"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")));case"date":return t.createElement("div",{key:e.name,className:"space-y-2"},t.createElement(oh,{htmlFor:e.name,className:"text-base font-medium"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")),t.createElement(St,{id:e.name,type:"date",value:A[e.name]||"",disabled:!n,onChange:function(t){return M(Object.assign(Object.assign({},A),E({},e.name,t.target.value)))},required:e.required,className:"h-11"}));case"datetime":return t.createElement("div",{key:e.name,className:"space-y-2"},t.createElement(oh,{htmlFor:e.name,className:"text-base font-medium"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")),t.createElement(St,{id:e.name,type:"datetime-local",value:A[e.name]||"",disabled:!n,onChange:function(t){return M(Object.assign(Object.assign({},A),E({},e.name,t.target.value)))},required:e.required,className:"h-11"}));case"text":return t.createElement("div",{key:e.name,className:"space-y-2"},t.createElement(oh,{htmlFor:e.name,className:"text-base font-medium"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")),t.createElement(ev,{id:e.name,rows:4,value:A[e.name]||"",disabled:!n,onChange:function(t){return M(Object.assign(Object.assign({},A),E({},e.name,t.target.value)))},required:e.required,className:"resize-none"}));case"json":case"jsonb":return t.createElement("div",{key:e.name,className:"space-y-2"},t.createElement(oh,{htmlFor:e.name,className:"text-base font-medium"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")),t.createElement(fP,{id:e.name,value:A[e.name]||"",required:e.required,disabled:!n,onChange:function(t){return M(Object.assign(Object.assign({},A),E({},e.name,t)))}}));case"integer":case"float":return t.createElement("div",{key:e.name,className:"space-y-2"},t.createElement(oh,{htmlFor:e.name,className:"text-base font-medium"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")),t.createElement(St,{id:e.name,type:"number",value:A[e.name]||"",disabled:!n,onChange:function(t){return M(Object.assign(Object.assign({},A),E({},e.name,t.target.value)))},required:e.required,className:"h-11"}));default:return t.createElement("div",{key:e.name,className:"space-y-2"},t.createElement(oh,{htmlFor:e.name,className:"text-base font-medium"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")),t.createElement(St,{id:e.name,type:"email"===e.type?"email":"text",maxLength:e.maxLength,value:A[e.name]||"",disabled:!n,onChange:function(t){return M(Object.assign(Object.assign({},A),E({},e.name,t.target.value)))},required:e.required,className:"h-11"}))}}(e)})),t.createElement(av,{className:"gap-2"},t.createElement(kt,{variant:"outline",onClick:function(){return b(!1)},disabled:q},"取消"),t.createElement(kt,{onClick:ge,disabled:q},q?t.createElement(t.Fragment,null,t.createElement(J,{className:"h-4 w-4 mr-2 animate-spin"}),x?"更新中...":"创建中..."):x?"更新":"创建"))))))}function AP(e){return/^https?:\/\//i.test(e)}function MP(e){var n=e.url;return t.createElement("div",{className:"flex items-center gap-2 max-w-[360px]"},t.createElement(ha,null,t.createElement(da,{asChild:!0},t.createElement("a",{href:n,target:"_blank",rel:"noreferrer",className:"inline-flex h-10 w-10 shrink-0 items-center justify-center overflow-hidden rounded border bg-muted",title:"点击打开原图"},t.createElement("img",{src:n,alt:"",className:"h-full w-full object-cover",onError:function(e){e.currentTarget.style.display="none"}}))),t.createElement(fa,{side:"right",className:"p-2"},t.createElement("img",{src:n,alt:"",className:"max-h-64 max-w-64 rounded object-contain",onError:function(e){e.currentTarget.style.display="none"}}))),t.createElement("a",{href:n,target:"_blank",rel:"noreferrer",className:"truncate text-primary underline-offset-2 hover:underline",title:n},n))}function TP(e){var n=e.model,r=O(i([]),2),o=r[0],l=r[1],c=O(i(!1),2),u=c[0],h=c[1],d=O(i(!1),2),f=d[0],p=d[1],m=O(i(!1),2),g=m[0],v=m[1],b=O(i(null),2),w=b[0],x=b[1],S=O(i({}),2),N=S[0],A=S[1],M=O(i(1),2),T=M[0],R=M[1],D=O(i(10),2),P=D[0];D[1];var L=O(i(0),2),I=L[0],_=L[1],B=O(i(""),2),F=B[0],j=B[1],H=O(i(!1),2),V=H[0],q=H[1],$=O(i(null),2),Y=$[0],G=$[1],X=O(i({}),2),Q=X[0],Z=X[1],ee=O(i([]),2),te=ee[0],ie=ee[1],se=s(function(){return te.length?JSON.stringify(te):""},[te]),le=function(e){return!e.readOnly&&!1!==e.editable};a(function(){n&&ue()},[null==n?void 0:n.table_name,T,P,F,se]);var ce=function(){var e=k(C().m(function e(t){var n,r,i,o,s;return C().w(function(e){for(;;)switch(e.p=e.n){case 0:if("relation"===t.type&&t.relation){e.n=1;break}return e.a(2);case 1:if(n=t.relation,r=n.target,i=n.displayField,o="".concat(r,"_").concat(i||"name"),!Q[o]){e.n=2;break}return e.a(2);case 2:return e.p=2,e.n=3,op(r,{displayField:i||"name",limit:200});case 3:(s=e.v).success&&s.data&&Z(function(e){return Object.assign(Object.assign({},e),E({},o,s.data))}),e.n=5;break;case 4:e.p=4,e.v;case 5:return e.a(2)}},e,null,[[2,4]])}));return function(t){return e.apply(this,arguments)}}();a(function(){f&&n&&n.json_schema.fields.filter(function(e){return"relation"===e.type&&e.relation}).forEach(function(e){return ce(e)})},[f,n]);var ue=function(){var e=k(C().m(function e(){var t,r,i,o;return C().w(function(e){for(;;)switch(e.p=e.n){case 0:if(n){e.n=1;break}return e.a(2);case 1:return h(!0),e.p=2,i={page:T,limit:P},F&&(i.search=F),te.length>0&&(i.filters=te),e.n=3,ip(n.table_name,i);case 3:if((o=e.v).success){e.n=4;break}return Ch.error(o.message||"加载数据失败"),l([]),_(0),e.a(2);case 4:l((null===(t=o.data)||void 0===t?void 0:t.data)||[]),_((null===(r=o.data)||void 0===r?void 0:r.total)||0),e.n=6;break;case 5:e.p=5,e.v,Ch.error("加载数据失败"),l([]),_(0);case 6:return e.p=6,h(!1),e.f(6);case 7:return e.a(2)}},e,null,[[2,5,6,7]])}));return function(){return e.apply(this,arguments)}}(),he=function(){var e=k(C().m(function e(t){var r;return C().w(function(e){for(;;)switch(e.p=e.n){case 0:if(confirm("确定要删除这条数据吗?此操作不可撤销。")){e.n=1;break}return e.a(2);case 1:return G(t.id),e.p=2,e.n=3,lp(null==n?void 0:n.table_name,t.id);case 3:(r=e.v).success?(Ch.success("删除成功"),ue()):Ch.error(r.message||"删除失败"),e.n=5;break;case 4:e.p=4,e.v,Ch.error("删除失败");case 5:return e.p=5,G(null),e.f(5);case 6:return e.a(2)}},e,null,[[2,4,5,6]])}));return function(t){return e.apply(this,arguments)}}(),de=function(){var e=k(C().m(function e(){var t,r,i,o,s,a;return C().w(function(e){for(;;)switch(e.p=e.n){case 0:if(n){e.n=1;break}return e.a(2);case 1:if(q(!0),e.p=2,t={},n.json_schema.fields.forEach(function(e){if("id"!==e.name&&le(e))if("relation"===e.type&&e.relation){var n=e.relation.foreignKey||"".concat(e.relation.target,"_id");t[n]=N[n]}else{var r=N[e.name];if("date"!==e.type&&"datetime"!==e.type||(r=r?new Date(r).toISOString():null),"json"===e.type||"jsonb"===e.type){var i=(r||"").toString().trim();if(i){var o=Av(i);if(!o.ok)throw new Error("字段 ".concat(e.comment||e.name,":").concat(o.message));r=o.value}else r=null}t[e.name]=r}}),!w){e.n=4;break}return r=Object.assign(Object.assign({},t),{id:w.id}),e.n=3,ap(n.table_name,r);case 3:(i=e.v).success?(Ch.success("更新成功"),p(!1),ue()):Ch.error(i.message||"更新失败"),e.n=6;break;case 4:return e.n=5,sp(n.table_name,t);case 5:(o=e.v).success?(Ch.success("创建成功"),p(!1),ue()):Ch.error(o.message||"创建失败");case 6:e.n=8;break;case 7:e.p=7,a=e.v,s=a instanceof Error?a.message:"操作失败",Ch.error(s);case 8:return e.p=8,q(!1),e.f(8);case 9:return e.a(2)}},e,null,[[2,7,8,9]])}));return function(){return e.apply(this,arguments)}}(),fe=function(e,n,r){if("string"==typeof n){var i=n.trim();if(i&&function(e){var t,n=e.trim();if(!n)return!1;if(n.startsWith("data:image/"))return!0;if(!AP(n))return!1;var r=(null===(t=n.split("#")[0])||void 0===t?void 0:t.split("?")[0])||n;return/\.(png|jpe?g|gif|webp|bmp|svg)$/i.test(r)}(i))return t.createElement(MP,{url:i});if(i&&AP(i))return t.createElement("a",{href:i,target:"_blank",rel:"noreferrer",className:"max-w-[360px] truncate text-primary underline-offset-2 hover:underline block",title:i},i)}if("boolean"===e.type)return t.createElement(SP,{variant:n?"default":"secondary"},n?"是":"否");if("date"===e.type||"datetime"===e.type)return n?y(n).format("YYYY-MM-DD HH:mm:ss"):"-";if("text"===e.type&&n&&n.length>50)return t.createElement("span",{className:"max-w-xs truncate block",title:n},n.substring(0,50),"...");if("json"===e.type||"jsonb"===e.type)return t.createElement(dP,{value:n,title:e.comment||e.name});if("relation"===e.type&&e.relation&&r){var o=e.relation.displayField,s=void 0===o?"name":o,a=r["".concat(e.name,"_data")];if(a)return t.createElement(SP,{variant:"outline"},a[s]||"ID: ".concat(a.id));var l=r[e.relation.foreignKey||"".concat(e.relation.target,"_id")];return l?"ID: ".concat(l):"-"}return n||"-"};return n?t.createElement("div",{className:"min-h-[calc(100vh-4rem)] bg-gradient-to-br from-background via-background to-muted/20"},t.createElement("div",{className:"w-full py-4 space-y-4"},t.createElement("div",{className:"space-y-1"},t.createElement("div",{className:"flex items-center gap-3"},t.createElement("div",{className:"inline-flex items-center justify-center w-9 h-9 rounded-lg bg-primary/10 text-primary"},t.createElement(U,{className:"h-4 w-4"})),t.createElement("div",null,t.createElement("h1",{className:"text-2xl font-bold tracking-tight leading-tight"},n.name),t.createElement("p",{className:"text-sm text-muted-foreground"},"表名: ",n.table_name)))),t.createElement(sh,{className:"border-2 shadow-lg"},t.createElement(ah,{className:"bg-muted/30"},t.createElement("div",{className:"flex flex-col md:flex-row md:items-center md:justify-between gap-4"},t.createElement("div",null,t.createElement(lh,null,"数据管理"),t.createElement(ch,null,"查看和管理 ",n.name," 的数据")),t.createElement(kt,{onClick:function(){x(null),A({}),p(!0)},className:"w-full md:w-auto"},t.createElement(ne,{className:"h-4 w-4 mr-2"}),"新建数据"))),t.createElement(uh,{className:"space-y-4 pt-4"},t.createElement("div",{className:"flex flex-col md:flex-row md:items-center gap-3"},t.createElement("div",{className:"flex-1"},t.createElement(oh,{htmlFor:"search",className:"sr-only"},"搜索"),t.createElement("div",{className:"relative"},t.createElement(re,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),t.createElement(St,{id:"search",placeholder:"搜索数据...",value:F,onChange:function(e){return j(e.target.value)},className:"pl-10 h-10"}))),t.createElement(kt,{type:"button",variant:"outline",className:"h-10",onClick:function(){return v(!0)}},t.createElement(K,{className:"h-4 w-4 mr-2"}),"筛选",te.length>0?"(".concat(te.length,")"):"")),t.createElement("div",{className:"flex items-center justify-between p-4 rounded-lg bg-muted/50 border"},t.createElement("div",{className:"text-sm text-muted-foreground"},"共 ",t.createElement("span",{className:"font-semibold text-foreground"},I)," 条数据"),t.createElement(SP,{variant:"outline"},n.name)),t.createElement("div",{className:"rounded-lg border overflow-hidden"},t.createElement(pP,null,t.createElement(mP,null,t.createElement(bP,{className:"bg-muted/50"},t.createElement(yP,{className:"font-semibold w-20"},"ID"),n.json_schema.fields.map(function(e){return t.createElement(yP,{key:e.name,className:"font-semibold"},e.comment||e.name)}),t.createElement(yP,{className:"font-semibold"},"创建时间"),t.createElement(yP,{className:"font-semibold"},"更新时间"),t.createElement(yP,{className:ot("font-semibold w-32 text-center sticky right-0 z-30 bg-background","before:content-[''] before:absolute before:inset-y-0 before:left-0 before:w-px before:bg-border","after:content-[''] after:absolute after:inset-y-0 after:left-[-16px] after:w-4 after:bg-gradient-to-l after:from-background after:to-transparent","shadow-[-10px_0_16px_-14px_rgba(0,0,0,0.35)]")},"操作"))),t.createElement(gP,null,u?Array.from({length:3}).map(function(e,r){return t.createElement(bP,{key:r},t.createElement(wP,{colSpan:n.json_schema.fields.length+4},t.createElement("div",{className:"flex items-center gap-2 py-4"},t.createElement(J,{className:"h-4 w-4 animate-spin text-muted-foreground"}),t.createElement("span",{className:"text-sm text-muted-foreground"},"加载中..."))))}):0===o.length?t.createElement(bP,null,t.createElement(wP,{colSpan:n.json_schema.fields.length+4,className:"text-center py-12"},t.createElement("div",{className:"flex flex-col items-center gap-2 text-muted-foreground"},t.createElement(re,{className:"h-8 w-8"}),t.createElement("p",null,"暂无数据")))):o.map(function(e,r){return t.createElement(bP,{key:e.id,className:ot("group hover:bg-muted",r%2==0?"bg-muted/20":"")},t.createElement(wP,{className:"font-mono font-medium max-w-[220px] truncate",title:String(e.id)},e.id),n.json_schema.fields.map(function(n){return t.createElement(wP,{key:n.name},fe(n,e[n.name],e))}),t.createElement(wP,{className:"text-sm text-muted-foreground"},y(e.created_at).format("YYYY-MM-DD HH:mm")),t.createElement(wP,{className:"text-sm text-muted-foreground"},y(e.updated_at).format("YYYY-MM-DD HH:mm")),t.createElement(wP,{className:ot("sticky right-0 z-20 bg-background","before:content-[''] before:absolute before:inset-y-0 before:left-0 before:w-px before:bg-border","after:content-[''] after:absolute after:inset-y-0 after:left-[-16px] after:w-4 after:bg-gradient-to-l after:from-background after:to-transparent","shadow-[-10px_0_16px_-14px_rgba(0,0,0,0.25)]","group-hover:bg-muted")},t.createElement("div",{className:"flex items-center justify-center gap-2"},t.createElement(kt,{variant:"ghost",size:"sm",onClick:function(){return function(e){x(e);var t={};null==n||n.json_schema.fields.forEach(function(n){if("id"!==n.name)if("relation"===n.type&&n.relation){var r=n.relation.foreignKey||"".concat(n.relation.target,"_id");t[r]=e[r]}else{var i=e[n.name];"date"!==n.type&&"datetime"!==n.type||(i=i?y(i).format("YYYY-MM-DDTHH:mm"):""),"json"!==n.type&&"jsonb"!==n.type||(i=null==i||""===i?"":"string"==typeof i?i:JSON.stringify(i,null,2)),t[n.name]=i}}),A(t),p(!0)}(e)},className:"h-8 w-8 p-0"},t.createElement(oe,{className:"h-4 w-4"})),t.createElement(kt,{variant:"ghost",size:"sm",onClick:function(){return he(e)},disabled:Y===e.id,className:"h-8 w-8 p-0 text-destructive hover:text-destructive"},Y===e.id?t.createElement(J,{className:"h-4 w-4 animate-spin"}):t.createElement(ae,{className:"h-4 w-4"})))))})))),I>P&&t.createElement("div",{className:"flex items-center justify-between p-4 rounded-lg bg-muted/50 border"},t.createElement("div",{className:"text-sm text-muted-foreground"},"第 ",t.createElement("span",{className:"font-semibold text-foreground"},T)," 页, 共 ",t.createElement("span",{className:"font-semibold text-foreground"},Math.ceil(I/P))," 页"),t.createElement("div",{className:"flex gap-2"},t.createElement(kt,{variant:"outline",size:"sm",onClick:function(){return R(Math.max(1,T-1))},disabled:1===T||u},t.createElement(W,{className:"h-4 w-4 mr-1"}),"上一页"),t.createElement(kt,{variant:"outline",size:"sm",onClick:function(){return R(Math.min(Math.ceil(I/P),T+1))},disabled:T>=Math.ceil(I/P)||u},"下一页",t.createElement(z,{className:"h-4 w-4 ml-1"})))))),t.createElement(tv,{open:g,onOpenChange:v},t.createElement(ov,{className:"max-w-3xl"},t.createElement(sv,null,t.createElement(lv,{className:"text-xl"},"筛选"),t.createElement(uv,{className:"text-sm"},n.name," - ",n.table_name)),t.createElement("div",{className:"py-2"},t.createElement(NP,{fields:n.json_schema.fields,value:te,onChange:function(e){ie(e),R(1)}})),t.createElement(av,{className:"gap-2"},t.createElement(kt,{variant:"outline",onClick:function(){return v(!1)}},"关闭")))),t.createElement(tv,{open:f,onOpenChange:p},t.createElement(ov,{className:"max-w-3xl max-h-[85vh] overflow-y-auto"},t.createElement(sv,null,t.createElement(lv,{className:"text-2xl"},w?"编辑数据":"新建数据"),t.createElement(uv,{className:"text-base"},n.name," - ",n.table_name)),t.createElement("div",{className:"space-y-4 py-4"},n.json_schema.fields.map(function(e){return function(e){if("id"===e.name)return null;var n=le(e);switch(e.type){case"boolean":return t.createElement("div",{key:e.name,className:"flex items-center space-x-3 p-4 rounded-lg border bg-card"},t.createElement(Zg,{id:e.name,checked:N[e.name]||!1,disabled:!n,onCheckedChange:function(t){return A(Object.assign(Object.assign({},N),E({},e.name,t)))}}),t.createElement(oh,{htmlFor:e.name,className:"text-base font-medium cursor-pointer"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")));case"date":return t.createElement("div",{key:e.name,className:"space-y-2"},t.createElement(oh,{htmlFor:e.name,className:"text-base font-medium"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")),t.createElement(St,{id:e.name,type:"date",value:N[e.name]||"",disabled:!n,onChange:function(t){return A(Object.assign(Object.assign({},N),E({},e.name,t.target.value)))},required:e.required,className:"h-11"}));case"datetime":return t.createElement("div",{key:e.name,className:"space-y-2"},t.createElement(oh,{htmlFor:e.name,className:"text-base font-medium"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")),t.createElement(St,{id:e.name,type:"datetime-local",value:N[e.name]||"",disabled:!n,onChange:function(t){return A(Object.assign(Object.assign({},N),E({},e.name,t.target.value)))},required:e.required,className:"h-11"}));case"text":return t.createElement("div",{key:e.name,className:"space-y-2"},t.createElement(oh,{htmlFor:e.name,className:"text-base font-medium"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")),t.createElement(ev,{id:e.name,rows:4,value:N[e.name]||"",disabled:!n,onChange:function(t){return A(Object.assign(Object.assign({},N),E({},e.name,t.target.value)))},required:e.required,className:"resize-none"}));case"json":case"jsonb":return t.createElement("div",{key:e.name,className:"space-y-2"},t.createElement(oh,{htmlFor:e.name,className:"text-base font-medium"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")),t.createElement(fP,{id:e.name,value:N[e.name]||"",required:e.required,disabled:!n,onChange:function(t){return A(Object.assign(Object.assign({},N),E({},e.name,t)))}}));case"integer":case"float":return t.createElement("div",{key:e.name,className:"space-y-2"},t.createElement(oh,{htmlFor:e.name,className:"text-base font-medium"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")),t.createElement(St,{id:e.name,type:"number",value:N[e.name]||"",disabled:!n,onChange:function(t){return A(Object.assign(Object.assign({},N),E({},e.name,t.target.value)))},required:e.required,className:"h-11"}));case"relation":if(!e.relation)return null;var r=e.relation,i=r.target,o=r.displayField,s=void 0===o?"name":o,a="".concat(i,"_").concat(s),l=Q[a]||[],c=e.relation.foreignKey||"".concat(i,"_id"),u=void 0!==N[c]&&null!==N[c]?String(N[c]):"",h=l.find(function(e){return String(e.id)===u});return t.createElement("div",{key:e.name,className:"space-y-2"},t.createElement(oh,{htmlFor:e.name,className:"text-base font-medium"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")),t.createElement(Ag,{value:u,disabled:!n,onValueChange:function(e){var t=parseInt(e,10),n=!isNaN(t)&&String(t)===e;A(Object.assign(Object.assign({},N),E({},c,n?t:e)))}},t.createElement(Tg,{className:"h-11"},t.createElement(Mg,{placeholder:"请选择".concat(e.comment||e.name)},h?h.label:u?"ID: ".concat(u):"请选择".concat(e.comment||e.name))),t.createElement(Pg,null,0===l.length?t.createElement(Ig,{value:"_loading",disabled:!0},"加载中..."):l.map(function(e){return t.createElement(Ig,{key:e.id,value:String(e.id)},e.label)}))));default:return t.createElement("div",{key:e.name,className:"space-y-2"},t.createElement(oh,{htmlFor:e.name,className:"text-base font-medium"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")),t.createElement(St,{id:e.name,type:"email"===e.type?"email":"text",maxLength:e.maxLength,value:N[e.name]||"",disabled:!n,onChange:function(t){return A(Object.assign(Object.assign({},N),E({},e.name,t.target.value)))},required:e.required,className:"h-11"}))}}(e)})),t.createElement(av,{className:"gap-2"},t.createElement(kt,{variant:"outline",onClick:function(){return p(!1)},disabled:V},"取消"),t.createElement(kt,{onClick:de,disabled:V},V?t.createElement(t.Fragment,null,t.createElement(J,{className:"h-4 w-4 mr-2 animate-spin"}),w?"更新中...":"创建中..."):w?"更新":"创建")))))):t.createElement("div",{className:"min-h-[calc(100vh-4rem)] bg-gradient-to-br from-background via-background to-muted/20"},t.createElement("div",{className:"w-full py-4"},t.createElement(sh,{className:"border-2"},t.createElement(uh,{className:"py-16 text-center"},t.createElement(U,{className:"h-12 w-12 mx-auto mb-4 text-muted-foreground"}),t.createElement("p",{className:"text-lg text-muted-foreground"},"请选择数据模型")))))}function RP(e){var n=e.model;return t.createElement(TP,{key:n.id,model:n})}function DP(e){return e.models.map(function(e){return{path:"/data/list-".concat(e.id),name:e.name,icon:t.createElement(se),component:function(){return t.createElement(RP,{model:e})}}})}var PP=function(e){return[{path:"/login",name:"登录",icon:t.createElement(Z),component:mp},{name:"数据管理",icon:t.createElement(q),path:"/data",component:OP,routes:A(DP(e))}]},LP=ie,IP=le,_P=ee,BP=X;function FP(e){var n=e.inputModels,r=e.skipAuth,o=void 0!==r&&r,l=e.brandName,c=void 0===l?"WE0-CMS":l,u=fp(),h=pp(),d=h.locale,f=h.setLocale,p=O(i("/data"),2),m=p[0],g=p[1],v=O(i([]),2);v[0],v[1];var b=O(i(!1),2),y=b[0],w=b[1],x=O(i(null),2),E=x[0],N=x[1],A=O(i(!0),2),M=A[0],T=A[1],R=s(function(){return PP({models:n.models})},[n.models]);a(function(){if(o)return w(!0),N(null),T(!1),void("/login"===m&&g("/data"));var e=function(){var e=k(C().m(function e(){var t,n;return C().w(function(e){for(;;)switch(e.p=e.n){case 0:if(e.p=0,np()){e.n=1;break}return w(!1),g("/login"),T(!1),e.a(2);case 1:return e.p=1,e.n=2,Zf();case 2:if(e.v.success){e.n=3;break}throw new Error("token验证失败");case 3:if(!(t=rp())){e.n=4;break}N(t),e.n=6;break;case 4:return e.n=5,ep();case 5:(n=e.v).success&&n.data&&(N(n.data),localStorage.setItem("cms_user",JSON.stringify(n.data)));case 6:w(!0),"/login"===m&&g("/data"),e.n=8;break;case 7:e.p=7,e.v,tp(),w(!1),N(null),g("/login");case 8:e.n=10;break;case 9:e.p=9,e.v,w(!1),N(null),g("/login");case 10:return e.p=10,T(!1),e.f(10);case 11:return e.a(2)}},e,null,[[1,7],[0,9,10,11]])}));return function(){return e.apply(this,arguments)}}();e()},[o]);var D=function(e,t){N(t),w(!0),g("/data"),Ch.success("".concat(u("auth.welcome"),", ").concat(t.username,"!"))},P=function(e,t){var n,r=S(e);try{for(r.s();!(n=r.n()).done;){var i=n.value;if(i.path===t)return i;if(i.routes){var o=P(i.routes,t);if(o)return o}}}catch(e){r.e(e)}finally{r.f()}return null};if(M)return t.createElement("div",{className:"flex min-h-screen items-center justify-center bg-background"},t.createElement("div",{className:"space-y-4"},t.createElement(st,{className:"h-12 w-48"}),t.createElement(st,{className:"h-4 w-64"})));if(!y)return t.createElement(mp,{onLoginSuccess:D});var L=R.filter(function(e){return"/login"!==e.path}),I=function(e){if(!e)return U;if(t.isValidElement(e)){var n=e.type;if(n&&"function"==typeof n){var r=n.name||"";if(r.includes("Home"))return Y;if(r.includes("Table"))return se;if(r.includes("Database"))return U;if(r.includes("File"))return $}}return U},_=L.flatMap(function(e){return e.routes&&e.routes.length>0?e.routes.map(function(e){return{title:e.name,icon:I(e.icon),path:e.path}}):[{title:e.name,icon:I(e.icon),path:e.path}]});return t.createElement("div",{className:"we0-cms-root"},t.createElement(ga,null,t.createElement(va,{variant:"inset"},t.createElement(wa,{className:"border-b border-sidebar-border p-4"},t.createElement("div",{className:"flex items-center gap-3"},t.createElement("div",{className:"flex items-center justify-center w-12 h-12 rounded-2xl bg-primary shadow-[0_4px_12px_-2px_rgba(93,112,82,0.2)] transition-all duration-300 hover:scale-105"},t.createElement(LP,{className:"w-5 h-5 text-primary-foreground"})),t.createElement("span",{className:"font-bold text-xl text-foreground"},c))),t.createElement(ka,null,t.createElement(Sa,null,t.createElement(Ea,null,"Navigation"),t.createElement(Ca,null,t.createElement(Na,null,_.map(function(e){return t.createElement(Oa,{key:e.path},t.createElement(Ma,{onClick:function(){return g(e.path)},isActive:(n=e.path,m===n||m.startsWith(n+"/")),tooltip:e.title},t.createElement(e.icon,{className:"w-4 h-4"}),t.createElement("span",null,e.title)));var n}))))),t.createElement(xa,{className:"border-t border-sidebar-border"},t.createElement(Na,null,t.createElement(Oa,null,t.createElement(Uu,null,t.createElement($u,{asChild:!0},t.createElement(Ma,{tooltip:u("settings.language")},t.createElement(BP,{className:"w-4 h-4"}),t.createElement("span",null,"zh-CN"===d?"中文":"English"))),t.createElement(Gu,{align:"end",className:"w-48"},t.createElement(Xu,{onClick:function(){return f("zh-CN")},className:"zh-CN"===d?"bg-accent":""},"简体中文"),t.createElement(Xu,{onClick:function(){return f("en-US")},className:"en-US"===d?"bg-accent":""},"English")))),!o&&E&&t.createElement(t.Fragment,null,t.createElement(Oa,null,t.createElement(Ma,{tooltip:E.username||"User"},t.createElement(IP,{className:"w-4 h-4"}),t.createElement("span",{className:"truncate"},E.username))),t.createElement(Oa,null,t.createElement(Ma,{onClick:function(){window.confirm(u("auth.logoutConfirm"))&&(tp(),localStorage.removeItem("cms_token"),localStorage.removeItem("cms_user"),w(!1),N(null),g("/login"),Ch.success(u("auth.logoutSuccess")))},tooltip:u("auth.logout")},t.createElement(_P,{className:"w-4 h-4"}),t.createElement("span",null,u("auth.logout")))))))),t.createElement(ya,null,t.createElement("header",{className:"flex h-16 items-center gap-4 border-b border-border/50 bg-background/80 backdrop-blur-sm px-6 sticky top-0 z-10"},t.createElement(ba,null),t.createElement("h1",{className:"text-xl font-bold text-foreground"},function(){if("/login"===m)return u("auth.login");var e=P(R,m);return(null==e?void 0:e.name)||u("data.dataManagement")}())),t.createElement("main",{className:"flex-1 min-w-0 p-8 bg-gradient-to-br from-background via-background to-muted/20"},function(){if(!o&&"/login"===m)return t.createElement(mp,{onLoginSuccess:D});if(o&&"/login"===m)return t.createElement(OP,null);var e=P(R,m);if(e){var n=e.component;return t.createElement(n,null)}return t.createElement(OP,null)}()))))}function jP(e){var n=e.defaultLocale,r=D(e,["defaultLocale"]);return t.createElement(hp,{defaultLocale:n},t.createElement(FP,Object.assign({},r)))}export{jP as CmsLayoutShadcn,hp as I18nProvider,PP as cmsRoutes,jP as default,Yf as setSessionId,pp as useLocale,fp as useT,dp as useTranslation};
10
+ var ee={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},te=["color","size","strokeWidth","absoluteStrokeWidth","className","children"],ne=function(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase().trim()},re=function(e,t){var i=n(function(n,i){var o=n.color,s=void 0===o?"currentColor":o,a=n.size,l=void 0===a?24:a,c=n.strokeWidth,u=void 0===c?2:c,h=n.absoluteStrokeWidth,f=n.className,d=void 0===f?"":f,p=n.children,m=function(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],-1===t.indexOf(n)&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}(n,te);return r("svg",W(W({ref:i},ee),{},{width:l,height:l,stroke:s,strokeWidth:h?24*Number(u)/Number(l):u,className:["lucide","lucide-".concat(ne(e)),d].join(" ")},m),[].concat(K(t.map(function(e){var t=q(e,2),n=t[0],i=t[1];return r(n,i)})),K(Array.isArray(p)?p:[p])))});return i.displayName="".concat(e),i},ie=re("AlertCircle",[["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"}]]),oe=re("CheckCircle2",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),se=re("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]),ae=re("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]),le=re("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]),ce=re("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]),ue=re("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]),he=re("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]),fe=re("Crown",[["path",{d:"m2 4 3 12h14l3-12-6 7-4-7-4 7-6-7zm3 16h14",key:"zkxr6b"}]]),de=re("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]),pe=re("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]),me=re("Filter",[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]]),ge=re("Home",[["path",{d:"m3 9 9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"y5dka4"}],["polyline",{points:"9 22 9 12 15 12 15 22",key:"e2us08"}]]),ve=re("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]),ye=re("Languages",[["path",{d:"m5 8 6 6",key:"1wu5hv"}],["path",{d:"m4 14 6-6 2-3",key:"1k1g8d"}],["path",{d:"M2 5h12",key:"or177f"}],["path",{d:"M7 2h1",key:"1t2jsx"}],["path",{d:"m22 22-5-10-5 10",key:"don7ne"}],["path",{d:"M14 18h6",key:"1m8k6r"}]]),be=re("Loader2",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]),we=re("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]),ke=re("LogIn",[["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}],["polyline",{points:"10 17 15 12 10 7",key:"1ail0h"}],["line",{x1:"15",x2:"3",y1:"12",y2:"12",key:"v6grx8"}]]),xe=re("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]),Se=re("PanelLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),Ce=re("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]),Ee=re("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]),Ae=re("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),Me=re("SquarePen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a2.121 2.121 0 1 1 3 3L12 15l-4 1 1-4Z",key:"1lpok0"}]]),Oe=re("Table",[["path",{d:"M12 3v18",key:"108xh3"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}]]),Ne=re("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]),Te=re("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]),Re=re("XCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]),De=re("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function Pe(e){var t,n,r="";if("string"==typeof e||"number"==typeof e)r+=e;else if("object"==typeof e)if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=Pe(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function Le(){for(var e,t,n=0,r="",i=arguments.length;n<i;n++)(e=arguments[n])&&(t=Pe(e))&&(r&&(r+=" "),r+=t);return r}const Be=e=>{const t=We(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{const n=e.split("-");return""===n[0]&&1!==n.length&&n.shift(),Ie(n,t)||Fe(e)},getConflictingClassGroupIds:(e,t)=>{const i=n[e]||[];return t&&r[e]?[...i,...r[e]]:i}}},Ie=(e,t)=>{if(0===e.length)return t.classGroupId;const n=e[0],r=t.nextPart.get(n),i=r?Ie(e.slice(1),r):void 0;if(i)return i;if(0===t.validators.length)return;const o=e.join("-");return t.validators.find(({validator:e})=>e(o))?.classGroupId},_e=/^\[(.+)\]$/,Fe=e=>{if(_e.test(e)){const t=_e.exec(e)[1],n=t?.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},We=e=>{const{theme:t,prefix:n}=e,r={nextPart:new Map,validators:[]};return Ve(Object.entries(e.classGroups),n).forEach(([e,n])=>{je(n,r,e,t)}),r},je=(e,t,n,r)=>{e.forEach(e=>{if("string"==typeof e){return void((""===e?t:He(t,e)).classGroupId=n)}if("function"==typeof e)return ze(e)?void je(e(r),t,n,r):void t.validators.push({validator:e,classGroupId:n});Object.entries(e).forEach(([e,i])=>{je(i,He(t,e),n,r)})})},He=(e,t)=>{let n=e;return t.split("-").forEach(e=>{n.nextPart.has(e)||n.nextPart.set(e,{nextPart:new Map,validators:[]}),n=n.nextPart.get(e)}),n},ze=e=>e.isThemeGetter,Ve=(e,t)=>t?e.map(([e,n])=>[e,n.map(e=>"string"==typeof e?t+e:"object"==typeof e?Object.fromEntries(Object.entries(e).map(([e,n])=>[t+e,n])):e)]):e,qe=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=new Map,r=new Map;const i=(i,o)=>{n.set(i,o),t++,t>e&&(t=0,r=n,n=new Map)};return{get(e){let t=n.get(e);return void 0!==t?t:void 0!==(t=r.get(e))?(i(e,t),t):void 0},set(e,t){n.has(e)?n.set(e,t):i(e,t)}}},Ue=e=>{const{separator:t,experimentalParseClassName:n}=e,r=1===t.length,i=t[0],o=t.length,s=e=>{const n=[];let s,a=0,l=0;for(let c=0;c<e.length;c++){let u=e[c];if(0===a){if(u===i&&(r||e.slice(c,c+o)===t)){n.push(e.slice(l,c)),l=c+o;continue}if("/"===u){s=c;continue}}"["===u?a++:"]"===u&&a--}const c=0===n.length?e:e.substring(l),u=c.startsWith("!");return{modifiers:n,hasImportantModifier:u,baseClassName:u?c.substring(1):c,maybePostfixModifierPosition:s&&s>l?s-l:void 0}};return n?e=>n({className:e,parseClassName:s}):s},Ke=e=>{if(e.length<=1)return e;const t=[];let n=[];return e.forEach(e=>{"["===e[0]?(t.push(...n.sort(),e),n=[]):n.push(e)}),t.push(...n.sort()),t},Ge=/\s+/;function Ye(){let e,t,n=0,r="";for(;n<arguments.length;)(e=arguments[n++])&&(t=$e(e))&&(r&&(r+=" "),r+=t);return r}const $e=e=>{if("string"==typeof e)return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=$e(e[r]))&&(n&&(n+=" "),n+=t);return n};function Xe(e,...t){let n,r,i,o=function(a){const l=t.reduce((e,t)=>t(e),e());return n=(e=>({cache:qe(e.cacheSize),parseClassName:Ue(e),...Be(e)}))(l),r=n.cache.get,i=n.cache.set,o=s,s(a)};function s(e){const t=r(e);if(t)return t;const o=((e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i}=t,o=[],s=e.trim().split(Ge);let a="";for(let e=s.length-1;e>=0;e-=1){const t=s[e],{modifiers:l,hasImportantModifier:c,baseClassName:u,maybePostfixModifierPosition:h}=n(t);let f=Boolean(h),d=r(f?u.substring(0,h):u);if(!d){if(!f){a=t+(a.length>0?" "+a:a);continue}if(d=r(u),!d){a=t+(a.length>0?" "+a:a);continue}f=!1}const p=Ke(l).join(":"),m=c?p+"!":p,g=m+d;if(o.includes(g))continue;o.push(g);const v=i(d,f);for(let e=0;e<v.length;++e){const t=v[e];o.push(m+t)}a=t+(a.length>0?" "+a:a)}return a})(e,n);return i(e,o),o}return function(){return o(Ye.apply(null,arguments))}}const Je=e=>{const t=t=>t[e]||[];return t.isThemeGetter=!0,t},Qe=/^\[(?:([a-z-]+):)?(.+)\]$/i,Ze=/^\d+\/\d+$/,et=new Set(["px","full","screen"]),tt=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,nt=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,rt=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,it=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,ot=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,st=e=>lt(e)||et.has(e)||Ze.test(e),at=e=>kt(e,"length",xt),lt=e=>Boolean(e)&&!Number.isNaN(Number(e)),ct=e=>kt(e,"number",lt),ut=e=>Boolean(e)&&Number.isInteger(Number(e)),ht=e=>e.endsWith("%")&&lt(e.slice(0,-1)),ft=e=>Qe.test(e),dt=e=>tt.test(e),pt=new Set(["length","size","percentage"]),mt=e=>kt(e,pt,St),gt=e=>kt(e,"position",St),vt=new Set(["image","url"]),yt=e=>kt(e,vt,Et),bt=e=>kt(e,"",Ct),wt=()=>!0,kt=(e,t,n)=>{const r=Qe.exec(e);return!!r&&(r[1]?"string"==typeof t?r[1]===t:t.has(r[1]):n(r[2]))},xt=e=>nt.test(e)&&!rt.test(e),St=()=>!1,Ct=e=>it.test(e),Et=e=>ot.test(e),At=Xe(()=>{const e=Je("colors"),t=Je("spacing"),n=Je("blur"),r=Je("brightness"),i=Je("borderColor"),o=Je("borderRadius"),s=Je("borderSpacing"),a=Je("borderWidth"),l=Je("contrast"),c=Je("grayscale"),u=Je("hueRotate"),h=Je("invert"),f=Je("gap"),d=Je("gradientColorStops"),p=Je("gradientColorStopPositions"),m=Je("inset"),g=Je("margin"),v=Je("opacity"),y=Je("padding"),b=Je("saturate"),w=Je("scale"),k=Je("sepia"),x=Je("skew"),S=Je("space"),C=Je("translate"),E=()=>["auto",ft,t],A=()=>[ft,t],M=()=>["",st,at],O=()=>["auto",lt,ft],N=()=>["","0",ft],T=()=>[lt,ft];return{cacheSize:500,separator:":",theme:{colors:[wt],spacing:[st,at],blur:["none","",dt,ft],brightness:T(),borderColor:[e],borderRadius:["none","","full",dt,ft],borderSpacing:A(),borderWidth:M(),contrast:T(),grayscale:N(),hueRotate:T(),invert:N(),gap:A(),gradientColorStops:[e],gradientColorStopPositions:[ht,at],inset:E(),margin:E(),opacity:T(),padding:A(),saturate:T(),scale:T(),sepia:N(),skew:T(),space:A(),translate:A()},classGroups:{aspect:[{aspect:["auto","square","video",ft]}],container:["container"],columns:[{columns:[dt]}],"break-after":[{"break-after":["auto","avoid","all","avoid-page","page","left","right","column"]}],"break-before":[{"break-before":["auto","avoid","all","avoid-page","page","left","right","column"]}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top",ft]}],overflow:[{overflow:["auto","hidden","clip","visible","scroll"]}],"overflow-x":[{"overflow-x":["auto","hidden","clip","visible","scroll"]}],"overflow-y":[{"overflow-y":["auto","hidden","clip","visible","scroll"]}],overscroll:[{overscroll:["auto","contain","none"]}],"overscroll-x":[{"overscroll-x":["auto","contain","none"]}],"overscroll-y":[{"overscroll-y":["auto","contain","none"]}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[m]}],"inset-x":[{"inset-x":[m]}],"inset-y":[{"inset-y":[m]}],start:[{start:[m]}],end:[{end:[m]}],top:[{top:[m]}],right:[{right:[m]}],bottom:[{bottom:[m]}],left:[{left:[m]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",ut,ft]}],basis:[{basis:E()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",ft]}],grow:[{grow:N()}],shrink:[{shrink:N()}],order:[{order:["first","last","none",ut,ft]}],"grid-cols":[{"grid-cols":[wt]}],"col-start-end":[{col:["auto",{span:["full",ut,ft]},ft]}],"col-start":[{"col-start":O()}],"col-end":[{"col-end":O()}],"grid-rows":[{"grid-rows":[wt]}],"row-start-end":[{row:["auto",{span:[ut,ft]},ft]}],"row-start":[{"row-start":O()}],"row-end":[{"row-end":O()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",ft]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",ft]}],gap:[{gap:[f]}],"gap-x":[{"gap-x":[f]}],"gap-y":[{"gap-y":[f]}],"justify-content":[{justify:["normal","start","end","center","between","around","evenly","stretch"]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal","start","end","center","between","around","evenly","stretch","baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":["start","end","center","between","around","evenly","stretch","baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[y]}],px:[{px:[y]}],py:[{py:[y]}],ps:[{ps:[y]}],pe:[{pe:[y]}],pt:[{pt:[y]}],pr:[{pr:[y]}],pb:[{pb:[y]}],pl:[{pl:[y]}],m:[{m:[g]}],mx:[{mx:[g]}],my:[{my:[g]}],ms:[{ms:[g]}],me:[{me:[g]}],mt:[{mt:[g]}],mr:[{mr:[g]}],mb:[{mb:[g]}],ml:[{ml:[g]}],"space-x":[{"space-x":[S]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[S]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",ft,t]}],"min-w":[{"min-w":[ft,t,"min","max","fit"]}],"max-w":[{"max-w":[ft,t,"none","full","min","max","fit","prose",{screen:[dt]},dt]}],h:[{h:[ft,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[ft,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[ft,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[ft,t,"auto","min","max","fit"]}],"font-size":[{text:["base",dt,at]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",ct]}],"font-family":[{font:[wt]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",ft]}],"line-clamp":[{"line-clamp":["none",lt,ct]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",st,ft]}],"list-image":[{"list-image":["none",ft]}],"list-style-type":[{list:["none","disc","decimal",ft]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[v]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[v]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:["solid","dashed","dotted","double","none","wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",st,at]}],"underline-offset":[{"underline-offset":["auto",st,ft]}],"text-decoration-color":[{decoration:[e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:A()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ft]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",ft]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[v]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top",gt]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",mt]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},yt]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[p]}],"gradient-via-pos":[{via:[p]}],"gradient-to-pos":[{to:[p]}],"gradient-from":[{from:[d]}],"gradient-via":[{via:[d]}],"gradient-to":[{to:[d]}],rounded:[{rounded:[o]}],"rounded-s":[{"rounded-s":[o]}],"rounded-e":[{"rounded-e":[o]}],"rounded-t":[{"rounded-t":[o]}],"rounded-r":[{"rounded-r":[o]}],"rounded-b":[{"rounded-b":[o]}],"rounded-l":[{"rounded-l":[o]}],"rounded-ss":[{"rounded-ss":[o]}],"rounded-se":[{"rounded-se":[o]}],"rounded-ee":[{"rounded-ee":[o]}],"rounded-es":[{"rounded-es":[o]}],"rounded-tl":[{"rounded-tl":[o]}],"rounded-tr":[{"rounded-tr":[o]}],"rounded-br":[{"rounded-br":[o]}],"rounded-bl":[{"rounded-bl":[o]}],"border-w":[{border:[a]}],"border-w-x":[{"border-x":[a]}],"border-w-y":[{"border-y":[a]}],"border-w-s":[{"border-s":[a]}],"border-w-e":[{"border-e":[a]}],"border-w-t":[{"border-t":[a]}],"border-w-r":[{"border-r":[a]}],"border-w-b":[{"border-b":[a]}],"border-w-l":[{"border-l":[a]}],"border-opacity":[{"border-opacity":[v]}],"border-style":[{border:["solid","dashed","dotted","double","none","hidden"]}],"divide-x":[{"divide-x":[a]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[a]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[v]}],"divide-style":[{divide:["solid","dashed","dotted","double","none"]}],"border-color":[{border:[i]}],"border-color-x":[{"border-x":[i]}],"border-color-y":[{"border-y":[i]}],"border-color-s":[{"border-s":[i]}],"border-color-e":[{"border-e":[i]}],"border-color-t":[{"border-t":[i]}],"border-color-r":[{"border-r":[i]}],"border-color-b":[{"border-b":[i]}],"border-color-l":[{"border-l":[i]}],"divide-color":[{divide:[i]}],"outline-style":[{outline:["","solid","dashed","dotted","double","none"]}],"outline-offset":[{"outline-offset":[st,ft]}],"outline-w":[{outline:[st,at]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:M()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[v]}],"ring-offset-w":[{"ring-offset":[st,at]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",dt,bt]}],"shadow-color":[{shadow:[wt]}],opacity:[{opacity:[v]}],"mix-blend":[{"mix-blend":["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity","plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"]}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[r]}],contrast:[{contrast:[l]}],"drop-shadow":[{"drop-shadow":["","none",dt,ft]}],grayscale:[{grayscale:[c]}],"hue-rotate":[{"hue-rotate":[u]}],invert:[{invert:[h]}],saturate:[{saturate:[b]}],sepia:[{sepia:[k]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[l]}],"backdrop-grayscale":[{"backdrop-grayscale":[c]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[u]}],"backdrop-invert":[{"backdrop-invert":[h]}],"backdrop-opacity":[{"backdrop-opacity":[v]}],"backdrop-saturate":[{"backdrop-saturate":[b]}],"backdrop-sepia":[{"backdrop-sepia":[k]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[s]}],"border-spacing-x":[{"border-spacing-x":[s]}],"border-spacing-y":[{"border-spacing-y":[s]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",ft]}],duration:[{duration:T()}],ease:[{ease:["linear","in","out","in-out",ft]}],delay:[{delay:T()}],animate:[{animate:["none","spin","ping","pulse","bounce",ft]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[w]}],"scale-x":[{"scale-x":[w]}],"scale-y":[{"scale-y":[w]}],rotate:[{rotate:[ut,ft]}],"translate-x":[{"translate-x":[C]}],"translate-y":[{"translate-y":[C]}],"skew-x":[{"skew-x":[x]}],"skew-y":[{"skew-y":[x]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",ft]}],accent:[{accent:["auto",e]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",ft]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":A()}],"scroll-mx":[{"scroll-mx":A()}],"scroll-my":[{"scroll-my":A()}],"scroll-ms":[{"scroll-ms":A()}],"scroll-me":[{"scroll-me":A()}],"scroll-mt":[{"scroll-mt":A()}],"scroll-mr":[{"scroll-mr":A()}],"scroll-mb":[{"scroll-mb":A()}],"scroll-ml":[{"scroll-ml":A()}],"scroll-p":[{"scroll-p":A()}],"scroll-px":[{"scroll-px":A()}],"scroll-py":[{"scroll-py":A()}],"scroll-ps":[{"scroll-ps":A()}],"scroll-pe":[{"scroll-pe":A()}],"scroll-pt":[{"scroll-pt":A()}],"scroll-pr":[{"scroll-pr":A()}],"scroll-pb":[{"scroll-pb":A()}],"scroll-pl":[{"scroll-pl":A()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",ft]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[st,at,ct]}],stroke:[{stroke:[e,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}});function Mt(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return At(Le(t))}function Ot(t){var n=t.className,r=Z(t,["className"]);return e.createElement("div",Object.assign({className:Mt("animate-pulse rounded-md bg-muted",n)},r))}function Nt(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function Tt(...e){return t=>{let n=!1;const r=e.map(e=>{const r=Nt(e,t);return n||"function"!=typeof r||(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){const n=r[t];"function"==typeof n?n():Nt(e[t],null)}}}}function Rt(...t){return e.useCallback(Tt(...t),t)}var Dt=Symbol.for("react.lazy"),Pt=e[" use ".trim().toString()];function Lt(e){return null!=e&&"object"==typeof e&&"$$typeof"in e&&e.$$typeof===Dt&&"_payload"in e&&("object"==typeof(t=e._payload)&&null!==t&&"then"in t);var t}function Bt(t){const n=_t(t),r=e.forwardRef((t,r)=>{let{children:i,...o}=t;Lt(i)&&"function"==typeof Pt&&(i=Pt(i._payload));const s=e.Children.toArray(i),a=s.find(Wt);if(a){const t=a.props.children,i=s.map(n=>n===a?e.Children.count(t)>1?e.Children.only(null):e.isValidElement(t)?t.props.children:null:n);return d(n,{...o,ref:r,children:e.isValidElement(t)?e.cloneElement(t,void 0,i):null})}return d(n,{...o,ref:r,children:i})});return r.displayName=`${t}.Slot`,r}var It=Bt("Slot");function _t(t){const n=e.forwardRef((t,n)=>{let{children:r,...i}=t;if(Lt(r)&&"function"==typeof Pt&&(r=Pt(r._payload)),e.isValidElement(r)){const t=function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;if(n)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(r),o=function(e,t){const n={...t};for(const r in t){const i=e[r],o=t[r];/^on[A-Z]/.test(r)?i&&o?n[r]=(...e)=>{const t=o(...e);return i(...e),t}:i&&(n[r]=i):"style"===r?n[r]={...i,...o}:"className"===r&&(n[r]=[i,o].filter(Boolean).join(" "))}return{...e,...n}}(i,r.props);return r.type!==e.Fragment&&(o.ref=n?Tt(n,t):t),e.cloneElement(r,o)}return e.Children.count(r)>1?e.Children.only(null):null});return n.displayName=`${t}.SlotClone`,n}var Ft=Symbol("radix.slottable");function Wt(t){return e.isValidElement(t)&&"function"==typeof t.type&&"__radixId"in t.type&&t.type.__radixId===Ft}const jt=e=>"boolean"==typeof e?`${e}`:0===e?"0":e,Ht=Le,zt=(e,t)=>n=>{var r;if(null==(null==t?void 0:t.variants))return Ht(e,null==n?void 0:n.class,null==n?void 0:n.className);const{variants:i,defaultVariants:o}=t,s=Object.keys(i).map(e=>{const t=null==n?void 0:n[e],r=null==o?void 0:o[e];if(null===t)return null;const s=jt(t)||jt(r);return i[e][s]}),a=n&&Object.entries(n).reduce((e,t)=>{let[n,r]=t;return void 0===r||(e[n]=r),e},{}),l=null==t||null===(r=t.compoundVariants)||void 0===r?void 0:r.reduce((e,t)=>{let{class:n,className:r,...i}=t;return Object.entries(i).every(e=>{let[t,n]=e;return Array.isArray(n)?n.includes({...o,...a}[t]):{...o,...a}[t]===n})?[...e,n,r]:e},[]);return Ht(e,s,l,null==n?void 0:n.class,null==n?void 0:n.className)};var Vt=zt("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-full text-sm font-bold transition-all duration-300 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[hsl(var(--primary))]/30 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-[0_4px_20px_-2px_rgba(93,112,82,0.15)] hover:scale-105 hover:shadow-[0_6px_24px_-4px_rgba(93,112,82,0.25)] active:scale-95",destructive:"bg-destructive text-destructive-foreground shadow-[0_4px_20px_-2px_rgba(168,84,72,0.15)] hover:scale-105 hover:shadow-[0_6px_24px_-4px_rgba(168,84,72,0.25)] active:scale-95",outline:"border-2 border-secondary bg-transparent text-secondary hover:bg-secondary/10 hover:scale-105 active:scale-95",secondary:"bg-secondary text-secondary-foreground shadow-[0_4px_20px_-2px_rgba(193,140,93,0.15)] hover:scale-105 hover:shadow-[0_6px_24px_-4px_rgba(193,140,93,0.25)] active:scale-95",ghost:"bg-transparent text-primary hover:bg-primary/10 hover:scale-105 active:scale-95",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-12 px-8 py-2",sm:"h-10 px-6 text-sm",lg:"h-14 px-10 text-base",icon:"h-12 w-12"}},defaultVariants:{variant:"default",size:"default"}}),qt=e.forwardRef(function(t,n){var r=t.className,i=t.variant,o=t.size,s=t.asChild,a=void 0!==s&&s,l=Z(t,["className","variant","size","asChild"]),c=a?It:"button";return e.createElement(c,Object.assign({className:Mt(Vt({variant:i,size:o,className:r})),ref:n},l))});qt.displayName="Button";var Ut=e.forwardRef(function(t,n){var r=t.className,i=t.type,o=Z(t,["className","type"]);return e.createElement("input",Object.assign({type:i,className:Mt("flex h-12 w-full rounded-full border border-input bg-background px-6 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[hsl(var(--primary))]/30 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 transition-all duration-300 md:text-sm",r),ref:n},o))});Ut.displayName="Input";var Kt=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((t,n)=>{const r=Bt(`Primitive.${n}`),i=e.forwardRef((e,t)=>{const{asChild:i,...o}=e,s=i?r:n;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),d(s,{...o,ref:t})});return i.displayName=`Primitive.${n}`,{...t,[n]:i}},{}),Gt="horizontal",Yt=["horizontal","vertical"],$t=e.forwardRef((e,t)=>{const{decorative:n,orientation:r=Gt,...i}=e,o=function(e){return Yt.includes(e)}(r)?r:Gt,s=n?{role:"none"}:{"aria-orientation":"vertical"===o?o:void 0,role:"separator"};return d(Kt.div,{"data-orientation":o,...s,...i,ref:t})});$t.displayName="Separator";var Xt=$t,Jt=e.forwardRef(function(t,n){var r=t.className,i=t.orientation,o=void 0===i?"horizontal":i,s=t.decorative,a=void 0===s||s,l=Z(t,["className","orientation","decorative"]);return e.createElement(Xt,Object.assign({ref:n,decorative:a,orientation:o,className:Mt("shrink-0 bg-border","horizontal"===o?"h-[1px] w-full":"h-full w-[1px]",r)},l))});function Qt(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),!1===n||!r.defaultPrevented)return t?.(r)}}function Zt(t,n=[]){let r=[];const i=()=>{const n=r.map(t=>e.createContext(t));return function(r){const i=r?.[t]||n;return e.useMemo(()=>({[`__scope${t}`]:{...r,[t]:i}}),[r,i])}};return i.scopeName=t,[function(n,i){const o=e.createContext(i),s=r.length;r=[...r,i];const a=n=>{const{scope:r,children:i,...a}=n,l=r?.[t]?.[s]||o,c=e.useMemo(()=>a,Object.values(a));return d(l.Provider,{value:c,children:i})};return a.displayName=n+"Provider",[a,function(r,a){const l=a?.[t]?.[s]||o,c=e.useContext(l);if(c)return c;if(void 0!==i)return i;throw new Error(`\`${r}\` must be used within \`${n}\``)}]},en(i,...n)]}function en(...t){const n=t[0];if(1===t.length)return n;const r=()=>{const r=t.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(t){const i=r.reduce((e,{useScope:n,scopeName:r})=>({...e,...n(t)[`__scope${r}`]}),{});return e.useMemo(()=>({[`__scope${n.scopeName}`]:i}),[i])}};return r.scopeName=n.scopeName,r}Jt.displayName=Xt.displayName;var tn=globalThis?.document?e.useLayoutEffect:()=>{},nn=e[" useId ".trim().toString()]||(()=>{}),rn=0;function on(t){const[n,r]=e.useState(nn());return tn(()=>{t||r(e=>e??String(rn++))},[t]),t||(n?`radix-${n}`:"")}var sn=e[" useInsertionEffect ".trim().toString()]||tn;function an({prop:t,defaultProp:n,onChange:r=()=>{},caller:i}){const[o,s,a]=function({defaultProp:t,onChange:n}){const[r,i]=e.useState(t),o=e.useRef(r),s=e.useRef(n);return sn(()=>{s.current=n},[n]),e.useEffect(()=>{o.current!==r&&(s.current?.(r),o.current=r)},[r,o]),[r,i,s]}({defaultProp:n,onChange:r}),l=void 0!==t,c=l?t:o;{const n=e.useRef(void 0!==t);e.useEffect(()=>{const e=n.current;if(e!==l){}n.current=l},[l,i])}const u=e.useCallback(e=>{if(l){const n=function(e){return"function"==typeof e}(e)?e(t):e;n!==t&&a.current?.(n)}else s(e)},[l,t,s,a]);return[c,u]}function ln(t){const n=cn(t),r=e.forwardRef((t,r)=>{const{children:i,...o}=t,s=e.Children.toArray(i),a=s.find(hn);if(a){const t=a.props.children,i=s.map(n=>n===a?e.Children.count(t)>1?e.Children.only(null):e.isValidElement(t)?t.props.children:null:n);return d(n,{...o,ref:r,children:e.isValidElement(t)?e.cloneElement(t,void 0,i):null})}return d(n,{...o,ref:r,children:i})});return r.displayName=`${t}.Slot`,r}function cn(t){const n=e.forwardRef((t,n)=>{const{children:r,...i}=t;if(e.isValidElement(r)){const t=function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;if(n)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(r),o=function(e,t){const n={...t};for(const r in t){const i=e[r],o=t[r];/^on[A-Z]/.test(r)?i&&o?n[r]=(...e)=>{const t=o(...e);return i(...e),t}:i&&(n[r]=i):"style"===r?n[r]={...i,...o}:"className"===r&&(n[r]=[i,o].filter(Boolean).join(" "))}return{...e,...n}}(i,r.props);return r.type!==e.Fragment&&(o.ref=n?Tt(n,t):t),e.cloneElement(r,o)}return e.Children.count(r)>1?e.Children.only(null):null});return n.displayName=`${t}.SlotClone`,n}var un=Symbol("radix.slottable");function hn(t){return e.isValidElement(t)&&"function"==typeof t.type&&"__radixId"in t.type&&t.type.__radixId===un}var fn=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((t,n)=>{const r=ln(`Primitive.${n}`),i=e.forwardRef((e,t)=>{const{asChild:i,...o}=e,s=i?r:n;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),d(s,{...o,ref:t})});return i.displayName=`Primitive.${n}`,{...t,[n]:i}},{});function dn(e,t){e&&g.flushSync(()=>e.dispatchEvent(t))}function pn(t){const n=e.useRef(t);return e.useEffect(()=>{n.current=t}),e.useMemo(()=>(...e)=>n.current?.(...e),[])}var mn,gn="dismissableLayer.update",vn="dismissableLayer.pointerDownOutside",yn="dismissableLayer.focusOutside",bn=e.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),wn=e.forwardRef((t,n)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:a,onDismiss:l,...c}=t,u=e.useContext(bn),[h,f]=e.useState(null),p=h?.ownerDocument??globalThis?.document,[,m]=e.useState({}),g=Rt(n,e=>f(e)),v=Array.from(u.layers),[y]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),b=v.indexOf(y),w=h?v.indexOf(h):-1,k=u.layersWithOutsidePointerEventsDisabled.size>0,x=w>=b,S=function(t,n=globalThis?.document){const r=pn(t),i=e.useRef(!1),o=e.useRef(()=>{});return e.useEffect(()=>{const e=e=>{if(e.target&&!i.current){let t=function(){xn(vn,r,i,{discrete:!0})};const i={originalEvent:e};"touch"===e.pointerType?(n.removeEventListener("click",o.current),o.current=t,n.addEventListener("click",o.current,{once:!0})):t()}else n.removeEventListener("click",o.current);i.current=!1},t=window.setTimeout(()=>{n.addEventListener("pointerdown",e)},0);return()=>{window.clearTimeout(t),n.removeEventListener("pointerdown",e),n.removeEventListener("click",o.current)}},[n,r]),{onPointerDownCapture:()=>i.current=!0}}(e=>{const t=e.target,n=[...u.branches].some(e=>e.contains(t));x&&!n&&(o?.(e),a?.(e),e.defaultPrevented||l?.())},p),C=function(t,n=globalThis?.document){const r=pn(t),i=e.useRef(!1);return e.useEffect(()=>{const e=e=>{if(e.target&&!i.current){xn(yn,r,{originalEvent:e},{discrete:!1})}};return n.addEventListener("focusin",e),()=>n.removeEventListener("focusin",e)},[n,r]),{onFocusCapture:()=>i.current=!0,onBlurCapture:()=>i.current=!1}}(e=>{const t=e.target;[...u.branches].some(e=>e.contains(t))||(s?.(e),a?.(e),e.defaultPrevented||l?.())},p);return function(t,n=globalThis?.document){const r=pn(t);e.useEffect(()=>{const e=e=>{"Escape"===e.key&&r(e)};return n.addEventListener("keydown",e,{capture:!0}),()=>n.removeEventListener("keydown",e,{capture:!0})},[r,n])}(e=>{w===u.layers.size-1&&(i?.(e),!e.defaultPrevented&&l&&(e.preventDefault(),l()))},p),e.useEffect(()=>{if(h)return r&&(0===u.layersWithOutsidePointerEventsDisabled.size&&(mn=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(h)),u.layers.add(h),kn(),()=>{r&&1===u.layersWithOutsidePointerEventsDisabled.size&&(p.body.style.pointerEvents=mn)}},[h,p,r,u]),e.useEffect(()=>()=>{h&&(u.layers.delete(h),u.layersWithOutsidePointerEventsDisabled.delete(h),kn())},[h,u]),e.useEffect(()=>{const e=()=>m({});return document.addEventListener(gn,e),()=>document.removeEventListener(gn,e)},[]),d(fn.div,{...c,ref:g,style:{pointerEvents:k?x?"auto":"none":void 0,...t.style},onFocusCapture:Qt(t.onFocusCapture,C.onFocusCapture),onBlurCapture:Qt(t.onBlurCapture,C.onBlurCapture),onPointerDownCapture:Qt(t.onPointerDownCapture,S.onPointerDownCapture)})});wn.displayName="DismissableLayer";function kn(){const e=new CustomEvent(gn);document.dispatchEvent(e)}function xn(e,t,n,{discrete:r}){const i=n.originalEvent.target,o=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?dn(i,o):i.dispatchEvent(o)}e.forwardRef((t,n)=>{const r=e.useContext(bn),i=e.useRef(null),o=Rt(n,i);return e.useEffect(()=>{const e=i.current;if(e)return r.branches.add(e),()=>{r.branches.delete(e)}},[r.branches]),d(fn.div,{...t,ref:o})}).displayName="DismissableLayerBranch";var Sn="focusScope.autoFocusOnMount",Cn="focusScope.autoFocusOnUnmount",En={bubbles:!1,cancelable:!0},An=e.forwardRef((t,n)=>{const{loop:r=!1,trapped:i=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...a}=t,[l,c]=e.useState(null),u=pn(o),h=pn(s),f=e.useRef(null),p=Rt(n,e=>c(e)),m=e.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;e.useEffect(()=>{if(i){let e=function(e){if(m.paused||!l)return;const t=e.target;l.contains(t)?f.current=t:Tn(f.current,{select:!0})},t=function(e){if(m.paused||!l)return;const t=e.relatedTarget;null!==t&&(l.contains(t)||Tn(f.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(const t of e)t.removedNodes.length>0&&Tn(l)};document.addEventListener("focusin",e),document.addEventListener("focusout",t);const r=new MutationObserver(n);return l&&r.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",e),document.removeEventListener("focusout",t),r.disconnect()}}},[i,l,m.paused]),e.useEffect(()=>{if(l){Rn.add(m);const t=document.activeElement;if(!l.contains(t)){const n=new CustomEvent(Sn,En);l.addEventListener(Sn,u),l.dispatchEvent(n),n.defaultPrevented||(!function(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Tn(r,{select:t}),document.activeElement!==n)return}((e=Mn(l),e.filter(e=>"A"!==e.tagName)),{select:!0}),document.activeElement===t&&Tn(l))}return()=>{l.removeEventListener(Sn,u),setTimeout(()=>{const e=new CustomEvent(Cn,En);l.addEventListener(Cn,h),l.dispatchEvent(e),e.defaultPrevented||Tn(t??document.body,{select:!0}),l.removeEventListener(Cn,h),Rn.remove(m)},0)}}var e},[l,u,h,m]);const g=e.useCallback(e=>{if(!r&&!i)return;if(m.paused)return;const t="Tab"===e.key&&!e.altKey&&!e.ctrlKey&&!e.metaKey,n=document.activeElement;if(t&&n){const t=e.currentTarget,[i,o]=function(e){const t=Mn(e),n=On(t,e),r=On(t.reverse(),e);return[n,r]}(t);i&&o?e.shiftKey||n!==o?e.shiftKey&&n===i&&(e.preventDefault(),r&&Tn(o,{select:!0})):(e.preventDefault(),r&&Tn(i,{select:!0})):n===t&&e.preventDefault()}},[r,i,m.paused]);return d(fn.div,{tabIndex:-1,...a,ref:p,onKeyDown:g})});function Mn(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{const t="INPUT"===e.tagName&&"hidden"===e.type;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function On(e,t){for(const n of e)if(!Nn(n,{upTo:t}))return n}function Nn(e,{upTo:t}){if("hidden"===getComputedStyle(e).visibility)return!0;for(;e;){if(void 0!==t&&e===t)return!1;if("none"===getComputedStyle(e).display)return!0;e=e.parentElement}return!1}function Tn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&function(e){return e instanceof HTMLInputElement&&"select"in e}(e)&&t&&e.select()}}An.displayName="FocusScope";var Rn=function(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=Dn(e,t),e.unshift(t)},remove(t){e=Dn(e,t),e[0]?.resume()}}}();function Dn(e,t){const n=[...e],r=n.indexOf(t);return-1!==r&&n.splice(r,1),n}var Pn=e.forwardRef((t,n)=>{const{container:r,...i}=t,[o,s]=e.useState(!1);tn(()=>s(!0),[]);const a=r||o&&globalThis?.document?.body;return a?v.createPortal(d(fn.div,{...i,ref:n}),a):null});Pn.displayName="Portal";var Ln=t=>{const{present:n,children:r}=t,i=function(t){const[n,r]=e.useState(),i=e.useRef(null),o=e.useRef(t),s=e.useRef("none"),a=t?"mounted":"unmounted",[l,c]=function(t,n){return e.useReducer((e,t)=>n[e][t]??e,t)}(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return e.useEffect(()=>{const e=Bn(i.current);s.current="mounted"===l?e:"none"},[l]),tn(()=>{const e=i.current,n=o.current;if(n!==t){const r=s.current,i=Bn(e);if(t)c("MOUNT");else if("none"===i||"none"===e?.display)c("UNMOUNT");else{c(n&&r!==i?"ANIMATION_OUT":"UNMOUNT")}o.current=t}},[t,c]),tn(()=>{if(n){let e;const t=n.ownerDocument.defaultView??window,r=r=>{const s=Bn(i.current).includes(CSS.escape(r.animationName));if(r.target===n&&s&&(c("ANIMATION_END"),!o.current)){const r=n.style.animationFillMode;n.style.animationFillMode="forwards",e=t.setTimeout(()=>{"forwards"===n.style.animationFillMode&&(n.style.animationFillMode=r)})}},a=e=>{e.target===n&&(s.current=Bn(i.current))};return n.addEventListener("animationstart",a),n.addEventListener("animationcancel",r),n.addEventListener("animationend",r),()=>{t.clearTimeout(e),n.removeEventListener("animationstart",a),n.removeEventListener("animationcancel",r),n.removeEventListener("animationend",r)}}c("ANIMATION_END")},[n,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:e.useCallback(e=>{i.current=e?getComputedStyle(e):null,r(e)},[])}}(n),o="function"==typeof r?r({present:i.isPresent}):e.Children.only(r),s=Rt(i.ref,function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;if(n)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(o));return"function"==typeof r||i.isPresent?e.cloneElement(o,{ref:s}):null};function Bn(e){return e?.animationName||"none"}Ln.displayName="Presence";var In=0;function _n(){e.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Fn()),document.body.insertAdjacentElement("beforeend",e[1]??Fn()),In++,()=>{1===In&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),In--}},[])}function Fn(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Wn="right-scroll-bar-position",jn="width-before-scroll-bar";function Hn(e,t){return"function"==typeof e?e(t):e&&(e.current=t),e}var zn="undefined"!=typeof window?e.useLayoutEffect:e.useEffect,Vn=new WeakMap;function qn(e,t){var n,r,o,s=(n=t||null,r=function(t){return e.forEach(function(e){return Hn(e,t)})},(o=i(function(){return{value:n,callback:r,facade:{get current(){return o.value},set current(e){var t=o.value;t!==e&&(o.value=e,o.callback(e,t))}}}})[0]).callback=r,o.facade);return zn(function(){var t=Vn.get(s);if(t){var n=new Set(t),r=new Set(e),i=s.current;n.forEach(function(e){r.has(e)||Hn(e,null)}),r.forEach(function(e){n.has(e)||Hn(e,i)})}Vn.set(s,e)},[e]),s}function Un(e){return e}var Kn=function(t){var n=t.sideCar,r=Z(t,["sideCar"]);if(!n)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var i=n.read();if(!i)throw new Error("Sidecar medium not found");return e.createElement(i,Q({},r))};Kn.isSideCarExport=!0;var Gn=function(e){void 0===e&&(e={});var t=function(e,t){void 0===t&&(t=Un);var n=[],r=!1;return{read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var i=t(e,r);return n.push(i),function(){n=n.filter(function(e){return e!==i})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var i=n;n=[],i.forEach(e),t=n}var o=function(){var n=t;t=[],n.forEach(e)},s=function(){return Promise.resolve().then(o)};s(),n={push:function(e){t.push(e),s()},filter:function(e){return t=t.filter(e),n}}}}}(null);return t.options=Q({async:!0,ssr:!1},e),t}(),Yn=function(){},$n=e.forwardRef(function(t,n){var r=e.useRef(null),i=e.useState({onScrollCapture:Yn,onWheelCapture:Yn,onTouchMoveCapture:Yn}),o=i[0],s=i[1],a=t.forwardProps,l=t.children,c=t.className,u=t.removeScrollBar,h=t.enabled,f=t.shards,d=t.sideCar,p=t.noRelative,m=t.noIsolation,g=t.inert,v=t.allowPinchZoom,y=t.as,b=void 0===y?"div":y,w=t.gapMode,k=Z(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),x=d,S=qn([r,n]),C=Q(Q({},k),o);return e.createElement(e.Fragment,null,h&&e.createElement(x,{sideCar:Gn,removeScrollBar:u,shards:f,noRelative:p,noIsolation:m,inert:g,setCallbacks:s,allowPinchZoom:!!v,lockRef:r,gapMode:w}),a?e.cloneElement(e.Children.only(l),Q(Q({},C),{ref:S})):e.createElement(b,Q({},C,{className:c,ref:S}),l))});$n.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},$n.classNames={fullWidth:jn,zeroRight:Wn};function Xn(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=function(){if("undefined"!=typeof __webpack_nonce__)return __webpack_nonce__}();return t&&e.setAttribute("nonce",t),e}var Jn=function(){var e=0,t=null;return{add:function(n){var r,i;0==e&&(t=Xn())&&(i=n,(r=t).styleSheet?r.styleSheet.cssText=i:r.appendChild(document.createTextNode(i)),function(e){(document.head||document.getElementsByTagName("head")[0]).appendChild(e)}(t)),e++},remove:function(){! --e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Qn=function(){var t,n=(t=Jn(),function(n,r){e.useEffect(function(){return t.add(n),function(){t.remove()}},[n&&r])});return function(e){var t=e.styles,r=e.dynamic;return n(t,r),null}},Zn={left:0,top:0,right:0,gap:0},er=function(e){return parseInt(e||"",10)||0},tr=function(e){if(void 0===e&&(e="margin"),"undefined"==typeof window)return Zn;var t=function(e){var t=window.getComputedStyle(document.body),n=t["padding"===e?"paddingLeft":"marginLeft"],r=t["padding"===e?"paddingTop":"marginTop"],i=t["padding"===e?"paddingRight":"marginRight"];return[er(n),er(r),er(i)]}(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},nr=Qn(),rr="data-scroll-locked",ir=function(e,t,n,r){var i=e.left,o=e.top,s=e.right,a=e.gap;return void 0===n&&(n="margin"),"\n .".concat("with-scroll-bars-hidden"," {\n overflow: hidden ").concat(r,";\n padding-right: ").concat(a,"px ").concat(r,";\n }\n body[").concat(rr,"] {\n overflow: hidden ").concat(r,";\n overscroll-behavior: contain;\n ").concat([t&&"position: relative ".concat(r,";"),"margin"===n&&"\n padding-left: ".concat(i,"px;\n padding-top: ").concat(o,"px;\n padding-right: ").concat(s,"px;\n margin-left:0;\n margin-top:0;\n margin-right: ").concat(a,"px ").concat(r,";\n "),"padding"===n&&"padding-right: ".concat(a,"px ").concat(r,";")].filter(Boolean).join(""),"\n }\n \n .").concat(Wn," {\n right: ").concat(a,"px ").concat(r,";\n }\n \n .").concat(jn," {\n margin-right: ").concat(a,"px ").concat(r,";\n }\n \n .").concat(Wn," .").concat(Wn," {\n right: 0 ").concat(r,";\n }\n \n .").concat(jn," .").concat(jn," {\n margin-right: 0 ").concat(r,";\n }\n \n body[").concat(rr,"] {\n ").concat("--removed-body-scroll-bar-size",": ").concat(a,"px;\n }\n")},or=function(){var e=parseInt(document.body.getAttribute(rr)||"0",10);return isFinite(e)?e:0},sr=function(t){var n=t.noRelative,r=t.noImportant,i=t.gapMode,o=void 0===i?"margin":i;e.useEffect(function(){return document.body.setAttribute(rr,(or()+1).toString()),function(){var e=or()-1;e<=0?document.body.removeAttribute(rr):document.body.setAttribute(rr,e.toString())}},[]);var s=e.useMemo(function(){return tr(o)},[o]);return e.createElement(nr,{styles:ir(s,!n,o,r?"":"!important")})},ar=!1;if("undefined"!=typeof window)try{var lr=Object.defineProperty({},"passive",{get:function(){return ar=!0,!0}});window.addEventListener("test",lr,lr),window.removeEventListener("test",lr,lr)}catch(e){ar=!1}var cr=!!ar&&{passive:!1},ur=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return"hidden"!==n[t]&&!(n.overflowY===n.overflowX&&!function(e){return"TEXTAREA"===e.tagName}(e)&&"visible"===n[t])},hr=function(e,t){var n=t.ownerDocument,r=t;do{if("undefined"!=typeof ShadowRoot&&r instanceof ShadowRoot&&(r=r.host),fr(e,r)){var i=dr(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},fr=function(e,t){return"v"===e?function(e){return ur(e,"overflowY")}(t):function(e){return ur(e,"overflowX")}(t)},dr=function(e,t){return"v"===e?function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]}(t):function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]}(t)},pr=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},mr=function(e){return[e.deltaX,e.deltaY]},gr=function(e){return e&&"current"in e?e.current:e},vr=function(e){return"\n .block-interactivity-".concat(e," {pointer-events: none;}\n .allow-interactivity-").concat(e," {pointer-events: all;}\n")},yr=0,br=[];function wr(e){for(var t=null;null!==e;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var kr,xr=(kr=function(t){var n=e.useRef([]),r=e.useRef([0,0]),i=e.useRef(),o=e.useState(yr++)[0],s=e.useState(Qn)[0],a=e.useRef(t);e.useEffect(function(){a.current=t},[t]),e.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(o));var e=function(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}([t.lockRef.current],(t.shards||[]).map(gr),!0).filter(Boolean);return e.forEach(function(e){return e.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),e.forEach(function(e){return e.classList.remove("allow-interactivity-".concat(o))})}}},[t.inert,t.lockRef.current,t.shards]);var l=e.useCallback(function(e,t){if("touches"in e&&2===e.touches.length||"wheel"===e.type&&e.ctrlKey)return!a.current.allowPinchZoom;var n,o=pr(e),s=r.current,l="deltaX"in e?e.deltaX:s[0]-o[0],c="deltaY"in e?e.deltaY:s[1]-o[1],u=e.target,h=Math.abs(l)>Math.abs(c)?"h":"v";if("touches"in e&&"h"===h&&"range"===u.type)return!1;var f=window.getSelection(),d=f&&f.anchorNode;if(d&&(d===u||d.contains(u)))return!1;var p=hr(h,u);if(!p)return!0;if(p?n=h:(n="v"===h?"h":"v",p=hr(h,u)),!p)return!1;if(!i.current&&"changedTouches"in e&&(l||c)&&(i.current=n),!n)return!0;var m=i.current||n;return function(e,t,n,r,i){var o=function(e,t){return"h"===e&&"rtl"===t?-1:1}(e,window.getComputedStyle(t).direction),s=o*r,a=n.target,l=t.contains(a),c=!1,u=s>0,h=0,f=0;do{if(!a)break;var d=dr(e,a),p=d[0],m=d[1]-d[2]-o*p;(p||m)&&fr(e,a)&&(h+=m,f+=p);var g=a.parentNode;a=g&&g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.host:g}while(!l&&a!==document.body||l&&(t.contains(a)||t===a));return(u&&(i&&Math.abs(h)<1||!i&&s>h)||!u&&(i&&Math.abs(f)<1||!i&&-s>f))&&(c=!0),c}(m,t,e,"h"===m?l:c,!0)},[]),c=e.useCallback(function(e){var t=e;if(br.length&&br[br.length-1]===s){var r="deltaY"in t?mr(t):pr(t),i=n.current.filter(function(e){return e.name===t.type&&(e.target===t.target||t.target===e.shadowParent)&&(n=e.delta,i=r,n[0]===i[0]&&n[1]===i[1]);var n,i})[0];if(i&&i.should)t.cancelable&&t.preventDefault();else if(!i){var o=(a.current.shards||[]).map(gr).filter(Boolean).filter(function(e){return e.contains(t.target)});(o.length>0?l(t,o[0]):!a.current.noIsolation)&&t.cancelable&&t.preventDefault()}}},[]),u=e.useCallback(function(e,t,r,i){var o={name:e,delta:t,target:r,should:i,shadowParent:wr(r)};n.current.push(o),setTimeout(function(){n.current=n.current.filter(function(e){return e!==o})},1)},[]),h=e.useCallback(function(e){r.current=pr(e),i.current=void 0},[]),f=e.useCallback(function(e){u(e.type,mr(e),e.target,l(e,t.lockRef.current))},[]),d=e.useCallback(function(e){u(e.type,pr(e),e.target,l(e,t.lockRef.current))},[]);e.useEffect(function(){return br.push(s),t.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:d}),document.addEventListener("wheel",c,cr),document.addEventListener("touchmove",c,cr),document.addEventListener("touchstart",h,cr),function(){br=br.filter(function(e){return e!==s}),document.removeEventListener("wheel",c,cr),document.removeEventListener("touchmove",c,cr),document.removeEventListener("touchstart",h,cr)}},[]);var p=t.removeScrollBar,m=t.inert;return e.createElement(e.Fragment,null,m?e.createElement(s,{styles:vr(o)}):null,p?e.createElement(sr,{noRelative:t.noRelative,gapMode:t.gapMode}):null)},Gn.useMedium(kr),Kn),Sr=e.forwardRef(function(t,n){return e.createElement($n,Q({},t,{ref:n,sideCar:xr}))});Sr.classNames=$n.classNames;var Cr=Sr,Er=new WeakMap,Ar=new WeakMap,Mr={},Or=0,Nr=function(e){return e&&(e.host||Nr(e.parentNode))},Tr=function(e,t,n,r){var i=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=Nr(t);return n&&e.contains(n)?n:null}).filter(function(e){return Boolean(e)})}(t,Array.isArray(e)?e:[e]);Mr[n]||(Mr[n]=new WeakMap);var o=Mr[n],s=[],a=new Set,l=new Set(i),c=function(e){e&&!a.has(e)&&(a.add(e),c(e.parentNode))};i.forEach(c);var u=function(e){e&&!l.has(e)&&Array.prototype.forEach.call(e.children,function(e){if(a.has(e))u(e);else try{var t=e.getAttribute(r),i=null!==t&&"false"!==t,l=(Er.get(e)||0)+1,c=(o.get(e)||0)+1;Er.set(e,l),o.set(e,c),s.push(e),1===l&&i&&Ar.set(e,!0),1===c&&e.setAttribute(n,"true"),i||e.setAttribute(r,"true")}catch(e){}})};return u(t),a.clear(),Or++,function(){s.forEach(function(e){var t=Er.get(e)-1,i=o.get(e)-1;Er.set(e,t),o.set(e,i),t||(Ar.has(e)||e.removeAttribute(r),Ar.delete(e)),i||e.removeAttribute(n)}),--Or||(Er=new WeakMap,Er=new WeakMap,Ar=new WeakMap,Mr={})}},Rr=function(e,t,n){void 0===n&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),i=t||function(e){return"undefined"==typeof document?null:(Array.isArray(e)?e[0]:e).ownerDocument.body}(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll("[aria-live], script"))),Tr(r,i,n,"aria-hidden")):function(){return null}},Dr="Dialog",[Pr,Lr]=Zt(Dr),[Br,Ir]=Pr(Dr),_r=t=>{const{__scopeDialog:n,children:r,open:i,defaultOpen:o,onOpenChange:s,modal:a=!0}=t,l=e.useRef(null),c=e.useRef(null),[u,h]=an({prop:i,defaultProp:o??!1,onChange:s,caller:Dr});return d(Br,{scope:n,triggerRef:l,contentRef:c,contentId:on(),titleId:on(),descriptionId:on(),open:u,onOpenChange:h,onOpenToggle:e.useCallback(()=>h(e=>!e),[h]),modal:a,children:r})};_r.displayName=Dr;var Fr="DialogTrigger",Wr=e.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Ir(Fr,n),o=Rt(t,i.triggerRef);return d(fn.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":oi(i.open),...r,ref:o,onClick:Qt(e.onClick,i.onOpenToggle)})});Wr.displayName=Fr;var jr="DialogPortal",[Hr,zr]=Pr(jr,{forceMount:void 0}),Vr=t=>{const{__scopeDialog:n,forceMount:r,children:i,container:o}=t,s=Ir(jr,n);return d(Hr,{scope:n,forceMount:r,children:e.Children.map(i,e=>d(Ln,{present:r||s.open,children:d(Pn,{asChild:!0,container:o,children:e})}))})};Vr.displayName=jr;var qr="DialogOverlay",Ur=e.forwardRef((e,t)=>{const n=zr(qr,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,o=Ir(qr,e.__scopeDialog);return o.modal?d(Ln,{present:r||o.open,children:d(Gr,{...i,ref:t})}):null});Ur.displayName=qr;var Kr=ln("DialogOverlay.RemoveScroll"),Gr=e.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Ir(qr,n);return d(Cr,{as:Kr,allowPinchZoom:!0,shards:[i.contentRef],children:d(fn.div,{"data-state":oi(i.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),Yr="DialogContent",$r=e.forwardRef((e,t)=>{const n=zr(Yr,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,o=Ir(Yr,e.__scopeDialog);return d(Ln,{present:r||o.open,children:o.modal?d(Xr,{...i,ref:t}):d(Jr,{...i,ref:t})})});$r.displayName=Yr;var Xr=e.forwardRef((t,n)=>{const r=Ir(Yr,t.__scopeDialog),i=e.useRef(null),o=Rt(n,r.contentRef,i);return e.useEffect(()=>{const e=i.current;if(e)return Rr(e)},[]),d(Qr,{...t,ref:o,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Qt(t.onCloseAutoFocus,e=>{e.preventDefault(),r.triggerRef.current?.focus()}),onPointerDownOutside:Qt(t.onPointerDownOutside,e=>{const t=e.detail.originalEvent,n=0===t.button&&!0===t.ctrlKey;(2===t.button||n)&&e.preventDefault()}),onFocusOutside:Qt(t.onFocusOutside,e=>e.preventDefault())})}),Jr=e.forwardRef((t,n)=>{const r=Ir(Yr,t.__scopeDialog),i=e.useRef(!1),o=e.useRef(!1);return d(Qr,{...t,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:e=>{t.onCloseAutoFocus?.(e),e.defaultPrevented||(i.current||r.triggerRef.current?.focus(),e.preventDefault()),i.current=!1,o.current=!1},onInteractOutside:e=>{t.onInteractOutside?.(e),e.defaultPrevented||(i.current=!0,"pointerdown"===e.detail.originalEvent.type&&(o.current=!0));const n=e.target,s=r.triggerRef.current?.contains(n);s&&e.preventDefault(),"focusin"===e.detail.originalEvent.type&&o.current&&e.preventDefault()}})}),Qr=e.forwardRef((t,n)=>{const{__scopeDialog:r,trapFocus:i,onOpenAutoFocus:o,onCloseAutoFocus:s,...a}=t,l=Ir(Yr,r),c=e.useRef(null),u=Rt(n,c);return _n(),m(p,{children:[d(An,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:o,onUnmountAutoFocus:s,children:d(wn,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":oi(l.open),...a,ref:u,onDismiss:()=>l.onOpenChange(!1)})}),m(p,{children:[d(ci,{titleId:l.titleId}),d(ui,{contentRef:c,descriptionId:l.descriptionId})]})]})}),Zr="DialogTitle",ei=e.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Ir(Zr,n);return d(fn.h2,{id:i.titleId,...r,ref:t})});ei.displayName=Zr;var ti="DialogDescription",ni=e.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Ir(ti,n);return d(fn.p,{id:i.descriptionId,...r,ref:t})});ni.displayName=ti;var ri="DialogClose",ii=e.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Ir(ri,n);return d(fn.button,{type:"button",...r,ref:t,onClick:Qt(e.onClick,()=>i.onOpenChange(!1))})});function oi(e){return e?"open":"closed"}ii.displayName=ri;var si="DialogTitleWarning",[ai,li]=function(t,n){const r=e.createContext(n),i=t=>{const{children:n,...i}=t,o=e.useMemo(()=>i,Object.values(i));return d(r.Provider,{value:o,children:n})};return i.displayName=t+"Provider",[i,function(i){const o=e.useContext(r);if(o)return o;if(void 0!==n)return n;throw new Error(`\`${i}\` must be used within \`${t}\``)}]}(si,{contentName:Yr,titleName:Zr,docsSlug:"dialog"}),ci=({titleId:t})=>{const n=li(si),r=`\`${n.contentName}\` requires a \`${n.titleName}\` for the component to be accessible for screen reader users.\n\nIf you want to hide the \`${n.titleName}\`, you can wrap it with our VisuallyHidden component.\n\nFor more information, see https://radix-ui.com/primitives/docs/components/${n.docsSlug}`;return e.useEffect(()=>{if(t){document.getElementById(t)}},[r,t]),null},ui=({contentRef:t,descriptionId:n})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${li("DialogDescriptionWarning").contentName}}.`;return e.useEffect(()=>{const e=t.current?.getAttribute("aria-describedby");if(n&&e){document.getElementById(n)}},[r,t,n]),null},hi=_r,fi=Wr,di=Vr,pi=Ur,mi=$r,gi=ei,vi=ni,yi=ii,bi=hi,wi=di,ki=e.forwardRef(function(t,n){var r=t.className,i=Z(t,["className"]);return e.createElement(pi,Object.assign({className:Mt("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",r)},i,{ref:n}))});ki.displayName=pi.displayName;var xi=zt("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),Si=e.forwardRef(function(t,n){var r=t.side,i=void 0===r?"right":r,o=t.className,s=t.children,a=Z(t,["side","className","children"]);return e.createElement(wi,null,e.createElement(ki,null),e.createElement(mi,Object.assign({ref:n,className:Mt(xi({side:i}),o)},a),s,e.createElement(yi,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary"},e.createElement(De,{className:"h-4 w-4"}),e.createElement("span",{className:"sr-only"},"Close"))))});Si.displayName=mi.displayName;var Ci=function(t){var n=t.className,r=Z(t,["className"]);return e.createElement("div",Object.assign({className:Mt("flex flex-col space-y-2 text-center sm:text-left",n)},r))};Ci.displayName="SheetHeader";var Ei=e.forwardRef(function(t,n){var r=t.className,i=Z(t,["className"]);return e.createElement(gi,Object.assign({ref:n,className:Mt("text-lg font-semibold text-foreground",r)},i))});Ei.displayName=gi.displayName;var Ai=e.forwardRef(function(t,n){var r=t.className,i=Z(t,["className"]);return e.createElement(vi,Object.assign({ref:n,className:Mt("text-sm text-muted-foreground",r)},i))});Ai.displayName=vi.displayName;const Mi=["top","right","bottom","left"],Oi=Math.min,Ni=Math.max,Ti=Math.round,Ri=Math.floor,Di=e=>({x:e,y:e}),Pi={left:"right",right:"left",bottom:"top",top:"bottom"},Li={start:"end",end:"start"};function Bi(e,t,n){return Ni(e,Oi(t,n))}function Ii(e,t){return"function"==typeof e?e(t):e}function _i(e){return e.split("-")[0]}function Fi(e){return e.split("-")[1]}function Wi(e){return"x"===e?"y":"x"}function ji(e){return"y"===e?"height":"width"}const Hi=new Set(["top","bottom"]);function zi(e){return Hi.has(_i(e))?"y":"x"}function Vi(e){return Wi(zi(e))}function qi(e){return e.replace(/start|end/g,e=>Li[e])}const Ui=["left","right"],Ki=["right","left"],Gi=["top","bottom"],Yi=["bottom","top"];function $i(e,t,n,r){const i=Fi(e);let o=function(e,t,n){switch(e){case"top":case"bottom":return n?t?Ki:Ui:t?Ui:Ki;case"left":case"right":return t?Gi:Yi;default:return[]}}(_i(e),"start"===n,r);return i&&(o=o.map(e=>e+"-"+i),t&&(o=o.concat(o.map(qi)))),o}function Xi(e){return e.replace(/left|right|bottom|top/g,e=>Pi[e])}function Ji(e){return"number"!=typeof e?function(e){return{top:0,right:0,bottom:0,left:0,...e}}(e):{top:e,right:e,bottom:e,left:e}}function Qi(e){const{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function Zi(e,t,n){let{reference:r,floating:i}=e;const o=zi(t),s=Vi(t),a=ji(s),l=_i(t),c="y"===o,u=r.x+r.width/2-i.width/2,h=r.y+r.height/2-i.height/2,f=r[a]/2-i[a]/2;let d;switch(l){case"top":d={x:u,y:r.y-i.height};break;case"bottom":d={x:u,y:r.y+r.height};break;case"right":d={x:r.x+r.width,y:h};break;case"left":d={x:r.x-i.width,y:h};break;default:d={x:r.x,y:r.y}}switch(Fi(t)){case"start":d[s]-=f*(n&&c?-1:1);break;case"end":d[s]+=f*(n&&c?-1:1)}return d}async function eo(e,t){var n;void 0===t&&(t={});const{x:r,y:i,platform:o,rects:s,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:h="floating",altBoundary:f=!1,padding:d=0}=Ii(t,e),p=Ji(d),m=a[f?"floating"===h?"reference":"floating":h],g=Qi(await o.getClippingRect({element:null==(n=await(null==o.isElement?void 0:o.isElement(m)))||n?m:m.contextElement||await(null==o.getDocumentElement?void 0:o.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),v="floating"===h?{x:r,y:i,width:s.floating.width,height:s.floating.height}:s.reference,y=await(null==o.getOffsetParent?void 0:o.getOffsetParent(a.floating)),b=await(null==o.isElement?void 0:o.isElement(y))&&await(null==o.getScale?void 0:o.getScale(y))||{x:1,y:1},w=Qi(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:v,offsetParent:y,strategy:l}):v);return{top:(g.top-w.top+p.top)/b.y,bottom:(w.bottom-g.bottom+p.bottom)/b.y,left:(g.left-w.left+p.left)/b.x,right:(w.right-g.right+p.right)/b.x}}function to(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function no(e){return Mi.some(t=>e[t]>=0)}const ro=new Set(["left","top"]);function io(){return"undefined"!=typeof window}function oo(e){return lo(e)?(e.nodeName||"").toLowerCase():"#document"}function so(e){var t;return(null==e||null==(t=e.ownerDocument)?void 0:t.defaultView)||window}function ao(e){var t;return null==(t=(lo(e)?e.ownerDocument:e.document)||window.document)?void 0:t.documentElement}function lo(e){return!!io()&&(e instanceof Node||e instanceof so(e).Node)}function co(e){return!!io()&&(e instanceof Element||e instanceof so(e).Element)}function uo(e){return!!io()&&(e instanceof HTMLElement||e instanceof so(e).HTMLElement)}function ho(e){return!(!io()||"undefined"==typeof ShadowRoot)&&(e instanceof ShadowRoot||e instanceof so(e).ShadowRoot)}const fo=new Set(["inline","contents"]);function po(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=Ao(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!fo.has(i)}const mo=new Set(["table","td","th"]);function go(e){return mo.has(oo(e))}const vo=[":popover-open",":modal"];function yo(e){return vo.some(t=>{try{return e.matches(t)}catch(e){return!1}})}const bo=["transform","translate","scale","rotate","perspective"],wo=["transform","translate","scale","rotate","perspective","filter"],ko=["paint","layout","strict","content"];function xo(e){const t=So(),n=co(e)?Ao(e):e;return bo.some(e=>!!n[e]&&"none"!==n[e])||!!n.containerType&&"normal"!==n.containerType||!t&&!!n.backdropFilter&&"none"!==n.backdropFilter||!t&&!!n.filter&&"none"!==n.filter||wo.some(e=>(n.willChange||"").includes(e))||ko.some(e=>(n.contain||"").includes(e))}function So(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}const Co=new Set(["html","body","#document"]);function Eo(e){return Co.has(oo(e))}function Ao(e){return so(e).getComputedStyle(e)}function Mo(e){return co(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Oo(e){if("html"===oo(e))return e;const t=e.assignedSlot||e.parentNode||ho(e)&&e.host||ao(e);return ho(t)?t.host:t}function No(e){const t=Oo(e);return Eo(t)?e.ownerDocument?e.ownerDocument.body:e.body:uo(t)&&po(t)?t:No(t)}function To(e,t,n){var r;void 0===t&&(t=[]),void 0===n&&(n=!0);const i=No(e),o=i===(null==(r=e.ownerDocument)?void 0:r.body),s=so(i);if(o){const e=Ro(s);return t.concat(s,s.visualViewport||[],po(i)?i:[],e&&n?To(e):[])}return t.concat(i,To(i,[],n))}function Ro(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Do(e){const t=Ao(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=uo(e),o=i?e.offsetWidth:n,s=i?e.offsetHeight:r,a=Ti(n)!==o||Ti(r)!==s;return a&&(n=o,r=s),{width:n,height:r,$:a}}function Po(e){return co(e)?e:e.contextElement}function Lo(e){const t=Po(e);if(!uo(t))return Di(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:o}=Do(t);let s=(o?Ti(n.width):n.width)/r,a=(o?Ti(n.height):n.height)/i;return s&&Number.isFinite(s)||(s=1),a&&Number.isFinite(a)||(a=1),{x:s,y:a}}const Bo=Di(0);function Io(e){const t=so(e);return So()&&t.visualViewport?{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}:Bo}function _o(e,t,n,r){void 0===t&&(t=!1),void 0===n&&(n=!1);const i=e.getBoundingClientRect(),o=Po(e);let s=Di(1);t&&(r?co(r)&&(s=Lo(r)):s=Lo(e));const a=function(e,t,n){return void 0===t&&(t=!1),!(!n||t&&n!==so(e))&&t}(o,n,r)?Io(o):Di(0);let l=(i.left+a.x)/s.x,c=(i.top+a.y)/s.y,u=i.width/s.x,h=i.height/s.y;if(o){const e=so(o),t=r&&co(r)?so(r):r;let n=e,i=Ro(n);for(;i&&r&&t!==n;){const e=Lo(i),t=i.getBoundingClientRect(),r=Ao(i),o=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,s=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;l*=e.x,c*=e.y,u*=e.x,h*=e.y,l+=o,c+=s,n=so(i),i=Ro(n)}}return Qi({width:u,height:h,x:l,y:c})}function Fo(e,t){const n=Mo(e).scrollLeft;return t?t.left+n:_o(ao(e)).left+n}function Wo(e,t){const n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-Fo(e,n),y:n.top+t.scrollTop}}const jo=new Set(["absolute","fixed"]);function Ho(e,t,n){let r;if("viewport"===t)r=function(e,t){const n=so(e),r=ao(e),i=n.visualViewport;let o=r.clientWidth,s=r.clientHeight,a=0,l=0;if(i){o=i.width,s=i.height;const e=So();(!e||e&&"fixed"===t)&&(a=i.offsetLeft,l=i.offsetTop)}const c=Fo(r);if(c<=0){const e=r.ownerDocument,t=e.body,n=getComputedStyle(t),i="CSS1Compat"===e.compatMode&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,s=Math.abs(r.clientWidth-t.clientWidth-i);s<=25&&(o-=s)}else c<=25&&(o+=c);return{width:o,height:s,x:a,y:l}}(e,n);else if("document"===t)r=function(e){const t=ao(e),n=Mo(e),r=e.ownerDocument.body,i=Ni(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),o=Ni(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let s=-n.scrollLeft+Fo(e);const a=-n.scrollTop;return"rtl"===Ao(r).direction&&(s+=Ni(t.clientWidth,r.clientWidth)-i),{width:i,height:o,x:s,y:a}}(ao(e));else if(co(t))r=function(e,t){const n=_o(e,!0,"fixed"===t),r=n.top+e.clientTop,i=n.left+e.clientLeft,o=uo(e)?Lo(e):Di(1);return{width:e.clientWidth*o.x,height:e.clientHeight*o.y,x:i*o.x,y:r*o.y}}(t,n);else{const n=Io(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return Qi(r)}function zo(e,t){const n=Oo(e);return!(n===t||!co(n)||Eo(n))&&("fixed"===Ao(n).position||zo(n,t))}function Vo(e,t,n){const r=uo(t),i=ao(t),o="fixed"===n,s=_o(e,!0,o,t);let a={scrollLeft:0,scrollTop:0};const l=Di(0);function c(){l.x=Fo(i)}if(r||!r&&!o)if(("body"!==oo(t)||po(i))&&(a=Mo(t)),r){const e=_o(t,!0,o,t);l.x=e.x+t.clientLeft,l.y=e.y+t.clientTop}else i&&c();o&&!r&&i&&c();const u=!i||r||o?Di(0):Wo(i,a);return{x:s.left+a.scrollLeft-l.x-u.x,y:s.top+a.scrollTop-l.y-u.y,width:s.width,height:s.height}}function qo(e){return"static"===Ao(e).position}function Uo(e,t){if(!uo(e)||"fixed"===Ao(e).position)return null;if(t)return t(e);let n=e.offsetParent;return ao(e)===n&&(n=n.ownerDocument.body),n}function Ko(e,t){const n=so(e);if(yo(e))return n;if(!uo(e)){let t=Oo(e);for(;t&&!Eo(t);){if(co(t)&&!qo(t))return t;t=Oo(t)}return n}let r=Uo(e,t);for(;r&&go(r)&&qo(r);)r=Uo(r,t);return r&&Eo(r)&&qo(r)&&!xo(r)?n:r||function(e){let t=Oo(e);for(;uo(t)&&!Eo(t);){if(xo(t))return t;if(yo(t))return null;t=Oo(t)}return null}(e)||n}const Go={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const o="fixed"===i,s=ao(r),a=!!t&&yo(t.floating);if(r===s||a&&o)return n;let l={scrollLeft:0,scrollTop:0},c=Di(1);const u=Di(0),h=uo(r);if((h||!h&&!o)&&(("body"!==oo(r)||po(s))&&(l=Mo(r)),uo(r))){const e=_o(r);c=Lo(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}const f=!s||h||o?Di(0):Wo(s,l);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+u.x+f.x,y:n.y*c.y-l.scrollTop*c.y+u.y+f.y}},getDocumentElement:ao,getClippingRect:function(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const o=[..."clippingAncestors"===n?yo(t)?[]:function(e,t){const n=t.get(e);if(n)return n;let r=To(e,[],!1).filter(e=>co(e)&&"body"!==oo(e)),i=null;const o="fixed"===Ao(e).position;let s=o?Oo(e):e;for(;co(s)&&!Eo(s);){const t=Ao(s),n=xo(s);n||"fixed"!==t.position||(i=null),(o?!n&&!i:!n&&"static"===t.position&&i&&jo.has(i.position)||po(s)&&!n&&zo(e,s))?r=r.filter(e=>e!==s):i=t,s=Oo(s)}return t.set(e,r),r}(t,this._c):[].concat(n),r],s=o[0],a=o.reduce((e,n)=>{const r=Ho(t,n,i);return e.top=Ni(r.top,e.top),e.right=Oi(r.right,e.right),e.bottom=Oi(r.bottom,e.bottom),e.left=Ni(r.left,e.left),e},Ho(t,s,i));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}},getOffsetParent:Ko,getElementRects:async function(e){const t=this.getOffsetParent||Ko,n=this.getDimensions,r=await n(e.floating);return{reference:Vo(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}},getClientRects:function(e){return Array.from(e.getClientRects())},getDimensions:function(e){const{width:t,height:n}=Do(e);return{width:t,height:n}},getScale:Lo,isElement:co,isRTL:function(e){return"rtl"===Ao(e).direction}};function Yo(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function $o(e,t,n,r){void 0===r&&(r={});const{ancestorScroll:i=!0,ancestorResize:o=!0,elementResize:s="function"==typeof ResizeObserver,layoutShift:a="function"==typeof IntersectionObserver,animationFrame:l=!1}=r,c=Po(e),u=i||o?[...c?To(c):[],...To(t)]:[];u.forEach(e=>{i&&e.addEventListener("scroll",n,{passive:!0}),o&&e.addEventListener("resize",n)});const h=c&&a?function(e,t){let n,r=null;const i=ao(e);function o(){var e;clearTimeout(n),null==(e=r)||e.disconnect(),r=null}return function s(a,l){void 0===a&&(a=!1),void 0===l&&(l=1),o();const c=e.getBoundingClientRect(),{left:u,top:h,width:f,height:d}=c;if(a||t(),!f||!d)return;const p={rootMargin:-Ri(h)+"px "+-Ri(i.clientWidth-(u+f))+"px "+-Ri(i.clientHeight-(h+d))+"px "+-Ri(u)+"px",threshold:Ni(0,Oi(1,l))||1};let m=!0;function g(t){const r=t[0].intersectionRatio;if(r!==l){if(!m)return s();r?s(!1,r):n=setTimeout(()=>{s(!1,1e-7)},1e3)}1!==r||Yo(c,e.getBoundingClientRect())||s(),m=!1}try{r=new IntersectionObserver(g,{...p,root:i.ownerDocument})}catch(e){r=new IntersectionObserver(g,p)}r.observe(e)}(!0),o}(c,n):null;let f,d=-1,p=null;s&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===c&&p&&(p.unobserve(t),cancelAnimationFrame(d),d=requestAnimationFrame(()=>{var e;null==(e=p)||e.observe(t)})),n()}),c&&!l&&p.observe(c),p.observe(t));let m=l?_o(e):null;return l&&function t(){const r=_o(e);m&&!Yo(m,r)&&n();m=r,f=requestAnimationFrame(t)}(),n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener("scroll",n),o&&e.removeEventListener("resize",n)}),null==h||h(),null==(e=p)||e.disconnect(),p=null,l&&cancelAnimationFrame(f)}}const Xo=function(e){return void 0===e&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:i,y:o,placement:s,middlewareData:a}=t,l=await async function(e,t){const{placement:n,platform:r,elements:i}=e,o=await(null==r.isRTL?void 0:r.isRTL(i.floating)),s=_i(n),a=Fi(n),l="y"===zi(n),c=ro.has(s)?-1:1,u=o&&l?-1:1,h=Ii(t,e);let{mainAxis:f,crossAxis:d,alignmentAxis:p}="number"==typeof h?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return a&&"number"==typeof p&&(d="end"===a?-1*p:p),l?{x:d*u,y:f*c}:{x:f*c,y:d*u}}(t,e);return s===(null==(n=a.offset)?void 0:n.placement)&&null!=(r=a.arrow)&&r.alignmentOffset?{}:{x:i+l.x,y:o+l.y,data:{...l,placement:s}}}}},Jo=function(e){return void 0===e&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:i}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:a={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=Ii(e,t),c={x:n,y:r},u=await eo(t,l),h=zi(_i(i)),f=Wi(h);let d=c[f],p=c[h];if(o){const e="y"===f?"bottom":"right";d=Bi(d+u["y"===f?"top":"left"],d,d-u[e])}if(s){const e="y"===h?"bottom":"right";p=Bi(p+u["y"===h?"top":"left"],p,p-u[e])}const m=a.fn({...t,[f]:d,[h]:p});return{...m,data:{x:m.x-n,y:m.y-r,enabled:{[f]:o,[h]:s}}}}}},Qo=function(e){return void 0===e&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:i,middlewareData:o,rects:s,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:u=!0,crossAxis:h=!0,fallbackPlacements:f,fallbackStrategy:d="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:m=!0,...g}=Ii(e,t);if(null!=(n=o.arrow)&&n.alignmentOffset)return{};const v=_i(i),y=zi(a),b=_i(a)===a,w=await(null==l.isRTL?void 0:l.isRTL(c.floating)),k=f||(b||!m?[Xi(a)]:function(e){const t=Xi(e);return[qi(e),t,qi(t)]}(a)),x="none"!==p;!f&&x&&k.push(...$i(a,m,p,w));const S=[a,...k],C=await eo(t,g),E=[];let A=(null==(r=o.flip)?void 0:r.overflows)||[];if(u&&E.push(C[v]),h){const e=function(e,t,n){void 0===n&&(n=!1);const r=Fi(e),i=Vi(e),o=ji(i);let s="x"===i?r===(n?"end":"start")?"right":"left":"start"===r?"bottom":"top";return t.reference[o]>t.floating[o]&&(s=Xi(s)),[s,Xi(s)]}(i,s,w);E.push(C[e[0]],C[e[1]])}if(A=[...A,{placement:i,overflows:E}],!E.every(e=>e<=0)){var M,O;const e=((null==(M=o.flip)?void 0:M.index)||0)+1,t=S[e];if(t){if(!("alignment"===h&&y!==zi(t))||A.every(e=>zi(e.placement)!==y||e.overflows[0]>0))return{data:{index:e,overflows:A},reset:{placement:t}}}let n=null==(O=A.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0])?void 0:O.placement;if(!n)switch(d){case"bestFit":{var N;const e=null==(N=A.filter(e=>{if(x){const t=zi(e.placement);return t===y||"y"===t}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0])?void 0:N[0];e&&(n=e);break}case"initialPlacement":n=a}if(i!==n)return{reset:{placement:n}}}return{}}}},Zo=function(e){return void 0===e&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:i,rects:o,platform:s,elements:a}=t,{apply:l=()=>{},...c}=Ii(e,t),u=await eo(t,c),h=_i(i),f=Fi(i),d="y"===zi(i),{width:p,height:m}=o.floating;let g,v;"top"===h||"bottom"===h?(g=h,v=f===(await(null==s.isRTL?void 0:s.isRTL(a.floating))?"start":"end")?"left":"right"):(v=h,g="end"===f?"top":"bottom");const y=m-u.top-u.bottom,b=p-u.left-u.right,w=Oi(m-u[g],y),k=Oi(p-u[v],b),x=!t.middlewareData.shift;let S=w,C=k;if(null!=(n=t.middlewareData.shift)&&n.enabled.x&&(C=b),null!=(r=t.middlewareData.shift)&&r.enabled.y&&(S=y),x&&!f){const e=Ni(u.left,0),t=Ni(u.right,0),n=Ni(u.top,0),r=Ni(u.bottom,0);d?C=p-2*(0!==e||0!==t?e+t:Ni(u.left,u.right)):S=m-2*(0!==n||0!==r?n+r:Ni(u.top,u.bottom))}await l({...t,availableWidth:C,availableHeight:S});const E=await s.getDimensions(a.floating);return p!==E.width||m!==E.height?{reset:{rects:!0}}:{}}}},es=function(e){return void 0===e&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...i}=Ii(e,t);switch(r){case"referenceHidden":{const e=to(await eo(t,{...i,elementContext:"reference"}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:no(e)}}}case"escaped":{const e=to(await eo(t,{...i,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:no(e)}}}default:return{}}}}},ts=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:i,rects:o,platform:s,elements:a,middlewareData:l}=t,{element:c,padding:u=0}=Ii(e,t)||{};if(null==c)return{};const h=Ji(u),f={x:n,y:r},d=Vi(i),p=ji(d),m=await s.getDimensions(c),g="y"===d,v=g?"top":"left",y=g?"bottom":"right",b=g?"clientHeight":"clientWidth",w=o.reference[p]+o.reference[d]-f[d]-o.floating[p],k=f[d]-o.reference[d],x=await(null==s.getOffsetParent?void 0:s.getOffsetParent(c));let S=x?x[b]:0;S&&await(null==s.isElement?void 0:s.isElement(x))||(S=a.floating[b]||o.floating[p]);const C=w/2-k/2,E=S/2-m[p]/2-1,A=Oi(h[v],E),M=Oi(h[y],E),O=A,N=S-m[p]-M,T=S/2-m[p]/2+C,R=Bi(O,T,N),D=!l.arrow&&null!=Fi(i)&&T!==R&&o.reference[p]/2-(T<O?A:M)-m[p]/2<0,P=D?T<O?T-O:T-N:0;return{[d]:f[d]+P,data:{[d]:R,centerOffset:T-R-P,...D&&{alignmentOffset:P}},reset:D}}}),ns=function(e){return void 0===e&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:i,rects:o,middlewareData:s}=t,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=Ii(e,t),u={x:n,y:r},h=zi(i),f=Wi(h);let d=u[f],p=u[h];const m=Ii(a,t),g="number"==typeof m?{mainAxis:m,crossAxis:0}:{mainAxis:0,crossAxis:0,...m};if(l){const e="y"===f?"height":"width",t=o.reference[f]-o.floating[e]+g.mainAxis,n=o.reference[f]+o.reference[e]-g.mainAxis;d<t?d=t:d>n&&(d=n)}if(c){var v,y;const e="y"===f?"width":"height",t=ro.has(_i(i)),n=o.reference[h]-o.floating[e]+(t&&(null==(v=s.offset)?void 0:v[h])||0)+(t?0:g.crossAxis),r=o.reference[h]+o.reference[e]+(t?0:(null==(y=s.offset)?void 0:y[h])||0)-(t?g.crossAxis:0);p<n?p=n:p>r&&(p=r)}return{[f]:d,[h]:p}}}},rs=(e,t,n)=>{const r=new Map,i={platform:Go,...n},o={...i.platform,_c:r};return(async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:o=[],platform:s}=n,a=o.filter(Boolean),l=await(null==s.isRTL?void 0:s.isRTL(t));let c=await s.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:h}=Zi(c,r,l),f=r,d={},p=0;for(let n=0;n<a.length;n++){const{name:o,fn:m}=a[n],{x:g,y:v,data:y,reset:b}=await m({x:u,y:h,initialPlacement:r,placement:f,strategy:i,middlewareData:d,rects:c,platform:s,elements:{reference:e,floating:t}});u=null!=g?g:u,h=null!=v?v:h,d={...d,[o]:{...d[o],...y}},b&&p<=50&&(p++,"object"==typeof b&&(b.placement&&(f=b.placement),b.rects&&(c=!0===b.rects?await s.getElementRects({reference:e,floating:t,strategy:i}):b.rects),({x:u,y:h}=Zi(c,f,l))),n=-1)}return{x:u,y:h,placement:f,strategy:i,middlewareData:d}})(e,t,{...i,platform:o})};var is="undefined"!=typeof document?o:function(){};function os(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if("function"==typeof e&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&"object"==typeof e){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;0!==r--;)if(!os(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;0!==r--;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;0!==r--;){const n=i[r];if(("_owner"!==n||!e.$$typeof)&&!os(e[n],t[n]))return!1}return!0}return e!=e&&t!=t}function ss(e){if("undefined"==typeof window)return 1;return(e.ownerDocument.defaultView||window).devicePixelRatio||1}function as(e,t){const n=ss(e);return Math.round(t*n)/n}function ls(t){const n=e.useRef(t);return is(()=>{n.current=t}),n}const cs=e=>({name:"arrow",options:e,fn(t){const{element:n,padding:r}="function"==typeof e?e(t):e;return n&&(i=n,{}.hasOwnProperty.call(i,"current"))?null!=n.current?ts({element:n.current,padding:r}).fn(t):{}:n?ts({element:n,padding:r}).fn(t):{};var i}}),us=(e,t)=>({...Xo(e),options:[e,t]}),hs=(e,t)=>({...Jo(e),options:[e,t]}),fs=(e,t)=>({...ns(e),options:[e,t]}),ds=(e,t)=>({...Qo(e),options:[e,t]}),ps=(e,t)=>({...Zo(e),options:[e,t]}),ms=(e,t)=>({...es(e),options:[e,t]}),gs=(e,t)=>({...cs(e),options:[e,t]});var vs=e.forwardRef((e,t)=>{const{children:n,width:r=10,height:i=5,...o}=e;return d(fn.svg,{...o,ref:t,width:r,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:d("polygon",{points:"0,0 30,0 15,10"})})});vs.displayName="Arrow";var ys=vs;function bs(t){const[n,r]=e.useState(void 0);return tn(()=>{if(t){r({width:t.offsetWidth,height:t.offsetHeight});const e=new ResizeObserver(e=>{if(!Array.isArray(e))return;if(!e.length)return;const n=e[0];let i,o;if("borderBoxSize"in n){const e=n.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,o=t.blockSize}else i=t.offsetWidth,o=t.offsetHeight;r({width:i,height:o})});return e.observe(t,{box:"border-box"}),()=>e.unobserve(t)}r(void 0)},[t]),n}var ws="Popper",[ks,xs]=Zt(ws),[Ss,Cs]=ks(ws),Es=t=>{const{__scopePopper:n,children:r}=t,[i,o]=e.useState(null);return d(Ss,{scope:n,anchor:i,onAnchorChange:o,children:r})};Es.displayName=ws;var As="PopperAnchor",Ms=e.forwardRef((t,n)=>{const{__scopePopper:r,virtualRef:i,...o}=t,s=Cs(As,r),a=e.useRef(null),l=Rt(n,a),c=e.useRef(null);return e.useEffect(()=>{const e=c.current;c.current=i?.current||a.current,e!==c.current&&s.onAnchorChange(c.current)}),i?null:d(fn.div,{...o,ref:l})});Ms.displayName=As;var Os="PopperContent",[Ns,Ts]=ks(Os),Rs=e.forwardRef((t,n)=>{const{__scopePopper:r,side:i="bottom",sideOffset:o=0,align:s="center",alignOffset:a=0,arrowPadding:l=0,avoidCollisions:c=!0,collisionBoundary:u=[],collisionPadding:h=0,sticky:f="partial",hideWhenDetached:p=!1,updatePositionStrategy:m="optimized",onPlaced:v,...y}=t,b=Cs(Os,r),[w,k]=e.useState(null),x=Rt(n,e=>k(e)),[S,C]=e.useState(null),E=bs(S),A=E?.width??0,M=E?.height??0,O=i+("center"!==s?"-"+s:""),N="number"==typeof h?h:{top:0,right:0,bottom:0,left:0,...h},T=Array.isArray(u)?u:[u],R=T.length>0,D={padding:N,boundary:T.filter(Bs),altBoundary:R},{refs:P,floatingStyles:L,placement:B,isPositioned:I,middlewareData:_}=function(t){void 0===t&&(t={});const{placement:n="bottom",strategy:r="absolute",middleware:i=[],platform:o,elements:{reference:s,floating:a}={},transform:l=!0,whileElementsMounted:c,open:u}=t,[h,f]=e.useState({x:0,y:0,strategy:r,placement:n,middlewareData:{},isPositioned:!1}),[d,p]=e.useState(i);os(d,i)||p(i);const[m,v]=e.useState(null),[y,b]=e.useState(null),w=e.useCallback(e=>{e!==C.current&&(C.current=e,v(e))},[]),k=e.useCallback(e=>{e!==E.current&&(E.current=e,b(e))},[]),x=s||m,S=a||y,C=e.useRef(null),E=e.useRef(null),A=e.useRef(h),M=null!=c,O=ls(c),N=ls(o),T=ls(u),R=e.useCallback(()=>{if(!C.current||!E.current)return;const e={placement:n,strategy:r,middleware:d};N.current&&(e.platform=N.current),rs(C.current,E.current,e).then(e=>{const t={...e,isPositioned:!1!==T.current};D.current&&!os(A.current,t)&&(A.current=t,g.flushSync(()=>{f(t)}))})},[d,n,r,N,T]);is(()=>{!1===u&&A.current.isPositioned&&(A.current.isPositioned=!1,f(e=>({...e,isPositioned:!1})))},[u]);const D=e.useRef(!1);is(()=>(D.current=!0,()=>{D.current=!1}),[]),is(()=>{if(x&&(C.current=x),S&&(E.current=S),x&&S){if(O.current)return O.current(x,S,R);R()}},[x,S,R,O,M]);const P=e.useMemo(()=>({reference:C,floating:E,setReference:w,setFloating:k}),[w,k]),L=e.useMemo(()=>({reference:x,floating:S}),[x,S]),B=e.useMemo(()=>{const e={position:r,left:0,top:0};if(!L.floating)return e;const t=as(L.floating,h.x),n=as(L.floating,h.y);return l?{...e,transform:"translate("+t+"px, "+n+"px)",...ss(L.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:t,top:n}},[r,l,L.floating,h.x,h.y]);return e.useMemo(()=>({...h,update:R,refs:P,elements:L,floatingStyles:B}),[h,R,P,L,B])}({strategy:"fixed",placement:O,whileElementsMounted:(...e)=>$o(...e,{animationFrame:"always"===m}),elements:{reference:b.anchor},middleware:[us({mainAxis:o+M,alignmentAxis:a}),c&&hs({mainAxis:!0,crossAxis:!1,limiter:"partial"===f?fs():void 0,...D}),c&&ds({...D}),ps({...D,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{const{width:i,height:o}=t.reference,s=e.floating.style;s.setProperty("--radix-popper-available-width",`${n}px`),s.setProperty("--radix-popper-available-height",`${r}px`),s.setProperty("--radix-popper-anchor-width",`${i}px`),s.setProperty("--radix-popper-anchor-height",`${o}px`)}}),S&&gs({element:S,padding:l}),Is({arrowWidth:A,arrowHeight:M}),p&&ms({strategy:"referenceHidden",...D})]}),[F,W]=_s(B),j=pn(v);tn(()=>{I&&j?.()},[I,j]);const H=_.arrow?.x,z=_.arrow?.y,V=0!==_.arrow?.centerOffset,[q,U]=e.useState();return tn(()=>{w&&U(window.getComputedStyle(w).zIndex)},[w]),d("div",{ref:P.setFloating,"data-radix-popper-content-wrapper":"",style:{...L,transform:I?L.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:q,"--radix-popper-transform-origin":[_.transformOrigin?.x,_.transformOrigin?.y].join(" "),..._.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:d(Ns,{scope:r,placedSide:F,onArrowChange:C,arrowX:H,arrowY:z,shouldHideArrow:V,children:d(fn.div,{"data-side":F,"data-align":W,...y,ref:x,style:{...y.style,animation:I?void 0:"none"}})})})});Rs.displayName=Os;var Ds="PopperArrow",Ps={top:"bottom",right:"left",bottom:"top",left:"right"},Ls=e.forwardRef(function(e,t){const{__scopePopper:n,...r}=e,i=Ts(Ds,n),o=Ps[i.placedSide];return d("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:d(ys,{...r,ref:t,style:{...r.style,display:"block"}})})});function Bs(e){return null!==e}Ls.displayName=Ds;var Is=e=>({name:"transformOrigin",options:e,fn(t){const{placement:n,rects:r,middlewareData:i}=t,o=0!==i.arrow?.centerOffset,s=o?0:e.arrowWidth,a=o?0:e.arrowHeight,[l,c]=_s(n),u={start:"0%",center:"50%",end:"100%"}[c],h=(i.arrow?.x??0)+s/2,f=(i.arrow?.y??0)+a/2;let d="",p="";return"bottom"===l?(d=o?u:`${h}px`,p=-a+"px"):"top"===l?(d=o?u:`${h}px`,p=`${r.floating.height+a}px`):"right"===l?(d=-a+"px",p=o?u:`${f}px`):"left"===l&&(d=`${r.floating.width+a}px`,p=o?u:`${f}px`),{data:{x:d,y:p}}}});function _s(e){const[t,n="center"]=e.split("-");return[t,n]}var Fs=Es,Ws=Ms,js=Rs,Hs=Ls,zs=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),Vs=e.forwardRef((e,t)=>d(fn.span,{...e,ref:t,style:{...zs,...e.style}}));Vs.displayName="VisuallyHidden";var qs=Vs,[Us,Ks]=Zt("Tooltip",[xs]),Gs=xs(),Ys="TooltipProvider",$s=700,Xs="tooltip.open",[Js,Qs]=Us(Ys),Zs=t=>{const{__scopeTooltip:n,delayDuration:r=$s,skipDelayDuration:i=300,disableHoverableContent:o=!1,children:s}=t,a=e.useRef(!0),l=e.useRef(!1),c=e.useRef(0);return e.useEffect(()=>{const e=c.current;return()=>window.clearTimeout(e)},[]),d(Js,{scope:n,isOpenDelayedRef:a,delayDuration:r,onOpen:e.useCallback(()=>{window.clearTimeout(c.current),a.current=!1},[]),onClose:e.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>a.current=!0,i)},[i]),isPointerInTransitRef:l,onPointerInTransitChange:e.useCallback(e=>{l.current=e},[]),disableHoverableContent:o,children:s})};Zs.displayName=Ys;var ea="Tooltip",[ta,na]=Us(ea),ra=t=>{const{__scopeTooltip:n,children:r,open:i,defaultOpen:o,onOpenChange:s,disableHoverableContent:a,delayDuration:l}=t,c=Qs(ea,t.__scopeTooltip),u=Gs(n),[h,f]=e.useState(null),p=on(),m=e.useRef(0),g=a??c.disableHoverableContent,v=l??c.delayDuration,y=e.useRef(!1),[b,w]=an({prop:i,defaultProp:o??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(Xs))):c.onClose(),s?.(e)},caller:ea}),k=e.useMemo(()=>b?y.current?"delayed-open":"instant-open":"closed",[b]),x=e.useCallback(()=>{window.clearTimeout(m.current),m.current=0,y.current=!1,w(!0)},[w]),S=e.useCallback(()=>{window.clearTimeout(m.current),m.current=0,w(!1)},[w]),C=e.useCallback(()=>{window.clearTimeout(m.current),m.current=window.setTimeout(()=>{y.current=!0,w(!0),m.current=0},v)},[v,w]);return e.useEffect(()=>()=>{m.current&&(window.clearTimeout(m.current),m.current=0)},[]),d(Fs,{...u,children:d(ta,{scope:n,contentId:p,open:b,stateAttribute:k,trigger:h,onTriggerChange:f,onTriggerEnter:e.useCallback(()=>{c.isOpenDelayedRef.current?C():x()},[c.isOpenDelayedRef,C,x]),onTriggerLeave:e.useCallback(()=>{g?S():(window.clearTimeout(m.current),m.current=0)},[S,g]),onOpen:x,onClose:S,disableHoverableContent:g,children:r})})};ra.displayName=ea;var ia="TooltipTrigger",oa=e.forwardRef((t,n)=>{const{__scopeTooltip:r,...i}=t,o=na(ia,r),s=Qs(ia,r),a=Gs(r),l=Rt(n,e.useRef(null),o.onTriggerChange),c=e.useRef(!1),u=e.useRef(!1),h=e.useCallback(()=>c.current=!1,[]);return e.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),d(Ws,{asChild:!0,...a,children:d(fn.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...i,ref:l,onPointerMove:Qt(t.onPointerMove,e=>{"touch"!==e.pointerType&&(u.current||s.isPointerInTransitRef.current||(o.onTriggerEnter(),u.current=!0))}),onPointerLeave:Qt(t.onPointerLeave,()=>{o.onTriggerLeave(),u.current=!1}),onPointerDown:Qt(t.onPointerDown,()=>{o.open&&o.onClose(),c.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:Qt(t.onFocus,()=>{c.current||o.onOpen()}),onBlur:Qt(t.onBlur,o.onClose),onClick:Qt(t.onClick,o.onClose)})})});oa.displayName=ia;var[sa,aa]=Us("TooltipPortal",{forceMount:void 0}),la="TooltipContent",ca=e.forwardRef((e,t)=>{const n=aa(la,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...o}=e,s=na(la,e.__scopeTooltip);return d(Ln,{present:r||s.open,children:s.disableHoverableContent?d(pa,{side:i,...o,ref:t}):d(ua,{side:i,...o,ref:t})})}),ua=e.forwardRef((t,n)=>{const r=na(la,t.__scopeTooltip),i=Qs(la,t.__scopeTooltip),o=e.useRef(null),s=Rt(n,o),[a,l]=e.useState(null),{trigger:c,onClose:u}=r,h=o.current,{onPointerInTransitChange:f}=i,p=e.useCallback(()=>{l(null),f(!1)},[f]),m=e.useCallback((e,t)=>{const n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=function(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),o=Math.abs(t.left-e.x);switch(Math.min(n,r,i,o)){case o:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}(r,n.getBoundingClientRect()),o=function(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n})}return r}(r,i),s=function(e){const{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}(t.getBoundingClientRect()),a=function(e){const t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:e.y>t.y?1:0),function(e){if(e.length<=1)return e.slice();const t=[];for(let n=0;n<e.length;n++){const r=e[n];for(;t.length>=2;){const e=t[t.length-1],n=t[t.length-2];if(!((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x)))break;t.pop()}t.push(r)}t.pop();const n=[];for(let t=e.length-1;t>=0;t--){const r=e[t];for(;n.length>=2;){const e=n[n.length-1],t=n[n.length-2];if(!((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x)))break;n.pop()}n.push(r)}return n.pop(),1===t.length&&1===n.length&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}(t)}([...o,...s]);l(a),f(!0)},[f]);return e.useEffect(()=>()=>p(),[p]),e.useEffect(()=>{if(c&&h){const e=e=>m(e,h),t=e=>m(e,c);return c.addEventListener("pointerleave",e),h.addEventListener("pointerleave",t),()=>{c.removeEventListener("pointerleave",e),h.removeEventListener("pointerleave",t)}}},[c,h,m,p]),e.useEffect(()=>{if(a){const e=e=>{const t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||h?.contains(t),i=!function(e,t){const{x:n,y:r}=e;let i=!1;for(let e=0,o=t.length-1;e<t.length;o=e++){const s=t[e],a=t[o],l=s.x,c=s.y,u=a.x,h=a.y;c>r!=h>r&&n<(u-l)*(r-c)/(h-c)+l&&(i=!i)}return i}(n,a);r?p():i&&(p(),u())};return document.addEventListener("pointermove",e),()=>document.removeEventListener("pointermove",e)}},[c,h,a,u,p]),d(pa,{...t,ref:s})}),[ha,fa]=Us(ea,{isInside:!1}),da=function(e){const t=({children:e})=>d(p,{children:e});return t.displayName=`${e}.Slottable`,t.__radixId=un,t}("TooltipContent"),pa=e.forwardRef((t,n)=>{const{__scopeTooltip:r,children:i,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:a,...l}=t,c=na(la,r),u=Gs(r),{onClose:h}=c;return e.useEffect(()=>(document.addEventListener(Xs,h),()=>document.removeEventListener(Xs,h)),[h]),e.useEffect(()=>{if(c.trigger){const e=e=>{const t=e.target;t?.contains(c.trigger)&&h()};return window.addEventListener("scroll",e,{capture:!0}),()=>window.removeEventListener("scroll",e,{capture:!0})}},[c.trigger,h]),d(wn,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:e=>e.preventDefault(),onDismiss:h,children:m(js,{"data-state":c.stateAttribute,...u,...l,ref:n,style:{...l.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[d(da,{children:i}),d(ha,{scope:r,isInside:!0,children:d(qs,{id:c.contentId,role:"tooltip",children:o||i})})]})})});ca.displayName=la;var ma="TooltipArrow";e.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=Gs(n);return fa(ma,n).isInside?null:d(Hs,{...i,...r,ref:t})}).displayName=ma;var ga=ca,va=Zs,ya=ra,ba=oa,wa=e.forwardRef(function(t,n){var r=t.className,i=t.sideOffset,o=void 0===i?4:i,s=Z(t,["className","sideOffset"]);return e.createElement(ga,Object.assign({ref:n,sideOffset:o,className:Mt("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-tooltip-content-transform-origin]",r)},s))});wa.displayName=ga.displayName;var ka=e.createContext(null);function xa(){var t=e.useContext(ka);if(!t)throw new Error("useSidebar must be used within a SidebarProvider.");return t}function Sa(t){var n=t.defaultOpen,r=void 0===n||n,i=t.open,o=t.onOpenChange,s=t.className,a=t.style,l=t.children,c=Z(t,["defaultOpen","open","onOpenChange","className","style","children"]),u=function(){var t=q(e.useState(void 0),2),n=t[0],r=t[1];return e.useEffect(function(){var e=window.matchMedia("(max-width: ".concat(767,"px)")),t=function(){r(window.innerWidth<768)};return e.addEventListener("change",t),r(window.innerWidth<768),function(){return e.removeEventListener("change",t)}},[]),!!n}(),h=q(e.useState(!1),2),f=h[0],d=h[1],p=q(e.useState(r),2),m=p[0],g=p[1],v=null!=i?i:m,y=e.useCallback(function(e){var t="function"==typeof e?e(v):e;o?o(t):g(t),document.cookie="".concat("sidebar_state","=").concat(t,"; path=/; max-age=").concat(604800)},[o,v]),b=e.useCallback(function(){return u?d(function(e){return!e}):y(function(e){return!e})},[u,y,d]);e.useEffect(function(){var e=function(e){"b"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),b())};return window.addEventListener("keydown",e),function(){return window.removeEventListener("keydown",e)}},[b]);var w=v?"expanded":"collapsed",k=e.useMemo(function(){return{state:w,open:v,setOpen:y,isMobile:u,openMobile:f,setOpenMobile:d,toggleSidebar:b}},[w,v,y,u,f,d,b]);return e.createElement(ka.Provider,{value:k},e.createElement(va,{delayDuration:0},e.createElement("div",Object.assign({style:Object.assign({"--sidebar-width":"16rem","--sidebar-width-icon":"3rem"},a),className:Mt("group/sidebar-wrapper flex min-h-svh w-full",s)},c),l)))}function Ca(t){var n=t.side,r=void 0===n?"left":n,i=t.variant,o=void 0===i?"sidebar":i,s=t.collapsible,a=void 0===s?"offcanvas":s,l=t.className,c=t.children,u=Z(t,["side","variant","collapsible","className","children"]),h=xa(),f=h.isMobile,d=h.state,p=h.openMobile,m=h.setOpenMobile;return"none"===a?e.createElement("div",Object.assign({className:Mt("bg-sidebar text-sidebar-foreground flex h-full w-[var(--sidebar-width)] flex-col",l)},u),c):f?e.createElement(bi,Object.assign({open:p,onOpenChange:m},u),e.createElement(Si,{className:"bg-sidebar text-sidebar-foreground w-[var(--sidebar-width)] p-0 [&>button]:hidden",style:{"--sidebar-width":"18rem"},side:r},e.createElement(Ci,{className:"sr-only"},e.createElement(Ei,null,"Sidebar"),e.createElement(Ai,null,"Displays the mobile sidebar.")),e.createElement("div",{className:"flex h-full w-full flex-col"},c))):e.createElement("div",{className:"group peer text-sidebar-foreground hidden md:block","data-state":d,"data-collapsible":"collapsed"===d?a:"","data-variant":o,"data-side":r},e.createElement("div",{className:Mt("relative w-[var(--sidebar-width)] bg-transparent transition-[width] duration-200 ease-linear","group-data-[collapsible=offcanvas]:w-0","floating"===o||"inset"===o?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+1rem)]":"group-data-[collapsible=icon]:w-[var(--sidebar-width-icon)]")}),e.createElement("div",Object.assign({className:Mt("fixed inset-y-0 z-10 hidden h-svh w-[var(--sidebar-width)] transition-[left,right,width] duration-200 ease-linear md:flex","left"===r?"left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]":"right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]","floating"===o||"inset"===o?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+1rem+2px)]":"group-data-[collapsible=icon]:w-[var(--sidebar-width-icon)] group-data-[side=left]:border-r group-data-[side=right]:border-l",l)},u),e.createElement("div",{className:"bg-sidebar group-data-[variant=floating]:border-sidebar-border flex h-full w-full flex-col group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:shadow-sm"},c)))}function Ea(t){var n=t.className,r=t.onClick,i=Z(t,["className","onClick"]),o=xa().toggleSidebar;return e.createElement(qt,Object.assign({variant:"ghost",size:"icon",className:Mt("h-7 w-7",n),onClick:function(e){null==r||r(e),o()}},i),e.createElement(Se,null),e.createElement("span",{className:"sr-only"},"Toggle Sidebar"))}function Aa(t){var n=t.className,r=Z(t,["className"]);return e.createElement("main",Object.assign({className:Mt("bg-background relative flex w-full flex-1 flex-col min-w-0 overflow-x-hidden","md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2",n)},r))}function Ma(t){var n=t.className,r=Z(t,["className"]);return e.createElement("div",Object.assign({className:Mt("flex flex-col gap-2 p-2",n)},r))}function Oa(t){var n=t.className,r=Z(t,["className"]);return e.createElement("div",Object.assign({className:Mt("flex flex-col gap-2 p-2",n)},r))}function Na(t){var n=t.className,r=Z(t,["className"]);return e.createElement("div",Object.assign({className:Mt("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",n)},r))}function Ta(t){var n=t.className,r=Z(t,["className"]);return e.createElement("div",Object.assign({className:Mt("relative flex w-full min-w-0 flex-col p-2",n)},r))}function Ra(t){var n=t.className,r=t.asChild,i=void 0!==r&&r,o=Z(t,["className","asChild"]),s=i?It:"div";return e.createElement(s,Object.assign({className:Mt("text-sidebar-foreground/70 flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium transition-[margin,opacity] duration-200 ease-linear [&>svg]:size-4 [&>svg]:shrink-0","group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",n)},o))}function Da(t){var n=t.className,r=Z(t,["className"]);return e.createElement("div",Object.assign({className:Mt("w-full text-sm",n)},r))}function Pa(t){var n=t.className,r=Z(t,["className"]);return e.createElement("ul",Object.assign({className:Mt("flex w-full min-w-0 flex-col gap-1",n)},r))}function La(t){var n=t.className,r=Z(t,["className"]);return e.createElement("li",Object.assign({className:Mt("group/menu-item relative",n)},r))}var Ba=zt("peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"},size:{default:"h-8 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:p-0!"}},defaultVariants:{variant:"default",size:"default"}});function Ia(t){var n=t.asChild,r=void 0!==n&&n,i=t.isActive,o=void 0!==i&&i,s=t.variant,a=void 0===s?"default":s,l=t.size,c=void 0===l?"default":l,u=t.tooltip,h=t.className,f=Z(t,["asChild","isActive","variant","size","tooltip","className"]),d=r?It:"button",p=xa(),m=p.isMobile,g=p.state,v=e.createElement(d,Object.assign({"data-size":c,"data-active":o,className:Mt(Ba({variant:a,size:c}),h)},f));return u?("string"==typeof u&&(u={children:u}),e.createElement(ya,null,e.createElement(ba,{asChild:!0},v),e.createElement(wa,Object.assign({side:"right",align:"center",hidden:"collapsed"!==g||m},u)))):v}function _a(e){const n=e+"CollectionProvider",[r,i]=Zt(n),[o,s]=r(n,{collectionRef:{current:null},itemMap:new Map}),a=e=>{const{scope:n,children:r}=e,i=t.useRef(null),s=t.useRef(new Map).current;return d(o,{scope:n,itemMap:s,collectionRef:i,children:r})};a.displayName=n;const l=e+"CollectionSlot",c=ln(l),u=t.forwardRef((e,t)=>{const{scope:n,children:r}=e,i=Rt(t,s(l,n).collectionRef);return d(c,{ref:i,children:r})});u.displayName=l;const h=e+"CollectionItemSlot",f="data-radix-collection-item",p=ln(h),m=t.forwardRef((e,n)=>{const{scope:r,children:i,...o}=e,a=t.useRef(null),l=Rt(n,a),c=s(h,r);return t.useEffect(()=>(c.itemMap.set(a,{ref:a,...o}),()=>{c.itemMap.delete(a)})),d(p,{[f]:"",ref:l,children:i})});return m.displayName=h,[{Provider:a,Slot:u,ItemSlot:m},function(n){const r=s(e+"CollectionConsumer",n);return t.useCallback(()=>{const e=r.collectionRef.current;if(!e)return[];const t=Array.from(e.querySelectorAll(`[${f}]`));return Array.from(r.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[r.collectionRef,r.itemMap])},i]}var Fa=e.createContext(void 0);function Wa(t){const n=e.useContext(Fa);return t||n||"ltr"}var ja="rovingFocusGroup.onEntryFocus",Ha={bubbles:!1,cancelable:!0},za="RovingFocusGroup",[Va,qa,Ua]=_a(za),[Ka,Ga]=Zt(za,[Ua]),[Ya,$a]=Ka(za),Xa=e.forwardRef((e,t)=>d(Va.Provider,{scope:e.__scopeRovingFocusGroup,children:d(Va.Slot,{scope:e.__scopeRovingFocusGroup,children:d(Ja,{...e,ref:t})})}));Xa.displayName=za;var Ja=e.forwardRef((t,n)=>{const{__scopeRovingFocusGroup:r,orientation:i,loop:o=!1,dir:s,currentTabStopId:a,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:c,onEntryFocus:u,preventScrollOnEntryFocus:h=!1,...f}=t,p=e.useRef(null),m=Rt(n,p),g=Wa(s),[v,y]=an({prop:a,defaultProp:l??null,onChange:c,caller:za}),[b,w]=e.useState(!1),k=pn(u),x=qa(r),S=e.useRef(!1),[C,E]=e.useState(0);return e.useEffect(()=>{const e=p.current;if(e)return e.addEventListener(ja,k),()=>e.removeEventListener(ja,k)},[k]),d(Ya,{scope:r,orientation:i,dir:g,loop:o,currentTabStopId:v,onItemFocus:e.useCallback(e=>y(e),[y]),onItemShiftTab:e.useCallback(()=>w(!0),[]),onFocusableItemAdd:e.useCallback(()=>E(e=>e+1),[]),onFocusableItemRemove:e.useCallback(()=>E(e=>e-1),[]),children:d(fn.div,{tabIndex:b||0===C?-1:0,"data-orientation":i,...f,ref:m,style:{outline:"none",...t.style},onMouseDown:Qt(t.onMouseDown,()=>{S.current=!0}),onFocus:Qt(t.onFocus,e=>{const t=!S.current;if(e.target===e.currentTarget&&t&&!b){const t=new CustomEvent(ja,Ha);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){const e=x().filter(e=>e.focusable);tl([e.find(e=>e.active),e.find(e=>e.id===v),...e].filter(Boolean).map(e=>e.ref.current),h)}}S.current=!1}),onBlur:Qt(t.onBlur,()=>w(!1))})})}),Qa="RovingFocusGroupItem",Za=e.forwardRef((t,n)=>{const{__scopeRovingFocusGroup:r,focusable:i=!0,active:o=!1,tabStopId:s,children:a,...l}=t,c=on(),u=s||c,h=$a(Qa,r),f=h.currentTabStopId===u,p=qa(r),{onFocusableItemAdd:m,onFocusableItemRemove:g,currentTabStopId:v}=h;return e.useEffect(()=>{if(i)return m(),()=>g()},[i,m,g]),d(Va.ItemSlot,{scope:r,id:u,focusable:i,active:o,children:d(fn.span,{tabIndex:f?0:-1,"data-orientation":h.orientation,...l,ref:n,onMouseDown:Qt(t.onMouseDown,e=>{i?h.onItemFocus(u):e.preventDefault()}),onFocus:Qt(t.onFocus,()=>h.onItemFocus(u)),onKeyDown:Qt(t.onKeyDown,e=>{if("Tab"===e.key&&e.shiftKey)return void h.onItemShiftTab();if(e.target!==e.currentTarget)return;const t=function(e,t,n){const r=function(e,t){return"rtl"!==t?e:"ArrowLeft"===e?"ArrowRight":"ArrowRight"===e?"ArrowLeft":e}(e.key,n);return"vertical"===t&&["ArrowLeft","ArrowRight"].includes(r)||"horizontal"===t&&["ArrowUp","ArrowDown"].includes(r)?void 0:el[r]}(e,h.orientation,h.dir);if(void 0!==t){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let i=p().filter(e=>e.focusable).map(e=>e.ref.current);if("last"===t)i.reverse();else if("prev"===t||"next"===t){"prev"===t&&i.reverse();const o=i.indexOf(e.currentTarget);i=h.loop?(r=o+1,(n=i).map((e,t)=>n[(r+t)%n.length])):i.slice(o+1)}setTimeout(()=>tl(i))}var n,r}),children:"function"==typeof a?a({isCurrentTabStop:f,hasTabStop:null!=v}):a})})});Za.displayName=Qa;var el={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function tl(e,t=!1){const n=document.activeElement;for(const r of e){if(r===n)return;if(r.focus({preventScroll:t}),document.activeElement!==n)return}}var nl=Xa,rl=Za,il=["Enter"," "],ol=["ArrowUp","PageDown","End"],sl=["ArrowDown","PageUp","Home",...ol],al={ltr:[...il,"ArrowRight"],rtl:[...il,"ArrowLeft"]},ll={ltr:["ArrowLeft"],rtl:["ArrowRight"]},cl="Menu",[ul,hl,fl]=_a(cl),[dl,pl]=Zt(cl,[fl,xs,Ga]),ml=xs(),gl=Ga(),[vl,yl]=dl(cl),[bl,wl]=dl(cl),kl=t=>{const{__scopeMenu:n,open:r=!1,children:i,dir:o,onOpenChange:s,modal:a=!0}=t,l=ml(n),[c,u]=e.useState(null),h=e.useRef(!1),f=pn(s),p=Wa(o);return e.useEffect(()=>{const e=()=>{h.current=!0,document.addEventListener("pointerdown",t,{capture:!0,once:!0}),document.addEventListener("pointermove",t,{capture:!0,once:!0})},t=()=>h.current=!1;return document.addEventListener("keydown",e,{capture:!0}),()=>{document.removeEventListener("keydown",e,{capture:!0}),document.removeEventListener("pointerdown",t,{capture:!0}),document.removeEventListener("pointermove",t,{capture:!0})}},[]),d(Fs,{...l,children:d(vl,{scope:n,open:r,onOpenChange:f,content:c,onContentChange:u,children:d(bl,{scope:n,onClose:e.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:h,dir:p,modal:a,children:i})})})};kl.displayName=cl;var xl=e.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=ml(n);return d(Ws,{...i,...r,ref:t})});xl.displayName="MenuAnchor";var Sl="MenuPortal",[Cl,El]=dl(Sl,{forceMount:void 0}),Al=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:i}=e,o=yl(Sl,t);return d(Cl,{scope:t,forceMount:n,children:d(Ln,{present:n||o.open,children:d(Pn,{asChild:!0,container:i,children:r})})})};Al.displayName=Sl;var Ml="MenuContent",[Ol,Nl]=dl(Ml),Tl=e.forwardRef((e,t)=>{const n=El(Ml,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,o=yl(Ml,e.__scopeMenu),s=wl(Ml,e.__scopeMenu);return d(ul.Provider,{scope:e.__scopeMenu,children:d(Ln,{present:r||o.open,children:d(ul.Slot,{scope:e.__scopeMenu,children:s.modal?d(Rl,{...i,ref:t}):d(Dl,{...i,ref:t})})})})}),Rl=e.forwardRef((t,n)=>{const r=yl(Ml,t.__scopeMenu),i=e.useRef(null),o=Rt(n,i);return e.useEffect(()=>{const e=i.current;if(e)return Rr(e)},[]),d(Ll,{...t,ref:o,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:Qt(t.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})}),Dl=e.forwardRef((e,t)=>{const n=yl(Ml,e.__scopeMenu);return d(Ll,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Pl=ln("MenuContent.ScrollLock"),Ll=e.forwardRef((t,n)=>{const{__scopeMenu:r,loop:i=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:a,disableOutsidePointerEvents:l,onEntryFocus:c,onEscapeKeyDown:u,onPointerDownOutside:h,onFocusOutside:f,onInteractOutside:p,onDismiss:m,disableOutsideScroll:g,...v}=t,y=yl(Ml,r),b=wl(Ml,r),w=ml(r),k=gl(r),x=hl(r),[S,C]=e.useState(null),E=e.useRef(null),A=Rt(n,E,y.onContentChange),M=e.useRef(0),O=e.useRef(""),N=e.useRef(0),T=e.useRef(null),R=e.useRef("right"),D=e.useRef(0),P=g?Cr:e.Fragment,L=g?{as:Pl,allowPinchZoom:!0}:void 0,B=e=>{const t=O.current+e,n=x().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,o=function(e,t,n){const r=t.length>1&&Array.from(t).every(e=>e===t[0]),i=r?t[0]:t,o=n?e.indexOf(n):-1;let s=(a=e,l=Math.max(o,0),a.map((e,t)=>a[(l+t)%a.length]));var a,l;1===i.length&&(s=s.filter(e=>e!==n));const c=s.find(e=>e.toLowerCase().startsWith(i.toLowerCase()));return c!==n?c:void 0}(n.map(e=>e.textValue),t,i),s=n.find(e=>e.textValue===o)?.ref.current;!function e(t){O.current=t,window.clearTimeout(M.current),""!==t&&(M.current=window.setTimeout(()=>e(""),1e3))}(t),s&&setTimeout(()=>s.focus())};e.useEffect(()=>()=>window.clearTimeout(M.current),[]),_n();const I=e.useCallback(e=>R.current===T.current?.side&&function(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return function(e,t){const{x:n,y:r}=e;let i=!1;for(let e=0,o=t.length-1;e<t.length;o=e++){const s=t[e],a=t[o],l=s.x,c=s.y,u=a.x,h=a.y;c>r!=h>r&&n<(u-l)*(r-c)/(h-c)+l&&(i=!i)}return i}(n,t)}(e,T.current?.area),[]);return d(Ol,{scope:r,searchRef:O,onItemEnter:e.useCallback(e=>{I(e)&&e.preventDefault()},[I]),onItemLeave:e.useCallback(e=>{I(e)||(E.current?.focus(),C(null))},[I]),onTriggerLeave:e.useCallback(e=>{I(e)&&e.preventDefault()},[I]),pointerGraceTimerRef:N,onPointerGraceIntentChange:e.useCallback(e=>{T.current=e},[]),children:d(P,{...L,children:d(An,{asChild:!0,trapped:o,onMountAutoFocus:Qt(s,e=>{e.preventDefault(),E.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:a,children:d(wn,{asChild:!0,disableOutsidePointerEvents:l,onEscapeKeyDown:u,onPointerDownOutside:h,onFocusOutside:f,onInteractOutside:p,onDismiss:m,children:d(nl,{asChild:!0,...k,dir:b.dir,orientation:"vertical",loop:i,currentTabStopId:S,onCurrentTabStopIdChange:C,onEntryFocus:Qt(c,e=>{b.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:d(js,{role:"menu","aria-orientation":"vertical","data-state":sc(y.open),"data-radix-menu-content":"",dir:b.dir,...w,...v,ref:A,style:{outline:"none",...v.style},onKeyDown:Qt(v.onKeyDown,e=>{const t=e.target.closest("[data-radix-menu-content]")===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=1===e.key.length;t&&("Tab"===e.key&&e.preventDefault(),!n&&r&&B(e.key));const i=E.current;if(e.target!==i)return;if(!sl.includes(e.key))return;e.preventDefault();const o=x().filter(e=>!e.disabled).map(e=>e.ref.current);ol.includes(e.key)&&o.reverse(),function(e){const t=document.activeElement;for(const n of e){if(n===t)return;if(n.focus(),document.activeElement!==t)return}}(o)}),onBlur:Qt(t.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(M.current),O.current="")}),onPointerMove:Qt(t.onPointerMove,cc(e=>{const t=e.target,n=D.current!==e.clientX;if(e.currentTarget.contains(t)&&n){const t=e.clientX>D.current?"right":"left";R.current=t,D.current=e.clientX}}))})})})})})})});Tl.displayName=Ml;var Bl=e.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return d(fn.div,{role:"group",...r,ref:t})});Bl.displayName="MenuGroup";var Il=e.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return d(fn.div,{...r,ref:t})});Il.displayName="MenuLabel";var _l="MenuItem",Fl="menu.itemSelect",Wl=e.forwardRef((t,n)=>{const{disabled:r=!1,onSelect:i,...o}=t,s=e.useRef(null),a=wl(_l,t.__scopeMenu),l=Nl(_l,t.__scopeMenu),c=Rt(n,s),u=e.useRef(!1);return d(jl,{...o,ref:c,disabled:r,onClick:Qt(t.onClick,()=>{const e=s.current;if(!r&&e){const t=new CustomEvent(Fl,{bubbles:!0,cancelable:!0});e.addEventListener(Fl,e=>i?.(e),{once:!0}),dn(e,t),t.defaultPrevented?u.current=!1:a.onClose()}}),onPointerDown:e=>{t.onPointerDown?.(e),u.current=!0},onPointerUp:Qt(t.onPointerUp,e=>{u.current||e.currentTarget?.click()}),onKeyDown:Qt(t.onKeyDown,e=>{const t=""!==l.searchRef.current;r||t&&" "===e.key||il.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});Wl.displayName=_l;var jl=e.forwardRef((t,n)=>{const{__scopeMenu:r,disabled:i=!1,textValue:o,...s}=t,a=Nl(_l,r),l=gl(r),c=e.useRef(null),u=Rt(n,c),[h,f]=e.useState(!1),[p,m]=e.useState("");return e.useEffect(()=>{const e=c.current;e&&m((e.textContent??"").trim())},[s.children]),d(ul.ItemSlot,{scope:r,disabled:i,textValue:o??p,children:d(rl,{asChild:!0,...l,focusable:!i,children:d(fn.div,{role:"menuitem","data-highlighted":h?"":void 0,"aria-disabled":i||void 0,"data-disabled":i?"":void 0,...s,ref:u,onPointerMove:Qt(t.onPointerMove,cc(e=>{if(i)a.onItemLeave(e);else if(a.onItemEnter(e),!e.defaultPrevented){e.currentTarget.focus({preventScroll:!0})}})),onPointerLeave:Qt(t.onPointerLeave,cc(e=>a.onItemLeave(e))),onFocus:Qt(t.onFocus,()=>f(!0)),onBlur:Qt(t.onBlur,()=>f(!1))})})})}),Hl=e.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...i}=e;return d($l,{scope:e.__scopeMenu,checked:n,children:d(Wl,{role:"menuitemcheckbox","aria-checked":ac(n)?"mixed":n,...i,ref:t,"data-state":lc(n),onSelect:Qt(i.onSelect,()=>r?.(!!ac(n)||!n),{checkForDefaultPrevented:!1})})})});Hl.displayName="MenuCheckboxItem";var zl="MenuRadioGroup",[Vl,ql]=dl(zl,{value:void 0,onValueChange:()=>{}}),Ul=e.forwardRef((e,t)=>{const{value:n,onValueChange:r,...i}=e,o=pn(r);return d(Vl,{scope:e.__scopeMenu,value:n,onValueChange:o,children:d(Bl,{...i,ref:t})})});Ul.displayName=zl;var Kl="MenuRadioItem",Gl=e.forwardRef((e,t)=>{const{value:n,...r}=e,i=ql(Kl,e.__scopeMenu),o=n===i.value;return d($l,{scope:e.__scopeMenu,checked:o,children:d(Wl,{role:"menuitemradio","aria-checked":o,...r,ref:t,"data-state":lc(o),onSelect:Qt(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});Gl.displayName=Kl;var Yl="MenuItemIndicator",[$l,Xl]=dl(Yl,{checked:!1}),Jl=e.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...i}=e,o=Xl(Yl,n);return d(Ln,{present:r||ac(o.checked)||!0===o.checked,children:d(fn.span,{...i,ref:t,"data-state":lc(o.checked)})})});Jl.displayName=Yl;var Ql=e.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return d(fn.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});Ql.displayName="MenuSeparator";var Zl=e.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=ml(n);return d(Hs,{...i,...r,ref:t})});Zl.displayName="MenuArrow";var[ec,tc]=dl("MenuSub"),nc="MenuSubTrigger",rc=e.forwardRef((t,n)=>{const r=yl(nc,t.__scopeMenu),i=wl(nc,t.__scopeMenu),o=tc(nc,t.__scopeMenu),s=Nl(nc,t.__scopeMenu),a=e.useRef(null),{pointerGraceTimerRef:l,onPointerGraceIntentChange:c}=s,u={__scopeMenu:t.__scopeMenu},h=e.useCallback(()=>{a.current&&window.clearTimeout(a.current),a.current=null},[]);return e.useEffect(()=>h,[h]),e.useEffect(()=>{const e=l.current;return()=>{window.clearTimeout(e),c(null)}},[l,c]),d(xl,{asChild:!0,...u,children:d(jl,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":r.open,"aria-controls":o.contentId,"data-state":sc(r.open),...t,ref:Tt(n,o.onTriggerChange),onClick:e=>{t.onClick?.(e),t.disabled||e.defaultPrevented||(e.currentTarget.focus(),r.open||r.onOpenChange(!0))},onPointerMove:Qt(t.onPointerMove,cc(e=>{s.onItemEnter(e),e.defaultPrevented||t.disabled||r.open||a.current||(s.onPointerGraceIntentChange(null),a.current=window.setTimeout(()=>{r.onOpenChange(!0),h()},100))})),onPointerLeave:Qt(t.onPointerLeave,cc(e=>{h();const t=r.content?.getBoundingClientRect();if(t){const n=r.content?.dataset.side,i="right"===n,o=i?-5:5,a=t[i?"left":"right"],c=t[i?"right":"left"];s.onPointerGraceIntentChange({area:[{x:e.clientX+o,y:e.clientY},{x:a,y:t.top},{x:c,y:t.top},{x:c,y:t.bottom},{x:a,y:t.bottom}],side:n}),window.clearTimeout(l.current),l.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(e),e.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:Qt(t.onKeyDown,e=>{const n=""!==s.searchRef.current;t.disabled||n&&" "===e.key||al[i.dir].includes(e.key)&&(r.onOpenChange(!0),r.content?.focus(),e.preventDefault())})})})});rc.displayName=nc;var ic="MenuSubContent",oc=e.forwardRef((t,n)=>{const r=El(Ml,t.__scopeMenu),{forceMount:i=r.forceMount,...o}=t,s=yl(Ml,t.__scopeMenu),a=wl(Ml,t.__scopeMenu),l=tc(ic,t.__scopeMenu),c=e.useRef(null),u=Rt(n,c);return d(ul.Provider,{scope:t.__scopeMenu,children:d(Ln,{present:i||s.open,children:d(ul.Slot,{scope:t.__scopeMenu,children:d(Ll,{id:l.contentId,"aria-labelledby":l.triggerId,...o,ref:u,align:"start",side:"rtl"===a.dir?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{a.isUsingKeyboardRef.current&&c.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:Qt(t.onFocusOutside,e=>{e.target!==l.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:Qt(t.onEscapeKeyDown,e=>{a.onClose(),e.preventDefault()}),onKeyDown:Qt(t.onKeyDown,e=>{const t=e.currentTarget.contains(e.target),n=ll[a.dir].includes(e.key);t&&n&&(s.onOpenChange(!1),l.trigger?.focus(),e.preventDefault())})})})})})});function sc(e){return e?"open":"closed"}function ac(e){return"indeterminate"===e}function lc(e){return ac(e)?"indeterminate":e?"checked":"unchecked"}function cc(e){return t=>"mouse"===t.pointerType?e(t):void 0}oc.displayName=ic;var uc=kl,hc=xl,fc=Al,dc=Tl,pc=Bl,mc=Il,gc=Wl,vc=Hl,yc=Ul,bc=Gl,wc=Jl,kc=Ql,xc=Zl,Sc=rc,Cc=oc,Ec="DropdownMenu",[Ac,Mc]=Zt(Ec,[pl]),Oc=pl(),[Nc,Tc]=Ac(Ec),Rc=t=>{const{__scopeDropdownMenu:n,children:r,dir:i,open:o,defaultOpen:s,onOpenChange:a,modal:l=!0}=t,c=Oc(n),u=e.useRef(null),[h,f]=an({prop:o,defaultProp:s??!1,onChange:a,caller:Ec});return d(Nc,{scope:n,triggerId:on(),triggerRef:u,contentId:on(),open:h,onOpenChange:f,onOpenToggle:e.useCallback(()=>f(e=>!e),[f]),modal:l,children:d(uc,{...c,open:h,onOpenChange:f,dir:i,modal:l,children:r})})};Rc.displayName=Ec;var Dc="DropdownMenuTrigger",Pc=e.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,o=Tc(Dc,n),s=Oc(n);return d(hc,{asChild:!0,...s,children:d(fn.button,{type:"button",id:o.triggerId,"aria-haspopup":"menu","aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":o.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...i,ref:Tt(t,o.triggerRef),onPointerDown:Qt(e.onPointerDown,e=>{r||0!==e.button||!1!==e.ctrlKey||(o.onOpenToggle(),o.open||e.preventDefault())}),onKeyDown:Qt(e.onKeyDown,e=>{r||(["Enter"," "].includes(e.key)&&o.onOpenToggle(),"ArrowDown"===e.key&&o.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(e.key)&&e.preventDefault())})})})});Pc.displayName=Dc;var Lc=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Oc(t);return d(fc,{...r,...n})};Lc.displayName="DropdownMenuPortal";var Bc="DropdownMenuContent",Ic=e.forwardRef((t,n)=>{const{__scopeDropdownMenu:r,...i}=t,o=Tc(Bc,r),s=Oc(r),a=e.useRef(!1);return d(dc,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...i,ref:n,onCloseAutoFocus:Qt(t.onCloseAutoFocus,e=>{a.current||o.triggerRef.current?.focus(),a.current=!1,e.preventDefault()}),onInteractOutside:Qt(t.onInteractOutside,e=>{const t=e.detail.originalEvent,n=0===t.button&&!0===t.ctrlKey,r=2===t.button||n;o.modal&&!r||(a.current=!0)}),style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Ic.displayName=Bc;e.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Oc(n);return d(pc,{...i,...r,ref:t})}).displayName="DropdownMenuGroup";var _c=e.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Oc(n);return d(mc,{...i,...r,ref:t})});_c.displayName="DropdownMenuLabel";var Fc=e.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Oc(n);return d(gc,{...i,...r,ref:t})});Fc.displayName="DropdownMenuItem";var Wc=e.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Oc(n);return d(vc,{...i,...r,ref:t})});Wc.displayName="DropdownMenuCheckboxItem";e.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Oc(n);return d(yc,{...i,...r,ref:t})}).displayName="DropdownMenuRadioGroup";var jc=e.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Oc(n);return d(bc,{...i,...r,ref:t})});jc.displayName="DropdownMenuRadioItem";var Hc=e.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Oc(n);return d(wc,{...i,...r,ref:t})});Hc.displayName="DropdownMenuItemIndicator";var zc=e.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Oc(n);return d(kc,{...i,...r,ref:t})});zc.displayName="DropdownMenuSeparator";e.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Oc(n);return d(xc,{...i,...r,ref:t})}).displayName="DropdownMenuArrow";var Vc=e.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Oc(n);return d(Sc,{...i,...r,ref:t})});Vc.displayName="DropdownMenuSubTrigger";var qc=e.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Oc(n);return d(Cc,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});qc.displayName="DropdownMenuSubContent";var Uc=Lc,Kc=Ic,Gc=_c,Yc=Fc,$c=Wc,Xc=jc,Jc=Hc,Qc=zc,Zc=Vc,eu=qc,tu=Rc,nu=Pc,ru=e.forwardRef(function(t,n){var r=t.className,i=t.inset,o=t.children,s=Z(t,["className","inset","children"]);return e.createElement(Zc,Object.assign({ref:n,className:Mt("flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",i&&"pl-8",r)},s),o,e.createElement(ce,{className:"ml-auto"}))});ru.displayName=Zc.displayName;var iu=e.forwardRef(function(t,n){var r=t.className,i=Z(t,["className"]);return e.createElement(eu,Object.assign({ref:n,className:Mt("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]",r)},i))});iu.displayName=eu.displayName;var ou=e.forwardRef(function(t,n){var r=t.className,i=t.sideOffset,o=void 0===i?4:i,s=Z(t,["className","sideOffset"]);return e.createElement(Uc,null,e.createElement(Kc,Object.assign({ref:n,sideOffset:o,className:Mt("z-50 max-h-[var(--radix-dropdown-menu-content-available-height)] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]",r)},s)))});ou.displayName=Kc.displayName;var su=e.forwardRef(function(t,n){var r=t.className,i=t.inset,o=Z(t,["className","inset"]);return e.createElement(Yc,Object.assign({ref:n,className:Mt("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",i&&"pl-8",r)},o))});su.displayName=Yc.displayName;var au=e.forwardRef(function(t,n){var r=t.className,i=t.children,o=t.checked,s=Z(t,["className","children","checked"]);return e.createElement($c,Object.assign({ref:n,className:Mt("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",r),checked:o},s),e.createElement("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center"},e.createElement(Jc,null,e.createElement(se,{className:"h-4 w-4"}))),i)});au.displayName=$c.displayName;var lu=e.forwardRef(function(t,n){var r=t.className,i=t.children,o=Z(t,["className","children"]);return e.createElement(Xc,Object.assign({ref:n,className:Mt("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",r)},o),e.createElement("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center"},e.createElement(Jc,null,e.createElement(he,{className:"h-2 w-2 fill-current"}))),i)});lu.displayName=Xc.displayName;var cu=e.forwardRef(function(t,n){var r=t.className,i=t.inset,o=Z(t,["className","inset"]);return e.createElement(Gc,Object.assign({ref:n,className:Mt("px-2 py-1.5 text-sm font-semibold",i&&"pl-8",r)},o))});cu.displayName=Gc.displayName;var uu=e.forwardRef(function(t,n){var r=t.className,i=Z(t,["className"]);return e.createElement(Qc,Object.assign({ref:n,className:Mt("-mx-1 my-1 h-px bg-muted",r)},i))});uu.displayName=Qc.displayName;var hu=e.forwardRef((e,t)=>d(Kt.label,{...e,ref:t,onMouseDown:t=>{t.target.closest("button, input, select, textarea")||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));hu.displayName="Label";var fu=hu,du=zt("text-sm font-bold leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 text-foreground"),pu=e.forwardRef(function(t,n){var r=t.className,i=Z(t,["className"]);return e.createElement(fu,Object.assign({ref:n,className:Mt(du(),r)},i))});pu.displayName=fu.displayName;var mu=e.forwardRef(function(t,n){var r=t.className,i=Z(t,["className"]);return e.createElement("div",Object.assign({ref:n,className:Mt("rounded-[2rem] border border-[hsl(var(--border))]/50 bg-card text-card-foreground shadow-[0_4px_20px_-2px_rgba(93,112,82,0.15)] transition-all duration-300",r)},i))});mu.displayName="Card";var gu=e.forwardRef(function(t,n){var r=t.className,i=Z(t,["className"]);return e.createElement("div",Object.assign({ref:n,className:Mt("flex flex-col space-y-1.5 p-6",r)},i))});gu.displayName="CardHeader";var vu=e.forwardRef(function(t,n){var r=t.className,i=Z(t,["className"]);return e.createElement("div",Object.assign({ref:n,className:Mt("text-2xl font-bold leading-none tracking-tight",r)},i))});vu.displayName="CardTitle";var yu=e.forwardRef(function(t,n){var r=t.className,i=Z(t,["className"]);return e.createElement("div",Object.assign({ref:n,className:Mt("text-sm text-muted-foreground",r)},i))});yu.displayName="CardDescription";var bu=e.forwardRef(function(t,n){var r=t.className,i=Z(t,["className"]);return e.createElement("div",Object.assign({ref:n,className:Mt("p-6 pt-0",r)},i))});bu.displayName="CardContent";var wu=e.forwardRef(function(t,n){var r=t.className,i=Z(t,["className"]);return e.createElement("div",Object.assign({ref:n,className:Mt("flex items-center p-6 pt-0",r)},i))});wu.displayName="CardFooter";var ku={items:[],config:Object.assign({},{top:24,duration:3,maxCount:5})},xu=new Set;function Su(){xu.forEach(function(e){return e(ku.items.slice())})}function Cu(e){switch(e){case"success":return t.createElement(oe,null);case"error":return t.createElement(Re,null);case"warning":return t.createElement(ie,null);case"loading":return t.createElement(be,{className:"animate-spin"});default:return t.createElement(ve,null)}}function Eu(e){var t,n,r;Nu();var i=Date.now(),o=null!==(t=e.key)&&void 0!==t?t:"msg_".concat(i,"_").concat(Math.random().toString(36).slice(2)),s=ku.items.findIndex(function(e){return e.key===o}),a={key:o,content:e.content,duration:null!==(n=e.duration)&&void 0!==n?n:ku.config.duration,type:e.type,onClose:e.onClose,icon:null!==(r=e.icon)&&void 0!==r?r:Cu(e.type),className:e.className,createdAt:i};return s>=0?ku.items[s]=Object.assign({},ku.items[s],a):(ku.items.length>=ku.config.maxCount&&ku.items.shift(),ku.items.push(a)),Su(),a.duration>0&&"loading"!==a.type&&window.setTimeout(function(){Au(o)},1e3*a.duration),{close:function(){return Au(o)}}}function Au(e){var t;if(void 0===e)return ku.items.forEach(function(e){var t;return null===(t=e.onClose)||void 0===t?void 0:t.call(e)}),ku.items=[],void Su();var n=ku.items.findIndex(function(t){return t.key===e});if(n>=0){var r=q(ku.items.splice(n,1),1)[0];null===(t=null==r?void 0:r.onClose)||void 0===t||t.call(r),Su()}}var Mu=null,Ou=null;function Nu(){"undefined"!=typeof window&&(Ou||((Ou=document.createElement("div")).setAttribute("data-custom-message-holder",""),document.body.appendChild(Ou)),Mu||(Mu=y(Ou)).render(t.createElement(Tu,null)))}function Tu(){var e=function(){var e=q(i(ku.items),2),t=e[0],n=e[1];return a(function(){var e=n;return xu.add(e),function(){xu.delete(e)}},[]),t}(),n=ku.config.top;return t.createElement("div",{className:"fixed left-1/2 -translate-x-1/2 z-[1000] w-80 pointer-events-none",style:{top:n}},t.createElement("div",{className:"mx-auto flex w-full max-w-xl flex-col items-center gap-2 px-4"},e.map(function(e){var n,r,i=function(e){switch(e){case"success":return{container:"border-green-200 bg-green-50/90 text-green-800 border-l-4 border-l-green-500",icon:"text-green-500",text:"text-green-800"};case"error":return{container:"border-red-200 bg-red-50/90 text-red-800 border-l-4 border-l-red-500",icon:"text-red-500",text:"text-red-800"};case"warning":return{container:"border-yellow-200 bg-yellow-50/90 text-yellow-800 border-l-4 border-l-yellow-500",icon:"text-yellow-500",text:"text-yellow-800"};default:return{container:"border-blue-200 bg-blue-50/90 text-blue-800 border-l-4 border-l-blue-500",icon:"text-blue-500",text:"text-blue-800"}}}(e.type);return t.createElement("div",{key:e.key,className:"pointer-events-auto flex w-full items-center gap-2 rounded-md border px-3 py-2 backdrop-blur ".concat(i.container," ").concat(null!==(n=e.className)&&void 0!==n?n:"")},t.createElement("span",{className:"text-[18px] leading-none ".concat(i.icon)},null!==(r=e.icon)&&void 0!==r?r:Cu(e.type)),t.createElement("div",{className:"min-w-0 flex-1 text-[14px] leading-normal ".concat(i.text)},"string"==typeof e.content?t.createElement("span",{className:"break-words align-middle"},e.content):e.content))})))}function Ru(e,n,r,i){if(t.isValidElement(n)||"string"==typeof n||"number"==typeof n)return{type:e,content:n,duration:r,onClose:i};var o=n;return Object.assign({},o,{type:e})}var Du,Pu,Lu=(Pu={open:function(e){var t;return Eu(Object.assign({},e,{type:null!==(t=e.type)&&void 0!==t?t:"info"}))},info:function(e,t,n){return Eu(Ru("info",e,t,n))},success:function(e,t,n){return Eu(Ru("success",e,t,n))},error:function(e,t,n){return Eu(Ru("error",e,t,n))},warning:function(e,t,n){return Eu(Ru("warning",e,t,n))},loading:function(e,t,n){return Eu(Ru("loading",e,null!=t?t:0,n))},destroy:function(e){return Au(e)},config:function(e){return t=e,ku.config=Object.assign({},ku.config,t),void Su();var t},useMessage:function(){var e=s(function(){return"undefined"!=typeof window&&Nu(),t.createElement(t.Fragment,null)},[]);return[Du.current,e]}},(Du={}).current=Pu,Pu);function Bu(e,t){return function(){return e.apply(t,arguments)}}var Iu,_u=Object.prototype.toString,Fu=Object.getPrototypeOf,Wu=Symbol.iterator,ju=Symbol.toStringTag,Hu=(Iu=Object.create(null),function(e){var t=_u.call(e);return Iu[t]||(Iu[t]=t.slice(8,-1).toLowerCase())}),zu=function(e){return e=e.toLowerCase(),function(t){return Hu(t)===e}},Vu=function(e){return function(t){return Y(t)===e}},qu=Array.isArray,Uu=Vu("undefined");function Ku(e){return null!==e&&!Uu(e)&&null!==e.constructor&&!Uu(e.constructor)&&$u(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var Gu=zu("ArrayBuffer");var Yu=Vu("string"),$u=Vu("function"),Xu=Vu("number"),Ju=function(e){return null!==e&&"object"===Y(e)},Qu=function(e){if("object"!==Hu(e))return!1;var t=Fu(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||ju in e||Wu in e)},Zu=zu("Date"),eh=zu("File"),th=zu("Blob"),nh=zu("FileList"),rh=zu("URLSearchParams"),ih=q(["ReadableStream","Request","Response","Headers"].map(zu),4),oh=ih[0],sh=ih[1],ah=ih[2],lh=ih[3];function ch(e,t){var n,r,i=(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).allOwnKeys,o=void 0!==i&&i;if(null!=e)if("object"!==Y(e)&&(e=[e]),qu(e))for(n=0,r=e.length;n<r;n++)t.call(null,e[n],n,e);else{if(Ku(e))return;var s,a=o?Object.getOwnPropertyNames(e):Object.keys(e),l=a.length;for(n=0;n<l;n++)s=a[n],t.call(null,e[s],s,e)}}function uh(e,t){if(Ku(e))return null;t=t.toLowerCase();for(var n,r=Object.keys(e),i=r.length;i-- >0;)if(t===(n=r[i]).toLowerCase())return n;return null}var hh="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,fh=function(e){return!Uu(e)&&e!==hh};var dh,ph=(dh="undefined"!=typeof Uint8Array&&Fu(Uint8Array),function(e){return dh&&e instanceof dh}),mh=zu("HTMLFormElement"),gh=function(){var e=Object.prototype.hasOwnProperty;return function(t,n){return e.call(t,n)}}(),vh=zu("RegExp"),yh=function(e,t){var n=Object.getOwnPropertyDescriptors(e),r={};ch(n,function(n,i){var o;!1!==(o=t(n,i,e))&&(r[i]=o||n)}),Object.defineProperties(e,r)};var bh,wh,kh,xh,Sh=zu("AsyncFunction"),Ch=(bh="function"==typeof setImmediate,wh=$u(hh.postMessage),bh?setImmediate:wh?(kh="axios@".concat(Math.random()),xh=[],hh.addEventListener("message",function(e){var t=e.source,n=e.data;t===hh&&n===kh&&xh.length&&xh.shift()()},!1),function(e){xh.push(e),hh.postMessage(kh,"*")}):function(e){return setTimeout(e)}),Eh="undefined"!=typeof queueMicrotask?queueMicrotask.bind(hh):"undefined"!=typeof process&&process.nextTick||Ch,Ah={isArray:qu,isArrayBuffer:Gu,isBuffer:Ku,isFormData:function(e){var t;return e&&("function"==typeof FormData&&e instanceof FormData||$u(e.append)&&("formdata"===(t=Hu(e))||"object"===t&&$u(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&Gu(e.buffer)},isString:Yu,isNumber:Xu,isBoolean:function(e){return!0===e||!1===e},isObject:Ju,isPlainObject:Qu,isEmptyObject:function(e){if(!Ju(e)||Ku(e))return!1;try{return 0===Object.keys(e).length&&Object.getPrototypeOf(e)===Object.prototype}catch(e){return!1}},isReadableStream:oh,isRequest:sh,isResponse:ah,isHeaders:lh,isUndefined:Uu,isDate:Zu,isFile:eh,isBlob:th,isRegExp:vh,isFunction:$u,isStream:function(e){return Ju(e)&&$u(e.pipe)},isURLSearchParams:rh,isTypedArray:ph,isFileList:nh,forEach:ch,merge:function e(){for(var t=fh(this)&&this||{},n=t.caseless,r=t.skipUndefined,i={},o=function(t,o){var s=n&&uh(i,o)||o;Qu(i[s])&&Qu(t)?i[s]=e(i[s],t):Qu(t)?i[s]=e({},t):qu(t)?i[s]=t.slice():r&&Uu(t)||(i[s]=t)},s=0,a=arguments.length;s<a;s++)arguments[s]&&ch(arguments[s],o);return i},extend:function(e,t,n){return ch(t,function(t,r){n&&$u(t)?e[r]=Bu(t,n):e[r]=t},{allOwnKeys:(arguments.length>3&&void 0!==arguments[3]?arguments[3]:{}).allOwnKeys}),e},trim:function(e){return e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")},stripBOM:function(e){return 65279===e.charCodeAt(0)&&(e=e.slice(1)),e},inherits:function(e,t,n,r){e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},toFlatObject:function(e,t,n,r){var i,o,s,a={};if(t=t||{},null==e)return t;do{for(o=(i=Object.getOwnPropertyNames(e)).length;o-- >0;)s=i[o],r&&!r(s,e,t)||a[s]||(t[s]=e[s],a[s]=!0);e=!1!==n&&Fu(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kindOf:Hu,kindOfTest:zu,endsWith:function(e,t,n){e=String(e),(void 0===n||n>e.length)&&(n=e.length),n-=t.length;var r=e.indexOf(t,n);return-1!==r&&r===n},toArray:function(e){if(!e)return null;if(qu(e))return e;var t=e.length;if(!Xu(t))return null;for(var n=new Array(t);t-- >0;)n[t]=e[t];return n},forEachEntry:function(e,t){for(var n,r=(e&&e[Wu]).call(e);(n=r.next())&&!n.done;){var i=n.value;t.call(e,i[0],i[1])}},matchAll:function(e,t){for(var n,r=[];null!==(n=e.exec(t));)r.push(n);return r},isHTMLForm:mh,hasOwnProperty:gh,hasOwnProp:gh,reduceDescriptors:yh,freezeMethods:function(e){yh(e,function(t,n){if($u(e)&&-1!==["arguments","caller","callee"].indexOf(n))return!1;var r=e[n];$u(r)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=function(){throw Error("Can not rewrite read-only method '"+n+"'")}))})},toObjectSet:function(e,t){var n={},r=function(e){e.forEach(function(e){n[e]=!0})};return qu(e)?r(e):r(String(e).split(t)),n},toCamelCase:function(e){return e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,t,n){return t.toUpperCase()+n})},noop:function(){},toFiniteNumber:function(e,t){return null!=e&&Number.isFinite(e=+e)?e:t},findKey:uh,global:hh,isContextDefined:fh,isSpecCompliantForm:function(e){return!!(e&&$u(e.append)&&"FormData"===e[ju]&&e[Wu])},toJSONObject:function(e){var t=new Array(10),n=function(e,r){if(Ju(e)){if(t.indexOf(e)>=0)return;if(Ku(e))return e;if(!("toJSON"in e)){t[r]=e;var i=qu(e)?[]:{};return ch(e,function(e,t){var o=n(e,r+1);!Uu(o)&&(i[t]=o)}),t[r]=void 0,i}}return e};return n(e,0)},isAsyncFn:Sh,isThenable:function(e){return e&&(Ju(e)||$u(e))&&$u(e.then)&&$u(e.catch)},setImmediate:Ch,asap:Eh,isIterable:function(e){return null!=e&&$u(e[Wu])}};function Mh(e,t,n,r,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),i&&(this.response=i,this.status=i.status?i.status:null)}Ah.inherits(Mh,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Ah.toJSONObject(this.config),code:this.code,status:this.status}}});var Oh=Mh.prototype,Nh={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(function(e){Nh[e]={value:e}}),Object.defineProperties(Mh,Nh),Object.defineProperty(Oh,"isAxiosError",{value:!0}),Mh.from=function(e,t,n,r,i,o){var s=Object.create(Oh);Ah.toFlatObject(e,s,function(e){return e!==Error.prototype},function(e){return"isAxiosError"!==e});var a=e&&e.message?e.message:"Error",l=null==t&&e?e.code:t;return Mh.call(s,a,l,n,r,i),e&&null==s.cause&&Object.defineProperty(s,"cause",{value:e,configurable:!0}),s.name=e&&e.name||"Error",o&&Object.assign(s,o),s};function Th(e){return Ah.isPlainObject(e)||Ah.isArray(e)}function Rh(e){return Ah.endsWith(e,"[]")?e.slice(0,-2):e}function Dh(e,t,n){return e?e.concat(t).map(function(e,t){return e=Rh(e),!n&&t?"["+e+"]":e}).join(n?".":""):t}var Ph=Ah.toFlatObject(Ah,{},null,function(e){return/^is[A-Z]/.test(e)});function Lh(e,t,n){if(!Ah.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;var r=(n=Ah.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(e,t){return!Ah.isUndefined(t[e])})).metaTokens,i=n.visitor||c,o=n.dots,s=n.indexes,a=(n.Blob||"undefined"!=typeof Blob&&Blob)&&Ah.isSpecCompliantForm(t);if(!Ah.isFunction(i))throw new TypeError("visitor must be a function");function l(e){if(null===e)return"";if(Ah.isDate(e))return e.toISOString();if(Ah.isBoolean(e))return e.toString();if(!a&&Ah.isBlob(e))throw new Mh("Blob is not supported. Use a Buffer instead.");return Ah.isArrayBuffer(e)||Ah.isTypedArray(e)?a&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function c(e,n,i){var a=e;if(e&&!i&&"object"===Y(e))if(Ah.endsWith(n,"{}"))n=r?n:n.slice(0,-2),e=JSON.stringify(e);else if(Ah.isArray(e)&&function(e){return Ah.isArray(e)&&!e.some(Th)}(e)||(Ah.isFileList(e)||Ah.endsWith(n,"[]"))&&(a=Ah.toArray(e)))return n=Rh(n),a.forEach(function(e,r){!Ah.isUndefined(e)&&null!==e&&t.append(!0===s?Dh([n],r,o):null===s?n:n+"[]",l(e))}),!1;return!!Th(e)||(t.append(Dh(i,n,o),l(e)),!1)}var u=[],h=Object.assign(Ph,{defaultVisitor:c,convertValue:l,isVisitable:Th});if(!Ah.isObject(e))throw new TypeError("data must be an object");return function e(n,r){if(!Ah.isUndefined(n)){if(-1!==u.indexOf(n))throw Error("Circular reference detected in "+r.join("."));u.push(n),Ah.forEach(n,function(n,o){!0===(!(Ah.isUndefined(n)||null===n)&&i.call(t,n,Ah.isString(o)?o.trim():o,r,h))&&e(n,r?r.concat(o):[o])}),u.pop()}}(e),t}function Bh(e){var t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(e){return t[e]})}function Ih(e,t){this._pairs=[],e&&Lh(e,this,t)}var _h=Ih.prototype;function Fh(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Wh(e,t,n){if(!t)return e;var r=n&&n.encode||Fh;Ah.isFunction(n)&&(n={serialize:n});var i,o=n&&n.serialize;if(i=o?o(t,n):Ah.isURLSearchParams(t)?t.toString():new Ih(t,n).toString(r)){var s=e.indexOf("#");-1!==s&&(e=e.slice(0,s)),e+=(-1===e.indexOf("?")?"?":"&")+i}return e}_h.append=function(e,t){this._pairs.push([e,t])},_h.toString=function(e){var t=e?function(t){return e.call(this,t,Bh)}:Bh;return this._pairs.map(function(e){return t(e[0])+"="+t(e[1])},"").join("&")};var jh=function(){return R(function e(){N(this,e),this.handlers=[]},[{key:"use",value:function(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1}},{key:"eject",value:function(e){this.handlers[e]&&(this.handlers[e]=null)}},{key:"clear",value:function(){this.handlers&&(this.handlers=[])}},{key:"forEach",value:function(e){Ah.forEach(this.handlers,function(t){null!==t&&e(t)})}}])}(),Hh=jh,zh={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Vh={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:Ih,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]},qh="undefined"!=typeof window&&"undefined"!=typeof document,Uh="object"===("undefined"==typeof navigator?"undefined":Y(navigator))&&navigator||void 0,Kh=qh&&(!Uh||["ReactNative","NativeScript","NS"].indexOf(Uh.product)<0),Gh="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,Yh=qh&&window.location.href||"http://localhost",$h=W(W({},Object.freeze({__proto__:null,hasBrowserEnv:qh,hasStandardBrowserEnv:Kh,hasStandardBrowserWebWorkerEnv:Gh,navigator:Uh,origin:Yh})),Vh);function Xh(e){function t(e,n,r,i){var o=e[i++];if("__proto__"===o)return!0;var s=Number.isFinite(+o),a=i>=e.length;return o=!o&&Ah.isArray(r)?r.length:o,a?(Ah.hasOwnProp(r,o)?r[o]=[r[o],n]:r[o]=n,!s):(r[o]&&Ah.isObject(r[o])||(r[o]=[]),t(e,n,r[o],i)&&Ah.isArray(r[o])&&(r[o]=function(e){var t,n,r={},i=Object.keys(e),o=i.length;for(t=0;t<o;t++)r[n=i[t]]=e[n];return r}(r[o])),!s)}if(Ah.isFormData(e)&&Ah.isFunction(e.entries)){var n={};return Ah.forEachEntry(e,function(e,r){t(function(e){return Ah.matchAll(/\w+|\[(\w*)]/g,e).map(function(e){return"[]"===e[0]?"":e[1]||e[0]})}(e),r,n,0)}),n}return null}var Jh={transitional:zh,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){var n,r=t.getContentType()||"",i=r.indexOf("application/json")>-1,o=Ah.isObject(e);if(o&&Ah.isHTMLForm(e)&&(e=new FormData(e)),Ah.isFormData(e))return i?JSON.stringify(Xh(e)):e;if(Ah.isArrayBuffer(e)||Ah.isBuffer(e)||Ah.isStream(e)||Ah.isFile(e)||Ah.isBlob(e)||Ah.isReadableStream(e))return e;if(Ah.isArrayBufferView(e))return e.buffer;if(Ah.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();if(o){if(r.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return Lh(e,new $h.classes.URLSearchParams,W({visitor:function(e,t,n,r){return $h.isNode&&Ah.isBuffer(e)?(this.append(t,e.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)}},t))}(e,this.formSerializer).toString();if((n=Ah.isFileList(e))||r.indexOf("multipart/form-data")>-1){var s=this.env&&this.env.FormData;return Lh(n?{"files[]":e}:e,s&&new s,this.formSerializer)}}return o||i?(t.setContentType("application/json",!1),function(e,t,n){if(Ah.isString(e))try{return(t||JSON.parse)(e),Ah.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(n||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){var t=this.transitional||Jh.transitional,n=t&&t.forcedJSONParsing,r="json"===this.responseType;if(Ah.isResponse(e)||Ah.isReadableStream(e))return e;if(e&&Ah.isString(e)&&(n&&!this.responseType||r)){var i=!(t&&t.silentJSONParsing)&&r;try{return JSON.parse(e,this.parseReviver)}catch(e){if(i){if("SyntaxError"===e.name)throw Mh.from(e,Mh.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:$h.classes.FormData,Blob:$h.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Ah.forEach(["delete","get","head","post","put","patch"],function(e){Jh.headers[e]={}});var Qh=Jh,Zh=Ah.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),ef=Symbol("internals");function tf(e){return e&&String(e).trim().toLowerCase()}function nf(e){return!1===e||null==e?e:Ah.isArray(e)?e.map(nf):String(e)}function rf(e,t,n,r,i){return Ah.isFunction(r)?r.call(this,t,n):(i&&(t=n),Ah.isString(t)?Ah.isString(r)?-1!==t.indexOf(r):Ah.isRegExp(r)?r.test(t):void 0:void 0)}var of=function(){return R(function e(t){N(this,e),t&&this.set(t)},[{key:"set",value:function(e,t,n){var r=this;function i(e,t,n){var i=tf(t);if(!i)throw new Error("header name must be a non-empty string");var o=Ah.findKey(r,i);(!o||void 0===r[o]||!0===n||void 0===n&&!1!==r[o])&&(r[o||t]=nf(e))}var o=function(e,t){return Ah.forEach(e,function(e,n){return i(e,n,t)})};if(Ah.isPlainObject(e)||e instanceof this.constructor)o(e,t);else if(Ah.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim()))o(function(e){var t,n,r,i={};return e&&e.split("\n").forEach(function(e){r=e.indexOf(":"),t=e.substring(0,r).trim().toLowerCase(),n=e.substring(r+1).trim(),!t||i[t]&&Zh[t]||("set-cookie"===t?i[t]?i[t].push(n):i[t]=[n]:i[t]=i[t]?i[t]+", "+n:n)}),i}(e),t);else if(Ah.isObject(e)&&Ah.isIterable(e)){var s,a,l,c={},u=D(e);try{for(u.s();!(l=u.n()).done;){var h=l.value;if(!Ah.isArray(h))throw TypeError("Object iterator must return a key-value pair");c[a=h[0]]=(s=c[a])?Ah.isArray(s)?[].concat(K(s),[h[1]]):[s,h[1]]:h[1]}}catch(e){u.e(e)}finally{u.f()}o(c,t)}else null!=e&&i(t,e,n);return this}},{key:"get",value:function(e,t){if(e=tf(e)){var n=Ah.findKey(this,e);if(n){var r=this[n];if(!t)return r;if(!0===t)return function(e){for(var t,n=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;t=r.exec(e);)n[t[1]]=t[2];return n}(r);if(Ah.isFunction(t))return t.call(this,r,n);if(Ah.isRegExp(t))return t.exec(r);throw new TypeError("parser must be boolean|regexp|function")}}}},{key:"has",value:function(e,t){if(e=tf(e)){var n=Ah.findKey(this,e);return!(!n||void 0===this[n]||t&&!rf(0,this[n],n,t))}return!1}},{key:"delete",value:function(e,t){var n=this,r=!1;function i(e){if(e=tf(e)){var i=Ah.findKey(n,e);!i||t&&!rf(0,n[i],i,t)||(delete n[i],r=!0)}}return Ah.isArray(e)?e.forEach(i):i(e),r}},{key:"clear",value:function(e){for(var t=Object.keys(this),n=t.length,r=!1;n--;){var i=t[n];e&&!rf(0,this[i],i,e,!0)||(delete this[i],r=!0)}return r}},{key:"normalize",value:function(e){var t=this,n={};return Ah.forEach(this,function(r,i){var o=Ah.findKey(n,i);if(o)return t[o]=nf(r),void delete t[i];var s=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,function(e,t,n){return t.toUpperCase()+n})}(i):String(i).trim();s!==i&&delete t[i],t[s]=nf(r),n[s]=!0}),this}},{key:"concat",value:function(){for(var e,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(e=this.constructor).concat.apply(e,[this].concat(n))}},{key:"toJSON",value:function(e){var t=Object.create(null);return Ah.forEach(this,function(n,r){null!=n&&!1!==n&&(t[r]=e&&Ah.isArray(n)?n.join(", "):n)}),t}},{key:Symbol.iterator,value:function(){return Object.entries(this.toJSON())[Symbol.iterator]()}},{key:"toString",value:function(){return Object.entries(this.toJSON()).map(function(e){var t=q(e,2);return t[0]+": "+t[1]}).join("\n")}},{key:"getSetCookie",value:function(){return this.get("set-cookie")||[]}},{key:Symbol.toStringTag,get:function(){return"AxiosHeaders"}}],[{key:"from",value:function(e){return e instanceof this?e:new this(e)}},{key:"concat",value:function(e){for(var t=new this(e),n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return r.forEach(function(e){return t.set(e)}),t}},{key:"accessor",value:function(e){var t=(this[ef]=this[ef]={accessors:{}}).accessors,n=this.prototype;function r(e){var r=tf(e);t[r]||(!function(e,t){var n=Ah.toCamelCase(" "+t);["get","set","has"].forEach(function(r){Object.defineProperty(e,r+n,{value:function(e,n,i){return this[r].call(this,t,e,n,i)},configurable:!0})})}(n,e),t[r]=!0)}return Ah.isArray(e)?e.forEach(r):r(e),this}}])}();of.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),Ah.reduceDescriptors(of.prototype,function(e,t){var n=e.value,r=t[0].toUpperCase()+t.slice(1);return{get:function(){return n},set:function(e){this[r]=e}}}),Ah.freezeMethods(of);var sf=of;function af(e,t){var n=this||Qh,r=t||n,i=sf.from(r.headers),o=r.data;return Ah.forEach(e,function(e){o=e.call(n,o,i.normalize(),t?t.status:void 0)}),i.normalize(),o}function lf(e){return!(!e||!e.__CANCEL__)}function cf(e,t,n){Mh.call(this,null==e?"canceled":e,Mh.ERR_CANCELED,t,n),this.name="CanceledError"}function uf(e,t,n){var r=n.config.validateStatus;n.status&&r&&!r(n.status)?t(new Mh("Request failed with status code "+n.status,[Mh.ERR_BAD_REQUEST,Mh.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n)):e(n)}Ah.inherits(cf,Mh,{__CANCEL__:!0});var hf=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:3,r=0,i=function(e,t){e=e||10;var n,r=new Array(e),i=new Array(e),o=0,s=0;return t=void 0!==t?t:1e3,function(a){var l=Date.now(),c=i[s];n||(n=l),r[o]=a,i[o]=l;for(var u=s,h=0;u!==o;)h+=r[u++],u%=e;if((o=(o+1)%e)===s&&(s=(s+1)%e),!(l-n<t)){var f=c&&l-c;return f?Math.round(1e3*h/f):void 0}}}(50,250);return function(e,t){var n,r,i=0,o=1e3/t,s=function(t){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Date.now();i=o,n=null,r&&(clearTimeout(r),r=null),e.apply(void 0,K(t))};return[function(){for(var e=Date.now(),t=e-i,a=arguments.length,l=new Array(a),c=0;c<a;c++)l[c]=arguments[c];t>=o?s(l,e):(n=l,r||(r=setTimeout(function(){r=null,s(n)},o-t)))},function(){return n&&s(n)}]}(function(n){var o=n.loaded,s=n.lengthComputable?n.total:void 0,a=o-r,l=i(a);r=o;var c=P({loaded:o,total:s,progress:s?o/s:void 0,bytes:a,rate:l||void 0,estimated:l&&s&&o<=s?(s-o)/l:void 0,event:n,lengthComputable:null!=s},t?"download":"upload",!0);e(c)},n)},ff=function(e,t){var n=null!=e;return[function(r){return t[0]({lengthComputable:n,total:e,loaded:r})},t[1]]},df=function(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return Ah.asap(function(){return e.apply(void 0,n)})}},pf=$h.hasStandardBrowserEnv?function(e,t){return function(n){return n=new URL(n,$h.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)}}(new URL($h.origin),$h.navigator&&/(msie|trident)/i.test($h.navigator.userAgent)):function(){return!0},mf=$h.hasStandardBrowserEnv?{write:function(e,t,n,r,i,o,s){if("undefined"!=typeof document){var a=["".concat(e,"=").concat(encodeURIComponent(t))];Ah.isNumber(n)&&a.push("expires=".concat(new Date(n).toUTCString())),Ah.isString(r)&&a.push("path=".concat(r)),Ah.isString(i)&&a.push("domain=".concat(i)),!0===o&&a.push("secure"),Ah.isString(s)&&a.push("SameSite=".concat(s)),document.cookie=a.join("; ")}},read:function(e){if("undefined"==typeof document)return null;var t=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return t?decodeURIComponent(t[1]):null},remove:function(e){this.write(e,"",Date.now()-864e5,"/")}}:{write:function(){},read:function(){return null},remove:function(){}};function gf(e,t,n){var r=!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t);return e&&(r||0==n)?function(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}var vf=function(e){return e instanceof sf?W({},e):e};function yf(e,t){t=t||{};var n={};function r(e,t,n,r){return Ah.isPlainObject(e)&&Ah.isPlainObject(t)?Ah.merge.call({caseless:r},e,t):Ah.isPlainObject(t)?Ah.merge({},t):Ah.isArray(t)?t.slice():t}function i(e,t,n,i){return Ah.isUndefined(t)?Ah.isUndefined(e)?void 0:r(void 0,e,0,i):r(e,t,0,i)}function o(e,t){if(!Ah.isUndefined(t))return r(void 0,t)}function s(e,t){return Ah.isUndefined(t)?Ah.isUndefined(e)?void 0:r(void 0,e):r(void 0,t)}function a(n,i,o){return o in t?r(n,i):o in e?r(void 0,n):void 0}var l={url:o,method:o,data:o,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:a,headers:function(e,t,n){return i(vf(e),vf(t),0,!0)}};return Ah.forEach(Object.keys(W(W({},e),t)),function(r){var o=l[r]||i,s=o(e[r],t[r],r);Ah.isUndefined(s)&&o!==a||(n[r]=s)}),n}var bf,wf=function(e){var t=yf({},e),n=t.data,r=t.withXSRFToken,i=t.xsrfHeaderName,o=t.xsrfCookieName,s=t.headers,a=t.auth;if(t.headers=s=sf.from(s),t.url=Wh(gf(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&s.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),Ah.isFormData(n))if($h.hasStandardBrowserEnv||$h.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if(Ah.isFunction(n.getHeaders)){var l=n.getHeaders(),c=["content-type","content-length"];Object.entries(l).forEach(function(e){var t=q(e,2),n=t[0],r=t[1];c.includes(n.toLowerCase())&&s.set(n,r)})}if($h.hasStandardBrowserEnv&&(r&&Ah.isFunction(r)&&(r=r(t)),r||!1!==r&&pf(t.url))){var u=i&&o&&mf.read(o);u&&s.set(i,u)}return t},kf="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise(function(t,n){var r,i,o,s,a,l=wf(e),c=l.data,u=sf.from(l.headers).normalize(),h=l.responseType,f=l.onUploadProgress,d=l.onDownloadProgress;function p(){s&&s(),a&&a(),l.cancelToken&&l.cancelToken.unsubscribe(r),l.signal&&l.signal.removeEventListener("abort",r)}var m=new XMLHttpRequest;function g(){if(m){var r=sf.from("getAllResponseHeaders"in m&&m.getAllResponseHeaders());uf(function(e){t(e),p()},function(e){n(e),p()},{data:h&&"text"!==h&&"json"!==h?m.response:m.responseText,status:m.status,statusText:m.statusText,headers:r,config:e,request:m}),m=null}}if(m.open(l.method.toUpperCase(),l.url,!0),m.timeout=l.timeout,"onloadend"in m?m.onloadend=g:m.onreadystatechange=function(){m&&4===m.readyState&&(0!==m.status||m.responseURL&&0===m.responseURL.indexOf("file:"))&&setTimeout(g)},m.onabort=function(){m&&(n(new Mh("Request aborted",Mh.ECONNABORTED,e,m)),m=null)},m.onerror=function(t){var r=new Mh(t&&t.message?t.message:"Network Error",Mh.ERR_NETWORK,e,m);r.event=t||null,n(r),m=null},m.ontimeout=function(){var t=l.timeout?"timeout of "+l.timeout+"ms exceeded":"timeout exceeded",r=l.transitional||zh;l.timeoutErrorMessage&&(t=l.timeoutErrorMessage),n(new Mh(t,r.clarifyTimeoutError?Mh.ETIMEDOUT:Mh.ECONNABORTED,e,m)),m=null},void 0===c&&u.setContentType(null),"setRequestHeader"in m&&Ah.forEach(u.toJSON(),function(e,t){m.setRequestHeader(t,e)}),Ah.isUndefined(l.withCredentials)||(m.withCredentials=!!l.withCredentials),h&&"json"!==h&&(m.responseType=l.responseType),d){var v=q(hf(d,!0),2);o=v[0],a=v[1],m.addEventListener("progress",o)}if(f&&m.upload){var y=q(hf(f),2);i=y[0],s=y[1],m.upload.addEventListener("progress",i),m.upload.addEventListener("loadend",s)}(l.cancelToken||l.signal)&&(r=function(t){m&&(n(!t||t.type?new cf(null,e,m):t),m.abort(),m=null)},l.cancelToken&&l.cancelToken.subscribe(r),l.signal&&(l.signal.aborted?r():l.signal.addEventListener("abort",r)));var b,w,k=(b=l.url,(w=/^([-+\w]{1,25})(:?\/\/|:)/.exec(b))&&w[1]||"");k&&-1===$h.protocols.indexOf(k)?n(new Mh("Unsupported protocol "+k+":",Mh.ERR_BAD_REQUEST,e)):m.send(c||null)})},xf=function(e,t){var n=(e=e?e.filter(Boolean):[]).length;if(t||n){var r,i=new AbortController,o=function(e){if(!r){r=!0,a();var t=e instanceof Error?e:this.reason;i.abort(t instanceof Mh?t:new cf(t instanceof Error?t.message:t))}},s=t&&setTimeout(function(){s=null,o(new Mh("timeout ".concat(t," of ms exceeded"),Mh.ETIMEDOUT))},t),a=function(){e&&(s&&clearTimeout(s),s=null,e.forEach(function(e){e.unsubscribe?e.unsubscribe(o):e.removeEventListener("abort",o)}),e=null)};e.forEach(function(e){return e.addEventListener("abort",o)});var l=i.signal;return l.unsubscribe=function(){return Ah.asap(a)},l}},Sf=j().m(function e(t,n){var r,i,o;return j().w(function(e){for(;;)switch(e.n){case 0:if(r=t.byteLength,n&&!(r<n)){e.n=2;break}return e.n=1,t;case 1:return e.a(2);case 2:i=0;case 3:if(!(i<r)){e.n=5;break}return o=i+n,e.n=4,t.slice(i,o);case 4:i=o,e.n=3;break;case 5:return e.a(2)}},e)}),Cf=function(){var e=X(j().m(function e(t,n){var r,i,o,s,a,l,c;return j().w(function(e){for(;;)switch(e.p=e.n){case 0:r=!1,i=!1,e.p=1,s=S(Ef(t));case 2:return e.n=3,M(s.next());case 3:if(!(r=!(a=e.v).done)){e.n=5;break}return l=a.value,e.d(z(x(S(Sf(l,n)))),4);case 4:r=!1,e.n=2;break;case 5:e.n=7;break;case 6:e.p=6,c=e.v,i=!0,o=c;case 7:if(e.p=7,e.p=8,!r||null==s.return){e.n=9;break}return e.n=9,M(s.return());case 9:if(e.p=9,!i){e.n=10;break}throw o;case 10:return e.f(9);case 11:return e.f(7);case 12:return e.a(2)}},e,null,[[8,,9,11],[1,6,7,12]])}));return function(t,n){return e.apply(this,arguments)}}(),Ef=function(){var e=X(j().m(function e(t){var n,r,i,o;return j().w(function(e){for(;;)switch(e.p=e.n){case 0:if(!t[Symbol.asyncIterator]){e.n=2;break}return e.d(z(x(S(t))),1);case 1:return e.a(2);case 2:n=t.getReader(),e.p=3;case 4:return e.n=5,M(n.read());case 5:if(r=e.v,i=r.done,o=r.value,!i){e.n=6;break}return e.a(3,8);case 6:return e.n=7,o;case 7:e.n=4;break;case 8:return e.p=8,e.n=9,M(n.cancel());case 9:return e.f(8);case 10:return e.a(2)}},e,null,[[3,,8,10]])}));return function(t){return e.apply(this,arguments)}}(),Af=function(e,t,n,r){var i,o=Cf(e,t),s=0,a=function(e){i||(i=!0,r&&r(e))};return new ReadableStream({pull:function(e){return A(j().m(function t(){var r,i,l,c,u,h;return j().w(function(t){for(;;)switch(t.p=t.n){case 0:return t.p=0,t.n=1,o.next();case 1:if(r=t.v,i=r.done,l=r.value,!i){t.n=2;break}return a(),e.close(),t.a(2);case 2:c=l.byteLength,n&&(u=s+=c,n(u)),e.enqueue(new Uint8Array(l)),t.n=4;break;case 3:throw t.p=3,h=t.v,a(h),h;case 4:return t.a(2)}},t,null,[[0,3]])}))()},cancel:function(e){return a(e),o.return()}},{highWaterMark:2})},Mf=Ah.isFunction,Of={Request:(bf=Ah.global).Request,Response:bf.Response},Nf=Ah.global,Tf=Nf.ReadableStream,Rf=Nf.TextEncoder,Df=function(e){try{for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return!!e.apply(void 0,n)}catch(e){return!1}},Pf=function(e){var t=e=Ah.merge.call({skipUndefined:!0},Of,e),n=t.fetch,r=t.Request,i=t.Response,o=n?Mf(n):"function"==typeof fetch,s=Mf(r),a=Mf(i);if(!o)return!1;var l,c=o&&Mf(Tf),u=o&&("function"==typeof Rf?(l=new Rf,function(e){return l.encode(e)}):function(){var e=A(j().m(function e(t){var n,i;return j().w(function(e){for(;;)switch(e.n){case 0:return n=Uint8Array,e.n=1,new r(t).arrayBuffer();case 1:return i=e.v,e.a(2,new n(i))}},e)}));return function(t){return e.apply(this,arguments)}}()),h=s&&c&&Df(function(){var e=!1,t=new r($h.origin,{body:new Tf,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),f=a&&c&&Df(function(){return Ah.isReadableStream(new i("").body)}),d={stream:f&&function(e){return e.body}};o&&["text","arrayBuffer","blob","formData","stream"].forEach(function(e){!d[e]&&(d[e]=function(t,n){var r=t&&t[e];if(r)return r.call(t);throw new Mh("Response type '".concat(e,"' is not supported"),Mh.ERR_NOT_SUPPORT,n)})});var p=function(){var e=A(j().m(function e(t){var n;return j().w(function(e){for(;;)switch(e.n){case 0:if(null!=t){e.n=1;break}return e.a(2,0);case 1:if(!Ah.isBlob(t)){e.n=2;break}return e.a(2,t.size);case 2:if(!Ah.isSpecCompliantForm(t)){e.n=4;break}return n=new r($h.origin,{method:"POST",body:t}),e.n=3,n.arrayBuffer();case 3:case 6:return e.a(2,e.v.byteLength);case 4:if(!Ah.isArrayBufferView(t)&&!Ah.isArrayBuffer(t)){e.n=5;break}return e.a(2,t.byteLength);case 5:if(Ah.isURLSearchParams(t)&&(t+=""),!Ah.isString(t)){e.n=7;break}return e.n=6,u(t);case 7:return e.a(2)}},e)}));return function(t){return e.apply(this,arguments)}}(),m=function(){var e=A(j().m(function e(t,n){var r;return j().w(function(e){for(;;)if(0===e.n)return r=Ah.toFiniteNumber(t.getContentLength()),e.a(2,null==r?p(n):r)},e)}));return function(t,n){return e.apply(this,arguments)}}();return function(){var e=A(j().m(function e(t){var o,a,l,c,u,p,g,v,y,b,w,k,x,S,C,E,A,M,O,N,T,R,D,P,L,B,I,_,F,H,z,V,U,K,G,Y,$,X,J;return j().w(function(e){for(;;)switch(e.p=e.n){case 0:if(o=wf(t),a=o.url,l=o.method,c=o.data,u=o.signal,p=o.cancelToken,g=o.timeout,v=o.onDownloadProgress,y=o.onUploadProgress,b=o.responseType,w=o.headers,k=o.withCredentials,x=void 0===k?"same-origin":k,S=o.fetchOptions,C=n||fetch,b=b?(b+"").toLowerCase():"text",E=xf([u,p&&p.toAbortSignal()],g),A=null,M=E&&E.unsubscribe&&function(){E.unsubscribe()},e.p=1,!($=y&&h&&"get"!==l&&"head"!==l)){e.n=3;break}return e.n=2,m(w,c);case 2:X=O=e.v,$=0!==X;case 3:if(!$){e.n=4;break}N=new r(a,{method:"POST",body:c,duplex:"half"}),Ah.isFormData(c)&&(T=N.headers.get("content-type"))&&w.setContentType(T),N.body&&(R=ff(O,hf(df(y))),D=q(R,2),P=D[0],L=D[1],c=Af(N.body,65536,P,L));case 4:return Ah.isString(x)||(x=x?"include":"omit"),B=s&&"credentials"in r.prototype,I=W(W({},S),{},{signal:E,method:l.toUpperCase(),headers:w.normalize().toJSON(),body:c,duplex:"half",credentials:B?x:void 0}),A=s&&new r(a,I),e.n=5,s?C(A,S):C(a,I);case 5:return _=e.v,F=f&&("stream"===b||"response"===b),f&&(v||F&&M)&&(H={},["status","statusText","headers"].forEach(function(e){H[e]=_[e]}),z=Ah.toFiniteNumber(_.headers.get("content-length")),V=v&&ff(z,hf(df(v),!0))||[],U=q(V,2),K=U[0],G=U[1],_=new i(Af(_.body,65536,K,function(){G&&G(),M&&M()}),H)),b=b||"text",e.n=6,d[Ah.findKey(d,b)||"text"](_,t);case 6:return Y=e.v,!F&&M&&M(),e.n=7,new Promise(function(e,n){uf(e,n,{data:Y,headers:sf.from(_.headers),status:_.status,statusText:_.statusText,config:t,request:A})});case 7:return e.a(2,e.v);case 8:if(e.p=8,J=e.v,M&&M(),!J||"TypeError"!==J.name||!/Load failed|fetch/i.test(J.message)){e.n=9;break}throw Object.assign(new Mh("Network Error",Mh.ERR_NETWORK,t,A),{cause:J.cause||J});case 9:throw Mh.from(J,J&&J.code,t,A);case 10:return e.a(2)}},e,null,[[1,8]])}));return function(t){return e.apply(this,arguments)}}()},Lf=new Map,Bf=function(e){for(var t,n,r=e&&e.env||{},i=r.fetch,o=[r.Request,r.Response,i],s=o.length,a=Lf;s--;)t=o[s],void 0===(n=a.get(t))&&a.set(t,n=s?new Map:Pf(r)),a=n;return n};Bf();var If={http:null,xhr:kf,fetch:{get:Bf}};Ah.forEach(If,function(e,t){if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}});var _f=function(e){return"- ".concat(e)},Ff=function(e){return Ah.isFunction(e)||null===e||!1===e};var Wf={getAdapter:function(e,t){for(var n,r,i=(e=Ah.isArray(e)?e:[e]).length,o={},s=0;s<i;s++){var a=void 0;if(r=n=e[s],!Ff(n)&&void 0===(r=If[(a=String(n)).toLowerCase()]))throw new Mh("Unknown adapter '".concat(a,"'"));if(r&&(Ah.isFunction(r)||(r=r.get(t))))break;o[a||"#"+s]=r}if(!r){var l=Object.entries(o).map(function(e){var t=q(e,2),n=t[0],r=t[1];return"adapter ".concat(n," ")+(!1===r?"is not supported by the environment":"is not available in the build")});throw new Mh("There is no suitable adapter to dispatch the request "+(i?l.length>1?"since :\n"+l.map(_f).join("\n"):" "+_f(l[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return r},adapters:If};function jf(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new cf(null,e)}function Hf(e){return jf(e),e.headers=sf.from(e.headers),e.data=af.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Wf.getAdapter(e.adapter||Qh.adapter,e)(e).then(function(t){return jf(e),t.data=af.call(e,e.transformResponse,t),t.headers=sf.from(t.headers),t},function(t){return lf(t)||(jf(e),t&&t.response&&(t.response.data=af.call(e,e.transformResponse,t.response),t.response.headers=sf.from(t.response.headers))),Promise.reject(t)})}var zf="1.13.2",Vf={};["object","boolean","number","function","string","symbol"].forEach(function(e,t){Vf[e]=function(n){return Y(n)===e||"a"+(t<1?"n ":" ")+e}});var qf={};Vf.transitional=function(e,t,n){return function(r,i,o){if(!1===e)throw new Mh(function(e,t){return"[Axios v"+zf+"] Transitional option '"+e+"'"+t+(n?". "+n:"")}(i," has been removed"+(t?" in "+t:"")),Mh.ERR_DEPRECATED);return t&&!qf[i]&&(qf[i]=!0),!e||e(r,i,o)}},Vf.spelling=function(e){return function(e,t){return!0}};var Uf={assertOptions:function(e,t,n){if("object"!==Y(e))throw new Mh("options must be an object",Mh.ERR_BAD_OPTION_VALUE);for(var r=Object.keys(e),i=r.length;i-- >0;){var o=r[i],s=t[o];if(s){var a=e[o],l=void 0===a||s(a,o,e);if(!0!==l)throw new Mh("option "+o+" must be "+l,Mh.ERR_BAD_OPTION_VALUE)}else if(!0!==n)throw new Mh("Unknown option "+o,Mh.ERR_BAD_OPTION)}},validators:Vf},Kf=Uf.validators,Gf=function(){return R(function e(t){N(this,e),this.defaults=t||{},this.interceptors={request:new Hh,response:new Hh}},[{key:"request",value:(e=A(j().m(function e(t,n){var r,i,o;return j().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,this._request(t,n);case 1:return e.a(2,e.v);case 2:if(e.p=2,(o=e.v)instanceof Error){r={},Error.captureStackTrace?Error.captureStackTrace(r):r=new Error,i=r.stack?r.stack.replace(/^.+\n/,""):"";try{o.stack?i&&!String(o.stack).endsWith(i.replace(/^.+\n.+\n/,""))&&(o.stack+="\n"+i):o.stack=i}catch(e){}}throw o;case 3:return e.a(2)}},e,this,[[0,2]])})),function(t,n){return e.apply(this,arguments)})},{key:"_request",value:function(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{};var n=t=yf(this.defaults,t),r=n.transitional,i=n.paramsSerializer,o=n.headers;void 0!==r&&Uf.assertOptions(r,{silentJSONParsing:Kf.transitional(Kf.boolean),forcedJSONParsing:Kf.transitional(Kf.boolean),clarifyTimeoutError:Kf.transitional(Kf.boolean)},!1),null!=i&&(Ah.isFunction(i)?t.paramsSerializer={serialize:i}:Uf.assertOptions(i,{encode:Kf.function,serialize:Kf.function},!0)),void 0!==t.allowAbsoluteUrls||(void 0!==this.defaults.allowAbsoluteUrls?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),Uf.assertOptions(t,{baseUrl:Kf.spelling("baseURL"),withXsrfToken:Kf.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();var s=o&&Ah.merge(o.common,o[t.method]);o&&Ah.forEach(["delete","get","head","post","put","patch","common"],function(e){delete o[e]}),t.headers=sf.concat(s,o);var a=[],l=!0;this.interceptors.request.forEach(function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(l=l&&e.synchronous,a.unshift(e.fulfilled,e.rejected))});var c,u=[];this.interceptors.response.forEach(function(e){u.push(e.fulfilled,e.rejected)});var h,f=0;if(!l){var d=[Hf.bind(this),void 0];for(d.unshift.apply(d,a),d.push.apply(d,u),h=d.length,c=Promise.resolve(t);f<h;)c=c.then(d[f++],d[f++]);return c}h=a.length;for(var p=t;f<h;){var m=a[f++],g=a[f++];try{p=m(p)}catch(e){g.call(this,e);break}}try{c=Hf.call(this,p)}catch(e){return Promise.reject(e)}for(f=0,h=u.length;f<h;)c=c.then(u[f++],u[f++]);return c}},{key:"getUri",value:function(e){return Wh(gf((e=yf(this.defaults,e)).baseURL,e.url,e.allowAbsoluteUrls),e.params,e.paramsSerializer)}}]);var e}();Ah.forEach(["delete","get","head","options"],function(e){Gf.prototype[e]=function(t,n){return this.request(yf(n||{},{method:e,url:t,data:(n||{}).data}))}}),Ah.forEach(["post","put","patch"],function(e){function t(t){return function(n,r,i){return this.request(yf(i||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:n,data:r}))}}Gf.prototype[e]=t(),Gf.prototype[e+"Form"]=t(!0)});var Yf=Gf,$f=function(){function e(t){if(N(this,e),"function"!=typeof t)throw new TypeError("executor must be a function.");var n;this.promise=new Promise(function(e){n=e});var r=this;this.promise.then(function(e){if(r._listeners){for(var t=r._listeners.length;t-- >0;)r._listeners[t](e);r._listeners=null}}),this.promise.then=function(e){var t,n=new Promise(function(e){r.subscribe(e),t=e}).then(e);return n.cancel=function(){r.unsubscribe(t)},n},t(function(e,t,i){r.reason||(r.reason=new cf(e,t,i),n(r.reason))})}return R(e,[{key:"throwIfRequested",value:function(){if(this.reason)throw this.reason}},{key:"subscribe",value:function(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}},{key:"unsubscribe",value:function(e){if(this._listeners){var t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}}},{key:"toAbortSignal",value:function(){var e=this,t=new AbortController,n=function(e){t.abort(e)};return this.subscribe(n),t.signal.unsubscribe=function(){return e.unsubscribe(n)},t.signal}}],[{key:"source",value:function(){var t;return{token:new e(function(e){t=e}),cancel:t}}}])}(),Xf=$f;var Jf={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Jf).forEach(function(e){var t=q(e,2),n=t[0],r=t[1];Jf[r]=n});var Qf=Jf;var Zf=function e(t){var n=new Yf(t),r=Bu(Yf.prototype.request,n);return Ah.extend(r,Yf.prototype,n,{allOwnKeys:!0}),Ah.extend(r,n,null,{allOwnKeys:!0}),r.create=function(n){return e(yf(t,n))},r}(Qh);Zf.Axios=Yf,Zf.CanceledError=cf,Zf.CancelToken=Xf,Zf.isCancel=lf,Zf.VERSION=zf,Zf.toFormData=Lh,Zf.AxiosError=Mh,Zf.Cancel=Zf.CanceledError,Zf.all=function(e){return Promise.all(e)},Zf.spread=function(e){return function(t){return e.apply(null,t)}},Zf.isAxiosError=function(e){return Ah.isObject(e)&&!0===e.isAxiosError},Zf.mergeConfig=yf,Zf.AxiosHeaders=sf,Zf.formToJSON=function(e){return Xh(Ah.isHTMLForm(e)?new FormData(e):e)},Zf.getAdapter=Wf.getAdapter,Zf.HttpStatusCode=Qf,Zf.default=Zf;var ed=Zf;ed.Axios,ed.AxiosError,ed.CanceledError,ed.isCancel,ed.CancelToken,ed.VERSION,ed.all,ed.Cancel,ed.isAxiosError,ed.spread,ed.toFormData,ed.AxiosHeaders,ed.HttpStatusCode,ed.formToJSON,ed.getAdapter,ed.mergeConfig;var td=ed.create({baseURL:"/api/cms",timeout:1e4,headers:{"Content-Type":"application/json"}}),nd=new Map;td.interceptors.request.use(function(e){e.url&&e.url.startsWith("http")&&(e.baseURL="");var t=localStorage.getItem("cms_token");t&&(e.headers.Authorization="Bearer ".concat(t));var n=localStorage.getItem("cms_session_id");return n&&(e.headers["X-Session-Id"]=n),e},function(e){return Promise.reject(e)}),td.interceptors.response.use(function(e){return e},function(e){var t="请求错误",n=!1;if(e.response){var r=e.response.status,i=e.response.data;401===r?"登录已过期,请重新登录"===(null==i?void 0:i.message)?(t="登录已过期,请重新登录",n=!0):"认证信息无效"===(null==i?void 0:i.message)?(t="认证信息无效,请重新登录",n=!0):(t="认证失败,请登录",n=!0):t=(null==i?void 0:i.message)||"HTTP ".concat(r,": ").concat(e.response.statusText)}else t=e.request?"网络连接失败,请检查网络状态":e.message||"请求错误";return n?(localStorage.removeItem("cms_token"),localStorage.removeItem("cms_user"),"/login"!==window.location.pathname&&"/"!==window.location.pathname&&(Lu.error(t),setTimeout(function(){window.location.reload()},1e3))):Lu.error(t),Promise.reject(e)});var rd,id=function(e,t,n){var r=e;if(t){var i=new URLSearchParams(t).toString();r=r+(r.includes("?")?"&":"?")+i}var o="GET ".concat(r),s=nd.get(o);if(s)return s;var a=td.get(r,n).then(function(e){return e.data}).finally(function(){nd.delete(o)});return nd.set(o,a),a},od=function(e,t,n){return td.post(e,t,n).then(function(e){return e.data})},sd=function(e,t,n){return td.put(e,t,n).then(function(e){return e.data})},ad=function(e,t){return td.delete(e,t).then(function(e){return e.data})};try{var ld=localStorage.getItem("cms_session_id")||void 0;rd=ld}catch(zC){}function cd(e){rd=e;try{localStorage.setItem("cms_session_id",e)}catch(e){}}var ud=function(){return id("/models")},hd=function(){return id("/auth/signup/status/".concat(rd?rd+"_":"","cms_users"))},fd=function(e){return od("/auth/signup/".concat(rd?rd+"_":"","cms_users"),e)},dd=function(e){return od("/auth/login/".concat(rd?rd+"_":"","cms_users"),e)},pd=function(){return od("/auth/verify/".concat(rd?rd+"_":"","cms_users"))},md=function(){return id("/auth/user/".concat(rd?rd+"_":"","cms_users"))},gd=function(){localStorage.removeItem("cms_token"),localStorage.removeItem("cms_user")},vd=function(){return localStorage.getItem("cms_token")},yd=function(){var e=localStorage.getItem("cms_user");return e?JSON.parse(e):null},bd=function(e,t){var n=t?Object.assign({},t):void 0;return(null==n?void 0:n.filters)&&Array.isArray(n.filters)&&(n.filters=JSON.stringify(n.filters)),id("/data/".concat(rd?rd+"_":"").concat(e),n)},wd=function(e,t){return id("/relation/".concat(rd?rd+"_":"").concat(e,"/options"),t)},kd=function(e,t){return od("/data/".concat(rd?rd+"_":"").concat(e),t)},xd=function(e,t){return sd("/data/".concat(rd?rd+"_":"").concat(e),t)},Sd=function(e,t){return ad("/data/".concat(rd?rd+"_":"").concat(e,"?id=").concat(t))},Cd={"zh-CN":{common:{confirm:"确认",cancel:"取消",save:"保存",delete:"删除",edit:"编辑",add:"添加",search:"搜索",filter:"筛选",reset:"重置",submit:"提交",back:"返回",next:"下一页",previous:"上一页",loading:"加载中...",success:"成功",error:"错误",warning:"警告",info:"信息",close:"关闭",refresh:"刷新",export:"导出",import:"导入",view:"查看",create:"创建",update:"更新",actions:"操作",operation:"操作",total:"共",page:"页",pageSize:"每页",goto:"跳转"},auth:{login:"登录",logout:"登出",username:"用户名",password:"密码",email:"邮箱",signup:"注册",welcome:"欢迎",loginSuccess:"登录成功",loginFailed:"登录失败",logoutSuccess:"已成功登出",logoutConfirm:"确定要登出系统吗?",pleaseLogin:"请登录",invalidCredentials:"用户名或密码错误",createAdminAccount:"创建管理员账号",adminCreatedSuccess:"管理员账号创建成功",noAdmin:"系统中还没有管理员账号",firstTimeSetup:"首次使用,请创建管理员账号"},data:{dataManagement:"数据管理",dataList:"数据列表",addData:"新增数据",editData:"编辑数据",deleteData:"删除数据",deleteConfirm:"确定要删除这条数据吗?",deleteSuccess:"删除成功",deleteFailed:"删除失败",createSuccess:"创建成功",createFailed:"创建失败",updateSuccess:"更新成功",updateFailed:"更新失败",loadFailed:"加载失败",noData:"暂无数据",selectModel:"选择模型",selectModelFirst:"请先选择一个模型",searchPlaceholder:"搜索...",filterTitle:"筛选条件",addFilter:"添加筛选",clearFilters:"清除筛选",totalRecords:"条记录",perPage:"条/页"},model:{modelManagement:"模型管理",modelList:"模型列表",addModel:"新增模型",editModel:"编辑模型",deleteModel:"删除模型",deleteConfirm:"确定要删除这个模型吗?",modelName:"模型名称",tableName:"表名",fields:"字段",fieldName:"字段名",fieldType:"字段类型",fieldComment:"字段说明",required:"必填",unique:"唯一",maxLength:"最大长度",defaultValue:"默认值",addField:"添加字段",removeField:"移除字段",createSuccess:"模型创建成功",createFailed:"模型创建失败",updateSuccess:"模型更新成功",updateFailed:"模型更新失败",deleteSuccess:"模型删除成功",deleteFailed:"模型删除失败",loadFailed:"模型加载失败",noModels:"暂无模型"},field:{string:"字符串",number:"数字",boolean:"布尔值",date:"日期",datetime:"日期时间",text:"文本",email:"邮箱",url:"链接",json:"JSON",relation:"关联"},validation:{required:"此字段为必填项",invalidEmail:"请输入有效的邮箱地址",invalidUrl:"请输入有效的URL",maxLength:"超过最大长度限制",minLength:"未达到最小长度要求",invalidFormat:"格式不正确"},settings:{settings:"设置",language:"语言",theme:"主题",general:"通用",advanced:"高级"}},"en-US":{common:{confirm:"Confirm",cancel:"Cancel",save:"Save",delete:"Delete",edit:"Edit",add:"Add",search:"Search",filter:"Filter",reset:"Reset",submit:"Submit",back:"Back",next:"Next",previous:"Previous",loading:"Loading...",success:"Success",error:"Error",warning:"Warning",info:"Info",close:"Close",refresh:"Refresh",export:"Export",import:"Import",view:"View",create:"Create",update:"Update",actions:"Actions",operation:"Operation",total:"Total",page:"Page",pageSize:"Page Size",goto:"Go to"},auth:{login:"Login",logout:"Logout",username:"Username",password:"Password",email:"Email",signup:"Sign Up",welcome:"Welcome",loginSuccess:"Login successful",loginFailed:"Login failed",logoutSuccess:"Logout successful",logoutConfirm:"Are you sure you want to logout?",pleaseLogin:"Please login",invalidCredentials:"Invalid username or password",createAdminAccount:"Create Admin Account",adminCreatedSuccess:"Admin account created successfully",noAdmin:"No admin account exists",firstTimeSetup:"First time setup, please create admin account"},data:{dataManagement:"Data Management",dataList:"Data List",addData:"Add Data",editData:"Edit Data",deleteData:"Delete Data",deleteConfirm:"Are you sure you want to delete this record?",deleteSuccess:"Delete successful",deleteFailed:"Delete failed",createSuccess:"Create successful",createFailed:"Create failed",updateSuccess:"Update successful",updateFailed:"Update failed",loadFailed:"Load failed",noData:"No data",selectModel:"Select Model",selectModelFirst:"Please select a model first",searchPlaceholder:"Search...",filterTitle:"Filters",addFilter:"Add Filter",clearFilters:"Clear Filters",totalRecords:"records",perPage:"per page"},model:{modelManagement:"Model Management",modelList:"Model List",addModel:"Add Model",editModel:"Edit Model",deleteModel:"Delete Model",deleteConfirm:"Are you sure you want to delete this model?",modelName:"Model Name",tableName:"Table Name",fields:"Fields",fieldName:"Field Name",fieldType:"Field Type",fieldComment:"Field Comment",required:"Required",unique:"Unique",maxLength:"Max Length",defaultValue:"Default Value",addField:"Add Field",removeField:"Remove Field",createSuccess:"Model created successfully",createFailed:"Model creation failed",updateSuccess:"Model updated successfully",updateFailed:"Model update failed",deleteSuccess:"Model deleted successfully",deleteFailed:"Model deletion failed",loadFailed:"Model loading failed",noModels:"No models"},field:{string:"String",number:"Number",boolean:"Boolean",date:"Date",datetime:"Datetime",text:"Text",email:"Email",url:"URL",json:"JSON",relation:"Relation"},validation:{required:"This field is required",invalidEmail:"Please enter a valid email address",invalidUrl:"Please enter a valid URL",maxLength:"Exceeded maximum length",minLength:"Below minimum length",invalidFormat:"Invalid format"},settings:{settings:"Settings",language:"Language",theme:"Theme",general:"General",advanced:"Advanced"}}},Ed=c(void 0);function Ad(e){var n=e.children,r=e.defaultLocale,o=q(i(r||function(){try{var e=localStorage.getItem("cms_locale");if(e&&("zh-CN"===e||"en-US"===e))return e}catch(e){}return"zh-CN"}()),2),s=o[0],a=o[1],l={locale:s,setLocale:function(e){a(e),function(e){try{localStorage.setItem("cms_locale",e)}catch(e){}}(e)},t:function(e){var t,n=e.split("."),r=Cd[s],i=D(n);try{for(i.s();!(t=i.n()).done;){var o=t.value;if(!r||"object"!==Y(r)||!(o in r))return e;r=r[o]}}catch(e){i.e(e)}finally{i.f()}return"string"==typeof r?r:e},messages:Cd[s]};return t.createElement(Ed.Provider,{value:l},n)}function Md(){var e=l(Ed);if(!e)throw new Error("useTranslation must be used within I18nProvider");return e}function Od(){return Md().t}function Nd(){var e=Md();return{locale:e.locale,setLocale:e.setLocale}}function Td(e){var n=e.onLoginSuccess,r=Od(),o=q(i(""),2),s=o[0],l=o[1],c=q(i(""),2),u=c[0],h=c[1],f=q(i(!1),2),d=f[0],p=f[1],m=q(i("login"),2),g=m[0],v=m[1];a(function(){var e=vd();if(e){var t=function(){var t=A(j().m(function t(){var r;return j().w(function(t){for(;;)switch(t.p=t.n){case 0:return p(!0),t.p=1,t.n=2,pd();case 2:if(t.v.success){t.n=3;break}throw new Error("token验证失败");case 3:return t.n=4,md();case 4:if(!(r=t.v).success||!r.data){t.n=5;break}localStorage.setItem("cms_user",JSON.stringify(r.data)),null==n||n(e,r.data),t.n=6;break;case 5:throw new Error("获取用户信息失败");case 6:t.n=8;break;case 7:t.p=7,t.v,gd();case 8:return t.p=8,p(!1),t.f(8);case 9:return t.a(2)}},t,null,[[1,7,8,9]])}));return function(){return t.apply(this,arguments)}}();t()}},[n]),a(function(){if(!vd()){var e=function(){var e=A(j().m(function e(){var t,n;return j().w(function(e){for(;;)switch(e.p=e.n){case 0:return p(!0),e.p=1,e.n=2,hd();case 2:(n=e.v).success&&(null===(t=n.data)||void 0===t?void 0:t.allowSignup)?v("signup"):v("login"),e.n=4;break;case 3:e.p=3,e.v,v("login");case 4:return e.p=4,p(!1),e.f(4);case 5:return e.a(2)}},e,null,[[1,3,4,5]])}));return function(){return e.apply(this,arguments)}}();e()}},[]);var y=function(){var e=A(j().m(function e(t){var i,o,a,l,c;return j().w(function(e){for(;;)switch(e.p=e.n){case 0:if(t.preventDefault(),s&&u){e.n=1;break}return Lu.error(r("validation.required")),e.a(2);case 1:if(p(!0),e.p=2,"signup"!==g){e.n=4;break}return e.n=3,fd({username:s,password:u});case 3:l=e.v,e.n=6;break;case 4:return e.n=5,dd({username:s,password:u});case 5:l=e.v;case 6:if((a=l).success&&(null===(i=a.data)||void 0===i?void 0:i.token)){e.n=7;break}return Lu.error(a.message||r("auth.loginFailed")),"signup"===g&&(null===(o=a.message)||void 0===o?void 0:o.includes("已存在管理员"))&&v("login"),e.a(2);case 7:localStorage.setItem("cms_token",a.data.token),localStorage.setItem("cms_user",JSON.stringify(a.data.user)),null==n||n(a.data.token,a.data.user),e.n=9;break;case 8:e.p=8,c=e.v,Lu.error("".concat(r("auth.loginFailed"),", ").concat(c.message||r("common.error")));case 9:return e.p=9,p(!1),e.f(9);case 10:return e.a(2)}},e,null,[[2,8,9,10]])}));return function(t){return e.apply(this,arguments)}}();return t.createElement("div",{className:"we0-cms-root"},t.createElement("div",{className:"min-h-screen flex relative overflow-hidden bg-white"},t.createElement("div",{className:"pointer-events-none absolute inset-0"},t.createElement("div",{className:"absolute inset-0 bg-[linear-gradient(110deg,#ffffff_0%,#f7fbff_40%,#edf6ff_70%,#eaf3ff_100%)]"}),t.createElement("div",{className:"absolute inset-0 bg-[radial-gradient(1200px_600px_at_-10%_-10%,rgba(59,130,246,0.12),transparent),radial-gradient(900px_500px_at_110%_20%,rgba(147,51,234,0.10),transparent),radial-gradient(700px_400px_at_60%_120%,rgba(99,102,241,0.10),transparent)]"}),t.createElement("div",{className:"absolute inset-0 bg-[linear-gradient(115deg,rgba(255,255,255,0.6)_0%,rgba(255,255,255,0.15)_32%,transparent_32%,transparent_68%,rgba(255,255,255,0.15)_68%,rgba(255,255,255,0.6)_100%)]"})),t.createElement("div",{className:"flex-1 relative flex items-center justify-center"},t.createElement("div",{className:"relative z-10 max-w-4xl w-full px-16 text-left"},t.createElement("div",{className:"mb-12"},t.createElement("div",{className:"inline-flex items-center rounded-2xl px-4 py-2 bg-white/70 backdrop-blur border border-white/60"},t.createElement("span",{className:"text-2xl font-semibold tracking-tight text-gray-900"},r("data.dataManagement"))),t.createElement("h1",{className:"mt-8 text-5xl md:text-6xl font-extrabold leading-tight text-gray-900"},"WE0-CMS"),t.createElement("p",{className:"mt-6 text-2xl text-gray-600"},r("auth.welcome"))))),t.createElement("div",{className:"w-[480px] min-w-[380px] flex items-center justify-center p-8 mt-30"},t.createElement("div",{className:"w-full max-w-sm"},d?t.createElement(mu,{className:"bg-white/30 backdrop-blur-xl border border-white/50 shadow-none rounded-3xl overflow-hidden"},t.createElement(bu,{className:"p-8"},t.createElement("div",{className:"space-y-4"},t.createElement(Ot,{className:"h-12 w-48"}),t.createElement(Ot,{className:"h-4 w-64"}),t.createElement(Ot,{className:"h-10 w-full"}),t.createElement(Ot,{className:"h-10 w-full"})))):t.createElement(mu,{className:"bg-white/30 backdrop-blur-xl border border-white/50 shadow-none rounded-3xl overflow-hidden"},t.createElement(gu,{className:"p-8 pb-6"},t.createElement(vu,{className:"text-center text-2xl mb-2 text-gray-800"},r("signup"===g?"auth.createAdminAccount":"auth.welcome")),t.createElement(yu,{className:"text-center text-gray-500"},r("signup"===g?"auth.firstTimeSetup":"auth.pleaseLogin"))),t.createElement(bu,{className:"p-8 pt-0"},t.createElement("form",{onSubmit:y,className:"space-y-6"},t.createElement("div",{className:"space-y-2"},t.createElement(pu,{htmlFor:"username"},r("auth.username"),"/",r("auth.email")),t.createElement("div",{className:"relative"},t.createElement(Te,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400"}),t.createElement(Ut,{id:"username",type:"text",placeholder:r("auth.email"),value:s,onChange:function(e){return l(e.target.value)},className:"pl-10 h-12 rounded-xl border-gray-200 hover:border-blue-400 focus:border-blue-500 transition-colors",required:!0,minLength:2}))),t.createElement("div",{className:"space-y-2"},t.createElement(pu,{htmlFor:"password"},r("auth.password")),t.createElement("div",{className:"relative"},t.createElement(we,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400"}),t.createElement(Ut,{id:"password",type:"password",placeholder:r("auth.password"),value:u,onChange:function(e){return h(e.target.value)},className:"pl-10 h-12 rounded-xl border-gray-200 hover:border-blue-400 focus:border-blue-500 transition-colors",required:!0,minLength:6}))),t.createElement(qt,{type:"submit",className:"w-full h-12 rounded-xl transition-all duration-200 font-semibold text-base shadow-lg hover:brightness-[1.03] active:scale-[0.99]",style:{backgroundImage:"linear-gradient(135deg, rgba(236, 248, 255, 0.78) 0%, rgba(221, 238, 255, 0.78) 100%)",color:"rgba(0, 0, 0, 0.7)",border:"none",boxShadow:"0 6px 24px rgba(37, 99, 235, 0.12)"},disabled:d},t.createElement(ke,{className:"h-4 w-4 mr-2"}),r(d?"common.loading":"signup"===g?"auth.signup":"auth.login")))))))))}function Rd(e,[t,n]){return Math.min(n,Math.max(t,e))}function Dd(t){const n=e.useRef({value:t,previous:t});return e.useMemo(()=>(n.current.value!==t&&(n.current.previous=n.current.value,n.current.value=t),n.current.previous),[t])}var Pd=[" ","Enter","ArrowUp","ArrowDown"],Ld=[" ","Enter"],Bd="Select",[Id,_d,Fd]=_a(Bd),[Wd,jd]=Zt(Bd,[Fd,xs]),Hd=xs(),[zd,Vd]=Wd(Bd),[qd,Ud]=Wd(Bd),Kd=t=>{const{__scopeSelect:n,children:r,open:i,defaultOpen:o,onOpenChange:s,value:a,defaultValue:l,onValueChange:c,dir:u,name:h,autoComplete:f,disabled:p,required:g,form:v}=t,y=Hd(n),[b,w]=e.useState(null),[k,x]=e.useState(null),[S,C]=e.useState(!1),E=Wa(u),[A,M]=an({prop:i,defaultProp:o??!1,onChange:s,caller:Bd}),[O,N]=an({prop:a,defaultProp:l,onChange:c,caller:Bd}),T=e.useRef(null),R=!b||(v||!!b.closest("form")),[D,P]=e.useState(new Set),L=Array.from(D).map(e=>e.props.value).join(";");return d(Fs,{...y,children:m(zd,{required:g,scope:n,trigger:b,onTriggerChange:w,valueNode:k,onValueNodeChange:x,valueNodeHasChildren:S,onValueNodeHasChildrenChange:C,contentId:on(),value:O,onValueChange:N,open:A,onOpenChange:M,dir:E,triggerPointerDownPosRef:T,disabled:p,children:[d(Id.Provider,{scope:n,children:d(qd,{scope:t.__scopeSelect,onNativeOptionAdd:e.useCallback(e=>{P(t=>new Set(t).add(e))},[]),onNativeOptionRemove:e.useCallback(e=>{P(t=>{const n=new Set(t);return n.delete(e),n})},[]),children:r})}),R?m(Dp,{"aria-hidden":!0,required:g,tabIndex:-1,name:h,autoComplete:f,value:O,onChange:e=>N(e.target.value),disabled:p,form:v,children:[void 0===O?d("option",{value:""}):null,Array.from(D)]},L):null]})})};Kd.displayName=Bd;var Gd="SelectTrigger",Yd=e.forwardRef((t,n)=>{const{__scopeSelect:r,disabled:i=!1,...o}=t,s=Hd(r),a=Vd(Gd,r),l=a.disabled||i,c=Rt(n,a.onTriggerChange),u=_d(r),h=e.useRef("touch"),[f,p,m]=Lp(e=>{const t=u().filter(e=>!e.disabled),n=t.find(e=>e.value===a.value),r=Bp(t,e,n);void 0!==r&&a.onValueChange(r.value)}),g=e=>{l||(a.onOpenChange(!0),m()),e&&(a.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return d(Ws,{asChild:!0,...s,children:d(fn.button,{type:"button",role:"combobox","aria-controls":a.contentId,"aria-expanded":a.open,"aria-required":a.required,"aria-autocomplete":"none",dir:a.dir,"data-state":a.open?"open":"closed",disabled:l,"data-disabled":l?"":void 0,"data-placeholder":Pp(a.value)?"":void 0,...o,ref:c,onClick:Qt(o.onClick,e=>{e.currentTarget.focus(),"mouse"!==h.current&&g(e)}),onPointerDown:Qt(o.onPointerDown,e=>{h.current=e.pointerType;const t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),0===e.button&&!1===e.ctrlKey&&"mouse"===e.pointerType&&(g(e),e.preventDefault())}),onKeyDown:Qt(o.onKeyDown,e=>{const t=""!==f.current;e.ctrlKey||e.altKey||e.metaKey||1!==e.key.length||p(e.key),t&&" "===e.key||Pd.includes(e.key)&&(g(),e.preventDefault())})})})});Yd.displayName=Gd;var $d="SelectValue",Xd=e.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:i,children:o,placeholder:s="",...a}=e,l=Vd($d,n),{onValueNodeHasChildrenChange:c}=l,u=void 0!==o,h=Rt(t,l.onValueNodeChange);return tn(()=>{c(u)},[c,u]),d(fn.span,{...a,ref:h,style:{pointerEvents:"none"},children:Pp(l.value)?d(p,{children:s}):o})});Xd.displayName=$d;var Jd=e.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...i}=e;return d(fn.span,{"aria-hidden":!0,...i,ref:t,children:r||"▼"})});Jd.displayName="SelectIcon";var Qd=e=>d(Pn,{asChild:!0,...e});Qd.displayName="SelectPortal";var Zd="SelectContent",ep=e.forwardRef((t,n)=>{const r=Vd(Zd,t.__scopeSelect),[i,o]=e.useState();if(tn(()=>{o(new DocumentFragment)},[]),!r.open){const e=i;return e?g.createPortal(d(np,{scope:t.__scopeSelect,children:d(Id.Slot,{scope:t.__scopeSelect,children:d("div",{children:t.children})})}),e):null}return d(op,{...t,ref:n})});ep.displayName=Zd;var tp=10,[np,rp]=Wd(Zd),ip=ln("SelectContent.RemoveScroll"),op=e.forwardRef((t,n)=>{const{__scopeSelect:r,position:i="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:a,side:l,sideOffset:c,align:u,alignOffset:h,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:g,hideWhenDetached:v,avoidCollisions:y,...b}=t,w=Vd(Zd,r),[k,x]=e.useState(null),[S,C]=e.useState(null),E=Rt(n,e=>x(e)),[A,M]=e.useState(null),[O,N]=e.useState(null),T=_d(r),[R,D]=e.useState(!1),P=e.useRef(!1);e.useEffect(()=>{if(k)return Rr(k)},[k]),_n();const L=e.useCallback(e=>{const[t,...n]=T().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(const n of e){if(n===i)return;if(n?.scrollIntoView({block:"nearest"}),n===t&&S&&(S.scrollTop=0),n===r&&S&&(S.scrollTop=S.scrollHeight),n?.focus(),document.activeElement!==i)return}},[T,S]),B=e.useCallback(()=>L([A,k]),[L,A,k]);e.useEffect(()=>{R&&B()},[R,B]);const{onOpenChange:I,triggerPointerDownPosRef:_}=w;e.useEffect(()=>{if(k){let e={x:0,y:0};const t=t=>{e={x:Math.abs(Math.round(t.pageX)-(_.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(_.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():k.contains(n.target)||I(!1),document.removeEventListener("pointermove",t),_.current=null};return null!==_.current&&(document.addEventListener("pointermove",t),document.addEventListener("pointerup",n,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",t),document.removeEventListener("pointerup",n,{capture:!0})}}},[k,I,_]),e.useEffect(()=>{const e=()=>I(!1);return window.addEventListener("blur",e),window.addEventListener("resize",e),()=>{window.removeEventListener("blur",e),window.removeEventListener("resize",e)}},[I]);const[F,W]=Lp(e=>{const t=T().filter(e=>!e.disabled),n=t.find(e=>e.ref.current===document.activeElement),r=Bp(t,e,n);r&&setTimeout(()=>r.ref.current.focus())}),j=e.useCallback((e,t,n)=>{const r=!P.current&&!n;(void 0!==w.value&&w.value===t||r)&&(M(e),r&&(P.current=!0))},[w.value]),H=e.useCallback(()=>k?.focus(),[k]),z=e.useCallback((e,t,n)=>{const r=!P.current&&!n;(void 0!==w.value&&w.value===t||r)&&N(e)},[w.value]),V="popper"===i?ap:sp,q=V===ap?{side:l,sideOffset:c,align:u,alignOffset:h,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:g,hideWhenDetached:v,avoidCollisions:y}:{};return d(np,{scope:r,content:k,viewport:S,onViewportChange:C,itemRefCallback:j,selectedItem:A,onItemLeave:H,itemTextRefCallback:z,focusSelectedItem:B,selectedItemText:O,position:i,isPositioned:R,searchRef:F,children:d(Cr,{as:ip,allowPinchZoom:!0,children:d(An,{asChild:!0,trapped:w.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:Qt(o,e=>{w.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:d(wn,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:d(V,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:e=>e.preventDefault(),...b,...q,onPlaced:()=>D(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...b.style},onKeyDown:Qt(b.onKeyDown,e=>{const t=e.ctrlKey||e.altKey||e.metaKey;if("Tab"===e.key&&e.preventDefault(),t||1!==e.key.length||W(e.key),["ArrowUp","ArrowDown","Home","End"].includes(e.key)){let t=T().filter(e=>!e.disabled).map(e=>e.ref.current);if(["ArrowUp","End"].includes(e.key)&&(t=t.slice().reverse()),["ArrowUp","ArrowDown"].includes(e.key)){const n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>L(t)),e.preventDefault()}})})})})})})});op.displayName="SelectContentImpl";var sp=e.forwardRef((t,n)=>{const{__scopeSelect:r,onPlaced:i,...o}=t,s=Vd(Zd,r),a=rp(Zd,r),[l,c]=e.useState(null),[u,h]=e.useState(null),f=Rt(n,e=>h(e)),p=_d(r),m=e.useRef(!1),g=e.useRef(!0),{viewport:v,selectedItem:y,selectedItemText:b,focusSelectedItem:w}=a,k=e.useCallback(()=>{if(s.trigger&&s.valueNode&&l&&u&&v&&y&&b){const e=s.trigger.getBoundingClientRect(),t=u.getBoundingClientRect(),n=s.valueNode.getBoundingClientRect(),r=b.getBoundingClientRect();if("rtl"!==s.dir){const i=r.left-t.left,o=n.left-i,s=e.left-o,a=e.width+s,c=Math.max(a,t.width),u=window.innerWidth-tp,h=Rd(o,[tp,Math.max(tp,u-c)]);l.style.minWidth=a+"px",l.style.left=h+"px"}else{const i=t.right-r.right,o=window.innerWidth-n.right-i,s=window.innerWidth-e.right-o,a=e.width+s,c=Math.max(a,t.width),u=window.innerWidth-tp,h=Rd(o,[tp,Math.max(tp,u-c)]);l.style.minWidth=a+"px",l.style.right=h+"px"}const o=p(),a=window.innerHeight-2*tp,c=v.scrollHeight,h=window.getComputedStyle(u),f=parseInt(h.borderTopWidth,10),d=parseInt(h.paddingTop,10),g=parseInt(h.borderBottomWidth,10),w=f+d+c+parseInt(h.paddingBottom,10)+g,k=Math.min(5*y.offsetHeight,w),x=window.getComputedStyle(v),S=parseInt(x.paddingTop,10),C=parseInt(x.paddingBottom,10),E=e.top+e.height/2-tp,A=a-E,M=y.offsetHeight/2,O=f+d+(y.offsetTop+M),N=w-O;if(O<=E){const e=o.length>0&&y===o[o.length-1].ref.current;l.style.bottom="0px";const t=u.clientHeight-v.offsetTop-v.offsetHeight,n=O+Math.max(A,M+(e?C:0)+t+g);l.style.height=n+"px"}else{const e=o.length>0&&y===o[0].ref.current;l.style.top="0px";const t=Math.max(E,f+v.offsetTop+(e?S:0)+M)+N;l.style.height=t+"px",v.scrollTop=O-E+v.offsetTop}l.style.margin=`${tp}px 0`,l.style.minHeight=k+"px",l.style.maxHeight=a+"px",i?.(),requestAnimationFrame(()=>m.current=!0)}},[p,s.trigger,s.valueNode,l,u,v,y,b,s.dir,i]);tn(()=>k(),[k]);const[x,S]=e.useState();tn(()=>{u&&S(window.getComputedStyle(u).zIndex)},[u]);const C=e.useCallback(e=>{e&&!0===g.current&&(k(),w?.(),g.current=!1)},[k,w]);return d(lp,{scope:r,contentWrapper:l,shouldExpandOnScrollRef:m,onScrollButtonChange:C,children:d("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:x},children:d(fn.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});sp.displayName="SelectItemAlignedPosition";var ap=e.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:i=tp,...o}=e,s=Hd(n);return d(js,{...s,...o,ref:t,align:r,collisionPadding:i,style:{boxSizing:"border-box",...o.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});ap.displayName="SelectPopperPosition";var[lp,cp]=Wd(Zd,{}),up="SelectViewport",hp=e.forwardRef((t,n)=>{const{__scopeSelect:r,nonce:i,...o}=t,s=rp(up,r),a=cp(up,r),l=Rt(n,s.onViewportChange),c=e.useRef(0);return m(p,{children:[d("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:i}),d(Id.Slot,{scope:r,children:d(fn.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:Qt(o.onScroll,e=>{const t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=a;if(r?.current&&n){const e=Math.abs(c.current-t.scrollTop);if(e>0){const r=window.innerHeight-2*tp,i=parseFloat(n.style.minHeight),o=parseFloat(n.style.height),s=Math.max(i,o);if(s<r){const i=s+e,o=Math.min(r,i),a=i-o;n.style.height=o+"px","0px"===n.style.bottom&&(t.scrollTop=a>0?a:0,n.style.justifyContent="flex-end")}}}c.current=t.scrollTop})})})]})});hp.displayName=up;var fp="SelectGroup",[dp,pp]=Wd(fp);e.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,i=on();return d(dp,{scope:n,id:i,children:d(fn.div,{role:"group","aria-labelledby":i,...r,ref:t})})}).displayName=fp;var mp="SelectLabel",gp=e.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,i=pp(mp,n);return d(fn.div,{id:i.id,...r,ref:t})});gp.displayName=mp;var vp="SelectItem",[yp,bp]=Wd(vp),wp=e.forwardRef((t,n)=>{const{__scopeSelect:r,value:i,disabled:o=!1,textValue:s,...a}=t,l=Vd(vp,r),c=rp(vp,r),u=l.value===i,[h,f]=e.useState(s??""),[p,m]=e.useState(!1),g=Rt(n,e=>c.itemRefCallback?.(e,i,o)),v=on(),y=e.useRef("touch"),b=()=>{o||(l.onValueChange(i),l.onOpenChange(!1))};if(""===i)throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return d(yp,{scope:r,value:i,disabled:o,textId:v,isSelected:u,onItemTextChange:e.useCallback(e=>{f(t=>t||(e?.textContent??"").trim())},[]),children:d(Id.ItemSlot,{scope:r,value:i,disabled:o,textValue:h,children:d(fn.div,{role:"option","aria-labelledby":v,"data-highlighted":p?"":void 0,"aria-selected":u&&p,"data-state":u?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...a,ref:g,onFocus:Qt(a.onFocus,()=>m(!0)),onBlur:Qt(a.onBlur,()=>m(!1)),onClick:Qt(a.onClick,()=>{"mouse"!==y.current&&b()}),onPointerUp:Qt(a.onPointerUp,()=>{"mouse"===y.current&&b()}),onPointerDown:Qt(a.onPointerDown,e=>{y.current=e.pointerType}),onPointerMove:Qt(a.onPointerMove,e=>{y.current=e.pointerType,o?c.onItemLeave?.():"mouse"===y.current&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Qt(a.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:Qt(a.onKeyDown,e=>{""!==c.searchRef?.current&&" "===e.key||(Ld.includes(e.key)&&b()," "===e.key&&e.preventDefault())})})})})});wp.displayName=vp;var kp="SelectItemText",xp=e.forwardRef((t,n)=>{const{__scopeSelect:r,className:i,style:o,...s}=t,a=Vd(kp,r),l=rp(kp,r),c=bp(kp,r),u=Ud(kp,r),[h,f]=e.useState(null),v=Rt(n,e=>f(e),c.onItemTextChange,e=>l.itemTextRefCallback?.(e,c.value,c.disabled)),y=h?.textContent,b=e.useMemo(()=>d("option",{value:c.value,disabled:c.disabled,children:y},c.value),[c.disabled,c.value,y]),{onNativeOptionAdd:w,onNativeOptionRemove:k}=u;return tn(()=>(w(b),()=>k(b)),[w,k,b]),m(p,{children:[d(fn.span,{id:c.textId,...s,ref:v}),c.isSelected&&a.valueNode&&!a.valueNodeHasChildren?g.createPortal(s.children,a.valueNode):null]})});xp.displayName=kp;var Sp="SelectItemIndicator",Cp=e.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return bp(Sp,n).isSelected?d(fn.span,{"aria-hidden":!0,...r,ref:t}):null});Cp.displayName=Sp;var Ep="SelectScrollUpButton",Ap=e.forwardRef((t,n)=>{const r=rp(Ep,t.__scopeSelect),i=cp(Ep,t.__scopeSelect),[o,s]=e.useState(!1),a=Rt(n,i.onScrollButtonChange);return tn(()=>{if(r.viewport&&r.isPositioned){let e=function(){const e=t.scrollTop>0;s(e)};const t=r.viewport;return e(),t.addEventListener("scroll",e),()=>t.removeEventListener("scroll",e)}},[r.viewport,r.isPositioned]),o?d(Np,{...t,ref:a,onAutoScroll:()=>{const{viewport:e,selectedItem:t}=r;e&&t&&(e.scrollTop=e.scrollTop-t.offsetHeight)}}):null});Ap.displayName=Ep;var Mp="SelectScrollDownButton",Op=e.forwardRef((t,n)=>{const r=rp(Mp,t.__scopeSelect),i=cp(Mp,t.__scopeSelect),[o,s]=e.useState(!1),a=Rt(n,i.onScrollButtonChange);return tn(()=>{if(r.viewport&&r.isPositioned){let e=function(){const e=t.scrollHeight-t.clientHeight,n=Math.ceil(t.scrollTop)<e;s(n)};const t=r.viewport;return e(),t.addEventListener("scroll",e),()=>t.removeEventListener("scroll",e)}},[r.viewport,r.isPositioned]),o?d(Np,{...t,ref:a,onAutoScroll:()=>{const{viewport:e,selectedItem:t}=r;e&&t&&(e.scrollTop=e.scrollTop+t.offsetHeight)}}):null});Op.displayName=Mp;var Np=e.forwardRef((t,n)=>{const{__scopeSelect:r,onAutoScroll:i,...o}=t,s=rp("SelectScrollButton",r),a=e.useRef(null),l=_d(r),c=e.useCallback(()=>{null!==a.current&&(window.clearInterval(a.current),a.current=null)},[]);return e.useEffect(()=>()=>c(),[c]),tn(()=>{const e=l().find(e=>e.ref.current===document.activeElement);e?.ref.current?.scrollIntoView({block:"nearest"})},[l]),d(fn.div,{"aria-hidden":!0,...o,ref:n,style:{flexShrink:0,...o.style},onPointerDown:Qt(o.onPointerDown,()=>{null===a.current&&(a.current=window.setInterval(i,50))}),onPointerMove:Qt(o.onPointerMove,()=>{s.onItemLeave?.(),null===a.current&&(a.current=window.setInterval(i,50))}),onPointerLeave:Qt(o.onPointerLeave,()=>{c()})})}),Tp=e.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return d(fn.div,{"aria-hidden":!0,...r,ref:t})});Tp.displayName="SelectSeparator";var Rp="SelectArrow";e.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,i=Hd(n),o=Vd(Rp,n),s=rp(Rp,n);return o.open&&"popper"===s.position?d(Hs,{...i,...r,ref:t}):null}).displayName=Rp;var Dp=e.forwardRef(({__scopeSelect:t,value:n,...r},i)=>{const o=e.useRef(null),s=Rt(i,o),a=Dd(n);return e.useEffect(()=>{const e=o.current;if(!e)return;const t=window.HTMLSelectElement.prototype,r=Object.getOwnPropertyDescriptor(t,"value").set;if(a!==n&&r){const t=new Event("change",{bubbles:!0});r.call(e,n),e.dispatchEvent(t)}},[a,n]),d(fn.select,{...r,style:{...zs,...r.style},ref:s,defaultValue:n})});function Pp(e){return""===e||void 0===e}function Lp(t){const n=pn(t),r=e.useRef(""),i=e.useRef(0),o=e.useCallback(e=>{const t=r.current+e;n(t),function e(t){r.current=t,window.clearTimeout(i.current),""!==t&&(i.current=window.setTimeout(()=>e(""),1e3))}(t)},[n]),s=e.useCallback(()=>{r.current="",window.clearTimeout(i.current)},[]);return e.useEffect(()=>()=>window.clearTimeout(i.current),[]),[r,o,s]}function Bp(e,t,n){const r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1;let o=(s=e,a=Math.max(i,0),s.map((e,t)=>s[(a+t)%s.length]));var s,a;1===r.length&&(o=o.filter(e=>e!==n));const l=o.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return l!==n?l:void 0}Dp.displayName="SelectBubbleInput";var Ip=Yd,_p=Jd,Fp=Qd,Wp=ep,jp=hp,Hp=gp,zp=wp,Vp=xp,qp=Cp,Up=Ap,Kp=Op,Gp=Tp,Yp=Kd,$p=Xd,Xp=e.forwardRef(function(t,n){var r=t.className,i=t.children,o=Z(t,["className","children"]);return e.createElement(Ip,Object.assign({ref:n,className:Mt("flex h-12 w-full items-center justify-between rounded-full border border-input bg-background px-6 py-2 text-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-[hsl(var(--primary))]/30 focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 transition-all duration-300 [&>span]:line-clamp-1",r)},o),i,e.createElement(_p,{asChild:!0},e.createElement(ae,{className:"h-4 w-4 opacity-50"})))});Xp.displayName=Ip.displayName;var Jp=e.forwardRef(function(t,n){var r=t.className,i=Z(t,["className"]);return e.createElement(Up,Object.assign({ref:n,className:Mt("flex cursor-default items-center justify-center py-1",r)},i),e.createElement(ue,{className:"h-4 w-4"}))});Jp.displayName=Up.displayName;var Qp=e.forwardRef(function(t,n){var r=t.className,i=Z(t,["className"]);return e.createElement(Kp,Object.assign({ref:n,className:Mt("flex cursor-default items-center justify-center py-1",r)},i),e.createElement(ae,{className:"h-4 w-4"}))});Qp.displayName=Kp.displayName;var Zp=e.forwardRef(function(t,n){var r=t.className,i=t.children,o=t.position,s=void 0===o?"popper":o,a=Z(t,["className","children","position"]);return e.createElement(Fp,null,e.createElement(Wp,Object.assign({ref:n,className:Mt("relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-2xl border bg-popover text-popover-foreground shadow-[0_10px_40px_-10px_rgba(93,112,82,0.2)] data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]","popper"===s&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",r),position:s},a),e.createElement(Jp,null),e.createElement(jp,{className:Mt("p-1","popper"===s&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]")},i),e.createElement(Qp,null)))});Zp.displayName=Wp.displayName;var em=e.forwardRef(function(t,n){var r=t.className,i=Z(t,["className"]);return e.createElement(Hp,Object.assign({ref:n,className:Mt("py-1.5 pl-8 pr-2 text-sm font-semibold",r)},i))});em.displayName=Hp.displayName;var tm=e.forwardRef(function(t,n){var r=t.className,i=t.children,o=Z(t,["className","children"]);return e.createElement(zp,Object.assign({ref:n,className:Mt("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",r)},o),e.createElement("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center"},e.createElement(qp,null,e.createElement(se,{className:"h-4 w-4"}))),e.createElement(Vp,null,i))});tm.displayName=zp.displayName;var nm=e.forwardRef(function(t,n){var r=t.className,i=Z(t,["className"]);return e.createElement(Gp,Object.assign({ref:n,className:Mt("-mx-1 my-1 h-px bg-muted",r)},i))});nm.displayName=Gp.displayName;var rm="Switch",[im,om]=Zt(rm),[sm,am]=im(rm),lm=e.forwardRef((t,n)=>{const{__scopeSwitch:r,name:i,checked:o,defaultChecked:s,required:a,disabled:l,value:c="on",onCheckedChange:u,form:h,...f}=t,[p,g]=e.useState(null),v=Rt(n,e=>g(e)),y=e.useRef(!1),b=!p||(h||!!p.closest("form")),[w,k]=an({prop:o,defaultProp:s??!1,onChange:u,caller:rm});return m(sm,{scope:r,checked:w,disabled:l,children:[d(fn.button,{type:"button",role:"switch","aria-checked":w,"aria-required":a,"data-state":fm(w),"data-disabled":l?"":void 0,disabled:l,value:c,...f,ref:v,onClick:Qt(t.onClick,e=>{k(e=>!e),b&&(y.current=e.isPropagationStopped(),y.current||e.stopPropagation())})}),b&&d(hm,{control:p,bubbles:!y.current,name:i,value:c,checked:w,required:a,disabled:l,form:h,style:{transform:"translateX(-100%)"}})]})});lm.displayName=rm;var cm="SwitchThumb",um=e.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,i=am(cm,n);return d(fn.span,{"data-state":fm(i.checked),"data-disabled":i.disabled?"":void 0,...r,ref:t})});um.displayName=cm;var hm=e.forwardRef(({__scopeSwitch:t,control:n,checked:r,bubbles:i=!0,...o},s)=>{const a=e.useRef(null),l=Rt(a,s),c=Dd(r),u=bs(n);return e.useEffect(()=>{const e=a.current;if(!e)return;const t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,"checked").set;if(c!==r&&n){const t=new Event("click",{bubbles:i});n.call(e,r),e.dispatchEvent(t)}},[c,r,i]),d("input",{type:"checkbox","aria-hidden":!0,defaultChecked:r,...o,tabIndex:-1,ref:l,style:{...o.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});function fm(e){return e?"checked":"unchecked"}hm.displayName="SwitchBubbleInput";var dm=lm,pm=um,mm=e.forwardRef(function(t,n){var r=t.className,i=Z(t,["className"]);return e.createElement(dm,Object.assign({className:Mt("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",r)},i,{ref:n}),e.createElement(pm,{className:Mt("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")}))});mm.displayName=dm.displayName;var gm=e.forwardRef(function(t,n){var r=t.className,i=Z(t,["className"]);return e.createElement("textarea",Object.assign({className:Mt("flex min-h-[120px] w-full rounded-3xl border border-input bg-background px-6 py-4 text-base ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[hsl(var(--primary))]/30 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 transition-all duration-300 md:text-sm",r),ref:n},i))});gm.displayName="Textarea";var vm=hi,ym=fi,bm=di,wm=e.forwardRef(function(t,n){var r=t.className,i=Z(t,["className"]);return e.createElement(pi,Object.assign({ref:n,className:Mt("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",r)},i))});wm.displayName=pi.displayName;var km=e.forwardRef(function(t,n){var r=t.className,i=t.children,o=Z(t,["className","children"]);return e.createElement(bm,null,e.createElement(wm,null),e.createElement(mi,Object.assign({ref:n,className:Mt("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border border-[hsl(var(--border))]/50 bg-background p-6 shadow-[0_20px_60px_-10px_rgba(93,112,82,0.2)] duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] rounded-[2rem]",r)},o),i,e.createElement(yi,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground"},e.createElement(De,{className:"h-4 w-4"}),e.createElement("span",{className:"sr-only"},"Close"))))});km.displayName=mi.displayName;var xm=function(t){var n=t.className,r=Z(t,["className"]);return e.createElement("div",Object.assign({className:Mt("flex flex-col space-y-1.5 text-center sm:text-left",n)},r))};xm.displayName="DialogHeader";var Sm=function(t){var n=t.className,r=Z(t,["className"]);return e.createElement("div",Object.assign({className:Mt("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",n)},r))};Sm.displayName="DialogFooter";var Cm=e.forwardRef(function(t,n){var r=t.className,i=Z(t,["className"]);return e.createElement(gi,Object.assign({ref:n,className:Mt("text-lg font-semibold leading-none tracking-tight",r)},i))});Cm.displayName=gi.displayName;var Em,Am=e.forwardRef(function(t,n){var r=t.className,i=Z(t,["className"]);return e.createElement(vi,Object.assign({ref:n,className:Mt("text-sm text-muted-foreground",r)},i))});function Mm(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=e.length,r=0,i="",o=0,s=16,a=0,l=0,c=0,u=0,h=0;function f(t,n){for(var i=0,o=0;i<t||!n;){var s=e.charCodeAt(r);if(s>=48&&s<=57)o=16*o+s-48;else if(s>=65&&s<=70)o=16*o+s-65+10;else{if(!(s>=97&&s<=102))break;o=16*o+s-97+10}r++,i++}return i<t&&(o=-1),o}function d(){if(i="",h=0,o=r,l=a,u=c,r>=n)return o=n,s=17;var t=e.charCodeAt(r);if(Om(t)){do{r++,i+=String.fromCharCode(t),t=e.charCodeAt(r)}while(Om(t));return s=15}if(Nm(t))return r++,i+=String.fromCharCode(t),13===t&&10===e.charCodeAt(r)&&(r++,i+="\n"),a++,c=r,s=14;switch(t){case 123:return r++,s=1;case 125:return r++,s=2;case 91:return r++,s=3;case 93:return r++,s=4;case 58:return r++,s=6;case 44:return r++,s=5;case 34:return r++,i=function(){for(var t="",i=r;;){if(r>=n){t+=e.substring(i,r),h=2;break}var o=e.charCodeAt(r);if(34===o){t+=e.substring(i,r),r++;break}if(92!==o){if(o>=0&&o<=31){if(Nm(o)){t+=e.substring(i,r),h=2;break}h=6}r++}else{if(t+=e.substring(i,r),++r>=n){h=2;break}switch(e.charCodeAt(r++)){case 34:t+='"';break;case 92:t+="\\";break;case 47:t+="/";break;case 98:t+="\b";break;case 102:t+="\f";break;case 110:t+="\n";break;case 114:t+="\r";break;case 116:t+="\t";break;case 117:var s=f(4,!0);s>=0?t+=String.fromCharCode(s):h=4;break;default:h=5}i=r}}return t}(),s=10;case 47:var d=r-1;if(47===e.charCodeAt(r+1)){for(r+=2;r<n&&!Nm(e.charCodeAt(r));)r++;return i=e.substring(d,r),s=12}if(42===e.charCodeAt(r+1)){r+=2;for(var m=n-1,g=!1;r<m;){var v=e.charCodeAt(r);if(42===v&&47===e.charCodeAt(r+1)){r+=2,g=!0;break}r++,Nm(v)&&(13===v&&10===e.charCodeAt(r)&&r++,a++,c=r)}return g||(r++,h=1),i=e.substring(d,r),s=13}return i+=String.fromCharCode(t),r++,s=16;case 45:if(i+=String.fromCharCode(t),++r===n||!Tm(e.charCodeAt(r)))return s=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return i+=function(){var t=r;if(48===e.charCodeAt(r))r++;else for(r++;r<e.length&&Tm(e.charCodeAt(r));)r++;if(r<e.length&&46===e.charCodeAt(r)){if(!(++r<e.length&&Tm(e.charCodeAt(r))))return h=3,e.substring(t,r);for(r++;r<e.length&&Tm(e.charCodeAt(r));)r++}var n=r;if(r<e.length&&(69===e.charCodeAt(r)||101===e.charCodeAt(r)))if((++r<e.length&&43===e.charCodeAt(r)||45===e.charCodeAt(r))&&r++,r<e.length&&Tm(e.charCodeAt(r))){for(r++;r<e.length&&Tm(e.charCodeAt(r));)r++;n=r}else h=3;return e.substring(t,n)}(),s=11;default:for(;r<n&&p(t);)r++,t=e.charCodeAt(r);if(o!==r){switch(i=e.substring(o,r)){case"true":return s=8;case"false":return s=9;case"null":return s=7}return s=16}return i+=String.fromCharCode(t),r++,s=16}}function p(e){if(Om(e)||Nm(e))return!1;switch(e){case 125:case 93:case 123:case 91:case 34:case 58:case 44:case 47:return!1}return!0}return{setPosition:function(e){r=e,i="",o=0,s=16,h=0},getPosition:function(){return r},scan:t?function(){var e;do{e=d()}while(e>=12&&e<=15);return e}:d,getToken:function(){return s},getTokenValue:function(){return i},getTokenOffset:function(){return o},getTokenLength:function(){return r-o},getTokenStartLine:function(){return l},getTokenStartCharacter:function(){return o-u},getTokenError:function(){return h}}}function Om(e){return 32===e||9===e}function Nm(e){return 10===e||13===e}function Tm(e){return e>=48&&e<=57}Am.displayName=vi.displayName,function(e){e[e.lineFeed=10]="lineFeed",e[e.carriageReturn=13]="carriageReturn",e[e.space=32]="space",e[e._0=48]="_0",e[e._1=49]="_1",e[e._2=50]="_2",e[e._3=51]="_3",e[e._4=52]="_4",e[e._5=53]="_5",e[e._6=54]="_6",e[e._7=55]="_7",e[e._8=56]="_8",e[e._9=57]="_9",e[e.a=97]="a",e[e.b=98]="b",e[e.c=99]="c",e[e.d=100]="d",e[e.e=101]="e",e[e.f=102]="f",e[e.g=103]="g",e[e.h=104]="h",e[e.i=105]="i",e[e.j=106]="j",e[e.k=107]="k",e[e.l=108]="l",e[e.m=109]="m",e[e.n=110]="n",e[e.o=111]="o",e[e.p=112]="p",e[e.q=113]="q",e[e.r=114]="r",e[e.s=115]="s",e[e.t=116]="t",e[e.u=117]="u",e[e.v=118]="v",e[e.w=119]="w",e[e.x=120]="x",e[e.y=121]="y",e[e.z=122]="z",e[e.A=65]="A",e[e.B=66]="B",e[e.C=67]="C",e[e.D=68]="D",e[e.E=69]="E",e[e.F=70]="F",e[e.G=71]="G",e[e.H=72]="H",e[e.I=73]="I",e[e.J=74]="J",e[e.K=75]="K",e[e.L=76]="L",e[e.M=77]="M",e[e.N=78]="N",e[e.O=79]="O",e[e.P=80]="P",e[e.Q=81]="Q",e[e.R=82]="R",e[e.S=83]="S",e[e.T=84]="T",e[e.U=85]="U",e[e.V=86]="V",e[e.W=87]="W",e[e.X=88]="X",e[e.Y=89]="Y",e[e.Z=90]="Z",e[e.asterisk=42]="asterisk",e[e.backslash=92]="backslash",e[e.closeBrace=125]="closeBrace",e[e.closeBracket=93]="closeBracket",e[e.colon=58]="colon",e[e.comma=44]="comma",e[e.dot=46]="dot",e[e.doubleQuote=34]="doubleQuote",e[e.minus=45]="minus",e[e.openBrace=123]="openBrace",e[e.openBracket=91]="openBracket",e[e.plus=43]="plus",e[e.slash=47]="slash",e[e.formFeed=12]="formFeed",e[e.tab=9]="tab"}(Em||(Em={}));var Rm,Dm,Pm,Lm=new Array(20).fill(0).map(function(e,t){return" ".repeat(t)}),Bm=200,Im={" ":{"\n":new Array(Bm).fill(0).map(function(e,t){return"\n"+" ".repeat(t)}),"\r":new Array(Bm).fill(0).map(function(e,t){return"\r"+" ".repeat(t)}),"\r\n":new Array(Bm).fill(0).map(function(e,t){return"\r\n"+" ".repeat(t)})},"\t":{"\n":new Array(Bm).fill(0).map(function(e,t){return"\n"+"\t".repeat(t)}),"\r":new Array(Bm).fill(0).map(function(e,t){return"\r"+"\t".repeat(t)}),"\r\n":new Array(Bm).fill(0).map(function(e,t){return"\r\n"+"\t".repeat(t)})}},_m=["\n","\r","\r\n"];function Fm(e,t,n){var r,i,o,s,a;if(t){for(s=t.offset,a=s+t.length,o=s;o>0&&!jm(e,o-1);)o--;for(var l=a;l<e.length&&!jm(e,l);)l++;i=e.substring(o,l),r=function(e,t){var n=0,r=0,i=t.tabSize||4;for(;n<e.length;){var o=e.charAt(n);if(o===Lm[1])r++;else{if("\t"!==o)break;r+=i}n++}return Math.floor(r/i)}(i,n)}else i=e,r=0,o=0,s=0,a=e.length;var c,u,h=function(e,t){for(var n=0;n<t.length;n++){var r=t.charAt(n);if("\r"===r)return n+1<t.length&&"\n"===t.charAt(n+1)?"\r\n":"\r";if("\n"===r)return"\n"}return e&&e.eol||"\n"}(n,e),f=_m.includes(h),d=0,p=0;n.insertSpaces?c=null!==(u=Lm[n.tabSize||4])&&void 0!==u?u:Wm(Lm[1],n.tabSize||4):c="\t";var m="\t"===c?"\t":" ",g=Mm(i,!1),v=!1;function y(){if(d>1)return Wm(h,d)+Wm(c,r+p);var e=c.length*(r+p);return!f||e>Im[m][h].length?h+Wm(c,r+p):e<=0?h:Im[m][h][e]}function b(){var e=g.scan();for(d=0;15===e||14===e;)14===e&&n.keepLines?d+=1:14===e&&(d=1),e=g.scan();return v=16===e||0!==g.getTokenError(),e}var w=[];function k(n,r,i){v||t&&!(r<a&&i>s)||e.substring(r,i)===n||w.push({offset:r,length:i-r,content:n})}var x=b();if(n.keepLines&&d>0&&k(Wm(h,d),0,0),17!==x){var S=g.getTokenOffset()+o;k(c.length*r<20&&n.insertSpaces?Lm[c.length*r]:Wm(c,r),o,S)}for(;17!==x;){for(var C=g.getTokenOffset()+g.getTokenLength()+o,E=b(),A="",M=!1;0===d&&(12===E||13===E);){var O=g.getTokenOffset()+o;k(Lm[1],C,O),C=g.getTokenOffset()+g.getTokenLength()+o,A=(M=12===E)?y():"",E=b()}if(2===E)1!==x&&p--,n.keepLines&&d>0||!n.keepLines&&1!==x?A=y():n.keepLines&&(A=Lm[1]);else if(4===E)3!==x&&p--,n.keepLines&&d>0||!n.keepLines&&3!==x?A=y():n.keepLines&&(A=Lm[1]);else{switch(x){case 3:case 1:p++,A=n.keepLines&&d>0||!n.keepLines?y():Lm[1];break;case 5:A=n.keepLines&&d>0||!n.keepLines?y():Lm[1];break;case 12:A=y();break;case 13:d>0?A=y():M||(A=Lm[1]);break;case 6:n.keepLines&&d>0?A=y():M||(A=Lm[1]);break;case 10:n.keepLines&&d>0?A=y():6!==E||M||(A="");break;case 7:case 8:case 9:case 11:case 2:case 4:n.keepLines&&d>0?A=y():12!==E&&13!==E||M?5!==E&&17!==E&&(v=!0):A=Lm[1];break;case 16:v=!0}d>0&&(12===E||13===E)&&(A=y())}17===E&&(A=n.keepLines&&d>0?y():n.insertFinalNewline?h:""),k(A,C,g.getTokenOffset()+o),x=E}return w}function Wm(e,t){for(var n="",r=0;r<t;r++)n+=e;return n}function jm(e,t){return-1!=="\r\n".indexOf(e.charAt(t))}!function(e){e.DEFAULT={allowTrailingComma:!1}}(Rm||(Rm={})),function(e){e[e.None=0]="None",e[e.UnexpectedEndOfComment=1]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=2]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=3]="UnexpectedEndOfNumber",e[e.InvalidUnicode=4]="InvalidUnicode",e[e.InvalidEscapeCharacter=5]="InvalidEscapeCharacter",e[e.InvalidCharacter=6]="InvalidCharacter"}(Dm||(Dm={})),function(e){e[e.OpenBraceToken=1]="OpenBraceToken",e[e.CloseBraceToken=2]="CloseBraceToken",e[e.OpenBracketToken=3]="OpenBracketToken",e[e.CloseBracketToken=4]="CloseBracketToken",e[e.CommaToken=5]="CommaToken",e[e.ColonToken=6]="ColonToken",e[e.NullKeyword=7]="NullKeyword",e[e.TrueKeyword=8]="TrueKeyword",e[e.FalseKeyword=9]="FalseKeyword",e[e.StringLiteral=10]="StringLiteral",e[e.NumericLiteral=11]="NumericLiteral",e[e.LineCommentTrivia=12]="LineCommentTrivia",e[e.BlockCommentTrivia=13]="BlockCommentTrivia",e[e.LineBreakTrivia=14]="LineBreakTrivia",e[e.Trivia=15]="Trivia",e[e.Unknown=16]="Unknown",e[e.EOF=17]="EOF"}(Pm||(Pm={}));var Hm,zm=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Rm.DEFAULT,r=null,i=[],o=[];function s(e){Array.isArray(i)?i.push(e):null!==r&&(i[r]=e)}var a={onObjectBegin:function(){var e={};s(e),o.push(i),i=e,r=null},onObjectProperty:function(e){r=e},onObjectEnd:function(){i=o.pop()},onArrayBegin:function(){var e=[];s(e),o.push(i),i=e,r=null},onArrayEnd:function(){i=o.pop()},onLiteralValue:s,onError:function(e,n,r){t.push({error:e,offset:n,length:r})}};return function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Rm.DEFAULT,r=Mm(e,!1),i=[],o=0;function s(e){return e?function(){return 0===o&&e(r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter())}:function(){return!0}}function a(e){return e?function(t){return 0===o&&e(t,r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter())}:function(){return!0}}function l(e){return e?function(t){return 0===o&&e(t,r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter(),function(){return i.slice()})}:function(){return!0}}function c(e){return e?function(){o>0?o++:!1===e(r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter(),function(){return i.slice()})&&(o=1)}:function(){return!0}}function u(e){return e?function(){o>0&&o--,0===o&&e(r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter())}:function(){return!0}}var h=c(t.onObjectBegin),f=l(t.onObjectProperty),d=u(t.onObjectEnd),p=c(t.onArrayBegin),m=u(t.onArrayEnd),g=l(t.onLiteralValue),v=a(t.onSeparator),y=s(t.onComment),b=a(t.onError),w=n&&n.disallowComments,k=n&&n.allowTrailingComma;function x(){for(;;){var e=r.scan();switch(r.getTokenError()){case 4:S(14);break;case 5:S(15);break;case 3:S(13);break;case 1:w||S(11);break;case 2:S(12);break;case 6:S(16)}switch(e){case 12:case 13:w?S(10):y();break;case 16:S(1);break;case 15:case 14:break;default:return e}}}function S(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];if(b(e),t.length+n.length>0)for(var i=r.getToken();17!==i;){if(-1!==t.indexOf(i)){x();break}if(-1!==n.indexOf(i))break;i=x()}}function C(e){var t=r.getTokenValue();return e?g(t):(f(t),i.push(t)),x(),!0}function E(){switch(r.getToken()){case 11:var e=r.getTokenValue(),t=Number(e);isNaN(t)&&(S(2),t=0),g(t);break;case 7:g(null);break;case 8:g(!0);break;case 9:g(!1);break;default:return!1}return x(),!0}function A(){return 10!==r.getToken()?(S(3,[],[2,5]),!1):(C(!1),6===r.getToken()?(v(":"),x(),N()||S(4,[],[2,5])):S(5,[],[2,5]),i.pop(),!0)}function M(){h(),x();for(var e=!1;2!==r.getToken()&&17!==r.getToken();){if(5===r.getToken()){if(e||S(4,[],[]),v(","),x(),2===r.getToken()&&k)break}else e&&S(6,[],[]);A()||S(4,[],[2,5]),e=!0}return d(),2!==r.getToken()?S(7,[2],[]):x(),!0}function O(){p(),x();for(var e=!0,t=!1;4!==r.getToken()&&17!==r.getToken();){if(5===r.getToken()){if(t||S(4,[],[]),v(","),x(),4===r.getToken()&&k)break}else t&&S(6,[],[]);e?(i.push(0),e=!1):i[i.length-1]++,N()||S(4,[],[4,5]),t=!0}return m(),e||i.pop(),4!==r.getToken()?S(8,[4],[]):x(),!0}function N(){switch(r.getToken()){case 3:return O();case 1:return M();case 10:return C(!0);default:return E()}}if(x(),17===r.getToken())return!!n.allowEmptyContent||(S(4,[],[]),!1);if(!N())return S(4,[],[]),!1;17!==r.getToken()&&S(9,[],[])}(e,a,n),i[0]};function Vm(e,t){if(!t.length)return"JSON 格式不正确";var n=t[0],r=function(e,t){for(var n=1,r=1,i=Math.max(0,Math.min(t,e.length)),o=0;o<i;o++){"\n"===e.charAt(o)?(n++,r=1):r++}return{line:n,col:r}}(e,n.offset),i=r.line,o=r.col,s=function(e){switch(e){case 1:return"InvalidSymbol";case 2:return"InvalidNumberFormat";case 3:return"PropertyNameExpected";case 4:return"ValueExpected";case 5:return"ColonExpected";case 6:return"CommaExpected";case 7:return"CloseBraceExpected";case 8:return"CloseBracketExpected";case 9:return"EndOfFileExpected";case 10:return"InvalidCommentToken";case 11:return"UnexpectedEndOfComment";case 12:return"UnexpectedEndOfString";case 13:return"UnexpectedEndOfNumber";case 14:return"InvalidUnicode";case 15:return"InvalidEscapeCharacter";case 16:return"InvalidCharacter"}return"<unknown ParseErrorCode>"}(n.error);return"JSON 格式不正确(".concat(s,",行 ").concat(i," 列 ").concat(o,")")}function qm(e){if(null==e||""===e)return{ok:!0,value:null,pretty:"null",compact:"null"};try{if("string"!=typeof e)return{ok:!0,value:e,pretty:JSON.stringify(e,null,2),compact:JSON.stringify(e)};var t=e,n=[],r=zm(t,n,{allowTrailingComma:!0,disallowComments:!1});return n.length?{ok:!1,message:Vm(t,n),pretty:t,compact:t}:{ok:!0,value:r,pretty:JSON.stringify(r,null,2),compact:JSON.stringify(r)}}catch(t){var i="string"==typeof e?e:String(e);return{ok:!1,message:"JSON 格式不正确",pretty:i,compact:i}}}function Um(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,n=(e||"").toString(),r=[];if(zm(n,r,{allowTrailingComma:!0,disallowComments:!1}),r.length)return{ok:!1,message:Vm(n,r)};for(var i=function(e,t,n){return Fm(e,t,n)}(n,void 0,{insertSpaces:!0,tabSize:t}),o=n,s=i.length-1;s>=0;s--){var a=i[s];o=o.slice(0,a.offset)+a.content+o.slice(a.offset+a.length)}return{ok:!0,formatted:o}}function Km(){return Km=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Km.apply(null,arguments)}!function(e){e[e.InvalidSymbol=1]="InvalidSymbol",e[e.InvalidNumberFormat=2]="InvalidNumberFormat",e[e.PropertyNameExpected=3]="PropertyNameExpected",e[e.ValueExpected=4]="ValueExpected",e[e.ColonExpected=5]="ColonExpected",e[e.CommaExpected=6]="CommaExpected",e[e.CloseBraceExpected=7]="CloseBraceExpected",e[e.CloseBracketExpected=8]="CloseBracketExpected",e[e.EndOfFileExpected=9]="EndOfFileExpected",e[e.InvalidCommentToken=10]="InvalidCommentToken",e[e.UnexpectedEndOfComment=11]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=12]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=13]="UnexpectedEndOfNumber",e[e.InvalidUnicode=14]="InvalidUnicode",e[e.InvalidEscapeCharacter=15]="InvalidEscapeCharacter",e[e.InvalidCharacter=16]="InvalidCharacter"}(Hm||(Hm={}));var Gm=[],Ym=[];function $m(e){if(e<768)return!1;for(var t=0,n=Gm.length;;){var r=t+n>>1;if(e<Gm[r])n=r;else{if(!(e>=Ym[r]))return!0;t=r+1}if(t==n)return!1}}function Xm(e){return e>=127462&&e<=127487}!function(){for(var e="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(function(e){return e?parseInt(e,36):1}),t=0,n=0;t<e.length;t++)(t%2?Ym:Gm).push(n+=e[t])}();function Jm(e,t){return(!(arguments.length>2&&void 0!==arguments[2])||arguments[2]?Qm:Zm)(e,t,!(arguments.length>3&&void 0!==arguments[3])||arguments[3])}function Qm(e,t,n){if(t==e.length)return t;t&&tg(e.charCodeAt(t))&&ng(e.charCodeAt(t-1))&&t--;var r=eg(e,t);for(t+=rg(r);t<e.length;){var i=eg(e,t);if(8205==r||8205==i||n&&$m(i))t+=rg(i),r=i;else{if(!Xm(i))break;for(var o=0,s=t-2;s>=0&&Xm(eg(e,s));)o++,s-=2;if(o%2==0)break;t+=2}}return t}function Zm(e,t,n){for(;t>0;){var r=Qm(e,t-2,n);if(r<t)return r;t--}return 0}function eg(e,t){var n=e.charCodeAt(t);if(!ng(n)||t+1==e.length)return n;var r=e.charCodeAt(t+1);return tg(r)?r-56320+(n-55296<<10)+65536:n}function tg(e){return e>=56320&&e<57344}function ng(e){return e>=55296&&e<56320}function rg(e){return e<65536?1:2}var ig=function(){function e(){N(this,e)}return R(e,[{key:"lineAt",value:function(e){if(e<0||e>this.length)throw new RangeError("Invalid position ".concat(e," in document of length ").concat(this.length));return this.lineInner(e,!1,1,0)}},{key:"line",value:function(e){if(e<1||e>this.lines)throw new RangeError("Invalid line number ".concat(e," in ").concat(this.lines,"-line document"));return this.lineInner(e,!0,1,0)}},{key:"replace",value:function(e,t,n){var r=q(dg(this,e,t),2);e=r[0],t=r[1];var i=[];return this.decompose(0,e,i,2),n.length&&n.decompose(0,n.length,i,3),this.decompose(t,this.length,i,1),sg.from(i,this.length-(t-e)+n.length)}},{key:"append",value:function(e){return this.replace(this.length,this.length,e)}},{key:"slice",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.length,n=q(dg(this,e,t),2);e=n[0],t=n[1];var r=[];return this.decompose(e,t,r,0),sg.from(r,t-e)}},{key:"eq",value:function(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;for(var t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),r=new cg(this),i=new cg(e),o=t,s=t;;){if(r.next(o),i.next(o),o=0,r.lineBreak!=i.lineBreak||r.done!=i.done||r.value!=i.value)return!1;if(s+=r.value.length,r.done||s>=n)return!0}}},{key:"iter",value:function(){return new cg(this,arguments.length>0&&void 0!==arguments[0]?arguments[0]:1)}},{key:"iterRange",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.length;return new ug(this,e,t)}},{key:"iterLines",value:function(e,t){var n;if(null==e)n=this.iter();else{null==t&&(t=this.lines+1);var r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new hg(n)}},{key:"toString",value:function(){return this.sliceString(0)}},{key:"toJSON",value:function(){var e=[];return this.flatten(e),e}}],[{key:"of",value:function(t){if(0==t.length)throw new RangeError("A document must have at least one line");return 1!=t.length||t[0]?t.length<=32?new og(t):sg.from(og.split(t,[])):e.empty}}])}(),og=function(){function e(t){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(e){var t,n=-1,r=D(e);try{for(r.s();!(t=r.n()).done;){n+=t.value.length+1}}catch(e){r.e(e)}finally{r.f()}return n}(t);return N(this,e),(n=O(this,e)).text=t,n.length=r,n}return I(e,ig),R(e,[{key:"lines",get:function(){return this.text.length}},{key:"children",get:function(){return null}},{key:"lineInner",value:function(e,t,n,r){for(var i=0;;i++){var o=this.text[i],s=r+o.length;if((t?n:s)>=e)return new fg(r,s,n,o);r=s+1,n++}}},{key:"decompose",value:function(t,n,r,i){var o=t<=0&&n>=this.length?this:new e(lg(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(1&i){var s=r.pop(),a=ag(o.text,s.text.slice(),0,o.length);if(a.length<=32)r.push(new e(a,s.length+o.length));else{var l=a.length>>1;r.push(new e(a.slice(0,l)),new e(a.slice(l)))}}else r.push(o)}},{key:"replace",value:function(t,n,r){if(!(r instanceof e))return U(e,"replace",this,3)([t,n,r]);var i=q(dg(this,t,n),2);t=i[0],n=i[1];var o=ag(this.text,ag(r.text,lg(this.text,0,t)),n),s=this.length+r.length-(n-t);return o.length<=32?new e(o,s):sg.from(e.split(o,[]),s)}},{key:"sliceString",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.length,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"\n",r=q(dg(this,e,t),2);e=r[0],t=r[1];for(var i="",o=0,s=0;o<=t&&s<this.text.length;s++){var a=this.text[s],l=o+a.length;o>e&&s&&(i+=n),e<l&&t>o&&(i+=a.slice(Math.max(0,e-o),t-o)),o=l+1}return i}},{key:"flatten",value:function(e){var t,n=D(this.text);try{for(n.s();!(t=n.n()).done;){var r=t.value;e.push(r)}}catch(e){n.e(e)}finally{n.f()}}},{key:"scanIdentical",value:function(){return 0}}],[{key:"split",value:function(t,n){var r,i=[],o=-1,s=D(t);try{for(s.s();!(r=s.n()).done;){var a=r.value;i.push(a),o+=a.length+1,32==i.length&&(n.push(new e(i,o)),i=[],o=-1)}}catch(e){s.e(e)}finally{s.f()}return o>-1&&n.push(new e(i,o)),n}}])}(),sg=function(){function e(t,n){var r;N(this,e),(r=O(this,e)).children=t,r.length=n,r.lines=0;var i,o=D(t);try{for(o.s();!(i=o.n()).done;){var s=i.value;r.lines+=s.lines}}catch(e){o.e(e)}finally{o.f()}return r}return I(e,ig),R(e,[{key:"lineInner",value:function(e,t,n,r){for(var i=0;;i++){var o=this.children[i],s=r+o.length,a=n+o.lines-1;if((t?a:s)>=e)return o.lineInner(e,t,n,r);r=s+1,n=a+1}}},{key:"decompose",value:function(e,t,n,r){for(var i=0,o=0;o<=t&&i<this.children.length;i++){var s=this.children[i],a=o+s.length;if(e<=a&&t>=o){var l=r&((o<=e?1:0)|(a>=t?2:0));o>=e&&a<=t&&!l?n.push(s):s.decompose(e-o,t-o,n,l)}o=a+1}}},{key:"replace",value:function(t,n,r){var i=q(dg(this,t,n),2);if(t=i[0],n=i[1],r.lines<this.lines)for(var o=0,s=0;o<this.children.length;o++){var a=this.children[o],l=s+a.length;if(t>=s&&n<=l){var c=a.replace(t-s,n-s,r),u=this.lines-a.lines+c.lines;if(c.lines<u>>4&&c.lines>u>>6){var h=this.children.slice();return h[o]=c,new e(h,this.length-(n-t)+r.length)}return U(e,"replace",this,3)([s,l,c])}s=l+1}return U(e,"replace",this,3)([t,n,r])}},{key:"sliceString",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.length,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"\n",r=q(dg(this,e,t),2);e=r[0],t=r[1];for(var i="",o=0,s=0;o<this.children.length&&s<=t;o++){var a=this.children[o],l=s+a.length;s>e&&o&&(i+=n),e<l&&t>s&&(i+=a.sliceString(e-s,t-s,n)),s=l+1}return i}},{key:"flatten",value:function(e){var t,n=D(this.children);try{for(n.s();!(t=n.n()).done;){t.value.flatten(e)}}catch(e){n.e(e)}finally{n.f()}}},{key:"scanIdentical",value:function(t,n){if(!(t instanceof e))return 0;for(var r=0,i=q(n>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1],4),o=i[0],s=i[1],a=i[2],l=i[3];;o+=n,s+=n){if(o==a||s==l)return r;var c=this.children[o],u=t.children[s];if(c!=u)return r+c.scanIdentical(u,n);r+=c.length+1}}}],[{key:"from",value:function(t){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t.reduce(function(e,t){return e+t.length+1},-1),i=0,o=D(t);try{for(o.s();!(n=o.n()).done;){i+=n.value.lines}}catch(e){o.e(e)}finally{o.f()}if(i<32){var s,a=[],l=D(t);try{for(l.s();!(s=l.n()).done;){s.value.flatten(a)}}catch(e){l.e(e)}finally{l.f()}return new og(a,r)}var c=Math.max(32,i>>5),u=c<<1,h=c>>1,f=[],d=0,p=-1,m=[];function g(t){var n;if(t.lines>u&&t instanceof e){var r,i=D(t.children);try{for(i.s();!(r=i.n()).done;){g(r.value)}}catch(e){i.e(e)}finally{i.f()}}else t.lines>h&&(d>h||!d)?(v(),f.push(t)):t instanceof og&&d&&(n=m[m.length-1])instanceof og&&t.lines+n.lines<=32?(d+=t.lines,p+=t.length+1,m[m.length-1]=new og(n.text.concat(t.text),n.length+1+t.length)):(d+t.lines>c&&v(),d+=t.lines,p+=t.length+1,m.push(t))}function v(){0!=d&&(f.push(1==m.length?m[0]:e.from(m,p)),p=-1,d=m.length=0)}var y,b=D(t);try{for(b.s();!(y=b.n()).done;){g(y.value)}}catch(e){b.e(e)}finally{b.f()}return v(),1==f.length?f[0]:new e(f,r)}}])}();function ag(e,t){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1e9,i=0,o=0,s=!0;o<e.length&&i<=r;o++){var a=e[o],l=i+a.length;l>=n&&(l>r&&(a=a.slice(0,r-i)),i<n&&(a=a.slice(n-i)),s?(t[t.length-1]+=a,s=!1):t.push(a)),i=l+1}return t}function lg(e,t,n){return ag(e,[""],t,n)}ig.empty=new og([""],0);var cg=function(){return R(function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;N(this,e),this.dir=n,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[t],this.offsets=[n>0?1:(t instanceof og?t.text.length:t.children.length)<<1]},[{key:"nextInner",value:function(e,t){for(this.done=this.lineBreak=!1;;){var n=this.nodes.length-1,r=this.nodes[n],i=this.offsets[n],o=i>>1,s=r instanceof og?r.text.length:r.children.length;if(o==(t>0?s:0)){if(0==n)return this.done=!0,this.value="",this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&i)==(t>0?0:1)){if(this.offsets[n]+=t,0==e)return this.lineBreak=!0,this.value="\n",this;e--}else if(r instanceof og){var a=r.text[o+(t<0?-1:0)];if(this.offsets[n]+=t,a.length>Math.max(0,e))return this.value=0==e?a:t>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{var l=r.children[o+(t<0?-1:0)];e>l.length?(e-=l.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(l),this.offsets.push(t>0?1:(l instanceof og?l.text.length:l.children.length)<<1))}}}},{key:"next",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}])}(),ug=function(){return R(function e(t,n,r){N(this,e),this.value="",this.done=!1,this.cursor=new cg(t,n>r?-1:1),this.pos=n>r?t.length:0,this.from=Math.min(n,r),this.to=Math.max(n,r)},[{key:"nextInner",value:function(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);var n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;var r=this.cursor.next(e).value;return this.pos+=(r.length+e)*t,this.value=r.length<=n?r:t<0?r.slice(r.length-n):r.slice(0,n),this.done=!this.value,this}},{key:"next",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}},{key:"lineBreak",get:function(){return this.cursor.lineBreak&&""!=this.value}}])}(),hg=function(){return R(function e(t){N(this,e),this.inner=t,this.afterBreak=!0,this.value="",this.done=!1},[{key:"next",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=this.inner.next(e),n=t.done,r=t.lineBreak,i=t.value;return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(this.done=!0,this.value=""):r?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=i,this.afterBreak=!1),this}},{key:"lineBreak",get:function(){return!1}}])}();"undefined"!=typeof Symbol&&(ig.prototype[Symbol.iterator]=function(){return this.iter()},cg.prototype[Symbol.iterator]=ug.prototype[Symbol.iterator]=hg.prototype[Symbol.iterator]=function(){return this});var fg=function(){return R(function e(t,n,r,i){N(this,e),this.from=t,this.to=n,this.number=r,this.text=i},[{key:"length",get:function(){return this.to-this.from}}])}();function dg(e,t,n){return[t=Math.max(0,Math.min(e.length,t)),Math.max(t,Math.min(e.length,n))]}function pg(e,t){return Jm(e,t,!(arguments.length>2&&void 0!==arguments[2])||arguments[2],!(arguments.length>3&&void 0!==arguments[3])||arguments[3])}function mg(e,t){var n,r=e.charCodeAt(t);if(!(n=r,n>=55296&&n<56320&&t+1!=e.length))return r;var i=e.charCodeAt(t+1);return function(e){return e>=56320&&e<57344}(i)?i-56320+(r-55296<<10)+65536:r}function gg(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode(55296+(e>>10),56320+(1023&e)))}function vg(e){return e<65536?1:2}var yg=/\r\n?|\n/,bg=function(e){return e[e.Simple=0]="Simple",e[e.TrackDel=1]="TrackDel",e[e.TrackBefore=2]="TrackBefore",e[e.TrackAfter=3]="TrackAfter",e}(bg||(bg={})),wg=function(){function e(t){N(this,e),this.sections=t}return R(e,[{key:"length",get:function(){for(var e=0,t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}},{key:"newLength",get:function(){for(var e=0,t=0;t<this.sections.length;t+=2){var n=this.sections[t+1];e+=n<0?this.sections[t]:n}return e}},{key:"empty",get:function(){return 0==this.sections.length||2==this.sections.length&&this.sections[1]<0}},{key:"iterGaps",value:function(e){for(var t=0,n=0,r=0;t<this.sections.length;){var i=this.sections[t++],o=this.sections[t++];o<0?(e(n,r,i),r+=i):r+=o,n+=i}}},{key:"iterChangedRanges",value:function(e){Cg(this,e,arguments.length>1&&void 0!==arguments[1]&&arguments[1])}},{key:"invertedDesc",get:function(){for(var t=[],n=0;n<this.sections.length;){var r=this.sections[n++],i=this.sections[n++];i<0?t.push(r,i):t.push(i,r)}return new e(t)}},{key:"composeDesc",value:function(e){return this.empty?e:e.empty?this:Ag(this,e)}},{key:"mapDesc",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return e.empty?this:Eg(this,e,t)}},{key:"mapPos",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:bg.Simple,r=0,i=0,o=0;o<this.sections.length;){var s=this.sections[o++],a=this.sections[o++],l=r+s;if(a<0){if(l>e)return i+(e-r);i+=s}else{if(n!=bg.Simple&&l>=e&&(n==bg.TrackDel&&r<e&&l>e||n==bg.TrackBefore&&r<e||n==bg.TrackAfter&&l>e))return null;if(l>e||l==e&&t<0&&!s)return e==r||t<0?i:i+a;i+=a}r=l}if(e>r)throw new RangeError("Position ".concat(e," is out of range for changeset of length ").concat(r));return i}},{key:"touchesRange",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e,n=0,r=0;n<this.sections.length&&r<=t;){var i=r+this.sections[n++];if(this.sections[n++]>=0&&r<=t&&i>=e)return!(r<e&&i>t)||"cover";r=i}return!1}},{key:"toString",value:function(){for(var e="",t=0;t<this.sections.length;){var n=this.sections[t++],r=this.sections[t++];e+=(e?" ":"")+n+(r>=0?":"+r:"")}return e}},{key:"toJSON",value:function(){return this.sections}}],[{key:"fromJSON",value:function(t){if(!Array.isArray(t)||t.length%2||t.some(function(e){return"number"!=typeof e}))throw new RangeError("Invalid JSON representation of ChangeDesc");return new e(t)}},{key:"create",value:function(t){return new e(t)}}])}(),kg=function(){function e(t,n){var r;return N(this,e),(r=O(this,e,[t])).inserted=n,r}return I(e,wg),R(e,[{key:"apply",value:function(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Cg(this,function(t,n,r,i,o){return e=e.replace(r,r+(n-t),o)},!1),e}},{key:"mapDesc",value:function(e){return Eg(this,e,arguments.length>1&&void 0!==arguments[1]&&arguments[1],!0)}},{key:"invert",value:function(t){for(var n=this.sections.slice(),r=[],i=0,o=0;i<n.length;i+=2){var s=n[i],a=n[i+1];if(a>=0){n[i]=a,n[i+1]=s;for(var l=i>>1;r.length<l;)r.push(ig.empty);r.push(s?t.slice(o,o+s):ig.empty)}o+=s}return new e(n,r)}},{key:"compose",value:function(e){return this.empty?e:e.empty?this:Ag(this,e,!0)}},{key:"map",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return e.empty?this:Eg(this,e,t,!0)}},{key:"iterChanges",value:function(e){Cg(this,e,arguments.length>1&&void 0!==arguments[1]&&arguments[1])}},{key:"desc",get:function(){return wg.create(this.sections)}},{key:"filter",value:function(t){var n=[],r=[],i=[],o=new Mg(this);e:for(var s=0,a=0;;){for(var l=s==t.length?1e9:t[s++];a<l||a==l&&0==o.len;){if(o.done)break e;var c=Math.min(o.len,l-a);xg(i,c,-1);var u=-1==o.ins?-1:0==o.off?o.ins:0;xg(n,c,u),u>0&&Sg(r,n,o.text),o.forward(c),a+=c}for(var h=t[s++];a<h;){if(o.done)break e;var f=Math.min(o.len,h-a);xg(n,f,-1),xg(i,f,-1==o.ins?-1:0==o.off?o.ins:0),o.forward(f),a+=f}}return{changes:new e(n,r),filtered:wg.create(i)}}},{key:"toJSON",value:function(){for(var e=[],t=0;t<this.sections.length;t+=2){var n=this.sections[t],r=this.sections[t+1];r<0?e.push(n):0==r?e.push([n]):e.push([n].concat(this.inserted[t>>1].toJSON()))}return e}}],[{key:"of",value:function(t,n,r){var i=[],o=[],s=0,a=null;function l(){if(arguments.length>0&&void 0!==arguments[0]&&arguments[0]||i.length){s<n&&xg(i,n-s,-1);var t=new e(i,o);a=a?a.compose(t.map(a)):t,i=[],o=[],s=0}}return function t(c){if(Array.isArray(c)){var u,h=D(c);try{for(h.s();!(u=h.n()).done;){t(u.value)}}catch(e){h.e(e)}finally{h.f()}}else if(c instanceof e){if(c.length!=n)throw new RangeError("Mismatched change set length (got ".concat(c.length,", expected ").concat(n,")"));l(),a=a?a.compose(c.map(a)):c}else{var f=c.from,d=c.to,p=void 0===d?f:d,m=c.insert;if(f>p||f<0||p>n)throw new RangeError("Invalid change range ".concat(f," to ").concat(p," (in doc of length ").concat(n,")"));var g=m?"string"==typeof m?ig.of(m.split(r||yg)):m:ig.empty,v=g.length;if(f==p&&0==v)return;f<s&&l(),f>s&&xg(i,f-s,-1),xg(i,p-f,v),Sg(o,i,g),s=p}}(t),l(!a),a}},{key:"empty",value:function(t){return new e(t?[t,-1]:[],[])}},{key:"fromJSON",value:function(t){if(!Array.isArray(t))throw new RangeError("Invalid JSON representation of ChangeSet");for(var n=[],r=[],i=0;i<t.length;i++){var o=t[i];if("number"==typeof o)n.push(o,-1);else{if(!Array.isArray(o)||"number"!=typeof o[0]||o.some(function(e,t){return t&&"string"!=typeof e}))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==o.length)n.push(o[0],0);else{for(;r.length<i;)r.push(ig.empty);r[i]=ig.of(o.slice(1)),n.push(o[0],r[i].length)}}}return new e(n,r)}},{key:"createSet",value:function(t,n){return new e(t,n)}}])}();function xg(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(!(0==t&&n<=0)){var i=e.length-2;i>=0&&n<=0&&n==e[i+1]?e[i]+=t:i>=0&&0==t&&0==e[i]?e[i+1]+=n:r?(e[i]+=t,e[i+1]+=n):e.push(t,n)}}function Sg(e,t,n){if(0!=n.length){var r=t.length-2>>1;if(r<e.length)e[e.length-1]=e[e.length-1].append(n);else{for(;e.length<r;)e.push(ig.empty);e.push(n)}}}function Cg(e,t,n){for(var r=e.inserted,i=0,o=0,s=0;s<e.sections.length;){var a=e.sections[s++],l=e.sections[s++];if(l<0)i+=a,o+=a;else{for(var c=i,u=o,h=ig.empty;c+=a,u+=l,l&&r&&(h=h.append(r[s-2>>1])),!(n||s==e.sections.length||e.sections[s+1]<0);)a=e.sections[s++],l=e.sections[s++];t(i,c,o,u,h),i=c,o=u}}}function Eg(e,t,n){for(var r=[],i=arguments.length>3&&void 0!==arguments[3]&&arguments[3]?[]:null,o=new Mg(e),s=new Mg(t),a=-1;;){if(o.done&&s.len||s.done&&o.len)throw new Error("Mismatched change set lengths");if(-1==o.ins&&-1==s.ins){var l=Math.min(o.len,s.len);xg(r,l,-1),o.forward(l),s.forward(l)}else if(s.ins>=0&&(o.ins<0||a==o.i||0==o.off&&(s.len<o.len||s.len==o.len&&!n))){var c=s.len;for(xg(r,s.ins,-1);c;){var u=Math.min(o.len,c);o.ins>=0&&a<o.i&&o.len<=u&&(xg(r,0,o.ins),i&&Sg(i,r,o.text),a=o.i),o.forward(u),c-=u}s.next()}else{if(!(o.ins>=0)){if(o.done&&s.done)return i?kg.createSet(r,i):wg.create(r);throw new Error("Mismatched change set lengths")}for(var h=0,f=o.len;f;)if(-1==s.ins){var d=Math.min(f,s.len);h+=d,f-=d,s.forward(d)}else{if(!(0==s.ins&&s.len<f))break;f-=s.len,s.next()}xg(r,h,a<o.i?o.ins:0),i&&a<o.i&&Sg(i,r,o.text),a=o.i,o.forward(o.len-f)}}}function Ag(e,t){for(var n=[],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2]?[]:null,i=new Mg(e),o=new Mg(t),s=!1;;){if(i.done&&o.done)return r?kg.createSet(n,r):wg.create(n);if(0==i.ins)xg(n,i.len,0,s),i.next();else if(0!=o.len||o.done){if(i.done||o.done)throw new Error("Mismatched change set lengths");var a=Math.min(i.len2,o.len),l=n.length;if(-1==i.ins){var c=-1==o.ins?-1:o.off?0:o.ins;xg(n,a,c,s),r&&c&&Sg(r,n,o.text)}else-1==o.ins?(xg(n,i.off?0:i.len,a,s),r&&Sg(r,n,i.textBit(a))):(xg(n,i.off?0:i.len,o.off?0:o.ins,s),r&&!o.off&&Sg(r,n,o.text));s=(i.ins>a||o.ins>=0&&o.len>a)&&(s||n.length>l),i.forward2(a),o.forward(a)}else xg(n,0,o.ins,s),r&&Sg(r,n,o.text),o.next()}}var Mg=function(){return R(function e(t){N(this,e),this.set=t,this.i=0,this.next()},[{key:"next",value:function(){var e=this.set.sections;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}},{key:"done",get:function(){return-2==this.ins}},{key:"len2",get:function(){return this.ins<0?this.len:this.ins}},{key:"text",get:function(){var e=this.set.inserted,t=this.i-2>>1;return t>=e.length?ig.empty:e[t]}},{key:"textBit",value:function(e){var t=this.set.inserted,n=this.i-2>>1;return n>=t.length&&!e?ig.empty:t[n].slice(this.off,null==e?void 0:this.off+e)}},{key:"forward",value:function(e){e==this.len?this.next():(this.len-=e,this.off+=e)}},{key:"forward2",value:function(e){-1==this.ins?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}])}(),Og=function(){function e(t,n,r){N(this,e),this.from=t,this.to=n,this.flags=r}return R(e,[{key:"anchor",get:function(){return 32&this.flags?this.to:this.from}},{key:"head",get:function(){return 32&this.flags?this.from:this.to}},{key:"empty",get:function(){return this.from==this.to}},{key:"assoc",get:function(){return 8&this.flags?-1:16&this.flags?1:0}},{key:"bidiLevel",get:function(){var e=7&this.flags;return 7==e?null:e}},{key:"goalColumn",get:function(){var e=this.flags>>6;return 16777215==e?void 0:e}},{key:"map",value:function(t){var n,r,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1;return this.empty?n=r=t.mapPos(this.from,i):(n=t.mapPos(this.from,1),r=t.mapPos(this.to,-1)),n==this.from&&r==this.to?this:new e(n,r,this.flags)}},{key:"extend",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e;if(e<=this.anchor&&t>=this.anchor)return Ng.range(e,t);var n=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return Ng.range(this.anchor,n)}},{key:"eq",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return!(this.anchor!=e.anchor||this.head!=e.head||this.goalColumn!=e.goalColumn||t&&this.empty&&this.assoc!=e.assoc)}},{key:"toJSON",value:function(){return{anchor:this.anchor,head:this.head}}}],[{key:"fromJSON",value:function(e){if(!e||"number"!=typeof e.anchor||"number"!=typeof e.head)throw new RangeError("Invalid JSON representation for SelectionRange");return Ng.range(e.anchor,e.head)}},{key:"create",value:function(t,n,r){return new e(t,n,r)}}])}(),Ng=function(){function e(t,n){N(this,e),this.ranges=t,this.mainIndex=n}return R(e,[{key:"map",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1;return t.empty?this:e.create(this.ranges.map(function(e){return e.map(t,n)}),this.mainIndex)}},{key:"eq",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(var n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n],t))return!1;return!0}},{key:"main",get:function(){return this.ranges[this.mainIndex]}},{key:"asSingle",value:function(){return 1==this.ranges.length?this:new e([this.main],0)}},{key:"addRange",value:function(t){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return e.create([t].concat(this.ranges),n?0:this.mainIndex+1)}},{key:"replaceRange",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.mainIndex,r=this.ranges.slice();return r[n]=t,e.create(r,this.mainIndex)}},{key:"toJSON",value:function(){return{ranges:this.ranges.map(function(e){return e.toJSON()}),main:this.mainIndex}}}],[{key:"fromJSON",value:function(t){if(!t||!Array.isArray(t.ranges)||"number"!=typeof t.main||t.main>=t.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new e(t.ranges.map(function(e){return Og.fromJSON(e)}),t.main)}},{key:"single",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t;return new e([e.range(t,n)],0)}},{key:"create",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(0==t.length)throw new RangeError("A selection needs at least one range");for(var r=0,i=0;i<t.length;i++){var o=t[i];if(o.empty?o.from<=r:o.from<r)return e.normalized(t.slice(),n);r=o.to}return new e(t,n)}},{key:"cursor",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2?arguments[2]:void 0,r=arguments.length>3?arguments[3]:void 0;return Og.create(e,e,(0==t?0:t<0?8:16)|(null==n?7:Math.min(6,n))|(null!=r?r:16777215)<<6)}},{key:"range",value:function(e,t,n,r){var i=(null!=n?n:16777215)<<6|(null==r?7:Math.min(6,r));return t<e?Og.create(t,e,48|i):Og.create(e,t,(t>e?8:0)|i)}},{key:"normalized",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=t[n];t.sort(function(e,t){return e.from-t.from}),n=t.indexOf(r);for(var i=1;i<t.length;i++){var o=t[i],s=t[i-1];if(o.empty?o.from<=s.to:o.from<s.to){var a=s.from,l=Math.max(o.to,s.to);i<=n&&n--,t.splice(--i,2,o.anchor>o.head?e.range(l,a):e.range(a,l))}}return new e(t,n)}}])}();function Tg(e,t){var n,r=D(e.ranges);try{for(r.s();!(n=r.n()).done;){if(n.value.to>t)throw new RangeError("Selection points outside of document")}}catch(e){r.e(e)}finally{r.f()}}var Rg=0,Dg=function(){function e(t,n,r,i,o){N(this,e),this.combine=t,this.compareInput=n,this.compare=r,this.isStatic=i,this.id=Rg++,this.default=t([]),this.extensions="function"==typeof o?o(this):o}return R(e,[{key:"reader",get:function(){return this}},{key:"of",value:function(e){return new Lg([],this,0,e)}},{key:"compute",value:function(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Lg(e,this,1,t)}},{key:"computeN",value:function(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Lg(e,this,2,t)}},{key:"from",value:function(e,t){return t||(t=function(e){return e}),this.compute([e],function(n){return t(n.field(e))})}}],[{key:"define",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new e(t.combine||function(e){return e},t.compareInput||function(e,t){return e===t},t.compare||(t.combine?function(e,t){return e===t}:Pg),!!t.static,t.enables)}}])}();function Pg(e,t){return e==t||e.length==t.length&&e.every(function(e,n){return e===t[n]})}var Lg=function(){return R(function e(t,n,r,i){N(this,e),this.dependencies=t,this.facet=n,this.type=r,this.value=i,this.id=Rg++},[{key:"dynamicSlot",value:function(e){var t,n,r=this,i=this.value,o=this.facet.compareInput,s=this.id,a=e[s]>>1,l=2==this.type,c=!1,u=!1,h=[],f=D(this.dependencies);try{for(f.s();!(n=f.n()).done;){var d=n.value;"doc"==d?c=!0:"selection"==d?u=!0:1&(null!==(t=e[d.id])&&void 0!==t?t:1)||h.push(e[d.id])}}catch(e){f.e(e)}finally{f.f()}return{create:function(e){return e.values[a]=i(e),1},update:function(e,t){if(c&&t.docChanged||u&&(t.docChanged||t.selection)||Ig(e,h)){var n=i(e);if(l?!Bg(n,e.values[a],o):!o(n,e.values[a]))return e.values[a]=n,1}return 0},reconfigure:function(e,t){var n,c=t.config.address[s];if(null!=c){var u=Xg(t,c);if(r.dependencies.every(function(n){return n instanceof Dg?t.facet(n)===e.facet(n):!(n instanceof Fg)||t.field(n,!1)==e.field(n,!1)})||(l?Bg(n=i(e),u,o):o(n=i(e),u)))return e.values[a]=u,0}else n=i(e);return e.values[a]=n,1}}}}])}();function Bg(e,t,n){if(e.length!=t.length)return!1;for(var r=0;r<e.length;r++)if(!n(e[r],t[r]))return!1;return!0}function Ig(e,t){var n,r=!1,i=D(t);try{for(i.s();!(n=i.n()).done;){1&$g(e,n.value)&&(r=!0)}}catch(e){i.e(e)}finally{i.f()}return r}var _g=Dg.define({static:!0}),Fg=function(){function e(t,n,r,i,o){N(this,e),this.id=t,this.createF=n,this.updateF=r,this.compareF=i,this.spec=o,this.provides=void 0}return R(e,[{key:"create",value:function(e){var t=this,n=e.facet(_g).find(function(e){return e.field==t});return((null==n?void 0:n.create)||this.createF)(e)}},{key:"slot",value:function(e){var t=this,n=e[this.id]>>1;return{create:function(e){return e.values[n]=t.create(e),1},update:function(e,r){var i=e.values[n],o=t.updateF(i,r);return t.compareF(i,o)?0:(e.values[n]=o,1)},reconfigure:function(e,r){var i,o=e.facet(_g),s=r.facet(_g);return(i=o.find(function(e){return e.field==t}))&&i!=s.find(function(e){return e.field==t})?(e.values[n]=i.create(e),1):null!=r.config.address[t.id]?(e.values[n]=r.field(t),0):(e.values[n]=t.create(e),1)}}}},{key:"init",value:function(e){return[this,_g.of({field:this,create:e})]}},{key:"extension",get:function(){return this}}],[{key:"define",value:function(t){var n=new e(Rg++,t.create,t.update,t.compare||function(e,t){return e===t},t);return t.provide&&(n.provides=t.provide(n)),n}}])}(),Wg=4,jg=3,Hg=2,zg=1;function Vg(e){return function(t){return new Ug(t,e)}}var qg={highest:Vg(0),high:Vg(zg),default:Vg(Hg),low:Vg(jg),lowest:Vg(Wg)},Ug=R(function e(t,n){N(this,e),this.inner=t,this.prec=n}),Kg=function(){function e(){N(this,e)}return R(e,[{key:"of",value:function(e){return new Gg(this,e)}},{key:"reconfigure",value:function(t){return e.reconfigure.of({compartment:this,extension:t})}},{key:"get",value:function(e){return e.config.compartments.get(this)}}])}(),Gg=R(function e(t,n){N(this,e),this.compartment=t,this.inner=n}),Yg=function(){function e(t,n,r,i,o,s){for(N(this,e),this.base=t,this.compartments=n,this.dynamicSlots=r,this.address=i,this.staticValues=o,this.facets=s,this.statusTemplate=[];this.statusTemplate.length<r.length;)this.statusTemplate.push(0)}return R(e,[{key:"staticFacet",value:function(e){var t=this.address[e.id];return null==t?e.default:this.staticValues[t>>1]}}],[{key:"resolve",value:function(t,n,r){var i,o=[],s=Object.create(null),a=new Map,l=D(function(e,t,n){var r=[[],[],[],[],[]],i=new Map;function o(e,s){var a=i.get(e);if(null!=a){if(a<=s)return;var l=r[a].indexOf(e);l>-1&&r[a].splice(l,1),e instanceof Gg&&n.delete(e.compartment)}if(i.set(e,s),Array.isArray(e)){var c,u=D(e);try{for(u.s();!(c=u.n()).done;){o(c.value,s)}}catch(e){u.e(e)}finally{u.f()}}else if(e instanceof Gg){if(n.has(e.compartment))throw new RangeError("Duplicate use of compartment in extensions");var h=t.get(e.compartment)||e.inner;n.set(e.compartment,h),o(h,s)}else if(e instanceof Ug)o(e.inner,e.prec);else if(e instanceof Fg)r[s].push(e),e.provides&&o(e.provides,s);else if(e instanceof Lg)r[s].push(e),e.facet.extensions&&o(e.facet.extensions,Hg);else{var f=e.extension;if(!f)throw new Error("Unrecognized extension value in extension set (".concat(e,"). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks."));o(f,s)}}return o(e,Hg),r.reduce(function(e,t){return e.concat(t)})}(t,n,a));try{for(l.s();!(i=l.n()).done;){var c=i.value;c instanceof Fg?o.push(c):(s[c.facet.id]||(s[c.facet.id]=[])).push(c)}}catch(e){l.e(e)}finally{l.f()}for(var u=Object.create(null),h=[],f=[],d=function(){var e=m[p];u[e.id]=f.length<<1,f.push(function(t){return e.slot(t)})},p=0,m=o;p<m.length;p++)d();var g=null==r?void 0:r.config.facets,v=function(){var e=s[y],t=e[0].facet,n=g&&g[y]||[];if(e.every(function(e){return 0==e.type}))if(u[t.id]=h.length<<1|1,Pg(n,e))h.push(r.facet(t));else{var i=t.combine(e.map(function(e){return e.value}));h.push(r&&t.compare(i,r.facet(t))?r.facet(t):i)}else{var o,a=D(e);try{var l=function(){var e=o.value;0==e.type?(u[e.id]=h.length<<1|1,h.push(e.value)):(u[e.id]=f.length<<1,f.push(function(t){return e.dynamicSlot(t)}))};for(a.s();!(o=a.n()).done;)l()}catch(e){a.e(e)}finally{a.f()}u[t.id]=f.length<<1,f.push(function(n){return function(e,t,n){var r=n.map(function(t){return e[t.id]}),i=n.map(function(e){return e.type}),o=r.filter(function(e){return!(1&e)}),s=e[t.id]>>1;function a(e){for(var n=[],o=0;o<r.length;o++){var s=Xg(e,r[o]);if(2==i[o]){var a,l=D(s);try{for(l.s();!(a=l.n()).done;){var c=a.value;n.push(c)}}catch(e){l.e(e)}finally{l.f()}}else n.push(s)}return t.combine(n)}return{create:function(e){var t,n=D(r);try{for(n.s();!(t=n.n()).done;)$g(e,t.value)}catch(e){n.e(e)}finally{n.f()}return e.values[s]=a(e),1},update:function(e,n){if(!Ig(e,o))return 0;var r=a(e);return t.compare(r,e.values[s])?0:(e.values[s]=r,1)},reconfigure:function(e,i){var o=Ig(e,r),l=i.config.facets[t.id],c=i.facet(t);if(l&&!o&&Pg(n,l))return e.values[s]=c,0;var u=a(e);return t.compare(u,c)?(e.values[s]=c,0):(e.values[s]=u,1)}}}(n,t,e)})}};for(var y in s)v();return new e(t,a,f.map(function(e){return e(u)}),u,h,s)}}])}();function $g(e,t){if(1&t)return 2;var n=t>>1,r=e.status[n];if(4==r)throw new Error("Cyclic dependency between fields and/or facets");if(2&r)return r;e.status[n]=4;var i=e.computeSlot(e,e.config.dynamicSlots[n]);return e.status[n]=2|i}function Xg(e,t){return 1&t?e.config.staticValues[t>>1]:e.values[t>>1]}var Jg=Dg.define(),Qg=Dg.define({combine:function(e){return e.some(function(e){return e})},static:!0}),Zg=Dg.define({combine:function(e){return e.length?e[0]:void 0},static:!0}),ev=Dg.define(),tv=Dg.define(),nv=Dg.define(),rv=Dg.define({combine:function(e){return!!e.length&&e[0]}}),iv=function(){return R(function e(t,n){N(this,e),this.type=t,this.value=n},null,[{key:"define",value:function(){return new ov}}])}(),ov=function(){return R(function e(){N(this,e)},[{key:"of",value:function(e){return new iv(this,e)}}])}(),sv=function(){return R(function e(t){N(this,e),this.map=t},[{key:"of",value:function(e){return new av(this,e)}}])}(),av=function(){function e(t,n){N(this,e),this.type=t,this.value=n}return R(e,[{key:"map",value:function(t){var n=this.type.map(this.value,t);return void 0===n?void 0:n==this.value?this:new e(this.type,n)}},{key:"is",value:function(e){return this.type==e}}],[{key:"define",value:function(){return new sv((arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).map||function(e){return e})}},{key:"mapEffects",value:function(e,t){if(!e.length)return e;var n,r=[],i=D(e);try{for(i.s();!(n=i.n()).done;){var o=n.value.map(t);o&&r.push(o)}}catch(e){i.e(e)}finally{i.f()}return r}}])}();av.reconfigure=av.define(),av.appendConfig=av.define();var lv=function(){function e(t,n,r,i,o,s){N(this,e),this.startState=t,this.changes=n,this.selection=r,this.effects=i,this.annotations=o,this.scrollIntoView=s,this._doc=null,this._state=null,r&&Tg(r,n.newLength),o.some(function(t){return t.type==e.time})||(this.annotations=o.concat(e.time.of(Date.now())))}return R(e,[{key:"newDoc",get:function(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}},{key:"newSelection",get:function(){return this.selection||this.startState.selection.map(this.changes)}},{key:"state",get:function(){return this._state||this.startState.applyTransaction(this),this._state}},{key:"annotation",value:function(e){var t,n=D(this.annotations);try{for(n.s();!(t=n.n()).done;){var r=t.value;if(r.type==e)return r.value}}catch(e){n.e(e)}finally{n.f()}}},{key:"docChanged",get:function(){return!this.changes.empty}},{key:"reconfigured",get:function(){return this.startState.config!=this.state.config}},{key:"isUserEvent",value:function(t){var n=this.annotation(e.userEvent);return!(!n||!(n==t||n.length>t.length&&n.slice(0,t.length)==t&&"."==n[t.length]))}}],[{key:"create",value:function(t,n,r,i,o,s){return new e(t,n,r,i,o,s)}}])}();function cv(e,t){for(var n=[],r=0,i=0;;){var o=void 0,s=void 0;if(r<e.length&&(i==t.length||t[i]>=e[r]))o=e[r++],s=e[r++];else{if(!(i<t.length))return n;o=t[i++],s=t[i++]}!n.length||n[n.length-1]<o?n.push(o,s):n[n.length-1]<s&&(n[n.length-1]=s)}}function uv(e,t,n){var r,i,o,s;return n?(i=t.changes,o=kg.empty(t.changes.length),s=e.changes.compose(t.changes)):(i=t.changes.map(e.changes),o=e.changes.mapDesc(t.changes,!0),s=e.changes.compose(i)),{changes:s,selection:t.selection?t.selection.map(o):null===(r=e.selection)||void 0===r?void 0:r.map(i),effects:av.mapEffects(e.effects,i).concat(av.mapEffects(t.effects,o)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function hv(e,t,n){var r=t.selection,i=pv(t.annotations);return t.userEvent&&(i=i.concat(lv.userEvent.of(t.userEvent))),{changes:t.changes instanceof kg?t.changes:kg.of(t.changes||[],n,e.facet(Zg)),selection:r&&(r instanceof Ng?r:Ng.single(r.anchor,r.head)),effects:pv(t.effects),annotations:i,scrollIntoView:!!t.scrollIntoView}}function fv(e,t,n){var r=hv(e,t.length?t[0]:{},e.doc.length);t.length&&!1===t[0].filter&&(n=!1);for(var i=1;i<t.length;i++){!1===t[i].filter&&(n=!1);var o=!!t[i].sequential;r=uv(r,hv(e,t[i],o?r.changes.newLength:e.doc.length),o)}var s=lv.create(e,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return function(e){for(var t=e.startState,n=t.facet(nv),r=e,i=n.length-1;i>=0;i--){var o=n[i](e);o&&Object.keys(o).length&&(r=uv(r,hv(t,o,e.changes.newLength),!0))}return r==e?e:lv.create(t,e.changes,e.selection,r.effects,r.annotations,r.scrollIntoView)}(n?function(e){var t,n=e.startState,r=!0,i=D(n.facet(ev));try{for(i.s();!(t=i.n()).done;){var o=(0,t.value)(e);if(!1===o){r=!1;break}Array.isArray(o)&&(r=!0===r?o:cv(r,o))}}catch(e){i.e(e)}finally{i.f()}if(!0!==r){var s,a;if(!1===r)a=e.changes.invertedDesc,s=kg.empty(n.doc.length);else{var l=e.changes.filter(r);s=l.changes,a=l.filtered.mapDesc(l.changes).invertedDesc}e=lv.create(n,s,e.selection&&e.selection.map(a),av.mapEffects(e.effects,a),e.annotations,e.scrollIntoView)}for(var c=n.facet(tv),u=c.length-1;u>=0;u--){var h=c[u](e);e=h instanceof lv?h:Array.isArray(h)&&1==h.length&&h[0]instanceof lv?h[0]:fv(n,pv(h),!1)}return e}(s):s)}lv.time=iv.define(),lv.userEvent=iv.define(),lv.addToHistory=iv.define(),lv.remote=iv.define();var dv=[];function pv(e){return null==e?dv:Array.isArray(e)?e:[e]}var mv,gv=function(e){return e[e.Word=0]="Word",e[e.Space=1]="Space",e[e.Other=2]="Other",e}(gv||(gv={})),vv=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;try{mv=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(e){}function yv(e){return function(t){if(!/\S/.test(t))return gv.Space;if(function(e){if(mv)return mv.test(e);for(var t=0;t<e.length;t++){var n=e[t];if(/\w/.test(n)||n>"€"&&(n.toUpperCase()!=n.toLowerCase()||vv.test(n)))return!0}return!1}(t))return gv.Word;for(var n=0;n<e.length;n++)if(t.indexOf(e[n])>-1)return gv.Word;return gv.Other}}var bv=function(){function e(t,n,r,i,o,s){N(this,e),this.config=t,this.doc=n,this.selection=r,this.values=i,this.status=t.statusTemplate.slice(),this.computeSlot=o,s&&(s._state=this);for(var a=0;a<this.config.dynamicSlots.length;a++)$g(this,a<<1);this.computeSlot=null}return R(e,[{key:"field",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=this.config.address[e.id];if(null!=n)return $g(this,n),Xg(this,n);if(t)throw new RangeError("Field is not present in this state")}},{key:"update",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return fv(this,t,!0)}},{key:"applyTransaction",value:function(t){var n,r,i=this,o=this.config,s=o,a=s.base,l=s.compartments,c=D(t.effects);try{for(c.s();!(n=c.n()).done;){var u=n.value;u.is(Kg.reconfigure)?(o&&(l=new Map,o.compartments.forEach(function(e,t){return l.set(t,e)}),o=null),l.set(u.value.compartment,u.value.extension)):u.is(av.reconfigure)?(o=null,a=u.value):u.is(av.appendConfig)&&(o=null,a=pv(a).concat(u.value))}}catch(e){c.e(e)}finally{c.f()}if(o)r=t.startState.values.slice();else{var h=new e(o=Yg.resolve(a,l,this),this.doc,this.selection,o.dynamicSlots.map(function(){return null}),function(e,t){return t.reconfigure(e,i)},null);r=h.values}var f=t.startState.facet(Qg)?t.newSelection:t.newSelection.asSingle();new e(o,t.newDoc,f,r,function(e,n){return n.update(e,t)},t)}},{key:"replaceSelection",value:function(e){return"string"==typeof e&&(e=this.toText(e)),this.changeByRange(function(t){return{changes:{from:t.from,to:t.to,insert:e},range:Ng.cursor(t.from+e.length)}})}},{key:"changeByRange",value:function(e){for(var t=this.selection,n=e(t.ranges[0]),r=this.changes(n.changes),i=[n.range],o=pv(n.effects),s=1;s<t.ranges.length;s++){for(var a=e(t.ranges[s]),l=this.changes(a.changes),c=l.map(r),u=0;u<s;u++)i[u]=i[u].map(c);var h=r.mapDesc(l,!0);i.push(a.range.map(h)),r=r.compose(c),o=av.mapEffects(o,c).concat(av.mapEffects(pv(a.effects),h))}return{changes:r,selection:Ng.create(i,t.mainIndex),effects:o}}},{key:"changes",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return t instanceof kg?t:kg.of(t,this.doc.length,this.facet(e.lineSeparator))}},{key:"toText",value:function(t){return ig.of(t.split(this.facet(e.lineSeparator)||yg))}},{key:"sliceDoc",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.doc.length;return this.doc.sliceString(e,t,this.lineBreak)}},{key:"facet",value:function(e){var t=this.config.address[e.id];return null==t?e.default:($g(this,t),Xg(this,t))}},{key:"toJSON",value:function(e){var t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(var n in e){var r=e[n];r instanceof Fg&&null!=this.config.address[r.id]&&(t[n]=r.spec.toJSON(this.field(e[n]),this))}return t}},{key:"tabSize",get:function(){return this.facet(e.tabSize)}},{key:"lineBreak",get:function(){return this.facet(e.lineSeparator)||"\n"}},{key:"readOnly",get:function(){return this.facet(rv)}},{key:"phrase",value:function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];var o,s=D(this.facet(e.phrases));try{for(s.s();!(o=s.n()).done;){var a=o.value;if(Object.prototype.hasOwnProperty.call(a,t)){t=a[t];break}}}catch(e){s.e(e)}finally{s.f()}return r.length&&(t=t.replace(/\$(\$|\d*)/g,function(e,t){if("$"==t)return"$";var n=+(t||1);return!n||n>r.length?e:r[n-1]})),t}},{key:"languageDataAt",value:function(e,t){var n,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1,i=[],o=D(this.facet(Jg));try{for(o.s();!(n=o.n()).done;){var s,a=D((0,n.value)(this,t,r));try{for(a.s();!(s=a.n()).done;){var l=s.value;Object.prototype.hasOwnProperty.call(l,e)&&i.push(l[e])}}catch(e){a.e(e)}finally{a.f()}}}catch(e){o.e(e)}finally{o.f()}return i}},{key:"charCategorizer",value:function(e){var t=this.languageDataAt("wordChars",e);return yv(t.length?t[0]:"")}},{key:"wordAt",value:function(e){for(var t=this.doc.lineAt(e),n=t.text,r=t.from,i=t.length,o=this.charCategorizer(e),s=e-r,a=e-r;s>0;){var l=pg(n,s,!1);if(o(n.slice(l,s))!=gv.Word)break;s=l}for(;a<i;){var c=pg(n,a);if(o(n.slice(a,c))!=gv.Word)break;a=c}return s==a?null:Ng.range(s+r,a+r)}}],[{key:"fromJSON",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2?arguments[2]:void 0;if(!t||"string"!=typeof t.doc)throw new RangeError("Invalid JSON representation for EditorState");var i=[];if(r){var o=function(){if(Object.prototype.hasOwnProperty.call(t,s)){var e=r[s],n=t[s];i.push(e.init(function(t){return e.spec.fromJSON(n,t)}))}};for(var s in r)o()}return e.create({doc:t.doc,selection:Ng.fromJSON(t.selection),extensions:n.extensions?i.concat([n.extensions]):i})}},{key:"create",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=Yg.resolve(t.extensions||[],new Map),r=t.doc instanceof ig?t.doc:ig.of((t.doc||"").split(n.staticFacet(e.lineSeparator)||yg)),i=t.selection?t.selection instanceof Ng?t.selection:Ng.single(t.selection.anchor,t.selection.head):Ng.single(0);return Tg(i,r.length),n.staticFacet(Qg)||(i=i.asSingle()),new e(n,r,i,n.dynamicSlots.map(function(){return null}),function(e,t){return t.create(e)},null)}}])}();function wv(e,t){var n,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i={},o=D(e);try{for(o.s();!(n=o.n()).done;)for(var s=n.value,a=0,l=Object.keys(s);a<l.length;a++){var c=l[a],u=s[c],h=i[c];if(void 0===h)i[c]=u;else if(h===u||void 0===u);else{if(!Object.hasOwnProperty.call(r,c))throw new Error("Config merge conflict for field "+c);i[c]=r[c](h,u)}}}catch(e){o.e(e)}finally{o.f()}for(var f in t)void 0===i[f]&&(i[f]=t[f]);return i}bv.allowMultipleSelections=Qg,bv.tabSize=Dg.define({combine:function(e){return e.length?e[0]:4}}),bv.lineSeparator=Zg,bv.readOnly=rv,bv.phrases=Dg.define({compare:function(e,t){var n=Object.keys(e),r=Object.keys(t);return n.length==r.length&&n.every(function(n){return e[n]==t[n]})}}),bv.languageData=Jg,bv.changeFilter=ev,bv.transactionFilter=tv,bv.transactionExtender=nv,Kg.reconfigure=av.define();var kv=function(){return R(function e(){N(this,e)},[{key:"eq",value:function(e){return this==e}},{key:"range",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e;return Sv.create(e,t,this)}}])}();function xv(e,t){return e==t||e.constructor==t.constructor&&e.eq(t)}kv.prototype.startSide=kv.prototype.endSide=0,kv.prototype.point=!1,kv.prototype.mapMode=bg.TrackDel;var Sv=function(){function e(t,n,r){N(this,e),this.from=t,this.to=n,this.value=r}return R(e,null,[{key:"create",value:function(t,n,r){return new e(t,n,r)}}])}();function Cv(e,t){return e.from-t.from||e.value.startSide-t.value.startSide}var Ev=function(){function e(t,n,r,i){N(this,e),this.from=t,this.to=n,this.value=r,this.maxPoint=i}return R(e,[{key:"length",get:function(){return this.to[this.to.length-1]}},{key:"findIndex",value:function(e,t,n){for(var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=n?this.to:this.from,o=r,s=i.length;;){if(o==s)return o;var a=o+s>>1,l=i[a]-e||(n?this.value[a].endSide:this.value[a].startSide)-t;if(a==o)return l>=0?o:s;l>=0?s=a:o=a+1}}},{key:"between",value:function(e,t,n,r){for(var i=this.findIndex(t,-1e9,!0),o=this.findIndex(n,1e9,!1,i);i<o;i++)if(!1===r(this.from[i]+e,this.to[i]+e,this.value[i]))return!1}},{key:"map",value:function(t,n){for(var r=[],i=[],o=[],s=-1,a=-1,l=0;l<this.value.length;l++){var c=this.value[l],u=this.from[l]+t,h=this.to[l]+t,f=void 0,d=void 0;if(u==h){var p=n.mapPos(u,c.startSide,c.mapMode);if(null==p)continue;if(f=d=p,c.startSide!=c.endSide&&(d=n.mapPos(u,c.endSide))<f)continue}else if((f=n.mapPos(u,c.startSide))>(d=n.mapPos(h,c.endSide))||f==d&&c.startSide>0&&c.endSide<=0)continue;(d-f||c.endSide-c.startSide)<0||(s<0&&(s=f),c.point&&(a=Math.max(a,d-f)),r.push(c),i.push(f-s),o.push(d-s))}return{mapped:r.length?new e(i,o,r,a):null,pos:s}}}])}(),Av=function(){function e(t,n,r,i){N(this,e),this.chunkPos=t,this.chunk=n,this.nextLayer=r,this.maxPoint=i}return R(e,[{key:"length",get:function(){var e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}},{key:"size",get:function(){if(this.isEmpty)return 0;var e,t=this.nextLayer.size,n=D(this.chunk);try{for(n.s();!(e=n.n()).done;){t+=e.value.value.length}}catch(e){n.e(e)}finally{n.f()}return t}},{key:"chunkEnd",value:function(e){return this.chunkPos[e]+this.chunk[e].length}},{key:"update",value:function(t){var n=t.add,r=void 0===n?[]:n,i=t.sort,o=void 0!==i&&i,s=t.filterFrom,a=void 0===s?0:s,l=t.filterTo,c=void 0===l?this.length:l,u=t.filter;if(0==r.length&&!u)return this;if(o&&(r=r.slice().sort(Cv)),this.isEmpty)return r.length?e.of(r):this;for(var h=new Nv(this,null,-1).goto(0),f=0,d=[],p=new Mv;h.value||f<r.length;)if(f<r.length&&(h.from-r[f].from||h.startSide-r[f].value.startSide)>=0){var m=r[f++];p.addInner(m.from,m.to,m.value)||d.push(m)}else 1==h.rangeIndex&&h.chunkIndex<this.chunk.length&&(f==r.length||this.chunkEnd(h.chunkIndex)<r[f].from)&&(!u||a>this.chunkEnd(h.chunkIndex)||c<this.chunkPos[h.chunkIndex])&&p.addChunk(this.chunkPos[h.chunkIndex],this.chunk[h.chunkIndex])?h.nextChunk():((!u||a>h.to||c<h.from||u(h.from,h.to,h.value))&&(p.addInner(h.from,h.to,h.value)||d.push(Sv.create(h.from,h.to,h.value))),h.next());return p.finishInner(this.nextLayer.isEmpty&&!d.length?e.empty:this.nextLayer.update({add:d,filter:u,filterFrom:a,filterTo:c}))}},{key:"map",value:function(t){if(t.empty||this.isEmpty)return this;for(var n=[],r=[],i=-1,o=0;o<this.chunk.length;o++){var s=this.chunkPos[o],a=this.chunk[o],l=t.touchesRange(s,s+a.length);if(!1===l)i=Math.max(i,a.maxPoint),n.push(a),r.push(t.mapPos(s));else if(!0===l){var c=a.map(s,t),u=c.mapped,h=c.pos;u&&(i=Math.max(i,u.maxPoint),n.push(u),r.push(h))}}var f=this.nextLayer.map(t);return 0==n.length?f:new e(r,n,f||e.empty,i)}},{key:"between",value:function(e,t,n){if(!this.isEmpty){for(var r=0;r<this.chunk.length;r++){var i=this.chunkPos[r],o=this.chunk[r];if(t>=i&&e<=i+o.length&&!1===o.between(i,e-i,t-i,n))return}this.nextLayer.between(e,t,n)}}},{key:"iter",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return Tv.from([this]).goto(e)}},{key:"isEmpty",get:function(){return this.nextLayer==this}}],[{key:"create",value:function(t,n,r,i){return new e(t,n,r,i)}},{key:"iter",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return Tv.from(e).goto(t)}},{key:"compare",value:function(e,t,n,r){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:-1,o=e.filter(function(e){return e.maxPoint>0||!e.isEmpty&&e.maxPoint>=i}),s=t.filter(function(e){return e.maxPoint>0||!e.isEmpty&&e.maxPoint>=i}),a=Ov(o,s,n),l=new Dv(o,a,i),c=new Dv(s,a,i);n.iterGaps(function(e,t,n){return Pv(l,e,c,t,n,r)}),n.empty&&0==n.length&&Pv(l,0,c,0,0,r)}},{key:"eq",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3?arguments[3]:void 0;null==r&&(r=999999999);var i=e.filter(function(e){return!e.isEmpty&&t.indexOf(e)<0}),o=t.filter(function(t){return!t.isEmpty&&e.indexOf(t)<0});if(i.length!=o.length)return!1;if(!i.length)return!0;for(var s=Ov(i,o),a=new Dv(i,s,0).goto(n),l=new Dv(o,s,0).goto(n);;){if(a.to!=l.to||!Lv(a.active,l.active)||a.point&&(!l.point||!xv(a.point,l.point)))return!1;if(a.to>r)return!0;a.next(),l.next()}}},{key:"spans",value:function(e,t,n,r){for(var i=new Dv(e,null,arguments.length>4&&void 0!==arguments[4]?arguments[4]:-1).goto(t),o=t,s=i.openStart;;){var a=Math.min(i.to,n);if(i.point){var l=i.activeForPoint(i.to),c=i.pointFrom<t?l.length+1:i.point.startSide<0?l.length:Math.min(l.length,s);r.point(o,a,i.point,l,c,i.pointRank),s=Math.min(i.openEnd(a),l.length)}else a>o&&(r.span(o,a,i.active,s),s=i.openEnd(a));if(i.to>n)return s+(i.point&&i.to>n?1:0);o=i.to,i.next()}}},{key:"of",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=new Mv,i=D(e instanceof Sv?[e]:n?function(e){if(e.length>1)for(var t=e[0],n=1;n<e.length;n++){var r=e[n];if(Cv(t,r)>0)return e.slice().sort(Cv);t=r}return e}(e):e);try{for(i.s();!(t=i.n()).done;){var o=t.value;r.add(o.from,o.to,o.value)}}catch(e){i.e(e)}finally{i.f()}return r.finish()}},{key:"join",value:function(t){if(!t.length)return e.empty;for(var n=t[t.length-1],r=t.length-2;r>=0;r--)for(var i=t[r];i!=e.empty;i=i.nextLayer)n=new e(i.chunkPos,i.chunk,n,Math.max(i.maxPoint,n.maxPoint));return n}}])}();Av.empty=new Av([],[],null,-1),Av.empty.nextLayer=Av.empty;var Mv=function(){function e(){N(this,e),this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}return R(e,[{key:"finishChunk",value:function(e){this.chunks.push(new Ev(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}},{key:"add",value:function(t,n,r){this.addInner(t,n,r)||(this.nextLayer||(this.nextLayer=new e)).add(t,n,r)}},{key:"addInner",value:function(e,t,n){var r=e-this.lastTo||n.startSide-this.last.endSide;if(r<=0&&(e-this.lastFrom||n.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return!(r<0)&&(250==this.from.length&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=n,this.lastFrom=e,this.lastTo=t,this.value.push(n),n.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}},{key:"addChunk",value:function(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);var n=t.value.length-1;return this.last=t.value[n],this.lastFrom=t.from[n]+e,this.lastTo=t.to[n]+e,!0}},{key:"finish",value:function(){return this.finishInner(Av.empty)}},{key:"finishInner",value:function(e){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return e;var t=Av.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}])}();function Ov(e,t,n){var r,i=new Map,o=D(e);try{for(o.s();!(r=o.n()).done;)for(var s=r.value,a=0;a<s.chunk.length;a++)s.chunk[a].maxPoint<=0&&i.set(s.chunk[a],s.chunkPos[a])}catch(e){o.e(e)}finally{o.f()}var l,c=new Set,u=D(t);try{for(u.s();!(l=u.n()).done;)for(var h=l.value,f=0;f<h.chunk.length;f++){var d=i.get(h.chunk[f]);null==d||(n?n.mapPos(d):d)!=h.chunkPos[f]||(null==n?void 0:n.touchesRange(d,d+h.chunk[f].length))||c.add(h.chunk[f])}}catch(e){u.e(e)}finally{u.f()}return c}var Nv=function(){return R(function e(t,n,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;N(this,e),this.layer=t,this.skip=n,this.minPoint=r,this.rank=i},[{key:"startSide",get:function(){return this.value?this.value.startSide:0}},{key:"endSide",get:function(){return this.value?this.value.endSide:0}},{key:"goto",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1e9;return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}},{key:"gotoInner",value:function(e,t,n){for(;this.chunkIndex<this.layer.chunk.length;){var r=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(r)||this.layer.chunkEnd(this.chunkIndex)<e||r.maxPoint<this.minPoint))break;this.chunkIndex++,n=!1}if(this.chunkIndex<this.layer.chunk.length){var i=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!n||this.rangeIndex<i)&&this.setRangeIndex(i)}this.next()}},{key:"forward",value:function(e,t){(this.to-e||this.endSide-t)<0&&this.gotoInner(e,t,!0)}},{key:"next",value:function(){for(;;){if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}var e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],n=e+t.from[this.rangeIndex];if(this.from=n,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}},{key:"setRangeIndex",value:function(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}},{key:"nextChunk",value:function(){this.chunkIndex++,this.rangeIndex=0,this.next()}},{key:"compare",value:function(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}}])}(),Tv=function(){function e(t){N(this,e),this.heap=t}return R(e,[{key:"startSide",get:function(){return this.value?this.value.startSide:0}},{key:"goto",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1e9,r=D(this.heap);try{for(r.s();!(t=r.n()).done;){t.value.goto(e,n)}}catch(e){r.e(e)}finally{r.f()}for(var i=this.heap.length>>1;i>=0;i--)Rv(this.heap,i);return this.next(),this}},{key:"forward",value:function(e,t){var n,r=D(this.heap);try{for(r.s();!(n=r.n()).done;){n.value.forward(e,t)}}catch(e){r.e(e)}finally{r.f()}for(var i=this.heap.length>>1;i>=0;i--)Rv(this.heap,i);(this.to-e||this.value.endSide-t)<0&&this.next()}},{key:"next",value:function(){if(0==this.heap.length)this.from=this.to=1e9,this.value=null,this.rank=-1;else{var e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),Rv(this.heap,0)}}}],[{key:"from",value:function(t){for(var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1,i=[],o=0;o<t.length;o++)for(var s=t[o];!s.isEmpty;s=s.nextLayer)s.maxPoint>=r&&i.push(new Nv(s,n,r,o));return 1==i.length?i[0]:new e(i)}}])}();function Rv(e,t){for(var n=e[t];;){var r=1+(t<<1);if(r>=e.length)break;var i=e[r];if(r+1<e.length&&i.compare(e[r+1])>=0&&(i=e[r+1],r++),n.compare(i)<0)break;e[r]=n,e[t]=i,t=r}}var Dv=function(){return R(function e(t,n,r){N(this,e),this.minPoint=r,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Tv.from(t,n,r)},[{key:"goto",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1e9;return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}},{key:"forward",value:function(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}},{key:"removeActive",value:function(e){Bv(this.active,e),Bv(this.activeTo,e),Bv(this.activeRank,e),this.minActive=_v(this.active,this.activeTo)}},{key:"addActive",value:function(e){for(var t=0,n=this.cursor,r=n.value,i=n.to,o=n.rank;t<this.activeRank.length&&(o-this.activeRank[t]||i-this.activeTo[t])>0;)t++;Iv(this.active,t,r),Iv(this.activeTo,t,i),Iv(this.activeRank,t,o),e&&Iv(e,t,this.cursor.from),this.minActive=_v(this.active,this.activeTo)}},{key:"next",value:function(){var e=this.to,t=this.point;this.point=null;for(var n=this.openStart<0?[]:null;;){var r=this.minActive;if(r>-1&&(this.activeTo[r]-this.cursor.from||this.active[r].endSide-this.cursor.startSide)<0){if(this.activeTo[r]>e){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),n&&Bv(n,r)}else{if(!this.cursor.value){this.to=this.endSide=1e9;break}if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}var i=this.cursor.value;if(i.point){if(!(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)){this.point=i,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=i.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}this.cursor.next()}else this.addActive(n),this.cursor.next()}}if(n){this.openStart=0;for(var o=n.length-1;o>=0&&n[o]<e;o--)this.openStart++}}},{key:"activeForPoint",value:function(e){if(!this.active.length)return this.active;for(var t=[],n=this.active.length-1;n>=0&&!(this.activeRank[n]<this.pointRank);n--)(this.activeTo[n]>e||this.activeTo[n]==e&&this.active[n].endSide>=this.point.endSide)&&t.push(this.active[n]);return t.reverse()}},{key:"openEnd",value:function(e){for(var t=0,n=this.activeTo.length-1;n>=0&&this.activeTo[n]>e;n--)t++;return t}}])}();function Pv(e,t,n,r,i,o){e.goto(t),n.goto(r);for(var s=r+i,a=r,l=r-t,c=!!o.boundChange,u=!1;;){var h=e.to+l-n.to,f=h||e.endSide-n.endSide,d=f<0?e.to+l:n.to,p=Math.min(d,s);if(e.point||n.point?(e.point&&n.point&&xv(e.point,n.point)&&Lv(e.activeForPoint(e.to),n.activeForPoint(n.to))||o.comparePoint(a,p,e.point,n.point),u=!1):(u&&o.boundChange(a),p>a&&!Lv(e.active,n.active)&&o.compareRange(a,p,e.active,n.active),c&&p<s&&(h||e.openEnd(d)!=n.openEnd(d))&&(u=!0)),d>s)break;a=d,f<=0&&e.next(),f>=0&&n.next()}}function Lv(e,t){if(e.length!=t.length)return!1;for(var n=0;n<e.length;n++)if(e[n]!=t[n]&&!xv(e[n],t[n]))return!1;return!0}function Bv(e,t){for(var n=t,r=e.length-1;n<r;n++)e[n]=e[n+1];e.pop()}function Iv(e,t,n){for(var r=e.length-1;r>=t;r--)e[r+1]=e[r];e[t]=n}function _v(e,t){for(var n=-1,r=1e9,i=0;i<t.length;i++)(t[i]-r||e[i].endSide-e[n].endSide)<0&&(n=i,r=t[i]);return n}function Fv(e,t){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.length,r=0,i=0;i<n&&i<e.length;)9==e.charCodeAt(i)?(r+=t-r%t,i++):(r++,i=pg(e,i));return r}function Wv(e,t,n,r){for(var i=0,o=0;;){if(o>=t)return i;if(i==e.length)break;o+=9==e.charCodeAt(i)?n-o%n:1,i=pg(e,i)}return!0===r?-1:e.length}for(var jv="undefined"==typeof Symbol?"__ͼ":Symbol.for("ͼ"),Hv="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),zv="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{},Vv=function(){return R(function e(t,n){N(this,e),this.rules=[];var r=(n||{}).finish;function i(e){return/^@/.test(e)?[e]:e.split(/,\s*/)}function o(e,t,n,s){var a=[],l=/^@(\w+)\b/.exec(e[0]),c=l&&"keyframes"==l[1];if(l&&null==t)return n.push(e[0]+";");for(var u in t){var h=t[u];if(/&/.test(u))o(u.split(/,\s*/).map(function(t){return e.map(function(e){return t.replace(/&/,e)})}).reduce(function(e,t){return e.concat(t)}),h,n);else if(h&&"object"==Y(h)){if(!l)throw new RangeError("The value of a property ("+u+") should be a primitive value.");o(i(u),h,a,c)}else null!=h&&a.push(u.replace(/_.*/,"").replace(/[A-Z]/g,function(e){return"-"+e.toLowerCase()})+": "+h+";")}(a.length||c)&&n.push((!r||l||s?e:e.map(r)).join(", ")+" {"+a.join(" ")+"}")}for(var s in t)o(i(s),t[s],this.rules)},[{key:"getRules",value:function(){return this.rules.join("\n")}}],[{key:"newName",value:function(){var e=zv[jv]||1;return zv[jv]=e+1,"ͼ"+e.toString(36)}},{key:"mount",value:function(e,t,n){var r=e[Hv],i=n&&n.nonce;r?i&&r.setNonce(i):r=new Uv(e,i),r.mount(Array.isArray(t)?t:[t],e)}}])}(),qv=new Map,Uv=function(){return R(function e(t,n){N(this,e);var r=t.ownerDocument||t,i=r.defaultView;if(!t.head&&t.adoptedStyleSheets&&i.CSSStyleSheet){var o=qv.get(r);if(o)return t[Hv]=o;this.sheet=new i.CSSStyleSheet,qv.set(r,this)}else this.styleTag=r.createElement("style"),n&&this.styleTag.setAttribute("nonce",n);this.modules=[],t[Hv]=this},[{key:"mount",value:function(e,t){for(var n=this.sheet,r=0,i=0,o=0;o<e.length;o++){var s=e[o],a=this.modules.indexOf(s);if(a<i&&a>-1&&(this.modules.splice(a,1),i--,a=-1),-1==a){if(this.modules.splice(i++,0,s),n)for(var l=0;l<s.rules.length;l++)n.insertRule(s.rules[l],r++)}else{for(;i<a;)r+=this.modules[i++].rules.length;r+=s.rules.length,i++}}if(n)t.adoptedStyleSheets.indexOf(this.sheet)<0&&(t.adoptedStyleSheets=[this.sheet].concat(K(t.adoptedStyleSheets)));else{for(var c="",u=0;u<this.modules.length;u++)c+=this.modules[u].getRules()+"\n";this.styleTag.textContent=c;var h=t.head||t;this.styleTag.parentNode!=h&&h.insertBefore(this.styleTag,h.firstChild)}}},{key:"setNonce",value:function(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}}])}(),Kv={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Gv={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Yv="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),$v="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Xv=0;Xv<10;Xv++)Kv[48+Xv]=Kv[96+Xv]=String(Xv);for(Xv=1;Xv<=24;Xv++)Kv[Xv+111]="F"+Xv;for(Xv=65;Xv<=90;Xv++)Kv[Xv]=String.fromCharCode(Xv+32),Gv[Xv]=String.fromCharCode(Xv);for(var Jv in Kv)Gv.hasOwnProperty(Jv)||(Gv[Jv]=Kv[Jv]);function Qv(){var e=arguments[0];"string"==typeof e&&(e=document.createElement(e));var t=1,n=arguments[1];if(n&&"object"==Y(n)&&null==n.nodeType&&!Array.isArray(n)){for(var r in n)if(Object.prototype.hasOwnProperty.call(n,r)){var i=n[r];"string"==typeof i?e.setAttribute(r,i):null!=i&&(e[r]=i)}t++}for(;t<arguments.length;t++)Zv(e,arguments[t]);return e}function Zv(e,t){if("string"==typeof t)e.appendChild(document.createTextNode(t));else if(null==t);else if(null!=t.nodeType)e.appendChild(t);else{if(!Array.isArray(t))throw new RangeError("Unsupported child node: "+t);for(var n=0;n<t.length;n++)Zv(e,t[n])}}var ey="undefined"!=typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},ty="undefined"!=typeof document?document:{documentElement:{style:{}}},ny=/Edge\/(\d+)/.exec(ey.userAgent),ry=/MSIE \d/.test(ey.userAgent),iy=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ey.userAgent),oy=!!(ry||iy||ny),sy=!oy&&/gecko\/(\d+)/i.test(ey.userAgent),ay=!oy&&/Chrome\/(\d+)/.exec(ey.userAgent),ly="webkitFontSmoothing"in ty.documentElement.style,cy=!oy&&/Apple Computer/.test(ey.vendor),uy=cy&&(/Mobile\/\w+/.test(ey.userAgent)||ey.maxTouchPoints>2),hy={mac:uy||/Mac/.test(ey.platform),windows:/Win/.test(ey.platform),linux:/Linux|X11/.test(ey.platform),ie:oy,ie_version:ry?ty.documentMode||6:iy?+iy[1]:ny?+ny[1]:0,gecko:sy,gecko_version:sy?+(/Firefox\/(\d+)/.exec(ey.userAgent)||[0,0])[1]:0,chrome:!!ay,chrome_version:ay?+ay[1]:0,ios:uy,android:/Android\b/.test(ey.userAgent),webkit:ly,webkit_version:ly?+(/\bAppleWebKit\/(\d+)/.exec(ey.userAgent)||[0,0])[1]:0,safari:cy,safari_version:cy?+(/\bVersion\/(\d+(\.\d+)?)/.exec(ey.userAgent)||[0,0])[1]:0,tabSize:null!=ty.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};function fy(e,t){for(var n in e)"class"==n&&t.class?t.class+=" "+e.class:"style"==n&&t.style?t.style+=";"+e.style:t[n]=e[n];return t}var dy=Object.create(null);function py(e,t,n){if(e==t)return!0;e||(e=dy),t||(t=dy);var r=Object.keys(e),i=Object.keys(t);if(r.length-(n&&r.indexOf(n)>-1?1:0)!=i.length-(n&&i.indexOf(n)>-1?1:0))return!1;for(var o=0,s=r;o<s.length;o++){var a=s[o];if(a!=n&&(-1==i.indexOf(a)||e[a]!==t[a]))return!1}return!0}function my(e,t,n){var r=!1;if(t)for(var i in t)n&&i in n||(r=!0,"style"==i?e.style.cssText="":e.removeAttribute(i));if(n)for(var o in n)t&&t[o]==n[o]||(r=!0,"style"==o?e.style.cssText=n[o]:e.setAttribute(o,n[o]));return r}function gy(e){for(var t=Object.create(null),n=0;n<e.attributes.length;n++){var r=e.attributes[n];t[r.name]=r.value}return t}var vy=function(){return R(function e(){N(this,e)},[{key:"eq",value:function(e){return!1}},{key:"updateDOM",value:function(e,t){return!1}},{key:"compare",value:function(e){return this==e||this.constructor==e.constructor&&this.eq(e)}},{key:"estimatedHeight",get:function(){return-1}},{key:"lineBreaks",get:function(){return 0}},{key:"ignoreEvent",value:function(e){return!0}},{key:"coordsAt",value:function(e,t,n){return null}},{key:"isHidden",get:function(){return!1}},{key:"editable",get:function(){return!1}},{key:"destroy",value:function(e){}}])}(),yy=function(e){return e[e.Text=0]="Text",e[e.WidgetBefore=1]="WidgetBefore",e[e.WidgetAfter=2]="WidgetAfter",e[e.WidgetRange=3]="WidgetRange",e}(yy||(yy={})),by=function(){function e(t,n,r,i){var o;return N(this,e),(o=O(this,e)).startSide=t,o.endSide=n,o.widget=r,o.spec=i,o}return I(e,kv),R(e,[{key:"heightRelevant",get:function(){return!1}},{key:"hasHeight",value:function(){return!!this.widget&&this.widget.estimatedHeight>-1}}],[{key:"mark",value:function(e){return new wy(e)}},{key:"widget",value:function(e){var t=Math.max(-1e4,Math.min(1e4,e.side||0)),n=!!e.block;return t+=n&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new xy(e,t,t,n,e.widget||null,!1)}},{key:"replace",value:function(e){var t,n,r=!!e.block;if(e.isBlockGap)t=-5e8,n=4e8;else{var i=Sy(e,r);t=(i.start?r?-3e8:-1:5e8)-1,n=1+(i.end?r?2e8:1:-6e8)}return new xy(e,t,n,r,e.widget||null,!0)}},{key:"line",value:function(e){return new ky(e)}},{key:"set",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Av.of(e,t)}}])}();by.none=Av.empty;var wy=function(){function e(t){var n;N(this,e);var r=Sy(t);return(n=O(this,e,[r.start?-1:5e8,r.end?1:-6e8,null,t])).tagName=t.tagName||"span",n.attrs=t.class&&t.attributes?fy(t.attributes,{class:t.class}):t.class?{class:t.class}:t.attributes||dy,n}return I(e,by),R(e,[{key:"eq",value:function(t){return this==t||t instanceof e&&this.tagName==t.tagName&&py(this.attrs,t.attrs)}},{key:"range",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t;if(t>=n)throw new RangeError("Mark decorations may not be empty");return U(e,"range",this,3)([t,n])}}])}();wy.prototype.point=!1;var ky=function(){function e(t){return N(this,e),O(this,e,[-2e8,-2e8,null,t])}return I(e,by),R(e,[{key:"eq",value:function(t){return t instanceof e&&this.spec.class==t.spec.class&&py(this.spec.attributes,t.spec.attributes)}},{key:"range",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t;if(n!=t)throw new RangeError("Line decoration ranges must be zero-length");return U(e,"range",this,3)([t,n])}}])}();ky.prototype.mapMode=bg.TrackBefore,ky.prototype.point=!0;var xy=function(){function e(t,n,r,i,o,s){var a;return N(this,e),(a=O(this,e,[n,r,o,t])).block=i,a.isReplace=s,a.mapMode=i?n<=0?bg.TrackBefore:bg.TrackAfter:bg.TrackDel,a}return I(e,by),R(e,[{key:"type",get:function(){return this.startSide!=this.endSide?yy.WidgetRange:this.startSide<=0?yy.WidgetBefore:yy.WidgetAfter}},{key:"heightRelevant",get:function(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}},{key:"eq",value:function(t){return t instanceof e&&(n=this.widget,r=t.widget,n==r||!!(n&&r&&n.compare(r)))&&this.block==t.block&&this.startSide==t.startSide&&this.endSide==t.endSide;var n,r}},{key:"range",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t;if(this.isReplace&&(t>n||t==n&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&n!=t)throw new RangeError("Widget decorations can only have zero-length ranges");return U(e,"range",this,3)([t,n])}}])}();function Sy(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=e.inclusiveStart,r=e.inclusiveEnd;return null==n&&(n=e.inclusive),null==r&&(r=e.inclusive),{start:null!=n?n:t,end:null!=r?r:t}}function Cy(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=n.length-1;i>=0&&n[i]+r>=e?n[i]=Math.max(n[i],t):n.push(e,t)}xy.prototype.point=!0;var Ey=function(){function e(t,n){var r;return N(this,e),(r=O(this,e)).tagName=t,r.attributes=n,r}return I(e,kv),R(e,[{key:"eq",value:function(t){return t==this||t instanceof e&&this.tagName==t.tagName&&py(this.attributes,t.attributes)}}],[{key:"create",value:function(t){return new e(t.tagName,t.attributes||dy)}},{key:"set",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Av.of(e,t)}}])}();function Ay(e){return(11==e.nodeType?e.getSelection?e:e.ownerDocument:e).getSelection()}function My(e,t){return!!t&&(e==t||e.contains(1!=t.nodeType?t.parentNode:t))}function Oy(e,t){if(!t.anchorNode)return!1;try{return My(e,t.anchorNode)}catch(e){return!1}}function Ny(e){return 3==e.nodeType?zy(e,0,e.nodeValue.length).getClientRects():1==e.nodeType?e.getClientRects():[]}function Ty(e,t,n,r){return!!n&&(Py(e,t,n,r,-1)||Py(e,t,n,r,1))}function Ry(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t}function Dy(e){return 1==e.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(e.nodeName)}function Py(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:Ly(e))){if("DIV"==e.nodeName)return!1;var o=e.parentNode;if(!o||1!=o.nodeType)return!1;t=Ry(e)+(i<0?0:1),e=o}else{if(1!=e.nodeType)return!1;if(1==(e=e.childNodes[t+(i<0?-1:0)]).nodeType&&"false"==e.contentEditable)return!1;t=i<0?Ly(e):0}}}function Ly(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function By(e,t){var n=t?e.left:e.right;return{left:n,right:n,top:e.top,bottom:e.bottom}}function Iy(e){var t=e.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.innerWidth,top:0,bottom:e.innerHeight}}function _y(e,t){var n=t.width/e.offsetWidth,r=t.height/e.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(t.width-e.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(t.height-e.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}Ey.prototype.startSide=Ey.prototype.endSide=-1;var Fy,Wy=function(){return R(function e(){N(this,e),this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0},[{key:"eq",value:function(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}},{key:"setRange",value:function(e){var t=e.anchorNode,n=e.focusNode;this.set(t,Math.min(e.anchorOffset,t?Ly(t):0),n,Math.min(e.focusOffset,n?Ly(n):0))}},{key:"set",value:function(e,t,n,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=r}}])}(),jy=null;function Hy(e){if(e.setActive)return e.setActive();if(jy)return e.focus(jy);for(var t=[],n=e;n&&(t.push(n,n.scrollTop,n.scrollLeft),n!=n.ownerDocument);n=n.parentNode);if(e.focus(null==jy?{get preventScroll(){return jy={preventScroll:!0},!0}}:void 0),!jy){jy=!1;for(var r=0;r<t.length;){var i=t[r++],o=t[r++],s=t[r++];i.scrollTop!=o&&(i.scrollTop=o),i.scrollLeft!=s&&(i.scrollLeft=s)}}}function zy(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t,r=Fy||(Fy=document.createRange());return r.setEnd(e,n),r.setStart(e,t),r}function Vy(e,t,n,r){var i={key:t,code:t,keyCode:n,which:n,cancelable:!0};r&&(i.altKey=r.altKey,i.ctrlKey=r.ctrlKey,i.shiftKey=r.shiftKey,i.metaKey=r.metaKey);var o=new KeyboardEvent("keydown",i);o.synthetic=!0,e.dispatchEvent(o);var s=new KeyboardEvent("keyup",i);return s.synthetic=!0,e.dispatchEvent(s),o.defaultPrevented||s.defaultPrevented}function qy(e){return e.scrollTop>Math.max(1,e.scrollHeight-e.clientHeight-4)}function Uy(e,t){for(var n=e,r=t;;){if(3==n.nodeType&&r>0)return{node:n,offset:r};if(1==n.nodeType&&r>0){if("false"==n.contentEditable)return null;r=Ly(n=n.childNodes[r-1])}else{if(!n.parentNode||Dy(n))return null;r=Ry(n),n=n.parentNode}}}function Ky(e,t){for(var n=e,r=t;;){if(3==n.nodeType&&r<n.nodeValue.length)return{node:n,offset:r};if(1==n.nodeType&&r<n.childNodes.length){if("false"==n.contentEditable)return null;n=n.childNodes[r],r=0}else{if(!n.parentNode||Dy(n))return null;r=Ry(n)+1,n=n.parentNode}}}hy.safari&&hy.safari_version>=26&&(jy=!1);var Gy=function(){function e(t,n){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];N(this,e),this.node=t,this.offset=n,this.precise=r}return R(e,null,[{key:"before",value:function(t,n){return new e(t.parentNode,Ry(t),n)}},{key:"after",value:function(t,n){return new e(t.parentNode,Ry(t)+1,n)}}])}(),Yy=function(e){return e[e.LTR=0]="LTR",e[e.RTL=1]="RTL",e}(Yy||(Yy={})),$y=Yy.LTR,Xy=Yy.RTL;function Jy(e){for(var t=[],n=0;n<e.length;n++)t.push(1<<+e[n]);return t}for(var Qy=Jy("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),Zy=Jy("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),eb=Object.create(null),tb=[],nb=0,rb=["()","[]","{}"];nb<rb.length;nb++){var ib=rb[nb],ob=ib.charCodeAt(0),sb=ib.charCodeAt(1);eb[ob]=sb,eb[sb]=-ob}function ab(e){return e<=247?Qy[e]:1424<=e&&e<=1524?2:1536<=e&&e<=1785?Zy[e-1536]:1774<=e&&e<=2220?4:8192<=e&&e<=8204?256:64336<=e&&e<=65023?4:1}var lb=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/,cb=function(){return R(function e(t,n,r){N(this,e),this.from=t,this.to=n,this.level=r},[{key:"dir",get:function(){return this.level%2?Xy:$y}},{key:"side",value:function(e,t){return this.dir==t==e?this.to:this.from}},{key:"forward",value:function(e,t){return e==(this.dir==t)}}],[{key:"find",value:function(e,t,n,r){for(var i=-1,o=0;o<e.length;o++){var s=e[o];if(s.from<=t&&s.to>=t){if(s.level==n)return o;(i<0||(0!=r?r<0?s.from<t:s.to>t:e[i].level>s.level))&&(i=o)}}if(i<0)throw new RangeError("Index out of range");return i}}])}();function ub(e,t){if(e.length!=t.length)return!1;for(var n=0;n<e.length;n++){var r=e[n],i=t[n];if(r.from!=i.from||r.to!=i.to||r.direction!=i.direction||!ub(r.inner,i.inner))return!1}return!0}var hb=[];function fb(e,t,n,r,i,o,s){var a=r%2?2:1;if(r%2==i%2)for(var l=t,c=0;l<n;){var u=!0,h=!1;if(c==o.length||l<o[c].from){var f=hb[l];f!=a&&(u=!1,h=16==f)}var d=u||1!=a?null:[],p=u?r:r+1,m=l;e:for(;;)if(c<o.length&&m==o[c].from){if(h)break e;var g=o[c];if(!u)for(var v=g.to,y=c+1;;){if(v==n)break e;if(!(y<o.length&&o[y].from==v)){if(hb[v]==a)break e;break}v=o[y++].to}if(c++,d)d.push(g);else g.from>l&&s.push(new cb(l,g.from,p)),db(e,g.direction==$y!=!(p%2)?r+1:r,i,g.inner,g.from,g.to,s),l=g.to;m=g.to}else{if(m==n||(u?hb[m]!=a:hb[m]==a))break;m++}d?fb(e,l,m,r+1,i,d,s):l<m&&s.push(new cb(l,m,p)),l=m}else for(var b=n,w=o.length;b>t;){var k=!0,x=!1;if(!w||b>o[w-1].to){var S=hb[b-1];S!=a&&(k=!1,x=16==S)}var C=k||1!=a?null:[],E=k?r:r+1,A=b;e:for(;;)if(w&&A==o[w-1].to){if(x)break e;var M=o[--w];if(!k)for(var O=M.from,N=w;;){if(O==t)break e;if(!N||o[N-1].to!=O){if(hb[O-1]==a)break e;break}O=o[--N].from}if(C)C.push(M);else M.to<b&&s.push(new cb(M.to,b,E)),db(e,M.direction==$y!=!(E%2)?r+1:r,i,M.inner,M.from,M.to,s),b=M.from;A=M.from}else{if(A==t||(k?hb[A-1]!=a:hb[A-1]==a))break;A--}C?fb(e,A,b,r+1,i,C,s):A<b&&s.push(new cb(A,b,E)),b=A}}function db(e,t,n,r,i,o,s){var a=t%2?2:1;!function(e,t,n,r,i){for(var o=0;o<=r.length;o++){for(var s=o?r[o-1].to:t,a=o<r.length?r[o].from:n,l=o?256:i,c=s,u=l,h=l;c<a;c++){var f=ab(e.charCodeAt(c));512==f?f=u:8==f&&4==h&&(f=16),hb[c]=4==f?2:f,7&f&&(h=f),u=f}for(var d=s,p=l,m=l;d<a;d++){var g=hb[d];if(128==g)d<a-1&&p==hb[d+1]&&24&p?g=hb[d]=p:hb[d]=256;else if(64==g){for(var v=d+1;v<a&&64==hb[v];)v++;for(var y=d&&8==p||v<n&&8==hb[v]?1==m?1:8:256,b=d;b<v;b++)hb[b]=y;d=v-1}else 8==g&&1==m&&(hb[d]=1);p=g,7&g&&(m=g)}}}(e,i,o,r,a),function(e,t,n,r,i){for(var o=1==i?2:1,s=0,a=0,l=0;s<=r.length;s++)for(var c,u,h,f=s?r[s-1].to:t,d=s<r.length?r[s].from:n,p=f;p<d;p++)if(u=eb[c=e.charCodeAt(p)])if(u<0){for(var m=a-3;m>=0;m-=3)if(tb[m+1]==-u){var g=tb[m+2],v=2&g?i:4&g?1&g?o:i:0;v&&(hb[p]=hb[tb[m]]=v),a=m;break}}else{if(189==tb.length)break;tb[a++]=p,tb[a++]=c,tb[a++]=l}else if(2==(h=hb[p])||1==h){var y=h==i;l=y?0:1;for(var b=a-3;b>=0;b-=3){var w=tb[b+2];if(2&w)break;if(y)tb[b+2]|=2;else{if(4&w)break;tb[b+2]|=4}}}}(e,i,o,r,a),function(e,t,n,r){for(var i=0,o=r;i<=n.length;i++)for(var s=i?n[i-1].to:e,a=i<n.length?n[i].from:t,l=s;l<a;){var c=hb[l];if(256==c){for(var u=l+1;;)if(u==a){if(i==n.length)break;u=n[i++].to,a=i<n.length?n[i].from:t}else{if(256!=hb[u])break;u++}for(var h=1==o,f=h==(1==(u<t?hb[u]:r))?h?1:2:r,d=u,p=i,m=p?n[p-1].to:e;d>l;)d==m&&(d=n[--p].from,m=p?n[p-1].to:e),hb[--d]=f;l=u}else o=c,l++}}(i,o,r,a),fb(e,i,o,t,n,r,s)}function pb(e){return[new cb(0,e,0)]}var mb="";function gb(e,t,n,r,i){var o,s=r.head-e.from,a=cb.find(t,s,null!==(o=r.bidiLevel)&&void 0!==o?o:-1,r.assoc),l=t[a],c=l.side(i,n);if(s==c){var u=a+=i?1:-1;if(u<0||u>=t.length)return null;s=(l=t[a=u]).side(!i,n),c=l.side(i,n)}var h=pg(e.text,s,l.forward(i,n));(h<l.from||h>l.to)&&(h=c),mb=e.text.slice(Math.min(s,h),Math.max(s,h));var f=a==(i?t.length-1:0)?null:t[a+(i?1:-1)];return f&&h==c&&f.level+(i?0:1)<l.level?Ng.cursor(f.side(!i,n)+e.from,f.forward(i,n)?1:-1,f.level):Ng.cursor(h+e.from,l.forward(i,n)?-1:1,l.level)}function vb(e,t,n){for(var r=t;r<n;r++){var i=ab(e.charCodeAt(r));if(1==i)return $y;if(2==i||4==i)return Xy}return $y}var yb=Dg.define(),bb=Dg.define(),wb=Dg.define(),kb=Dg.define(),xb=Dg.define(),Sb=Dg.define(),Cb=Dg.define(),Eb=Dg.define(),Ab=Dg.define(),Mb=Dg.define({combine:function(e){return e.some(function(e){return e})}}),Ob=Dg.define({combine:function(e){return e.some(function(e){return e})}}),Nb=Dg.define(),Tb=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"nearest",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"nearest",i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:5,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:5,s=arguments.length>5&&void 0!==arguments[5]&&arguments[5];N(this,e),this.range=t,this.y=n,this.x=r,this.yMargin=i,this.xMargin=o,this.isSnapshot=s}return R(e,[{key:"map",value:function(t){return t.empty?this:new e(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}},{key:"clip",value:function(t){return this.range.to<=t.doc.length?this:new e(Ng.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}])}(),Rb=av.define({map:function(e,t){return e.map(t)}}),Db=av.define();function Pb(e,t,n){var r=e.facet(kb);r.length?r[0](t):window.onerror&&window.onerror(String(t),n,void 0,void 0,t)}var Lb=Dg.define({combine:function(e){return!e.length||e[0]}}),Bb=0,Ib=Dg.define({combine:function(e){return e.filter(function(t,n){for(var r=0;r<n;r++)if(e[r].plugin==t.plugin)return!1;return!0})}}),_b=function(){function e(t,n,r,i,o){N(this,e),this.id=t,this.create=n,this.domEventHandlers=r,this.domEventObservers=i,this.baseExtensions=o(this),this.extension=this.baseExtensions.concat(Ib.of({plugin:this,arg:void 0}))}return R(e,[{key:"of",value:function(e){return this.baseExtensions.concat(Ib.of({plugin:this,arg:e}))}}],[{key:"define",value:function(t,n){var r=n||{},i=r.eventHandlers,o=r.eventObservers,s=r.provide,a=r.decorations;return new e(Bb++,t,i,o,function(e){var t=[];return a&&t.push(Hb.of(function(t){var n=t.plugin(e);return n?a(n):by.none})),s&&t.push(s(e)),t})}},{key:"fromClass",value:function(t,n){return e.define(function(e,n){return new t(e,n)},n)}}])}(),Fb=function(){return R(function e(t){N(this,e),this.spec=t,this.mustUpdate=null,this.value=null},[{key:"plugin",get:function(){return this.spec&&this.spec.plugin}},{key:"update",value:function(e){if(this.value){if(this.mustUpdate){var t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(e){if(Pb(t.state,e,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(e){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){Pb(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}},{key:"destroy",value:function(e){var t;if(null===(t=this.value)||void 0===t?void 0:t.destroy)try{this.value.destroy()}catch(t){Pb(e.state,t,"CodeMirror plugin crashed")}}},{key:"deactivate",value:function(){this.spec=this.value=null}}])}(),Wb=Dg.define(),jb=Dg.define(),Hb=Dg.define(),zb=Dg.define(),Vb=Dg.define(),qb=Dg.define(),Ub=Dg.define();function Kb(e,t){var n=e.state.facet(Ub);if(!n.length)return n;var r=n.map(function(t){return t instanceof Function?t(e):t}),i=[];return Av.spans(r,t.from,t.to,{point:function(){},span:function(e,n,r,o){for(var s=e-t.from,a=n-t.from,l=i,c=r.length-1;c>=0;c--,o--){var u=r[c].spec.bidiIsolate,h=void 0;if(null==u&&(u=vb(t.text,s,a)),o>0&&l.length&&(h=l[l.length-1]).to==s&&h.direction==u)h.to=a,l=h.inner;else{var f={from:s,to:a,direction:u,inner:[]};l.push(f),l=f.inner}}}}),i}var Gb=Dg.define();function Yb(e){var t,n=0,r=0,i=0,o=0,s=D(e.state.facet(Gb));try{for(s.s();!(t=s.n()).done;){var a=(0,t.value)(e);a&&(null!=a.left&&(n=Math.max(n,a.left)),null!=a.right&&(r=Math.max(r,a.right)),null!=a.top&&(i=Math.max(i,a.top)),null!=a.bottom&&(o=Math.max(o,a.bottom)))}}catch(e){s.e(e)}finally{s.f()}return{left:n,right:r,top:i,bottom:o}}var $b=Dg.define(),Xb=function(){function e(t,n,r,i){N(this,e),this.fromA=t,this.toA=n,this.fromB=r,this.toB=i}return R(e,[{key:"join",value:function(t){return new e(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.toB))}},{key:"addToSet",value:function(e){for(var t=e.length,n=this;t>0;t--){var r=e[t-1];if(!(r.fromA>n.toA)){if(r.toA<n.fromA)break;n=n.join(r),e.splice(t-1,1)}}return e.splice(t,0,n),e}}],[{key:"extendWithRanges",value:function(t,n){if(0==n.length)return t;for(var r=[],i=0,o=0,s=0;;){var a=i<t.length?t[i].fromB:1e9,l=o<n.length?n[o]:1e9,c=Math.min(a,l);if(1e9==c)break;for(var u=c+s,h=c,f=u;;)if(o<n.length&&n[o]<=h){var d=n[o+1];o+=2,h=Math.max(h,d);for(var p=i;p<t.length&&t[p].fromB<=h;p++)s=t[p].toA-t[p].toB;f=Math.max(f,d+s)}else{if(!(i<t.length&&t[i].fromB<=h))break;var m=t[i++];h=Math.max(h,m.toB),f=Math.max(f,m.toA),s=m.toA-m.toB}r.push(new e(u,f,c,h))}return r}}])}(),Jb=function(){function e(t,n,r){N(this,e),this.view=t,this.state=n,this.transactions=r,this.flags=0,this.startState=t.state,this.changes=kg.empty(this.startState.doc.length);var i,o=D(r);try{for(o.s();!(i=o.n()).done;){var s=i.value;this.changes=this.changes.compose(s.changes)}}catch(e){o.e(e)}finally{o.f()}var a=[];this.changes.iterChangedRanges(function(e,t,n,r){return a.push(new Xb(e,t,n,r))}),this.changedRanges=a}return R(e,[{key:"viewportChanged",get:function(){return(4&this.flags)>0}},{key:"viewportMoved",get:function(){return(8&this.flags)>0}},{key:"heightChanged",get:function(){return(2&this.flags)>0}},{key:"geometryChanged",get:function(){return this.docChanged||(18&this.flags)>0}},{key:"focusChanged",get:function(){return(1&this.flags)>0}},{key:"docChanged",get:function(){return!this.changes.empty}},{key:"selectionSet",get:function(){return this.transactions.some(function(e){return e.selection})}},{key:"empty",get:function(){return 0==this.flags&&0==this.transactions.length}}],[{key:"create",value:function(t,n,r){return new e(t,n,r)}}])}(),Qb=[],Zb=function(){return R(function e(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;N(this,e),this.dom=t,this.length=n,this.flags=r,this.parent=null,t.cmTile=this},[{key:"breakAfter",get:function(){return 1&this.flags}},{key:"children",get:function(){return Qb}},{key:"isWidget",value:function(){return!1}},{key:"isHidden",get:function(){return!1}},{key:"isComposite",value:function(){return!1}},{key:"isLine",value:function(){return!1}},{key:"isText",value:function(){return!1}},{key:"isBlock",value:function(){return!1}},{key:"domAttrs",get:function(){return null}},{key:"sync",value:function(e){if(this.flags|=2,4&this.flags){this.flags&=-5;var t=this.domAttrs;t&&function(e,t){for(var n=e.attributes.length-1;n>=0;n--){var r=e.attributes[n].name;null==t[r]&&e.removeAttribute(r)}for(var i in t){var o=t[i];"style"==i?e.style.cssText=o:e.getAttribute(i)!=o&&e.setAttribute(i,o)}}(this.dom,t)}}},{key:"toString",value:function(){return this.constructor.name+(this.children.length?"(".concat(this.children,")"):"")+(this.breakAfter?"#":"")}},{key:"destroy",value:function(){this.parent=null}},{key:"setDOM",value:function(e){this.dom=e,e.cmTile=this}},{key:"posAtStart",get:function(){return this.parent?this.parent.posBefore(this):0}},{key:"posAtEnd",get:function(){return this.posAtStart+this.length}},{key:"posBefore",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.posAtStart,r=D(this.children);try{for(r.s();!(t=r.n()).done;){var i=t.value;if(i==e)return n;n+=i.length+i.breakAfter}}catch(e){r.e(e)}finally{r.f()}throw new RangeError("Invalid child in posBefore")}},{key:"posAfter",value:function(e){return this.posBefore(e)+e.length}},{key:"covers",value:function(e){return!0}},{key:"coordsIn",value:function(e,t){return null}},{key:"domPosFor",value:function(e,t){var n=Ry(this.dom),r=this.length?e>0:t>0;return new Gy(this.parent.dom,n+(r?1:0),0==e||e==this.length)}},{key:"markDirty",value:function(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&2&this.parent.flags&&this.parent.markDirty(!1)}},{key:"overrideDOMText",get:function(){return null}},{key:"root",get:function(){for(var e=this;e;e=e.parent)if(e instanceof nw)return e;return null}}],[{key:"get",value:function(e){return e.cmTile}}])}(),ew=function(){function e(t){var n;return N(this,e),(n=O(this,e,[t,0]))._children=[],n}return I(e,Zb),R(e,[{key:"isComposite",value:function(){return!0}},{key:"children",get:function(){return this._children}},{key:"lastChild",get:function(){return this.children.length?this.children[this.children.length-1]:null}},{key:"append",value:function(e){this.children.push(e),e.parent=this}},{key:"sync",value:function(t){if(!(2&this.flags)){U(e,"sync",this,3)([t]);var n,r,i=this.dom,o=null,s=(null==t?void 0:t.node)==i?t:null,a=0,l=D(this.children);try{for(l.s();!(r=l.n()).done;){var c=r.value;if(c.sync(t),a+=c.length+c.breakAfter,n=o?o.nextSibling:i.firstChild,s&&n!=c.dom&&(s.written=!0),c.dom.parentNode==i)for(;n&&n!=c.dom;)n=tw(n);else i.insertBefore(c.dom,n);o=c.dom}}catch(e){l.e(e)}finally{l.f()}for(n=o?o.nextSibling:i.firstChild,s&&n&&(s.written=!0);n;)n=tw(n);this.length=a}}}])}();function tw(e){var t=e.nextSibling;return e.parentNode.removeChild(e),t}var nw=function(){function e(t,n){var r;return N(this,e),(r=O(this,e,[n])).view=t,r}return I(e,ew),R(e,[{key:"owns",value:function(e){for(;e;e=e.parent)if(e==this)return!0;return!1}},{key:"isBlock",value:function(){return!0}},{key:"nearest",value:function(e){for(;;){if(!e)return null;var t=Zb.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}},{key:"blockTiles",value:function(e){for(var t=[],n=this,r=0,i=0;;)if(r==n.children.length){if(!t.length)return;(n=n.parent).breakAfter&&i++,r=t.pop()}else{var o=n.children[r++];if(o instanceof rw)t.push(r),n=o,r=0;else{var s=i+o.length,a=e(o,i);if(void 0!==a)return a;i=s+o.breakAfter}}}},{key:"resolveBlock",value:function(e,t){var n,r,i=-1,o=-1;if(this.blockTiles(function(s,a){var l=a+s.length;if(e>=a&&e<=l){if(s.isWidget()&&t>=-1&&t<=1){if(32&s.flags)return!0;16&s.flags&&(n=void 0)}(a<e||e==l&&(t<-1?s.length:s.covers(1)))&&(!n||!s.isWidget()&&n.isWidget())&&(n=s,i=e-a),(l>e||e==a&&(t>1?s.length:s.covers(-1)))&&(!r||!s.isWidget()&&r.isWidget())&&(r=s,o=e-a)}}),!n&&!r)throw new Error("No tile at position "+e);return n&&t<0||!r?{tile:n,offset:i}:{tile:r,offset:o}}}])}(),rw=function(){function e(t,n){var r;return N(this,e),(r=O(this,e,[t])).wrapper=n,r}return I(e,ew),R(e,[{key:"isBlock",value:function(){return!0}},{key:"covers",value:function(e){return!!this.children.length&&(e<0?this.children[0].covers(-1):this.lastChild.covers(1))}},{key:"domAttrs",get:function(){return this.wrapper.attributes}}],[{key:"of",value:function(t,n){var r=new e(n||document.createElement(t.tagName),t);return n||(r.flags|=4),r}}])}(),iw=function(){function e(t,n){var r;return N(this,e),(r=O(this,e,[t])).attrs=n,r}return I(e,ew),R(e,[{key:"isLine",value:function(){return!0}},{key:"domAttrs",get:function(){return this.attrs}},{key:"resolveInline",value:function(e,t,n){var r=null,i=-1,o=null,s=-1;!function e(a,l){for(var c=0,u=0;c<a.children.length&&u<=l;c++){var h=a.children[c],f=u+h.length;f>=l&&(h.isComposite()?e(h,l-u):(!o||o.isHidden&&(t>0||n&&ow(o,h)))&&(f>l||32&h.flags)?(o=h,s=l-u):(u<l||16&h.flags&&!h.isHidden)&&(r=h,i=l-u)),u=f}}(this,e);var a=(t<0?r:o)||r||o;return a?{tile:a,offset:a==r?i:s}:null}},{key:"coordsIn",value:function(e,t){var n=this.resolveInline(e,t,!0);return n?n.tile.coordsIn(Math.max(0,n.offset),t):function(e){var t=e.dom.lastChild;if(!t)return e.dom.getBoundingClientRect();var n=Ny(t);return n[n.length-1]||null}(this)}},{key:"domIn",value:function(e,t){var n=this.resolveInline(e,t);if(n){var r=n.tile,i=n.offset;if(this.dom.contains(r.dom))return r.isText()?new Gy(r.dom,Math.min(r.dom.nodeValue.length,i)):r.domPosFor(i,16&r.flags?1:32&r.flags?-1:t);var o,s=!1,a=D(n.tile.parent.children);try{for(a.s();!(o=a.n()).done;){var l=o.value;if(s)return new Gy(l.dom,0);l==n.tile&&(s=!0)}}catch(e){a.e(e)}finally{a.f()}}return new Gy(this.dom,0)}}],[{key:"start",value:function(t,n,r){var i=new e(n||document.createElement("div"),t);return n&&r||(i.flags|=4),i}}])}();function ow(e,t){var n=e.coordsIn(0,1),r=t.coordsIn(0,1);return n&&r&&r.top<n.bottom}for(var sw=function(){function e(t,n){var r;return N(this,e),(r=O(this,e,[t])).mark=n,r}return I(e,ew),R(e,[{key:"domAttrs",get:function(){return this.mark.attrs}}],[{key:"of",value:function(t,n){var r=new e(n||document.createElement(t.tagName),t);return n||(r.flags|=4),r}}])}(),aw=function(){function e(t,n){var r;return N(this,e),(r=O(this,e,[t,n.length])).text=n,r}return I(e,Zb),R(e,[{key:"sync",value:function(t){2&this.flags||(U(e,"sync",this,3)([t]),this.dom.nodeValue!=this.text&&(t&&t.node==this.dom&&(t.written=!0),this.dom.nodeValue=this.text))}},{key:"isText",value:function(){return!0}},{key:"toString",value:function(){return JSON.stringify(this.text)}},{key:"coordsIn",value:function(e,t){var n=this.dom.nodeValue.length;e>n&&(e=n);var r=e,i=e,o=0;0==e&&t<0||e==n&&t>=0?hy.chrome||hy.gecko||(e?(r--,o=1):i<n&&(i++,o=-1)):t<0?r--:i<n&&i++;var s=zy(this.dom,r,i).getClientRects();if(!s.length)return null;var a=s[(o?o<0:t>=0)?0:s.length-1];return hy.safari&&!o&&0==a.width&&(a=Array.prototype.find.call(s,function(e){return e.width})||a),o?By(a,o<0):a||null}}],[{key:"of",value:function(t,n){var r=new e(n||document.createTextNode(t),t);return n||(r.flags|=2),r}}])}(),lw=function(){function e(t,n,r,i){var o;return N(this,e),(o=O(this,e,[t,n,i])).widget=r,o}return I(e,Zb),R(e,[{key:"isWidget",value:function(){return!0}},{key:"isHidden",get:function(){return this.widget.isHidden}},{key:"covers",value:function(e){return!(48&this.flags)&&(this.flags&(e<0?64:128))>0}},{key:"coordsIn",value:function(e,t){return this.coordsInWidget(e,t,!1)}},{key:"coordsInWidget",value:function(e,t,n){var r=this.widget.coordsAt(this.dom,e,t);if(r)return r;if(n)return By(this.dom.getBoundingClientRect(),this.length?0==e:t<=0);var i=this.dom.getClientRects(),o=null;if(!i.length)return null;for(var s=!!(16&this.flags)||!(32&this.flags)&&e>0,a=s?i.length-1:0;o=i[a],!(e>0?0==a:a==i.length-1||o.top<o.bottom);a+=s?-1:1);return By(o,!s)}},{key:"overrideDOMText",get:function(){if(!this.length)return ig.empty;var e=this.root;if(!e)return ig.empty;var t=this.posAtStart;return e.view.state.doc.slice(t,t+this.length)}},{key:"destroy",value:function(){U(e,"destroy",this,3)([]),this.widget.destroy(this.dom)}}],[{key:"of",value:function(t,n,r,i,o){return o||(o=t.toDOM(n),t.editable||(o.contentEditable="false")),new e(o,r,t,i)}}])}(),cw=function(){function e(t){N(this,e);var n=document.createElement("img");return n.className="cm-widgetBuffer",n.setAttribute("aria-hidden","true"),O(this,e,[n,0,t])}return I(e,Zb),R(e,[{key:"isHidden",get:function(){return!0}},{key:"overrideDOMText",get:function(){return ig.empty}},{key:"coordsIn",value:function(e){return this.dom.getBoundingClientRect()}}])}(),uw=function(){return R(function e(t){N(this,e),this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=t},[{key:"advance",value:function(e,t,n){for(var r=this.tile,i=this.index,o=this.beforeBreak,s=this.parents;e||t>0;)if(r.isComposite())if(o){if(!e)break;n&&n.break(),e--,o=!1}else if(i==r.children.length){if(!e&&!s.length)break;n&&n.leave(r),o=!!r.breakAfter;var a=s.pop();r=a.tile,i=a.index,i++}else{var l=r.children[i],c=l.breakAfter;!(t>0?l.length<=e:l.length<e)||n&&!1===n.skip(l,0,l.length)&&l.isComposite?(s.push({tile:r,index:i}),r=l,i=0,n&&l.isComposite()&&n.enter(l)):(o=!!c,i++,e-=l.length)}else if(i==r.length){o=!!r.breakAfter;var u=s.pop();r=u.tile,i=u.index,i++}else{if(!e)break;var h=Math.min(e,r.length-i);n&&n.skip(r,i,i+h),e-=h,i+=h}return this.tile=r,this.index=i,this.beforeBreak=o,this}},{key:"root",get:function(){return this.parents.length?this.parents[0].tile:this.tile}}])}(),hw=R(function e(t,n,r,i){N(this,e),this.from=t,this.to=n,this.wrapper=r,this.rank=i}),fw=function(){return R(function e(t,n,r){N(this,e),this.cache=t,this.root=n,this.blockWrappers=r,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0},[{key:"addText",value:function(e,t,n,r){var i;this.flushBuffer();var o=this.ensureMarks(t,n),s=o.lastChild;s&&s.isText()&&!(8&s.flags)&&s.length+e.length<512?(this.cache.reused.set(s,2),(o.children[o.children.length-1]=new aw(s.dom,s.text+e)).parent=o):o.append(r||aw.of(e,null===(i=this.cache.find(aw))||void 0===i?void 0:i.dom));this.pos+=e.length,this.afterWidget=null}},{key:"addComposition",value:function(e,t){var n=this.curLine;n.dom!=t.line.dom&&(n.setDOM(this.cache.reused.has(t.line)?ww(t.line.dom):t.line.dom),this.cache.reused.set(t.line,2));for(var r=n,i=t.marks.length-1;i>=0;i--){var o=t.marks[i],s=r.lastChild;if(s instanceof sw&&s.mark.eq(o.mark))s.dom!=o.dom&&s.setDOM(ww(o.dom)),r=s;else{if(this.cache.reused.get(o)){var a=Zb.get(o.dom);a&&a.setDOM(ww(o.dom))}var l=sw.of(o.mark,o.dom);r.append(l),r=l}this.cache.reused.set(o,2)}var c=Zb.get(e.text);c&&this.cache.reused.set(c,2);var u=new aw(e.text,e.text.nodeValue);u.flags|=8,r.append(u)}},{key:"addInlineWidget",value:function(e,t,n){var r=this.afterWidget&&48&e.flags&&(48&this.afterWidget.flags)==(48&e.flags);r||this.flushBuffer();var i=this.ensureMarks(t,n);r||16&e.flags||i.append(this.getBuffer(1)),i.append(e),this.pos+=e.length,this.afterWidget=e}},{key:"addMark",value:function(e,t,n){this.flushBuffer(),this.ensureMarks(t,n).append(e),this.pos+=e.length,this.afterWidget=null}},{key:"addBlockWidget",value:function(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}},{key:"continueWidget",value:function(e){(this.afterWidget||this.lastBlock).length+=e,this.pos+=e}},{key:"addLineStart",value:function(e,t){var n;e||(e=bw);var r=iw.start(e,t||(null===(n=this.cache.find(iw))||void 0===n?void 0:n.dom),!!t);this.getBlockPos().append(this.lastBlock=this.curLine=r)}},{key:"addLine",value:function(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}},{key:"addBreak",value:function(){this.lastBlock.flags|=1,this.endLine(),this.pos++}},{key:"addLineStartIfNotCovered",value:function(e){this.blockPosCovered()||this.addLineStart(e)}},{key:"ensureLine",value:function(e){this.curLine||this.addLineStart(e)}},{key:"ensureMarks",value:function(e,t){for(var n,r=this,i=this.curLine,o=function(){var o,a=e[s];if(t>0&&(o=i.lastChild)&&o instanceof sw&&o.mark.eq(a))i=o,t--;else{var l=sw.of(a,null===(n=r.cache.find(sw,function(e){return e.mark.eq(a)}))||void 0===n?void 0:n.dom);i.append(l),i=l,t=0}},s=e.length-1;s>=0;s--)o();return i}},{key:"endLine",value:function(){if(this.curLine){this.flushBuffer();var e=this.curLine.lastChild;e&&yw(this.curLine,!1)&&("BR"==e.dom.nodeName||!e.isWidget()||hy.ios&&yw(this.curLine,!0))||this.curLine.append(this.cache.findWidget(xw,0,32)||new lw(xw.toDOM(),0,xw,32)),this.curLine=this.afterWidget=null}}},{key:"updateBlockWrappers",value:function(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(var e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to<this.pos&&this.wrappers.splice(e,1);for(var t=this.blockWrappers;t.value&&t.from<=this.pos;t.next())if(t.to>=this.pos){for(var n=new hw(t.from,t.to,t.value,t.rank),r=this.wrappers.length;r>0&&(this.wrappers[r-1].rank-n.rank||this.wrappers[r-1].to-n.to)<0;)r--;this.wrappers.splice(r,0,n)}this.wrapperPos=this.pos}},{key:"getBlockPos",value:function(){var e,t=this;this.updateBlockWrappers();var n,r=this.root,i=D(this.wrappers);try{var o=function(){var i=n.value,o=r.lastChild;if(i.from<t.pos&&o instanceof rw&&o.wrapper.eq(i.wrapper))r=o;else{var s=rw.of(i.wrapper,null===(e=t.cache.find(rw,function(e){return e.wrapper.eq(i.wrapper)}))||void 0===e?void 0:e.dom);r.append(s),r=s}};for(i.s();!(n=i.n()).done;)o()}catch(e){i.e(e)}finally{i.f()}return r}},{key:"blockPosCovered",value:function(){var e=this.lastBlock;return null!=e&&!e.breakAfter&&(!e.isWidget()||(160&e.flags)>0)}},{key:"getBuffer",value:function(e){var t=2|(e<0?16:32),n=this.cache.find(cw,void 0,1);return n&&(n.flags=t),n||new cw(t)}},{key:"flushBuffer",value:function(){!this.afterWidget||32&this.afterWidget.flags||(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}])}(),dw=function(){return R(function e(t){N(this,e),this.skipCount=0,this.text="",this.textOff=0,this.cursor=t.iter()},[{key:"skip",value:function(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}},{key:"next",value:function(e){if(this.textOff==this.text.length){var t=this.cursor.next(this.skipCount),n=t.value,r=t.lineBreak,i=t.done;if(this.skipCount=0,i)throw new Error("Ran out of text content when drawing inline views");this.text=n;var o=this.textOff=Math.min(e,n.length);return r?null:n.slice(0,o)}var s=Math.min(this.text.length,this.textOff+e),a=this.text.slice(this.textOff,s);return this.textOff=s,a}}])}(),pw=[lw,iw,aw,sw,cw,rw,nw],mw=0;mw<pw.length;mw++)pw[mw].bucket=mw;var gw=function(){return R(function e(t){N(this,e),this.view=t,this.buckets=pw.map(function(){return[]}),this.index=pw.map(function(){return 0}),this.reused=new Map},[{key:"add",value:function(e){var t=e.constructor.bucket,n=this.buckets[t];n.length<6?n.push(e):n[this.index[t]=(this.index[t]+1)%6]=e}},{key:"find",value:function(e,t){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2,r=e.bucket,i=this.buckets[r],o=this.index[r],s=i.length-1;s>=0;s--){var a=(s+o)%i.length,l=i[a];if((!t||t(l))&&!this.reused.has(l))return i.splice(a,1),a<o&&this.index[r]--,this.reused.set(l,n),l}return null}},{key:"findWidget",value:function(e,t,n){var r=this.buckets[0];if(r.length)for(var i=0,o=0;;i++){if(i==r.length){if(o)return null;o=1,i=0}var s=r[i];if(!this.reused.has(s)&&(0==o?s.widget.compare(e):s.widget.constructor==e.constructor&&e.updateDOM(s.dom,this.view)))return r.splice(i,1),i<this.index[0]&&this.index[0]--,s.widget==e&&s.length==t&&(497&s.flags)==n?(this.reused.set(s,1),s):(this.reused.set(s,2),new lw(s.dom,t,e,-498&s.flags|n))}}},{key:"reuse",value:function(e){return this.reused.set(e,1),e}},{key:"maybeReuse",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;if(!this.reused.has(e))return this.reused.set(e,t),e.dom}},{key:"clear",value:function(){for(var e=0;e<this.buckets.length;e++)this.buckets[e].length=this.index[e]=0}}])}(),vw=function(){return R(function e(t,n,r,i,o){var s=this;N(this,e),this.view=t,this.decorations=i,this.disallowBlockEffectsFor=o,this.openWidget=!1,this.openMarks=0,this.cache=new gw(t),this.text=new dw(t.state.doc),this.builder=new fw(this.cache,new nw(t,t.contentDOM),Av.iter(r)),this.cache.reused.set(n,2),this.old=new uw(n),this.reuseWalker={skip:function(e,t,n){if(s.cache.add(e),e.isComposite())return!1},enter:function(e){return s.cache.add(e)},leave:function(){},break:function(){}}},[{key:"run",value:function(e,t){for(var n=t&&this.getCompositionContext(t.text),r=0,i=0,o=0;;){var s=o<e.length?e[o++]:null,a=s?s.fromA:this.old.root.length;if(a>r){var l=a-r;this.preserve(l,!o,!s),r=a,i+=l}if(!s)break;t&&s.fromA<=t.range.fromA&&s.toA>=t.range.toA?(this.forward(s.fromA,t.range.fromA,t.range.fromA<t.range.toA?1:-1),this.emit(i,t.range.fromB),this.cache.clear(),this.builder.addComposition(t,n),this.text.skip(t.range.toB-t.range.fromB),this.forward(t.range.fromA,s.toA),this.emit(t.range.toB,s.toB)):(this.forward(s.fromA,s.toA),this.emit(i,s.toB)),i=s.toB,r=s.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}},{key:"preserve",value:function(e,t,n){var r=this,i=function(e){for(var t=[],n=e.parents.length;n>1;n--){var r=n==e.parents.length?e.tile:e.parents[n].tile;r instanceof sw&&t.push(r.mark)}return t}(this.old),o=this.openMarks;this.old.advance(e,n?1:-1,{skip:function(e,t,n){if(e.isWidget())if(r.openWidget)r.builder.continueWidget(n-t);else{var s=n>0||t<e.length?lw.of(e.widget,r.view,n-t,496&e.flags,r.cache.maybeReuse(e)):r.cache.reuse(e);256&s.flags?(s.flags&=-2,r.builder.addBlockWidget(s)):(r.builder.ensureLine(null),r.builder.addInlineWidget(s,i,o),o=i.length)}else if(e.isText())r.builder.ensureLine(null),t||n!=e.length?(r.cache.add(e),r.builder.addText(e.text.slice(t,n),i,o)):r.builder.addText(e.text,i,o,r.cache.reuse(e)),o=i.length;else if(e.isLine())e.flags&=-2,r.cache.reused.set(e,1),r.builder.addLine(e);else if(e instanceof cw)r.cache.add(e);else{if(!(e instanceof sw))return!1;r.builder.ensureLine(null),r.builder.addMark(e,i,o),r.cache.reused.set(e,1),o=i.length}r.openWidget=!1},enter:function(e){e.isLine()?r.builder.addLineStart(e.attrs,r.cache.maybeReuse(e)):(r.cache.add(e),e instanceof sw&&i.unshift(e.mark)),r.openWidget=!1},leave:function(e){e.isLine()?i.length&&(i.length=o=0):e instanceof sw&&(i.shift(),o=Math.min(o,i.length))},break:function(){r.builder.addBreak(),r.openWidget=!1}}),this.text.skip(e)}},{key:"emit",value:function(e,t){var n=this,r=null,i=this.builder,o=0,s=Av.spans(this.decorations,e,t,{point:function(e,t,s,a,l,c){if(s instanceof xy){if(n.disallowBlockEffectsFor[c]){if(s.block)throw new RangeError("Block decorations may not be specified via plugins");if(t>n.view.state.doc.lineAt(e).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(o=a.length,l>a.length)i.continueWidget(t-e);else{var u=s.widget||(s.block?kw.block:kw.inline),h=function(e){var t=e.isReplace?(e.startSide<0?64:0)|(e.endSide>0?128:0):e.startSide>0?32:16;e.block&&(t|=256);return t}(s),f=n.cache.findWidget(u,t-e,h)||lw.of(u,n.view,t-e,h);s.block?(s.startSide>0&&i.addLineStartIfNotCovered(r),i.addBlockWidget(f)):(i.ensureLine(r),i.addInlineWidget(f,a,l))}r=null}else r=function(e,t){var n=t.spec.attributes,r=t.spec.class;if(!n&&!r)return e;e||(e={class:"cm-line"});n&&fy(n,e);r&&(e.class+=" "+r);return e}(r,s);t>e&&n.text.skip(t-e)},span:function(e,t,o,s){for(var a=e;a<t;){var l=n.text.next(Math.min(512,t-a));null==l?(i.addLineStartIfNotCovered(r),i.addBreak(),a++):(i.ensureLine(r),i.addText(l,o,a==e?s:o.length),a+=l.length),r=null}}});i.addLineStartIfNotCovered(r),this.openWidget=s>o,this.openMarks=s}},{key:"forward",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;t-e<=10?this.old.advance(t-e,n,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,n,this.reuseWalker))}},{key:"getCompositionContext",value:function(e){for(var t=[],n=null,r=e.parentNode;;r=r.parentNode){var i=Zb.get(r);if(r==this.view.contentDOM)break;i instanceof sw?t.push(i):(null==i?void 0:i.isLine())?n=i:i instanceof rw||("DIV"!=r.nodeName||n||r==this.view.contentDOM?n||t.push(sw.of(new wy({tagName:r.nodeName.toLowerCase(),attributes:gy(r)}),r)):n=new iw(r,bw))}return{line:n,marks:t}}}])}();function yw(e,t){var n=function(e){var r,i=D(e.children);try{for(i.s();!(r=i.n()).done;){var o=r.value;if((t?o.isText():o.length)||n(o))return!0}}catch(e){i.e(e)}finally{i.f()}return!1};return n(e)}var bw={class:"cm-line"};function ww(e){var t=Zb.get(e);return t&&t.setDOM(e.cloneNode()),e}var kw=function(){function e(t){var n;return N(this,e),(n=O(this,e)).tag=t,n}return I(e,vy),R(e,[{key:"eq",value:function(e){return e.tag==this.tag}},{key:"toDOM",value:function(){return document.createElement(this.tag)}},{key:"updateDOM",value:function(e){return e.nodeName.toLowerCase()==this.tag}},{key:"isHidden",get:function(){return!0}}])}();kw.inline=new kw("span"),kw.block=new kw("div");var xw=new(function(){function e(){return N(this,e),O(this,e,arguments)}return I(e,vy),R(e,[{key:"toDOM",value:function(){return document.createElement("br")}},{key:"isHidden",get:function(){return!0}},{key:"editable",get:function(){return!0}}])}()),Sw=function(){return R(function e(t){N(this,e),this.view=t,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=by.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new nw(t,t.contentDOM),this.updateInner([new Xb(0,0,0,t.state.doc.length)],null)},[{key:"update",value:function(e){var t,n=this,r=e.changedRanges;this.minWidth>0&&r.length&&(r.every(function(e){var t=e.fromA;return e.toA<n.minWidthFrom||t>n.minWidthTo})?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);var i=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&((null===(t=this.domChanged)||void 0===t?void 0:t.newSel)?i=this.domChanged.newSel.head:function(e,t){var n=!1;t&&e.iterChangedRanges(function(e,r){e<t.to&&r>t.from&&(n=!0)});return n}(e.changes,this.hasComposition)||e.selectionSet||(i=e.state.selection.main.head));var o=i>-1?function(e,t,n){var r=Ew(e,n);if(!r)return null;var i=r.node,o=r.from,s=r.to,a=i.nodeValue;if(/[\n\r]/.test(a))return null;if(e.state.doc.sliceString(r.from,r.to)!=a)return null;var l=t.invertedDesc;return{range:new Xb(l.mapPos(o),l.mapPos(s),o,s),text:i}}(this.view,e.changes,i):null;if(this.domChanged=null,this.hasComposition){var s=this.hasComposition,a=s.from,l=s.to;r=new Xb(a,l,e.changes.mapPos(a,-1),e.changes.mapPos(l,1)).addToSet(r.slice())}this.hasComposition=o?{from:o.range.fromB,to:o.range.toB}:null,(hy.ie||hy.chrome)&&!o&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);var c=this.decorations,u=this.blockWrappers;this.updateDeco();var h,f,d,p,m=(h=c,f=this.decorations,d=e.changes,p=new Aw,Av.compare(h,f,d,p),p.changes);m.length&&(r=Xb.extendWithRanges(r,m));var g=function(e,t,n){var r=new Mw;return Av.compare(e,t,n,r),r.changes}(u,this.blockWrappers,e.changes);return g.length&&(r=Xb.extendWithRanges(r,g)),o&&!r.some(function(e){return e.fromA<=o.range.fromA&&e.toA>=o.range.toA})&&(r=o.range.addToSet(r.slice())),!(2&this.tile.flags&&0==r.length)&&(this.updateInner(r,o),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}},{key:"updateInner",value:function(e,t){var n=this;this.view.viewState.mustMeasureContent=!0;var r=this.view.observer;r.ignore(function(){if(t||e.length){var i=n.tile,o=new vw(n.view,i,n.blockWrappers,n.decorations,n.dynamicDecorationMap);n.tile=o.run(e,t),Cw(i,o.cache.reused)}n.tile.dom.style.height=n.view.viewState.contentHeight/n.view.scaleY+"px",n.tile.dom.style.flexBasis=n.minWidth?n.minWidth+"px":"";var s=hy.chrome||hy.ios?{node:r.selectionRange.focusNode,written:!1}:void 0;n.tile.sync(s),!s||!s.written&&r.selectionRange.focusNode==s.node&&n.tile.dom.contains(s.node)||(n.forceSelection=!0),n.tile.dom.style.height=""});var i=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length){var o,s=D(this.tile.children);try{for(s.s();!(o=s.n()).done;){var a=o.value;a.isWidget()&&a.widget instanceof Ow&&i.push(a.dom)}}catch(e){s.e(e)}finally{s.f()}}r.updateGaps(i)}},{key:"updateEditContextFormatting",value:function(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);var t,n=D(e.transactions);try{for(n.s();!(t=n.n()).done;){var r,i=D(t.value.effects);try{for(i.s();!(r=i.n()).done;){var o=r.value;o.is(Db)&&(this.editContextFormatting=o.value)}}catch(e){i.e(e)}finally{i.f()}}}catch(e){n.e(e)}finally{n.f()}}},{key:"updateSelection",value:function(){var e=this,t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];!(arguments.length>0&&void 0!==arguments[0]&&arguments[0])&&this.view.observer.selectionRange.focusNode||this.view.observer.readSelectionRange();var n=this.tile.dom,r=this.view.root.activeElement,i=r==n,o=!i&&!(this.view.state.facet(Lb)||n.tabIndex>-1)&&Oy(n,this.view.observer.selectionRange)&&!(r&&n.contains(r));if(i||t||o){var s=this.forceSelection;this.forceSelection=!1;var a,l,c,u=this.view.state.selection.main;if(u.empty?l=a=this.inlineDOMNearPos(u.anchor,u.assoc||1):(l=this.inlineDOMNearPos(u.head,u.head==u.from?1:-1),a=this.inlineDOMNearPos(u.anchor,u.anchor==u.from?1:-1)),hy.gecko&&u.empty&&!this.hasComposition&&(1==(c=a).node.nodeType&&c.node.firstChild&&(0==c.offset||"false"==c.node.childNodes[c.offset-1].contentEditable)&&(c.offset==c.node.childNodes.length||"false"==c.node.childNodes[c.offset].contentEditable))){var h=document.createTextNode("");this.view.observer.ignore(function(){return a.node.insertBefore(h,a.node.childNodes[a.offset]||null)}),a=l=new Gy(h,0),s=!0}var f=this.view.observer.selectionRange;!s&&f.focusNode&&(Ty(a.node,a.offset,f.anchorNode,f.anchorOffset)&&Ty(l.node,l.offset,f.focusNode,f.focusOffset)||this.suppressWidgetCursorChange(f,u))||(this.view.observer.ignore(function(){hy.android&&hy.chrome&&n.contains(f.focusNode)&&function(e,t){for(var n=e;n&&n!=t;n=n.assignedSlot||n.parentNode)if(1==n.nodeType&&"false"==n.contentEditable)return!0;return!1}(f.focusNode,n)&&(n.blur(),n.focus({preventScroll:!0}));var t=Ay(e.view.root);if(t)if(u.empty){if(hy.gecko){var i=function(e,t){return 1!=e.nodeType?0:(t&&"false"==e.childNodes[t-1].contentEditable?1:0)|(t<e.childNodes.length&&"false"==e.childNodes[t].contentEditable?2:0)}(a.node,a.offset);if(i&&3!=i){var s=(1==i?Uy:Ky)(a.node,a.offset);s&&(a=new Gy(s.node,s.offset))}}t.collapse(a.node,a.offset),null!=u.bidiLevel&&void 0!==t.caretBidiLevel&&(t.caretBidiLevel=u.bidiLevel)}else if(t.extend){t.collapse(a.node,a.offset);try{t.extend(l.node,l.offset)}catch(e){}}else{var c=document.createRange();if(u.anchor>u.head){var h=[l,a];a=h[0],l=h[1]}c.setEnd(l.node,l.offset),c.setStart(a.node,a.offset),t.removeAllRanges(),t.addRange(c)}else;o&&e.view.root.activeElement==n&&(n.blur(),r&&r.focus())}),this.view.observer.setSelectionRange(a,l)),this.impreciseAnchor=a.precise?null:new Gy(f.anchorNode,f.anchorOffset),this.impreciseHead=l.precise?null:new Gy(f.focusNode,f.focusOffset)}}},{key:"suppressWidgetCursorChange",value:function(e,t){return this.hasComposition&&t.empty&&Ty(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}},{key:"enforceCursorAssoc",value:function(){if(!this.hasComposition){var e=this.view,t=e.state.selection.main,n=Ay(e.root),r=e.observer.selectionRange,i=r.anchorNode,o=r.anchorOffset;if(n&&t.empty&&t.assoc&&n.modify){var s=this.lineAt(t.head,t.assoc);if(s){var a=s.posAtStart;if(t.head!=a&&t.head!=a+s.length){var l=this.coordsAt(t.head,-1),c=this.coordsAt(t.head,1);if(l&&c&&!(l.bottom>c.top)){var u=this.domAtPos(t.head+t.assoc,t.assoc);n.collapse(u.node,u.offset),n.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();var h=e.observer.selectionRange;e.docView.posFromDOM(h.anchorNode,h.anchorOffset)!=t.from&&n.collapse(i,o)}}}}}}},{key:"posFromDOM",value:function(e,t){var n=this.tile.nearest(e);if(!n)return 2&this.tile.dom.compareDocumentPosition(e)?0:this.view.state.doc.length;var r,i=n.posAtStart;if(!n.isComposite())return n.isText()?e==n.dom?i+t:i+(t?n.length:0):i;if(e==n.dom)r=n.dom.childNodes[t];else{for(var o=0==Ly(e)?0:0==t?-1:1;;){var s=e.parentNode;if(s==n.dom)break;0==o&&s.firstChild!=s.lastChild&&(o=e==s.firstChild?-1:1),e=s}r=o<0?e:e.nextSibling}if(r==n.dom.firstChild)return i;for(;r&&!Zb.get(r);)r=r.nextSibling;if(!r)return i+n.length;for(var a=0,l=i;;a++){var c=n.children[a];if(c.dom==r)return l;l+=c.length+c.breakAfter}}},{key:"domAtPos",value:function(e,t){var n=this.tile.resolveBlock(e,t),r=n.tile,i=n.offset;return r.isWidget()?r.domPosFor(e,t):r.domIn(i,t)}},{key:"inlineDOMNearPos",value:function(e,t){var n,r,i=-1,o=!1,s=-1,a=!1;return this.tile.blockTiles(function(t,l){if(t.isWidget()){if(32&t.flags&&l>=e)return!0;16&t.flags&&(o=!0)}else{var c=l+t.length;if(l<=e&&(n=t,i=e-l,o=c<e),c>=e&&!r&&(r=t,s=e-l,a=l>e),l>e&&r)return!0}}),n||r?(o&&r?n=null:a&&n&&(r=null),n&&t<0||!r?n.domIn(i,t):r.domIn(s,t)):this.domAtPos(e,t)}},{key:"coordsAt",value:function(e,t){var n=this.tile.resolveBlock(e,t),r=n.tile,i=n.offset;return r.isWidget()?r.widget instanceof Ow?null:r.coordsInWidget(i,t,!0):r.coordsIn(i,t)}},{key:"lineAt",value:function(e,t){var n=this.tile.resolveBlock(e,t).tile;return n.isLine()?n:null}},{key:"coordsForChar",value:function(e){var t=this.tile.resolveBlock(e,1),n=t.tile,r=t.offset;if(!n.isLine())return null;return function e(t,n){if(t.isComposite()){var r,i=D(t.children);try{for(i.s();!(r=i.n()).done;){var o=r.value;if(o.length>=n){var s=e(o,n);if(s)return s}if((n-=o.length)<0)break}}catch(e){i.e(e)}finally{i.f()}}else if(t.isText()&&n<t.length){var a=pg(t.text,n);if(a==n)return null;for(var l=zy(t.dom,n,a).getClientRects(),c=0;c<l.length;c++){var u=l[c];if(c==l.length-1||u.top<u.bottom&&u.left<u.right)return u}}return null}(n,r)}},{key:"measureVisibleLineHeights",value:function(e){var t=this,n=[],r=e.from,i=e.to,o=this.view.contentDOM.clientWidth,s=o>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,a=-1,l=this.view.textDirection==Yy.LTR,c=0,u=function(e,h,f){for(var d=0;d<e.children.length&&!(h>i);d++){var p=e.children[d],m=h+p.length,g=p.dom.getBoundingClientRect(),v=g.height;if(f&&!d&&(c+=g.top-f.top),p instanceof rw)m>r&&u(p,h,g);else if(h>=r&&(c>0&&n.push(-c),n.push(v+c),c=0,s)){var y=p.dom.lastChild,b=y?Ny(y):[];if(b.length){var w=b[b.length-1],k=l?w.right-g.left:g.right-w.left;k>a&&(a=k,t.minWidth=o,t.minWidthFrom=h,t.minWidthTo=m)}}f&&d==e.children.length-1&&(c+=f.bottom-g.bottom),h=m+p.breakAfter}};return u(this.tile,0,null),n}},{key:"textDirectionAt",value:function(e){var t=this.tile.resolveBlock(e,1).tile;return"rtl"==getComputedStyle(t.dom).direction?Yy.RTL:Yy.LTR}},{key:"measureTextSize",value:function(){var e=this,t=this.tile.blockTiles(function(e){if(e.isLine()&&e.children.length&&e.length<=20){var t,n,r=0,i=D(e.children);try{for(i.s();!(n=i.n()).done;){var o=n.value;if(!o.isText()||/[^ -~]/.test(o.text))return;var s=Ny(o.dom);if(1!=s.length)return;r+=s[0].width,t=s[0].height}}catch(e){i.e(e)}finally{i.f()}if(r)return{lineHeight:e.dom.getBoundingClientRect().height,charWidth:r/e.length,textHeight:t}}});if(t)return t;var n,r,i,o=document.createElement("div");return o.className="cm-line",o.style.width="99999px",o.style.position="absolute",o.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(function(){e.tile.dom.appendChild(o);var t=Ny(o.firstChild)[0];n=o.getBoundingClientRect().height,r=t&&t.width?t.width/27:7,i=t&&t.height?t.height:n,o.remove()}),{lineHeight:n,charWidth:r,textHeight:i}}},{key:"computeBlockGapDeco",value:function(){for(var e=[],t=this.view.viewState,n=0,r=0;;r++){var i=r==t.viewports.length?null:t.viewports[r],o=i?i.from-1:this.view.state.doc.length;if(o>n){var s=(t.lineBlockAt(o).bottom-t.lineBlockAt(n).top)/this.view.scaleY;e.push(by.replace({widget:new Ow(s),block:!0,inclusive:!0,isBlockGap:!0}).range(n,o))}if(!i)break;n=i.to+1}return by.set(e)}},{key:"updateDeco",value:function(){var e=this,t=1,n=this.view.state.facet(Hb).map(function(n){return(e.dynamicDecorationMap[t++]="function"==typeof n)?n(e.view):n}),r=!1,i=this.view.state.facet(Vb).map(function(t,n){var i="function"==typeof t;return i&&(r=!0),i?t(e.view):t});for(i.length&&(this.dynamicDecorationMap[t++]=r,n.push(Av.join(i))),this.decorations=[this.editContextFormatting].concat(K(n),[this.computeBlockGapDeco(),this.view.viewState.lineGapDeco]);t<this.decorations.length;)this.dynamicDecorationMap[t++]=!1;this.blockWrappers=this.view.state.facet(zb).map(function(t){return"function"==typeof t?t(e.view):t})}},{key:"scrollIntoView",value:function(e){if(e.isSnapshot){var t=this.view.viewState.lineBlockAt(e.range.head);return this.view.scrollDOM.scrollTop=t.top-e.yMargin,void(this.view.scrollDOM.scrollLeft=e.xMargin)}var n,r=D(this.view.state.facet(Nb));try{for(r.s();!(n=r.n()).done;){var i=n.value;try{if(i(this.view,e.range,e))return!0}catch(e){Pb(this.view.state,e,"scroll handler")}}}catch(e){r.e(e)}finally{r.f()}var o,s=e.range,a=this.coordsAt(s.head,s.empty?s.assoc:s.head>s.anchor?-1:1);if(a){!s.empty&&(o=this.coordsAt(s.anchor,s.anchor>s.head?-1:1))&&(a={left:Math.min(a.left,o.left),top:Math.min(a.top,o.top),right:Math.max(a.right,o.right),bottom:Math.max(a.bottom,o.bottom)});var l=Yb(this.view),c={left:a.left-l.left,top:a.top-l.top,right:a.right+l.right,bottom:a.bottom+l.bottom},u=this.view.scrollDOM,h=u.offsetWidth,f=u.offsetHeight;if(function(e,t,n,r,i,o,s,a){for(var l=e.ownerDocument,c=l.defaultView||window,u=e,h=!1;u&&!h;)if(1==u.nodeType){var f=void 0,d=u==l.body,p=1,m=1;if(d)f=Iy(c);else{if(/^(fixed|sticky)$/.test(getComputedStyle(u).position)&&(h=!0),u.scrollHeight<=u.clientHeight&&u.scrollWidth<=u.clientWidth){u=u.assignedSlot||u.parentNode;continue}var g=u.getBoundingClientRect(),v=_y(u,g);p=v.scaleX,m=v.scaleY,f={left:g.left,right:g.left+u.clientWidth*p,top:g.top,bottom:g.top+u.clientHeight*m}}var y=0,b=0;if("nearest"==i)t.top<f.top?(b=t.top-(f.top+s),n>0&&t.bottom>f.bottom+b&&(b=t.bottom-f.bottom+s)):t.bottom>f.bottom&&(b=t.bottom-f.bottom+s,n<0&&t.top-b<f.top&&(b=t.top-(f.top+s)));else{var w=t.bottom-t.top,k=f.bottom-f.top;b=("center"==i&&w<=k?t.top+w/2-k/2:"start"==i||"center"==i&&n<0?t.top-s:t.bottom-k+s)-f.top}if("nearest"==r?t.left<f.left?(y=t.left-(f.left+o),n>0&&t.right>f.right+y&&(y=t.right-f.right+o)):t.right>f.right&&(y=t.right-f.right+o,n<0&&t.left<f.left+y&&(y=t.left-(f.left+o))):y=("center"==r?t.left+(t.right-t.left)/2-(f.right-f.left)/2:"start"==r==a?t.left-o:t.right-(f.right-f.left)+o)-f.left,y||b)if(d)c.scrollBy(y,b);else{var x=0,S=0;if(b){var C=u.scrollTop;u.scrollTop+=b/m,S=(u.scrollTop-C)*m}if(y){var E=u.scrollLeft;u.scrollLeft+=y/p,x=(u.scrollLeft-E)*p}t={left:t.left-x,top:t.top-S,right:t.right-x,bottom:t.bottom-S},x&&Math.abs(x-y)<1&&(r="nearest"),S&&Math.abs(S-b)<1&&(i="nearest")}if(d)break;(t.top<f.top||t.bottom>f.bottom||t.left<f.left||t.right>f.right)&&(t={left:Math.max(t.left,f.left),right:Math.min(t.right,f.right),top:Math.max(t.top,f.top),bottom:Math.min(t.bottom,f.bottom)}),u=u.assignedSlot||u.parentNode}else{if(11!=u.nodeType)break;u=u.host}}(this.view.scrollDOM,c,s.head<s.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,h),-h),Math.max(Math.min(e.yMargin,f),-f),this.view.textDirection==Yy.LTR),window.visualViewport&&window.innerHeight-window.visualViewport.height>1&&(a.top>window.pageYOffset+window.visualViewport.offsetTop+window.visualViewport.height||a.bottom<window.pageYOffset+window.visualViewport.offsetTop)){var d=this.view.docView.lineAt(s.head,1);d&&d.dom.scrollIntoView({block:"nearest"})}}}},{key:"lineHasWidget",value:function(e){var t=function(e){return e.isWidget()||e.children.some(t)};return t(this.tile.resolveBlock(e,1).tile)}},{key:"destroy",value:function(){Cw(this.tile)}}])}();function Cw(e,t){var n=null==t?void 0:t.get(e);if(1!=n){null==n&&e.destroy();var r,i=D(e.children);try{for(i.s();!(r=i.n()).done;){Cw(r.value,t)}}catch(e){i.e(e)}finally{i.f()}}}function Ew(e,t){var n=e.observer.selectionRange;if(!n.focusNode)return null;var r=Uy(n.focusNode,n.focusOffset),i=Ky(n.focusNode,n.focusOffset),o=r||i;if(i&&r&&i.node!=r.node){var s=Zb.get(i.node);if(!s||s.isText()&&s.text!=i.node.nodeValue)o=i;else if(e.docView.lastCompositionAfterCursor){var a=Zb.get(r.node);!a||a.isText()&&a.text!=r.node.nodeValue||(o=i)}}if(e.docView.lastCompositionAfterCursor=o!=r,!o)return null;var l=t-o.offset;return{from:l,to:l+o.node.nodeValue.length,node:o.node}}var Aw=function(){return R(function e(){N(this,e),this.changes=[]},[{key:"compareRange",value:function(e,t){Cy(e,t,this.changes)}},{key:"comparePoint",value:function(e,t){Cy(e,t,this.changes)}},{key:"boundChange",value:function(e){Cy(e,e,this.changes)}}])}();var Mw=function(){return R(function e(){N(this,e),this.changes=[]},[{key:"compareRange",value:function(e,t){Cy(e,t,this.changes)}},{key:"comparePoint",value:function(){}},{key:"boundChange",value:function(e){Cy(e,e,this.changes)}}])}();var Ow=function(){function e(t){var n;return N(this,e),(n=O(this,e)).height=t,n}return I(e,vy),R(e,[{key:"toDOM",value:function(){var e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}},{key:"eq",value:function(e){return e.height==this.height}},{key:"updateDOM",value:function(e){return e.style.height=this.height+"px",!0}},{key:"editable",get:function(){return!0}},{key:"estimatedHeight",get:function(){return this.height}},{key:"ignoreEvent",value:function(){return!1}}])}();function Nw(e,t,n){var r=e.lineBlockAt(t);if(Array.isArray(r.type)){var i,o,s=D(r.type);try{for(s.s();!(o=s.n()).done;){var a=o.value;if(a.from>t)break;if(!(a.to<t)){if(a.from<t&&a.to>t)return a;i&&(a.type!=yy.Text||i.type==a.type&&!(n<0?a.from<t:a.to>t))||(i=a)}}}catch(e){s.e(e)}finally{s.f()}return i||r}return r}function Tw(e,t,n,r){for(var i=e.state.doc.lineAt(t.head),o=e.bidiSpans(i),s=e.textDirectionAt(i.from),a=t,l=null;;){var c=gb(i,o,s,a,n),u=mb;if(!c){if(i.number==(n?e.state.doc.lines:1))return a;u="\n",i=e.state.doc.line(i.number+(n?1:-1)),o=e.bidiSpans(i),c=e.visualLineSide(i,!n)}if(l){if(!l(u))return a}else{if(!r)return c;l=r(u)}a=c}}function Rw(e,t,n){for(var r,i=function(){var r,i=0,o=D(e);try{for(o.s();!(r=o.n()).done;){r.value.between(t-1,t+1,function(e,r,o){if(t>e&&t<r){var s=i||n||(t-e<r-t?-1:1);t=s<0?e:r,i=s}})}}catch(e){o.e(e)}finally{o.f()}if(!i)return{v:t}};;)if(r=i())return r.v}function Dw(e,t){for(var n=null,r=0;r<t.ranges.length;r++){var i=t.ranges[r],o=null;if(i.empty){var s=Rw(e,i.from,0);s!=i.from&&(o=Ng.cursor(s,-1))}else{var a=Rw(e,i.from,-1),l=Rw(e,i.to,1);a==i.from&&l==i.to||(o=Ng.range(i.from==i.anchor?a:l,i.from==i.head?a:l))}o&&(n||(n=t.ranges.slice()),n[r]=o)}return n?Ng.create(n,t.mainIndex):t}function Pw(e,t,n){var r=Rw(e.state.facet(qb).map(function(t){return t(e)}),n.from,t.head>n.from?-1:1);return r==n.from?n:Ng.cursor(r,r<n.from?1:-1)}var Lw=R(function e(t,n){N(this,e),this.pos=t,this.assoc=n});function Bw(e,t,n,r){for(var i,o=e.contentDOM.getBoundingClientRect(),s=o.top+e.viewState.paddingTop,a=t.x,l=t.y,c=l-s;;){if(c<0)return new Lw(0,1);if(c>e.viewState.docHeight)return new Lw(e.state.doc.length,-1);if(i=e.elementAtHeight(c),null==r)break;if(i.type==yy.Text){if(r<0?i.to<e.viewport.from:i.from>e.viewport.to)break;var u=e.docView.coordsAt(r<0?i.from:i.to,r>0?-1:1);if(u&&(r<0?u.top<=c+s:u.bottom>=c+s))break}var h=e.viewState.heightOracle.textHeight/2;c=r>0?i.bottom+h:i.top-h}if(e.viewport.from>=i.to||e.viewport.to<=i.from){if(n)return null;if(i.type==yy.Text){var f=function(e,t,n,r,i){var o=Math.round((r-t.left)*e.defaultCharacterWidth);if(e.lineWrapping&&n.height>1.5*e.defaultLineHeight){var s=e.viewState.heightOracle.textHeight;o+=Math.floor((i-n.top-.5*(e.defaultLineHeight-s))/s)*e.viewState.heightOracle.lineLength}var a=e.state.sliceDoc(n.from,n.to);return n.from+Wv(a,o,e.state.tabSize)}(e,o,i,a,l);return new Lw(f,f==i.from?1:-1)}}if(i.type!=yy.Text)return c<(i.top+i.bottom)/2?new Lw(i.from,1):new Lw(i.to,-1);var d=e.docView.lineAt(i.from,2);return d&&d.length==i.length||(d=e.docView.lineAt(i.from,-2)),new Iw(e,a,l,e.textDirectionAt(i.from)).scanTile(d,i.from)}var Iw=function(){return R(function e(t,n,r,i){N(this,e),this.view=t,this.x=n,this.y=r,this.baseDir=i,this.line=null,this.spans=null},[{key:"bidiSpansAt",value:function(e){return(!this.line||this.line.from>e||this.line.to<e)&&(this.line=this.view.state.doc.lineAt(e),this.spans=this.view.bidiSpans(this.line)),this}},{key:"baseDirAt",value:function(e,t){var n=this.bidiSpansAt(e),r=n.line,i=n.spans;return i[cb.find(i,e-r.from,-1,t)].level==this.baseDir}},{key:"dirAt",value:function(e,t){var n=this.bidiSpansAt(e),r=n.line,i=n.spans;return i[cb.find(i,e-r.from,-1,t)].dir}},{key:"bidiIn",value:function(e,t){var n=this.bidiSpansAt(e),r=n.spans,i=n.line;return r.length>1||r.length&&(r[0].level!=this.baseDir||r[0].to+i.from<t)}},{key:"scan",value:function(e,t){var n,r,i,o=0,s=e.length-1,a=new Set,l=this.bidiIn(e[0],e[s]),c=-1,u=1e9;e:for(;o<s;){var h=s-o,f=o+s>>1;t:if(a.has(f)){for(var d=o+Math.floor(Math.random()*h),p=0;p<h;p++){if(!a.has(d)){f=d;break t}++d==s&&(d=o)}break e}a.add(f);var m=t(f);if(m)for(var g=0;g<m.length;g++){var v=m[g],y=0;if(v.bottom<this.y)(!n||n.bottom<v.bottom)&&(n=v),y=1;else if(v.top>this.y)(!r||r.top>v.top)&&(r=v),y=-1;else{var b=v.left>this.x?this.x-v.left:v.right<this.x?this.x-v.right:0,w=Math.abs(b);w<u&&(c=f,u=w,i=v),b&&(y=b<0==(this.baseDir==Yy.LTR)?-1:1)}-1!=y||l&&!this.baseDirAt(e[f],1)?1!=y||l&&!this.baseDirAt(e[f+1],-1)||(o=f+1):s=f}}if(!i){var k=n&&(!r||this.y-n.bottom<r.top-this.y)?n:r;return this.y=(k.top+k.bottom)/2,this.scan(e,t)}var x=(l?this.dirAt(e[c],1):this.baseDir)==Yy.LTR;return{i:c,after:this.x>(i.left+i.right)/2==x}}},{key:"scanText",value:function(e,t){for(var n=[],r=0;r<e.length;r=pg(e.text,r))n.push(t+r);n.push(t+e.length);var i=this.scan(n,function(r){var i=n[r]-t,o=n[r+1]-t;return zy(e.dom,i,o).getClientRects()});return i.after?new Lw(n[i.i+1],-1):new Lw(n[i.i],1)}},{key:"scanTile",value:function(e,t){if(!e.length)return new Lw(t,1);if(1==e.children.length){var n=e.children[0];if(n.isText())return this.scanText(n,t);if(n.isComposite())return this.scanTile(n,t)}for(var r=[t],i=0,o=t;i<e.children.length;i++)r.push(o+=e.children[i].length);var s=this.scan(r,function(t){var n=e.children[t];return 48&n.flags?null:(1==n.dom.nodeType?n.dom:zy(n.dom,0,n.length)).getClientRects()}),a=e.children[s.i],l=r[s.i];return a.isText()?this.scanText(a,l):a.isComposite()?this.scanTile(a,l):s.after?new Lw(r[s.i+1],-1):new Lw(l,1)}}])}(),_w="￿",Fw=function(){return R(function e(t,n){N(this,e),this.points=t,this.view=n,this.text="",this.lineSeparator=n.state.facet(bv.lineSeparator)},[{key:"append",value:function(e){this.text+=e}},{key:"lineBreak",value:function(){this.text+=_w}},{key:"readRange",value:function(e,t){if(!e)return this;for(var n=e.parentNode,r=e;;){this.findPointBefore(n,r);var i=this.text.length;this.readNode(r);var o=Zb.get(r),s=r.nextSibling;if(s==t){(null==o?void 0:o.breakAfter)&&!s&&n!=this.view.contentDOM&&this.lineBreak();break}var a=Zb.get(s);(o&&a?o.breakAfter:(o?o.breakAfter:Dy(r))||Dy(s)&&("BR"!=r.nodeName||(null==o?void 0:o.isWidget()))&&this.text.length>i)&&!jw(s,t)&&this.lineBreak(),r=s}return this.findPointBefore(n,t),this}},{key:"readTextNode",value:function(e){var t,n=e.nodeValue,r=D(this.points);try{for(r.s();!(t=r.n()).done;){var i=t.value;i.node==e&&(i.pos=this.text.length+Math.min(i.offset,n.length))}}catch(e){r.e(e)}finally{r.f()}for(var o=0,s=this.lineSeparator?null:/\r\n?|\n/g;;){var a=-1,l=1,c=void 0;if(this.lineSeparator?(a=n.indexOf(this.lineSeparator,o),l=this.lineSeparator.length):(c=s.exec(n))&&(a=c.index,l=c[0].length),this.append(n.slice(o,a<0?n.length:a)),a<0)break;if(this.lineBreak(),l>1){var u,h=D(this.points);try{for(h.s();!(u=h.n()).done;){var f=u.value;f.node==e&&f.pos>this.text.length&&(f.pos-=l-1)}}catch(e){h.e(e)}finally{h.f()}}o=a+l}}},{key:"readNode",value:function(e){var t=Zb.get(e),n=t&&t.overrideDOMText;if(null!=n){this.findPointInside(e,n.length);for(var r=n.iter();!r.next().done;)r.lineBreak?this.lineBreak():this.append(r.value)}else 3==e.nodeType?this.readTextNode(e):"BR"==e.nodeName?e.nextSibling&&this.lineBreak():1==e.nodeType&&this.readRange(e.firstChild,null)}},{key:"findPointBefore",value:function(e,t){var n,r=D(this.points);try{for(r.s();!(n=r.n()).done;){var i=n.value;i.node==e&&e.childNodes[i.offset]==t&&(i.pos=this.text.length)}}catch(e){r.e(e)}finally{r.f()}}},{key:"findPointInside",value:function(e,t){var n,r=D(this.points);try{for(r.s();!(n=r.n()).done;){var i=n.value;(3==e.nodeType?i.node==e:e.contains(i.node))&&(i.pos=this.text.length+(Ww(e,i.node,i.offset)?t:0))}}catch(e){r.e(e)}finally{r.f()}}}])}();function Ww(e,t,n){for(;;){if(!t||n<Ly(t))return!1;if(t==e)return!0;n=Ry(t)+1,t=t.parentNode}}function jw(e,t){for(var n;e!=t&&e;e=e.nextSibling){var r=Zb.get(e);if(!(null==r?void 0:r.isWidget()))return!1;r&&(n||(n=[])).push(r)}if(n){var i,o=D(n);try{for(o.s();!(i=o.n()).done;){var s=i.value.overrideDOMText;if(null==s?void 0:s.length)return!1}}catch(e){o.e(e)}finally{o.f()}}return!0}var Hw=R(function e(t,n){N(this,e),this.node=t,this.offset=n,this.pos=-1}),zw=R(function e(t,n,r,i){N(this,e),this.typeOver=i,this.bounds=null,this.text="",this.domChanged=n>-1;var o=t.docView,s=o.impreciseHead,a=o.impreciseAnchor;if(t.state.readOnly&&n>-1)this.newSel=null;else if(n>-1&&(this.bounds=Vw(t.docView.tile,n,r,0))){var l=s||a?[]:function(e){var t=[];if(e.root.activeElement!=e.contentDOM)return t;var n=e.observer.selectionRange,r=n.anchorNode,i=n.anchorOffset,o=n.focusNode,s=n.focusOffset;r&&(t.push(new Hw(r,i)),o==r&&s==i||t.push(new Hw(o,s)));return t}(t),c=new Fw(l,t);c.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=c.text,this.newSel=function(e,t){if(0==e.length)return null;var n=e[0].pos,r=2==e.length?e[1].pos:n;return n>-1&&r>-1?Ng.single(n+t,r+t):null}(l,this.bounds.from)}else{var u=t.observer.selectionRange,h=s&&s.node==u.focusNode&&s.offset==u.focusOffset||!My(t.contentDOM,u.focusNode)?t.state.selection.main.head:t.docView.posFromDOM(u.focusNode,u.focusOffset),f=a&&a.node==u.anchorNode&&a.offset==u.anchorOffset||!My(t.contentDOM,u.anchorNode)?t.state.selection.main.anchor:t.docView.posFromDOM(u.anchorNode,u.anchorOffset),d=t.viewport;if((hy.ios||hy.chrome)&&t.state.selection.main.empty&&h!=f&&(d.from>0||d.to<t.state.doc.length)){var p=Math.min(h,f),m=Math.max(h,f),g=d.from-p,v=d.to-m;0!=g&&1!=g&&0!=p||0!=v&&-1!=v&&m!=t.state.doc.length||(h=0,f=t.state.doc.length)}t.inputState.composing>-1&&t.state.selection.ranges.length>1?this.newSel=t.state.selection.replaceRange(Ng.range(f,h)):this.newSel=Ng.single(f,h)}});function Vw(e,t,n,r){if(e.isComposite()){for(var i=-1,o=-1,s=-1,a=-1,l=0,c=r,u=r;l<e.children.length;l++){var h=e.children[l],f=c+h.length;if(c<t&&f>n)return Vw(h,t,n,c);if(f>=t&&-1==i&&(i=l,o=c),c>n&&h.dom.parentNode==e.dom){s=l,a=u;break}u=f,c=f+h.breakAfter}return{from:o,to:a<0?r+e.length:a,startDOM:(i?e.children[i-1].dom.nextSibling:null)||e.dom.firstChild,endDOM:s<e.children.length&&s>=0?e.children[s].dom:null}}return e.isText()?{from:r,to:r+e.length,startDOM:e.dom,endDOM:e.dom.nextSibling}:null}function qw(e,t){var n,r=t.newSel,i=e.state.selection.main,o=e.inputState.lastKeyTime>Date.now()-100?e.inputState.lastKeyCode:-1;if(t.bounds){var s=t.bounds,a=s.from,l=s.to,c=i.from,u=null;(8===o||hy.android&&t.text.length<l-a)&&(c=i.to,u="end");var h=Kw(e.state.doc.sliceString(a,l,_w),t.text,c-a,u);h&&(hy.chrome&&13==o&&h.toB==h.from+2&&t.text.slice(h.from,h.toB)==_w+_w&&h.toB--,n={from:a+h.from,to:a+h.toA,insert:ig.of(t.text.slice(h.from,h.toB).split(_w))})}else r&&(!e.hasFocus&&e.state.facet(Lb)||Gw(r,i))&&(r=null);if(!n&&!r)return!1;if(!n&&t.typeOver&&!i.empty&&r&&r.main.empty?n={from:i.from,to:i.to,insert:e.state.doc.slice(i.from,i.to)}:(hy.mac||hy.android)&&n&&n.from==n.to&&n.from==i.head-1&&/^\. ?$/.test(n.insert.toString())&&"off"==e.contentDOM.getAttribute("autocorrect")?(r&&2==n.insert.length&&(r=Ng.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:ig.of([n.insert.toString().replace("."," ")])}):n&&n.from>=i.from&&n.to<=i.to&&(n.from!=i.from||n.to!=i.to)&&i.to-i.from-(n.to-n.from)<=4?n={from:i.from,to:i.to,insert:e.state.doc.slice(i.from,n.from).append(n.insert).append(e.state.doc.slice(n.to,i.to))}:e.state.doc.lineAt(i.from).to<i.to&&e.docView.lineHasWidget(i.to)&&e.inputState.insertingTextAt>Date.now()-50?n={from:i.from,to:i.to,insert:e.state.toText(e.inputState.insertingText)}:hy.chrome&&n&&n.from==n.to&&n.from==i.head&&"\n "==n.insert.toString()&&e.lineWrapping&&(r&&(r=Ng.single(r.main.anchor-1,r.main.head-1)),n={from:i.from,to:i.to,insert:ig.of([" "])}),n)return Uw(e,n,r,o);if(r&&!Gw(r,i)){var f=!1,d="select";return e.inputState.lastSelectionTime>Date.now()-50&&("select"==e.inputState.lastSelectionOrigin&&(f=!0),"select.pointer"==(d=e.inputState.lastSelectionOrigin)&&(r=Dw(e.state.facet(qb).map(function(t){return t(e)}),r))),e.dispatch({selection:r,scrollIntoView:f,userEvent:d}),!0}return!1}function Uw(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:-1;if(hy.ios&&e.inputState.flushIOSKey(t))return!0;var i=e.state.selection.main;if(hy.android&&(t.to==i.to&&(t.from==i.from||t.from==i.from-1&&" "==e.state.sliceDoc(t.from,i.from))&&1==t.insert.length&&2==t.insert.lines&&Vy(e.contentDOM,"Enter",13)||(t.from==i.from-1&&t.to==i.to&&0==t.insert.length||8==r&&t.insert.length<t.to-t.from&&t.to>i.head)&&Vy(e.contentDOM,"Backspace",8)||t.from==i.from&&t.to==i.to+1&&0==t.insert.length&&Vy(e.contentDOM,"Delete",46)))return!0;var o,s=t.insert.toString();e.inputState.composing>=0&&e.inputState.composing++;var a=function(){return o||(o=function(e,t,n){var r,i=e.state,o=i.selection.main,s=-1;if(t.from==t.to&&t.from<o.from||t.from>o.to){var a=t.from<o.from?-1:1,l=a<0?o.from:o.to,c=Rw(i.facet(qb).map(function(t){return t(e)}),l,a);t.from==c&&(s=c)}if(s>-1)r={changes:t,selection:Ng.cursor(t.from+t.insert.length,-1)};else if(t.from>=o.from&&t.to<=o.to&&t.to-t.from>=(o.to-o.from)/3&&(!n||n.main.empty&&n.main.from==t.from+t.insert.length)&&e.inputState.composing<0){var u=o.from<t.from?i.sliceDoc(o.from,t.from):"",h=o.to>t.to?i.sliceDoc(t.to,o.to):"";r=i.replaceSelection(e.state.toText(u+t.insert.sliceString(0,void 0,e.state.lineBreak)+h))}else{var f=i.changes(t),d=n&&n.main.to<=f.newLength?n.main:void 0;if(i.selection.ranges.length>1&&(e.inputState.composing>=0||e.inputState.compositionPendingChange)&&t.to<=o.to+10&&t.to>=o.to-10){var p,m=e.state.sliceDoc(t.from,t.to),g=n&&Ew(e,n.main.head);if(g){var v=t.insert.length-(t.to-t.from);p={from:g.from,to:g.to-v}}else p=e.state.doc.lineAt(o.head);var y=o.to-t.to;r=i.changeByRange(function(n){if(n.from==o.from&&n.to==o.to)return{changes:f,range:d||n.map(f)};var r=n.to-y,s=r-m.length;if(e.state.sliceDoc(s,r)!=m||r>=p.from&&s<=p.to)return{range:n};var a=i.changes({from:s,to:r,insert:t.insert}),l=n.to-o.to;return{changes:a,range:d?Ng.range(Math.max(0,d.anchor+l),Math.max(0,d.head+l)):n.map(a)}})}else r={changes:f,selection:d&&i.selection.replaceRange(d)}}var b="input.type";(e.composing||e.inputState.compositionPendingChange&&e.inputState.compositionEndedAt>Date.now()-50)&&(e.inputState.compositionPendingChange=!1,b+=".compose",e.inputState.compositionFirstChange&&(b+=".start",e.inputState.compositionFirstChange=!1));return i.update(r,{userEvent:b,scrollIntoView:!0})}(e,t,n))};return e.state.facet(Sb).some(function(n){return n(e,t.from,t.to,s,a)})||e.dispatch(a()),!0}function Kw(e,t,n,r){for(var i=Math.min(e.length,t.length),o=0;o<i&&e.charCodeAt(o)==t.charCodeAt(o);)o++;if(o==i&&e.length==t.length)return null;for(var s=e.length,a=t.length;s>0&&a>0&&e.charCodeAt(s-1)==t.charCodeAt(a-1);)s--,a--;"end"==r&&(n-=s+Math.max(0,o-Math.min(s,a))-o);if(s<o&&e.length<t.length)a=(o-=n<=o&&n>=s?o-n:0)+(a-s),s=o;else if(a<o){s=(o-=n<=o&&n>=a?o-n:0)+(s-a),a=o}return{from:o,toA:s,toB:a}}function Gw(e,t){return t.head==e.main.head&&t.anchor==e.main.anchor}var Yw=function(){return R(function e(t){N(this,e),this.view=t,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=t.hasFocus,hy.safari&&t.contentDOM.addEventListener("input",function(){return null}),hy.gecko&&function(e){vk.has(e)||(vk.add(e),e.addEventListener("copy",function(){}),e.addEventListener("cut",function(){}))}(t.contentDOM.ownerDocument)},[{key:"setSelectionOrigin",value:function(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}},{key:"handleEvent",value:function(e){var t=this;(function(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(var n,r=t.target;r!=e.contentDOM;r=r.parentNode)if(!r||11==r.nodeType||(n=Zb.get(r))&&n.isWidget()&&!n.isHidden&&n.widget.ignoreEvent(t))return!1;return!0})(this.view,e)&&!this.ignoreDuringComposition(e)&&("keydown"==e.type&&this.keydown(e)||(0!=this.view.updateState?Promise.resolve().then(function(){return t.runHandlers(e.type,e)}):this.runHandlers(e.type,e)))}},{key:"runHandlers",value:function(e,t){var n=this.handlers[e];if(n){var r,i=D(n.observers);try{for(i.s();!(r=i.n()).done;){(0,r.value)(this.view,t)}}catch(e){i.e(e)}finally{i.f()}var o,s=D(n.handlers);try{for(s.s();!(o=s.n()).done;){var a=o.value;if(t.defaultPrevented)break;if(a(this.view,t)){t.preventDefault();break}}}catch(e){s.e(e)}finally{s.f()}}}},{key:"ensureHandlers",value:function(e){var t=function(e){var t=Object.create(null);function n(e){return t[e]||(t[e]={observers:[],handlers:[]})}var r,i=D(e);try{for(i.s();!(r=i.n()).done;){var o=r.value,s=o.spec,a=s&&s.plugin.domEventHandlers,l=s&&s.plugin.domEventObservers;if(a)for(var c in a){var u=a[c];u&&n(c).handlers.push($w(o.value,u))}if(l)for(var h in l){var f=l[h];f&&n(h).observers.push($w(o.value,f))}}}catch(e){i.e(e)}finally{i.f()}for(var d in tk)n(d).handlers.push(tk[d]);for(var p in nk)n(p).observers.push(nk[p]);return t}(e),n=this.handlers,r=this.view.contentDOM;for(var i in t)if("scroll"!=i){var o=!t[i].handlers.length,s=n[i];s&&o!=!s.handlers.length&&(r.removeEventListener(i,this.handleEvent),s=null),s||r.addEventListener(i,this.handleEvent,{passive:o})}for(var a in n)"scroll"==a||t[a]||r.removeEventListener(a,this.handleEvent);this.handlers=t}},{key:"keydown",value:function(e){var t,n=this;return this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),9==e.keyCode&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode)||(this.tabFocusMode>0&&27!=e.keyCode&&Qw.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),!hy.android||!hy.chrome||e.synthetic||13!=e.keyCode&&8!=e.keyCode?!hy.ios||e.synthetic||e.altKey||e.metaKey||!((t=Xw.find(function(t){return t.keyCode==e.keyCode}))&&!e.ctrlKey||Jw.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey)?(229!=e.keyCode&&this.view.observer.forceFlush(),!1):(this.pendingIOSKey=t||e,setTimeout(function(){return n.flushIOSKey()},250),!0):(this.view.observer.delayAndroidKey(e.key,e.keyCode),!0))}},{key:"flushIOSKey",value:function(e){var t=this.pendingIOSKey;return!!t&&(!("Enter"==t.key&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString()))&&(this.pendingIOSKey=void 0,Vy(this.view.contentDOM,t.key,t.keyCode,t instanceof KeyboardEvent?t:void 0)))}},{key:"ignoreDuringComposition",value:function(e){return!(!/^key/.test(e.type)||e.synthetic)&&(this.composing>0||!!(hy.safari&&!hy.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100)&&(this.compositionPendingKey=!1,!0))}},{key:"startMouseSelection",value:function(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}},{key:"update",value:function(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}},{key:"destroy",value:function(){this.mouseSelection&&this.mouseSelection.destroy()}}])}();function $w(e,t){return function(n,r){try{return t.call(e,r,n)}catch(e){Pb(n.state,e)}}}var Xw=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],Jw="dthko",Qw=[16,17,18,20,91,92,224,225];function Zw(e){return.7*Math.max(0,e)+8}var ek=function(){return R(function e(t,n,r,i){N(this,e),this.view=t,this.startEvent=n,this.style=r,this.mustSelect=i,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=n,this.scrollParents=function(e){for(var t,n,r=e.ownerDocument,i=e.parentNode;i&&!(i==r.body||t&&n);)if(1==i.nodeType)!n&&i.scrollHeight>i.clientHeight&&(n=i),!t&&i.scrollWidth>i.clientWidth&&(t=i),i=i.assignedSlot||i.parentNode;else{if(11!=i.nodeType)break;i=i.host}return{x:t,y:n}}(t.contentDOM),this.atoms=t.state.facet(qb).map(function(e){return e(t)});var o=t.contentDOM.ownerDocument;o.addEventListener("mousemove",this.move=this.move.bind(this)),o.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=n.shiftKey,this.multiple=t.state.facet(bv.allowMultipleSelections)&&function(e,t){var n=e.state.facet(yb);return n.length?n[0](t):hy.mac?t.metaKey:t.ctrlKey}(t,n),this.dragging=!(!function(e,t){var n=e.state.selection.main;if(n.empty)return!1;var r=Ay(e.root);if(!r||0==r.rangeCount)return!0;for(var i=r.getRangeAt(0).getClientRects(),o=0;o<i.length;o++){var s=i[o];if(s.left<=t.clientX&&s.right>=t.clientX&&s.top<=t.clientY&&s.bottom>=t.clientY)return!0}return!1}(t,n)||1!=hk(n))&&null},[{key:"start",value:function(e){!1===this.dragging&&this.select(e)}},{key:"move",value:function(e){if(0==e.buttons)return this.destroy();if(!(this.dragging||null==this.dragging&&(t=this.startEvent,n=e,Math.max(Math.abs(t.clientX-n.clientX),Math.abs(t.clientY-n.clientY))<10))){var t,n;this.select(this.lastEvent=e);var r=0,i=0,o=0,s=0,a=this.view.win.innerWidth,l=this.view.win.innerHeight;if(this.scrollParents.x){var c=this.scrollParents.x.getBoundingClientRect();o=c.left,a=c.right}if(this.scrollParents.y){var u=this.scrollParents.y.getBoundingClientRect();s=u.top,l=u.bottom}var h=Yb(this.view);e.clientX-h.left<=o+6?r=-Zw(o-e.clientX):e.clientX+h.right>=a-6&&(r=Zw(e.clientX-a)),e.clientY-h.top<=s+6?i=-Zw(s-e.clientY):e.clientY+h.bottom>=l-6&&(i=Zw(e.clientY-l)),this.setScrollSpeed(r,i)}}},{key:"up",value:function(e){null==this.dragging&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}},{key:"destroy",value:function(){this.setScrollSpeed(0,0);var e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}},{key:"setScrollSpeed",value:function(e,t){var n=this;this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(function(){return n.scroll()},50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}},{key:"scroll",value:function(){var e=this.scrollSpeed,t=e.x,n=e.y;t&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=t,t=0),n&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=n,n=0),(t||n)&&this.view.win.scrollBy(t,n),!1===this.dragging&&this.select(this.lastEvent)}},{key:"select",value:function(e){var t=this.view,n=Dw(this.atoms,this.style.get(e,this.extend,this.multiple));!this.mustSelect&&n.eq(t.state.selection,!1===this.dragging)||this.view.dispatch({selection:n,userEvent:"select.pointer"}),this.mustSelect=!1}},{key:"update",value:function(e){var t=this;e.transactions.some(function(e){return e.isUserEvent("input.type")})?this.destroy():this.style.update(e)&&setTimeout(function(){return t.select(t.lastEvent)},20)}}])}();var tk=Object.create(null),nk=Object.create(null),rk=hy.ie&&hy.ie_version<15||hy.ios&&hy.webkit_version<604;function ik(e,t,n){var r,i=D(e.facet(t));try{for(i.s();!(r=i.n()).done;){n=(0,r.value)(n,e)}}catch(e){i.e(e)}finally{i.f()}return n}function ok(e,t){t=ik(e.state,Eb,t);var n,r=e.state,i=1,o=r.toText(t),s=o.lines==r.selection.ranges.length,a=null!=dk&&r.selection.ranges.every(function(e){return e.empty})&&dk==o.toString();if(a){var l=-1;n=r.changeByRange(function(e){var n=r.doc.lineAt(e.from);if(n.from==l)return{range:e};l=n.from;var a=r.toText((s?o.line(i++).text:t)+r.lineBreak);return{changes:{from:n.from,insert:a},range:Ng.cursor(e.from+a.length)}})}else n=s?r.changeByRange(function(e){var t=o.line(i++);return{changes:{from:e.from,to:e.to,insert:t.text},range:Ng.cursor(e.from+t.length)}}):r.replaceSelection(o);e.dispatch(n,{userEvent:"input.paste",scrollIntoView:!0})}function sk(e,t,n,r){if(1==r)return Ng.cursor(t,n);if(2==r)return function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,r=e.charCategorizer(t),i=e.doc.lineAt(t),o=t-i.from;if(0==i.length)return Ng.cursor(t);0==o?n=1:o==i.length&&(n=-1);var s=o,a=o;n<0?s=pg(i.text,o,!1):a=pg(i.text,o);for(var l=r(i.text.slice(s,a));s>0;){var c=pg(i.text,s,!1);if(r(i.text.slice(c,s))!=l)break;s=c}for(;a<i.length;){var u=pg(i.text,a);if(r(i.text.slice(a,u))!=l)break;a=u}return Ng.range(s+i.from,a+i.from)}(e.state,t,n);var i=e.docView.lineAt(t,n),o=e.state.doc.lineAt(i?i.posAtEnd:t),s=i?i.posAtStart:o.from,a=i?i.posAtEnd:o.to;return a<e.state.doc.length&&a==o.to&&a++,Ng.range(s,a)}nk.scroll=function(e){e.inputState.lastScrollTop=e.scrollDOM.scrollTop,e.inputState.lastScrollLeft=e.scrollDOM.scrollLeft},tk.keydown=function(e,t){return e.inputState.setSelectionOrigin("select"),27==t.keyCode&&0!=e.inputState.tabFocusMode&&(e.inputState.tabFocusMode=Date.now()+2e3),!1},nk.touchstart=function(e,t){e.inputState.lastTouchTime=Date.now(),e.inputState.setSelectionOrigin("select.pointer")},nk.touchmove=function(e){e.inputState.setSelectionOrigin("select.pointer")},tk.mousedown=function(e,t){if(e.observer.flush(),e.inputState.lastTouchTime>Date.now()-2e3)return!1;var n,r=null,i=D(e.state.facet(wb));try{for(i.s();!(n=i.n()).done;){if(r=(0,n.value)(e,t))break}}catch(e){i.e(e)}finally{i.f()}if(r||0!=t.button||(r=function(e,t){var n=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),r=hk(t),i=e.state.selection;return{update:function(e){e.docChanged&&(n.pos=e.changes.mapPos(n.pos),i=i.map(e.changes))},get:function(t,o,s){var a,l=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),c=sk(e,l.pos,l.assoc,r);if(n.pos!=l.pos&&!o){var u=sk(e,n.pos,n.assoc,r),h=Math.min(u.from,c.from),f=Math.max(u.to,c.to);c=h<c.from?Ng.range(h,f):Ng.range(f,h)}return o?i.replaceRange(i.main.extend(c.from,c.to)):s&&1==r&&i.ranges.length>1&&(a=function(e,t){for(var n=0;n<e.ranges.length;n++){var r=e.ranges[n],i=r.from,o=r.to;if(i<=t&&o>=t)return Ng.create(e.ranges.slice(0,n).concat(e.ranges.slice(n+1)),e.mainIndex==n?0:e.mainIndex-(e.mainIndex>n?1:0))}return null}(i,l.pos))?a:s?i.addRange(c):Ng.create([c])}}}(e,t)),r){var o=!e.hasFocus;e.inputState.startMouseSelection(new ek(e,t,r,o)),o&&e.observer.ignore(function(){Hy(e.contentDOM);var t=e.root.activeElement;t&&!t.contains(e.contentDOM)&&t.blur()});var s=e.inputState.mouseSelection;if(s)return s.start(t),!1===s.dragging}else e.inputState.setSelectionOrigin("select.pointer");return!1};var ak=hy.ie&&hy.ie_version<=11,lk=null,ck=0,uk=0;function hk(e){if(!ak)return e.detail;var t=lk,n=uk;return lk=e,uk=Date.now(),ck=!t||n>Date.now()-400&&Math.abs(t.clientX-e.clientX)<2&&Math.abs(t.clientY-e.clientY)<2?(ck+1)%3:1}function fk(e,t,n,r){if(n=ik(e.state,Eb,n)){var i=e.posAtCoords({x:t.clientX,y:t.clientY},!1),o=e.inputState.draggedContent,s=r&&o&&function(e,t){var n=e.state.facet(bb);return n.length?n[0](t):hy.mac?!t.altKey:!t.ctrlKey}(e,t)?{from:o.from,to:o.to}:null,a={from:i,insert:n},l=e.state.changes(s?[s,a]:a);e.focus(),e.dispatch({changes:l,selection:{anchor:l.mapPos(i,-1),head:l.mapPos(i,1)},userEvent:s?"move.drop":"input.drop"}),e.inputState.draggedContent=null}}tk.dragstart=function(e,t){var n=e.state.selection.main;if(t.target.draggable){var r=e.docView.tile.nearest(t.target);if(r&&r.isWidget()){var i=r.posAtStart,o=i+r.length;(i>=n.to||o<=n.from)&&(n=Ng.range(i,o))}}var s=e.inputState;return s.mouseSelection&&(s.mouseSelection.dragging=!0),s.draggedContent=n,t.dataTransfer&&(t.dataTransfer.setData("Text",ik(e.state,Ab,e.state.sliceDoc(n.from,n.to))),t.dataTransfer.effectAllowed="copyMove"),!1},tk.dragend=function(e){return e.inputState.draggedContent=null,!1},tk.drop=function(e,t){if(!t.dataTransfer)return!1;if(e.state.readOnly)return!0;var n=t.dataTransfer.files;if(n&&n.length){for(var r=Array(n.length),i=0,o=function(){++i==n.length&&fk(e,t,r.filter(function(e){return null!=e}).join(e.state.lineBreak),!1)},s=function(e){var t=new FileReader;t.onerror=o,t.onload=function(){/[\x00-\x08\x0e-\x1f]{2}/.test(t.result)||(r[e]=t.result),o()},t.readAsText(n[e])},a=0;a<n.length;a++)s(a);return!0}var l=t.dataTransfer.getData("Text");return!!l&&(fk(e,t,l,!0),!0)},tk.paste=function(e,t){if(e.state.readOnly)return!0;e.observer.flush();var n=rk?null:t.clipboardData;return n?(ok(e,n.getData("text/plain")||n.getData("text/uri-list")),!0):(function(e){var t=e.dom.parentNode;if(t){var n=t.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(function(){e.focus(),n.remove(),ok(e,n.value)},50)}}(e),!1)};var dk=null;tk.copy=tk.cut=function(e,t){if(!Oy(e.contentDOM,e.observer.selectionRange))return!1;var n=function(e){var t,n=[],r=[],i=!1,o=D(e.selection.ranges);try{for(o.s();!(t=o.n()).done;){var s=t.value;s.empty||(n.push(e.sliceDoc(s.from,s.to)),r.push(s))}}catch(e){o.e(e)}finally{o.f()}if(!n.length){var a,l=-1,c=D(e.selection.ranges);try{for(c.s();!(a=c.n()).done;){var u=a.value.from,h=e.doc.lineAt(u);h.number>l&&(n.push(h.text),r.push({from:h.from,to:Math.min(e.doc.length,h.to+1)})),l=h.number}}catch(e){c.e(e)}finally{c.f()}i=!0}return{text:ik(e,Ab,n.join(e.lineBreak)),ranges:r,linewise:i}}(e.state),r=n.text,i=n.ranges,o=n.linewise;if(!r&&!o)return!1;dk=o?r:null,"cut"!=t.type||e.state.readOnly||e.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});var s=rk?null:t.clipboardData;return s?(s.clearData(),s.setData("text/plain",r),!0):(function(e,t){var n=e.dom.parentNode;if(n){var r=n.appendChild(document.createElement("textarea"));r.style.cssText="position: fixed; left: -10000px; top: 10px",r.value=t,r.focus(),r.selectionEnd=t.length,r.selectionStart=0,setTimeout(function(){r.remove(),e.focus()},50)}}(e,r),!1)};var pk=iv.define();function mk(e,t){var n,r=[],i=D(e.facet(Cb));try{for(i.s();!(n=i.n()).done;){var o=(0,n.value)(e,t);o&&r.push(o)}}catch(e){i.e(e)}finally{i.f()}return r.length?e.update({effects:r,annotations:pk.of(!0)}):null}function gk(e){setTimeout(function(){var t=e.hasFocus;if(t!=e.inputState.notifiedFocused){var n=mk(e.state,t);n?e.dispatch(n):e.update([])}},10)}nk.focus=function(e){e.inputState.lastFocusTime=Date.now(),e.scrollDOM.scrollTop||!e.inputState.lastScrollTop&&!e.inputState.lastScrollLeft||(e.scrollDOM.scrollTop=e.inputState.lastScrollTop,e.scrollDOM.scrollLeft=e.inputState.lastScrollLeft),gk(e)},nk.blur=function(e){e.observer.clearSelectionRange(),gk(e)},nk.compositionstart=nk.compositionupdate=function(e){e.observer.editContext||(null==e.inputState.compositionFirstChange&&(e.inputState.compositionFirstChange=!0),e.inputState.composing<0&&(e.inputState.composing=0))},nk.compositionend=function(e){e.observer.editContext||(e.inputState.composing=-1,e.inputState.compositionEndedAt=Date.now(),e.inputState.compositionPendingKey=!0,e.inputState.compositionPendingChange=e.observer.pendingRecords().length>0,e.inputState.compositionFirstChange=null,hy.chrome&&hy.android?e.observer.flushSoon():e.inputState.compositionPendingChange?Promise.resolve().then(function(){return e.observer.flush()}):setTimeout(function(){e.inputState.composing<0&&e.docView.hasComposition&&e.update([])},50))},nk.contextmenu=function(e){e.inputState.lastContextMenu=Date.now()},tk.beforeinput=function(e,t){var n,r,i;if("insertText"!=t.inputType&&"insertCompositionText"!=t.inputType||(e.inputState.insertingText=t.data,e.inputState.insertingTextAt=Date.now()),"insertReplacementText"==t.inputType&&e.observer.editContext){var o=null===(n=t.dataTransfer)||void 0===n?void 0:n.getData("text/plain"),s=t.getTargetRanges();if(o&&s.length){var a=s[0],l=e.posAtDOM(a.startContainer,a.startOffset),c=e.posAtDOM(a.endContainer,a.endOffset);return Uw(e,{from:l,to:c,insert:e.state.toText(o)},null),!0}}if(hy.chrome&&hy.android&&(i=Xw.find(function(e){return e.inputType==t.inputType}))&&(e.observer.delayAndroidKey(i.key,i.keyCode),"Backspace"==i.key||"Delete"==i.key)){var u=(null===(r=window.visualViewport)||void 0===r?void 0:r.height)||0;setTimeout(function(){var t;((null===(t=window.visualViewport)||void 0===t?void 0:t.height)||0)>u+10&&e.hasFocus&&(e.contentDOM.blur(),e.focus())},100)}return hy.ios&&"deleteContentForward"==t.inputType&&e.observer.flushSoon(),hy.safari&&"insertText"==t.inputType&&e.inputState.composing>=0&&setTimeout(function(){return nk.compositionend(e,t)},20),!1};var vk=new Set;var yk=["pre-wrap","normal","pre-line","break-spaces"],bk=!1;function wk(){bk=!1}var kk=function(){return R(function e(t){N(this,e),this.lineWrapping=t,this.doc=ig.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30},[{key:"heightForGap",value:function(e,t){var n=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(n+=Math.max(0,Math.ceil((t-e-n*this.lineLength*.5)/this.lineLength))),this.lineHeight*n}},{key:"heightForLine",value:function(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}},{key:"setDoc",value:function(e){return this.doc=e,this}},{key:"mustRefreshForWrapping",value:function(e){return yk.indexOf(e)>-1!=this.lineWrapping}},{key:"mustRefreshForHeights",value:function(e){for(var t=!1,n=0;n<e.length;n++){var r=e[n];r<0?n++:this.heightSamples[Math.floor(10*r)]||(t=!0,this.heightSamples[Math.floor(10*r)]=!0)}return t}},{key:"refresh",value:function(e,t,n,r,i,o){var s=yk.indexOf(e)>-1,a=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=s||Math.abs(n-this.charWidth)>.1;if(this.lineWrapping=s,this.lineHeight=t,this.charWidth=n,this.textHeight=r,this.lineLength=i,a){this.heightSamples={};for(var l=0;l<o.length;l++){var c=o[l];c<0?l++:this.heightSamples[Math.floor(10*c)]=!0}}return a}}])}(),xk=function(){return R(function e(t,n){N(this,e),this.from=t,this.heights=n,this.index=0},[{key:"more",get:function(){return this.index<this.heights.length}}])}(),Sk=function(){function e(t,n,r,i,o){N(this,e),this.from=t,this.length=n,this.top=r,this.height=i,this._content=o}return R(e,[{key:"type",get:function(){return"number"==typeof this._content?yy.Text:Array.isArray(this._content)?this._content:this._content.type}},{key:"to",get:function(){return this.from+this.length}},{key:"bottom",get:function(){return this.top+this.height}},{key:"widget",get:function(){return this._content instanceof xy?this._content.widget:null}},{key:"widgetLineBreaks",get:function(){return"number"==typeof this._content?this._content:0}},{key:"join",value:function(t){var n=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(t._content)?t._content:[t]);return new e(this.from,this.length+t.length,this.top,this.height+t.height,n)}}])}(),Ck=function(e){return e[e.ByPos=0]="ByPos",e[e.ByHeight=1]="ByHeight",e[e.ByPosNoHeight=2]="ByPosNoHeight",e}(Ck||(Ck={})),Ek=.001,Ak=function(){function e(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2;N(this,e),this.length=t,this.height=n,this.flags=r}return R(e,[{key:"outdated",get:function(){return(2&this.flags)>0},set:function(e){this.flags=(e?2:0)|-3&this.flags}},{key:"setHeight",value:function(e){this.height!=e&&(Math.abs(this.height-e)>Ek&&(bk=!0),this.height=e)}},{key:"replace",value:function(t,n,r){return e.of(r)}},{key:"decomposeLeft",value:function(e,t){t.push(this)}},{key:"decomposeRight",value:function(e,t){t.push(this)}},{key:"applyChanges",value:function(e,t,n,r){for(var i=this,o=n.doc,s=r.length-1;s>=0;s--){var a=r[s],l=a.fromA,c=a.toA,u=a.fromB,h=a.toB,f=i.lineAt(l,Ck.ByPosNoHeight,n.setDoc(t),0,0),d=f.to>=c?f:i.lineAt(c,Ck.ByPosNoHeight,n,0,0);for(h+=d.to-c,c=d.to;s>0&&f.from<=r[s-1].toA;)l=r[s-1].fromA,u=r[s-1].fromB,s--,l<f.from&&(f=i.lineAt(l,Ck.ByPosNoHeight,n,0,0));u+=f.from-l,l=f.from;var p=Lk.build(n.setDoc(o),e,u,h);i=Mk(i,i.replace(l,c,p))}return i.updateHeight(n,0)}}],[{key:"empty",value:function(){return new Tk(0,0,0)}},{key:"of",value:function(t){if(1==t.length)return t[0];for(var n=0,r=t.length,i=0,o=0;;)if(n==r)if(i>2*o){var s=t[n-1];s.break?t.splice(--n,1,s.left,null,s.right):t.splice(--n,1,s.left,s.right),r+=1+s.break,i-=s.size}else{if(!(o>2*i))break;var a=t[r];a.break?t.splice(r,1,a.left,null,a.right):t.splice(r,1,a.left,a.right),r+=2+a.break,o-=a.size}else if(i<o){var l=t[n++];l&&(i+=l.size)}else{var c=t[--r];c&&(o+=c.size)}var u=0;return null==t[n-1]?(u=1,n--):null==t[n]&&(u=1,r++),new Dk(e.of(t.slice(0,n)),u,e.of(t.slice(r)))}}])}();function Mk(e,t){return e==t?e:(e.constructor!=t.constructor&&(bk=!0),t)}Ak.prototype.size=1;var Ok=by.replace({}),Nk=function(){function e(t,n,r){var i;return N(this,e),(i=O(this,e,[t,n])).deco=r,i.spaceAbove=0,i}return I(e,Ak),R(e,[{key:"mainBlock",value:function(e,t){return new Sk(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}},{key:"blockAt",value:function(e,t,n,r){return this.spaceAbove&&e<n+this.spaceAbove?new Sk(r,0,n,this.spaceAbove,Ok):this.mainBlock(n,r)}},{key:"lineAt",value:function(e,t,n,r,i){var o=this.mainBlock(r,i);return this.spaceAbove?this.blockAt(0,n,r,i).join(o):o}},{key:"forEachLine",value:function(e,t,n,r,i,o){e<=i+this.length&&t>=i&&o(this.lineAt(0,Ck.ByPos,n,r,i))}},{key:"setMeasuredHeight",value:function(e){var t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}},{key:"updateHeight",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>3?arguments[3]:void 0;return n&&n.from<=t&&n.more&&this.setMeasuredHeight(n),this.outdated=!1,this}},{key:"toString",value:function(){return"block(".concat(this.length,")")}}])}(),Tk=function(){function e(t,n,r){var i;return N(this,e),(i=O(this,e,[t,n,null])).collapsed=0,i.widgetHeight=0,i.breaks=0,i.spaceAbove=r,i}return I(e,Nk),R(e,[{key:"mainBlock",value:function(e,t){return new Sk(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}},{key:"replace",value:function(t,n,r){var i=r[0];return 1==r.length&&(i instanceof e||i instanceof Rk&&4&i.flags)&&Math.abs(this.length-i.length)<10?(i instanceof Rk?i=new e(i.length,this.height,this.spaceAbove):i.height=this.height,this.outdated||(i.outdated=!1),i):Ak.of(r)}},{key:"updateHeight",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=arguments.length>3?arguments[3]:void 0;return r&&r.from<=t&&r.more?this.setMeasuredHeight(r):(n||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}},{key:"toString",value:function(){return"line(".concat(this.length).concat(this.collapsed?-this.collapsed:"").concat(this.widgetHeight?":"+this.widgetHeight:"",")")}}])}(),Rk=function(){function e(t){return N(this,e),O(this,e,[t,0])}return I(e,Ak),R(e,[{key:"heightMetrics",value:function(e,t){var n,r=e.doc.lineAt(t).number,i=e.doc.lineAt(t+this.length).number,o=i-r+1,s=0;if(e.lineWrapping){var a=Math.min(this.height,e.lineHeight*o);n=a/o,this.length>o+1&&(s=(this.height-a)/(this.length-o-1))}else n=this.height/o;return{firstLine:r,lastLine:i,perLine:n,perChar:s}}},{key:"blockAt",value:function(e,t,n,r){var i=this.heightMetrics(t,r),o=i.firstLine,s=i.lastLine,a=i.perLine,l=i.perChar;if(t.lineWrapping){var c=r+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-n)/this.height))*this.length)),u=t.doc.lineAt(c),h=a+u.length*l,f=Math.max(n,e-h/2);return new Sk(u.from,u.length,f,h,0)}var d=Math.max(0,Math.min(s-o,Math.floor((e-n)/a))),p=t.doc.line(o+d),m=p.from,g=p.length;return new Sk(m,g,n+a*d,a,0)}},{key:"lineAt",value:function(e,t,n,r,i){if(t==Ck.ByHeight)return this.blockAt(e,n,r,i);if(t==Ck.ByPosNoHeight){var o=n.doc.lineAt(e),s=o.from,a=o.to;return new Sk(s,a-s,0,0,0)}var l=this.heightMetrics(n,i),c=l.firstLine,u=l.perLine,h=l.perChar,f=n.doc.lineAt(e),d=u+f.length*h,p=f.number-c,m=r+u*p+h*(f.from-i-p);return new Sk(f.from,f.length,Math.max(r,Math.min(m,r+this.height-d)),d,0)}},{key:"forEachLine",value:function(e,t,n,r,i,o){e=Math.max(e,i),t=Math.min(t,i+this.length);for(var s=this.heightMetrics(n,i),a=s.firstLine,l=s.perLine,c=s.perChar,u=e,h=r;u<=t;){var f=n.doc.lineAt(u);if(u==e){var d=f.number-a;h+=l*d+c*(e-i-d)}var p=l+c*f.length;o(new Sk(f.from,f.length,h,p,0)),h+=p,u=f.to+1}}},{key:"replace",value:function(t,n,r){var i=this.length-n;if(i>0){var o=r[r.length-1];o instanceof e?r[r.length-1]=new e(o.length+i):r.push(null,new e(i-1))}if(t>0){var s=r[0];s instanceof e?r[0]=new e(t+s.length):r.unshift(new e(t-1),null)}return Ak.of(r)}},{key:"decomposeLeft",value:function(t,n){n.push(new e(t-1),null)}},{key:"decomposeRight",value:function(t,n){n.push(null,new e(this.length-t-1))}},{key:"updateHeight",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3?arguments[3]:void 0,o=n+this.length;if(i&&i.from<=n+this.length&&i.more){var s=[],a=Math.max(n,i.from),l=-1;for(i.from>n&&s.push(new e(i.from-n-1).updateHeight(t,n));a<=o&&i.more;){var c=t.doc.lineAt(a).length;s.length&&s.push(null);var u=i.heights[i.index++],h=0;u<0&&(h=-u,u=i.heights[i.index++]),-1==l?l=u:Math.abs(u-l)>=Ek&&(l=-2);var f=new Tk(c,u,h);f.outdated=!1,s.push(f),a+=c+1}a<=o&&s.push(null,new e(o-a).updateHeight(t,a));var d=Ak.of(s);return(l<0||Math.abs(d.height-this.height)>=Ek||Math.abs(l-this.heightMetrics(t,n).perLine)>=Ek)&&(bk=!0),Mk(this,d)}return(r||this.outdated)&&(this.setHeight(t.heightForGap(n,n+this.length)),this.outdated=!1),this}},{key:"toString",value:function(){return"gap(".concat(this.length,")")}}])}(),Dk=function(){function e(t,n,r){var i;return N(this,e),(i=O(this,e,[t.length+n+r.length,t.height+r.height,n|(t.outdated||r.outdated?2:0)])).left=t,i.right=r,i.size=t.size+r.size,i}return I(e,Ak),R(e,[{key:"break",get:function(){return 1&this.flags}},{key:"blockAt",value:function(e,t,n,r){var i=n+this.left.height;return e<i?this.left.blockAt(e,t,n,r):this.right.blockAt(e,t,i,r+this.left.length+this.break)}},{key:"lineAt",value:function(e,t,n,r,i){var o=r+this.left.height,s=i+this.left.length+this.break,a=t==Ck.ByHeight?e<o:e<s,l=a?this.left.lineAt(e,t,n,r,i):this.right.lineAt(e,t,n,o,s);if(this.break||(a?l.to<s:l.from>s))return l;var c=t==Ck.ByPosNoHeight?Ck.ByPosNoHeight:Ck.ByPos;return a?l.join(this.right.lineAt(s,c,n,o,s)):this.left.lineAt(s,c,n,r,i).join(l)}},{key:"forEachLine",value:function(e,t,n,r,i,o){var s=r+this.left.height,a=i+this.left.length+this.break;if(this.break)e<a&&this.left.forEachLine(e,t,n,r,i,o),t>=a&&this.right.forEachLine(e,t,n,s,a,o);else{var l=this.lineAt(a,Ck.ByPos,n,r,i);e<l.from&&this.left.forEachLine(e,l.from-1,n,r,i,o),l.to>=e&&l.from<=t&&o(l),t>l.to&&this.right.forEachLine(l.to+1,t,n,s,a,o)}}},{key:"replace",value:function(e,t,n){var r=this.left.length+this.break;if(t<r)return this.balanced(this.left.replace(e,t,n),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-r,t-r,n));var i=[];e>0&&this.decomposeLeft(e,i);var o,s=i.length,a=D(n);try{for(a.s();!(o=a.n()).done;){var l=o.value;i.push(l)}}catch(e){a.e(e)}finally{a.f()}if(e>0&&Pk(i,s-1),t<this.length){var c=i.length;this.decomposeRight(t,i),Pk(i,c)}return Ak.of(i)}},{key:"decomposeLeft",value:function(e,t){var n=this.left.length;if(e<=n)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&e>=++n&&t.push(null),e>n&&this.right.decomposeLeft(e-n,t)}},{key:"decomposeRight",value:function(e,t){var n=this.left.length,r=n+this.break;if(e>=r)return this.right.decomposeRight(e-r,t);e<n&&this.left.decomposeRight(e,t),this.break&&e<r&&t.push(null),t.push(this.right)}},{key:"balanced",value:function(e,t){return e.size>2*t.size||t.size>2*e.size?Ak.of(this.break?[e,null,t]:[e,t]):(this.left=Mk(this.left,e),this.right=Mk(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}},{key:"updateHeight",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=arguments.length>3?arguments[3]:void 0,i=this.left,o=this.right,s=t+i.length+this.break,a=null;return r&&r.from<=t+i.length&&r.more?a=i=i.updateHeight(e,t,n,r):i.updateHeight(e,t,n),r&&r.from<=s+o.length&&r.more?a=o=o.updateHeight(e,s,n,r):o.updateHeight(e,s,n),a?this.balanced(i,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}},{key:"toString",value:function(){return this.left+(this.break?" ":"-")+this.right}}])}();function Pk(e,t){var n,r;null==e[t]&&(n=e[t-1])instanceof Rk&&(r=e[t+1])instanceof Rk&&e.splice(t-1,3,new Rk(n.length+1+r.length))}var Lk=function(){function e(t,n){N(this,e),this.pos=t,this.oracle=n,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=t}return R(e,[{key:"isCovered",get:function(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}},{key:"span",value:function(e,t){if(this.lineStart>-1){var n=Math.min(t,this.lineEnd),r=this.nodes[this.nodes.length-1];r instanceof Tk?r.length+=n-this.pos:(n>this.pos||!this.isCovered)&&this.nodes.push(new Tk(n-this.pos,-1,0)),this.writtenTo=n,t>n&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}},{key:"point",value:function(e,t,n){if(e<t||n.heightRelevant){var r=n.widget?n.widget.estimatedHeight:0,i=n.widget?n.widget.lineBreaks:0;r<0&&(r=this.oracle.lineHeight);var o=t-e;n.block?this.addBlock(new Nk(o,r,n)):(o||i||r>=5)&&this.addLineDeco(r,i,o)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}},{key:"enterLine",value:function(){if(!(this.lineStart>-1)){var e=this.oracle.doc.lineAt(this.pos),t=e.from,n=e.to;this.lineStart=t,this.lineEnd=n,this.writtenTo<t&&((this.writtenTo<t-1||null==this.nodes[this.nodes.length-1])&&this.nodes.push(this.blankContent(this.writtenTo,t-1)),this.nodes.push(null)),this.pos>t&&this.nodes.push(new Tk(this.pos-t,-1,0)),this.writtenTo=this.pos}}},{key:"blankContent",value:function(e,t){var n=new Rk(t-e);return this.oracle.doc.lineAt(e).to==t&&(n.flags|=4),n}},{key:"ensureLine",value:function(){this.enterLine();var e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Tk)return e;var t=new Tk(0,-1,0);return this.nodes.push(t),t}},{key:"addBlock",value:function(e){this.enterLine();var t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}},{key:"addLineDeco",value:function(e,t,n){var r=this.ensureLine();r.length+=n,r.collapsed+=n,r.widgetHeight=Math.max(r.widgetHeight,e),r.breaks+=t,this.writtenTo=this.pos=this.pos+n}},{key:"finish",value:function(e){var t=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||t instanceof Tk||this.isCovered?(this.writtenTo<this.pos||null==t)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new Tk(0,-1,0));var n,r=e,i=D(this.nodes);try{for(i.s();!(n=i.n()).done;){var o=n.value;o instanceof Tk&&o.updateHeight(this.oracle,r),r+=o?o.length:1}}catch(e){i.e(e)}finally{i.f()}return this.nodes}}],[{key:"build",value:function(t,n,r,i){var o=new e(r,t);return Av.spans(n,r,i,o,0),o.finish(r)}}])}();var Bk=function(){return R(function e(){N(this,e),this.changes=[]},[{key:"compareRange",value:function(){}},{key:"comparePoint",value:function(e,t,n,r){(e<t||n&&n.heightRelevant||r&&r.heightRelevant)&&Cy(e,t,this.changes,5)}}])}();function Ik(e,t){for(var n=e.getBoundingClientRect(),r=e.ownerDocument,i=r.defaultView||window,o=Math.max(0,n.left),s=Math.min(i.innerWidth,n.right),a=Math.max(0,n.top),l=Math.min(i.innerHeight,n.bottom),c=e.parentNode;c&&c!=r.body;)if(1==c.nodeType){var u=c,h=window.getComputedStyle(u);if((u.scrollHeight>u.clientHeight||u.scrollWidth>u.clientWidth)&&"visible"!=h.overflow){var f=u.getBoundingClientRect();o=Math.max(o,f.left),s=Math.min(s,f.right),a=Math.max(a,f.top),l=Math.min(c==e.parentNode?i.innerHeight:l,f.bottom)}c="absolute"==h.position||"fixed"==h.position?u.offsetParent:u.parentNode}else{if(11!=c.nodeType)break;c=c.host}return{left:o-n.left,right:Math.max(o,s)-n.left,top:a-(n.top+t),bottom:Math.max(a,l)-(n.top+t)}}function _k(e,t){var n=e.getBoundingClientRect();return{left:0,right:n.right-n.left,top:t,bottom:n.bottom-(n.top+t)}}var Fk=function(){return R(function e(t,n,r,i){N(this,e),this.from=t,this.to=n,this.size=r,this.displaySize=i},[{key:"draw",value:function(e,t){return by.replace({widget:new Wk(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}}],[{key:"same",value:function(e,t){if(e.length!=t.length)return!1;for(var n=0;n<e.length;n++){var r=e[n],i=t[n];if(r.from!=i.from||r.to!=i.to||r.size!=i.size)return!1}return!0}}])}(),Wk=function(){function e(t,n){var r;return N(this,e),(r=O(this,e)).size=t,r.vertical=n,r}return I(e,vy),R(e,[{key:"eq",value:function(e){return e.size==this.size&&e.vertical==this.vertical}},{key:"toDOM",value:function(){var e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}},{key:"estimatedHeight",get:function(){return this.vertical?this.size:-1}}])}(),jk=function(){return R(function e(t){var n=this;N(this,e),this.state=t,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scrollTop=0,this.scrolledToBottom=!1,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=qk,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=Yy.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;var r=t.facet(jb).some(function(e){return"function"!=typeof e&&"cm-lineWrapping"==e.class});this.heightOracle=new kk(r),this.stateDeco=Uk(t),this.heightMap=Ak.empty().applyChanges(this.stateDeco,ig.empty,this.heightOracle.setDoc(t.doc),[new Xb(0,0,0,t.doc.length)]);for(var i=0;i<2&&(this.viewport=this.getViewport(0,null),this.updateForViewport());i++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=by.set(this.lineGaps.map(function(e){return e.draw(n,!1)})),this.computeVisibleRanges()},[{key:"updateForViewport",value:function(){for(var e=this,t=[this.viewport],n=this.state.selection.main,r=function(){var r=i?n.head:n.anchor;if(!t.some(function(e){var t=e.from,n=e.to;return r>=t&&r<=n})){var o=e.lineBlockAt(r),s=o.from,a=o.to;t.push(new Hk(s,a))}},i=0;i<=1;i++)r();return this.viewports=t.sort(function(e,t){return e.from-t.from}),this.updateScaler()}},{key:"updateScaler",value:function(){var e=this.scaler;return this.scaler=this.heightMap.height<=7e6?qk:new Kk(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}},{key:"updateViewportLines",value:function(){var e=this;this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,function(t){e.viewportLines.push(Gk(t,e.scaler))})}},{key:"update",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.state=e.state;var n=this.stateDeco;this.stateDeco=Uk(this.state);var r,i,o,s,a=e.changedRanges,l=Xb.extendWithRanges(a,(r=n,i=this.stateDeco,o=e?e.changes:kg.empty(this.state.doc.length),s=new Bk,Av.compare(r,i,o,s,0),s.changes)),c=this.heightMap.height,u=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);wk(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),l),(this.heightMap.height!=c||bk)&&(e.flags|=2),u?(this.scrollAnchorPos=e.changes.mapPos(u.from,-1),this.scrollAnchorHeight=u.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=c);var h=l.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<h.from||t.range.head>h.to)||!this.viewportIsAppropriate(h))&&(h=this.getViewport(0,t));var f=h.from!=this.viewport.from||h.to!=this.viewport.to;this.viewport=h,e.flags|=this.updateForViewport(),(f||!e.changes.empty||2&e.flags)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Ob)&&(this.mustEnforceCursorAssoc=!0)}},{key:"measure",value:function(e){var t=e.contentDOM,n=window.getComputedStyle(t),r=this.heightOracle,i=n.whiteSpace;this.defaultTextDirection="rtl"==n.direction?Yy.RTL:Yy.LTR;var o=this.heightOracle.mustRefreshForWrapping(i)||"refresh"===this.mustMeasureContent,s=t.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=s.height;this.contentDOMHeight=s.height,this.mustMeasureContent=!1;var l=0,c=0;if(s.width&&s.height){var u=_y(t,s),h=u.scaleX,f=u.scaleY;(h>.005&&Math.abs(this.scaleX-h)>.005||f>.005&&Math.abs(this.scaleY-f)>.005)&&(this.scaleX=h,this.scaleY=f,l|=16,o=a=!0)}var d=(parseInt(n.paddingTop)||0)*this.scaleY,p=(parseInt(n.paddingBottom)||0)*this.scaleY;this.paddingTop==d&&this.paddingBottom==p||(this.paddingTop=d,this.paddingBottom=p,l|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,l|=16);var m=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=m&&(this.scrollAnchorHeight=-1,this.scrollTop=m),this.scrolledToBottom=qy(e.scrollDOM);var g=(this.printing?_k:Ik)(t,this.paddingTop),v=g.top-this.pixelViewport.top,y=g.bottom-this.pixelViewport.bottom;this.pixelViewport=g;var b,w,k,x=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(x!=this.inView&&(this.inView=x,x&&(a=!0)),!(this.inView||this.scrollTarget||(b=e.dom,w=b.getBoundingClientRect(),k=b.ownerDocument.defaultView||window,w.left<k.innerWidth&&w.right>0&&w.top<k.innerHeight&&w.bottom>0)))return 0;var S=s.width;if(this.contentDOMWidth==S&&this.editorHeight==e.scrollDOM.clientHeight||(this.contentDOMWidth=s.width,this.editorHeight=e.scrollDOM.clientHeight,l|=16),a){var C=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(C)&&(o=!0),o||r.lineWrapping&&Math.abs(S-this.contentDOMWidth)>r.charWidth){var E=e.docView.measureTextSize(),A=E.lineHeight,M=E.charWidth,O=E.textHeight;(o=A>0&&r.refresh(i,A,M,O,Math.max(5,S/M),C))&&(e.docView.minWidth=0,l|=16)}v>0&&y>0?c=Math.max(v,y):v<0&&y<0&&(c=Math.min(v,y)),wk();var N,T=D(this.viewports);try{for(T.s();!(N=T.n()).done;){var R=N.value,P=R.from==this.viewport.from?C:e.docView.measureVisibleLineHeights(R);this.heightMap=(o?Ak.empty().applyChanges(this.stateDeco,ig.empty,this.heightOracle,[new Xb(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,o,new xk(R.from,P))}}catch(e){T.e(e)}finally{T.f()}bk&&(l|=2)}var L=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return L&&(2&l&&(l|=this.updateScaler()),this.viewport=this.getViewport(c,this.scrollTarget),l|=this.updateForViewport()),(2&l||L)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),l|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),l}},{key:"visibleTop",get:function(){return this.scaler.fromDOM(this.pixelViewport.top)}},{key:"visibleBottom",get:function(){return this.scaler.fromDOM(this.pixelViewport.bottom)}},{key:"getViewport",value:function(e,t){var n=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),r=this.heightMap,i=this.heightOracle,o=this.visibleTop,s=this.visibleBottom,a=new Hk(r.lineAt(o-1e3*n,Ck.ByHeight,i,0,0).from,r.lineAt(s+1e3*(1-n),Ck.ByHeight,i,0,0).to);if(t){var l=t.range.head;if(l<a.from||l>a.to){var c,u=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),h=r.lineAt(l,Ck.ByPos,i,0,0);c="center"==t.y?(h.top+h.bottom)/2-u/2:"start"==t.y||"nearest"==t.y&&l<a.from?h.top:h.bottom-u,a=new Hk(r.lineAt(c-500,Ck.ByHeight,i,0,0).from,r.lineAt(c+u+500,Ck.ByHeight,i,0,0).to)}}return a}},{key:"mapViewport",value:function(e,t){var n=t.mapPos(e.from,-1),r=t.mapPos(e.to,1);return new Hk(this.heightMap.lineAt(n,Ck.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(r,Ck.ByPos,this.heightOracle,0,0).to)}},{key:"viewportIsAppropriate",value:function(e){var t=e.from,n=e.to,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(!this.inView)return!0;var i=this.heightMap.lineAt(t,Ck.ByPos,this.heightOracle,0,0).top,o=this.heightMap.lineAt(n,Ck.ByPos,this.heightOracle,0,0).bottom,s=this.visibleTop,a=this.visibleBottom;return(0==t||i<=s-Math.max(10,Math.min(-r,250)))&&(n==this.state.doc.length||o>=a+Math.max(10,Math.min(r,250)))&&i>s-2e3&&o<a+2e3}},{key:"mapLineGaps",value:function(e,t){if(!e.length||t.empty)return e;var n,r=[],i=D(e);try{for(i.s();!(n=i.n()).done;){var o=n.value;t.touchesRange(o.from,o.to)||r.push(new Fk(t.mapPos(o.from),t.mapPos(o.to),o.size,o.displaySize))}}catch(e){i.e(e)}finally{i.f()}return r}},{key:"ensureLineGaps",value:function(e,t){var n=this,r=this.heightOracle.lineWrapping,i=r?1e4:2e3,o=i>>1,s=i<<1;if(this.defaultTextDirection!=Yy.LTR&&!r)return[];var a,l=[],c=function(i,s,a,u){if(!(s-i<o)){var h=n.state.selection.main,f=[h.from];h.empty||f.push(h.to);for(var d=0,p=f;d<p.length;d++){var m=p[d];if(m>i&&m<s)return c(i,m-10,a,u),void c(m+10,s,a,u)}var g=function(e,t){var n,r=D(e);try{for(r.s();!(n=r.n()).done;){var i=n.value;if(t(i))return i}}catch(e){r.e(e)}finally{r.f()}return}(e,function(e){return e.from>=a.from&&e.to<=a.to&&Math.abs(e.from-i)<o&&Math.abs(e.to-s)<o&&!f.some(function(t){return e.from<t&&e.to>t})});if(!g){if(s<a.to&&t&&r&&t.visibleRanges.some(function(e){return e.from<=s&&e.to>=s})){var v=t.moveToLineBoundary(Ng.cursor(s),!1,!0).head;v>i&&(s=v)}var y=n.gapSize(a,i,s,u);g=new Fk(i,s,y,r||y<2e6?y:2e6)}l.push(g)}},u=function(t){if(!(t.length<s||t.type!=yy.Text)){var o=function(e,t,n){var r=[],i=e,o=0;Av.spans(n,e,t,{span:function(){},point:function(e,t){e>i&&(r.push({from:i,to:e}),o+=e-i),i=t}},20),i<t&&(r.push({from:i,to:t}),o+=t-i);return{total:o,ranges:r}}(t.from,t.to,n.stateDeco);if(!(o.total<s)){var a,l,u=n.scrollTarget?n.scrollTarget.range.head:null;if(r){var h,f,d=i/n.heightOracle.lineLength*n.heightOracle.lineHeight;if(null!=u){var p=Vk(o,u),m=((n.visibleBottom-n.visibleTop)/2+d)/t.height;h=p-m,f=p+m}else h=(n.visibleTop-t.top-d)/t.height,f=(n.visibleBottom-t.top+d)/t.height;a=zk(o,h),l=zk(o,f)}else{var g=o.total*n.heightOracle.charWidth,v=i*n.heightOracle.charWidth,y=0;if(g>2e6){var b,w=D(e);try{for(w.s();!(b=w.n()).done;){var k=b.value;k.from>=t.from&&k.from<t.to&&k.size!=k.displaySize&&k.from*n.heightOracle.charWidth+y<n.pixelViewport.left&&(y=k.size-k.displaySize)}}catch(e){w.e(e)}finally{w.f()}}var x,S,C=n.pixelViewport.left+y,E=n.pixelViewport.right+y;if(null!=u){var A=Vk(o,u),M=((E-C)/2+v)/g;x=A-M,S=A+M}else x=(C-v)/g,S=(E+v)/g;a=zk(o,x),l=zk(o,S)}a>t.from&&c(t.from,a,t,o),l<t.to&&c(l,t.to,t,o)}}},h=D(this.viewportLines);try{for(h.s();!(a=h.n()).done;){var f=a.value;Array.isArray(f.type)?f.type.forEach(u):u(f)}}catch(e){h.e(e)}finally{h.f()}return l}},{key:"gapSize",value:function(e,t,n,r){var i=Vk(r,n)-Vk(r,t);return this.heightOracle.lineWrapping?e.height*i:r.total*this.heightOracle.charWidth*i}},{key:"updateLineGaps",value:function(e){var t=this;Fk.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=by.set(e.map(function(e){return e.draw(t,t.heightOracle.lineWrapping)})))}},{key:"computeVisibleRanges",value:function(e){var t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));var n=[];Av.spans(t,this.viewport.from,this.viewport.to,{span:function(e,t){n.push({from:e,to:t})},point:function(){}},20);var r=0;if(n.length!=this.visibleRanges.length)r=12;else for(var i=0;i<n.length&&!(8&r);i++){var o=this.visibleRanges[i],s=n[i];o.from==s.from&&o.to==s.to||(r|=4,e&&e.mapPos(o.from,-1)==s.from&&e.mapPos(o.to,1)==s.to||(r|=8))}return this.visibleRanges=n,r}},{key:"lineBlockAt",value:function(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(function(t){return t.from<=e&&t.to>=e})||Gk(this.heightMap.lineAt(e,Ck.ByPos,this.heightOracle,0,0),this.scaler)}},{key:"lineBlockAtHeight",value:function(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(function(t){return t.top<=e&&t.bottom>=e})||Gk(this.heightMap.lineAt(this.scaler.fromDOM(e),Ck.ByHeight,this.heightOracle,0,0),this.scaler)}},{key:"scrollAnchorAt",value:function(e){var t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}},{key:"elementAtHeight",value:function(e){return Gk(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}},{key:"docHeight",get:function(){return this.scaler.toDOM(this.heightMap.height)}},{key:"contentHeight",get:function(){return this.docHeight+this.paddingTop+this.paddingBottom}}])}(),Hk=R(function e(t,n){N(this,e),this.from=t,this.to=n});function zk(e,t){var n=e.total,r=e.ranges;if(t<=0)return r[0].from;if(t>=1)return r[r.length-1].to;for(var i=Math.floor(n*t),o=0;;o++){var s=r[o],a=s.from,l=s.to-a;if(i<=l)return a+i;i-=l}}function Vk(e,t){var n,r=0,i=D(e.ranges);try{for(i.s();!(n=i.n()).done;){var o=n.value,s=o.from,a=o.to;if(t<=a){r+=t-s;break}r+=a-s}}catch(e){i.e(e)}finally{i.f()}return r/e.total}var qk={toDOM:function(e){return e},fromDOM:function(e){return e},scale:1,eq:function(e){return e==this}};function Uk(e){var t=e.facet(Hb).filter(function(e){return"function"!=typeof e}),n=e.facet(Vb).filter(function(e){return"function"!=typeof e});return n.length&&t.push(Av.join(n)),t}var Kk=function(){function e(t,n,r){N(this,e);var i=0,o=0,s=0;this.viewports=r.map(function(e){var r=e.from,o=e.to,s=n.lineAt(r,Ck.ByPos,t,0,0).top,a=n.lineAt(o,Ck.ByPos,t,0,0).bottom;return i+=a-s,{from:r,to:o,top:s,bottom:a,domTop:0,domBottom:0}}),this.scale=(7e6-i)/(n.height-i);var a,l=D(this.viewports);try{for(l.s();!(a=l.n()).done;){var c=a.value;c.domTop=s+(c.top-o)*this.scale,s=c.domBottom=c.domTop+(c.bottom-c.top),o=c.bottom}}catch(e){l.e(e)}finally{l.f()}}return R(e,[{key:"toDOM",value:function(e){for(var t=0,n=0,r=0;;t++){var i=t<this.viewports.length?this.viewports[t]:null;if(!i||e<i.top)return r+(e-n)*this.scale;if(e<=i.bottom)return i.domTop+(e-i.top);n=i.bottom,r=i.domBottom}}},{key:"fromDOM",value:function(e){for(var t=0,n=0,r=0;;t++){var i=t<this.viewports.length?this.viewports[t]:null;if(!i||e<i.domTop)return n+(e-r)/this.scale;if(e<=i.domBottom)return i.top+(e-i.domTop);n=i.bottom,r=i.domBottom}}},{key:"eq",value:function(t){return t instanceof e&&(this.scale==t.scale&&this.viewports.length==t.viewports.length&&this.viewports.every(function(e,n){return e.from==t.viewports[n].from&&e.to==t.viewports[n].to}))}}])}();function Gk(e,t){if(1==t.scale)return e;var n=t.toDOM(e.top),r=t.toDOM(e.bottom);return new Sk(e.from,e.length,n,r-n,Array.isArray(e._content)?e._content.map(function(e){return Gk(e,t)}):e._content)}var Yk=Dg.define({combine:function(e){return e.join(" ")}}),$k=Dg.define({combine:function(e){return e.indexOf(!0)>-1}}),Xk=Vv.newName(),Jk=Vv.newName(),Qk=Vv.newName(),Zk={"&light":"."+Jk,"&dark":"."+Qk};function ex(e,t,n){return new Vv(t,{finish:function(t){return/&/.test(t)?t.replace(/&\w*/,function(t){if("&"==t)return e;if(!n||!n[t])throw new RangeError("Unsupported selector: ".concat(t));return n[t]}):e+" "+t}})}var tx=ex("."+Xk,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:'url(\'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>\')',backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},Zk),nx={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},rx=hy.ie&&hy.ie_version<=11,ix=function(){return R(function e(t){var n=this;N(this,e),this.view=t,this.active=!1,this.editContext=null,this.selectionRange=new Wy,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=t.contentDOM,this.observer=new MutationObserver(function(e){var r,i=D(e);try{for(i.s();!(r=i.n()).done;){var o=r.value;n.queue.push(o)}}catch(e){i.e(e)}finally{i.f()}(hy.ie&&hy.ie_version<=11||hy.ios&&t.composing)&&e.some(function(e){return"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length})?n.flushSoon():n.flush()}),!window.EditContext||!hy.android||!1===t.constructor.EDIT_CONTEXT||hy.chrome&&hy.chrome_version<126||(this.editContext=new ax(t),t.state.facet(Lb)&&(t.contentDOM.editContext=this.editContext.editContext)),rx&&(this.onCharData=function(e){n.queue.push({target:e.target,type:"characterData",oldValue:e.prevValue}),n.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),"function"==typeof ResizeObserver&&(this.resizeScroll=new ResizeObserver(function(){var e;(null===(e=n.view.docView)||void 0===e?void 0:e.lastUpdate)<Date.now()-75&&n.onResize()}),this.resizeScroll.observe(t.scrollDOM)),this.addWindowListeners(this.win=t.win),this.start(),"function"==typeof IntersectionObserver&&(this.intersection=new IntersectionObserver(function(e){n.parentCheck<0&&(n.parentCheck=setTimeout(n.listenForScroll.bind(n),1e3)),e.length>0&&e[e.length-1].intersectionRatio>0!=n.intersecting&&(n.intersecting=!n.intersecting,n.intersecting!=n.view.inView&&n.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(function(e){e.length>0&&e[e.length-1].intersectionRatio>0&&n.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()},[{key:"onScrollChanged",value:function(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}},{key:"onScroll",value:function(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}},{key:"onResize",value:function(){var e=this;this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(function(){e.resizeTimeout=-1,e.view.requestMeasure()},50))}},{key:"onPrint",value:function(e){var t=this;("change"!=e.type&&e.type||e.matches)&&(this.view.viewState.printing=!0,this.view.measure(),setTimeout(function(){t.view.viewState.printing=!1,t.view.requestMeasure()},500))}},{key:"updateGaps",value:function(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some(function(t,n){return t!=e[n]}))){this.gapIntersection.disconnect();var t,n=D(e);try{for(n.s();!(t=n.n()).done;){var r=t.value;this.gapIntersection.observe(r)}}catch(e){n.e(e)}finally{n.f()}this.gaps=e}}},{key:"onSelectionChange",value:function(e){var t=this.selectionChanged;if(this.readSelectionRange()&&!this.delayedAndroidKey){var n=this.view,r=this.selectionRange;if(n.state.facet(Lb)?n.root.activeElement==this.dom:Oy(this.dom,r)){var i=r.anchorNode&&n.docView.tile.nearest(r.anchorNode);i&&i.isWidget()&&i.widget.ignoreEvent(e)?t||(this.selectionChanged=!1):(hy.ie&&hy.ie_version<=11||hy.android&&hy.chrome)&&!n.state.selection.main.empty&&r.focusNode&&Ty(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}}}},{key:"readSelectionRange",value:function(){var e=this.view,t=Ay(e.root);if(!t)return!1;var n=hy.safari&&11==e.root.nodeType&&e.root.activeElement==this.dom&&function(e,t){if(t.getComposedRanges){var n=t.getComposedRanges(e.root)[0];if(n)return sx(e,n)}var r=null;function i(e){e.preventDefault(),e.stopImmediatePropagation(),r=e.getTargetRanges()[0]}return e.contentDOM.addEventListener("beforeinput",i,!0),e.dom.ownerDocument.execCommand("indent"),e.contentDOM.removeEventListener("beforeinput",i,!0),r?sx(e,r):null}(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;var r=Oy(this.dom,n);return r&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&function(e,t){var n=t.focusNode,r=t.focusOffset;if(!n||t.anchorNode!=n||t.anchorOffset!=r)return!1;for(r=Math.min(r,Ly(n));;)if(r){if(1!=n.nodeType)return!1;var i=n.childNodes[r-1];"false"==i.contentEditable?r--:r=Ly(n=i)}else{if(n==e)return!0;r=Ry(n),n=n.parentNode}}(this.dom,n)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(n),r&&(this.selectionChanged=!0),!0)}},{key:"setSelectionRange",value:function(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}},{key:"clearSelectionRange",value:function(){this.selectionRange.set(null,0,null,0)}},{key:"listenForScroll",value:function(){this.parentCheck=-1;for(var e=0,t=null,n=this.dom;n;)if(1==n.nodeType)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==n?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(n),n=n.assignedSlot||n.parentNode;else{if(11!=n.nodeType)break;n=n.host}if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){var r,i=D(this.scrollTargets);try{for(i.s();!(r=i.n()).done;){r.value.removeEventListener("scroll",this.onScroll)}}catch(e){i.e(e)}finally{i.f()}var o,s=D(this.scrollTargets=t);try{for(s.s();!(o=s.n()).done;){o.value.addEventListener("scroll",this.onScroll)}}catch(e){s.e(e)}finally{s.f()}}}},{key:"ignore",value:function(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}},{key:"start",value:function(){this.active||(this.observer.observe(this.dom,nx),rx&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}},{key:"stop",value:function(){this.active&&(this.active=!1,this.observer.disconnect(),rx&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}},{key:"clear",value:function(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}},{key:"delayAndroidKey",value:function(e,t){var n,r=this;if(!this.delayedAndroidKey){this.flushingAndroidKey=this.view.win.requestAnimationFrame(function(){var e=r.delayedAndroidKey;e&&(r.clearDelayedAndroidKey(),r.view.inputState.lastKeyCode=e.keyCode,r.view.inputState.lastKeyTime=Date.now(),!r.flush()&&e.force&&Vy(r.dom,e.key,e.keyCode))})}this.delayedAndroidKey&&"Enter"!=e||(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(null===(n=this.delayedAndroidKey)||void 0===n?void 0:n.force)})}},{key:"clearDelayedAndroidKey",value:function(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}},{key:"flushSoon",value:function(){var e=this;this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(function(){e.delayedFlush=-1,e.flush()}))}},{key:"forceFlush",value:function(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}},{key:"pendingRecords",value:function(){var e,t=D(this.observer.takeRecords());try{for(t.s();!(e=t.n()).done;){var n=e.value;this.queue.push(n)}}catch(e){t.e(e)}finally{t.f()}return this.queue}},{key:"processRecords",value:function(){var e=this.pendingRecords();e.length&&(this.queue=[]);var t,n=-1,r=-1,i=!1,o=D(e);try{for(o.s();!(t=o.n()).done;){var s=t.value,a=this.readMutation(s);a&&(a.typeOver&&(i=!0),-1==n?(n=a.from,r=a.to):(n=Math.min(a.from,n),r=Math.max(a.to,r)))}}catch(e){o.e(e)}finally{o.f()}return{from:n,to:r,typeOver:i}}},{key:"readChange",value:function(){var e=this.processRecords(),t=e.from,n=e.to,r=e.typeOver,i=this.selectionChanged&&Oy(this.dom,this.selectionRange);if(t<0&&!i)return null;t>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;var o=new zw(this.view,t,n,r);return this.view.docView.domChanged={newSel:o.newSel?o.newSel.main:null},o}},{key:"flush",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();var t=this.readChange();if(!t)return this.view.requestMeasure(),!1;var n=this.view.state,r=qw(this.view,t);return this.view.state==n&&(t.domChanged||t.newSel&&!Gw(this.view.state.selection,t.newSel.main))&&this.view.update([]),r}},{key:"readMutation",value:function(e){var t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty("attributes"==e.type),"childList"==e.type){var n=ox(t,e.previousSibling||e.target.previousSibling,-1),r=ox(t,e.nextSibling||e.target.nextSibling,1);return{from:n?t.posAfter(n):t.posAtStart,to:r?t.posBefore(r):t.posAtEnd,typeOver:!1}}return"characterData"==e.type?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}},{key:"setWindow",value:function(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}},{key:"addWindowListeners",value:function(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}},{key:"removeWindowListeners",value:function(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}},{key:"update",value:function(e){this.editContext&&(this.editContext.update(e),e.startState.facet(Lb)!=e.state.facet(Lb)&&(e.view.contentDOM.editContext=e.state.facet(Lb)?this.editContext.editContext:null))}},{key:"destroy",value:function(){var e,t,n;this.stop(),null===(e=this.intersection)||void 0===e||e.disconnect(),null===(t=this.gapIntersection)||void 0===t||t.disconnect(),null===(n=this.resizeScroll)||void 0===n||n.disconnect();var r,i=D(this.scrollTargets);try{for(i.s();!(r=i.n()).done;){r.value.removeEventListener("scroll",this.onScroll)}}catch(e){i.e(e)}finally{i.f()}this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}])}();function ox(e,t,n){for(;t;){var r=Zb.get(t);if(r&&r.parent==e)return r;var i=t.parentNode;t=i!=e.dom?i:n>0?t.nextSibling:t.previousSibling}return null}function sx(e,t){var n=t.startContainer,r=t.startOffset,i=t.endContainer,o=t.endOffset,s=e.docView.domAtPos(e.state.selection.main.anchor,1);if(Ty(s.node,s.offset,i,o)){var a=[i,o,n,r];n=a[0],r=a[1],i=a[2],o=a[3]}return{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:o}}var ax=function(){return R(function e(t){var n=this;N(this,e),this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(t.state);var r=this.editContext=new window.EditContext({text:t.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,t.state.selection.main.anchor))),selectionEnd:this.toContextPos(t.state.selection.main.head)});for(var i in this.handlers.textupdate=function(e){var i=t.state.selection.main,o=i.anchor,s=i.head,a=n.toEditorPos(e.updateRangeStart),l=n.toEditorPos(e.updateRangeEnd);t.inputState.composing>=0&&!n.composing&&(n.composing={contextBase:e.updateRangeStart,editorBase:a,drifted:!1});var c=l-a>e.text.length;a==n.from&&o<n.from?a=o:l==n.to&&o>n.to&&(l=o);var u=Kw(t.state.sliceDoc(a,l),e.text,(c?i.from:i.to)-a,c?"end":null);if(u){var h={from:u.from+a,to:u.toA+a,insert:ig.of(e.text.slice(u.from,u.toB).split("\n"))};if((hy.mac||hy.android)&&h.from==s-1&&/^\. ?$/.test(e.text)&&"off"==t.contentDOM.getAttribute("autocorrect")&&(h={from:a,to:l,insert:ig.of([e.text.replace("."," ")])}),n.pendingContextChange=h,!t.state.readOnly){var f=n.to-n.from+(h.to-h.from+h.insert.length);Uw(t,h,Ng.single(n.toEditorPos(e.selectionStart,f),n.toEditorPos(e.selectionEnd,f)))}n.pendingContextChange&&(n.revertPending(t.state),n.setSelection(t.state)),h.from<h.to&&!h.insert.length&&t.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(r.text.slice(Math.max(0,e.updateRangeStart-1),Math.min(r.text.length,e.updateRangeStart+1)))&&n.handlers.compositionend(e)}else{var d=Ng.single(n.toEditorPos(e.selectionStart),n.toEditorPos(e.selectionEnd));Gw(d,i)||t.dispatch({selection:d,userEvent:"select"})}},this.handlers.characterboundsupdate=function(e){for(var i=[],o=null,s=n.toEditorPos(e.rangeStart),a=n.toEditorPos(e.rangeEnd);s<a;s++){var l=t.coordsForChar(s);o=l&&new DOMRect(l.left,l.top,l.right-l.left,l.bottom-l.top)||o||new DOMRect,i.push(o)}r.updateCharacterBounds(e.rangeStart,i)},this.handlers.textformatupdate=function(e){var r,i=[],o=D(e.getTextFormats());try{for(o.s();!(r=o.n()).done;){var s=r.value,a=s.underlineStyle,l=s.underlineThickness;if(!/none/i.test(a)&&!/none/i.test(l)){var c=n.toEditorPos(s.rangeStart),u=n.toEditorPos(s.rangeEnd);if(c<u){var h="text-decoration: underline ".concat(/^[a-z]/.test(a)?a+" ":"Dashed"==a?"dashed ":"Squiggle"==a?"wavy ":"").concat(/thin/i.test(l)?1:2,"px");i.push(by.mark({attributes:{style:h}}).range(c,u))}}}}catch(e){o.e(e)}finally{o.f()}t.dispatch({effects:Db.of(by.set(i))})},this.handlers.compositionstart=function(){t.inputState.composing<0&&(t.inputState.composing=0,t.inputState.compositionFirstChange=!0)},this.handlers.compositionend=function(){if(t.inputState.composing=-1,t.inputState.compositionFirstChange=null,n.composing){var e=n.composing.drifted;n.composing=null,e&&n.reset(t.state)}},this.handlers)r.addEventListener(i,this.handlers[i]);this.measureReq={read:function(e){n.editContext.updateControlBounds(e.contentDOM.getBoundingClientRect());var t=Ay(e.root);t&&t.rangeCount&&n.editContext.updateSelectionBounds(t.getRangeAt(0).getBoundingClientRect())}}},[{key:"applyEdits",value:function(e){var t=this,n=0,r=!1,i=this.pendingContextChange;return e.changes.iterChanges(function(o,s,a,l,c){if(!r){var u=c.length-(s-o);if(i&&s>=i.to){if(i.from==o&&i.to==s&&i.insert.eq(c))return i=t.pendingContextChange=null,n+=u,void(t.to+=u);i=null,t.revertPending(e.state)}if(o+=n,(s+=n)<=t.from)t.from+=u,t.to+=u;else if(o<t.to){if(o<t.from||s>t.to||t.to-t.from+c.length>3e4)return void(r=!0);t.editContext.updateText(t.toContextPos(o),t.toContextPos(s),c.toString()),t.to+=u}n+=u}}),i&&!r&&this.revertPending(e.state),!r}},{key:"update",value:function(e){var t=this,n=this.pendingContextChange,r=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(r.from,r.to)&&e.transactions.some(function(e){return!e.isUserEvent("input.type")&&e.changes.touchesRange(t.from,t.to)}))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):this.applyEdits(e)&&this.rangeIsValid(e.state)?(e.docChanged||e.selectionSet||n)&&this.setSelection(e.state):(this.pendingContextChange=null,this.reset(e.state)),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}},{key:"resetRange",value:function(e){var t=e.selection.main.head;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}},{key:"reset",value:function(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}},{key:"revertPending",value:function(e){var t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}},{key:"setSelection",value:function(e){var t=e.selection.main,n=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),r=this.toContextPos(t.head);this.editContext.selectionStart==n&&this.editContext.selectionEnd==r||this.editContext.updateSelection(n,r)}},{key:"rangeIsValid",value:function(e){var t=e.selection.main.head;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>3e4)}},{key:"toEditorPos",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.to-this.from;e=Math.min(e,t);var n=this.composing;return n&&n.drifted?n.editorBase+(e-n.contextBase):e+this.from}},{key:"toContextPos",value:function(e){var t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}},{key:"destroy",value:function(){for(var e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}])}(),lx=function(){function e(){var t,n=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};N(this,e),this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),r.parent&&r.parent.appendChild(this.dom);var i=r.dispatch;this.dispatchTransactions=r.dispatchTransactions||i&&function(e){return e.forEach(function(e){return i(e,n)})}||function(e){return n.update(e)},this.dispatch=this.dispatch.bind(this),this._root=r.root||function(e){for(;e;){if(e&&(9==e.nodeType||11==e.nodeType&&e.host))return e;e=e.assignedSlot||e.parentNode}return null}(r.parent)||document,this.viewState=new jk(r.state||bv.create(r)),r.scrollTo&&r.scrollTo.is(Rb)&&(this.viewState.scrollTarget=r.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Ib).map(function(e){return new Fb(e)});var o,s=D(this.plugins);try{for(s.s();!(o=s.n()).done;){o.value.update(this)}}catch(e){s.e(e)}finally{s.f()}this.observer=new ix(this),this.inputState=new Yw(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Sw(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),(null===(t=document.fonts)||void 0===t?void 0:t.ready)&&document.fonts.ready.then(function(){n.viewState.mustMeasureContent="refresh",n.requestMeasure()})}return R(e,[{key:"state",get:function(){return this.viewState.state}},{key:"viewport",get:function(){return this.viewState.viewport}},{key:"visibleRanges",get:function(){return this.viewState.visibleRanges}},{key:"inView",get:function(){return this.viewState.inView}},{key:"composing",get:function(){return!!this.inputState&&this.inputState.composing>0}},{key:"compositionStarted",get:function(){return!!this.inputState&&this.inputState.composing>=0}},{key:"root",get:function(){return this._root}},{key:"win",get:function(){return this.dom.ownerDocument.defaultView||window}},{key:"dispatch",value:function(){for(var e,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];var i=1==n.length&&n[0]instanceof lv?n:1==n.length&&Array.isArray(n[0])?n[0]:[(e=this.state).update.apply(e,n)];this.dispatchTransactions(i,this)}},{key:"update",value:function(e){var t=this;if(0!=this.updateState)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");var n,r,i=!1,o=!1,s=this.state,a=D(e);try{for(a.s();!(r=a.n()).done;){var l=r.value;if(l.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=l.state}}catch(e){a.e(e)}finally{a.f()}if(this.destroyed)this.viewState.state=s;else{var c=this.hasFocus,u=0,h=null;e.some(function(e){return e.annotation(pk)})?(this.inputState.notifiedFocused=c,u=1):c!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=c,(h=mk(s,c))||(u=1));var f=this.observer.delayedAndroidKey,d=null;if(f?(this.observer.clearDelayedAndroidKey(),((d=this.observer.readChange())&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(d=null)):this.observer.clear(),s.facet(bv.phrases)!=this.state.facet(bv.phrases))return this.setState(s);n=Jb.create(this,s,e),n.flags|=u;var p=this.viewState.scrollTarget;try{this.updateState=2;var m,g=D(e);try{for(g.s();!(m=g.n()).done;){var v=m.value;if(p&&(p=p.map(v.changes)),v.scrollIntoView){var y=v.state.selection.main;p=new Tb(y.empty?y:Ng.cursor(y.head,y.head>y.anchor?-1:1))}var b,w=D(v.effects);try{for(w.s();!(b=w.n()).done;){var k=b.value;k.is(Rb)&&(p=k.value.clip(this.state))}}catch(e){w.e(e)}finally{w.f()}}}catch(e){g.e(e)}finally{g.f()}this.viewState.update(n,p),this.bidiCache=hx.update(this.bidiCache,n.changes),n.empty||(this.updatePlugins(n),this.inputState.update(n)),i=this.docView.update(n),this.state.facet($b)!=this.styleModules&&this.mountStyles(),o=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(i,e.some(function(e){return e.isUserEvent("select.pointer")}))}finally{this.updateState=0}if(n.startState.facet(Yk)!=n.state.facet(Yk)&&(this.viewState.mustMeasureContent=!0),(i||o||p||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),i&&this.docViewUpdate(),!n.empty){var x,S=D(this.state.facet(xb));try{for(S.s();!(x=S.n()).done;){var C=x.value;try{C(n)}catch(k){Pb(this.state,k,"update listener")}}}catch(e){S.e(e)}finally{S.f()}}(h||d)&&Promise.resolve().then(function(){h&&t.state==h.startState&&t.dispatch(h),d&&!qw(t,d)&&f.force&&Vy(t.contentDOM,f.key,f.keyCode)})}}},{key:"setState",value:function(e){if(0!=this.updateState)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed)this.viewState.state=e;else{this.updateState=2;var t=this.hasFocus;try{var n,r=D(this.plugins);try{for(r.s();!(n=r.n()).done;){n.value.destroy(this)}}catch(e){r.e(e)}finally{r.f()}this.viewState=new jk(e),this.plugins=e.facet(Ib).map(function(e){return new Fb(e)}),this.pluginMap.clear();var i,o=D(this.plugins);try{for(o.s();!(i=o.n()).done;){i.value.update(this)}}catch(e){o.e(e)}finally{o.f()}this.docView.destroy(),this.docView=new Sw(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}}},{key:"updatePlugins",value:function(e){var t=e.startState.facet(Ib),n=e.state.facet(Ib);if(t!=n){var r,i=[],o=D(n);try{for(o.s();!(r=o.n()).done;){var s=r.value,a=t.indexOf(s);if(a<0)i.push(new Fb(s));else{var l=this.plugins[a];l.mustUpdate=e,i.push(l)}}}catch(e){o.e(e)}finally{o.f()}var c,u=D(this.plugins);try{for(u.s();!(c=u.n()).done;){var h=c.value;h.mustUpdate!=e&&h.destroy(this)}}catch(e){u.e(e)}finally{u.f()}this.plugins=i,this.pluginMap.clear()}else{var f,d=D(this.plugins);try{for(d.s();!(f=d.n()).done;){f.value.mustUpdate=e}}catch(e){d.e(e)}finally{d.f()}}for(var p=0;p<this.plugins.length;p++)this.plugins[p].update(this);t!=n&&this.inputState.ensureHandlers(this.plugins)}},{key:"docViewUpdate",value:function(){var e,t=D(this.plugins);try{for(t.s();!(e=t.n()).done;){var n=e.value.value;if(n&&n.docViewUpdate)try{n.docViewUpdate(this)}catch(e){Pb(this.state,e,"doc view update listener")}}}catch(e){t.e(e)}finally{t.f()}}},{key:"measure",value:function(){var e=this,t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];if(!this.destroyed){if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey)return this.measureScheduled=-1,void this.requestMeasure();this.measureScheduled=0,t&&this.observer.forceFlush();var n=null,r=this.scrollDOM,i=r.scrollTop*this.scaleY,o=this.viewState,s=o.scrollAnchorPos,a=o.scrollAnchorHeight;Math.abs(i-this.viewState.scrollTop)>1&&(a=-1),this.viewState.scrollAnchorHeight=-1;try{for(var l=0;;l++){if(a<0)if(qy(r))s=-1,a=this.viewState.heightMap.height;else{var c=this.viewState.scrollAnchorAt(i);s=c.from,a=c.top}this.updateState=1;var u=this.viewState.measure(this);if(!u&&!this.measureRequests.length&&null==this.viewState.scrollTarget)break;if(l>5)break;var h=[];if(!(4&u)){var f=[h,this.measureRequests];this.measureRequests=f[0],h=f[1]}var d=h.map(function(t){try{return t.read(e)}catch(t){return Pb(e.state,t),ux}}),p=Jb.create(this,this.state,[]),m=!1;p.flags|=u,n?n.flags|=u:n=p,this.updateState=2,p.empty||(this.updatePlugins(p),this.inputState.update(p),this.updateAttrs(),(m=this.docView.update(p))&&this.docViewUpdate());for(var g=0;g<h.length;g++)if(d[g]!=ux)try{var v=h[g];v.write&&v.write(d[g],this)}catch(e){Pb(this.state,e)}if(m&&this.docView.updateSelection(!0),!p.viewportChanged&&0==this.measureRequests.length){if(this.viewState.editorHeight){if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,a=-1;continue}var y=(s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)-a;if(y>1||y<-1){i+=y,r.scrollTop=i/this.scaleY,a=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty){var b,w=D(this.state.facet(xb));try{for(w.s();!(b=w.n()).done;){(0,b.value)(n)}}catch(e){w.e(e)}finally{w.f()}}}}},{key:"themeClasses",get:function(){return Xk+" "+(this.state.facet($k)?Qk:Jk)+" "+this.state.facet(Yk)}},{key:"updateAttrs",value:function(){var e=this,t=fx(this,Wb,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Lb)?"true":"false",class:"cm-content",style:"".concat(hy.tabSize,": ").concat(this.state.tabSize),role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),fx(this,jb,n);var r=this.observer.ignore(function(){var r=my(e.contentDOM,e.contentAttrs,n),i=my(e.dom,e.editorAttrs,t);return r||i});return this.editorAttrs=t,this.contentAttrs=n,r}},{key:"showAnnouncements",value:function(t){var n,r=!0,i=D(t);try{for(i.s();!(n=i.n()).done;){var o,s=D(n.value.effects);try{for(s.s();!(o=s.n()).done;){var a=o.value;if(a.is(e.announce))r&&(this.announceDOM.textContent=""),r=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=a.value}}catch(e){s.e(e)}finally{s.f()}}}catch(e){i.e(e)}finally{i.f()}}},{key:"mountStyles",value:function(){this.styleModules=this.state.facet($b);var t=this.state.facet(e.cspNonce);Vv.mount(this.root,this.styleModules.concat(tx).reverse(),t?{nonce:t}:void 0)}},{key:"readMeasured",value:function(){if(2==this.updateState)throw new Error("Reading the editor layout isn't allowed during an update");0==this.updateState&&this.measureScheduled>-1&&this.measure(!1)}},{key:"requestMeasure",value:function(e){var t=this;if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(function(){return t.measure()})),e){if(this.measureRequests.indexOf(e)>-1)return;if(null!=e.key)for(var n=0;n<this.measureRequests.length;n++)if(this.measureRequests[n].key===e.key)return void(this.measureRequests[n]=e);this.measureRequests.push(e)}}},{key:"plugin",value:function(e){var t=this.pluginMap.get(e);return(void 0===t||t&&t.plugin!=e)&&this.pluginMap.set(e,t=this.plugins.find(function(t){return t.plugin==e})||null),t&&t.update(this).value}},{key:"documentTop",get:function(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}},{key:"documentPadding",get:function(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}},{key:"scaleX",get:function(){return this.viewState.scaleX}},{key:"scaleY",get:function(){return this.viewState.scaleY}},{key:"elementAtHeight",value:function(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}},{key:"lineBlockAtHeight",value:function(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}},{key:"viewportLineBlocks",get:function(){return this.viewState.viewportLines}},{key:"lineBlockAt",value:function(e){return this.viewState.lineBlockAt(e)}},{key:"contentHeight",get:function(){return this.viewState.contentHeight}},{key:"moveByChar",value:function(e,t,n){return Pw(this,e,Tw(this,e,t,n))}},{key:"moveByGroup",value:function(e,t){var n=this;return Pw(this,e,Tw(this,e,t,function(t){return function(e,t,n){var r=e.state.charCategorizer(t),i=r(n);return function(e){var t=r(e);return i==gv.Space&&(i=t),i==t}}(n,e.head,t)}))}},{key:"visualLineSide",value:function(e,t){var n=this.bidiSpans(e),r=this.textDirectionAt(e.from),i=n[t?n.length-1:0];return Ng.cursor(i.side(t,r)+e.from,i.forward(!t,r)?1:-1)}},{key:"moveToLineBoundary",value:function(e,t){return function(e,t,n,r){var i=Nw(e,t.head,t.assoc||-1),o=r&&i.type==yy.Text&&(e.lineWrapping||i.widgetLineBreaks)?e.coordsAtPos(t.assoc<0&&t.head>i.from?t.head-1:t.head):null;if(o){var s=e.dom.getBoundingClientRect(),a=e.textDirectionAt(i.from),l=e.posAtCoords({x:n==(a==Yy.LTR)?s.right-1:s.left+1,y:(o.top+o.bottom)/2});if(null!=l)return Ng.cursor(l,n?-1:1)}return Ng.cursor(n?i.to:i.from,n?-1:1)}(this,e,t,!(arguments.length>2&&void 0!==arguments[2])||arguments[2])}},{key:"moveVertically",value:function(e,t,n){return Pw(this,e,function(e,t,n,r){var i=t.head,o=n?1:-1;if(i==(n?e.state.doc.length:0))return Ng.cursor(i,t.assoc);var s,a=t.goalColumn,l=e.contentDOM.getBoundingClientRect(),c=e.coordsAtPos(i,(t.empty?t.assoc:0)||(n?1:-1)),u=e.documentTop;if(c)null==a&&(a=c.left-l.left),s=o<0?c.top:c.bottom;else{var h=e.viewState.lineBlockAt(i);null==a&&(a=Math.min(l.right-l.left,e.defaultCharacterWidth*(i-h.from))),s=(o<0?h.top:h.bottom)+u}var f=Bw(e,{x:l.left+a,y:s+(null!=r?r:e.viewState.heightOracle.textHeight>>1)*o},!1,o);return Ng.cursor(f.pos,f.assoc,void 0,a)}(this,e,t,n))}},{key:"domAtPos",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return this.docView.domAtPos(e,t)}},{key:"posAtDOM",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this.docView.posFromDOM(e,t)}},{key:"posAtCoords",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];this.readMeasured();var n=Bw(this,e,t);return n&&n.pos}},{key:"posAndSideAtCoords",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return this.readMeasured(),Bw(this,e,t)}},{key:"coordsAtPos",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;this.readMeasured();var n=this.docView.coordsAt(e,t);if(!n||n.left==n.right)return n;var r=this.state.doc.lineAt(e),i=this.bidiSpans(r);return By(n,i[cb.find(i,e-r.from,-1,t)].dir==Yy.LTR==t>0)}},{key:"coordsForChar",value:function(e){return this.readMeasured(),this.docView.coordsForChar(e)}},{key:"defaultCharacterWidth",get:function(){return this.viewState.heightOracle.charWidth}},{key:"defaultLineHeight",get:function(){return this.viewState.heightOracle.lineHeight}},{key:"textDirection",get:function(){return this.viewState.defaultTextDirection}},{key:"textDirectionAt",value:function(e){return!this.state.facet(Mb)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}},{key:"lineWrapping",get:function(){return this.viewState.heightOracle.lineWrapping}},{key:"bidiSpans",value:function(e){if(e.length>cx)return pb(e.length);var t,n,r=this.textDirectionAt(e.from),i=D(this.bidiCache);try{for(i.s();!(n=i.n()).done;){var o=n.value;if(o.from==e.from&&o.dir==r&&(o.fresh||ub(o.isolates,t=Kb(this,e))))return o.order}}catch(e){i.e(e)}finally{i.f()}t||(t=Kb(this,e));var s=function(e,t,n){if(!e)return[new cb(0,0,t==Xy?1:0)];if(t==$y&&!n.length&&!lb.test(e))return pb(e.length);if(n.length)for(;e.length>hb.length;)hb[hb.length]=256;var r=[],i=t==$y?0:1;return db(e,i,i,n,0,e.length,r),r}(e.text,r,t);return this.bidiCache.push(new hx(e.from,e.to,r,t,!0,s)),s}},{key:"hasFocus",get:function(){var e;return(this.dom.ownerDocument.hasFocus()||hy.safari&&(null===(e=this.inputState)||void 0===e?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}},{key:"focus",value:function(){var e=this;this.observer.ignore(function(){Hy(e.contentDOM),e.docView.updateSelection()})}},{key:"setRoot",value:function(e){this._root!=e&&(this._root=e,this.observer.setWindow((9==e.nodeType?e:e.ownerDocument).defaultView||window),this.mountStyles())}},{key:"destroy",value:function(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();var e,t=D(this.plugins);try{for(t.s();!(e=t.n()).done;){e.value.destroy(this)}}catch(e){t.e(e)}finally{t.f()}this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}},{key:"scrollSnapshot",value:function(){var e=this.scrollDOM,t=e.scrollTop,n=e.scrollLeft,r=this.viewState.scrollAnchorAt(t);return Rb.of(new Tb(Ng.cursor(r.from),"start","start",r.top-t,n,!0))}},{key:"setTabFocusMode",value:function(e){null==e?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:"boolean"==typeof e?this.inputState.tabFocusMode=e?0:-1:0!=this.inputState.tabFocusMode&&(this.inputState.tabFocusMode=Date.now()+e)}}],[{key:"scrollIntoView",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Rb.of(new Tb("number"==typeof e?Ng.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}},{key:"domEventHandlers",value:function(e){return _b.define(function(){return{}},{eventHandlers:e})}},{key:"domEventObservers",value:function(e){return _b.define(function(){return{}},{eventObservers:e})}},{key:"theme",value:function(e,t){var n=Vv.newName(),r=[Yk.of(n),$b.of(ex(".".concat(n),e))];return t&&t.dark&&r.push($k.of(!0)),r}},{key:"baseTheme",value:function(e){return qg.lowest($b.of(ex("."+Xk,e,Zk)))}},{key:"findFromDOM",value:function(e){var t,n=e.querySelector(".cm-content"),r=n&&Zb.get(n)||Zb.get(e);return(null===(t=null==r?void 0:r.root)||void 0===t?void 0:t.view)||null}}])}();lx.styleModule=$b,lx.inputHandler=Sb,lx.clipboardInputFilter=Eb,lx.clipboardOutputFilter=Ab,lx.scrollHandler=Nb,lx.focusChangeEffect=Cb,lx.perLineTextDirection=Mb,lx.exceptionSink=kb,lx.updateListener=xb,lx.editable=Lb,lx.mouseSelectionStyle=wb,lx.dragMovesSelection=bb,lx.clickAddsSelectionRange=yb,lx.decorations=Hb,lx.blockWrappers=zb,lx.outerDecorations=Vb,lx.atomicRanges=qb,lx.bidiIsolatedRanges=Ub,lx.scrollMargins=Gb,lx.darkTheme=$k,lx.cspNonce=Dg.define({combine:function(e){return e.length?e[0]:""}}),lx.contentAttributes=jb,lx.editorAttributes=Wb,lx.lineWrapping=lx.contentAttributes.of({class:"cm-lineWrapping"}),lx.announce=av.define();var cx=4096,ux={},hx=function(){function e(t,n,r,i,o,s){N(this,e),this.from=t,this.to=n,this.dir=r,this.isolates=i,this.fresh=o,this.order=s}return R(e,null,[{key:"update",value:function(t,n){if(n.empty&&!t.some(function(e){return e.fresh}))return t;for(var r=[],i=t.length?t[t.length-1].dir:Yy.LTR,o=Math.max(0,t.length-10);o<t.length;o++){var s=t[o];s.dir!=i||n.touchesRange(s.from,s.to)||r.push(new e(n.mapPos(s.from,1),n.mapPos(s.to,-1),s.dir,s.isolates,!1,s.order))}return r}}])}();function fx(e,t,n){for(var r=e.state.facet(t),i=r.length-1;i>=0;i--){var o=r[i],s="function"==typeof o?o(e):o;s&&fy(s,n)}return n}var dx=hy.mac?"mac":hy.windows?"win":hy.linux?"linux":"key";function px(e,t,n){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),!1!==n&&t.shiftKey&&(e="Shift-"+e),e}var mx=qg.default(lx.domEventHandlers({keydown:function(e,t){return xx(yx(t.state),e,t,"editor")}})),gx=Dg.define({enables:mx}),vx=new WeakMap;function yx(e){var t=e.facet(gx),n=vx.get(t);return n||vx.set(t,n=function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:dx,r=Object.create(null),i=Object.create(null),o=function(e,t){var n=i[e];if(null==n)i[e]=t;else if(n!=t)throw new Error("Key binding "+e+" is used both as a regular binding and as a multi-stroke prefix")},s=function(e,t,i,s,a){for(var l,c,u=r[e]||(r[e]=Object.create(null)),h=t.split(/ (?!$)/).map(function(e){return function(e,t){var n,r,i,o,s=e.split(/-(?!$)/),a=s[s.length-1];"Space"==a&&(a=" ");for(var l=0;l<s.length-1;++l){var c=s[l];if(/^(cmd|meta|m)$/i.test(c))o=!0;else if(/^a(lt)?$/i.test(c))n=!0;else if(/^(c|ctrl|control)$/i.test(c))r=!0;else if(/^s(hift)?$/i.test(c))i=!0;else{if(!/^mod$/i.test(c))throw new Error("Unrecognized modifier name: "+c);"mac"==t?o=!0:r=!0}}return n&&(a="Alt-"+a),r&&(a="Ctrl-"+a),o&&(a="Meta-"+a),i&&(a="Shift-"+a),a}(e,n)}),f=function(){var t=h.slice(0,d).join(" ");o(t,!0),u[t]||(u[t]={preventDefault:!0,stopPropagation:!1,run:[function(n){var r=bx={view:n,prefix:t,scope:e};return setTimeout(function(){bx==r&&(bx=null)},wx),!0}]})},d=1;d<h.length;d++)f();var p=h.join(" ");o(p,!1);var m=u[p]||(u[p]={preventDefault:!1,stopPropagation:!1,run:(null===(c=null===(l=u._any)||void 0===l?void 0:l.run)||void 0===c?void 0:c.slice())||[]});i&&m.run.push(i),s&&(m.preventDefault=!0),a&&(m.stopPropagation=!0)},a=D(e);try{for(a.s();!(t=a.n()).done;){var l=t.value,c=l.scope?l.scope.split(" "):["editor"];if(l.any){var u,h=D(c);try{var f=function(){var e=u.value,t=r[e]||(r[e]=Object.create(null));t._any||(t._any={preventDefault:!1,stopPropagation:!1,run:[]});var n=l.any;for(var i in t)t[i].run.push(function(e){return n(e,kx)})};for(h.s();!(u=h.n()).done;)f()}catch(e){h.e(e)}finally{h.f()}}var d=l[n]||l.key;if(d){var p,m=D(c);try{for(m.s();!(p=m.n()).done;){var g=p.value;s(g,d,l.run,l.preventDefault,l.stopPropagation),l.shift&&s(g,"Shift-"+d,l.shift,l.preventDefault,l.stopPropagation)}}catch(e){m.e(e)}finally{m.f()}}}}catch(e){a.e(e)}finally{a.f()}return r}(t.reduce(function(e,t){return e.concat(t)},[]))),n}var bx=null,wx=4e3;var kx=null;function xx(e,t,n,r){kx=t;var i=function(e){var t=!(Yv&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||$v&&e.shiftKey&&e.key&&1==e.key.length||"Unidentified"==e.key)&&e.key||(e.shiftKey?Gv:Kv)[e.keyCode]||e.key||"Unidentified";return"Esc"==t&&(t="Escape"),"Del"==t&&(t="Delete"),"Left"==t&&(t="ArrowLeft"),"Up"==t&&(t="ArrowUp"),"Right"==t&&(t="ArrowRight"),"Down"==t&&(t="ArrowDown"),t}(t),o=vg(mg(i,0))==i.length&&" "!=i,s="",a=!1,l=!1,c=!1;bx&&bx.view==n&&bx.scope==r&&(s=bx.prefix+" ",Qw.indexOf(t.keyCode)<0&&(l=!0,bx=null));var u,h,f=new Set,d=function(e){if(e){var t,r=D(e.run);try{for(r.s();!(t=r.n()).done;){var i=t.value;if(!f.has(i)&&(f.add(i),i(n)))return e.stopPropagation&&(c=!0),!0}}catch(e){r.e(e)}finally{r.f()}e.preventDefault&&(e.stopPropagation&&(c=!0),l=!0)}return!1},p=e[r];return p&&(d(p[s+px(i,t,!o)])?a=!0:!o||!(t.altKey||t.metaKey||t.ctrlKey)||hy.windows&&t.ctrlKey&&t.altKey||hy.mac&&t.altKey&&!t.ctrlKey&&!t.metaKey||!(u=Kv[t.keyCode])||u==i?o&&t.shiftKey&&d(p[s+px(i,t,!0)])&&(a=!0):(d(p[s+px(u,t,!0)])||t.shiftKey&&(h=Gv[t.keyCode])!=i&&h!=u&&d(p[s+px(h,t,!1)]))&&(a=!0),!a&&d(p._any)&&(a=!0)),l&&(a=!0),a&&c&&t.stopPropagation(),kx=null,a}var Sx=function(){function e(t,n,r,i,o){N(this,e),this.className=t,this.left=n,this.top=r,this.width=i,this.height=o}return R(e,[{key:"draw",value:function(){var e=document.createElement("div");return e.className=this.className,this.adjust(e),e}},{key:"update",value:function(e,t){return t.className==this.className&&(this.adjust(e),!0)}},{key:"adjust",value:function(e){e.style.left=this.left+"px",e.style.top=this.top+"px",null!=this.width&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}},{key:"eq",value:function(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}}],[{key:"forRange",value:function(t,n,r){if(r.empty){var i=t.coordsAtPos(r.head,r.assoc||1);if(!i)return[];var o=Cx(t);return[new e(n,i.left-o.left,i.top-o.top,null,i.bottom-i.top)]}return Ax(t,n,r)}}])}();function Cx(e){var t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==Yy.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function Ex(e,t,n,r){var i=e.coordsAtPos(t,2*n);if(!i)return r;var o=e.dom.getBoundingClientRect(),s=(i.top+i.bottom)/2,a=e.posAtCoords({x:o.left+1,y:s}),l=e.posAtCoords({x:o.right-1,y:s});return null==a||null==l?r:{from:Math.max(r.from,Math.min(a,l)),to:Math.min(r.to,Math.max(a,l))}}function Ax(e,t,n){if(n.to<=e.viewport.from||n.from>=e.viewport.to)return[];var r=Math.max(n.from,e.viewport.from),i=Math.min(n.to,e.viewport.to),o=e.textDirection==Yy.LTR,s=e.contentDOM,a=s.getBoundingClientRect(),l=Cx(e),c=s.querySelector(".cm-line"),u=c&&window.getComputedStyle(c),h=a.left+(u?parseInt(u.paddingLeft)+Math.min(0,parseInt(u.textIndent)):0),f=a.right-(u?parseInt(u.paddingRight):0),d=Nw(e,r,1),p=Nw(e,i,-1),m=d.type==yy.Text?d:null,g=p.type==yy.Text?p:null;if(m&&(e.lineWrapping||d.widgetLineBreaks)&&(m=Ex(e,r,1,m)),g&&(e.lineWrapping||p.widgetLineBreaks)&&(g=Ex(e,i,-1,g)),m&&g&&m.from==g.from&&m.to==g.to)return k(x(n.from,n.to,m));var v=m?x(n.from,null,m):S(d,!1),y=g?x(null,n.to,g):S(p,!0),b=[];return(m||d).to<(g||p).from-(m&&g?1:0)||d.widgetLineBreaks>1&&v.bottom+e.defaultLineHeight/2<y.top?b.push(w(h,v.bottom,f,y.top)):v.bottom<y.top&&e.elementAtHeight((v.bottom+y.top)/2).type==yy.Text&&(v.bottom=y.top=(v.bottom+y.top)/2),k(v).concat(b).concat(k(y));function w(e,n,r,i){return new Sx(t,e-l.left,n-l.top,Math.max(0,r-e),i-n)}function k(e){for(var t=e.top,n=e.bottom,r=e.horizontal,i=[],o=0;o<r.length;o+=2)i.push(w(r[o],t,r[o+1],n));return i}function x(t,n,r){var i=1e9,s=-1e9,a=[];function l(t,n,l,c,u){var d=e.coordsAtPos(t,t==r.to?-2:2),p=e.coordsAtPos(l,l==r.from?2:-2);d&&p&&(i=Math.min(d.top,p.top,i),s=Math.max(d.bottom,p.bottom,s),u==Yy.LTR?a.push(o&&n?h:d.left,o&&c?f:p.right):a.push(!o&&c?h:p.left,!o&&n?f:d.right))}var c,u=null!=t?t:r.from,d=null!=n?n:r.to,p=D(e.visibleRanges);try{for(p.s();!(c=p.n()).done;){var m=c.value;if(m.to>u&&m.from<d)for(var g=Math.max(m.from,u),v=Math.min(m.to,d);;){var y,b=e.state.doc.lineAt(g),w=D(e.bidiSpans(b));try{for(w.s();!(y=w.n()).done;){var k=y.value,x=k.from+b.from,S=k.to+b.from;if(x>=v)break;S>g&&l(Math.max(x,g),null==t&&x<=u,Math.min(S,v),null==n&&S>=d,k.dir)}}catch(e){w.e(e)}finally{w.f()}if((g=b.to+1)>=v)break}}}catch(e){p.e(e)}finally{p.f()}return 0==a.length&&l(u,null==t,d,null==n,e.textDirection),{top:i,bottom:s,horizontal:a}}function S(e,t){var n=a.top+(t?e.top:e.bottom);return{top:n,bottom:n,horizontal:[]}}}var Mx=function(){return R(function e(t,n){N(this,e),this.view=t,this.layer=n,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=t.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),n.above&&this.dom.classList.add("cm-layer-above"),n.class&&this.dom.classList.add(n.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(t.state),t.requestMeasure(this.measureReq),n.mount&&n.mount(this.dom,t)},[{key:"update",value:function(e){e.startState.facet(Ox)!=e.state.facet(Ox)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}},{key:"docViewUpdate",value:function(e){!1!==this.layer.updateOnDocViewUpdate&&e.requestMeasure(this.measureReq)}},{key:"setOrder",value:function(e){for(var t=0,n=e.facet(Ox);t<n.length&&n[t]!=this.layer;)t++;this.dom.style.zIndex=String((this.layer.above?150:-1)-t)}},{key:"measure",value:function(){return this.layer.markers(this.view)}},{key:"scale",value:function(){var e=this.view,t=e.scaleX,n=e.scaleY;t==this.scaleX&&n==this.scaleY||(this.scaleX=t,this.scaleY=n,this.dom.style.transform="scale(".concat(1/t,", ").concat(1/n,")"))}},{key:"draw",value:function(e){var t=this;if(e.length!=this.drawn.length||e.some(function(e,n){return r=e,i=t.drawn[n],!(r.constructor==i.constructor&&r.eq(i));var r,i})){var n,r=this.dom.firstChild,i=0,o=D(e);try{for(o.s();!(n=o.n()).done;){var s=n.value;s.update&&r&&s.constructor&&this.drawn[i].constructor&&s.update(r,this.drawn[i])?(r=r.nextSibling,i++):this.dom.insertBefore(s.draw(),r)}}catch(e){o.e(e)}finally{o.f()}for(;r;){var a=r.nextSibling;r.remove(),r=a}this.drawn=e,hy.safari&&hy.safari_version>=26&&(this.dom.style.display=this.dom.firstChild?"":"none")}}},{key:"destroy",value:function(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}])}(),Ox=Dg.define();function Nx(e){return[_b.define(function(t){return new Mx(t,e)}),Ox.of(e)]}var Tx=Dg.define({combine:function(e){return wv(e,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:function(e,t){return Math.min(e,t)},drawRangeCursor:function(e,t){return e||t}})}});function Rx(e){return e.startState.facet(Tx)!=e.state.facet(Tx)}var Dx=Nx({above:!0,markers:function(e){var t,n=e.state,r=n.facet(Tx),i=[],o=D(n.selection.ranges);try{for(o.s();!(t=o.n()).done;){var s=t.value,a=s==n.selection.main;if(s.empty||r.drawRangeCursor){var l,c=a?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",u=s.empty?s:Ng.cursor(s.head,s.head>s.anchor?-1:1),h=D(Sx.forRange(e,c,u));try{for(h.s();!(l=h.n()).done;){var f=l.value;i.push(f)}}catch(e){h.e(e)}finally{h.f()}}}}catch(e){o.e(e)}finally{o.f()}return i},update:function(e,t){e.transactions.some(function(e){return e.selection})&&(t.style.animationName="cm-blink"==t.style.animationName?"cm-blink2":"cm-blink");var n=Rx(e);return n&&Px(e.state,t),e.docChanged||e.selectionSet||n},mount:function(e,t){Px(t.state,e)},class:"cm-cursorLayer"});function Px(e,t){t.style.animationDuration=e.facet(Tx).cursorBlinkRate+"ms"}var Lx=Nx({above:!1,markers:function(e){return e.state.selection.ranges.map(function(t){return t.empty?[]:Sx.forRange(e,"cm-selectionBackground",t)}).reduce(function(e,t){return e.concat(t)})},update:function(e,t){return e.docChanged||e.selectionSet||e.viewportChanged||Rx(e)},class:"cm-selectionLayer"}),Bx=qg.highest(lx.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),Ix=av.define({map:function(e,t){return null==e?null:t.mapPos(e)}}),_x=Fg.define({create:function(){return null},update:function(e,t){return null!=e&&(e=t.changes.mapPos(e)),t.effects.reduce(function(e,t){return t.is(Ix)?t.value:e},e)}}),Fx=_b.fromClass(function(){return R(function e(t){N(this,e),this.view=t,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}},[{key:"update",value:function(e){var t,n=e.state.field(_x);null==n?null!=this.cursor&&(null===(t=this.cursor)||void 0===t||t.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(e.startState.field(_x)!=n||e.docChanged||e.geometryChanged)&&this.view.requestMeasure(this.measureReq))}},{key:"readPos",value:function(){var e=this.view,t=e.state.field(_x),n=null!=t&&e.coordsAtPos(t);if(!n)return null;var r=e.scrollDOM.getBoundingClientRect();return{left:n.left-r.left+e.scrollDOM.scrollLeft*e.scaleX,top:n.top-r.top+e.scrollDOM.scrollTop*e.scaleY,height:n.bottom-n.top}}},{key:"drawCursor",value:function(e){if(this.cursor){var t=this.view,n=t.scaleX,r=t.scaleY;e?(this.cursor.style.left=e.left/n+"px",this.cursor.style.top=e.top/r+"px",this.cursor.style.height=e.height/r+"px"):this.cursor.style.left="-100000px"}}},{key:"destroy",value:function(){this.cursor&&this.cursor.remove()}},{key:"setDropPos",value:function(e){this.view.state.field(_x)!=e&&this.view.dispatch({effects:Ix.of(e)})}}])}(),{eventObservers:{dragover:function(e){this.setDropPos(this.view.posAtCoords({x:e.clientX,y:e.clientY}))},dragleave:function(e){e.target!=this.view.contentDOM&&this.view.contentDOM.contains(e.relatedTarget)||this.setDropPos(null)},dragend:function(){this.setDropPos(null)},drop:function(){this.setDropPos(null)}}});function Wx(e,t,n,r,i){t.lastIndex=0;for(var o,s=e.iterRange(n,r),a=n;!s.next().done;a+=s.value.length)if(!s.lineBreak)for(;o=t.exec(s.value);)i(a+o.index,o)}var jx=function(){return R(function e(t){N(this,e);var n=t.regexp,r=t.decoration,i=t.decorate,o=t.boundary,s=t.maxLength,a=void 0===s?1e3:s;if(!n.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=n,i)this.addMatch=function(e,t,n,r){return i(r,n,n+e[0].length,e,t)};else if("function"==typeof r)this.addMatch=function(e,t,n,i){var o=r(e,t,n);o&&i(n,n+e[0].length,o)};else{if(!r)throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.addMatch=function(e,t,n,i){return i(n,n+e[0].length,r)}}this.boundary=o,this.maxLength=a},[{key:"createDeco",value:function(e){var t,n=this,r=new Mv,i=r.add.bind(r),o=D(function(e,t){var n=e.visibleRanges;if(1==n.length&&n[0].from==e.viewport.from&&n[0].to==e.viewport.to)return n;var r,i=[],o=D(n);try{for(o.s();!(r=o.n()).done;){var s=r.value,a=s.from,l=s.to;a=Math.max(e.state.doc.lineAt(a).from,a-t),l=Math.min(e.state.doc.lineAt(l).to,l+t),i.length&&i[i.length-1].to>=a?i[i.length-1].to=l:i.push({from:a,to:l})}}catch(e){o.e(e)}finally{o.f()}return i}(e,this.maxLength));try{for(o.s();!(t=o.n()).done;){var s=t.value,a=s.from,l=s.to;Wx(e.state.doc,this.regexp,a,l,function(t,r){return n.addMatch(r,e,t,i)})}}catch(e){o.e(e)}finally{o.f()}return r.finish()}},{key:"updateDeco",value:function(e,t){var n=1e9,r=-1;return e.docChanged&&e.changes.iterChanges(function(t,i,o,s){s>=e.view.viewport.from&&o<=e.view.viewport.to&&(n=Math.min(o,n),r=Math.max(s,r))}),e.viewportMoved||r-n>1e3?this.createDeco(e.view):r>-1?this.updateRange(e.view,t.map(e.changes),n,r):t}},{key:"updateRange",value:function(e,t,n,r){var i,o=this,s=D(e.visibleRanges);try{var a=function(){var s=i.value,a=Math.max(s.from,n),l=Math.min(s.to,r);if(l>=a){var c=e.state.doc.lineAt(a),u=c.to<l?e.state.doc.lineAt(l):c,h=Math.max(s.from,c.from),f=Math.min(s.to,u.to);if(o.boundary){for(;a>c.from;a--)if(o.boundary.test(c.text[a-1-c.from])){h=a;break}for(;l<u.to;l++)if(o.boundary.test(u.text[l-u.from])){f=l;break}}var d,p=[],m=function(e,t,n){return p.push(n.range(e,t))};if(c==u)for(o.regexp.lastIndex=h-c.from;(d=o.regexp.exec(c.text))&&d.index<f-c.from;)o.addMatch(d,e,d.index+c.from,m);else Wx(e.state.doc,o.regexp,h,f,function(t,n){return o.addMatch(n,e,t,m)});t=t.update({filterFrom:h,filterTo:f,filter:function(e,t){return e<h||t>f},add:p})}};for(s.s();!(i=s.n()).done;)a()}catch(e){s.e(e)}finally{s.f()}return t}}])}(),Hx=null!=/x/.unicode?"gu":"g",zx=new RegExp("[\0-\b\n--Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\ufeff-]",Hx),Vx={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"},qx=null;var Ux=Dg.define({combine:function(e){var t=wv(e,{render:null,specialChars:zx,addSpecialChars:null});return(t.replaceTabs=!function(){var e;if(null==qx&&"undefined"!=typeof document&&document.body){var t=document.body.style;qx=null!=(null!==(e=t.tabSize)&&void 0!==e?e:t.MozTabSize)}return qx||!1}())&&(t.specialChars=new RegExp("\t|"+t.specialChars.source,Hx)),t.addSpecialChars&&(t.specialChars=new RegExp(t.specialChars.source+"|"+t.addSpecialChars.source,Hx)),t}});var Kx=null;var Gx=function(){function e(t,n){var r;return N(this,e),(r=O(this,e)).options=t,r.code=n,r}return I(e,vy),R(e,[{key:"eq",value:function(e){return e.code==this.code}},{key:"toDOM",value:function(e){var t=function(e){return e>=32?"•":10==e?"␤":String.fromCharCode(9216+e)}(this.code),n=e.state.phrase("Control character")+" "+(Vx[this.code]||"0x"+this.code.toString(16)),r=this.options.render&&this.options.render(this.code,n,t);if(r)return r;var i=document.createElement("span");return i.textContent=t,i.title=n,i.setAttribute("aria-label",n),i.className="cm-specialChar",i}},{key:"ignoreEvent",value:function(){return!1}}])}(),Yx=function(){function e(t){var n;return N(this,e),(n=O(this,e)).width=t,n}return I(e,vy),R(e,[{key:"eq",value:function(e){return e.width==this.width}},{key:"toDOM",value:function(){var e=document.createElement("span");return e.textContent="\t",e.className="cm-tab",e.style.width=this.width+"px",e}},{key:"ignoreEvent",value:function(){return!1}}])}();var $x=by.line({class:"cm-activeLine"}),Xx=_b.fromClass(function(){return R(function e(t){N(this,e),this.decorations=this.getDeco(t)},[{key:"update",value:function(e){(e.docChanged||e.selectionSet)&&(this.decorations=this.getDeco(e.view))}},{key:"getDeco",value:function(e){var t,n=-1,r=[],i=D(e.state.selection.ranges);try{for(i.s();!(t=i.n()).done;){var o=t.value,s=e.lineBlockAt(o.head);s.from>n&&(r.push($x.range(s.from)),n=s.from)}}catch(e){i.e(e)}finally{i.f()}return by.set(r)}}])}(),{decorations:function(e){return e.decorations}}),Jx=function(){function e(t){var n;return N(this,e),(n=O(this,e)).content=t,n}return I(e,vy),R(e,[{key:"toDOM",value:function(e){var t=document.createElement("span");return t.className="cm-placeholder",t.style.pointerEvents="none",t.appendChild("string"==typeof this.content?document.createTextNode(this.content):"function"==typeof this.content?this.content(e):this.content.cloneNode(!0)),t.setAttribute("aria-hidden","true"),t}},{key:"coordsAt",value:function(e){var t=e.firstChild?Ny(e.firstChild):[];if(!t.length)return null;var n=window.getComputedStyle(e.parentNode),r=By(t[0],"rtl"!=n.direction),i=parseInt(n.lineHeight);return r.bottom-r.top>1.5*i?{left:r.left,right:r.right,top:r.top,bottom:r.top+i}:r}},{key:"ignoreEvent",value:function(){return!1}}])}();var Qx=2e3;function Zx(e,t){var n=e.posAtCoords({x:t.clientX,y:t.clientY},!1),r=e.state.doc.lineAt(n),i=n-r.from,o=i>Qx?-1:i==r.length?function(e,t){var n=e.coordsAtPos(e.viewport.from);return n?Math.round(Math.abs((n.left-t)/e.defaultCharacterWidth)):-1}(e,t.clientX):Fv(r.text,e.state.tabSize,n-r.from);return{line:r.number,col:o,off:i}}function eS(e,t){var n=Zx(e,t),r=e.state.selection;return n?{update:function(e){if(e.docChanged){var t=e.changes.mapPos(e.startState.doc.line(n.line).from),i=e.state.doc.lineAt(t);n={line:i.number,col:n.col,off:Math.min(n.off,i.length)},r=r.map(e.changes)}},get:function(t,i,o){var s=Zx(e,t);if(!s)return r;var a=function(e,t,n){var r=Math.min(t.line,n.line),i=Math.max(t.line,n.line),o=[];if(t.off>Qx||n.off>Qx||t.col<0||n.col<0)for(var s=Math.min(t.off,n.off),a=Math.max(t.off,n.off),l=r;l<=i;l++){var c=e.doc.line(l);c.length<=a&&o.push(Ng.range(c.from+s,c.to+a))}else for(var u=Math.min(t.col,n.col),h=Math.max(t.col,n.col),f=r;f<=i;f++){var d=e.doc.line(f),p=Wv(d.text,u,e.tabSize,!0);if(p<0)o.push(Ng.cursor(d.to));else{var m=Wv(d.text,h,e.tabSize);o.push(Ng.range(d.from+p,d.from+m))}}return o}(e.state,n,s);return a.length?o?Ng.create(a.concat(r.ranges)):Ng.create(a):r}}:null}var tS={Alt:[18,function(e){return!!e.altKey}],Control:[17,function(e){return!!e.ctrlKey}],Shift:[16,function(e){return!!e.shiftKey}],Meta:[91,function(e){return!!e.metaKey}]},nS={style:"cursor: crosshair"};var rS="-10000px",iS=function(){return R(function e(t,n,r,i){N(this,e),this.facet=n,this.createTooltipView=r,this.removeTooltipView=i,this.input=t.state.facet(n),this.tooltips=this.input.filter(function(e){return e});var o=null;this.tooltipViews=this.tooltips.map(function(e){return o=r(e,o)})},[{key:"update",value:function(e,t){var n,r=e.state.facet(this.facet),i=r.filter(function(e){return e});if(r===this.input){var o,s=D(this.tooltipViews);try{for(s.s();!(o=s.n()).done;){var a=o.value;a.update&&a.update(e)}}catch(e){s.e(e)}finally{s.f()}return!1}for(var l=[],c=t?[]:null,u=0;u<i.length;u++){var h=i[u],f=-1;if(h){for(var d=0;d<this.tooltips.length;d++){var p=this.tooltips[d];p&&p.create==h.create&&(f=d)}if(f<0)l[u]=this.createTooltipView(h,u?l[u-1]:null),c&&(c[u]=!!h.above);else{var m=l[u]=this.tooltipViews[f];c&&(c[u]=t[f]),m.update&&m.update(e)}}}var g,v=D(this.tooltipViews);try{for(v.s();!(g=v.n()).done;){var y=g.value;l.indexOf(y)<0&&(this.removeTooltipView(y),null===(n=y.destroy)||void 0===n||n.call(y))}}catch(e){v.e(e)}finally{v.f()}return t&&(c.forEach(function(e,n){return t[n]=e}),t.length=c.length),this.input=r,this.tooltips=i,this.tooltipViews=l,!0}}])}();function oS(e){var t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}var sS=Dg.define({combine:function(e){var t,n,r;return{position:hy.ios?"absolute":(null===(t=e.find(function(e){return e.position}))||void 0===t?void 0:t.position)||"fixed",parent:(null===(n=e.find(function(e){return e.parent}))||void 0===n?void 0:n.parent)||null,tooltipSpace:(null===(r=e.find(function(e){return e.tooltipSpace}))||void 0===r?void 0:r.tooltipSpace)||oS}}}),aS=new WeakMap,lS=_b.fromClass(function(){return R(function e(t){var n=this;N(this,e),this.view=t,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;var r=t.state.facet(sS);this.position=r.position,this.parent=r.parent,this.classes=t.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver="function"==typeof ResizeObserver?new ResizeObserver(function(){return n.measureSoon()}):null,this.manager=new iS(t,fS,function(e,t){return n.createTooltip(e,t)},function(e){n.resizeObserver&&n.resizeObserver.unobserve(e.dom),e.dom.remove()}),this.above=this.manager.tooltips.map(function(e){return!!e.above}),this.intersectionObserver="function"==typeof IntersectionObserver?new IntersectionObserver(function(e){Date.now()>n.lastTransaction-50&&e.length>0&&e[e.length-1].intersectionRatio<1&&n.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),t.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()},[{key:"createContainer",value:function(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}},{key:"observeIntersection",value:function(){if(this.intersectionObserver){this.intersectionObserver.disconnect();var e,t=D(this.manager.tooltipViews);try{for(t.s();!(e=t.n()).done;){var n=e.value;this.intersectionObserver.observe(n.dom)}}catch(e){t.e(e)}finally{t.f()}}}},{key:"measureSoon",value:function(){var e=this;this.measureTimeout<0&&(this.measureTimeout=setTimeout(function(){e.measureTimeout=-1,e.maybeMeasure()},50))}},{key:"update",value:function(e){e.transactions.length&&(this.lastTransaction=Date.now());var t=this.manager.update(e,this.above);t&&this.observeIntersection();var n=t||e.geometryChanged,r=e.state.facet(sS);if(r.position!=this.position&&!this.madeAbsolute){this.position=r.position;var i,o=D(this.manager.tooltipViews);try{for(o.s();!(i=o.n()).done;){i.value.dom.style.position=this.position}}catch(e){o.e(e)}finally{o.f()}n=!0}if(r.parent!=this.parent){this.parent&&this.container.remove(),this.parent=r.parent,this.createContainer();var s,a=D(this.manager.tooltipViews);try{for(a.s();!(s=a.n()).done;){var l=s.value;this.container.appendChild(l.dom)}}catch(e){a.e(e)}finally{a.f()}n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}},{key:"createTooltip",value:function(e,t){var n=e.create(this.view),r=t?t.dom:null;if(n.dom.classList.add("cm-tooltip"),e.arrow&&!n.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){var i=document.createElement("div");i.className="cm-tooltip-arrow",n.dom.appendChild(i)}return n.dom.style.position=this.position,n.dom.style.top=rS,n.dom.style.left="0px",this.container.insertBefore(n.dom,r),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}},{key:"destroy",value:function(){var e,t,n;this.view.win.removeEventListener("resize",this.measureSoon);var r,i=D(this.manager.tooltipViews);try{for(i.s();!(r=i.n()).done;){var o=r.value;o.dom.remove(),null===(e=o.destroy)||void 0===e||e.call(o)}}catch(e){i.e(e)}finally{i.f()}this.parent&&this.container.remove(),null===(t=this.resizeObserver)||void 0===t||t.disconnect(),null===(n=this.intersectionObserver)||void 0===n||n.disconnect(),clearTimeout(this.measureTimeout)}},{key:"readMeasure",value:function(){var e=this,t=1,n=1,r=!1;if("fixed"==this.position&&this.manager.tooltipViews.length){var i=this.manager.tooltipViews[0].dom;if(hy.safari){var o=i.getBoundingClientRect();r=Math.abs(o.top+1e4)>1||Math.abs(o.left)>1}else r=!!i.offsetParent&&i.offsetParent!=this.container.ownerDocument.body}if(r||"absolute"==this.position)if(this.parent){var s=this.parent.getBoundingClientRect();s.width&&s.height&&(t=s.width/this.parent.offsetWidth,n=s.height/this.parent.offsetHeight)}else{var a=this.view.viewState;t=a.scaleX,n=a.scaleY}var l=this.view.scrollDOM.getBoundingClientRect(),c=Yb(this.view);return{visible:{left:l.left+c.left,top:l.top+c.top,right:l.right-c.right,bottom:l.bottom-c.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map(function(t,n){var r=e.manager.tooltipViews[n];return r.getCoords?r.getCoords(t.pos):e.view.coordsAtPos(t.pos)}),size:this.manager.tooltipViews.map(function(e){return e.dom.getBoundingClientRect()}),space:this.view.state.facet(sS).tooltipSpace(this.view),scaleX:t,scaleY:n,makeAbsolute:r}}},{key:"writeMeasure",value:function(e){var t;if(e.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";var n,r=D(this.manager.tooltipViews);try{for(r.s();!(n=r.n()).done;){n.value.dom.style.position="absolute"}}catch(e){r.e(e)}finally{r.f()}}for(var i=e.visible,o=e.space,s=e.scaleX,a=e.scaleY,l=[],c=0;c<this.manager.tooltips.length;c++){var u=this.manager.tooltips[c],h=this.manager.tooltipViews[c],f=h.dom,d=e.pos[c],p=e.size[c];if(!d||!1!==u.clip&&(d.bottom<=Math.max(i.top,o.top)||d.top>=Math.min(i.bottom,o.bottom)||d.right<Math.max(i.left,o.left)-.1||d.left>Math.min(i.right,o.right)+.1))f.style.top=rS;else{var m=u.arrow?h.dom.querySelector(".cm-tooltip-arrow"):null,g=m?7:0,v=p.right-p.left,y=null!==(t=aS.get(h))&&void 0!==t?t:p.bottom-p.top,b=h.offset||hS,w=this.view.textDirection==Yy.LTR,k=p.width>o.right-o.left?w?o.left:o.right-p.width:w?Math.max(o.left,Math.min(d.left-(m?14:0)+b.x,o.right-v)):Math.min(Math.max(o.left,d.left-v+(m?14:0)-b.x),o.right-v),x=this.above[c];!u.strictSide&&(x?d.top-y-g-b.y<o.top:d.bottom+y+g+b.y>o.bottom)&&x==o.bottom-d.bottom>d.top-o.top&&(x=this.above[c]=!x);var S=(x?d.top-o.top:o.bottom-d.bottom)-g;if(S<y&&!1!==h.resize){if(S<this.view.defaultLineHeight){f.style.top=rS;continue}aS.set(h,y),f.style.height=(y=S)/a+"px"}else f.style.height&&(f.style.height="");var C=x?d.top-y-g-b.y:d.bottom+g+b.y,E=k+v;if(!0!==h.overlap){var A,M=D(l);try{for(M.s();!(A=M.n()).done;){var O=A.value;O.left<E&&O.right>k&&O.top<C+y&&O.bottom>C&&(C=x?O.top-y-2-g:O.bottom+g+2)}}catch(e){M.e(e)}finally{M.f()}}if("absolute"==this.position?(f.style.top=(C-e.parent.top)/a+"px",cS(f,(k-e.parent.left)/s)):(f.style.top=C/a+"px",cS(f,k/s)),m){var N=d.left+(w?b.x:-b.x)-(k+14-7);m.style.left=N/s+"px"}!0!==h.overlap&&l.push({left:k,top:C,right:E,bottom:C+y}),f.classList.toggle("cm-tooltip-above",x),f.classList.toggle("cm-tooltip-below",!x),h.positioned&&h.positioned(e.space)}}}},{key:"maybeMeasure",value:function(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView))){var e,t=D(this.manager.tooltipViews);try{for(t.s();!(e=t.n()).done;){e.value.dom.style.top=rS}}catch(e){t.e(e)}finally{t.f()}}}}])}(),{eventObservers:{scroll:function(){this.maybeMeasure()}}});function cS(e,t){var n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+"px")}var uS=lx.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"".concat(7,"px"),width:"".concat(14,"px"),position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"".concat(7,"px solid transparent"),borderRight:"".concat(7,"px solid transparent")},".cm-tooltip-above &":{bottom:"-".concat(7,"px"),"&:before":{borderTop:"".concat(7,"px solid #bbb")},"&:after":{borderTop:"".concat(7,"px solid #f5f5f5"),bottom:"1px"}},".cm-tooltip-below &":{top:"-".concat(7,"px"),"&:before":{borderBottom:"".concat(7,"px solid #bbb")},"&:after":{borderBottom:"".concat(7,"px solid #f5f5f5"),top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),hS={x:0,y:0},fS=Dg.define({enables:[lS,uS]}),dS=Dg.define({combine:function(e){return e.reduce(function(e,t){return e.concat(t)},[])}}),pS=function(){function e(t){var n=this;N(this,e),this.view=t,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new iS(t,dS,function(e,t){return n.createHostedView(e,t)},function(e){return e.dom.remove()})}return R(e,[{key:"createHostedView",value:function(e,t){var n=e.create(this.view);return n.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(n.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&n.mount&&n.mount(this.view),n}},{key:"mount",value:function(e){var t,n=D(this.manager.tooltipViews);try{for(n.s();!(t=n.n()).done;){var r=t.value;r.mount&&r.mount(e)}}catch(e){n.e(e)}finally{n.f()}this.mounted=!0}},{key:"positioned",value:function(e){var t,n=D(this.manager.tooltipViews);try{for(n.s();!(t=n.n()).done;){var r=t.value;r.positioned&&r.positioned(e)}}catch(e){n.e(e)}finally{n.f()}}},{key:"update",value:function(e){this.manager.update(e)}},{key:"destroy",value:function(){var e,t,n=D(this.manager.tooltipViews);try{for(n.s();!(t=n.n()).done;){var r=t.value;null===(e=r.destroy)||void 0===e||e.call(r)}}catch(e){n.e(e)}finally{n.f()}}},{key:"passProp",value:function(e){var t,n=void 0,r=D(this.manager.tooltipViews);try{for(r.s();!(t=r.n()).done;){var i=t.value[e];if(void 0!==i)if(void 0===n)n=i;else if(n!==i)return}}catch(e){r.e(e)}finally{r.f()}return n}},{key:"offset",get:function(){return this.passProp("offset")}},{key:"getCoords",get:function(){return this.passProp("getCoords")}},{key:"overlap",get:function(){return this.passProp("overlap")}},{key:"resize",get:function(){return this.passProp("resize")}}],[{key:"create",value:function(t){return new e(t)}}])}(),mS=fS.compute([dS],function(e){var t=e.facet(dS);return 0===t.length?null:{pos:Math.min.apply(Math,K(t.map(function(e){return e.pos}))),end:Math.max.apply(Math,K(t.map(function(e){var t;return null!==(t=e.end)&&void 0!==t?t:e.pos}))),create:pS.create,above:t[0].above,arrow:t.some(function(e){return e.arrow})}}),gS=function(){return R(function e(t,n,r,i,o){N(this,e),this.view=t,this.source=n,this.field=r,this.setHover=i,this.hoverTime=o,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:t.dom,time:0},this.checkHover=this.checkHover.bind(this),t.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),t.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))},[{key:"update",value:function(){var e=this;this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(function(){return e.startHover()},20))}},{key:"active",get:function(){return this.view.state.field(this.field)}},{key:"checkHover",value:function(){if(this.hoverTimeout=-1,!this.active.length){var e=Date.now()-this.lastMove.time;e<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-e):this.startHover()}}},{key:"startHover",value:function(){var e=this;clearTimeout(this.restartTimeout);var t=this.view,n=this.lastMove,r=t.docView.tile.nearest(n.target);if(r){var i,o=1;if(r.isWidget())i=r.posAtStart;else{if(null==(i=t.posAtCoords(n)))return;var s=t.coordsAtPos(i);if(!s||n.y<s.top||n.y>s.bottom||n.x<s.left-t.defaultCharacterWidth||n.x>s.right+t.defaultCharacterWidth)return;var a=t.bidiSpans(t.state.doc.lineAt(i)).find(function(e){return e.from<=i&&e.to>=i}),l=a&&a.dir==Yy.RTL?-1:1;o=n.x<s.left?-l:l}var c=this.source(t,i,o);if(null==c?void 0:c.then){var u=this.pending={pos:i};c.then(function(n){e.pending==u&&(e.pending=null,!n||Array.isArray(n)&&!n.length||t.dispatch({effects:e.setHover.of(Array.isArray(n)?n:[n])}))},function(e){return Pb(t.state,e,"hover tooltip")})}else!c||Array.isArray(c)&&!c.length||t.dispatch({effects:this.setHover.of(Array.isArray(c)?c:[c])})}}},{key:"tooltip",get:function(){var e=this.view.plugin(lS),t=e?e.manager.tooltips.findIndex(function(e){return e.create==pS.create}):-1;return t>-1?e.manager.tooltipViews[t]:null}},{key:"mousemove",value:function(e){var t,n;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));var r=this.active,i=this.tooltip;if(r.length&&i&&!function(e,t){var n,r=e.getBoundingClientRect(),i=r.left,o=r.right,s=r.top,a=r.bottom;if(n=e.querySelector(".cm-tooltip-arrow")){var l=n.getBoundingClientRect();s=Math.min(l.top,s),a=Math.max(l.bottom,a)}return t.clientX>=i-vS&&t.clientX<=o+vS&&t.clientY>=s-vS&&t.clientY<=a+vS}(i.dom,e)||this.pending){var o=(r[0]||this.pending).pos,s=null!==(n=null===(t=r[0])||void 0===t?void 0:t.end)&&void 0!==n?n:o;(o==s?this.view.posAtCoords(this.lastMove)==o:function(e,t,n,r,i){var o=e.scrollDOM.getBoundingClientRect(),s=e.documentTop+e.documentPadding.top+e.contentHeight;if(o.left>r||o.right<r||o.top>i||Math.min(o.bottom,s)<i)return!1;var a=e.posAtCoords({x:r,y:i},!1);return a>=t&&a<=n}(this.view,o,s,e.clientX,e.clientY))||(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}},{key:"mouseleave",value:function(e){if(clearTimeout(this.hoverTimeout),this.hoverTimeout=-1,this.active.length){var t=this.tooltip;t&&t.dom.contains(e.relatedTarget)?this.watchTooltipLeave(t.dom):this.view.dispatch({effects:this.setHover.of([])})}}},{key:"watchTooltipLeave",value:function(e){var t=this,n=function(r){e.removeEventListener("mouseleave",n),t.active.length&&!t.view.dom.contains(r.relatedTarget)&&t.view.dispatch({effects:t.setHover.of([])})};e.addEventListener("mouseleave",n)}},{key:"destroy",value:function(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}])}(),vS=4;function yS(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=av.define(),r=Fg.define({create:function(){return[]},update:function(e,r){if(e.length&&(t.hideOnChange&&(r.docChanged||r.selection)?e=[]:t.hideOn&&(e=e.filter(function(e){return!t.hideOn(r,e)})),r.docChanged)){var i,o=[],s=D(e);try{for(s.s();!(i=s.n()).done;){var a=i.value,l=r.changes.mapPos(a.pos,-1,bg.TrackDel);if(null!=l){var c=Object.assign(Object.create(null),a);c.pos=l,null!=c.end&&(c.end=r.changes.mapPos(c.end)),o.push(c)}}}catch(e){s.e(e)}finally{s.f()}e=o}var u,h=D(r.effects);try{for(h.s();!(u=h.n()).done;){var f=u.value;f.is(n)&&(e=f.value),f.is(wS)&&(e=[])}}catch(e){h.e(e)}finally{h.f()}return e},provide:function(e){return dS.from(e)}});return{active:r,extension:[r,_b.define(function(i){return new gS(i,e,r,n,t.hoverTime||300)}),mS]}}function bS(e,t){var n=e.plugin(lS);if(!n)return null;var r=n.manager.tooltips.indexOf(t);return r<0?null:n.manager.tooltipViews[r]}var wS=av.define(),kS=Dg.define({combine:function(e){var t,n,r,i=D(e);try{for(i.s();!(r=i.n()).done;){var o=r.value;t=t||o.topContainer,n=n||o.bottomContainer}}catch(e){i.e(e)}finally{i.f()}return{topContainer:t,bottomContainer:n}}});function xS(e,t){var n=e.plugin(SS),r=n?n.specs.indexOf(t):-1;return r>-1?n.panels[r]:null}var SS=_b.fromClass(function(){return R(function e(t){N(this,e),this.input=t.state.facet(AS),this.specs=this.input.filter(function(e){return e}),this.panels=this.specs.map(function(e){return e(t)});var n=t.state.facet(kS);this.top=new CS(t,!0,n.topContainer),this.bottom=new CS(t,!1,n.bottomContainer),this.top.sync(this.panels.filter(function(e){return e.top})),this.bottom.sync(this.panels.filter(function(e){return!e.top}));var r,i=D(this.panels);try{for(i.s();!(r=i.n()).done;){var o=r.value;o.dom.classList.add("cm-panel"),o.mount&&o.mount()}}catch(e){i.e(e)}finally{i.f()}},[{key:"update",value:function(e){var t=e.state.facet(kS);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new CS(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new CS(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();var n=e.state.facet(AS);if(n!=this.input){var r,i=n.filter(function(e){return e}),o=[],s=[],a=[],l=[],c=D(i);try{for(c.s();!(r=c.n()).done;){var u=r.value,h=this.specs.indexOf(u),f=void 0;h<0?(f=u(e.view),l.push(f)):(f=this.panels[h]).update&&f.update(e),o.push(f),(f.top?s:a).push(f)}}catch(e){c.e(e)}finally{c.f()}this.specs=i,this.panels=o,this.top.sync(s),this.bottom.sync(a);for(var d=0,p=l;d<p.length;d++){var m=p[d];m.dom.classList.add("cm-panel"),m.mount&&m.mount()}}else{var g,v=D(this.panels);try{for(v.s();!(g=v.n()).done;){var y=g.value;y.update&&y.update(e)}}catch(e){v.e(e)}finally{v.f()}}}},{key:"destroy",value:function(){this.top.sync([]),this.bottom.sync([])}}])}(),{provide:function(e){return lx.scrollMargins.of(function(t){var n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})}}),CS=function(){return R(function e(t,n,r){N(this,e),this.view=t,this.top=n,this.container=r,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()},[{key:"sync",value:function(e){var t,n=D(this.panels);try{for(n.s();!(t=n.n()).done;){var r=t.value;r.destroy&&e.indexOf(r)<0&&r.destroy()}}catch(e){n.e(e)}finally{n.f()}this.panels=e,this.syncDOM()}},{key:"syncDOM",value:function(){if(0!=this.panels.length){if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";var e=this.container||this.view.dom;e.insertBefore(this.dom,this.top?e.firstChild:null)}var t,n=this.dom.firstChild,r=D(this.panels);try{for(r.s();!(t=r.n()).done;){var i=t.value;if(i.dom.parentNode==this.dom){for(;n!=i.dom;)n=ES(n);n=n.nextSibling}else this.dom.insertBefore(i.dom,n)}}catch(e){r.e(e)}finally{r.f()}for(;n;)n=ES(n)}else this.dom&&(this.dom.remove(),this.dom=void 0)}},{key:"scrollMargin",value:function(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}},{key:"syncClasses",value:function(){if(this.container&&this.classes!=this.view.themeClasses){var e,t=D(this.classes.split(" "));try{for(t.s();!(e=t.n()).done;){var n=e.value;n&&this.container.classList.remove(n)}}catch(e){t.e(e)}finally{t.f()}var r,i=D((this.classes=this.view.themeClasses).split(" "));try{for(i.s();!(r=i.n()).done;){var o=r.value;o&&this.container.classList.add(o)}}catch(e){i.e(e)}finally{i.f()}}}}])}();function ES(e){var t=e.nextSibling;return e.remove(),t}var AS=Dg.define({enables:SS});function MS(e,t){var n,r=new Promise(function(e){return n=e}),i=function(e){return function(e,t,n){var r=t.content?t.content(e,function(){return c(null)}):null;if(!r){if(r=Qv("form"),t.input){var i=Qv("input",t.input);/^(text|password|number|email|tel|url)$/.test(i.type)&&i.classList.add("cm-textfield"),i.name||(i.name="input"),r.appendChild(Qv("label",(t.label||"")+": ",i))}else r.appendChild(document.createTextNode(t.label||""));r.appendChild(document.createTextNode(" ")),r.appendChild(Qv("button",{class:"cm-button",type:"submit"},t.submitLabel||"OK"))}for(var o="FORM"==r.nodeName?[r]:r.querySelectorAll("form"),s=function(){var e=o[a];e.addEventListener("keydown",function(t){27==t.keyCode?(t.preventDefault(),c(null)):13==t.keyCode&&(t.preventDefault(),c(e))}),e.addEventListener("submit",function(t){t.preventDefault(),c(e)})},a=0;a<o.length;a++)s();var l=Qv("div",r,Qv("button",{onclick:function(){return c(null)},"aria-label":e.state.phrase("close"),class:"cm-dialog-close",type:"button"},["×"]));t.class&&(l.className=t.class);function c(t){l.contains(l.ownerDocument.activeElement)&&e.focus(),n(t)}return l.classList.add("cm-dialog"),{dom:l,top:t.top,mount:function(){var e;t.focus&&((e="string"==typeof t.focus?r.querySelector(t.focus):r.querySelector("input")||r.querySelector("button"))&&"select"in e?e.select():e&&"focus"in e&&e.focus())}}}(e,t,n)};e.state.field(OS,!1)?e.dispatch({effects:NS.of(i)}):e.dispatch({effects:av.appendConfig.of(OS.init(function(){return[i]}))});var o=TS.of(i);return{close:o,result:r.then(function(t){return(e.win.queueMicrotask||function(t){return e.win.setTimeout(t,10)})(function(){e.state.field(OS).indexOf(i)>-1&&e.dispatch({effects:o})}),t})}}var OS=Fg.define({create:function(){return[]},update:function(e,t){var n,r=D(t.effects);try{var i=function(){var t=n.value;t.is(NS)?e=[t.value].concat(e):t.is(TS)&&(e=e.filter(function(e){return e!=t.value}))};for(r.s();!(n=r.n()).done;)i()}catch(e){r.e(e)}finally{r.f()}return e},provide:function(e){return AS.computeN([e],function(t){return t.field(e)})}}),NS=av.define(),TS=av.define();var RS=function(){function e(){return N(this,e),O(this,e,arguments)}return I(e,kv),R(e,[{key:"compare",value:function(e){return this==e||this.constructor==e.constructor&&this.eq(e)}},{key:"eq",value:function(e){return!1}},{key:"destroy",value:function(e){}}])}();RS.prototype.elementClass="",RS.prototype.toDOM=void 0,RS.prototype.mapMode=bg.TrackBefore,RS.prototype.startSide=RS.prototype.endSide=-1,RS.prototype.point=!0;var DS=Dg.define(),PS=Dg.define(),LS={class:"",renderEmptyElements:!1,elementStyle:"",markers:function(){return Av.empty},lineMarker:function(){return null},widgetMarker:function(){return null},lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},BS=Dg.define();function IS(e){return[FS(),BS.of(W(W({},LS),e))]}var _S=Dg.define({combine:function(e){return e.some(function(e){return e})}});function FS(e){var t=[WS];return e&&!1===e.fixed&&t.push(_S.of(!0)),t}var WS=_b.fromClass(function(){return R(function e(t){N(this,e),this.view=t,this.domAfter=null,this.prevViewport=t.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=t.state.facet(BS).map(function(e){return new VS(t,e)}),this.fixed=!t.state.facet(_S);var n,r=D(this.gutters);try{for(r.s();!(n=r.n()).done;){var i=n.value;"after"==i.config.side?this.getDOMAfter().appendChild(i.dom):this.dom.appendChild(i.dom)}}catch(e){r.e(e)}finally{r.f()}this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),t.scrollDOM.insertBefore(this.dom,t.contentDOM)},[{key:"getDOMAfter",value:function(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}},{key:"update",value:function(e){if(this.updateGutters(e)){var t=this.prevViewport,n=e.view.viewport,r=Math.min(t.to,n.to)-Math.max(t.from,n.from);this.syncGutters(r<.8*(n.to-n.from))}if(e.geometryChanged){var i=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=i,this.domAfter&&(this.domAfter.style.minHeight=i)}this.view.state.facet(_S)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=e.view.viewport}},{key:"syncGutters",value:function(e){var t=this,n=this.dom.nextSibling;e&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());var r,i=Av.iter(this.view.state.facet(DS),this.view.viewport.from),o=[],s=this.gutters.map(function(e){return new zS(e,t.view.viewport,-t.view.documentPadding.top)}),a=D(this.view.viewportLineBlocks);try{for(a.s();!(r=a.n()).done;){var l=r.value;if(o.length&&(o=[]),Array.isArray(l.type)){var c,u=!0,h=D(l.type);try{for(h.s();!(c=h.n()).done;){var f=c.value;if(f.type==yy.Text&&u){HS(i,o,f.from);var d,p=D(s);try{for(p.s();!(d=p.n()).done;){d.value.line(this.view,f,o)}}catch(e){p.e(e)}finally{p.f()}u=!1}else if(f.widget){var m,g=D(s);try{for(g.s();!(m=g.n()).done;){m.value.widget(this.view,f)}}catch(e){g.e(e)}finally{g.f()}}}}catch(e){h.e(e)}finally{h.f()}}else if(l.type==yy.Text){HS(i,o,l.from);var v,y=D(s);try{for(y.s();!(v=y.n()).done;){v.value.line(this.view,l,o)}}catch(e){y.e(e)}finally{y.f()}}else if(l.widget){var b,w=D(s);try{for(w.s();!(b=w.n()).done;){b.value.widget(this.view,l)}}catch(e){w.e(e)}finally{w.f()}}}}catch(e){a.e(e)}finally{a.f()}var k,x=D(s);try{for(x.s();!(k=x.n()).done;){k.value.finish()}}catch(e){x.e(e)}finally{x.f()}e&&(this.view.scrollDOM.insertBefore(this.dom,n),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}},{key:"updateGutters",value:function(e){var t=e.startState.facet(BS),n=e.state.facet(BS),r=e.docChanged||e.heightChanged||e.viewportChanged||!Av.eq(e.startState.facet(DS),e.state.facet(DS),e.view.viewport.from,e.view.viewport.to);if(t==n){var i,o=D(this.gutters);try{for(o.s();!(i=o.n()).done;){i.value.update(e)&&(r=!0)}}catch(e){o.e(e)}finally{o.f()}}else{r=!0;var s,a=[],l=D(n);try{for(l.s();!(s=l.n()).done;){var c=s.value,u=t.indexOf(c);u<0?a.push(new VS(this.view,c)):(this.gutters[u].update(e),a.push(this.gutters[u]))}}catch(e){l.e(e)}finally{l.f()}var h,f=D(this.gutters);try{for(f.s();!(h=f.n()).done;){var d=h.value;d.dom.remove(),a.indexOf(d)<0&&d.destroy()}}catch(e){f.e(e)}finally{f.f()}for(var p=0,m=a;p<m.length;p++){var g=m[p];"after"==g.config.side?this.getDOMAfter().appendChild(g.dom):this.dom.appendChild(g.dom)}this.gutters=a}return r}},{key:"destroy",value:function(){var e,t=D(this.gutters);try{for(t.s();!(e=t.n()).done;){e.value.destroy()}}catch(e){t.e(e)}finally{t.f()}this.dom.remove(),this.domAfter&&this.domAfter.remove()}}])}(),{provide:function(e){return lx.scrollMargins.of(function(t){var n=t.plugin(e);if(!n||0==n.gutters.length||!n.fixed)return null;var r=n.dom.offsetWidth*t.scaleX,i=n.domAfter?n.domAfter.offsetWidth*t.scaleX:0;return t.textDirection==Yy.LTR?{left:r,right:i}:{right:r,left:i}})}});function jS(e){return Array.isArray(e)?e:[e]}function HS(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}var zS=function(){return R(function e(t,n,r){N(this,e),this.gutter=t,this.height=r,this.i=0,this.cursor=Av.iter(t.markers,n.from)},[{key:"addElement",value:function(e,t,n){var r=this.gutter,i=(t.top-this.height)/e.scaleY,o=t.height/e.scaleY;if(this.i==r.elements.length){var s=new qS(e,o,i,n);r.elements.push(s),r.dom.appendChild(s.dom)}else r.elements[this.i].update(e,o,i,n);this.height=t.bottom,this.i++}},{key:"line",value:function(e,t,n){var r=[];HS(this.cursor,r,t.from),n.length&&(r=r.concat(n));var i=this.gutter.config.lineMarker(e,t,r);i&&r.unshift(i);var o=this.gutter;(0!=r.length||o.config.renderEmptyElements)&&this.addElement(e,t,r)}},{key:"widget",value:function(e,t){var n,r=this.gutter.config.widgetMarker(e,t.widget,t),i=r?[r]:null,o=D(e.state.facet(PS));try{for(o.s();!(n=o.n()).done;){var s=(0,n.value)(e,t.widget,t);s&&(i||(i=[])).push(s)}}catch(e){o.e(e)}finally{o.f()}i&&this.addElement(e,t,i)}},{key:"finish",value:function(){for(var e=this.gutter;e.elements.length>this.i;){var t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}])}(),VS=function(){return R(function e(t,n){var r=this;N(this,e),this.view=t,this.config=n,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");var i=function(e){r.dom.addEventListener(e,function(i){var o,s=i.target;if(s!=r.dom&&r.dom.contains(s)){for(;s.parentNode!=r.dom;)s=s.parentNode;var a=s.getBoundingClientRect();o=(a.top+a.bottom)/2}else o=i.clientY;var l=t.lineBlockAtHeight(o-t.documentTop);n.domEventHandlers[e](t,l,i)&&i.preventDefault()})};for(var o in n.domEventHandlers)i(o);this.markers=jS(n.markers(t)),n.initialSpacer&&(this.spacer=new qS(t,0,0,[n.initialSpacer(t)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")},[{key:"update",value:function(e){var t=this.markers;if(this.markers=jS(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){var n=this.config.updateSpacer(this.spacer.markers[0],e);n!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[n])}var r=e.view.viewport;return!Av.eq(this.markers,t,r.from,r.to)||!!this.config.lineMarkerChange&&this.config.lineMarkerChange(e)}},{key:"destroy",value:function(){var e,t=D(this.elements);try{for(t.s();!(e=t.n()).done;){e.value.destroy()}}catch(e){t.e(e)}finally{t.f()}}}])}(),qS=function(){return R(function e(t,n,r,i){N(this,e),this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(t,n,r,i)},[{key:"update",value:function(e,t,n,r){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=n&&(this.dom.style.marginTop=(this.above=n)?n+"px":""),function(e,t){if(e.length!=t.length)return!1;for(var n=0;n<e.length;n++)if(!e[n].compare(t[n]))return!1;return!0}(this.markers,r)||this.setMarkers(e,r)}},{key:"setMarkers",value:function(e,t){for(var n="cm-gutterElement",r=this.dom.firstChild,i=0,o=0;;){var s=o,a=i<t.length?t[i++]:null,l=!1;if(a){var c=a.elementClass;c&&(n+=" "+c);for(var u=o;u<this.markers.length;u++)if(this.markers[u].compare(a)){s=u,l=!0;break}}else s=this.markers.length;for(;o<s;){var h=this.markers[o++];if(h.toDOM){h.destroy(r);var f=r.nextSibling;r.remove(),r=f}}if(!a)break;a.toDOM&&(l?r=r.nextSibling:this.dom.insertBefore(a.toDOM(e),r)),l&&o++}this.dom.className=n,this.markers=t}},{key:"destroy",value:function(){this.setMarkers(null,[])}}])}();var US=Dg.define(),KS=Dg.define(),GS=Dg.define({combine:function(e){return wv(e,{formatNumber:String,domEventHandlers:{}},{domEventHandlers:function(e,t){var n=Object.assign({},e),r=function(){var e=n[i],r=t[i];n[i]=e?function(t,n,i){return e(t,n,i)||r(t,n,i)}:r};for(var i in t)r();return n}})}}),YS=function(){function e(t){var n;return N(this,e),(n=O(this,e)).number=t,n}return I(e,RS),R(e,[{key:"eq",value:function(e){return this.number==e.number}},{key:"toDOM",value:function(){return document.createTextNode(this.number)}}])}();function $S(e,t){return e.state.facet(GS).formatNumber(t,e.state)}var XS=BS.compute([GS],function(e){return{class:"cm-lineNumbers",renderEmptyElements:!1,markers:function(e){return e.state.facet(US)},lineMarker:function(e,t,n){return n.some(function(e){return e.toDOM})?null:new YS($S(e,e.state.doc.lineAt(t.from).number))},widgetMarker:function(e,t,n){var r,i=D(e.state.facet(KS));try{for(i.s();!(r=i.n()).done;){var o=(0,r.value)(e,t,n);if(o)return o}}catch(e){i.e(e)}finally{i.f()}return null},lineMarkerChange:function(e){return e.startState.facet(GS)!=e.state.facet(GS)},initialSpacer:function(e){return new YS($S(e,JS(e.state.doc.lines)))},updateSpacer:function(e,t){var n=$S(t.view,JS(t.view.state.doc.lines));return n==e.number?e:new YS(n)},domEventHandlers:e.facet(GS).domEventHandlers,side:"before"}});function JS(e){for(var t=9;t<e;)t=10*t+9;return t}var QS=new(function(){function e(){var t;return N(this,e),(t=O(this,e,arguments)).elementClass="cm-activeLineGutter",t}return I(e,RS),R(e)}()),ZS=DS.compute(["selection"],function(e){var t,n=[],r=-1,i=D(e.selection.ranges);try{for(i.s();!(t=i.n()).done;){var o=t.value,s=e.doc.lineAt(o.head).from;s>r&&(r=s,n.push(QS.range(s)))}}catch(e){i.e(e)}finally{i.f()}return Av.of(n)});var eC=0,tC=R(function e(t,n){N(this,e),this.from=t,this.to=n}),nC=function(){return R(function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};N(this,e),this.id=eC++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||function(){throw new Error("This node type doesn't define a deserialize function")},this.combine=t.combine||null},[{key:"add",value:function(e){var t=this;if(this.perNode)throw new RangeError("Can't add per-node props to node types");return"function"!=typeof e&&(e=oC.match(e)),function(n){var r=e(n);return void 0===r?null:[t,r]}}}])}();nC.closedBy=new nC({deserialize:function(e){return e.split(" ")}}),nC.openedBy=new nC({deserialize:function(e){return e.split(" ")}}),nC.group=new nC({deserialize:function(e){return e.split(" ")}}),nC.isolate=new nC({deserialize:function(e){if(e&&"rtl"!=e&&"ltr"!=e&&"auto"!=e)throw new RangeError("Invalid value for isolate: "+e);return e||"auto"}}),nC.contextHash=new nC({perNode:!0}),nC.lookAhead=new nC({perNode:!0}),nC.mounted=new nC({perNode:!0});var rC=function(){return R(function e(t,n,r){var i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];N(this,e),this.tree=t,this.overlay=n,this.parser=r,this.bracketed=i},null,[{key:"get",value:function(e){return e&&e.props&&e.props[nC.mounted.id]}}])}(),iC=Object.create(null),oC=function(){function e(t,n,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;N(this,e),this.name=t,this.props=n,this.id=r,this.flags=i}return R(e,[{key:"prop",value:function(e){return this.props[e.id]}},{key:"isTop",get:function(){return(1&this.flags)>0}},{key:"isSkipped",get:function(){return(2&this.flags)>0}},{key:"isError",get:function(){return(4&this.flags)>0}},{key:"isAnonymous",get:function(){return(8&this.flags)>0}},{key:"is",value:function(e){if("string"==typeof e){if(this.name==e)return!0;var t=this.prop(nC.group);return!!t&&t.indexOf(e)>-1}return this.id==e}}],[{key:"define",value:function(t){var n=t.props&&t.props.length?Object.create(null):iC,r=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(null==t.name?8:0),i=new e(t.name||"",n,t.id,r);if(t.props){var o,s=D(t.props);try{for(s.s();!(o=s.n()).done;){var a=o.value;if(Array.isArray(a)||(a=a(i)),a){if(a[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[a[0].id]=a[1]}}}catch(e){s.e(e)}finally{s.f()}}return i}},{key:"match",value:function(e){var t=Object.create(null);for(var n in e){var r,i=D(n.split(" "));try{for(i.s();!(r=i.n()).done;){var o=r.value;t[o]=e[n]}}catch(e){i.e(e)}finally{i.f()}}return function(e){for(var n=e.prop(nC.group),r=-1;r<(n?n.length:0);r++){var i=t[r<0?e.name:n[r]];if(i)return i}}}}])}();oC.none=new oC("",Object.create(null),0,8);var sC,aC=function(){function e(t){N(this,e),this.types=t;for(var n=0;n<t.length;n++)if(t[n].id!=n)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}return R(e,[{key:"extend",value:function(){for(var t=[],n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];var o,s=D(this.types);try{for(s.s();!(o=s.n()).done;){var a,l=o.value,c=null,u=D(r);try{for(u.s();!(a=u.n()).done;){var h=(0,a.value)(l);if(h){c||(c=Object.assign({},l.props));var f=h[1],d=h[0];d.combine&&d.id in c&&(f=d.combine(c[d.id],f)),c[d.id]=f}}}catch(e){u.e(e)}finally{u.f()}t.push(c?new oC(l.name,c,l.id,l.flags):l)}}catch(e){s.e(e)}finally{s.f()}return new e(t)}}])}(),lC=new WeakMap,cC=new WeakMap;!function(e){e[e.ExcludeBuffers=1]="ExcludeBuffers",e[e.IncludeAnonymous=2]="IncludeAnonymous",e[e.IgnoreMounts=4]="IgnoreMounts",e[e.IgnoreOverlays=8]="IgnoreOverlays",e[e.EnterBracketed=16]="EnterBracketed"}(sC||(sC={}));var uC=function(){function e(t,n,r,i,o){if(N(this,e),this.type=t,this.children=n,this.positions=r,this.length=i,this.props=null,o&&o.length){this.props=Object.create(null);var s,a=D(o);try{for(a.s();!(s=a.n()).done;){var l=q(s.value,2),c=l[0],u=l[1];this.props["number"==typeof c?c:c.id]=u}}catch(e){a.e(e)}finally{a.f()}}}return R(e,[{key:"toString",value:function(){var e=rC.get(this);if(e&&!e.overlay)return e.tree.toString();var t,n="",r=D(this.children);try{for(r.s();!(t=r.n()).done;){var i=t.value.toString();i&&(n&&(n+=","),n+=i)}}catch(e){r.e(e)}finally{r.f()}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(n.length?"("+n+")":""):n}},{key:"cursor",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return new SC(this.topNode,e)}},{key:"cursorAt",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=lC.get(this)||this.topNode,r=new SC(n);return r.moveTo(e,t),lC.set(this,r._tree),r}},{key:"topNode",get:function(){return new gC(this,0,0,null)}},{key:"resolve",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=pC(lC.get(this)||this.topNode,e,t,!1);return lC.set(this,n),n}},{key:"resolveInner",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=pC(cC.get(this)||this.topNode,e,t,!0);return cC.set(this,n),n}},{key:"resolveStack",value:function(e){return function(e,t,n){for(var r=e.resolveInner(t,n),i=null,o=r instanceof gC?r:r.context.parent;o;o=o.parent)if(o.index<0){var s=o.parent;(i||(i=[r])).push(s.resolve(t,n)),o=s}else{var a=rC.get(o.tree);if(a&&a.overlay&&a.overlay[0].from<=t&&a.overlay[a.overlay.length-1].to>=t){var l=new gC(a.tree,a.overlay[0].from+o.from,-1,o);(i||(i=[r])).push(pC(l,t,n,!1))}}return i?kC(i):r}(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:0)}},{key:"iterate",value:function(e){for(var t=e.enter,n=e.leave,r=e.from,i=void 0===r?0:r,o=e.to,s=void 0===o?this.length:o,a=e.mode||0,l=(a&sC.IncludeAnonymous)>0,c=this.cursor(a|sC.IncludeAnonymous);;){var u=!1;if(c.from<=s&&c.to>=i&&(!l&&c.type.isAnonymous||!1!==t(c))){if(c.firstChild())continue;u=!0}for(;u&&n&&(l||!c.type.isAnonymous)&&n(c),!c.nextSibling();){if(!c.parent())return;u=!0}}}},{key:"prop",value:function(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}},{key:"propValues",get:function(){var e=[];if(this.props)for(var t in this.props)e.push([+t,this.props[t]]);return e}},{key:"balance",value:function(){var t=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.children.length<=8?this:OC(oC.none,this.children,this.positions,0,this.children.length,0,this.length,function(n,r,i){return new e(t.type,n,r,i,t.propValues)},n.makeTree||function(t,n,r){return new e(oC.none,t,n,r)})}}],[{key:"build",value:function(e){return EC(e)}}])}();uC.empty=new uC(oC.none,[],[],0);var hC=function(){function e(t,n){N(this,e),this.buffer=t,this.index=n}return R(e,[{key:"id",get:function(){return this.buffer[this.index-4]}},{key:"start",get:function(){return this.buffer[this.index-3]}},{key:"end",get:function(){return this.buffer[this.index-2]}},{key:"size",get:function(){return this.buffer[this.index-1]}},{key:"pos",get:function(){return this.index}},{key:"next",value:function(){this.index-=4}},{key:"fork",value:function(){return new e(this.buffer,this.index)}}])}(),fC=function(){function e(t,n,r){N(this,e),this.buffer=t,this.length=n,this.set=r}return R(e,[{key:"type",get:function(){return oC.none}},{key:"toString",value:function(){for(var e=[],t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}},{key:"childString",value:function(e){var t=this.buffer[e],n=this.buffer[e+3],r=this.set.types[t],i=r.name;if(/\W/.test(i)&&!r.isError&&(i=JSON.stringify(i)),n==(e+=4))return i;for(var o=[];e<n;)o.push(this.childString(e)),e=this.buffer[e+3];return i+"("+o.join(",")+")"}},{key:"findChild",value:function(e,t,n,r,i){for(var o=this.buffer,s=-1,a=e;a!=t&&!(dC(i,r,o[a+1],o[a+2])&&(s=a,n>0));a=o[a+3]);return s}},{key:"slice",value:function(t,n,r){for(var i=this.buffer,o=new Uint16Array(n-t),s=0,a=t,l=0;a<n;){o[l++]=i[a++],o[l++]=i[a++]-r;var c=o[l++]=i[a++]-r;o[l++]=i[a++]-t,s=Math.max(s,c)}return new e(o,s,this.set)}}])}();function dC(e,t,n,r){switch(e){case-2:return n<t;case-1:return r>=t&&n<t;case 0:return n<t&&r>t;case 1:return n<=t&&r>t;case 2:return r>t;case 4:return!0}}function pC(e,t,n,r){for(var i;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to<t);){var o=!r&&e instanceof gC&&e.index<0?null:e.parent;if(!o)return e;e=o}var s=r?0:sC.IgnoreOverlays;if(r)for(var a=e,l=a.parent;l;l=(a=l).parent)a instanceof gC&&a.index<0&&(null===(i=l.enter(t,n,s))||void 0===i?void 0:i.from)!=a.from&&(e=l);for(;;){var c=e.enter(t,n,s);if(!c)return e;e=c}}var mC=function(){return R(function e(){N(this,e)},[{key:"cursor",value:function(){return new SC(this,arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}},{key:"getChild",value:function(e){var t=vC(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,arguments.length>2&&void 0!==arguments[2]?arguments[2]:null);return t.length?t[0]:null}},{key:"getChildren",value:function(e){return vC(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,arguments.length>2&&void 0!==arguments[2]?arguments[2]:null)}},{key:"resolve",value:function(e){return pC(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,!1)}},{key:"resolveInner",value:function(e){return pC(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,!0)}},{key:"matchContext",value:function(e){return yC(this.parent,e)}},{key:"enterUnfinishedNodesBefore",value:function(e){for(var t=this.childBefore(e),n=this;t;){var r=t.lastChild;if(!r||r.to!=t.to)break;r.type.isError&&r.from==r.to?(n=t,t=r.prevSibling):t=r}return n}},{key:"node",get:function(){return this}},{key:"next",get:function(){return this.parent}}])}(),gC=function(){function e(t,n,r,i){var o;return N(this,e),(o=O(this,e))._tree=t,o.from=n,o.index=r,o._parent=i,o}return I(e,mC),R(e,[{key:"type",get:function(){return this._tree.type}},{key:"name",get:function(){return this._tree.type.name}},{key:"to",get:function(){return this.from+this._tree.length}},{key:"nextChild",value:function(t,n,r,i){for(var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,s=this;;){for(var a=s._tree,l=a.children,c=a.positions,u=n>0?l.length:-1;t!=u;t+=n){var h=l[t],f=c[t]+s.from,d=void 0;if(o&sC.EnterBracketed&&h instanceof uC&&(d=rC.get(h))&&!d.overlay&&d.bracketed&&r>=f&&r<=f+h.length||dC(i,r,f,f+h.length))if(h instanceof fC){if(o&sC.ExcludeBuffers)continue;var p=h.findChild(0,h.buffer.length,n,r-f,i);if(p>-1)return new wC(new bC(s,h,t,f),null,p)}else if(o&sC.IncludeAnonymous||!h.type.isAnonymous||CC(h)){var m=void 0;if(!(o&sC.IgnoreMounts)&&(m=rC.get(h))&&!m.overlay)return new e(m.tree,f,t,s);var g=new e(h,f,t,s);return o&sC.IncludeAnonymous||!g.type.isAnonymous?g:g.nextChild(n<0?h.children.length-1:0,n,r,i,o)}}if(o&sC.IncludeAnonymous||!s.type.isAnonymous)return null;if(t=s.index>=0?s.index+n:n<0?-1:s._parent._tree.children.length,!(s=s._parent))return null}}},{key:"firstChild",get:function(){return this.nextChild(0,1,0,4)}},{key:"lastChild",get:function(){return this.nextChild(this._tree.children.length-1,-1,0,4)}},{key:"childAfter",value:function(e){return this.nextChild(0,1,e,2)}},{key:"childBefore",value:function(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}},{key:"prop",value:function(e){return this._tree.prop(e)}},{key:"enter",value:function(t,n){var r,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(!(i&sC.IgnoreOverlays)&&(r=rC.get(this._tree))&&r.overlay){var o,s=t-this.from,a=i&sC.EnterBracketed&&r.bracketed,l=D(r.overlay);try{for(l.s();!(o=l.n()).done;){var c=o.value,u=c.from,h=c.to;if((n>0||a?u<=s:u<s)&&(n<0||a?h>=s:h>s))return new e(r.tree,r.overlay[0].from+this.from,-1,this)}}catch(e){l.e(e)}finally{l.f()}}return this.nextChild(0,1,t,n,i)}},{key:"nextSignificantParent",value:function(){for(var e=this;e.type.isAnonymous&&e._parent;)e=e._parent;return e}},{key:"parent",get:function(){return this._parent?this._parent.nextSignificantParent():null}},{key:"nextSibling",get:function(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}},{key:"prevSibling",get:function(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}},{key:"tree",get:function(){return this._tree}},{key:"toTree",value:function(){return this._tree}},{key:"toString",value:function(){return this._tree.toString()}}])}();function vC(e,t,n,r){var i=e.cursor(),o=[];if(!i.firstChild())return o;if(null!=n)for(var s=!1;!s;)if(s=i.type.is(n),!i.nextSibling())return o;for(;;){if(null!=r&&i.type.is(r))return o;if(i.type.is(t)&&o.push(i.node),!i.nextSibling())return null==r?o:[]}}function yC(e,t){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t.length-1,r=e;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}var bC=R(function e(t,n,r,i){N(this,e),this.parent=t,this.buffer=n,this.index=r,this.start=i}),wC=function(){function e(t,n,r){var i;return N(this,e),(i=O(this,e)).context=t,i._parent=n,i.index=r,i.type=t.buffer.set.types[t.buffer.buffer[r]],i}return I(e,mC),R(e,[{key:"name",get:function(){return this.type.name}},{key:"from",get:function(){return this.context.start+this.context.buffer.buffer[this.index+1]}},{key:"to",get:function(){return this.context.start+this.context.buffer.buffer[this.index+2]}},{key:"child",value:function(t,n,r){var i=this.context.buffer,o=i.findChild(this.index+4,i.buffer[this.index+3],t,n-this.context.start,r);return o<0?null:new e(this.context,this,o)}},{key:"firstChild",get:function(){return this.child(1,0,4)}},{key:"lastChild",get:function(){return this.child(-1,0,4)}},{key:"childAfter",value:function(e){return this.child(1,e,2)}},{key:"childBefore",value:function(e){return this.child(-1,e,-2)}},{key:"prop",value:function(e){return this.type.prop(e)}},{key:"enter",value:function(t,n){if((arguments.length>2&&void 0!==arguments[2]?arguments[2]:0)&sC.ExcludeBuffers)return null;var r=this.context.buffer,i=r.findChild(this.index+4,r.buffer[this.index+3],n>0?1:-1,t-this.context.start,n);return i<0?null:new e(this.context,this,i)}},{key:"parent",get:function(){return this._parent||this.context.parent.nextSignificantParent()}},{key:"externalSibling",value:function(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}},{key:"nextSibling",get:function(){var t=this.context.buffer,n=t.buffer[this.index+3];return n<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new e(this.context,this._parent,n):this.externalSibling(1)}},{key:"prevSibling",get:function(){var t=this.context.buffer,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new e(this.context,this._parent,t.findChild(n,this.index,-1,0,4))}},{key:"tree",get:function(){return null}},{key:"toTree",value:function(){var e=[],t=[],n=this.context.buffer,r=this.index+4,i=n.buffer[this.index+3];if(i>r){var o=n.buffer[this.index+1];e.push(n.slice(r,i,o)),t.push(0)}return new uC(this.type,e,t,this.to-this.from)}},{key:"toString",value:function(){return this.context.buffer.childString(this.index)}}])}();function kC(e){if(!e.length)return null;for(var t=0,n=e[0],r=1;r<e.length;r++){var i=e[r];(i.from>n.from||i.to<n.to)&&(n=i,t=r)}var o=n instanceof gC&&n.index<0?null:n.parent,s=e.slice();return o?s[t]=o:s.splice(t,1),new xC(s,n)}var xC=function(){return R(function e(t,n){N(this,e),this.heads=t,this.node=n},[{key:"next",get:function(){return kC(this.heads)}}])}();var SC=function(){return R(function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(N(this,e),this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=n&~sC.EnterBracketed,t instanceof gC)this.yieldNode(t);else{this._tree=t.context.parent,this.buffer=t.context;for(var r=t._parent;r;r=r._parent)this.stack.unshift(r.index);this.bufferNode=t,this.yieldBuf(t.index)}},[{key:"name",get:function(){return this.type.name}},{key:"yieldNode",value:function(e){return!!e&&(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0)}},{key:"yieldBuf",value:function(e,t){this.index=e;var n=this.buffer,r=n.start,i=n.buffer;return this.type=t||i.set.types[i.buffer[e]],this.from=r+i.buffer[e+1],this.to=r+i.buffer[e+2],!0}},{key:"yield",value:function(e){return!!e&&(e instanceof gC?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)))}},{key:"toString",value:function(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}},{key:"enterChild",value:function(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));var r=this.buffer.buffer,i=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,n);return!(i<0)&&(this.stack.push(this.index),this.yieldBuf(i))}},{key:"firstChild",value:function(){return this.enterChild(1,0,4)}},{key:"lastChild",value:function(){return this.enterChild(-1,0,4)}},{key:"childAfter",value:function(e){return this.enterChild(1,e,2)}},{key:"childBefore",value:function(e){return this.enterChild(-1,e,-2)}},{key:"enter",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.mode;return this.buffer?!(n&sC.ExcludeBuffers)&&this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}},{key:"parent",value:function(){if(!this.buffer)return this.yieldNode(this.mode&sC.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());var e=this.mode&sC.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}},{key:"sibling",value:function(e){if(!this.buffer)return!!this._tree._parent&&this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode));var t=this.buffer.buffer,n=this.stack.length-1;if(e<0){var r=n<0?0:this.stack[n]+4;if(this.index!=r)return this.yieldBuf(t.findChild(r,this.index,-1,0,4))}else{var i=t.buffer[this.index+3];if(i<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(i)}return n<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode))}},{key:"nextSibling",value:function(){return this.sibling(1)}},{key:"prevSibling",value:function(){return this.sibling(-1)}},{key:"atLastNode",value:function(e){var t,n,r=this.buffer;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(var i=0;i<this.index;i++)if(r.buffer.buffer[i+3]<this.index)return!1;t=r.index,n=r.parent}else{var o=this._tree;t=o.index,n=o._parent}for(;n;t=(s=n).index,n=s._parent,s){var s;if(t>-1)for(var a=t+e,l=e<0?-1:n._tree.children.length;a!=l;a+=e){var c=n._tree.children[a];if(this.mode&sC.IncludeAnonymous||c instanceof fC||!c.type.isAnonymous||CC(c))return!1}}return!0}},{key:"move",value:function(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}},{key:"next",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this.move(1,e)}},{key:"prev",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this.move(-1,e)}},{key:"moveTo",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}},{key:"node",get:function(){if(!this.buffer)return this._tree;var e=this.bufferNode,t=null,n=0;if(e&&e.context==this.buffer)e:for(var r=this.index,i=this.stack.length;i>=0;){for(var o=e;o;o=o._parent)if(o.index==r){if(r==this.index)return o;t=o,n=i+1;break e}r=this.stack[--i]}for(var s=n;s<this.stack.length;s++)t=new wC(this.buffer,t,this.stack[s]);return this.bufferNode=new wC(this.buffer,t,this.index)}},{key:"tree",get:function(){return this.buffer?null:this._tree._tree}},{key:"iterate",value:function(e,t){for(var n=0;;){var r=!1;if(this.type.isAnonymous||!1!==e(this)){if(this.firstChild()){n++;continue}this.type.isAnonymous||(r=!0)}for(;;){if(r&&t&&t(this),r=this.type.isAnonymous,!n)return;if(this.nextSibling())break;this.parent(),n--,r=!0}}}},{key:"matchContext",value:function(e){if(!this.buffer)return yC(this.node.parent,e);for(var t=this.buffer.buffer,n=t.set.types,r=e.length-1,i=this.stack.length-1;r>=0;i--){if(i<0)return yC(this._tree,e,r);var o=n[t.buffer[this.stack[i]]];if(!o.isAnonymous){if(e[r]&&e[r]!=o.name)return!1;r--}}return!0}}])}();function CC(e){return e.children.some(function(e){return e instanceof fC||!e.type.isAnonymous||CC(e)})}function EC(e){var t,n=e.buffer,r=e.nodeSet,i=e.maxBufferLength,o=void 0===i?1024:i,s=e.reused,a=void 0===s?[]:s,l=e.minRepeatType,c=void 0===l?r.types.length:l,u=Array.isArray(n)?new hC(n,n.length):n,h=r.types,f=0,d=0;function p(e,t,n,i,s,l){var b=u.id,w=u.start,k=u.end,x=u.size,S=d,C=f;if(x<0){if(u.next(),-1==x){var E=a[b];return n.push(E),void i.push(w-e)}if(-3==x)return void(f=b);if(-4==x)return void(d=b);throw new RangeError("Unrecognized record size: ".concat(x))}var A,M,O=h[b],N=w-e;if(k-w<=o&&(M=function(e,t){var n=u.fork(),r=0,i=0,s=0,a=n.end-o,l={size:0,start:0,skip:0};e:for(var h=n.pos-e;n.pos>h;){var f=n.size;if(n.id==t&&f>=0)l.size=r,l.start=i,l.skip=s,s+=4,r+=4,n.next();else{var d=n.pos-f;if(f<0||d<h||n.start<a)break;var p=n.id>=c?4:0,m=n.start;for(n.next();n.pos>d;){if(n.size<0){if(-3!=n.size&&-4!=n.size)break e;p+=4}else n.id>=c&&(p+=4);n.next()}i=m,r+=f,s+=p}}(t<0||r==e)&&(l.size=r,l.start=i,l.skip=s);return l.size>4?l:void 0}(u.pos-t,s))){for(var T=new Uint16Array(M.size-M.skip),R=u.pos-M.size,D=T.length;u.pos>R;)D=y(M.start,T,D);A=new fC(T,k-M.start,r),N=M.start-e}else{var P=u.pos-x;u.next();for(var L=[],B=[],I=b>=c?b:-1,_=0,F=k;u.pos>P;)I>=0&&u.id==I&&u.size>=0?(u.end<=F-o&&(g(L,B,w,_,u.end,F,I,S,C),_=L.length,F=u.end),u.next()):l>2500?m(w,P,L,B):p(w,P,L,B,I,l+1);if(I>=0&&_>0&&_<L.length&&g(L,B,w,_,w,F,I,S,C),L.reverse(),B.reverse(),I>-1&&_>0){var W=function(e,t){return function(n,r,i){var o,s,a=0,l=n.length-1;if(l>=0&&(o=n[l])instanceof uC){if(!l&&o.type==e&&o.length==i)return o;(s=o.prop(nC.lookAhead))&&(a=r[l]+o.length+s)}return v(e,n,r,i,a,t)}}(O,C);A=OC(O,L,B,0,L.length,0,k-w,W,W)}else A=v(O,L,B,k-w,S-k,C)}n.push(A),i.push(N)}function m(e,t,n,i){for(var s=[],a=0,l=-1;u.pos>t;){var c=u.id,h=u.start,f=u.end;if(u.size>4)u.next();else{if(l>-1&&h<l)break;l<0&&(l=f-o),s.push(c,h,f),a++,u.next()}}if(a){for(var d=new Uint16Array(4*a),p=s[s.length-2],m=s.length-3,g=0;m>=0;m-=3)d[g++]=s[m],d[g++]=s[m+1]-p,d[g++]=s[m+2]-p,d[g++]=g;n.push(new fC(d,s[2]-p,r)),i.push(p-e)}}function g(e,t,n,i,o,s,a,l,c){for(var u=[],h=[];e.length>i;)u.push(e.pop()),h.push(t.pop()+n-o);e.push(v(r.types[a],u,h,s-o,l-s,c)),t.push(o-n)}function v(e,t,n,r,i,o,s){if(o){var a=[nC.contextHash,o];s=s?[a].concat(s):[a]}if(i>25){var l=[nC.lookAhead,i];s=s?[l].concat(s):[l]}return new uC(e,t,n,r,s)}function y(e,t,n){var r=u.id,i=u.start,o=u.end,s=u.size;if(u.next(),s>=0&&r<c){var a=n;if(s>4)for(var l=u.pos-(s-4);u.pos>l;)n=y(e,t,n);t[--n]=a,t[--n]=o-e,t[--n]=i-e,t[--n]=r}else-3==s?f=r:-4==s&&(d=r);return n}for(var b=[],w=[];u.pos>0;)p(e.start||0,e.bufferStart||0,b,w,-1,0);var k=null!==(t=e.length)&&void 0!==t?t:b.length?w[0]+b[0].length:0;return new uC(h[e.topID],b.reverse(),w.reverse(),k)}var AC=new WeakMap;function MC(e,t){if(!e.isAnonymous||t instanceof fC||t.type!=e)return 1;var n=AC.get(t);if(null==n){n=1;var r,i=D(t.children);try{for(i.s();!(r=i.n()).done;){var o=r.value;if(o.type!=e||!(o instanceof uC)){n=1;break}n+=MC(e,o)}}catch(e){i.e(e)}finally{i.f()}AC.set(t,n)}return n}function OC(e,t,n,r,i,o,s,a,l){for(var c=0,u=r;u<i;u++)c+=MC(e,t[u]);var h=Math.ceil(1.5*c/8),f=[],d=[];return function t(n,r,i,s,a){for(var c=i;c<s;){var u=c,p=r[c],m=MC(e,n[c]);for(c++;c<s;c++){var g=MC(e,n[c]);if(m+g>=h)break;m+=g}if(c==u+1){if(m>h){var v=n[u];t(v.children,v.positions,0,v.children.length,r[u]+a);continue}f.push(n[u])}else{var y=r[c-1]+n[c-1].length-p;f.push(OC(e,n,r,u,c,p,y,null,l))}d.push(p+a-o)}}(t,n,r,i,0),(a||l)(f,d,s)}var NC=function(){function e(t,n,r,i){var o=arguments.length>4&&void 0!==arguments[4]&&arguments[4],s=arguments.length>5&&void 0!==arguments[5]&&arguments[5];N(this,e),this.from=t,this.to=n,this.tree=r,this.offset=i,this.open=(o?1:0)|(s?2:0)}return R(e,[{key:"openStart",get:function(){return(1&this.open)>0}},{key:"openEnd",get:function(){return(2&this.open)>0}}],[{key:"addTree",value:function(t){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=[new e(0,t.length,t,0,!1,i)],s=D(r);try{for(s.s();!(n=s.n()).done;){var a=n.value;a.to>t.length&&o.push(a)}}catch(e){s.e(e)}finally{s.f()}return o}},{key:"applyChanges",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:128;if(!n.length)return t;for(var i=[],o=1,s=t.length?t[0]:null,a=0,l=0,c=0;;a++){var u=a<n.length?n[a]:null,h=u?u.fromA:1e9;if(h-l>=r)for(;s&&s.from<h;){var f=s;if(l>=f.from||h<=f.to||c){var d=Math.max(f.from,l)-c,p=Math.min(f.to,h)-c;f=d>=p?null:new e(d,p,f.tree,f.offset+c,a>0,!!u)}if(f&&i.push(f),s.to>h)break;s=o<t.length?t[o++]:null}if(!u)break;l=u.toA,c=u.toA-u.toB}return i}}])}(),TC=function(){return R(function e(){N(this,e)},[{key:"startParse",value:function(e,t,n){return"string"==typeof e&&(e=new RC(e)),n=n?n.length?n.map(function(e){return new tC(e.from,e.to)}):[new tC(0,0)]:[new tC(0,e.length)],this.createParse(e,t||[],n)}},{key:"parse",value:function(e,t,n){for(var r=this.startParse(e,t,n);;){var i=r.advance();if(i)return i}}}])}(),RC=function(){return R(function e(t){N(this,e),this.string=t},[{key:"length",get:function(){return this.string.length}},{key:"chunk",value:function(e){return this.string.slice(e)}},{key:"lineChunks",get:function(){return!1}},{key:"read",value:function(e,t){return this.string.slice(e,t)}}])}();new nC({perNode:!0});var DC=0,PC=function(){function e(t,n,r,i){N(this,e),this.name=t,this.set=n,this.base=r,this.modified=i,this.id=DC++}return R(e,[{key:"toString",value:function(){var e,t=this.name,n=D(this.modified);try{for(n.s();!(e=n.n()).done;){var r=e.value;r.name&&(t="".concat(r.name,"(").concat(t,")"))}}catch(e){n.e(e)}finally{n.f()}return t}}],[{key:"define",value:function(t,n){var r="string"==typeof t?t:"?";if(t instanceof e&&(n=t),null==n?void 0:n.base)throw new Error("Can not derive from a modified tag");var i=new e(r,[],null,[]);if(i.set.push(i),n){var o,s=D(n.set);try{for(s.s();!(o=s.n()).done;){var a=o.value;i.set.push(a)}}catch(e){s.e(e)}finally{s.f()}}return i}},{key:"defineModifier",value:function(e){var t=new BC(e);return function(e){return e.modified.indexOf(t)>-1?e:BC.get(e.base||e,e.modified.concat(t).sort(function(e,t){return e.id-t.id}))}}}])}(),LC=0,BC=function(){function e(t){N(this,e),this.name=t,this.instances=[],this.id=LC++}return R(e,null,[{key:"get",value:function(t,n){if(!n.length)return t;var r=n[0].instances.find(function(e){return e.base==t&&(r=n,i=e.modified,r.length==i.length&&r.every(function(e,t){return e==i[t]}));var r,i});if(r)return r;var i,o=[],s=new PC(t.name,o,t,n),a=D(n);try{for(a.s();!(i=a.n()).done;){i.value.instances.push(s)}}catch(e){a.e(e)}finally{a.f()}var l,c=function(e){for(var t=[[]],n=0;n<e.length;n++)for(var r=0,i=t.length;r<i;r++)t.push(t[r].concat(e[n]));return t.sort(function(e,t){return t.length-e.length})}(n),u=D(t.set);try{for(u.s();!(l=u.n()).done;){var h=l.value;if(!h.modified.length){var f,d=D(c);try{for(d.s();!(f=d.n()).done;){var p=f.value;o.push(e.get(h,p))}}catch(e){d.e(e)}finally{d.f()}}}}catch(e){u.e(e)}finally{u.f()}return s}}])}();function IC(e){var t=Object.create(null);for(var n in e){var r=e[n];Array.isArray(r)||(r=[r]);var i,o=D(n.split(" "));try{for(o.s();!(i=o.n()).done;){var s=i.value;if(s){for(var a=[],l=2,c=s,u=0;;){if("..."==c&&u>0&&u+3==s.length){l=1;break}var h=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(c);if(!h)throw new RangeError("Invalid path: "+s);if(a.push("*"==h[0]?"":'"'==h[0][0]?JSON.parse(h[0]):h[0]),(u+=h[0].length)==s.length)break;var f=s[u++];if(u==s.length&&"!"==f){l=0;break}if("/"!=f)throw new RangeError("Invalid path: "+s);c=s.slice(u)}var d=a.length-1,p=a[d];if(!p)throw new RangeError("Invalid path: "+s);var m=new FC(r,l,d>0?a.slice(0,d):null);t[p]=m.sort(t[p])}}}catch(e){o.e(e)}finally{o.f()}}return _C.add(t)}var _C=new nC({combine:function(e,t){for(var n,r,i;e||t;)if(!e||t&&e.depth>=t.depth?(i=t,t=t.next):(i=e,e=e.next),!n||n.mode!=i.mode||i.context||n.context){var o=new FC(i.tags,i.mode,i.context);n?n.next=o:r=o,n=o}return r}}),FC=function(){return R(function e(t,n,r,i){N(this,e),this.tags=t,this.mode=n,this.context=r,this.next=i},[{key:"opaque",get:function(){return 0==this.mode}},{key:"inherit",get:function(){return 1==this.mode}},{key:"sort",value:function(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}},{key:"depth",get:function(){return this.context?this.context.length:0}}])}();function WC(e,t){var n,r=Object.create(null),i=D(e);try{for(i.s();!(n=i.n()).done;){var o=n.value;if(Array.isArray(o.tag)){var s,a=D(o.tag);try{for(a.s();!(s=a.n()).done;){var l=s.value;r[l.id]=o.class}}catch(e){a.e(e)}finally{a.f()}}else r[o.tag.id]=o.class}}catch(e){i.e(e)}finally{i.f()}var c=t||{},u=c.scope,h=c.all,f=void 0===h?null:h;return{style:function(e){var t,n=f,i=D(e);try{for(i.s();!(t=i.n()).done;){var o,s=D(t.value.set);try{for(s.s();!(o=s.n()).done;){var a=o.value,l=r[a.id];if(l){n=n?n+" "+l:l;break}}}catch(e){s.e(e)}finally{s.f()}}}catch(e){i.e(e)}finally{i.f()}return n},scope:u}}function jC(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.length,o=new HC(r,Array.isArray(t)?t:[t],n);o.highlightRange(e.cursor(),r,i,"",o.highlighters),o.flush(i)}FC.empty=new FC([],2,null);var HC=function(){return R(function e(t,n,r){N(this,e),this.at=t,this.highlighters=n,this.span=r,this.class=""},[{key:"startSpan",value:function(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}},{key:"flush",value:function(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}},{key:"highlightRange",value:function(e,t,n,r,i){var o=e.type,s=e.from,a=e.to;if(!(s>=n||a<=t)){o.isTop&&(i=this.highlighters.filter(function(e){return!e.scope||e.scope(o)}));var l=r,c=function(e){var t=e.type.prop(_C);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}(e)||FC.empty,u=function(e,t){var n,r=null,i=D(e);try{for(i.s();!(n=i.n()).done;){var o=n.value.style(t);o&&(r=r?r+" "+o:o)}}catch(e){i.e(e)}finally{i.f()}return r}(i,c.tags);if(u&&(l&&(l+=" "),l+=u,1==c.mode&&(r+=(r?" ":"")+u)),this.startSpan(Math.max(t,s),l),!c.opaque){var h=e.tree&&e.tree.prop(nC.mounted);if(h&&h.overlay){for(var f=e.node.enter(h.overlay[0].from+s,1),d=this.highlighters.filter(function(e){return!e.scope||e.scope(h.tree.type)}),p=e.firstChild(),m=0,g=s;;m++){var v=m<h.overlay.length?h.overlay[m]:null,y=v?v.from+s:a,b=Math.max(t,g),w=Math.min(n,y);if(b<w&&p)for(;e.from<w&&(this.highlightRange(e,b,w,r,i),this.startSpan(Math.min(w,e.to),l),!(e.to>=y)&&e.nextSibling()););if(!v||y>n)break;(g=v.to+s)>t&&(this.highlightRange(f.cursor(),Math.max(t,v.from+s),Math.min(n,g),"",d),this.startSpan(Math.min(n,g),l))}p&&e.parent()}else if(e.firstChild()){h&&(r="");do{if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,r,i),this.startSpan(Math.min(n,e.to),l)}}while(e.nextSibling());e.parent()}}}}}])}();var zC,VC=PC.define,qC=VC(),UC=VC(),KC=VC(UC),GC=VC(UC),YC=VC(),$C=VC(YC),XC=VC(YC),JC=VC(),QC=VC(JC),ZC=VC(),eE=VC(),tE=VC(),nE=VC(tE),rE=VC(),iE={comment:qC,lineComment:VC(qC),blockComment:VC(qC),docComment:VC(qC),name:UC,variableName:VC(UC),typeName:KC,tagName:VC(KC),propertyName:GC,attributeName:VC(GC),className:VC(UC),labelName:VC(UC),namespace:VC(UC),macroName:VC(UC),literal:YC,string:$C,docString:VC($C),character:VC($C),attributeValue:VC($C),number:XC,integer:VC(XC),float:VC(XC),bool:VC(YC),regexp:VC(YC),escape:VC(YC),color:VC(YC),url:VC(YC),keyword:ZC,self:VC(ZC),null:VC(ZC),atom:VC(ZC),unit:VC(ZC),modifier:VC(ZC),operatorKeyword:VC(ZC),controlKeyword:VC(ZC),definitionKeyword:VC(ZC),moduleKeyword:VC(ZC),operator:eE,derefOperator:VC(eE),arithmeticOperator:VC(eE),logicOperator:VC(eE),bitwiseOperator:VC(eE),compareOperator:VC(eE),updateOperator:VC(eE),definitionOperator:VC(eE),typeOperator:VC(eE),controlOperator:VC(eE),punctuation:tE,separator:VC(tE),bracket:nE,angleBracket:VC(nE),squareBracket:VC(nE),paren:VC(nE),brace:VC(nE),content:JC,heading:QC,heading1:VC(QC),heading2:VC(QC),heading3:VC(QC),heading4:VC(QC),heading5:VC(QC),heading6:VC(QC),contentSeparator:VC(JC),list:VC(JC),quote:VC(JC),emphasis:VC(JC),strong:VC(JC),link:VC(JC),monospace:VC(JC),strikethrough:VC(JC),inserted:VC(),deleted:VC(),changed:VC(),invalid:VC(),meta:rE,documentMeta:VC(rE),annotation:VC(rE),processingInstruction:VC(rE),definition:PC.defineModifier("definition"),constant:PC.defineModifier("constant"),function:PC.defineModifier("function"),standard:PC.defineModifier("standard"),local:PC.defineModifier("local"),special:PC.defineModifier("special")};for(var oE in iE){var sE=iE[oE];sE instanceof PC&&(sE.name=oE)}WC([{tag:iE.link,class:"tok-link"},{tag:iE.heading,class:"tok-heading"},{tag:iE.emphasis,class:"tok-emphasis"},{tag:iE.strong,class:"tok-strong"},{tag:iE.keyword,class:"tok-keyword"},{tag:iE.atom,class:"tok-atom"},{tag:iE.bool,class:"tok-bool"},{tag:iE.url,class:"tok-url"},{tag:iE.labelName,class:"tok-labelName"},{tag:iE.inserted,class:"tok-inserted"},{tag:iE.deleted,class:"tok-deleted"},{tag:iE.literal,class:"tok-literal"},{tag:iE.string,class:"tok-string"},{tag:iE.number,class:"tok-number"},{tag:[iE.regexp,iE.escape,iE.special(iE.string)],class:"tok-string2"},{tag:iE.variableName,class:"tok-variableName"},{tag:iE.local(iE.variableName),class:"tok-variableName tok-local"},{tag:iE.definition(iE.variableName),class:"tok-variableName tok-definition"},{tag:iE.special(iE.variableName),class:"tok-variableName2"},{tag:iE.definition(iE.propertyName),class:"tok-propertyName tok-definition"},{tag:iE.typeName,class:"tok-typeName"},{tag:iE.namespace,class:"tok-namespace"},{tag:iE.className,class:"tok-className"},{tag:iE.macroName,class:"tok-macroName"},{tag:iE.propertyName,class:"tok-propertyName"},{tag:iE.operator,class:"tok-operator"},{tag:iE.comment,class:"tok-comment"},{tag:iE.meta,class:"tok-meta"},{tag:iE.invalid,class:"tok-invalid"},{tag:iE.punctuation,class:"tok-punctuation"}]);var aE=new nC;var lE=new nC,cE=function(){return R(function e(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";N(this,e),this.data=t,this.name=i,bv.prototype.hasOwnProperty("tree")||Object.defineProperty(bv.prototype,"tree",{get:function(){return fE(this)}}),this.parser=n,this.extension=[kE.of(this),bv.languageData.of(function(e,t,n){var r=uE(e,t,n),i=r.type.prop(aE);if(!i)return[];var o=e.facet(i),s=r.type.prop(lE);if(s){var a,l=r.resolve(t-r.from,n),c=D(s);try{for(c.s();!(a=c.n()).done;){var u=a.value;if(u.test(l,e)){var h=e.facet(u.facet);return"replace"==u.type?h:h.concat(o)}}}catch(e){c.e(e)}finally{c.f()}}return o})].concat(r)},[{key:"isActiveAt",value:function(e,t){return uE(e,t,arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1).type.prop(aE)==this.data}},{key:"findRegions",value:function(e){var t=this,n=e.facet(kE);if((null==n?void 0:n.data)==this.data)return[{from:0,to:e.doc.length}];if(!n||!n.allowsNesting)return[];var r=[],i=function(e,n){if(e.prop(aE)!=t.data){var o=e.prop(nC.mounted);if(o){if(o.tree.prop(aE)==t.data){if(o.overlay){var s,a=D(o.overlay);try{for(a.s();!(s=a.n()).done;){var l=s.value;r.push({from:l.from+n,to:l.to+n})}}catch(e){a.e(e)}finally{a.f()}}else r.push({from:n,to:n+e.length});return}if(o.overlay){var c=r.length;if(i(o.tree,o.overlay[0].from+n),r.length>c)return}}for(var u=0;u<e.children.length;u++){var h=e.children[u];h instanceof uC&&i(h,e.positions[u]+n)}}else r.push({from:n,to:n+e.length})};return i(fE(e),0),r}},{key:"allowsNesting",get:function(){return!0}}])}();function uE(e,t,n){var r=e.facet(kE),i=fE(e).topNode;if(!r||r.allowsNesting)for(var o=i;o;o=o.enter(t,n,sC.ExcludeBuffers|sC.EnterBracketed))o.type.isTop&&(i=o);return i}cE.setState=av.define();var hE=function(){function e(t,n,r){var i;return N(this,e),(i=O(this,e,[t,n,[],r])).parser=n,i}return I(e,cE),R(e,[{key:"configure",value:function(t,n){return new e(this.data,this.parser.configure(t),n||this.name)}},{key:"allowsNesting",get:function(){return this.parser.hasWrappers()}}],[{key:"define",value:function(t){var n,r=(n=t.languageData,Dg.define({combine:n?function(e){return e.concat(n)}:void 0}));return new e(r,t.parser.configure({props:[aE.add(function(e){return e.isTop?r:void 0})]}),t.name)}}])}();function fE(e){var t=e.field(cE.state,!1);return t?t.tree:uC.empty}var dE=function(){return R(function e(t){N(this,e),this.doc=t,this.cursorPos=0,this.string="",this.cursor=t.iter()},[{key:"length",get:function(){return this.doc.length}},{key:"syncTo",value:function(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}},{key:"chunk",value:function(e){return this.syncTo(e),this.string}},{key:"lineChunks",get:function(){return!0}},{key:"read",value:function(e,t){var n=this.cursorPos-this.string.length;return e<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}}])}(),pE=null,mE=function(){function e(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],i=arguments.length>3?arguments[3]:void 0,o=arguments.length>4?arguments[4]:void 0,s=arguments.length>5?arguments[5]:void 0,a=arguments.length>6?arguments[6]:void 0,l=arguments.length>7?arguments[7]:void 0;N(this,e),this.parser=t,this.state=n,this.fragments=r,this.tree=i,this.treeLen=o,this.viewport=s,this.skipped=a,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}return R(e,[{key:"startParse",value:function(){return this.parser.startParse(new dE(this.state.doc),this.fragments)}},{key:"work",value:function(e,t){var n=this;return null!=t&&t>=this.state.doc.length&&(t=void 0),this.tree!=uC.empty&&this.isDone(null!=t?t:this.state.doc.length)?(this.takeTree(),!0):this.withContext(function(){var r;if("number"==typeof e){var i=Date.now()+e;e=function(){return Date.now()>i}}for(n.parse||(n.parse=n.startParse()),null!=t&&(null==n.parse.stoppedAt||n.parse.stoppedAt>t)&&t<n.state.doc.length&&n.parse.stopAt(t);;){var o=n.parse.advance();if(o){if(n.fragments=n.withoutTempSkipped(NC.addTree(o,n.fragments,null!=n.parse.stoppedAt)),n.treeLen=null!==(r=n.parse.stoppedAt)&&void 0!==r?r:n.state.doc.length,n.tree=o,n.parse=null,!(n.treeLen<(null!=t?t:n.state.doc.length)))return!0;n.parse=n.startParse()}if(e())return!1}})}},{key:"takeTree",value:function(){var e,t,n=this;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((null==this.parse.stoppedAt||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(function(){for(;!(t=n.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(NC.addTree(this.tree,this.fragments,!0)),this.parse=null)}},{key:"withContext",value:function(e){var t=pE;pE=this;try{return e()}finally{pE=t}}},{key:"withoutTempSkipped",value:function(e){for(var t;t=this.tempSkipped.pop();)e=gE(e,t.from,t.to);return e}},{key:"changes",value:function(t,n){var r=this.fragments,i=this.tree,o=this.treeLen,s=this.viewport,a=this.skipped;if(this.takeTree(),!t.empty){var l=[];if(t.iterChangedRanges(function(e,t,n,r){return l.push({fromA:e,toA:t,fromB:n,toB:r})}),r=NC.applyChanges(r,l),i=uC.empty,o=0,s={from:t.mapPos(s.from,-1),to:t.mapPos(s.to,1)},this.skipped.length){a=[];var c,u=D(this.skipped);try{for(u.s();!(c=u.n()).done;){var h=c.value,f=t.mapPos(h.from,1),d=t.mapPos(h.to,-1);f<d&&a.push({from:f,to:d})}}catch(e){u.e(e)}finally{u.f()}}}return new e(this.parser,n,r,i,o,s,a,this.scheduleOn)}},{key:"updateViewport",value:function(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;for(var t=this.skipped.length,n=0;n<this.skipped.length;n++){var r=this.skipped[n],i=r.from,o=r.to;i<e.to&&o>e.from&&(this.fragments=gE(this.fragments,i,o),this.skipped.splice(n--,1))}return!(this.skipped.length>=t)&&(this.reset(),!0)}},{key:"reset",value:function(){this.parse&&(this.takeTree(),this.parse=null)}},{key:"skipUntilInView",value:function(e,t){this.skipped.push({from:e,to:t})}},{key:"isDone",value:function(e){e=Math.min(e,this.state.doc.length);var t=this.fragments;return this.treeLen>=e&&t.length&&0==t[0].from&&t[0].to>=e}}],[{key:"create",value:function(t,n,r){return new e(t,n,[],uC.empty,0,r,[],null)}},{key:"getSkippingParser",value:function(e){return new(function(){function t(){return N(this,t),O(this,t,arguments)}return I(t,TC),R(t,[{key:"createParse",value:function(t,n,r){var i=r[0].from,o=r[r.length-1].to,s={parsedPos:i,advance:function(){var t=pE;if(t){var n,s=D(r);try{for(s.s();!(n=s.n()).done;){var a=n.value;t.tempSkipped.push(a)}}catch(e){s.e(e)}finally{s.f()}e&&(t.scheduleOn=t.scheduleOn?Promise.all([t.scheduleOn,e]):e)}return this.parsedPos=o,new uC(oC.none,[],[],o-i)},stoppedAt:null,stopAt:function(){}};return s}}])}())}},{key:"get",value:function(){return pE}}])}();function gE(e,t,n){return NC.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}var vE=function(){function e(t){N(this,e),this.context=t,this.tree=t.tree}return R(e,[{key:"apply",value:function(t){if(!t.docChanged&&this.tree==this.context.tree)return this;var n=this.context.changes(t.changes,t.state),r=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new e(n)}}],[{key:"init",value:function(t){var n=Math.min(3e3,t.doc.length),r=mE.create(t.facet(kE).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new e(r)}}])}();cE.state=Fg.define({create:vE.init,update:function(e,t){var n,r=D(t.effects);try{for(r.s();!(n=r.n()).done;){var i=n.value;if(i.is(cE.setState))return i.value}}catch(e){r.e(e)}finally{r.f()}return t.startState.facet(kE)!=t.state.facet(kE)?vE.init(t.state):e.apply(t)}});var yE=function(e){var t=setTimeout(function(){return e()},500);return function(){return clearTimeout(t)}};"undefined"!=typeof requestIdleCallback&&(yE=function(e){var t=-1,n=setTimeout(function(){t=requestIdleCallback(e,{timeout:400})},100);return function(){return t<0?clearTimeout(n):cancelIdleCallback(t)}});var bE="undefined"!=typeof navigator&&(null===(zC=navigator.scheduling)||void 0===zC?void 0:zC.isInputPending)?function(){return navigator.scheduling.isInputPending()}:null,wE=_b.fromClass(function(){return R(function e(t){N(this,e),this.view=t,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()},[{key:"update",value:function(e){var t=this.view.state.field(cE.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}},{key:"scheduleWork",value:function(){if(!this.working){var e=this.view.state,t=e.field(cE.state);t.tree==t.context.tree&&t.context.isDone(e.doc.length)||(this.working=yE(this.work))}}},{key:"work",value:function(e){this.working=null;var t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),!(this.chunkBudget<=0)){var n=this.view,r=n.state,i=n.viewport.to,o=r.field(cE.state);if(o.tree!=o.context.tree||!o.context.isDone(i+1e5)){var s=Date.now()+Math.min(this.chunkBudget,100,e&&!bE?Math.max(25,e.timeRemaining()-5):1e9),a=o.context.treeLen<i&&r.doc.length>i+1e3,l=o.context.work(function(){return bE&&bE()||Date.now()>s},i+(a?0:1e5));this.chunkBudget-=Date.now()-t,(l||this.chunkBudget<=0)&&(o.context.takeTree(),this.view.dispatch({effects:cE.setState.of(new vE(o.context))})),this.chunkBudget>0&&(!l||a)&&this.scheduleWork(),this.checkAsyncSchedule(o.context)}}}},{key:"checkAsyncSchedule",value:function(e){var t=this;e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(function(){return t.scheduleWork()}).catch(function(e){return Pb(t.view.state,e)}).then(function(){return t.workScheduled--}),e.scheduleOn=null)}},{key:"destroy",value:function(){this.working&&this.working()}},{key:"isWorking",value:function(){return!!(this.working||this.workScheduled>0)}}])}(),{eventHandlers:{focus:function(){this.scheduleWork()}}}),kE=Dg.define({combine:function(e){return e.length?e[0]:null},enables:function(e){return[cE.state,wE,lx.contentAttributes.compute([e],function(t){var n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]}}),xE=R(function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];N(this,e),this.language=t,this.support=n,this.extension=[t,n]}),SE=Dg.define(),CE=Dg.define({combine:function(e){if(!e.length)return" ";var t=e[0];if(!t||/\S/.test(t)||Array.from(t).some(function(e){return e!=t[0]}))throw new Error("Invalid indent unit: "+JSON.stringify(e[0]));return t}});function EE(e){var t=e.facet(CE);return 9==t.charCodeAt(0)?e.tabSize*t.length:t.length}function AE(e,t){var n="",r=e.tabSize,i=e.facet(CE)[0];if("\t"==i){for(;t>=r;)n+="\t",t-=r;i=" "}for(var o=0;o<t;o++)n+=i;return n}function ME(e,t){e instanceof bv&&(e=new OE(e));var n,r=D(e.state.facet(SE));try{for(r.s();!(n=r.n()).done;){var i=(0,n.value)(e,t);if(void 0!==i)return i}}catch(e){r.e(e)}finally{r.f()}var o=fE(e.state);return o.length>=t?function(e,t,n){var r=t.resolveStack(n),i=t.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(i!=r.node){for(var o=[],s=i;s&&!(s.from<r.node.from||s.to>r.node.to||s.from==r.node.from&&s.type==r.node.type);s=s.parent)o.push(s);for(var a=o.length-1;a>=0;a--)r={node:o[a],next:r}}return TE(r,e,n)}(e,o,t):null}var OE=function(){return R(function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};N(this,e),this.state=t,this.options=n,this.unit=EE(t)},[{key:"lineAt",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=this.state.doc.lineAt(e),r=this.options,i=r.simulateBreak,o=r.simulateDoubleBreak;return null!=i&&i>=n.from&&i<=n.to?o&&i==e?{text:"",from:e}:(t<0?i<e:i<=e)?{text:n.text.slice(i-n.from),from:i}:{text:n.text.slice(0,i-n.from),from:n.from}:n}},{key:"textAfterPos",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";var n=this.lineAt(e,t),r=n.text,i=n.from;return r.slice(e-i,Math.min(r.length,e+100-i))}},{key:"column",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=this.lineAt(e,t),r=n.text,i=n.from,o=this.countColumn(r,e-i),s=this.options.overrideIndentation?this.options.overrideIndentation(i):-1;return s>-1&&(o+=s-this.countColumn(r,r.search(/\S|$/))),o}},{key:"countColumn",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.length;return Fv(e,this.state.tabSize,t)}},{key:"lineIndent",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=this.lineAt(e,t),r=n.text,i=n.from,o=this.options.overrideIndentation;if(o){var s=o(i);if(s>-1)return s}return this.countColumn(r,r.search(/\S|$/))}},{key:"simulatedBreak",get:function(){return this.options.simulateBreak||null}}])}(),NE=new nC;function TE(e,t,n){for(var r=e;r;r=r.next){var i=RE(r.node);if(i)return i(PE.create(t,n,r))}return 0}function RE(e){var t=e.type.prop(NE);if(t)return t;var n,r=e.firstChild;if(r&&(n=r.type.prop(nC.closedBy))){var i=e.lastChild,o=i&&n.indexOf(i.name)>-1;return function(e){return function(e,t,n,r,i){var o=e.textAfter,s=o.match(/^\s*/)[0].length,a=r&&o.slice(s,s+r.length)==r||i==e.pos+s,l=t?function(e){var t=e.node,n=t.childAfter(t.from),r=t.lastChild;if(!n)return null;for(var i=e.options.simulateBreak,o=e.state.doc.lineAt(n.from),s=null==i||i<=o.from?o.to:Math.min(o.to,i),a=n.to;;){var l=t.childAfter(a);if(!l||l==r)return null;if(!l.type.isSkipped){if(l.from>=s)return null;var c=/^ */.exec(o.text.slice(n.to-o.from))[0].length;return{from:n.from,to:n.to+c}}a=l.to}}(e):null;return l?a?e.column(l.from):e.column(l.to):e.baseIndent+(a?0:e.unit*n)}(e,!0,1,void 0,o&&!function(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}(e)?i.from:void 0)}}return null==e.parent?DE:null}function DE(){return 0}var PE=function(){function e(t,n,r){var i;return N(this,e),(i=O(this,e,[t.state,t.options])).base=t,i.pos=n,i.context=r,i}return I(e,OE),R(e,[{key:"node",get:function(){return this.context.node}},{key:"textAfter",get:function(){return this.textAfterPos(this.pos)}},{key:"baseIndent",get:function(){return this.baseIndentFor(this.node)}},{key:"baseIndentFor",value:function(e){for(var t=this.state.doc.lineAt(e.from);;){for(var n=e.resolve(t.from);n.parent&&n.parent.from==n.from;)n=n.parent;if(LE(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}},{key:"continue",value:function(){return TE(this.context.next,this.base,this.pos)}}],[{key:"create",value:function(t,n,r){return new e(t,n,r)}}])}();function LE(e,t){for(var n=t;n;n=n.parent)if(e==n)return!0;return!1}function BE(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.except,n=e.units,r=void 0===n?1:n;return function(e){var n=t&&t.test(e.textAfter);return e.baseIndent+(n?0:r*e.unit)}}var IE=Dg.define(),_E=new nC;function FE(e){var t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function WE(e,t,n){var r,i=D(e.facet(IE));try{for(i.s();!(r=i.n()).done;){var o=(0,r.value)(e,t,n);if(o)return o}}catch(e){i.e(e)}finally{i.f()}return function(e,t,n){var r=fE(e);if(r.length<n)return null;for(var i=null,o=r.resolveStack(n,1);o;o=o.next){var s=o.node;if(!(s.to<=n||s.from>n)){if(i&&s.from<t)break;var a=s.type.prop(_E);if(a&&(s.to<r.length-50||r.length==e.doc.length||!FE(s))){var l=a(s,e);l&&l.from<=n&&l.from>=t&&l.to>n&&(i=l)}}}return i}(e,t,n)}function jE(e,t){var n=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);return n>=r?void 0:{from:n,to:r}}var HE=av.define({map:jE}),zE=av.define({map:jE});function VE(e){var t,n=[],r=D(e.state.selection.ranges);try{var i=function(){var r=t.value.head;if(n.some(function(e){return e.from<=r&&e.to>=r}))return 1;n.push(e.lineBlockAt(r))};for(r.s();!(t=r.n()).done;)i()}catch(e){r.e(e)}finally{r.f()}return n}var qE=Fg.define({create:function(){return by.none},update:function(e,t){t.isUserEvent("delete")&&t.changes.iterChangedRanges(function(t,n){return e=UE(e,t,n)}),e=e.map(t.changes);var n,r=D(t.effects);try{var i=function(){var r=n.value;if(r.is(HE)&&!function(e,t,n){var r=!1;return e.between(t,t,function(e,i){e==t&&i==n&&(r=!0)}),r}(e,r.value.from,r.value.to)){var i=t.state.facet(JE).preparePlaceholder,o=i?by.replace({widget:new tA(i(t.state,r.value))}):eA;e=e.update({add:[o.range(r.value.from,r.value.to)]})}else r.is(zE)&&(e=e.update({filter:function(e,t){return r.value.from!=e||r.value.to!=t},filterFrom:r.value.from,filterTo:r.value.to}))};for(r.s();!(n=r.n()).done;)i()}catch(e){r.e(e)}finally{r.f()}return t.selection&&(e=UE(e,t.selection.main.head)),e},provide:function(e){return lx.decorations.from(e)},toJSON:function(e,t){var n=[];return e.between(0,t.doc.length,function(e,t){n.push(e,t)}),n},fromJSON:function(e){if(!Array.isArray(e)||e.length%2)throw new RangeError("Invalid JSON for fold state");for(var t=[],n=0;n<e.length;){var r=e[n++],i=e[n++];if("number"!=typeof r||"number"!=typeof i)throw new RangeError("Invalid JSON for fold state");t.push(eA.range(r,i))}return by.set(t,!0)}});function UE(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t,r=!1;return e.between(t,n,function(e,i){e<n&&i>t&&(r=!0)}),r?e.update({filterFrom:t,filterTo:n,filter:function(e,r){return e>=n||r<=t}}):e}function KE(e,t,n){var r,i=null;return null===(r=e.field(qE,!1))||void 0===r||r.between(t,n,function(e,t){(!i||i.from>e)&&(i={from:e,to:t})}),i}function GE(e,t){return e.field(qE,!1)?t:t.concat(av.appendConfig.of(QE()))}function YE(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=e.state.doc.lineAt(t.from).number,i=e.state.doc.lineAt(t.to).number;return lx.announce.of("".concat(e.state.phrase(n?"Folded lines":"Unfolded lines")," ").concat(r," ").concat(e.state.phrase("to")," ").concat(i,"."))}var $E=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:function(e){var t,n=D(VE(e));try{for(n.s();!(t=n.n()).done;){var r=t.value,i=WE(e.state,r.from,r.to);if(i)return e.dispatch({effects:GE(e.state,[HE.of(i),YE(e,i)])}),!0}}catch(e){n.e(e)}finally{n.f()}return!1}},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:function(e){if(!e.state.field(qE,!1))return!1;var t,n=[],r=D(VE(e));try{for(r.s();!(t=r.n()).done;){var i=t.value,o=KE(e.state,i.from,i.to);o&&n.push(zE.of(o),YE(e,o,!1))}}catch(e){r.e(e)}finally{r.f()}return n.length&&e.dispatch({effects:n}),n.length>0}},{key:"Ctrl-Alt-[",run:function(e){for(var t=e.state,n=[],r=0;r<t.doc.length;){var i=e.lineBlockAt(r),o=WE(t,i.from,i.to);o&&n.push(HE.of(o)),r=(o?e.lineBlockAt(o.to):i).to+1}return n.length&&e.dispatch({effects:GE(e.state,n)}),!!n.length}},{key:"Ctrl-Alt-]",run:function(e){var t=e.state.field(qE,!1);if(!t||!t.size)return!1;var n=[];return t.between(0,e.state.doc.length,function(e,t){n.push(zE.of({from:e,to:t}))}),e.dispatch({effects:n}),!0}}],XE={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},JE=Dg.define({combine:function(e){return wv(e,XE)}});function QE(e){var t=[qE,iA];return e&&t.push(JE.of(e)),t}function ZE(e,t){var n=e.state,r=n.facet(JE),i=function(t){var n=e.lineBlockAt(e.posAtDOM(t.target)),r=KE(e.state,n.from,n.to);r&&e.dispatch({effects:zE.of(r)}),t.preventDefault()};if(r.placeholderDOM)return r.placeholderDOM(e,i,t);var o=document.createElement("span");return o.textContent=r.placeholderText,o.setAttribute("aria-label",n.phrase("folded code")),o.title=n.phrase("unfold"),o.className="cm-foldPlaceholder",o.onclick=i,o}var eA=by.replace({widget:new(function(){function e(){return N(this,e),O(this,e,arguments)}return I(e,vy),R(e,[{key:"toDOM",value:function(e){return ZE(e,null)}}])}())}),tA=function(){function e(t){var n;return N(this,e),(n=O(this,e)).value=t,n}return I(e,vy),R(e,[{key:"eq",value:function(e){return this.value==e.value}},{key:"toDOM",value:function(e){return ZE(e,this.value)}}])}(),nA={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:function(){return!1}},rA=function(){function e(t,n){var r;return N(this,e),(r=O(this,e)).config=t,r.open=n,r}return I(e,RS),R(e,[{key:"eq",value:function(e){return this.config==e.config&&this.open==e.open}},{key:"toDOM",value:function(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);var t=document.createElement("span");return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?"Fold line":"Unfold line"),t}}])}();var iA=lx.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}}),oA=function(){function e(t,n){var r;function i(e){var t=Vv.newName();return(r||(r=Object.create(null)))["."+t]=e,t}N(this,e),this.specs=t;var o="string"==typeof n.all?n.all:n.all?i(n.all):void 0,s=n.scope;this.scope=s instanceof cE?function(e){return e.prop(aE)==s.data}:s?function(e){return e==s}:void 0,this.style=WC(t.map(function(e){return{tag:e.tag,class:e.class||i(Object.assign({},e,{tag:null}))}}),{all:o}).style,this.module=r?new Vv(r):null,this.themeType=n.themeType}return R(e,null,[{key:"define",value:function(t,n){return new e(t,n||{})}}])}(),sA=Dg.define(),aA=Dg.define({combine:function(e){return e.length?[e[0]]:null}});function lA(e){var t=e.facet(sA);return t.length?t:e.facet(aA)}function cA(e,t){var n,r=[hA];return e instanceof oA&&(e.module&&r.push(lx.styleModule.of(e.module)),n=e.themeType),(null==t?void 0:t.fallback)?r.push(aA.of(e)):n?r.push(sA.computeN([lx.darkTheme],function(t){return t.facet(lx.darkTheme)==("dark"==n)?[e]:[]})):r.push(sA.of(e)),r}var uA=function(){return R(function e(t){N(this,e),this.markCache=Object.create(null),this.tree=fE(t.state),this.decorations=this.buildDeco(t,lA(t.state)),this.decoratedTo=t.viewport.to},[{key:"update",value:function(e){var t=fE(e.state),n=lA(e.state),r=n!=lA(e.startState),i=e.view.viewport,o=e.changes.mapPos(this.decoratedTo,1);t.length<i.to&&!r&&t.type==this.tree.type&&o>=i.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=i.to)}},{key:"buildDeco",value:function(e,t){var n=this;if(!t||!this.tree.length)return by.none;var r,i=new Mv,o=D(e.visibleRanges);try{for(o.s();!(r=o.n()).done;){var s=r.value,a=s.from,l=s.to;jC(this.tree,t,function(e,t,r){i.add(e,t,n.markCache[r]||(n.markCache[r]=by.mark({class:r})))},a,l)}}catch(e){o.e(e)}finally{o.f()}return i.finish()}}])}(),hA=qg.high(_b.fromClass(uA,{decorations:function(e){return e.decorations}})),fA=oA.define([{tag:iE.meta,color:"#404740"},{tag:iE.link,textDecoration:"underline"},{tag:iE.heading,textDecoration:"underline",fontWeight:"bold"},{tag:iE.emphasis,fontStyle:"italic"},{tag:iE.strong,fontWeight:"bold"},{tag:iE.strikethrough,textDecoration:"line-through"},{tag:iE.keyword,color:"#708"},{tag:[iE.atom,iE.bool,iE.url,iE.contentSeparator,iE.labelName],color:"#219"},{tag:[iE.literal,iE.inserted],color:"#164"},{tag:[iE.string,iE.deleted],color:"#a11"},{tag:[iE.regexp,iE.escape,iE.special(iE.string)],color:"#e40"},{tag:iE.definition(iE.variableName),color:"#00f"},{tag:iE.local(iE.variableName),color:"#30a"},{tag:[iE.typeName,iE.namespace],color:"#085"},{tag:iE.className,color:"#167"},{tag:[iE.special(iE.variableName),iE.macroName],color:"#256"},{tag:iE.definition(iE.propertyName),color:"#00c"},{tag:iE.comment,color:"#940"},{tag:iE.invalid,color:"#f00"}]),dA=lx.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),pA="()[]{}",mA=Dg.define({combine:function(e){return wv(e,{afterCursor:!0,brackets:pA,maxScanDistance:1e4,renderMatch:yA})}}),gA=by.mark({class:"cm-matchingBracket"}),vA=by.mark({class:"cm-nonmatchingBracket"});function yA(e){var t=[],n=e.matched?gA:vA;return t.push(n.range(e.start.from,e.start.to)),e.end&&t.push(n.range(e.end.from,e.end.to)),t}function bA(e){var t,n=[],r=e.facet(mA),i=D(e.selection.ranges);try{for(i.s();!(t=i.n()).done;){var o=t.value;if(o.empty){var s=CA(e,o.head,-1,r)||o.head>0&&CA(e,o.head-1,1,r)||r.afterCursor&&(CA(e,o.head,1,r)||o.head<e.doc.length&&CA(e,o.head+1,-1,r));s&&(n=n.concat(r.renderMatch(s,e)))}}}catch(e){i.e(e)}finally{i.f()}return by.set(n,!0)}var wA=[_b.fromClass(function(){return R(function e(t){N(this,e),this.paused=!1,this.decorations=bA(t.state)},[{key:"update",value:function(e){(e.docChanged||e.selectionSet||this.paused)&&(e.view.composing?(this.decorations=this.decorations.map(e.changes),this.paused=!0):(this.decorations=bA(e.state),this.paused=!1))}}])}(),{decorations:function(e){return e.decorations}}),dA];var kA=new nC;function xA(e,t,n){var r=e.prop(t<0?nC.openedBy:nC.closedBy);if(r)return r;if(1==e.name.length){var i=n.indexOf(e.name);if(i>-1&&i%2==(t<0?1:0))return[n[i+t]]}return null}function SA(e){var t=e.type.prop(kA);return t?t(e.node):e}function CA(e,t,n){for(var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=r.maxScanDistance||1e4,o=r.brackets||pA,s=fE(e),a=s.resolveInner(t,n),l=a;l;l=l.parent){var c=xA(l.type,n,o);if(c&&l.from<l.to){var u=SA(l);if(u&&(n>0?t>=u.from&&t<u.to:t>u.from&&t<=u.to))return EA(e,t,n,l,u,c,o)}}return function(e,t,n,r,i,o,s){var a=n<0?e.sliceDoc(t-1,t):e.sliceDoc(t,t+1),l=s.indexOf(a);if(l<0||l%2==0!=n>0)return null;for(var c={from:n<0?t-1:t,to:n>0?t+1:t},u=e.doc.iterRange(t,n>0?e.doc.length:0),h=0,f=0;!u.next().done&&f<=o;){var d=u.value;n<0&&(f+=d.length);for(var p=t+f*n,m=n>0?0:d.length-1,g=n>0?d.length:-1;m!=g;m+=n){var v=s.indexOf(d[m]);if(!(v<0||r.resolveInner(p+m,1).type!=i))if(v%2==0==n>0)h++;else{if(1==h)return{start:c,end:{from:p+m,to:p+m+1},matched:v>>1==l>>1};h--}}n>0&&(f+=d.length)}return u.done?{start:c,matched:!1}:null}(e,t,n,s,a.type,i,o)}function EA(e,t,n,r,i,o,s){var a=r.parent,l={from:i.from,to:i.to},c=0,u=null==a?void 0:a.cursor();if(u&&(n<0?u.childBefore(r.from):u.childAfter(r.to)))do{if(n<0?u.to<=r.from:u.from>=r.to){if(0==c&&o.indexOf(u.type.name)>-1&&u.from<u.to){var h=SA(u);return{start:l,end:h?{from:h.from,to:h.to}:void 0,matched:!0}}if(xA(u.type,n,s))c++;else if(xA(u.type,-n,s)){if(0==c){var f=SA(u);return{start:l,end:f&&f.from<f.to?{from:f.from,to:f.to}:void 0,matched:!1}}c--}}}while(n<0?u.prevSibling():u.nextSibling());return{start:l,matched:!1}}for(var AA=Object.create(null),MA=[oC.none],OA=[],NA=Object.create(null),TA=Object.create(null),RA=0,DA=[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]];RA<DA.length;RA++){var PA=q(DA[RA],2),LA=PA[0],BA=PA[1];TA[LA]=_A(AA,BA)}function IA(e,t){OA.indexOf(e)>-1||OA.push(e)}function _A(e,t){var n,r=[],i=D(t.split(" "));try{for(i.s();!(n=i.n()).done;){var o,s=n.value,a=[],l=D(s.split("."));try{for(l.s();!(o=l.n()).done;){var c=o.value,u=e[c]||iE[c];u?"function"==typeof u?a.length?a=a.map(u):IA(c,"Modifier ".concat(c," used at start of tag")):a.length?IA(c,"Tag ".concat(c," used as modifier")):a=Array.isArray(u)?u:[u]:IA(c,"Unknown highlighting tag ".concat(c))}}catch(e){l.e(e)}finally{l.f()}var h,f=D(a);try{for(f.s();!(h=f.n()).done;){var d=h.value;r.push(d)}}catch(e){f.e(e)}finally{f.f()}}}catch(e){i.e(e)}finally{i.f()}if(!r.length)return 0;var p=t.replace(/ /g,"_"),m=p+" "+r.map(function(e){return e.id}),g=NA[m];if(g)return g.id;var v=NA[m]=oC.define({id:MA.length,name:p,props:[IC(P({},p,r))]});return MA.push(v),v.id}Yy.RTL,Yy.LTR;function FA(e,t){return function(n){var r=n.state,i=n.dispatch;if(r.readOnly)return!1;var o=e(t,r);return!!o&&(i(r.update(o)),!0)}}var WA=FA(UA,0),jA=FA(qA,0),HA=FA(function(e,t){return qA(e,t,function(e){var t,n=[],r=D(e.selection.ranges);try{for(r.s();!(t=r.n()).done;){var i=t.value,o=e.doc.lineAt(i.from),s=i.to<=o.to?o:e.doc.lineAt(i.to);s.from>o.from&&s.from==i.to&&(s=i.to==o.to+1?o:e.doc.lineAt(i.to-1));var a=n.length-1;a>=0&&n[a].to>o.from?n[a].to=s.to:n.push({from:o.from+/^\s*/.exec(o.text)[0].length,to:s.to})}}catch(e){r.e(e)}finally{r.f()}return n}(t))},0);function zA(e,t){var n=e.languageDataAt("commentTokens",t,1);return n.length?n[0]:{}}var VA=50;function qA(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t.selection.ranges,r=n.map(function(e){return zA(t,e.from).block});if(!r.every(function(e){return e}))return null;var i=n.map(function(e,n){return function(e,t,n,r){var i,o,s=t.open,a=t.close,l=e.sliceDoc(n-VA,n),c=e.sliceDoc(r,r+VA),u=/\s*$/.exec(l)[0].length,h=/^\s*/.exec(c)[0].length,f=l.length-u;if(l.slice(f-s.length,f)==s&&c.slice(h,h+a.length)==a)return{open:{pos:n-u,margin:u&&1},close:{pos:r+h,margin:h&&1}};r-n<=2*VA?i=o=e.sliceDoc(n,r):(i=e.sliceDoc(n,n+VA),o=e.sliceDoc(r-VA,r));var d=/^\s*/.exec(i)[0].length,p=/\s*$/.exec(o)[0].length,m=o.length-p-a.length;return i.slice(d,d+s.length)==s&&o.slice(m,m+a.length)==a?{open:{pos:n+d+s.length,margin:/\s/.test(i.charAt(d+s.length))?1:0},close:{pos:r-p-a.length,margin:/\s/.test(o.charAt(m-1))?1:0}}:null}(t,r[n],e.from,e.to)});if(2!=e&&!i.every(function(e){return e}))return{changes:t.changes(n.map(function(e,t){return i[t]?[]:[{from:e.from,insert:r[t].open+" "},{from:e.to,insert:" "+r[t].close}]}))};if(1!=e&&i.some(function(e){return e})){for(var o,s=[],a=0;a<i.length;a++)if(o=i[a]){var l=r[a],c=o,u=c.open,h=c.close;s.push({from:u.pos-l.open.length,to:u.pos+u.margin},{from:h.pos-h.margin,to:h.pos+l.close.length})}return{changes:s}}return null}function UA(e,t){var n,r=[],i=-1,o=D(arguments.length>2&&void 0!==arguments[2]?arguments[2]:t.selection.ranges);try{e:for(o.s();!(n=o.n()).done;){for(var s=n.value,a=s.from,l=s.to,c=r.length,u=1e9,h=void 0,f=a;f<=l;){var d=t.doc.lineAt(f);if(null==h&&!(h=zA(t,d.from).line))continue e;if(d.from>i&&(a==l||l>d.from)){i=d.from;var p=/^\s*/.exec(d.text)[0].length,m=p==d.length,g=d.text.slice(p,p+h.length)==h?p:-1;p<d.text.length&&p<u&&(u=p),r.push({line:d,comment:g,token:h,indent:p,empty:m,single:!1})}f=d.to+1}if(u<1e9)for(var v=c;v<r.length;v++)r[v].indent<r[v].line.text.length&&(r[v].indent=u);r.length==c+1&&(r[c].single=!0)}}catch(e){o.e(e)}finally{o.f()}if(2!=e&&r.some(function(e){return e.comment<0&&(!e.empty||e.single)})){var y,b=[],w=D(r);try{for(w.s();!(y=w.n()).done;){var k=y.value,x=k.line,S=k.token,C=k.indent,E=k.empty;!k.single&&E||b.push({from:x.from+C,insert:S+" "})}}catch(e){w.e(e)}finally{w.f()}var A=t.changes(b);return{changes:A,selection:t.selection.map(A,1)}}if(1!=e&&r.some(function(e){return e.comment>=0})){var M,O=[],N=D(r);try{for(N.s();!(M=N.n()).done;){var T=M.value,R=T.line,P=T.comment,L=T.token;if(P>=0){var B=R.from+P,I=B+L.length;" "==R.text[I-R.from]&&I++,O.push({from:B,to:I})}}}catch(e){N.e(e)}finally{N.f()}return{changes:O}}return null}var KA=iv.define(),GA=iv.define(),YA=Dg.define(),$A=Dg.define({combine:function(e){return wv(e,{minDepth:100,newGroupDelay:500,joinToEvent:function(e,t){return t}},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:function(e,t){return function(n,r){return e(n,r)||t(n,r)}}})}}),XA=Fg.define({create:function(){return fM.empty},update:function(e,t){var n=t.state.facet($A),r=t.annotation(KA);if(r){var i=nM.fromTransaction(t,r.selection),o=r.side,s=0==o?e.undone:e.done;return s=i?rM(s,s.length,n.minDepth,i):aM(s,t.startState.selection),new fM(0==o?r.rest:s,0==o?s:r.rest)}var a=t.annotation(GA);if("full"!=a&&"before"!=a||(e=e.isolate()),!1===t.annotation(lv.addToHistory))return t.changes.empty?e:e.addMapping(t.changes.desc);var l=nM.fromTransaction(t),c=t.annotation(lv.time),u=t.annotation(lv.userEvent);return l?e=e.addChanges(l,c,u,n,t):t.selection&&(e=e.addSelection(t.startState.selection,c,u,n.newGroupDelay)),"full"!=a&&"after"!=a||(e=e.isolate()),e},toJSON:function(e){return{done:e.done.map(function(e){return e.toJSON()}),undone:e.undone.map(function(e){return e.toJSON()})}},fromJSON:function(e){return new fM(e.done.map(nM.fromJSON),e.undone.map(nM.fromJSON))}});function JA(e,t){return function(n){var r=n.state,i=n.dispatch;if(!t&&r.readOnly)return!1;var o=r.field(XA,!1);if(!o)return!1;var s=o.pop(e,r,t);return!!s&&(i(s),!0)}}var QA=JA(0,!1),ZA=JA(1,!1),eM=JA(0,!0),tM=JA(1,!0),nM=function(){function e(t,n,r,i,o){N(this,e),this.changes=t,this.effects=n,this.mapped=r,this.startSelection=i,this.selectionsAfter=o}return R(e,[{key:"setSelAfter",value:function(t){return new e(this.changes,this.effects,this.mapped,this.startSelection,t)}},{key:"toJSON",value:function(){var e,t,n;return{changes:null===(e=this.changes)||void 0===e?void 0:e.toJSON(),mapped:null===(t=this.mapped)||void 0===t?void 0:t.toJSON(),startSelection:null===(n=this.startSelection)||void 0===n?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map(function(e){return e.toJSON()})}}}],[{key:"fromJSON",value:function(t){return new e(t.changes&&kg.fromJSON(t.changes),[],t.mapped&&wg.fromJSON(t.mapped),t.startSelection&&Ng.fromJSON(t.startSelection),t.selectionsAfter.map(Ng.fromJSON))}},{key:"fromTransaction",value:function(t,n){var r,i=oM,o=D(t.startState.facet(YA));try{for(o.s();!(r=o.n()).done;){var s=(0,r.value)(t);s.length&&(i=i.concat(s))}}catch(e){o.e(e)}finally{o.f()}return!i.length&&t.changes.empty?null:new e(t.changes.invert(t.startState.doc),i,void 0,n||t.startState.selection,oM)}},{key:"selection",value:function(t){return new e(void 0,oM,void 0,void 0,t)}}])}();function rM(e,t,n,r){var i=t+1>n+20?t-n-1:0,o=e.slice(i,t);return o.push(r),o}function iM(e,t){return e.length?t.length?e.concat(t):e:t}var oM=[],sM=200;function aM(e,t){if(e.length){var n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-sM));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),rM(e,e.length-1,1e9,n.setSelAfter(r)))}return[nM.selection([t])]}function lM(e){var t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function cM(e,t){if(!e.length)return e;for(var n=e.length,r=oM;n;){var i=uM(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){var o=e.slice(0,n);return o[n-1]=i,o}t=i.mapped,n--,r=i.selectionsAfter}return r.length?[nM.selection(r)]:oM}function uM(e,t,n){var r=iM(e.selectionsAfter.length?e.selectionsAfter.map(function(e){return e.map(t)}):oM,n);if(!e.changes)return nM.selection(r);var i=e.changes.map(t),o=t.mapDesc(e.changes,!0),s=e.mapped?e.mapped.composeDesc(o):o;return new nM(i,av.mapEffects(e.effects,t),s,e.startSelection.map(o),r)}var hM=/^(input\.type|delete)($|\.)/,fM=function(){function e(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:void 0;N(this,e),this.done=t,this.undone=n,this.prevTime=r,this.prevUserEvent=i}return R(e,[{key:"isolate",value:function(){return this.prevTime?new e(this.done,this.undone):this}},{key:"addChanges",value:function(t,n,r,i,o){var s=this.done,a=s[s.length-1];return s=a&&a.changes&&!a.changes.empty&&t.changes&&(!r||hM.test(r))&&(!a.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(o,function(e,t){var n=[],r=!1;return e.iterChangedRanges(function(e,t){return n.push(e,t)}),t.iterChangedRanges(function(e,t,i,o){for(var s=0;s<n.length;){var a=n[s++],l=n[s++];o>=a&&i<=l&&(r=!0)}}),r}(a.changes,t.changes))||"input.type.compose"==r)?rM(s,s.length-1,i.minDepth,new nM(t.changes.compose(a.changes),iM(av.mapEffects(t.effects,a.changes),a.effects),a.mapped,a.startSelection,oM)):rM(s,s.length,i.minDepth,t),new e(s,oM,n,r)}},{key:"addSelection",value:function(t,n,r,i){var o,s,a=this.done.length?this.done[this.done.length-1].selectionsAfter:oM;return a.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&(o=a[a.length-1],s=t,o.ranges.length==s.ranges.length&&0===o.ranges.filter(function(e,t){return e.empty!=s.ranges[t].empty}).length)?this:new e(aM(this.done,t),this.undone,n,r)}},{key:"addMapping",value:function(t){return new e(cM(this.done,t),cM(this.undone,t),this.prevTime,this.prevUserEvent)}},{key:"pop",value:function(e,t,n){var r=0==e?this.done:this.undone;if(0==r.length)return null;var i=r[r.length-1],o=i.selectionsAfter[0]||(i.startSelection?i.startSelection.map(i.changes.invertedDesc,1):t.selection);if(n&&i.selectionsAfter.length)return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:KA.of({side:e,rest:lM(r),selection:o}),userEvent:0==e?"select.undo":"select.redo",scrollIntoView:!0});if(i.changes){var s=1==r.length?oM:r.slice(0,r.length-1);return i.mapped&&(s=cM(s,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:KA.of({side:e,rest:s,selection:o}),filter:!1,userEvent:0==e?"undo":"redo",scrollIntoView:!0})}return null}}])}();fM.empty=new fM(oM,oM);var dM=[{key:"Mod-z",run:QA,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:ZA,preventDefault:!0},{linux:"Ctrl-Shift-z",run:ZA,preventDefault:!0},{key:"Mod-u",run:eM,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:tM,preventDefault:!0}];function pM(e,t){return Ng.create(e.ranges.map(t),e.mainIndex)}function mM(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function gM(e,t){var n=e.state,r=e.dispatch,i=pM(n.selection,t);return!i.eq(n.selection,!0)&&(r(mM(n,i)),!0)}function vM(e,t){return Ng.cursor(t?e.to:e.from)}function yM(e,t){return gM(e,function(n){return n.empty?e.moveByChar(n,t):vM(n,t)})}function bM(e){return e.textDirectionAt(e.state.selection.main.head)==Yy.LTR}var wM=function(e){return yM(e,!bM(e))},kM=function(e){return yM(e,bM(e))};function xM(e,t){return gM(e,function(n){return n.empty?e.moveByGroup(n,t):vM(n,t)})}function SM(e,t,n){if(t.type.prop(n))return!0;var r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function CM(e,t,n){for(var r=fE(e).resolveInner(t.head),i=n?nC.closedBy:nC.openedBy,o=t.head;;){var s=n?r.childAfter(o):r.childBefore(o);if(!s)break;SM(e,s,i)?r=s:o=n?s.to:s.from}var a,l;return l=r.type.prop(i)&&(a=n?CA(e,r.from,1):CA(e,r.to,-1))&&a.matched?n?a.end.to:a.end.from:n?r.to:r.from,Ng.cursor(l,n?-1:1)}function EM(e,t){return gM(e,function(n){if(!n.empty)return vM(n,t);var r=e.moveVertically(n,t);return r.head!=n.head?r:e.moveToLineBoundary(n,t)})}var AM=function(e){return EM(e,!1)},MM=function(e){return EM(e,!0)};function OM(e){var t,n=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,r=0,i=0;if(n){var o,s=D(e.state.facet(lx.scrollMargins));try{for(s.s();!(o=s.n()).done;){var a=(0,o.value)(e);(null==a?void 0:a.top)&&(r=Math.max(null==a?void 0:a.top,r)),(null==a?void 0:a.bottom)&&(i=Math.max(null==a?void 0:a.bottom,i))}}catch(e){s.e(e)}finally{s.f()}t=e.scrollDOM.clientHeight-r-i}else t=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:r,marginBottom:i,selfScroll:n,height:Math.max(e.defaultLineHeight,t-5)}}function NM(e,t){var n,r=OM(e),i=e.state,o=pM(i.selection,function(n){return n.empty?e.moveVertically(n,t,r.height):vM(n,t)});if(o.eq(i.selection))return!1;if(r.selfScroll){var s=e.coordsAtPos(i.selection.main.head),a=e.scrollDOM.getBoundingClientRect(),l=a.top+r.marginTop,c=a.bottom-r.marginBottom;s&&s.top>l&&s.bottom<c&&(n=lx.scrollIntoView(o.main.head,{y:"start",yMargin:s.top-l}))}return e.dispatch(mM(i,o),{effects:n}),!0}var TM=function(e){return NM(e,!1)},RM=function(e){return NM(e,!0)};function DM(e,t,n){var r=e.lineBlockAt(t.head),i=e.moveToLineBoundary(t,n);if(i.head==t.head&&i.head!=(n?r.to:r.from)&&(i=e.moveToLineBoundary(t,n,!1)),!n&&i.head==r.from&&r.length){var o=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;o&&t.head!=r.from+o&&(i=Ng.cursor(r.from+o))}return i}function PM(e,t){var n=pM(e.state.selection,function(e){var n=t(e);return Ng.range(e.anchor,n.head,n.goalColumn,n.bidiLevel||void 0)});return!n.eq(e.state.selection)&&(e.dispatch(mM(e.state,n)),!0)}function LM(e,t){return PM(e,function(n){return e.moveByChar(n,t)})}var BM=function(e){return LM(e,!bM(e))},IM=function(e){return LM(e,bM(e))};function _M(e,t){return PM(e,function(n){return e.moveByGroup(n,t)})}function FM(e,t){return PM(e,function(n){return e.moveVertically(n,t)})}var WM=function(e){return FM(e,!1)},jM=function(e){return FM(e,!0)};function HM(e,t){return PM(e,function(n){return e.moveVertically(n,t,OM(e).height)})}var zM=function(e){return HM(e,!1)},VM=function(e){return HM(e,!0)},qM=function(e){var t=e.state;return(0,e.dispatch)(mM(t,{anchor:0})),!0},UM=function(e){var t=e.state;return(0,e.dispatch)(mM(t,{anchor:t.doc.length})),!0},KM=function(e){var t=e.state;return(0,e.dispatch)(mM(t,{anchor:t.selection.main.anchor,head:0})),!0},GM=function(e){var t=e.state;return(0,e.dispatch)(mM(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0};function YM(e,t){var n,r=e.state,i=r.selection,o=r.selection.ranges.slice(),s=D(r.selection.ranges);try{for(s.s();!(n=s.n()).done;){var a=n.value,l=r.doc.lineAt(a.head);if(t?l.to<e.state.doc.length:l.from>0)for(var c=function(n){var r=e.moveVertically(n,t);return r.head<l.from||r.head>l.to?(o.some(function(e){return e.head==r.head})||o.push(r),u=n,0):r.head==n.head?(u=n,0):void(u=n=r)},u=a;0!==c(u););}}catch(e){s.e(e)}finally{s.f()}return o.length!=i.ranges.length&&(e.dispatch(mM(r,Ng.create(o,o.length-1))),!0)}function $M(e,t){if(e.state.readOnly)return!1;var n="delete.selection",r=e.state,i=r.changeByRange(function(r){var i=r.from,o=r.to;if(i==o){var s=t(r);s<i?(n="delete.backward",s=XM(e,s,!1)):s>i&&(n="delete.forward",s=XM(e,s,!0)),i=Math.min(i,s),o=Math.max(o,s)}else i=XM(e,i,!1),o=XM(e,o,!0);return i==o?{range:r}:{changes:{from:i,to:o},range:Ng.cursor(i,i<r.head?-1:1)}});return!i.changes.empty&&(e.dispatch(r.update(i,{scrollIntoView:!0,userEvent:n,effects:"delete.selection"==n?lx.announce.of(r.phrase("Selection deleted")):void 0})),!0)}function XM(e,t,n){if(e instanceof lx){var r,i=D(e.state.facet(lx.atomicRanges).map(function(t){return t(e)}));try{for(i.s();!(r=i.n()).done;){r.value.between(t,t,function(e,r){e<t&&r>t&&(t=n?r:e)})}}catch(e){i.e(e)}finally{i.f()}}return t}var JM=function(e,t,n){return $M(e,function(r){var i,o,s=r.from,a=e.state,l=a.doc.lineAt(s);if(n&&!t&&s>l.from&&s<l.from+200&&!/[^ \t]/.test(i=l.text.slice(0,s-l.from))){if("\t"==i[i.length-1])return s-1;for(var c=Fv(i,a.tabSize)%EE(a)||EE(a),u=0;u<c&&" "==i[i.length-1-u];u++)s--;o=s}else(o=pg(l.text,s-l.from,t,t)+l.from)==s&&l.number!=(t?a.doc.lines:1)?o+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(l.text.slice(o-l.from,s-l.from))&&(o=pg(l.text,o-l.from,!1,!1)+l.from);return o})},QM=function(e){return JM(e,!1,!0)},ZM=function(e){return JM(e,!0,!1)},eO=function(e,t){return $M(e,function(n){for(var r=n.head,i=e.state,o=i.doc.lineAt(r),s=i.charCategorizer(r),a=null;;){if(r==(t?o.to:o.from)){r==n.head&&o.number!=(t?i.doc.lines:1)&&(r+=t?1:-1);break}var l=pg(o.text,r-o.from,t)+o.from,c=o.text.slice(Math.min(r,l)-o.from,Math.max(r,l)-o.from),u=s(c);if(null!=a&&u!=a)break;" "==c&&r==n.head||(a=u),r=l}return r})},tO=function(e){return eO(e,!1)};function nO(e){var t,n=[],r=-1,i=D(e.selection.ranges);try{for(i.s();!(t=i.n()).done;){var o=t.value,s=e.doc.lineAt(o.from),a=e.doc.lineAt(o.to);if(o.empty||o.to!=a.from||(a=e.doc.lineAt(o.to-1)),r>=s.number){var l=n[n.length-1];l.to=a.to,l.ranges.push(o)}else n.push({from:s.from,to:a.to,ranges:[o]});r=a.number+1}}catch(e){i.e(e)}finally{i.f()}return n}function rO(e,t,n){if(e.readOnly)return!1;var r,i=[],o=[],s=D(nO(e));try{for(s.s();!(r=s.n()).done;){var a=r.value;if(n?a.to!=e.doc.length:0!=a.from){var l=e.doc.lineAt(n?a.to+1:a.from-1),c=l.length+1;if(n){i.push({from:a.to,to:l.to},{from:a.from,insert:l.text+e.lineBreak});var u,h=D(a.ranges);try{for(h.s();!(u=h.n()).done;){var f=u.value;o.push(Ng.range(Math.min(e.doc.length,f.anchor+c),Math.min(e.doc.length,f.head+c)))}}catch(e){h.e(e)}finally{h.f()}}else{i.push({from:l.from,to:a.from},{from:a.to,insert:e.lineBreak+l.text});var d,p=D(a.ranges);try{for(p.s();!(d=p.n()).done;){var m=d.value;o.push(Ng.range(m.anchor-c,m.head-c))}}catch(e){p.e(e)}finally{p.f()}}}}}catch(e){s.e(e)}finally{s.f()}return!!i.length&&(t(e.update({changes:i,scrollIntoView:!0,selection:Ng.create(o,e.selection.mainIndex),userEvent:"move.line"})),!0)}function iO(e,t,n){if(e.readOnly)return!1;var r,i=[],o=D(nO(e));try{for(o.s();!(r=o.n()).done;){var s=r.value;n?i.push({from:s.from,insert:e.doc.slice(s.from,s.to)+e.lineBreak}):i.push({from:s.to,insert:e.lineBreak+e.doc.slice(s.from,s.to)})}}catch(e){o.e(e)}finally{o.f()}var a=e.changes(i);return t(e.update({changes:a,selection:e.selection.map(a,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}var oO=aO(!1),sO=aO(!0);function aO(e){return function(t){var n=t.state,r=t.dispatch;if(n.readOnly)return!1;var i=n.changeByRange(function(t){var r=t.from,i=t.to,o=n.doc.lineAt(r),s=!e&&r==i&&function(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};var n,r=fE(e).resolveInner(t),i=r.childBefore(t),o=r.childAfter(t);return i&&o&&i.to<=t&&o.from>=t&&(n=i.type.prop(nC.closedBy))&&n.indexOf(o.name)>-1&&e.doc.lineAt(i.to).from==e.doc.lineAt(o.from).from&&!/\S/.test(e.sliceDoc(i.to,o.from))?{from:i.to,to:o.from}:null}(n,r);e&&(r=i=(i<=o.to?o:n.doc.lineAt(i)).to);var a=new OE(n,{simulateBreak:r,simulateDoubleBreak:!!s}),l=ME(a,r);for(null==l&&(l=Fv(/^\s*/.exec(n.doc.lineAt(r).text)[0],n.tabSize));i<o.to&&/\s/.test(o.text[i-o.from]);)i++;s?(r=s.from,i=s.to):r>o.from&&r<o.from+100&&!/\S/.test(o.text.slice(0,r))&&(r=o.from);var c=["",AE(n,l)];return s&&c.push(AE(n,a.lineIndent(o.from,-1))),{changes:{from:r,to:i,insert:ig.of(c)},range:Ng.cursor(r+1+c[1].length)}});return r(n.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function lO(e,t){var n=-1;return e.changeByRange(function(r){for(var i=[],o=r.from;o<=r.to;){var s=e.doc.lineAt(o);s.number>n&&(r.empty||r.to>s.from)&&(t(s,i,r),n=s.number),o=s.to+1}var a=e.changes(i);return{changes:i,range:Ng.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}var cO=function(e){var t=e.state,n=e.dispatch;return!t.readOnly&&(n(t.update(lO(t,function(e,n){n.push({from:e.from,insert:t.facet(CE)})}),{userEvent:"input.indent"})),!0)},uO=function(e){var t=e.state,n=e.dispatch;return!t.readOnly&&(n(t.update(lO(t,function(e,n){var r=/^\s*/.exec(e.text)[0];if(r){for(var i=Fv(r,t.tabSize),o=0,s=AE(t,Math.max(0,i-EE(t)));o<r.length&&o<s.length&&r.charCodeAt(o)==s.charCodeAt(o);)o++;n.push({from:e.from+o,to:e.from+r.length,insert:s.slice(o)})}}),{userEvent:"delete.dedent"})),!0)},hO=[{key:"Ctrl-b",run:wM,shift:BM,preventDefault:!0},{key:"Ctrl-f",run:kM,shift:IM},{key:"Ctrl-p",run:AM,shift:WM},{key:"Ctrl-n",run:MM,shift:jM},{key:"Ctrl-a",run:function(e){return gM(e,function(t){return Ng.cursor(e.lineBlockAt(t.head).from,1)})},shift:function(e){return PM(e,function(t){return Ng.cursor(e.lineBlockAt(t.head).from)})}},{key:"Ctrl-e",run:function(e){return gM(e,function(t){return Ng.cursor(e.lineBlockAt(t.head).to,-1)})},shift:function(e){return PM(e,function(t){return Ng.cursor(e.lineBlockAt(t.head).to)})}},{key:"Ctrl-d",run:ZM},{key:"Ctrl-h",run:QM},{key:"Ctrl-k",run:function(e){return $M(e,function(t){var n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)})}},{key:"Ctrl-Alt-h",run:tO},{key:"Ctrl-o",run:function(e){var t=e.state,n=e.dispatch;if(t.readOnly)return!1;var r=t.changeByRange(function(e){return{changes:{from:e.from,to:e.to,insert:ig.of(["",""])},range:Ng.cursor(e.from)}});return n(t.update(r,{scrollIntoView:!0,userEvent:"input"})),!0}},{key:"Ctrl-t",run:function(e){var t=e.state,n=e.dispatch;if(t.readOnly)return!1;var r=t.changeByRange(function(e){if(!e.empty||0==e.from||e.from==t.doc.length)return{range:e};var n=e.from,r=t.doc.lineAt(n),i=n==r.from?n-1:pg(r.text,n-r.from,!1)+r.from,o=n==r.to?n+1:pg(r.text,n-r.from,!0)+r.from;return{changes:{from:i,to:o,insert:t.doc.slice(n,o).append(t.doc.slice(i,n))},range:Ng.cursor(o)}});return!r.changes.empty&&(n(t.update(r,{scrollIntoView:!0,userEvent:"move.character"})),!0)}},{key:"Ctrl-v",run:RM}],fO=[{key:"ArrowLeft",run:wM,shift:BM,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:function(e){return xM(e,!bM(e))},shift:function(e){return _M(e,!bM(e))},preventDefault:!0},{mac:"Cmd-ArrowLeft",run:function(e){return gM(e,function(t){return DM(e,t,!bM(e))})},shift:function(e){return PM(e,function(t){return DM(e,t,!bM(e))})},preventDefault:!0},{key:"ArrowRight",run:kM,shift:IM,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:function(e){return xM(e,bM(e))},shift:function(e){return _M(e,bM(e))},preventDefault:!0},{mac:"Cmd-ArrowRight",run:function(e){return gM(e,function(t){return DM(e,t,bM(e))})},shift:function(e){return PM(e,function(t){return DM(e,t,bM(e))})},preventDefault:!0},{key:"ArrowUp",run:AM,shift:WM,preventDefault:!0},{mac:"Cmd-ArrowUp",run:qM,shift:KM},{mac:"Ctrl-ArrowUp",run:TM,shift:zM},{key:"ArrowDown",run:MM,shift:jM,preventDefault:!0},{mac:"Cmd-ArrowDown",run:UM,shift:GM},{mac:"Ctrl-ArrowDown",run:RM,shift:VM},{key:"PageUp",run:TM,shift:zM},{key:"PageDown",run:RM,shift:VM},{key:"Home",run:function(e){return gM(e,function(t){return DM(e,t,!1)})},shift:function(e){return PM(e,function(t){return DM(e,t,!1)})},preventDefault:!0},{key:"Mod-Home",run:qM,shift:KM},{key:"End",run:function(e){return gM(e,function(t){return DM(e,t,!0)})},shift:function(e){return PM(e,function(t){return DM(e,t,!0)})},preventDefault:!0},{key:"Mod-End",run:UM,shift:GM},{key:"Enter",run:oO,shift:oO},{key:"Mod-a",run:function(e){var t=e.state;return(0,e.dispatch)(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0}},{key:"Backspace",run:QM,shift:QM,preventDefault:!0},{key:"Delete",run:ZM,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:tO,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:function(e){return eO(e,!0)},preventDefault:!0},{mac:"Mod-Backspace",run:function(e){return $M(e,function(t){var n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)})},preventDefault:!0},{mac:"Mod-Delete",run:function(e){return $M(e,function(t){var n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)})},preventDefault:!0}].concat(hO.map(function(e){return{mac:e.key,run:e.run,shift:e.shift}})),dO=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:function(e){return gM(e,function(t){return CM(e.state,t,!bM(e))})},shift:function(e){return PM(e,function(t){return CM(e.state,t,!bM(e))})}},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:function(e){return gM(e,function(t){return CM(e.state,t,bM(e))})},shift:function(e){return PM(e,function(t){return CM(e.state,t,bM(e))})}},{key:"Alt-ArrowUp",run:function(e){return rO(e.state,e.dispatch,!1)}},{key:"Shift-Alt-ArrowUp",run:function(e){return iO(e.state,e.dispatch,!1)}},{key:"Alt-ArrowDown",run:function(e){return rO(e.state,e.dispatch,!0)}},{key:"Shift-Alt-ArrowDown",run:function(e){return iO(e.state,e.dispatch,!0)}},{key:"Mod-Alt-ArrowUp",run:function(e){return YM(e,!1)}},{key:"Mod-Alt-ArrowDown",run:function(e){return YM(e,!0)}},{key:"Escape",run:function(e){var t=e.state,n=e.dispatch,r=t.selection,i=null;return r.ranges.length>1?i=Ng.create([r.main]):r.main.empty||(i=Ng.create([Ng.cursor(r.main.head)])),!!i&&(n(mM(t,i)),!0)}},{key:"Mod-Enter",run:sO},{key:"Alt-l",mac:"Ctrl-l",run:function(e){var t=e.state,n=e.dispatch,r=nO(t).map(function(e){var n=e.from,r=e.to;return Ng.range(n,Math.min(r+1,t.doc.length))});return n(t.update({selection:Ng.create(r),userEvent:"select"})),!0}},{key:"Mod-i",run:function(e){var t=e.state,n=e.dispatch,r=pM(t.selection,function(e){var n=fE(t),r=n.resolveStack(e.from,1);if(e.empty){var i=n.resolveStack(e.from,-1);i.node.from>=r.node.from&&i.node.to<=r.node.to&&(r=i)}for(var o=r;o;o=o.next){var s=o.node;if((s.from<e.from&&s.to>=e.to||s.to>e.to&&s.from<=e.from)&&o.next)return Ng.range(s.to,s.from)}return e});return!r.eq(t.selection)&&(n(mM(t,r)),!0)},preventDefault:!0},{key:"Mod-[",run:uO},{key:"Mod-]",run:cO},{key:"Mod-Alt-\\",run:function(e){var t=e.state,n=e.dispatch;if(t.readOnly)return!1;var r=Object.create(null),i=new OE(t,{overrideIndentation:function(e){var t=r[e];return null==t?-1:t}}),o=lO(t,function(e,n,o){var s=ME(i,e.from);if(null!=s){/\S/.test(e.text)||(s=0);var a=/^\s*/.exec(e.text)[0],l=AE(t,s);(a!=l||o.from<e.from+a.length)&&(r[e.from]=s,n.push({from:e.from,to:e.from+a.length,insert:l}))}});return o.changes.empty||n(t.update(o,{userEvent:"indent"})),!0}},{key:"Shift-Mod-k",run:function(e){if(e.state.readOnly)return!1;var t=e.state,n=t.changes(nO(t).map(function(e){var n=e.from,r=e.to;return n>0?n--:r<t.doc.length&&r++,{from:n,to:r}})),r=pM(t.selection,function(t){var n=void 0;if(e.lineWrapping){var r=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=r.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0}},{key:"Shift-Mod-\\",run:function(e){return function(e,t,n){var r=!1,i=pM(e.selection,function(t){var i=CA(e,t.head,-1)||CA(e,t.head,1)||t.head>0&&CA(e,t.head-1,1)||t.head<e.doc.length&&CA(e,t.head+1,-1);if(!i||!i.end)return t;r=!0;var o=i.start.from==t.head?i.end.to:i.end.from;return n?Ng.range(t.anchor,o):Ng.cursor(o)});return!!r&&(t(mM(e,i)),!0)}(e.state,e.dispatch,!1)}},{key:"Mod-/",run:function(e){var t=e.state,n=t.doc.lineAt(t.selection.main.from),r=zA(e.state,n.from);return r.line?WA(e):!!r.block&&HA(e)}},{key:"Alt-A",run:jA},{key:"Ctrl-m",mac:"Shift-Alt-m",run:function(e){return e.setTabFocusMode(),!0}}].concat(fO),pO={key:"Tab",run:cO,shift:uO},mO="function"==typeof String.prototype.normalize?function(e){return e.normalize("NFKD")}:function(e){return e},gO=function(){return R(function e(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:t.length,o=arguments.length>4?arguments[4]:void 0,s=arguments.length>5?arguments[5]:void 0;N(this,e),this.test=s,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=t.iterRange(r,i),this.bufferStart=r,this.normalize=o?function(e){return o(mO(e))}:mO,this.query=this.normalize(n)},[{key:"peek",value:function(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return mg(this.buffer,this.bufferPos)}},{key:"next",value:function(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}},{key:"nextOverlapping",value:function(){for(;;){var e=this.peek();if(e<0)return this.done=!0,this;var t=gg(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=vg(e);var r=this.normalize(t);if(r.length)for(var i=0,o=n;;i++){var s=r.charCodeAt(i),a=this.match(s,o,this.bufferPos+this.bufferStart);if(i==r.length-1){if(a)return this.value=a,this;break}o==n&&i<t.length&&t.charCodeAt(i)==s&&o++}}}},{key:"match",value:function(e,t,n){for(var r=null,i=0;i<this.matches.length;i+=2){var o=this.matches[i],s=!1;this.query.charCodeAt(o)==e&&(o==this.query.length-1?r={from:this.matches[i+1],to:n}:(this.matches[i]++,s=!0)),s||(this.matches.splice(i,2),i-=2)}return this.query.charCodeAt(0)==e&&(1==this.query.length?r={from:t,to:n}:this.matches.push(1,t)),r&&this.test&&!this.test(r.from,r.to,this.buffer,this.bufferStart)&&(r=null),r}}])}();"undefined"!=typeof Symbol&&(gO.prototype[Symbol.iterator]=function(){return this});var vO={from:-1,to:-1,match:/.*/.exec("")},yO="gm"+(null==/x/.unicode?"":"u"),bO=function(){return R(function e(t,n,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:t.length;if(N(this,e),this.text=t,this.to=o,this.curLine="",this.done=!1,this.value=vO,/\\[sWDnr]|\n|\r|\[\^/.test(n))return new xO(t,n,r,i,o);this.re=new RegExp(n,yO+((null==r?void 0:r.ignoreCase)?"i":"")),this.test=null==r?void 0:r.test,this.iter=t.iter();var s=t.lineAt(i);this.curLineStart=s.from,this.matchPos=SO(t,i),this.getLine(this.curLineStart)},[{key:"getLine",value:function(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}},{key:"nextLine",value:function(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}},{key:"next",value:function(){for(var e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;var t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){var n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=SO(this.text,r+(n==r?1:0)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,match:t},this;e=this.matchPos-this.curLineStart}else{if(!(this.curLineStart+this.curLine.length<this.to))return this.done=!0,this;this.nextLine(),e=0}}}}])}(),wO=new WeakMap,kO=function(){function e(t,n){N(this,e),this.from=t,this.text=n}return R(e,[{key:"to",get:function(){return this.from+this.text.length}}],[{key:"get",value:function(t,n,r){var i=wO.get(t);if(!i||i.from>=r||i.to<=n){var o=new e(n,t.sliceString(n,r));return wO.set(t,o),o}if(i.from==n&&i.to==r)return i;var s=i.text,a=i.from;return a>n&&(s=t.sliceString(n,a)+s,a=n),i.to<r&&(s+=t.sliceString(i.to,r)),wO.set(t,new e(a,s)),new e(n,s.slice(n-a,r-a))}}])}(),xO=function(){return R(function e(t,n,r,i,o){N(this,e),this.text=t,this.to=o,this.done=!1,this.value=vO,this.matchPos=SO(t,i),this.re=new RegExp(n,yO+((null==r?void 0:r.ignoreCase)?"i":"")),this.test=null==r?void 0:r.test,this.flat=kO.get(t,i,this.chunkEnd(i+5e3))},[{key:"chunkEnd",value:function(e){return e>=this.to?this.to:this.text.lineAt(e).to}},{key:"next",value:function(){for(;;){var e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){var n=this.flat.from+t.index,r=n+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,match:t},this.matchPos=SO(this.text,r+(n==r?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=kO.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+2*this.flat.text.length))}}}])}();function SO(e,t){if(t>=e.length)return t;for(var n,r=e.lineAt(t);t<r.to&&(n=r.text.charCodeAt(t-r.from))>=56320&&n<57344;)t++;return t}"undefined"!=typeof Symbol&&(bO.prototype[Symbol.iterator]=xO.prototype[Symbol.iterator]=function(){return this});var CO={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},EO=Dg.define({combine:function(e){return wv(e,CO,{highlightWordAroundCursor:function(e,t){return e||t},minSelectionLength:Math.min,maxMatches:Math.min})}});var AO=by.mark({class:"cm-selectionMatch"}),MO=by.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function OO(e,t,n,r){return!(0!=n&&e(t.sliceDoc(n-1,n))==gv.Word||r!=t.doc.length&&e(t.sliceDoc(r,r+1))==gv.Word)}var NO=_b.fromClass(function(){return R(function e(t){N(this,e),this.decorations=this.getDeco(t)},[{key:"update",value:function(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}},{key:"getDeco",value:function(e){var t=e.state.facet(EO),n=e.state,r=n.selection;if(r.ranges.length>1)return by.none;var i,o=r.main,s=null;if(o.empty){if(!t.highlightWordAroundCursor)return by.none;var a=n.wordAt(o.head);if(!a)return by.none;s=n.charCategorizer(o.head),i=n.sliceDoc(a.from,a.to)}else{var l=o.to-o.from;if(l<t.minSelectionLength||l>200)return by.none;if(t.wholeWords){if(i=n.sliceDoc(o.from,o.to),!OO(s=n.charCategorizer(o.head),n,o.from,o.to)||!function(e,t,n,r){return e(t.sliceDoc(n,n+1))==gv.Word&&e(t.sliceDoc(r-1,r))==gv.Word}(s,n,o.from,o.to))return by.none}else if(!(i=n.sliceDoc(o.from,o.to)))return by.none}var c,u=[],h=D(e.visibleRanges);try{for(h.s();!(c=h.n()).done;)for(var f=c.value,d=new gO(n.doc,i,f.from,f.to);!d.next().done;){var p=d.value,m=p.from,g=p.to;if((!s||OO(s,n,m,g))&&(o.empty&&m<=o.from&&g>=o.to?u.push(MO.range(m,g)):(m>=o.to||g<=o.from)&&u.push(AO.range(m,g)),u.length>t.maxMatches))return by.none}}catch(e){h.e(e)}finally{h.f()}return by.set(u)}}])}(),{decorations:function(e){return e.decorations}}),TO=lx.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}});var RO=Dg.define({combine:function(e){return wv(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:function(e){return new sN(e)},scrollToMatch:function(e){return lx.scrollIntoView(e)}})}}),DO=function(){return R(function e(t){N(this,e),this.search=t.search,this.caseSensitive=!!t.caseSensitive,this.literal=!!t.literal,this.regexp=!!t.regexp,this.replace=t.replace||"",this.valid=!!this.search&&(!this.regexp||function(e){try{return new RegExp(e,yO),!0}catch(e){return!1}}(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!t.wholeWord,this.test=t.test},[{key:"unquote",value:function(e){return this.literal?e:e.replace(/\\([nrt\\])/g,function(e,t){return"n"==t?"\n":"r"==t?"\r":"t"==t?"\t":"\\"})}},{key:"eq",value:function(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}},{key:"create",value:function(){return this.regexp?new WO(this):new BO(this)}},{key:"getCursor",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2?arguments[2]:void 0,r=e.doc?e:bv.create({doc:e});return null==n&&(n=r.doc.length),this.regexp?IO(this,r,t,n):LO(this,r,t,n)}}])}(),PO=R(function e(t){N(this,e),this.spec=t});function LO(e,t,n,r){var i;return e.wholeWord&&(i=function(e,t){return function(n,r,i,o){return(o>n||o+i.length<r)&&(o=Math.max(0,n-2),i=e.sliceString(o,Math.min(e.length,r+2))),!(t(_O(i,n-o))==gv.Word&&t(FO(i,n-o))==gv.Word||t(FO(i,r-o))==gv.Word&&t(_O(i,r-o))==gv.Word)}}(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=function(e,t,n){return function(r,i,o,s){if(n&&!n(r,i,o,s))return!1;var a=r>=s&&i<=s+o.length?o.slice(r-s,i-s):t.doc.sliceString(r,i);return e(a,t,r,i)}}(e.test,t,i)),new gO(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:function(e){return e.toLowerCase()},i)}var BO=function(){function e(t){return N(this,e),O(this,e,[t])}return I(e,PO),R(e,[{key:"nextMatch",value:function(e,t,n){var r=LO(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){var i=Math.min(e.doc.length,t+this.spec.unquoted.length);r=LO(this.spec,e,0,i).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==n?null:r.value}},{key:"prevMatchInRange",value:function(e,t,n){for(var r=n;;){for(var i=Math.max(t,r-1e4-this.spec.unquoted.length),o=LO(this.spec,e,i,r),s=null;!o.nextOverlapping().done;)s=o.value;if(s)return s;if(i==t)return null;r-=1e4}}},{key:"prevMatch",value:function(e,t,n){var r=this.prevMatchInRange(e,0,t);return r||(r=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length)),!r||r.from==t&&r.to==n?null:r}},{key:"getReplacement",value:function(e){return this.spec.unquote(this.spec.replace)}},{key:"matchAll",value:function(e,t){for(var n=LO(this.spec,e,0,e.doc.length),r=[];!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}},{key:"highlight",value:function(e,t,n,r){for(var i=LO(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));!i.next().done;)r(i.value.from,i.value.to)}}])}();function IO(e,t,n,r){var i,o;return e.wholeWord&&(o=t.charCategorizer(t.selection.main.head),i=function(e,t,n){return!n[0].length||(o(_O(n.input,n.index))!=gv.Word||o(FO(n.input,n.index))!=gv.Word)&&(o(FO(n.input,n.index+n[0].length))!=gv.Word||o(_O(n.input,n.index+n[0].length))!=gv.Word)}),e.test&&(i=function(e,t,n){return function(r,i,o){return(!n||n(r,i,o))&&e(o[0],t,r,i)}}(e.test,t,i)),new bO(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function _O(e,t){return e.slice(pg(e,t,!1),t)}function FO(e,t){return e.slice(t,pg(e,t))}var WO=function(){function e(){return N(this,e),O(this,e,arguments)}return I(e,PO),R(e,[{key:"nextMatch",value:function(e,t,n){var r=IO(this.spec,e,n,e.doc.length).next();return r.done&&(r=IO(this.spec,e,0,t).next()),r.done?null:r.value}},{key:"prevMatchInRange",value:function(e,t,n){for(var r=1;;r++){for(var i=Math.max(t,n-1e4*r),o=IO(this.spec,e,i,n),s=null;!o.next().done;)s=o.value;if(s&&(i==t||s.from>i+10))return s;if(i==t)return null}}},{key:"prevMatch",value:function(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}},{key:"getReplacement",value:function(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,function(t,n){if("&"==n)return e.match[0];if("$"==n)return"$";for(var r=n.length;r>0;r--){var i=+n.slice(0,r);if(i>0&&i<e.match.length)return e.match[i]+n.slice(r)}return t})}},{key:"matchAll",value:function(e,t){for(var n=IO(this.spec,e,0,e.doc.length),r=[];!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}},{key:"highlight",value:function(e,t,n,r){for(var i=IO(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));!i.next().done;)r(i.value.from,i.value.to)}}])}(),jO=av.define(),HO=av.define(),zO=Fg.define({create:function(e){return new VO(eN(e).create(),null)},update:function(e,t){var n,r=D(t.effects);try{for(r.s();!(n=r.n()).done;){var i=n.value;i.is(jO)?e=new VO(i.value.create(),e.panel):i.is(HO)&&(e=new VO(e.query,i.value?ZO:null))}}catch(e){r.e(e)}finally{r.f()}return e},provide:function(e){return AS.from(e,function(e){return e.panel})}}),VO=R(function e(t,n){N(this,e),this.query=t,this.panel=n}),qO=by.mark({class:"cm-searchMatch"}),UO=by.mark({class:"cm-searchMatch cm-searchMatch-selected"}),KO=_b.fromClass(function(){return R(function e(t){N(this,e),this.view=t,this.decorations=this.highlight(t.state.field(zO))},[{key:"update",value:function(e){var t=e.state.field(zO);(t!=e.startState.field(zO)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}},{key:"highlight",value:function(e){var t=e.query;if(!e.panel||!t.spec.valid)return by.none;for(var n=this.view,r=new Mv,i=0,o=n.visibleRanges,s=o.length;i<s;i++){for(var a=o[i],l=a.from,c=a.to;i<s-1&&c>o[i+1].from-500;)c=o[++i].to;t.highlight(n.state,l,c,function(e,t){var i=n.state.selection.ranges.some(function(n){return n.from==e&&n.to==t});r.add(e,t,i?UO:qO)})}return r.finish()}}])}(),{decorations:function(e){return e.decorations}});function GO(e){return function(t){var n=t.state.field(zO,!1);return n&&n.query.spec.valid?e(t,n):rN(t)}}var YO=GO(function(e,t){var n=t.query,r=e.state.selection.main.to,i=n.nextMatch(e.state,r,r);if(!i)return!1;var o=Ng.single(i.from,i.to),s=e.state.facet(RO);return e.dispatch({selection:o,effects:[uN(e,i),s.scrollToMatch(o.main,e)],userEvent:"select.search"}),nN(e),!0}),$O=GO(function(e,t){var n=t.query,r=e.state,i=r.selection.main.from,o=n.prevMatch(r,i,i);if(!o)return!1;var s=Ng.single(o.from,o.to),a=e.state.facet(RO);return e.dispatch({selection:s,effects:[uN(e,o),a.scrollToMatch(s.main,e)],userEvent:"select.search"}),nN(e),!0}),XO=GO(function(e,t){var n=t.query.matchAll(e.state,1e3);return!(!n||!n.length)&&(e.dispatch({selection:Ng.create(n.map(function(e){return Ng.range(e.from,e.to)})),userEvent:"select.search.matches"}),!0)}),JO=GO(function(e,t){var n=t.query,r=e.state,i=r.selection.main,o=i.from,s=i.to;if(r.readOnly)return!1;var a=n.nextMatch(r,o,o);if(!a)return!1;var l,c,u=a,h=[],f=[];u.from==o&&u.to==s&&(c=r.toText(n.getReplacement(u)),h.push({from:u.from,to:u.to,insert:c}),u=n.nextMatch(r,u.from,u.to),f.push(lx.announce.of(r.phrase("replaced match on line $",r.doc.lineAt(o).number)+".")));var d=e.state.changes(h);return u&&(l=Ng.single(u.from,u.to).map(d),f.push(uN(e,u)),f.push(r.facet(RO).scrollToMatch(l.main,e))),e.dispatch({changes:d,selection:l,effects:f,userEvent:"input.replace"}),!0}),QO=GO(function(e,t){var n=t.query;if(e.state.readOnly)return!1;var r=n.matchAll(e.state,1e9).map(function(e){return{from:e.from,to:e.to,insert:n.getReplacement(e)}});if(!r.length)return!1;var i=e.state.phrase("replaced $ matches",r.length)+".";return e.dispatch({changes:r,effects:lx.announce.of(i),userEvent:"input.replace.all"}),!0});function ZO(e){return e.state.facet(RO).createPanel(e)}function eN(e,t){var n,r,i,o,s,a=e.selection.main,l=a.empty||a.to>a.from+100?"":e.sliceDoc(a.from,a.to);if(t&&!l)return t;var c=e.facet(RO);return new DO({search:(null!==(n=null==t?void 0:t.literal)&&void 0!==n?n:c.literal)?l:l.replace(/\n/g,"\\n"),caseSensitive:null!==(r=null==t?void 0:t.caseSensitive)&&void 0!==r?r:c.caseSensitive,literal:null!==(i=null==t?void 0:t.literal)&&void 0!==i?i:c.literal,regexp:null!==(o=null==t?void 0:t.regexp)&&void 0!==o?o:c.regexp,wholeWord:null!==(s=null==t?void 0:t.wholeWord)&&void 0!==s?s:c.wholeWord})}function tN(e){var t=xS(e,ZO);return t&&t.dom.querySelector("[main-field]")}function nN(e){var t=tN(e);t&&t==e.root.activeElement&&t.select()}var rN=function(e){var t=e.state.field(zO,!1);if(t&&t.panel){var n=tN(e);if(n&&n!=e.root.activeElement){var r=eN(e.state,t.query.spec);r.valid&&e.dispatch({effects:jO.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[HO.of(!0),t?jO.of(eN(e.state,t.query.spec)):av.appendConfig.of(fN)]});return!0},iN=function(e){var t=e.state.field(zO,!1);if(!t||!t.panel)return!1;var n=xS(e,ZO);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:HO.of(!1)}),!0},oN=[{key:"Mod-f",run:rN,scope:"editor search-panel"},{key:"F3",run:YO,shift:$O,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:YO,shift:$O,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:iN,scope:"editor search-panel"},{key:"Mod-Shift-l",run:function(e){var t=e.state,n=e.dispatch,r=t.selection;if(r.ranges.length>1||r.main.empty)return!1;for(var i=r.main,o=i.from,s=i.to,a=[],l=0,c=new gO(t.doc,t.sliceDoc(o,s));!c.next().done;){if(a.length>1e3)return!1;c.value.from==o&&(l=a.length),a.push(Ng.range(c.value.from,c.value.to))}return n(t.update({selection:Ng.create(a,l),userEvent:"select.search.matches"})),!0}},{key:"Mod-Alt-g",run:function(e){var t=e.state,n=String(t.doc.lineAt(e.state.selection.main.head).number),r=MS(e,{label:t.phrase("Go to line"),input:{type:"text",name:"line",value:n},focus:!0,submitLabel:t.phrase("go")}),i=r.close;return r.result.then(function(n){var r=n&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.elements.line.value);if(r){var o=t.doc.lineAt(t.selection.main.head),s=q(r,5),a=s[1],l=s[2],c=s[3],u=s[4],h=c?+c.slice(1):0,f=l?+l:o.number;if(l&&u){var d=f/100;a&&(d=d*("-"==a?-1:1)+o.number/t.doc.lines),f=Math.round(t.doc.lines*d)}else l&&a&&(f=f*("-"==a?-1:1)+o.number);var p=t.doc.line(Math.max(1,Math.min(t.doc.lines,f))),m=Ng.cursor(p.from+Math.max(0,Math.min(h,p.length)));e.dispatch({effects:[i,lx.scrollIntoView(m.from,{y:"center"})],selection:m})}else e.dispatch({effects:i})}),!0}},{key:"Mod-d",run:function(e){var t=e.state,n=e.dispatch,r=t.selection.ranges;if(r.some(function(e){return e.from===e.to}))return function(e){var t=e.state,n=e.dispatch,r=t.selection,i=Ng.create(r.ranges.map(function(e){return t.wordAt(e.head)||Ng.cursor(e.head)}),r.mainIndex);return!i.eq(r)&&(n(t.update({selection:i})),!0)}({state:t,dispatch:n});var i=t.sliceDoc(r[0].from,r[0].to);if(t.selection.ranges.some(function(e){return t.sliceDoc(e.from,e.to)!=i}))return!1;var o=function(e,t){for(var n,r=e.selection,i=r.main,o=r.ranges,s=e.wordAt(i.head),a=s&&s.from==i.from&&s.to==i.to,l=function(n,r){if(r.next(),!r.done){if(n&&o.some(function(e){return e.from==r.value.from}))return c=n,u=r,0;if(a){var i=e.wordAt(r.value.from);if(!i||i.from!=r.value.from||i.to!=r.value.to)return c=n,u=r,0}return{v:r.value}}if(n)return{v:null};r=new gO(e.doc,t,0,Math.max(0,o[o.length-1].from-1)),c=n=!0,u=r},c=!1,u=new gO(e.doc,t,o[o.length-1].to);;)if(0!==(n=l(c,u))&&n)return n.v}(t,i);return!!o&&(n(t.update({selection:t.selection.addRange(Ng.range(o.from,o.to),!1),effects:lx.scrollIntoView(o.to)})),!0)},preventDefault:!0}],sN=function(){return R(function e(t){var n=this;N(this,e),this.view=t;var r=this.query=t.state.field(zO).query.spec;function i(e,t,n){return Qv("button",{class:"cm-button",name:e,onclick:t,type:"button"},n)}this.commit=this.commit.bind(this),this.searchField=Qv("input",{value:r.search,placeholder:aN(t,"Find"),"aria-label":aN(t,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=Qv("input",{value:r.replace,placeholder:aN(t,"Replace"),"aria-label":aN(t,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=Qv("input",{type:"checkbox",name:"case",form:"",checked:r.caseSensitive,onchange:this.commit}),this.reField=Qv("input",{type:"checkbox",name:"re",form:"",checked:r.regexp,onchange:this.commit}),this.wordField=Qv("input",{type:"checkbox",name:"word",form:"",checked:r.wholeWord,onchange:this.commit}),this.dom=Qv("div",{onkeydown:function(e){return n.keydown(e)},class:"cm-search"},[this.searchField,i("next",function(){return YO(t)},[aN(t,"next")]),i("prev",function(){return $O(t)},[aN(t,"previous")]),i("select",function(){return XO(t)},[aN(t,"all")]),Qv("label",null,[this.caseField,aN(t,"match case")]),Qv("label",null,[this.reField,aN(t,"regexp")]),Qv("label",null,[this.wordField,aN(t,"by word")])].concat(K(t.state.readOnly?[]:[Qv("br"),this.replaceField,i("replace",function(){return JO(t)},[aN(t,"replace")]),i("replaceAll",function(){return QO(t)},[aN(t,"replace all")])]),[Qv("button",{name:"close",onclick:function(){return iN(t)},"aria-label":aN(t,"close"),type:"button"},["×"])]))},[{key:"commit",value:function(){var e=new DO({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:jO.of(e)}))}},{key:"keydown",value:function(e){var t,n,r;t=this.view,n=e,r="search-panel",xx(yx(t.state),n,t,r)?e.preventDefault():13==e.keyCode&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?$O:YO)(this.view)):13==e.keyCode&&e.target==this.replaceField&&(e.preventDefault(),JO(this.view))}},{key:"update",value:function(e){var t,n=D(e.transactions);try{for(n.s();!(t=n.n()).done;){var r,i=D(t.value.effects);try{for(i.s();!(r=i.n()).done;){var o=r.value;o.is(jO)&&!o.value.eq(this.query)&&this.setQuery(o.value)}}catch(e){i.e(e)}finally{i.f()}}}catch(e){n.e(e)}finally{n.f()}}},{key:"setQuery",value:function(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}},{key:"mount",value:function(){this.searchField.select()}},{key:"pos",get:function(){return 80}},{key:"top",get:function(){return this.view.state.facet(RO).top}}])}();function aN(e,t){return e.state.phrase(t)}var lN=30,cN=/[\s\.,:;?!]/;function uN(e,t){var n=t.from,r=t.to,i=e.state.doc.lineAt(n),o=e.state.doc.lineAt(r).to,s=Math.max(i.from,n-lN),a=Math.min(o,r+lN),l=e.state.sliceDoc(s,a);if(s!=i.from)for(var c=0;c<lN;c++)if(!cN.test(l[c+1])&&cN.test(l[c])){l=l.slice(c);break}if(a!=o)for(var u=l.length-1;u>l.length-lN;u--)if(!cN.test(l[u-1])&&cN.test(l[u])){l=l.slice(0,u);break}return lx.announce.of("".concat(e.state.phrase("current match"),". ").concat(l," ").concat(e.state.phrase("on line")," ").concat(i.number,"."))}var hN=lx.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),fN=[zO,qg.low(KO),hN],dN=function(){return R(function e(t,n,r,i){N(this,e),this.state=t,this.pos=n,this.explicit=r,this.view=i,this.abortListeners=[],this.abortOnDocChange=!1},[{key:"tokenBefore",value:function(e){for(var t=fE(this.state).resolveInner(this.pos,-1);t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}},{key:"matchBefore",value:function(e){var t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),r=t.text.slice(n-t.from,this.pos-t.from),i=r.search(yN(e,!1));return i<0?null:{from:n+i,to:this.pos,text:r.slice(i)}}},{key:"aborted",get:function(){return null==this.abortListeners}},{key:"addEventListener",value:function(e,t,n){"abort"==e&&this.abortListeners&&(this.abortListeners.push(t),n&&n.onDocChange&&(this.abortOnDocChange=!0))}}])}();function pN(e){var t=Object.keys(e).join(""),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,"")),"[".concat(n?"\\w":"").concat(t.replace(/[^\w\s]/g,"\\$&"),"]")}function mN(e){var t=e.map(function(e){return"string"==typeof e?{label:e}:e}),n=t.every(function(e){return/^\w+$/.test(e.label)})?[/\w*$/,/\w+$/]:function(e){var t,n=Object.create(null),r=Object.create(null),i=D(e);try{for(i.s();!(t=i.n()).done;){var o=t.value.label;n[o[0]]=!0;for(var s=1;s<o.length;s++)r[o[s]]=!0}}catch(e){i.e(e)}finally{i.f()}var a=pN(n)+pN(r)+"*$";return[new RegExp("^"+a),new RegExp(a)]}(t),r=q(n,2),i=r[0],o=r[1];return function(e){var n=e.matchBefore(o);return n||e.explicit?{from:n?n.from:e.pos,options:t,validFor:i}:null}}var gN=R(function e(t,n,r,i){N(this,e),this.completion=t,this.source=n,this.match=r,this.score=i});function vN(e){return e.selection.main.from}function yN(e,t){var n,r=e.source,i=t&&"^"!=r[0],o="$"!=r[r.length-1];return i||o?new RegExp("".concat(i?"^":"","(?:").concat(r,")").concat(o?"$":""),null!==(n=e.flags)&&void 0!==n?n:e.ignoreCase?"i":""):e}var bN=iv.define();var wN=new WeakMap;function kN(e){if(!Array.isArray(e))return e;var t=wN.get(e);return t||wN.set(e,t=mN(e)),t}var xN=av.define(),SN=av.define(),CN=function(){return R(function e(t){N(this,e),this.pattern=t,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(var n=0;n<t.length;){var r=mg(t,n),i=vg(r);this.chars.push(r);var o=t.slice(n,n+i),s=o.toUpperCase();this.folded.push(mg(s==o?o.toLowerCase():s,0)),n+=i}this.astral=t.length!=this.chars.length},[{key:"ret",value:function(e,t){return this.score=e,this.matched=t,this}},{key:"match",value:function(e){if(0==this.pattern.length)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;var t=this.chars,n=this.folded,r=this.any,i=this.precise,o=this.byWord;if(1==t.length){var s=mg(e,0),a=vg(s),l=a==e.length?0:-100;if(s==t[0]);else{if(s!=n[0])return null;l+=-200}return this.ret(l,[0,a])}var c=e.indexOf(this.pattern);if(0==c)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);var u=t.length,h=0;if(c<0){for(var f=0,d=Math.min(e.length,200);f<d&&h<u;){var p=mg(e,f);p!=t[h]&&p!=n[h]||(r[h++]=f),f+=vg(p)}if(h<u)return null}for(var m=0,g=0,v=!1,y=0,b=-1,w=-1,k=/[a-z]/.test(e),x=!0,S=0,C=Math.min(e.length,200),E=0;S<C&&g<u;){var A=mg(e,S);c<0&&(m<u&&A==t[m]&&(i[m++]=S),y<u&&(A==t[y]||A==n[y]?(0==y&&(b=S),w=S+1,y++):y=0));var M=void 0,O=A<255?A>=48&&A<=57||A>=97&&A<=122?2:A>=65&&A<=90?1:0:(M=gg(A))!=M.toLowerCase()?1:M!=M.toUpperCase()?2:0;(!S||1==O&&k||0==E&&0!=O)&&(t[g]==A||n[g]==A&&(v=!0)?o[g++]=S:o.length&&(x=!1)),E=O,S+=vg(A)}return g==u&&0==o[0]&&x?this.result((v?-200:0)-100,o,e):y==u&&0==b?this.ret(-200-e.length+(w==e.length?0:-100),[0,w]):c>-1?this.ret(-700-e.length,[c,c+this.pattern.length]):y==u?this.ret(-900-e.length,[b,w]):g==u?this.result((v?-200:0)-100-700+(x?0:-1100),o,e):2==t.length?null:this.result((r[0]?-700:0)-200-1100,r,e)}},{key:"result",value:function(e,t,n){var r,i=[],o=0,s=D(t);try{for(s.s();!(r=s.n()).done;){var a=r.value,l=a+(this.astral?vg(mg(n,a)):1);o&&i[o-1]==a?i[o-1]=l:(i[o++]=a,i[o++]=l)}}catch(e){s.e(e)}finally{s.f()}return this.ret(e-n.length,i)}}])}(),EN=function(){return R(function e(t){N(this,e),this.pattern=t,this.matched=[],this.score=0,this.folded=t.toLowerCase()},[{key:"match",value:function(e){if(e.length<this.pattern.length)return null;var t=e.slice(0,this.pattern.length),n=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return null==n?null:(this.matched=[0,t.length],this.score=n+(e.length==this.pattern.length?0:-100),this)}}])}(),AN=Dg.define({combine:function(e){return wv(e,{activateOnTyping:!0,activateOnCompletion:function(){return!1},activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:function(){return""},optionClass:function(){return""},aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:ON,filterStrict:!1,compareCompletions:function(e,t){return(e.sortText||e.label).localeCompare(t.sortText||t.label)},interactionDelay:75,updateSyncTime:100},{defaultKeymap:function(e,t){return e&&t},closeOnBlur:function(e,t){return e&&t},icons:function(e,t){return e&&t},tooltipClass:function(e,t){return function(n){return MN(e(n),t(n))}},optionClass:function(e,t){return function(n){return MN(e(n),t(n))}},addToOptions:function(e,t){return e.concat(t)},filterStrict:function(e,t){return e||t}})}});function MN(e,t){return e?t?e+" "+t:e:t}function ON(e,t,n,r,i,o){var s,a,l=e.textDirection==Yy.RTL,c=l,u=!1,h="top",f=t.left-i.left,d=i.right-t.right,p=r.right-r.left,m=r.bottom-r.top;if(c&&f<Math.min(p,d)?c=!1:!c&&d<Math.min(p,f)&&(c=!0),p<=(c?f:d))s=Math.max(i.top,Math.min(n.top,i.bottom-m))-t.top,a=Math.min(400,c?f:d);else{u=!0,a=Math.min(400,(l?t.right:i.right-t.left)-30);var g=i.bottom-t.bottom;g>=m||g>t.top?s=n.bottom-t.top:(h="bottom",s=t.bottom-n.top)}var v=(t.bottom-t.top)/o.offsetHeight,y=(t.right-t.left)/o.offsetWidth;return{style:"".concat(h,": ").concat(s/v,"px; max-width: ").concat(a/y,"px"),class:"cm-completionInfo-"+(u?l?"left-narrow":"right-narrow":c?"left":"right")}}function NN(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){var r=Math.floor(t/n);return{from:r*n,to:(r+1)*n}}var i=Math.floor((e-t)/n);return{from:e-(i+1)*n,to:e-i*n}}var TN=function(){return R(function e(t,n,r){var i=this;N(this,e),this.view=t,this.stateField=n,this.applyCompletion=r,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:function(){return i.measureInfo()},write:function(e){return i.placeInfo(e)},key:this},this.space=null,this.currentClass="";var o=t.state.field(n),s=o.open,a=s.options,l=s.selected,c=t.state.facet(AN);this.optionContent=function(e){var t=e.addToOptions.slice();return e.icons&&t.push({render:function(e){var t,n=document.createElement("div");return n.classList.add("cm-completionIcon"),e.type&&(t=n.classList).add.apply(t,K(e.type.split(/\s+/g).map(function(e){return"cm-completionIcon-"+e}))),n.setAttribute("aria-hidden","true"),n},position:20}),t.push({render:function(e,t,n,r){var i=document.createElement("span");i.className="cm-completionLabel";for(var o=e.displayLabel||e.label,s=0,a=0;a<r.length;){var l=r[a++],c=r[a++];l>s&&i.appendChild(document.createTextNode(o.slice(s,l)));var u=i.appendChild(document.createElement("span"));u.appendChild(document.createTextNode(o.slice(l,c))),u.className="cm-completionMatchedText",s=c}return s<o.length&&i.appendChild(document.createTextNode(o.slice(s))),i},position:50},{render:function(e){if(!e.detail)return null;var t=document.createElement("span");return t.className="cm-completionDetail",t.textContent=e.detail,t},position:80}),t.sort(function(e,t){return e.position-t.position}).map(function(e){return e.render})}(c),this.optionClass=c.optionClass,this.tooltipClass=c.tooltipClass,this.range=NN(a.length,l,c.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(t.state),this.dom.addEventListener("mousedown",function(e){for(var r,o=t.state.field(n).open.options,s=e.target;s&&s!=i.dom;s=s.parentNode)if("LI"==s.nodeName&&(r=/-(\d+)$/.exec(s.id))&&+r[1]<o.length)return i.applyCompletion(t,o[+r[1]]),void e.preventDefault()}),this.dom.addEventListener("focusout",function(e){var n=t.state.field(i.stateField,!1);n&&n.tooltip&&t.state.facet(AN).closeOnBlur&&e.relatedTarget!=t.contentDOM&&t.dispatch({effects:SN.of(null)})}),this.showOptions(a,o.id)},[{key:"mount",value:function(){this.updateSel()}},{key:"showOptions",value:function(e,t){var n=this;this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener("scroll",function(){n.info&&n.view.requestMeasure(n.placeInfoReq)})}},{key:"update",value:function(e){var t,n=e.state.field(this.stateField),r=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),n!=r){var i=n.open,o=i.options,s=i.selected,a=i.disabled;r.open&&r.open.options==o||(this.range=NN(o.length,s,e.state.facet(AN).maxRenderedOptions),this.showOptions(o,n.id)),this.updateSel(),a!=(null===(t=r.open)||void 0===t?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!a)}}},{key:"updateTooltipClass",value:function(e){var t=this.tooltipClass(e);if(t!=this.currentClass){var n,r=D(this.currentClass.split(" "));try{for(r.s();!(n=r.n()).done;){var i=n.value;i&&this.dom.classList.remove(i)}}catch(e){r.e(e)}finally{r.f()}var o,s=D(t.split(" "));try{for(s.s();!(o=s.n()).done;){var a=o.value;a&&this.dom.classList.add(a)}}catch(e){s.e(e)}finally{s.f()}this.currentClass=t}}},{key:"positioned",value:function(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}},{key:"updateSel",value:function(){var e=this,t=this.view.state.field(this.stateField),n=t.open;(n.selected>-1&&n.selected<this.range.from||n.selected>=this.range.to)&&(this.range=NN(n.options.length,n.selected,this.view.state.facet(AN).maxRenderedOptions),this.showOptions(n.options,t.id));var r=this.updateSelectedOption(n.selected);if(r){this.destroyInfo();var i=n.options[n.selected].completion,o=i.info;if(!o)return;var s="string"==typeof o?document.createTextNode(o):o(i);if(!s)return;"then"in s?s.then(function(n){n&&e.view.state.field(e.stateField,!1)==t&&e.addInfoPane(n,i)}).catch(function(t){return Pb(e.view.state,t,"completion info")}):(this.addInfoPane(s,i),r.setAttribute("aria-describedby",this.info.id))}}},{key:"addInfoPane",value:function(e,t){this.destroyInfo();var n=this.info=document.createElement("div");if(n.className="cm-tooltip cm-completionInfo",n.id="cm-completionInfo-"+Math.floor(65535*Math.random()).toString(16),null!=e.nodeType)n.appendChild(e),this.infoDestroy=null;else{var r=e.dom,i=e.destroy;n.appendChild(r),this.infoDestroy=i||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}},{key:"updateSelectedOption",value:function(e){for(var t=null,n=this.list.firstChild,r=this.range.from;n;n=n.nextSibling,r++)"LI"==n.nodeName&&n.id?r==e?n.hasAttribute("aria-selected")||(n.setAttribute("aria-selected","true"),t=n):n.hasAttribute("aria-selected")&&(n.removeAttribute("aria-selected"),n.removeAttribute("aria-describedby")):r--;return t&&function(e,t){var n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=n.height/e.offsetHeight;r.top<n.top?e.scrollTop-=(n.top-r.top)/i:r.bottom>n.bottom&&(e.scrollTop+=(r.bottom-n.bottom)/i)}(this.list,t),t}},{key:"measureInfo",value:function(){var e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;var t=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),r=e.getBoundingClientRect(),i=this.space;if(!i){var o=this.dom.ownerDocument.documentElement;i={left:0,top:0,right:o.clientWidth,bottom:o.clientHeight}}return r.top>Math.min(i.bottom,t.bottom)-10||r.bottom<Math.max(i.top,t.top)+10?null:this.view.state.facet(AN).positionInfo(this.view,t,r,n,i,this.dom)}},{key:"placeInfo",value:function(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}},{key:"createListBox",value:function(e,t,n){var r=document.createElement("ul");r.id=t,r.setAttribute("role","listbox"),r.setAttribute("aria-expanded","true"),r.setAttribute("aria-label",this.view.state.phrase("Completions")),r.addEventListener("mousedown",function(e){e.target==r&&e.preventDefault()});for(var i=null,o=n.from;o<n.to;o++){var s=e[o],a=s.completion,l=s.match,c=a.section;if(c){var u="string"==typeof c?c:c.name;if(u!=i&&(o>n.from||0==n.from))if(i=u,"string"!=typeof c&&c.header)r.appendChild(c.header(c));else r.appendChild(document.createElement("completion-section")).textContent=u}var h=r.appendChild(document.createElement("li"));h.id=t+"-"+o,h.setAttribute("role","option");var f=this.optionClass(a);f&&(h.className=f);var d,p=D(this.optionContent);try{for(p.s();!(d=p.n()).done;){var m=(0,d.value)(a,this.view.state,this.view,l);m&&h.appendChild(m)}}catch(e){p.e(e)}finally{p.f()}}return n.from&&r.classList.add("cm-completionListIncompleteTop"),n.to<e.length&&r.classList.add("cm-completionListIncompleteBottom"),r}},{key:"destroyInfo",value:function(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}},{key:"destroy",value:function(){this.destroyInfo()}}])}();function RN(e,t){return function(n){return new TN(n,e,t)}}function DN(e){return 100*(e.boost||0)+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}var PN=function(){function e(t,n,r,i,o,s){N(this,e),this.options=t,this.attrs=n,this.tooltip=r,this.timestamp=i,this.selected=o,this.disabled=s}return R(e,[{key:"setSelected",value:function(t,n){return t==this.selected||t>=this.options.length?this:new e(this.options,_N(n,t),this.tooltip,this.timestamp,t,this.disabled)}},{key:"map",value:function(t){return new e(this.options,this.attrs,W(W({},this.tooltip),{},{pos:t.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}},{key:"setDisabled",value:function(){return new e(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}],[{key:"build",value:function(t,n,r,i,o,s){if(i&&!s&&t.some(function(e){return e.isPending}))return i.setDisabled();var a=function(e,t){var n,r=[],i=null,o=null,s=function(e){r.push(e);var t=e.completion.section;if(t){i||(i=[]);var n="string"==typeof t?t:t.name;i.some(function(e){return e.name==n})||i.push("string"==typeof t?{name:n}:t)}},a=t.facet(AN),l=D(e);try{for(l.s();!(n=l.n()).done;){var c=n.value;if(c.hasResult()){var u=c.result.getMatch;if(!1===c.result.filter){var h,f=D(c.result.options);try{for(f.s();!(h=f.n()).done;){var d=h.value;s(new gN(d,c.source,u?u(d):[],1e9-r.length))}}catch(e){f.e(e)}finally{f.f()}}else{var p,m=t.sliceDoc(c.from,c.to),g=void 0,v=a.filterStrict?new EN(m):new CN(m),y=D(c.result.options);try{for(y.s();!(p=y.n()).done;){var b=p.value;if(g=v.match(b.label)){var w=b.displayLabel?u?u(b,g.matched):[]:g.matched,k=g.score+(b.boost||0);if(s(new gN(b,c.source,w,k)),"object"==Y(b.section)&&"dynamic"===b.section.rank){var x=b.section.name;o||(o=Object.create(null)),o[x]=Math.max(k,o[x]||-1e9)}}}}catch(e){y.e(e)}finally{y.f()}}}}}catch(e){l.e(e)}finally{l.f()}if(i){var S,C=Object.create(null),E=0,A=D(i.sort(function(e,t){return("dynamic"===e.rank&&"dynamic"===t.rank?o[t.name]-o[e.name]:0)||("number"==typeof e.rank?e.rank:1e9)-("number"==typeof t.rank?t.rank:1e9)||(e.name<t.name?-1:1)}));try{for(A.s();!(S=A.n()).done;){var M=S.value;E-=1e5,C[M.name]=E}}catch(e){A.e(e)}finally{A.f()}var O,N=D(r);try{for(N.s();!(O=N.n()).done;){var T=O.value,R=T.completion.section;R&&(T.score+=C["string"==typeof R?R:R.name])}}catch(e){N.e(e)}finally{N.f()}}var P,L=[],B=null,I=a.compareCompletions,_=D(r.sort(function(e,t){return t.score-e.score||I(e.completion,t.completion)}));try{for(_.s();!(P=_.n()).done;){var F=P.value,W=F.completion;!B||B.label!=W.label||B.detail!=W.detail||null!=B.type&&null!=W.type&&B.type!=W.type||B.apply!=W.apply||B.boost!=W.boost?L.push(F):DN(F.completion)>DN(B)&&(L[L.length-1]=F),B=F.completion}}catch(e){_.e(e)}finally{_.f()}return L}(t,n);if(!a.length)return i&&t.some(function(e){return e.isPending})?i.setDisabled():null;var l=n.facet(AN).selectOnOpen?0:-1;if(i&&i.selected!=l&&-1!=i.selected)for(var c=i.options[i.selected].completion,u=0;u<a.length;u++)if(a[u].completion==c){l=u;break}return new e(a,_N(r,l),{pos:t.reduce(function(e,t){return t.hasResult()?Math.min(e,t.from):e},1e8),create:KN,above:o.aboveCursor},i?i.timestamp:Date.now(),l,!1)}}])}(),LN=function(){function e(t,n,r){N(this,e),this.active=t,this.id=n,this.open=r}return R(e,[{key:"update",value:function(t){var n=this,r=t.state,i=r.facet(AN),o=(i.override||r.languageDataAt("autocomplete",vN(r)).map(kN)).map(function(e){return(n.active.find(function(t){return t.source==e})||new jN(e,n.active.some(function(e){return 0!=e.state})?1:0)).update(t,i)});o.length==this.active.length&&o.every(function(e,t){return e==n.active[t]})&&(o=this.active);var s=this.open,a=t.effects.some(function(e){return e.is(zN)});s&&t.docChanged&&(s=s.map(t.changes)),t.selection||o.some(function(e){return e.hasResult()&&t.changes.touchesRange(e.from,e.to)})||!function(e,t){if(e==t)return!0;for(var n=0,r=0;;){for(;n<e.length&&!e[n].hasResult();)n++;for(;r<t.length&&!t[r].hasResult();)r++;var i=n==e.length,o=r==t.length;if(i||o)return i==o;if(e[n++].result!=t[r++].result)return!1}}(o,this.active)||a?s=PN.build(o,r,this.id,s,i,a):s&&s.disabled&&!o.some(function(e){return e.isPending})&&(s=null),!s&&o.every(function(e){return!e.isPending})&&o.some(function(e){return e.hasResult()})&&(o=o.map(function(e){return e.hasResult()?new jN(e.source,0):e}));var l,c=D(t.effects);try{for(c.s();!(l=c.n()).done;){var u=l.value;u.is(VN)&&(s=s&&s.setSelected(u.value,this.id))}}catch(e){c.e(e)}finally{c.f()}return o==this.active&&s==this.open?this:new e(o,this.id,s)}},{key:"tooltip",get:function(){return this.open?this.open.tooltip:null}},{key:"attrs",get:function(){return this.open?this.open.attrs:this.active.length?BN:IN}}],[{key:"start",value:function(){return new e(FN,"cm-ac-"+Math.floor(2e6*Math.random()).toString(36),null)}}])}();var BN={"aria-autocomplete":"list"},IN={};function _N(e,t){var n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(n["aria-activedescendant"]=e+"-"+t),n}var FN=[];function WN(e,t){if(e.isUserEvent("input.complete")){var n=e.annotation(bN);if(n&&t.activateOnCompletion(n))return 12}var r=e.isUserEvent("input.type");return r&&t.activateOnTyping?5:r?1:e.isUserEvent("delete.backward")?2:e.selection?8:e.docChanged?16:0}var jN=function(){function e(t,n){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];N(this,e),this.source=t,this.state=n,this.explicit=r}return R(e,[{key:"hasResult",value:function(){return!1}},{key:"isPending",get:function(){return 1==this.state}},{key:"update",value:function(t,n){var r=WN(t,n),i=this;(8&r||16&r&&this.touches(t))&&(i=new e(i.source,0)),4&r&&0==i.state&&(i=new e(this.source,1)),i=i.updateFor(t,r);var o,s=D(t.effects);try{for(s.s();!(o=s.n()).done;){var a=o.value;if(a.is(xN))i=new e(i.source,1,a.value);else if(a.is(SN))i=new e(i.source,0);else if(a.is(zN)){var l,c=D(a.value);try{for(c.s();!(l=c.n()).done;){var u=l.value;u.source==i.source&&(i=u)}}catch(e){c.e(e)}finally{c.f()}}}}catch(e){s.e(e)}finally{s.f()}return i}},{key:"updateFor",value:function(e,t){return this.map(e.changes)}},{key:"map",value:function(e){return this}},{key:"touches",value:function(e){return e.changes.touchesRange(vN(e.state))}}])}(),HN=function(){function e(t,n,r,i,o,s){var a;return N(this,e),(a=O(this,e,[t,3,n])).limit=r,a.result=i,a.from=o,a.to=s,a}return I(e,jN),R(e,[{key:"hasResult",value:function(){return!0}},{key:"updateFor",value:function(t,n){var r;if(!(3&n))return this.map(t.changes);var i=this.result;i.map&&!t.changes.empty&&(i=i.map(i,t.changes));var o=t.changes.mapPos(this.from),s=t.changes.mapPos(this.to,1),a=vN(t.state);if(a>s||!i||2&n&&(vN(t.startState)==this.from||a<this.limit))return new jN(this.source,4&n?1:0);var l=t.changes.mapPos(this.limit);return function(e,t,n,r){if(!e)return!1;var i=t.sliceDoc(n,r);return"function"==typeof e?e(i,n,r,t):yN(e,!0).test(i)}(i.validFor,t.state,o,s)?new e(this.source,this.explicit,l,i,o,s):i.update&&(i=i.update(i,o,s,new dN(t.state,a,!1)))?new e(this.source,this.explicit,l,i,i.from,null!==(r=i.to)&&void 0!==r?r:vN(t.state)):new jN(this.source,1,this.explicit)}},{key:"map",value:function(t){return t.empty?this:(this.result.map?this.result.map(this.result,t):this.result)?new e(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new jN(this.source,0)}},{key:"touches",value:function(e){return e.changes.touchesRange(this.from,this.to)}}])}();var zN=av.define({map:function(e,t){return e.map(function(e){return e.map(t)})}}),VN=av.define(),qN=Fg.define({create:function(){return LN.start()},update:function(e,t){return e.update(t)},provide:function(e){return[fS.from(e,function(e){return e.tooltip}),lx.contentAttributes.from(e,function(e){return e.attrs})]}});function UN(e,t){var n=t.completion.apply||t.completion.label,r=e.state.field(qN).active.find(function(e){return e.source==t.source});return r instanceof HN&&("string"==typeof n?e.dispatch(W(W({},function(e,t,n,r){var i=e.selection.main,o=n-i.from,s=r-i.from;return W(W({},e.changeByRange(function(a){if(a!=i&&n!=r&&e.sliceDoc(a.from+o,a.from+s)!=e.sliceDoc(n,r))return{range:a};var l=e.toText(t);return{changes:{from:a.from+o,to:r==i.from?a.to:a.from+s,insert:l},range:Ng.cursor(a.from+o+l.length)}})),{},{scrollIntoView:!0,userEvent:"input.complete"})}(e.state,n,r.from,r.to)),{},{annotations:bN.of(t.completion)})):n(e,t.completion,r.from,r.to),!0)}var KN=RN(qN,UN);function GN(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"option";return function(n){var r=n.state.field(qN,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(AN).interactionDelay)return!1;var i,o=1;"page"==t&&(i=bS(n,r.open.tooltip))&&(o=Math.max(2,Math.floor(i.dom.offsetHeight/i.dom.querySelector("li").offsetHeight)-1));var s=r.open.options.length,a=r.open.selected>-1?r.open.selected+o*(e?1:-1):e?0:s-1;return a<0?a="page"==t?0:s-1:a>=s&&(a="page"==t?s-1:0),n.dispatch({effects:VN.of(a)}),!0}}var YN=function(e){return!!e.state.field(qN,!1)&&(e.dispatch({effects:xN.of(!0)}),!0)},$N=R(function e(t,n){N(this,e),this.active=t,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}),XN=_b.fromClass(function(){return R(function e(t){N(this,e),this.view=t,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;var n,r=D(t.state.field(qN).active);try{for(r.s();!(n=r.n()).done;){var i=n.value;i.isPending&&this.startQuery(i)}}catch(e){r.e(e)}finally{r.f()}},[{key:"update",value:function(e){var t=this,n=e.state.field(qN),r=e.state.facet(AN);if(e.selectionSet||e.docChanged||e.startState.field(qN)!=n){for(var i=e.transactions.some(function(e){var t=WN(e,r);return 8&t||(e.selection||e.docChanged)&&!(3&t)}),o=0;o<this.running.length;o++){var s=this.running[o];if(i||s.context.abortOnDocChange&&e.docChanged||s.updates.length+e.transactions.length>50&&Date.now()-s.time>1e3){var a,l=D(s.context.abortListeners);try{for(l.s();!(a=l.n()).done;){var c=a.value;try{c()}catch(e){Pb(this.view.state,e)}}}catch(e){l.e(e)}finally{l.f()}s.context.abortListeners=null,this.running.splice(o--,1)}else{var u;(u=s.updates).push.apply(u,K(e.transactions))}}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(function(e){return e.effects.some(function(e){return e.is(xN)})})&&(this.pendingStart=!0);var h=this.pendingStart?50:r.activateOnTypingDelay;if(this.debounceUpdate=n.active.some(function(e){return e.isPending&&!t.running.some(function(t){return t.active.source==e.source})})?setTimeout(function(){return t.startUpdate()},h):-1,0!=this.composing){var f,d=D(e.transactions);try{for(d.s();!(f=d.n()).done;){var p=f.value;p.isUserEvent("input.type")?this.composing=2:2==this.composing&&p.selection&&(this.composing=3)}}catch(e){d.e(e)}finally{d.f()}}}}},{key:"startUpdate",value:function(){var e=this;this.debounceUpdate=-1,this.pendingStart=!1;var t,n=this.view.state.field(qN),r=D(n.active);try{var i=function(){var n=t.value;n.isPending&&!e.running.some(function(e){return e.active.source==n.source})&&e.startQuery(n)};for(r.s();!(t=r.n()).done;)i()}catch(e){r.e(e)}finally{r.f()}this.running.length&&n.open&&n.open.disabled&&(this.debounceAccept=setTimeout(function(){return e.accept()},this.view.state.facet(AN).updateSyncTime))}},{key:"startQuery",value:function(e){var t=this,n=this.view.state,r=vN(n),i=new dN(n,r,e.explicit,this.view),o=new $N(e,i);this.running.push(o),Promise.resolve(e.source(i)).then(function(e){o.context.aborted||(o.done=e||null,t.scheduleAccept())},function(e){t.view.dispatch({effects:SN.of(null)}),Pb(t.view.state,e)})}},{key:"scheduleAccept",value:function(){var e=this;this.running.every(function(e){return void 0!==e.done})?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(function(){return e.accept()},this.view.state.facet(AN).updateSyncTime))}},{key:"accept",value:function(){var e,t=this;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;for(var n=[],r=this.view.state.facet(AN),i=this.view.state.field(qN),o=function(o){var a=t.running[o];if(void 0===a.done)return s=o,0;if(t.running.splice(o--,1),a.done){var l,c=vN(a.updates.length?a.updates[0].startState:t.view.state),u=Math.min(c,a.done.from+(a.active.explicit?0:1)),h=new HN(a.active.source,a.active.explicit,u,a.done,a.done.from,null!==(e=a.done.to)&&void 0!==e?e:c),f=D(a.updates);try{for(f.s();!(l=f.n()).done;){var d=l.value;h=h.update(d,r)}}catch(e){f.e(e)}finally{f.f()}if(h.hasResult())return n.push(h),s=o,0}var p=i.active.find(function(e){return e.source==a.active.source});if(p&&p.isPending)if(null==a.done){var m,g=new jN(a.active.source,0),v=D(a.updates);try{for(v.s();!(m=v.n()).done;){var y=m.value;g=g.update(y,r)}}catch(e){v.e(e)}finally{v.f()}g.isPending||n.push(g)}else t.startQuery(p);s=o},s=0;s<this.running.length;s++)o(s);(n.length||i.open&&i.open.disabled)&&this.view.dispatch({effects:zN.of(n)})}}])}(),{eventHandlers:{blur:function(e){var t=this,n=this.view.state.field(qN,!1);if(n&&n.tooltip&&this.view.state.facet(AN).closeOnBlur){var r=n.open&&bS(this.view,n.open.tooltip);r&&r.dom.contains(e.relatedTarget)||setTimeout(function(){return t.view.dispatch({effects:SN.of(null)})},10)}},compositionstart:function(){this.composing=1},compositionend:function(){var e=this;3==this.composing&&setTimeout(function(){return e.view.dispatch({effects:xN.of(!1)})},20),this.composing=0}}}),JN="object"==("undefined"==typeof navigator?"undefined":Y(navigator))&&/Win/.test(navigator.platform),QN=qg.highest(lx.domEventHandlers({keydown:function(e,t){var n=t.state.field(qN,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&(!JN||!e.altKey)||e.metaKey)return!1;var r=n.open.options[n.open.selected],i=n.active.find(function(e){return e.source==r.source}),o=r.completion.commitCharacters||i.result.commitCharacters;return o&&o.indexOf(e.key)>-1&&UN(t,r),!1}})),ZN=lx.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"".concat(400,"px"),boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"".concat(30,"px")},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"".concat(30,"px")},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}}),eT={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},tT=av.define({map:function(e,t){var n=t.mapPos(e,-1,bg.TrackAfter);return null==n?void 0:n}}),nT=new(function(){function e(){return N(this,e),O(this,e,arguments)}return I(e,kv),R(e)}());nT.startSide=1,nT.endSide=-1;var rT=Fg.define({create:function(){return Av.empty},update:function(e,t){if(e=e.map(t.changes),t.selection){var n=t.state.doc.lineAt(t.selection.main.head);e=e.update({filter:function(e){return e>=n.from&&e<=n.to}})}var r,i=D(t.effects);try{for(i.s();!(r=i.n()).done;){var o=r.value;o.is(tT)&&(e=e.update({add:[nT.range(o.value,o.value+1)]}))}}catch(e){i.e(e)}finally{i.f()}return e}});var iT="()[]{}<>«»»«[]{}";function oT(e){for(var t=0;t<16;t+=2)if(iT.charCodeAt(t)==e)return iT.charAt(t+1);return gg(e<128?e:e+1)}function sT(e,t){return e.languageDataAt("closeBrackets",t)[0]||eT}var aT="object"==("undefined"==typeof navigator?"undefined":Y(navigator))&&/Android\b/.test(navigator.userAgent),lT=lx.inputHandler.of(function(e,t,n,r){if((aT?e.composing:e.compositionStarted)||e.state.readOnly)return!1;var i=e.state.selection.main;if(r.length>2||2==r.length&&1==vg(mg(r,0))||t!=i.from||n!=i.to)return!1;var o=function(e,t){var n,r=sT(e,e.selection.main.head),i=r.brackets||eT.brackets,o=D(i);try{for(o.s();!(n=o.n()).done;){var s=n.value,a=oT(mg(s,0));if(t==s)return a==s?pT(e,s,i.indexOf(s+s+s)>-1,r):fT(e,s,a,r.before||eT.before);if(t==a&&uT(e,e.selection.main.from))return dT(e,s,a)}}catch(e){o.e(e)}finally{o.f()}return null}(e.state,r);return!!o&&(e.dispatch(o),!0)}),cT=[{key:"Backspace",run:function(e){var t=e.state,n=e.dispatch;if(t.readOnly)return!1;var r=sT(t,t.selection.main.head).brackets||eT.brackets,i=null,o=t.changeByRange(function(e){if(e.empty){var n,o=function(e,t){var n=e.sliceString(t-2,t);return vg(mg(n,0))==n.length?n:n.slice(1)}(t.doc,e.head),s=D(r);try{for(s.s();!(n=s.n()).done;){var a=n.value;if(a==o&&hT(t.doc,e.head)==oT(mg(a,0)))return{changes:{from:e.head-a.length,to:e.head+a.length},range:Ng.cursor(e.head-a.length)}}}catch(e){s.e(e)}finally{s.f()}}return{range:i=e}});return i||n(t.update(o,{scrollIntoView:!0,userEvent:"delete.backward"})),!i}}];function uT(e,t){var n=!1;return e.field(rT).between(0,e.doc.length,function(e){e==t&&(n=!0)}),n}function hT(e,t){var n=e.sliceString(t,t+2);return n.slice(0,vg(mg(n,0)))}function fT(e,t,n,r){var i=null,o=e.changeByRange(function(o){if(!o.empty)return{changes:[{insert:t,from:o.from},{insert:n,from:o.to}],effects:tT.of(o.to+t.length),range:Ng.range(o.anchor+t.length,o.head+t.length)};var s=hT(e.doc,o.head);return!s||/\s/.test(s)||r.indexOf(s)>-1?{changes:{insert:t+n,from:o.head},effects:tT.of(o.head+t.length),range:Ng.cursor(o.head+t.length)}:{range:i=o}});return i?null:e.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function dT(e,t,n){var r=null,i=e.changeByRange(function(t){return t.empty&&hT(e.doc,t.head)==n?{changes:{from:t.head,to:t.head+n.length,insert:n},range:Ng.cursor(t.head+n.length)}:r={range:t}});return r?null:e.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function pT(e,t,n,r){var i=r.stringPrefixes||eT.stringPrefixes,o=null,s=e.changeByRange(function(r){if(!r.empty)return{changes:[{insert:t,from:r.from},{insert:t,from:r.to}],effects:tT.of(r.to+t.length),range:Ng.range(r.anchor+t.length,r.head+t.length)};var s,a=r.head,l=hT(e.doc,a);if(l==t){if(mT(e,a))return{changes:{insert:t+t,from:a},effects:tT.of(a+t.length),range:Ng.cursor(a+t.length)};if(uT(e,a)){var c=n&&e.sliceDoc(a,a+3*t.length)==t+t+t?t+t+t:t;return{changes:{from:a,to:a+c.length,insert:c},range:Ng.cursor(a+c.length)}}}else{if(n&&e.sliceDoc(a-2*t.length,a)==t+t&&(s=gT(e,a-2*t.length,i))>-1&&mT(e,s))return{changes:{insert:t+t+t+t,from:a},effects:tT.of(a+t.length),range:Ng.cursor(a+t.length)};if(e.charCategorizer(a)(l)!=gv.Word&&gT(e,a,i)>-1&&!function(e,t,n,r){for(var i=fE(e).resolveInner(t,-1),o=r.reduce(function(e,t){return Math.max(e,t.length)},0),s=0;s<5;s++){var a=e.sliceDoc(i.from,Math.min(i.to,i.from+n.length+o)),l=a.indexOf(n);if(!l||l>-1&&r.indexOf(a.slice(0,l))>-1){for(var c=i.firstChild;c&&c.from==i.from&&c.to-c.from>n.length+l;){if(e.sliceDoc(c.to-n.length,c.to)==n)return!1;c=c.firstChild}return!0}var u=i.to==t&&i.parent;if(!u)break;i=u}return!1}(e,a,t,i))return{changes:{insert:t+t,from:a},effects:tT.of(a+t.length),range:Ng.cursor(a+t.length)}}return{range:o=r}});return o?null:e.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function mT(e,t){var n=fE(e).resolveInner(t+1);return n.parent&&n.from==t}function gT(e,t,n){var r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=gv.Word)return t;var i,o=D(n);try{for(o.s();!(i=o.n()).done;){var s=i.value,a=t-s.length;if(e.sliceDoc(a,t)==s&&r(e.sliceDoc(a-1,a))!=gv.Word)return a}}catch(e){o.e(e)}finally{o.f()}return-1}var vT=[{key:"Ctrl-Space",run:YN},{mac:"Alt-`",run:YN},{mac:"Alt-i",run:YN},{key:"Escape",run:function(e){var t=e.state.field(qN,!1);return!(!t||!t.active.some(function(e){return 0!=e.state}))&&(e.dispatch({effects:SN.of(null)}),!0)}},{key:"ArrowDown",run:GN(!0)},{key:"ArrowUp",run:GN(!1)},{key:"PageDown",run:GN(!0,"page")},{key:"PageUp",run:GN(!1,"page")},{key:"Enter",run:function(e){var t=e.state.field(qN,!1);return!(e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(AN).interactionDelay)&&UN(e,t.open.options[t.open.selected])}}],yT=qg.highest(gx.computeN([AN],function(e){return e.facet(AN).defaultKeymap?[vT]:[]})),bT=R(function e(t,n,r){N(this,e),this.from=t,this.to=n,this.diagnostic=r}),wT=function(){function e(t,n,r){N(this,e),this.diagnostics=t,this.panel=n,this.selected=r}return R(e,null,[{key:"init",value:function(t,n,r){var i=r.facet(DT).markerFilter;i&&(t=i(t,r));for(var o=t.slice().sort(function(e,t){return e.from-t.from||e.to-t.to}),s=new Mv,a=[],l=0,c=r.doc.iter(),u=0,h=r.doc.length,f=function(e){var t,n,r=e==o.length?null:o[e];if(!r&&!a.length)return d=e,0;if(a.length)t=l,n=a.reduce(function(e,t){return Math.min(e,t.to)},r&&r.from>t?r.from:1e8);else{if((t=r.from)>h)return d=e,0;n=r.to,a.push(r),e++}for(;e<o.length;){var i=o[e];if(i.from!=t||!(i.to>i.from||i.to==t)){n=Math.min(i.from,n);break}a.push(i),e++,n=Math.min(i.to,n)}n=Math.min(n,h);var f=!1;if(a.some(function(e){return e.from==t&&(e.to==n||n==h)})&&!(f=t==n)&&n-t<10){var p=t-(u+c.value.length);p>0&&(c.next(p),u=t);for(var m=t;;){if(m>=n){f=!0;break}if(!c.lineBreak&&u+c.value.length>m)break;m=u+c.value.length,u+=c.value.length,c.next()}}var g=function(e){var t,n="hint",r=1,i=D(e);try{for(i.s();!(t=i.n()).done;){var o=t.value,s=HT(o.severity);s>r&&(r=s,n=o.severity)}}catch(e){i.e(e)}finally{i.f()}return n}(a);if(f)s.add(t,t,by.widget({widget:new IT(g),diagnostics:a.slice()}));else{var v=a.reduce(function(e,t){return t.markClass?e+" "+t.markClass:e},"");s.add(t,n,by.mark({class:"cm-lintRange cm-lintRange-"+g+v,diagnostics:a.slice(),inclusiveEnd:a.some(function(e){return e.to>n})}))}if((l=n)==h)return d=e,0;for(var y=0;y<a.length;y++)a[y].to<=l&&a.splice(y--,1);d=e},d=0;0!==f(d););var p=s.finish();return new e(p,n,kT(p))}}])}();function kT(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=null;return e.between(n,1e9,function(e,n,i){var o=i.spec;if(!(t&&o.diagnostics.indexOf(t)<0))if(r){if(o.diagnostics.indexOf(r.diagnostic)<0)return!1;r=new bT(r.from,n,r.diagnostic)}else r=new bT(e,n,t||o.diagnostics[0])}),r}function xT(e,t){return e.field(AT,!1)?t:t.concat(av.appendConfig.of(zT))}var ST=av.define(),CT=av.define(),ET=av.define(),AT=Fg.define({create:function(){return new wT(by.none,null,null)},update:function(e,t){if(t.docChanged&&e.diagnostics.size){var n=e.diagnostics.map(t.changes),r=null,i=e.panel;if(e.selected){var o=t.changes.mapPos(e.selected.from,1);r=kT(n,e.selected.diagnostic,o)||kT(n,null,o)}!n.size&&i&&t.state.facet(DT).autoPanel&&(i=null),e=new wT(n,i,r)}var s,a=D(t.effects);try{for(a.s();!(s=a.n()).done;){var l=s.value;if(l.is(ST)){var c=t.state.facet(DT).autoPanel?l.value.length?FT.open:null:e.panel;e=wT.init(l.value,c,t.state)}else l.is(CT)?e=new wT(e.diagnostics,l.value?FT.open:null,e.selected):l.is(ET)&&(e=new wT(e.diagnostics,e.panel,l.value))}}catch(e){a.e(e)}finally{a.f()}return e},provide:function(e){return[AS.from(e,function(e){return e.panel}),lx.decorations.from(e,function(e){return e.diagnostics})]}}),MT=by.mark({class:"cm-lintRange cm-lintRange-active"});function OT(e,t,n){var r,i=e.state.field(AT).diagnostics,o=-1,s=-1;i.between(t-(n<0?1:0),t+(n>0?1:0),function(e,i,a){var l=a.spec;if(t>=e&&t<=i&&(e==i||(t>e||n>0)&&(t<i||n<0)))return r=l.diagnostics,o=e,s=i,!1});var a=e.state.facet(DT).tooltipFilter;return r&&a&&(r=a(r,e.state)),r?{pos:o,end:s,above:e.state.doc.lineAt(o).to<s,create:function(){return{dom:NT(e,r)}}}:null}function NT(e,t){return Qv("ul",{class:"cm-tooltip-lint"},t.map(function(t){return BT(e,t,!1)}))}var TT=function(e){var t=e.state.field(AT,!1);return!(!t||!t.panel)&&(e.dispatch({effects:CT.of(!1)}),!0)},RT=[{key:"Mod-Shift-m",run:function(e){var t=e.state.field(AT,!1);t&&t.panel||e.dispatch({effects:xT(e.state,[CT.of(!0)])});var n=xS(e,FT.open);return n&&n.dom.querySelector(".cm-panel-lint ul").focus(),!0},preventDefault:!0},{key:"F8",run:function(e){var t=e.state.field(AT,!1);if(!t)return!1;var n=e.state.selection.main,r=kT(t.diagnostics,null,n.to+1);return!(!r&&(!(r=kT(t.diagnostics,null,0))||r.from==n.from&&r.to==n.to))&&(e.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),!0)}}],DT=Dg.define({combine:function(e){return W({sources:e.map(function(e){return e.source}).filter(function(e){return null!=e})},wv(e.map(function(e){return e.config}),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:function(){return null}},{delay:Math.max,markerFilter:PT,tooltipFilter:PT,needsRefresh:function(e,t){return e?t?function(n){return e(n)||t(n)}:e:t},hideOn:function(e,t){return e?t?function(n,r,i){return e(n,r,i)||t(n,r,i)}:e:t},autoPanel:function(e,t){return e||t}}))}});function PT(e,t){return e?t?function(n,r){return t(e(n,r),r)}:e:t}function LT(e){var t=[];if(e){var n,r=D(e);try{e:for(r.s();!(n=r.n()).done;){for(var i=n.value.name,o=function(){var e=i[s];if(/[a-zA-Z]/.test(e)&&!t.some(function(t){return t.toLowerCase()==e.toLowerCase()}))return t.push(e),1},s=0;s<i.length;s++)if(o())continue e;t.push("")}}catch(e){r.e(e)}finally{r.f()}}return t}function BT(e,t,n){var r,i=n?LT(t.actions):[];return Qv("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},Qv("span",{class:"cm-diagnosticText"},t.renderMessage?t.renderMessage(e):t.message),null===(r=t.actions)||void 0===r?void 0:r.map(function(n,r){var o=!1,s=function(r){if(r.preventDefault(),!o){o=!0;var i=kT(e.state.field(AT).diagnostics,t);i&&n.apply(e,i.from,i.to)}},a=n.name,l=i[r]?a.indexOf(i[r]):-1,c=l<0?a:[a.slice(0,l),Qv("u",a.slice(l,l+1)),a.slice(l+1)];return Qv("button",{type:"button",class:"cm-diagnosticAction"+(n.markClass?" "+n.markClass:""),onclick:s,onmousedown:s,"aria-label":" Action: ".concat(a).concat(l<0?"":' (access key "'.concat(i[r],')"'),".")},c)}),t.source&&Qv("div",{class:"cm-diagnosticSource"},t.source))}var IT=function(){function e(t){var n;return N(this,e),(n=O(this,e)).sev=t,n}return I(e,vy),R(e,[{key:"eq",value:function(e){return e.sev==this.sev}},{key:"toDOM",value:function(){return Qv("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}])}(),_T=R(function e(t,n){N(this,e),this.diagnostic=n,this.id="item_"+Math.floor(4294967295*Math.random()).toString(16),this.dom=BT(t,n,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}),FT=function(){function e(t){var n=this;N(this,e),this.view=t,this.items=[];this.list=Qv("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:function(e){if(!(e.ctrlKey||e.altKey||e.metaKey)){if(27==e.keyCode)TT(n.view),n.view.focus();else if(38==e.keyCode||33==e.keyCode)n.moveSelection((n.selectedIndex-1+n.items.length)%n.items.length);else if(40==e.keyCode||34==e.keyCode)n.moveSelection((n.selectedIndex+1)%n.items.length);else if(36==e.keyCode)n.moveSelection(0);else if(35==e.keyCode)n.moveSelection(n.items.length-1);else if(13==e.keyCode)n.view.focus();else{if(!(e.keyCode>=65&&e.keyCode<=90&&n.selectedIndex>=0))return;for(var r=n.items[n.selectedIndex].diagnostic,i=LT(r.actions),o=0;o<i.length;o++)if(i[o].toUpperCase().charCodeAt(0)==e.keyCode){var s=kT(n.view.state.field(AT).diagnostics,r);s&&r.actions[o].apply(t,s.from,s.to)}}e.preventDefault()}},onclick:function(e){for(var t=0;t<n.items.length;t++)n.items[t].dom.contains(e.target)&&n.moveSelection(t)}}),this.dom=Qv("div",{class:"cm-panel-lint"},this.list,Qv("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:function(){return TT(n.view)}},"×")),this.update()}return R(e,[{key:"selectedIndex",get:function(){var e=this.view.state.field(AT).selected;if(!e)return-1;for(var t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}},{key:"update",value:function(){var e=this,t=this.view.state.field(AT),n=t.diagnostics,r=t.selected,i=0,o=!1,s=null,a=new Set;for(n.between(0,this.view.state.doc.length,function(t,n,l){var c,u=D(l.spec.diagnostics);try{for(u.s();!(c=u.n()).done;){var h=c.value;if(!a.has(h)){a.add(h);for(var f=-1,d=void 0,p=i;p<e.items.length;p++)if(e.items[p].diagnostic==h){f=p;break}f<0?(d=new _T(e.view,h),e.items.splice(i,0,d),o=!0):(d=e.items[f],f>i&&(e.items.splice(i,f-i),o=!0)),r&&d.diagnostic==r.diagnostic?d.dom.hasAttribute("aria-selected")||(d.dom.setAttribute("aria-selected","true"),s=d):d.dom.hasAttribute("aria-selected")&&d.dom.removeAttribute("aria-selected"),i++}}}catch(e){u.e(e)}finally{u.f()}});i<this.items.length&&!(1==this.items.length&&this.items[0].diagnostic.from<0);)o=!0,this.items.pop();0==this.items.length&&(this.items.push(new _T(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),o=!0),s?(this.list.setAttribute("aria-activedescendant",s.id),this.view.requestMeasure({key:this,read:function(){return{sel:s.dom.getBoundingClientRect(),panel:e.list.getBoundingClientRect()}},write:function(t){var n=t.sel,r=t.panel,i=r.height/e.list.offsetHeight;n.top<r.top?e.list.scrollTop-=(r.top-n.top)/i:n.bottom>r.bottom&&(e.list.scrollTop+=(n.bottom-r.bottom)/i)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),o&&this.sync()}},{key:"sync",value:function(){var e=this.list.firstChild;function t(){var t=e;e=t.nextSibling,t.remove()}var n,r=D(this.items);try{for(r.s();!(n=r.n()).done;){var i=n.value;if(i.dom.parentNode==this.list){for(;e!=i.dom;)t();e=i.dom.nextSibling}else this.list.insertBefore(i.dom,e)}}catch(e){r.e(e)}finally{r.f()}for(;e;)t()}},{key:"moveSelection",value:function(e){if(!(this.selectedIndex<0)){var t=kT(this.view.state.field(AT).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:ET.of(t)})}}}],[{key:"open",value:function(t){return new e(t)}}])}();function WT(e){return function(e){return'url(\'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" '.concat(arguments.length>1&&void 0!==arguments[1]?arguments[1]:'viewBox="0 0 40 40"',">").concat(encodeURIComponent(e),"</svg>')")}('<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="'.concat(e,'" fill="none" stroke-width=".7"/>'),'width="6" height="3"')}var jT=lx.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:WT("#d11")},".cm-lintRange-warning":{backgroundImage:WT("orange")},".cm-lintRange-info":{backgroundImage:WT("#999")},".cm-lintRange-hint":{backgroundImage:WT("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}});function HT(e){return"error"==e?4:"warning"==e?3:"info"==e?2:1}var zT=[AT,lx.decorations.compute([AT],function(e){var t=e.field(AT),n=t.selected,r=t.panel;return n&&r&&n.from!=n.to?by.set([MT.range(n.from,n.to)]):by.none}),yS(OT,{hideOn:function(e,t){var n=t.pos,r=t.end||n,i=e.state.facet(DT).hideOn(e,n,r);if(null!=i)return i;var o=e.startState.doc.lineAt(t.pos);return!(!e.effects.some(function(e){return e.is(ST)})&&!e.changes.touchesRange(o.from,Math.max(o.to,r)))}}),jT],VT=function(e){void 0===e&&(e={});var t=e.crosshairCursor,n=void 0!==t&&t,r=[];!1!==e.closeBracketsKeymap&&(r=r.concat(cT)),!1!==e.defaultKeymap&&(r=r.concat(dO)),!1!==e.searchKeymap&&(r=r.concat(oN)),!1!==e.historyKeymap&&(r=r.concat(dM)),!1!==e.foldKeymap&&(r=r.concat($E)),!1!==e.completionKeymap&&(r=r.concat(vT)),!1!==e.lintKeymap&&(r=r.concat(RT));var i=[];return!1!==e.lineNumbers&&i.push(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return[GS.of(e),FS(),XS]}()),!1!==e.highlightActiveLineGutter&&i.push(ZS),!1!==e.highlightSpecialChars&&i.push(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return[Ux.of(e),Kx||(Kx=_b.fromClass(function(){return R(function e(t){N(this,e),this.view=t,this.decorations=by.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(t.state.facet(Ux)),this.decorations=this.decorator.createDeco(t)},[{key:"makeDecorator",value:function(e){var t=this;return new jx({regexp:e.specialChars,decoration:function(n,r,i){var o=r.state.doc,s=mg(n[0],0);if(9==s){var a=o.lineAt(i),l=r.state.tabSize,c=Fv(a.text,l,i-a.from);return by.replace({widget:new Yx((l-c%l)*t.view.defaultCharacterWidth/t.view.scaleX)})}return t.decorationCache[s]||(t.decorationCache[s]=by.replace({widget:new Gx(e,s)}))},boundary:e.replaceTabs?void 0:/[^]/})}},{key:"update",value:function(e){var t=e.state.facet(Ux);e.startState.facet(Ux)!=t?(this.decorator=this.makeDecorator(t),this.decorations=this.decorator.createDeco(e.view)):this.decorations=this.decorator.updateDeco(e,this.decorations)}}])}(),{decorations:function(e){return e.decorations}}))]}()),!1!==e.history&&i.push(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return[XA,$A.of(e),lx.domEventHandlers({beforeinput:function(e,t){var n="historyUndo"==e.inputType?QA:"historyRedo"==e.inputType?ZA:null;return!!n&&(e.preventDefault(),n(t))}})]}()),!1!==e.foldGutter&&i.push(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=W(W({},nA),e),n=new rA(t,!0),r=new rA(t,!1),i=_b.fromClass(function(){return R(function e(t){N(this,e),this.from=t.viewport.from,this.markers=this.buildMarkers(t)},[{key:"update",value:function(e){(e.docChanged||e.viewportChanged||e.startState.facet(kE)!=e.state.facet(kE)||e.startState.field(qE,!1)!=e.state.field(qE,!1)||fE(e.startState)!=fE(e.state)||t.foldingChanged(e))&&(this.markers=this.buildMarkers(e.view))}},{key:"buildMarkers",value:function(e){var t,i=new Mv,o=D(e.viewportLineBlocks);try{for(o.s();!(t=o.n()).done;){var s=t.value,a=KE(e.state,s.from,s.to)?r:WE(e.state,s.from,s.to)?n:null;a&&i.add(s.from,s.from,a)}}catch(e){o.e(e)}finally{o.f()}return i.finish()}}])}()),o=t.domEventHandlers;return[i,IS({class:"cm-foldGutter",markers:function(e){var t;return(null===(t=e.plugin(i))||void 0===t?void 0:t.markers)||Av.empty},initialSpacer:function(){return new rA(t,!1)},domEventHandlers:W(W({},o),{},{click:function(e,t,n){if(o.click&&o.click(e,t,n))return!0;var r=KE(e.state,t.from,t.to);if(r)return e.dispatch({effects:zE.of(r)}),!0;var i=WE(e.state,t.from,t.to);return!!i&&(e.dispatch({effects:HE.of(i)}),!0)}})}),QE()]}()),!1!==e.drawSelection&&i.push(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return[Tx.of(e),Dx,Lx,Bx,Ob.of(!0)]}()),!1!==e.dropCursor&&i.push([_x,Fx]),!1!==e.allowMultipleSelections&&i.push(bv.allowMultipleSelections.of(!0)),!1!==e.indentOnInput&&i.push(bv.transactionFilter.of(function(e){if(!e.docChanged||!e.isUserEvent("input.type")&&!e.isUserEvent("input.complete"))return e;var t=e.startState.languageDataAt("indentOnInput",e.startState.selection.main.head);if(!t.length)return e;var n=e.newDoc,r=e.newSelection.main.head,i=n.lineAt(r);if(r>i.from+200)return e;var o=n.sliceString(i.from,r);if(!t.some(function(e){return e.test(o)}))return e;var s,a=e.state,l=-1,c=[],u=D(a.selection.ranges);try{for(u.s();!(s=u.n()).done;){var h=s.value.head,f=a.doc.lineAt(h);if(f.from!=l){l=f.from;var d=ME(a,f.from);if(null!=d){var p=/^\s*/.exec(f.text)[0],m=AE(a,d);p!=m&&c.push({from:f.from,to:f.from+p.length,insert:m})}}}}catch(e){u.e(e)}finally{u.f()}return c.length?[e,{changes:c,sequential:!0}]:e})),!1!==e.syntaxHighlighting&&i.push(cA(fA,{fallback:!0})),!1!==e.bracketMatching&&i.push(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return[mA.of(e),wA]}()),!1!==e.closeBrackets&&i.push([lT,rT]),!1!==e.autocompletion&&i.push(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return[QN,qN,AN.of(e),XN,yT,ZN]}()),!1!==e.rectangularSelection&&i.push(function(e){var t=(null==e?void 0:e.eventFilter)||function(e){return e.altKey&&0==e.button};return lx.mouseSelectionStyle.of(function(e,n){return t(n)?eS(e,n):null})}()),!1!==n&&i.push(function(){var e=q(tS[(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).key||"Alt"],2),t=e[0],n=e[1],r=_b.fromClass(function(){return R(function e(t){N(this,e),this.view=t,this.isDown=!1},[{key:"set",value:function(e){this.isDown!=e&&(this.isDown=e,this.view.update([]))}}])}(),{eventObservers:{keydown:function(e){this.set(e.keyCode==t||n(e))},keyup:function(e){e.keyCode!=t&&n(e)||this.set(!1)},mousemove:function(e){this.set(n(e))}}});return[r,lx.contentAttributes.of(function(e){var t;return(null===(t=e.plugin(r))||void 0===t?void 0:t.isDown)?nS:null})]}()),!1!==e.highlightActiveLine&&i.push(Xx),!1!==e.highlightSelectionMatches&&i.push(function(e){var t=[TO,NO];return e&&t.push(EO.of(e)),t}()),e.tabSize&&"number"==typeof e.tabSize&&i.push(CE.of(" ".repeat(e.tabSize))),i.concat([gx.of(r.flat())]).filter(Boolean)},qT="#e06c75",UT="#abb2bf",KT="#7d8799",GT="#d19a66",YT="#2c313a",$T="#282c34",XT="#353a42",JT="#528bff",QT=[lx.theme({"&":{color:UT,backgroundColor:$T},".cm-content":{caretColor:JT},".cm-cursor, .cm-dropCursor":{borderLeftColor:JT},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:"#3E4451"},".cm-panels":{backgroundColor:"#21252b",color:UT},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:$T,color:KT,border:"none"},".cm-activeLineGutter":{backgroundColor:YT},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:XT},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:XT,borderBottomColor:XT},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:YT,color:UT}}},{dark:!0}),cA(oA.define([{tag:iE.keyword,color:"#c678dd"},{tag:[iE.name,iE.deleted,iE.character,iE.propertyName,iE.macroName],color:qT},{tag:[iE.function(iE.variableName),iE.labelName],color:"#61afef"},{tag:[iE.color,iE.constant(iE.name),iE.standard(iE.name)],color:GT},{tag:[iE.definition(iE.name),iE.separator],color:UT},{tag:[iE.typeName,iE.className,iE.number,iE.changed,iE.annotation,iE.modifier,iE.self,iE.namespace],color:"#e5c07b"},{tag:[iE.operator,iE.operatorKeyword,iE.url,iE.escape,iE.regexp,iE.link,iE.special(iE.string)],color:"#56b6c2"},{tag:[iE.meta,iE.comment],color:KT},{tag:iE.strong,fontWeight:"bold"},{tag:iE.emphasis,fontStyle:"italic"},{tag:iE.strikethrough,textDecoration:"line-through"},{tag:iE.link,color:KT,textDecoration:"underline"},{tag:iE.heading,fontWeight:"bold",color:qT},{tag:[iE.atom,iE.bool,iE.special(iE.variableName)],color:GT},{tag:[iE.processingInstruction,iE.string,iE.inserted],color:"#98c379"},{tag:iE.invalid,color:"#ffffff"}]))],ZT=lx.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),eR=function(e){void 0===e&&(e={});var t=e,n=t.indentWithTab,r=void 0===n||n,i=t.editable,o=void 0===i||i,s=t.readOnly,a=void 0!==s&&s,l=t.theme,c=void 0===l?"light":l,u=t.placeholder,h=void 0===u?"":u,f=t.basicSetup,d=void 0===f||f,p=[];switch(r&&p.unshift(gx.of([pO])),d&&("boolean"==typeof d?p.unshift(VT()):p.unshift(VT(d))),h&&p.unshift(function(e){var t=_b.fromClass(function(){return R(function t(n){N(this,t),this.view=n,this.placeholder=e?by.set([by.widget({widget:new Jx(e),side:1}).range(0)]):by.none},[{key:"decorations",get:function(){return this.view.state.doc.length?by.none:this.placeholder}}])}(),{decorations:function(e){return e.decorations}});return"string"==typeof e?[t,lx.contentAttributes.of({"aria-placeholder":e})]:t}(h)),c){case"light":p.push(ZT);break;case"dark":p.push(QT);break;case"none":break;default:p.push(c)}return!1===o&&p.push(lx.editable.of(!1)),a&&p.push(bv.readOnly.of(!0)),[].concat(p)},tR=function(){return R(function e(t,n){N(this,e),this.timeLeftMS=void 0,this.timeoutMS=void 0,this.isCancelled=!1,this.isTimeExhausted=!1,this.callbacks=[],this.timeLeftMS=n,this.timeoutMS=n,this.callbacks.push(t)},[{key:"tick",value:function(){if(!this.isCancelled&&!this.isTimeExhausted&&(this.timeLeftMS--,this.timeLeftMS<=0)){this.isTimeExhausted=!0;var e=this.callbacks.slice();this.callbacks.length=0,e.forEach(function(e){try{e()}catch(e){}})}}},{key:"cancel",value:function(){this.isCancelled=!0,this.callbacks.length=0}},{key:"reset",value:function(){this.timeLeftMS=this.timeoutMS,this.isCancelled=!1,this.isTimeExhausted=!1}},{key:"isDone",get:function(){return this.isCancelled||this.isTimeExhausted}}])}(),nR=function(){return R(function e(){N(this,e),this.interval=null,this.latches=new Set},[{key:"add",value:function(e){this.latches.add(e),this.start()}},{key:"remove",value:function(e){this.latches.delete(e),0===this.latches.size&&this.stop()}},{key:"start",value:function(){var e=this;null===this.interval&&(this.interval=setInterval(function(){e.latches.forEach(function(t){t.tick(),t.isDone&&e.remove(t)})},1))}},{key:"stop",value:function(){null!==this.interval&&(clearInterval(this.interval),this.interval=null)}}])}(),rR=null,iR=iv.define(),oR=[];function sR(e){var t=e.value,n=e.selection,r=e.onChange,s=e.onStatistics,l=e.onCreateEditor,c=e.onUpdate,u=e.extensions,h=void 0===u?oR:u,f=e.autoFocus,d=e.theme,p=void 0===d?"light":d,m=e.height,g=void 0===m?null:m,v=e.minHeight,y=void 0===v?null:v,b=e.maxHeight,w=void 0===b?null:b,k=e.width,x=void 0===k?null:k,S=e.minWidth,C=void 0===S?null:S,E=e.maxWidth,A=void 0===E?null:E,M=e.placeholder,O=void 0===M?"":M,N=e.editable,T=void 0===N||N,R=e.readOnly,D=void 0!==R&&R,P=e.indentWithTab,L=void 0===P||P,B=e.basicSetup,I=void 0===B||B,_=e.root,F=e.initialState,W=q(i(),2),j=W[0],H=W[1],z=q(i(),2),V=z[0],U=z[1],G=q(i(),2),Y=G[0],$=G[1],X=i(function(){return{current:null}})[0],J=i(function(){return{current:null}})[0],Q=lx.theme({"&":{height:g,minHeight:y,maxHeight:w,width:x,minWidth:C,maxWidth:A},"& .cm-scroller":{height:"100% !important"}}),Z=lx.updateListener.of(function(e){if(e.docChanged&&"function"==typeof r&&!e.transactions.some(function(e){return e.annotation(iR)})){X.current?X.current.reset():(X.current=new tR(function(){if(J.current){var e=J.current;J.current=null,e()}X.current=null},200),("undefined"==typeof window?new nR:(rR||(rR=new nR),rR)).add(X.current));var t=e.state.doc.toString();r(t,e)}s&&s(function(e){return{line:e.state.doc.lineAt(e.state.selection.main.from),lineCount:e.state.doc.lines,lineBreak:e.state.lineBreak,length:e.state.doc.length,readOnly:e.state.readOnly,tabSize:e.state.tabSize,selection:e.state.selection,selectionAsSingle:e.state.selection.asSingle().main,ranges:e.state.selection.ranges,selectionCode:e.state.sliceDoc(e.state.selection.main.from,e.state.selection.main.to),selections:e.state.selection.ranges.map(function(t){return e.state.sliceDoc(t.from,t.to)}),selectedText:e.state.selection.ranges.some(function(e){return!e.empty})}}(e))}),ee=eR({theme:p,editable:T,readOnly:D,placeholder:O,indentWithTab:L,basicSetup:I}),te=[Z,Q].concat(K(ee));return c&&"function"==typeof c&&te.push(lx.updateListener.of(c)),te=te.concat(h),o(function(){if(j&&!Y){var e={doc:t,selection:n,extensions:te},r=F?bv.fromJSON(F.json,e,F.fields):bv.create(e);if($(r),!V){var i=new lx({state:r,parent:j,root:_});U(i),l&&l(i,r)}}return function(){V&&($(void 0),U(void 0))}},[j,Y]),a(function(){e.container&&H(e.container)},[e.container]),a(function(){return function(){V&&(V.destroy(),U(void 0)),X.current&&(X.current.cancel(),X.current=null)}},[V]),a(function(){f&&V&&V.focus()},[f,V]),a(function(){V&&V.dispatch({effects:av.reconfigure.of(te)})},[p,h,g,y,w,x,C,A,O,T,D,L,I,r,c]),a(function(){if(void 0!==t){var e=V?V.state.doc.toString():"";if(V&&t!==e){var n=function(){V&&t!==V.state.doc.toString()&&V.dispatch({changes:{from:0,to:V.state.doc.toString().length,insert:t||""},annotations:[iR.of(!0)]})};X.current&&!X.current.isDone?J.current=n:n()}}},[t,V]),{state:Y,setState:$,view:V,setView:U,container:j,setContainer:H}}var aR=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],lR=n(function(e,t){var n=e.className,r=e.value,i=void 0===r?"":r,o=e.selection,s=e.extensions,a=void 0===s?[]:s,l=e.onChange,c=e.onStatistics,p=e.onCreateEditor,m=e.onUpdate,g=e.autoFocus,v=e.theme,y=void 0===v?"light":v,b=e.height,w=e.minHeight,k=e.maxHeight,x=e.width,S=e.minWidth,C=e.maxWidth,E=e.basicSetup,A=e.placeholder,M=e.indentWithTab,O=e.editable,N=e.readOnly,T=e.root,R=e.initialState,D=function(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,aR),P=u(null),L=sR({root:T,value:i,autoFocus:g,theme:y,height:b,minHeight:w,maxHeight:k,width:x,minWidth:S,maxWidth:C,basicSetup:E,placeholder:A,indentWithTab:M,editable:O,readOnly:N,selection:o,onChange:l,onStatistics:c,onCreateEditor:p,onUpdate:m,extensions:a,initialState:R}),B=L.state,I=L.view,_=L.container,F=L.setContainer;h(t,function(){return{editor:P.current,state:B,view:I}},[P,_,B,I]);var W=f(function(e){P.current=e,F(e)},[F]);if("string"!=typeof i)throw new Error("value must be typeof string but got "+Y(i));return d("div",Km({ref:W,className:("string"==typeof y?"cm-theme-"+y:"cm-theme")+(n?" "+n:"")},D))});lR.displayName="CodeMirror";var cR=function(){function e(t,n,r,i,o,s,a,l,c){var u=arguments.length>9&&void 0!==arguments[9]?arguments[9]:0,h=arguments.length>10?arguments[10]:void 0;N(this,e),this.p=t,this.stack=n,this.state=r,this.reducePos=i,this.pos=o,this.score=s,this.buffer=a,this.bufferBase=l,this.curContext=c,this.lookAhead=u,this.parent=h}return R(e,[{key:"toString",value:function(){return"[".concat(this.stack.filter(function(e,t){return t%3==0}).concat(this.state),"]@").concat(this.pos).concat(this.score?"!"+this.score:"")}},{key:"context",get:function(){return this.curContext?this.curContext.context:null}},{key:"pushState",value:function(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}},{key:"reduce",value:function(e){var t,n=e>>19,r=65535&e,i=this.p.parser,o=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),s=i.dynamicPrecedence(r);if(s&&(this.score+=s),0==n)return this.pushState(i.getGoto(this.state,r,!0),this.reducePos),r<i.minRepeatTerm&&this.storeNode(r,this.reducePos,this.reducePos,o?8:4,!0),void this.reduceContext(r,this.reducePos);var a=this.stack.length-3*(n-1)-(262144&e?6:0),l=a?this.stack[a-2]:this.p.ranges[0].from,c=this.reducePos-l;c>=2e3&&!(null===(t=this.p.parser.nodeSet.types[r])||void 0===t?void 0:t.isAnonymous)&&(l==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSize<c&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=l,this.p.lastBigReductionSize=c));var u=a?this.stack[a-1]:0,h=this.bufferBase+this.buffer.length-u;if(r<i.minRepeatTerm||131072&e){var f=i.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(r,l,f,h+4,!0)}if(262144&e)this.state=this.stack[a];else{var d=this.stack[a-3];this.state=i.getGoto(d,r,!0)}for(;this.stack.length>a;)this.stack.pop();this.reduceContext(r,l)}},{key:"storeNode",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:4,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4];if(0==e&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){var o=this,s=this.buffer.length;if(0==s&&o.parent&&(s=o.bufferBase-o.parent.bufferBase,o=o.parent),s>0&&0==o.buffer[s-4]&&o.buffer[s-1]>-1){if(t==n)return;if(o.buffer[s-2]>=t)return void(o.buffer[s-2]=n)}}if(i&&this.pos!=n){var a=this.buffer.length;if(a>0&&(0!=this.buffer[a-4]||this.buffer[a-1]<0)){for(var l=!1,c=a;c>0&&this.buffer[c-2]>n;c-=4)if(this.buffer[c-1]>=0){l=!0;break}if(l)for(;a>0&&this.buffer[a-2]>n;)this.buffer[a]=this.buffer[a-4],this.buffer[a+1]=this.buffer[a-3],this.buffer[a+2]=this.buffer[a-2],this.buffer[a+3]=this.buffer[a-1],a-=4,r>4&&(r-=4)}this.buffer[a]=e,this.buffer[a+1]=t,this.buffer[a+2]=n,this.buffer[a+3]=r}else this.buffer.push(e,t,n,r)}},{key:"shift",value:function(e,t,n,r){if(131072&e)this.pushState(65535&e,this.pos);else if(262144&e)this.pos=r,this.shiftContext(t,n),t<=this.p.parser.maxNode&&this.buffer.push(t,n,r,4);else{var i=e,o=this.p.parser;this.pos=r;var s=o.stateFlag(i,1);!s&&(r>n||t<=o.maxNode)&&(this.reducePos=r),this.pushState(i,s?n:Math.min(n,this.reducePos)),this.shiftContext(t,n),t<=o.maxNode&&this.buffer.push(t,n,r,4)}}},{key:"apply",value:function(e,t,n,r){65536&e?this.reduce(e):this.shift(e,t,n,r)}},{key:"useNode",value:function(e,t){var n=this.p.reused.length-1;(n<0||this.p.reused[n]!=e)&&(this.p.reused.push(e),n++);var r=this.pos;this.reducePos=this.pos=r+e.length,this.pushState(t,r),this.buffer.push(n,r,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}},{key:"split",value:function(){for(var t=this,n=t.buffer.length;n>0&&t.buffer[n-2]>t.reducePos;)n-=4;for(var r=t.buffer.slice(n),i=t.bufferBase+n;t&&i==t.bufferBase;)t=t.parent;return new e(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,r,i,this.curContext,this.lookAhead,t)}},{key:"recoverByDelete",value:function(e,t){var n=e<=this.p.parser.maxNode;n&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,n?8:4),this.pos=this.reducePos=t,this.score-=190}},{key:"canShift",value:function(e){for(var t=new hR(this);;){var n=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(0==n)return!1;if(!(65536&n))return!0;t.reduce(n)}}},{key:"recoverByInsert",value:function(e){if(this.stack.length>=300)return[];var t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){for(var n,r=[],i=0;i<t.length;i+=2)(n=t[i+1])!=this.state&&this.p.parser.hasAction(n,e)&&r.push(t[i],n);if(this.stack.length<120)for(var o=function(){var e=t[s+1];r.some(function(t,n){return 1&n&&t==e})||r.push(t[s],e)},s=0;r.length<8&&s<t.length;s+=2)o();t=r}for(var a=[],l=0;l<t.length&&a.length<4;l+=2){var c=t[l+1];if(c!=this.state){var u=this.split();u.pushState(c,this.pos),u.storeNode(0,u.pos,u.pos,4,!0),u.shiftContext(t[l],this.pos),u.reducePos=this.pos,u.score-=200,a.push(u)}}return a}},{key:"forceReduce",value:function(){var e=this.p.parser,t=e.stateSlot(this.state,5);if(!(65536&t))return!1;if(!e.validAction(this.state,t)){var n=t>>19,r=65535&t,i=this.stack.length-3*n;if(i<0||e.getGoto(this.stack[i],r,!1)<0){var o=this.findForcedReduction();if(null==o)return!1;t=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}},{key:"findForcedReduction",value:function(){var e=this,t=this.p.parser,n=[],r=function(i,o){if(!n.includes(i))return n.push(i),t.allActions(i,function(n){if(393216&n);else if(65536&n){var i=(n>>19)-o;if(i>1){var s=65535&n,a=e.stack.length-3*i;if(a>=0&&t.getGoto(e.stack[a],s,!1)>=0)return i<<19|65536|s}}else{var l=r(n,o+1);if(null!=l)return l}})};return r(this.state,0)}},{key:"forceAll",value:function(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}},{key:"deadEnd",get:function(){if(3!=this.stack.length)return!1;var e=this.p.parser;return 65535==e.data[e.stateSlot(this.state,1)]&&!e.stateSlot(this.state,4)}},{key:"restart",value:function(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}},{key:"sameState",value:function(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(var t=0;t<this.stack.length;t+=3)if(this.stack[t]!=e.stack[t])return!1;return!0}},{key:"parser",get:function(){return this.p.parser}},{key:"dialectEnabled",value:function(e){return this.p.parser.dialect.flags[e]}},{key:"shiftContext",value:function(e,t){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(t)))}},{key:"reduceContext",value:function(e,t){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(t)))}},{key:"emitContext",value:function(){var e=this.buffer.length-1;(e<0||-3!=this.buffer[e])&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}},{key:"emitLookAhead",value:function(){var e=this.buffer.length-1;(e<0||-4!=this.buffer[e])&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}},{key:"updateContext",value:function(e){if(e!=this.curContext.context){var t=new uR(this.curContext.tracker,e);t.hash!=this.curContext.hash&&this.emitContext(),this.curContext=t}}},{key:"setLookAhead",value:function(e){return!(e<=this.lookAhead)&&(this.emitLookAhead(),this.lookAhead=e,!0)}},{key:"close",value:function(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}],[{key:"start",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=t.parser.context;return new e(t,[],n,r,r,0,[],0,i?new uR(i,i.start):null,0,null)}}])}(),uR=R(function e(t,n){N(this,e),this.tracker=t,this.context=n,this.hash=t.strict?t.hash(n):0}),hR=function(){return R(function e(t){N(this,e),this.start=t,this.state=t.state,this.stack=t.stack,this.base=this.stack.length},[{key:"reduce",value:function(e){var t=65535&e,n=e>>19;0==n?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=3*(n-1);var r=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=r}}])}(),fR=function(){function e(t,n,r){N(this,e),this.stack=t,this.pos=n,this.index=r,this.buffer=t.buffer,0==this.index&&this.maybeNext()}return R(e,[{key:"maybeNext",value:function(){var e=this.stack.parent;null!=e&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}},{key:"id",get:function(){return this.buffer[this.index-4]}},{key:"start",get:function(){return this.buffer[this.index-3]}},{key:"end",get:function(){return this.buffer[this.index-2]}},{key:"size",get:function(){return this.buffer[this.index-1]}},{key:"next",value:function(){this.index-=4,this.pos-=4,0==this.index&&this.maybeNext()}},{key:"fork",value:function(){return new e(this.stack,this.pos,this.index)}}],[{key:"create",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t.bufferBase+t.buffer.length;return new e(t,n,n-t.bufferBase)}}])}();function dR(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Uint16Array;if("string"!=typeof e)return e;for(var n=null,r=0,i=0;r<e.length;){for(var o=0;;){var s=e.charCodeAt(r++),a=!1;if(126==s){o=65535;break}s>=92&&s--,s>=34&&s--;var l=s-32;if(l>=46&&(l-=46,a=!0),o+=l,a)break;o*=46}n?n[i++]=o:n=new t(o)}return n}var pR=R(function e(){N(this,e),this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}),mR=new pR,gR=function(){return R(function e(t,n){N(this,e),this.input=t,this.ranges=n,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=mR,this.rangeIndex=0,this.pos=this.chunkPos=n[0].from,this.range=n[0],this.end=n[n.length-1].to,this.readNext()},[{key:"resolveOffset",value:function(e,t){for(var n=this.range,r=this.rangeIndex,i=this.pos+e;i<n.from;){if(!r)return null;var o=this.ranges[--r];i-=n.from-o.to,n=o}for(;t<0?i>n.to:i>=n.to;){if(r==this.ranges.length-1)return null;var s=this.ranges[++r];i+=s.from-n.to,n=s}return i}},{key:"clipPos",value:function(e){if(e>=this.range.from&&e<this.range.to)return e;var t,n=D(this.ranges);try{for(n.s();!(t=n.n()).done;){var r=t.value;if(r.to>e)return Math.max(e,r.from)}}catch(e){n.e(e)}finally{n.f()}return this.end}},{key:"peek",value:function(e){var t,n,r=this.chunkOff+e;if(r>=0&&r<this.chunk.length)t=this.pos+e,n=this.chunk.charCodeAt(r);else{var i=this.resolveOffset(e,1);if(null==i)return-1;if((t=i)>=this.chunk2Pos&&t<this.chunk2Pos+this.chunk2.length)n=this.chunk2.charCodeAt(t-this.chunk2Pos);else{for(var o=this.rangeIndex,s=this.range;s.to<=t;)s=this.ranges[++o];this.chunk2=this.input.chunk(this.chunk2Pos=t),t+this.chunk2.length>s.to&&(this.chunk2=this.chunk2.slice(0,s.to-t)),n=this.chunk2.charCodeAt(0)}}return t>=this.token.lookAhead&&(this.token.lookAhead=t+1),n}},{key:"acceptToken",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=t?this.resolveOffset(t,-1):this.pos;if(null==n||n<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=n}},{key:"acceptTokenTo",value:function(e,t){this.token.value=e,this.token.end=t}},{key:"getChunk",value:function(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){var e=this.chunk,t=this.chunkPos;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=t,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;var n=this.input.chunk(this.pos),r=this.pos+n.length;this.chunk=r>this.range.to?n.slice(0,this.range.to-this.pos):n,this.chunkPos=this.pos,this.chunkOff=0}}},{key:"readNext",value:function(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}},{key:"advance",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}},{key:"setDone",value:function(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}},{key:"reset",value:function(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=mR,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}},{key:"read",value:function(e,t){if(e>=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);var n,r="",i=D(this.ranges);try{for(i.s();!(n=i.n()).done;){var o=n.value;if(o.from>=t)break;o.to>e&&(r+=this.input.read(Math.max(o.from,e),Math.min(o.to,t)))}}catch(e){i.e(e)}finally{i.f()}return r}}])}(),vR=function(){return R(function e(t,n){N(this,e),this.data=t,this.id=n},[{key:"token",value:function(e,t){var n=t.p.parser;yR(this.data,e,t,this.id,n.data,n.tokenPrecTable)}}])}();function yR(e,t,n,r,i,o){var s=0,a=1<<r,l=n.p.parser.dialect;e:for(;0!=(a&e[s]);){for(var c=e[s+1],u=s+3;u<c;u+=2)if((e[u+1]&a)>0){var h=e[u];if(l.allows(h)&&(-1==t.token.value||t.token.value==h||wR(h,t.token.value,i,o))){t.acceptToken(h);break}}var f=t.next,d=0,p=e[s+2];if(!(t.next<0&&p>d&&65535==e[c+3*p-3])){for(;d<p;){var m=d+p>>1,g=c+m+(m<<1),v=e[g],y=e[g+1]||65536;if(f<v)p=m;else{if(!(f>=y)){s=e[g+2],t.advance();continue e}d=m+1}}break}s=e[c+3*p-1]}}function bR(e,t,n){for(var r,i=t;65535!=(r=e[i]);i++)if(r==n)return i-t;return-1}function wR(e,t,n,r){var i=bR(n,r,t);return i<0||bR(n,r,e)<i}vR.prototype.contextual=vR.prototype.fallback=vR.prototype.extend=!1,function(){return R(function e(t,n,r){N(this,e),this.precTable=n,this.elseToken=r,this.data="string"==typeof t?dR(t):t},[{key:"token",value:function(e,t){for(var n=e.pos,r=0;;){var i=e.next<0,o=e.resolveOffset(1,1);if(yR(this.data,e,t,0,this.data,this.precTable),e.token.value>-1)break;if(null==this.elseToken)return;if(i||r++,null==o)break;e.reset(o,e.token)}r&&(e.reset(n,e.token),e.acceptToken(this.elseToken,r))}}])}().prototype.contextual=vR.prototype.fallback=vR.prototype.extend=!1;var kR="undefined"!=typeof process&&process.env&&/\bparse\b/.test(process.env.LOG),xR=null;function SR(e,t,n){var r=e.cursor(sC.IncludeAnonymous);for(r.moveTo(t);;)if(!(n<0?r.childBefore(t):r.childAfter(t)))for(;;){if((n<0?r.to<t:r.from>t)&&!r.type.isError)return n<0?Math.max(0,Math.min(r.to-1,t-25)):Math.min(e.length,Math.max(r.from+1,t+25));if(n<0?r.prevSibling():r.nextSibling())break;if(!r.parent())return n<0?0:e.length}}var CR=function(){return R(function e(t,n){N(this,e),this.fragments=t,this.nodeSet=n,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()},[{key:"nextFragment",value:function(){var e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?SR(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?SR(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}},{key:"nodeAt",value:function(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){var t=this.trees.length-1;if(t<0)return this.nextFragment(),null;var n=this.trees[t],r=this.index[t];if(r!=n.children.length){var i=n.children[r],o=this.start[t]+n.positions[r];if(o>e)return this.nextStart=o,null;if(i instanceof uC){if(o==e){if(o<this.safeFrom)return null;var s=o+i.length;if(s<=this.safeTo){var a=i.prop(nC.lookAhead);if(!a||s+a<this.fragment.to)return i}}this.index[t]++,o+i.length>=Math.max(this.safeFrom,e)&&(this.trees.push(i),this.start.push(o),this.index.push(0))}else this.index[t]++,this.nextStart=o+i.length}else this.trees.pop(),this.start.pop(),this.index.pop()}}}])}(),ER=function(){return R(function e(t,n){N(this,e),this.stream=n,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=t.tokenizers.map(function(e){return new pR})},[{key:"getActions",value:function(e){for(var t=0,n=null,r=e.p.parser,i=r.tokenizers,o=r.stateSlot(e.state,3),s=e.curContext?e.curContext.hash:0,a=0,l=0;l<i.length;l++)if(1<<l&o){var c=i[l],u=this.tokens[l];if((!n||c.fallback)&&((c.contextual||u.start!=e.pos||u.mask!=o||u.context!=s)&&(this.updateCachedToken(u,c,e),u.mask=o,u.context=s),u.lookAhead>u.end+25&&(a=Math.max(u.lookAhead,a)),0!=u.value)){var h=t;if(u.extended>-1&&(t=this.addActions(e,u.extended,u.end,t)),t=this.addActions(e,u.value,u.end,t),!c.extend&&(n=u,t>h))break}}for(;this.actions.length>t;)this.actions.pop();return a&&e.setLookAhead(a),n||e.pos!=this.stream.end||((n=new pR).value=e.p.parser.eofTerm,n.start=n.end=e.pos,t=this.addActions(e,n.value,n.end,t)),this.mainToken=n,this.actions}},{key:"getMainToken",value:function(e){if(this.mainToken)return this.mainToken;var t=new pR,n=e.pos,r=e.p;return t.start=n,t.end=Math.min(n+1,r.stream.end),t.value=n==r.stream.end?r.parser.eofTerm:0,t}},{key:"updateCachedToken",value:function(e,t,n){var r=this.stream.clipPos(n.pos);if(t.token(this.stream.reset(r,e),n),e.value>-1){for(var i=n.p.parser,o=0;o<i.specialized.length;o++)if(i.specialized[o]==e.value){var s=i.specializers[o](this.stream.read(e.start,e.end),n);if(s>=0&&n.p.parser.dialect.allows(s>>1)){1&s?e.extended=s>>1:e.value=s>>1;break}}}else e.value=0,e.end=this.stream.clipPos(r+1)}},{key:"putAction",value:function(e,t,n,r){for(var i=0;i<r;i+=3)if(this.actions[i]==e)return r;return this.actions[r++]=e,this.actions[r++]=t,this.actions[r++]=n,r}},{key:"addActions",value:function(e,t,n,r){for(var i=e.state,o=e.p.parser,s=o.data,a=0;a<2;a++)for(var l=o.stateSlot(i,a?2:1);;l+=3){if(65535==s[l]){if(1!=s[l+1]){0==r&&2==s[l+1]&&(r=this.putAction(TR(s,l+2),t,n,r));break}l=TR(s,l+2)}s[l]==t&&(r=this.putAction(TR(s,l+1),t,n,r))}return r}}])}(),AR=function(){return R(function e(t,n,r,i){N(this,e),this.parser=t,this.input=n,this.ranges=i,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new gR(n,i),this.tokens=new ER(t,this.stream),this.topTerm=t.top[1];var o=i[0].from;this.stacks=[cR.start(this,t.top[0],o)],this.fragments=r.length&&this.stream.end-o>4*t.bufferLength?new CR(r,t.nodeSet):null},[{key:"parsedPos",get:function(){return this.minStackPos}},{key:"advance",value:function(){var e,t,n=this.stacks,r=this.minStackPos,i=this.stacks=[];if(this.bigReductionCount>300&&1==n.length){for(var o=q(n,1)[0];o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(var s=0;s<n.length;s++)for(var a=n[s];;){if(this.tokens.mainToken=null,a.pos>r)i.push(a);else{if(this.advanceStack(a,i,n))continue;e||(e=[],t=[]),e.push(a);var l=this.tokens.getMainToken(a);t.push(l.value,l.end)}break}if(!i.length){var c=e&&function(e){var t,n=null,r=D(e);try{for(r.s();!(t=r.n()).done;){var i=t.value,o=i.p.stoppedAt;(i.pos==i.p.stream.end||null!=o&&i.pos>o)&&i.p.parser.stateFlag(i.state,2)&&(!n||n.score<i.score)&&(n=i)}}catch(e){r.e(e)}finally{r.f()}return n}(e);if(c)return this.stackToTree(c);if(this.parser.strict)throw new SyntaxError("No parse at "+r);this.recovering||(this.recovering=5)}if(this.recovering&&e){var u=null!=this.stoppedAt&&e[0].pos>this.stoppedAt?e[0]:this.runRecovery(e,t,i);if(u)return this.stackToTree(u.forceAll())}if(this.recovering){var h=1==this.recovering?1:3*this.recovering;if(i.length>h)for(i.sort(function(e,t){return t.score-e.score});i.length>h;)i.pop();i.some(function(e){return e.reducePos>r})&&this.recovering--}else if(i.length>1){e:for(var f=0;f<i.length-1;f++)for(var d=i[f],p=f+1;p<i.length;p++){var m=i[p];if(d.sameState(m)||d.buffer.length>500&&m.buffer.length>500){if(!((d.score-m.score||d.buffer.length-m.buffer.length)>0)){i.splice(f--,1);continue e}i.splice(p--,1)}}i.length>12&&(i.sort(function(e,t){return t.score-e.score}),i.splice(12,i.length-12))}this.minStackPos=i[0].pos;for(var g=1;g<i.length;g++)i[g].pos<this.minStackPos&&(this.minStackPos=i[g].pos);return null}},{key:"stopAt",value:function(e){if(null!=this.stoppedAt&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}},{key:"advanceStack",value:function(e,t,n){var r=e.pos,i=this.parser;kR&&this.stackID(e);if(null!=this.stoppedAt&&r>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments)for(var o=e.curContext&&e.curContext.tracker.strict,s=o?e.curContext.hash:0,a=this.fragments.nodeAt(r);a;){var l=this.parser.nodeSet.types[a.type.id]==a.type?i.getGoto(e.state,a.type.id):-1;if(l>-1&&a.length&&(!o||(a.prop(nC.contextHash)||0)==s))return e.useNode(a,l),!0;if(!(a instanceof uC)||0==a.children.length||a.positions[0]>0)break;var c=a.children[0];if(!(c instanceof uC&&0==a.positions[0]))break;a=c}var u=i.stateSlot(e.state,4);if(u>0)return e.reduce(u),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););for(var h=this.tokens.getActions(e),f=0;f<h.length;){var d=h[f++],p=h[f++],m=h[f++],g=f==h.length||!n,v=g?e:e.split(),y=this.tokens.mainToken;if(v.apply(d,p,y?y.start:v.pos,m),g)return!0;v.pos>r?t.push(v):n.push(v)}return!1}},{key:"advanceFully",value:function(e,t){for(var n=e.pos;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>n)return MR(e,t),!0}}},{key:"runRecovery",value:function(e,t,n){for(var r=null,i=!1,o=0;o<e.length;o++){var s=e[o],a=t[o<<1],l=t[1+(o<<1)];kR&&this.stackID(s);if(s.deadEnd){if(i)continue;if(i=!0,s.restart(),this.advanceFully(s,n))continue}for(var c=s.split(),u=0;u<10&&c.forceReduce();u++){if(this.advanceFully(c,n))break;kR&&this.stackID(c)+" -> "}var h,f=D(s.recoverByInsert(a));try{for(f.s();!(h=f.n()).done;){var d=h.value;this.advanceFully(d,n)}}catch(e){f.e(e)}finally{f.f()}this.stream.end>s.pos?(l==s.pos&&(l++,a=0),s.recoverByDelete(a,l),MR(s,n)):(!r||r.score<c.score)&&(r=c)}return r}},{key:"stackToTree",value:function(e){return e.close(),uC.build({buffer:fR.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}},{key:"stackID",value:function(e){var t=(xR||(xR=new WeakMap)).get(e);return t||xR.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}}])}();function MR(e,t){for(var n=0;n<t.length;n++){var r=t[n];if(r.pos==e.pos&&r.sameState(e))return void(t[n].score<e.score&&(t[n]=e))}t.push(e)}var OR=function(){return R(function e(t,n,r){N(this,e),this.source=t,this.flags=n,this.disabled=r},[{key:"allows",value:function(e){return!this.disabled||0==this.disabled[e]}}])}(),NR=function(){function e(t){var n,r;if(N(this,e),(r=O(this,e)).wrappers=[],14!=t.version)throw new RangeError("Parser version (".concat(t.version,") doesn't match runtime version (",14,")"));var i=t.nodeNames.split(" ");r.minRepeatTerm=i.length;for(var o=0;o<t.repeatNodeCount;o++)i.push("");for(var s=Object.keys(t.topRules).map(function(e){return t.topRules[e][1]}),a=[],l=0;l<i.length;l++)a.push([]);function c(e,t,n){a[e].push([t,t.deserialize(String(n))])}if(t.nodeProps){var u,h=D(t.nodeProps);try{for(h.s();!(u=h.n()).done;){var f=u.value,d=f[0];"string"==typeof d&&(d=nC[d]);for(var p=1;p<f.length;){var m=f[p++];if(m>=0)c(m,d,f[p++]);else{for(var g=f[p+-m],v=-m;v>0;v--)c(f[p++],d,g);p++}}}}catch(e){h.e(e)}finally{h.f()}}r.nodeSet=new aC(i.map(function(e,n){return oC.define({name:n>=r.minRepeatTerm?void 0:e,id:n,props:a[n],top:s.indexOf(n)>-1,error:0==n,skipped:t.skippedNodes&&t.skippedNodes.indexOf(n)>-1})})),t.propSources&&(r.nodeSet=(n=r.nodeSet).extend.apply(n,K(t.propSources))),r.strict=!1,r.bufferLength=1024;var y=dR(t.tokenData);r.context=t.context,r.specializerSpecs=t.specialized||[],r.specialized=new Uint16Array(r.specializerSpecs.length);for(var b=0;b<r.specializerSpecs.length;b++)r.specialized[b]=r.specializerSpecs[b].term;return r.specializers=r.specializerSpecs.map(RR),r.states=dR(t.states,Uint32Array),r.data=dR(t.stateData),r.goto=dR(t.goto),r.maxTerm=t.maxTerm,r.tokenizers=t.tokenizers.map(function(e){return"number"==typeof e?new vR(y,e):e}),r.topRules=t.topRules,r.dialects=t.dialects||{},r.dynamicPrecedences=t.dynamicPrecedences||null,r.tokenPrecTable=t.tokenPrec,r.termNames=t.termNames||null,r.maxNode=r.nodeSet.types.length-1,r.dialect=r.parseDialect(),r.top=r.topRules[Object.keys(r.topRules)[0]],r}return I(e,TC),R(e,[{key:"createParse",value:function(e,t,n){var r,i=new AR(this,e,t,n),o=D(this.wrappers);try{for(o.s();!(r=o.n()).done;){i=(0,r.value)(i,e,t,n)}}catch(e){o.e(e)}finally{o.f()}return i}},{key:"getGoto",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=this.goto;if(t>=r[0])return-1;for(var i=r[t+1];;){var o=r[i++],s=1&o,a=r[i++];if(s&&n)return a;for(var l=i+(o>>1);i<l;i++)if(r[i]==e)return a;if(s)return-1}}},{key:"hasAction",value:function(e,t){for(var n=this.data,r=0;r<2;r++)for(var i,o=this.stateSlot(e,r?2:1);;o+=3){if(65535==(i=n[o])){if(1!=n[o+1]){if(2==n[o+1])return TR(n,o+2);break}i=n[o=TR(n,o+2)]}if(i==t||0==i)return TR(n,o+1)}return 0}},{key:"stateSlot",value:function(e,t){return this.states[6*e+t]}},{key:"stateFlag",value:function(e,t){return(this.stateSlot(e,0)&t)>0}},{key:"validAction",value:function(e,t){return!!this.allActions(e,function(e){return e==t||null})}},{key:"allActions",value:function(e,t){for(var n=this.stateSlot(e,4),r=n?t(n):void 0,i=this.stateSlot(e,1);null==r;i+=3){if(65535==this.data[i]){if(1!=this.data[i+1])break;i=TR(this.data,i+2)}r=t(TR(this.data,i+1))}return r}},{key:"nextStates",value:function(e){for(var t=this,n=[],r=function(e){if(65535==t.data[e]){if(1!=t.data[e+1])return i=e,1;e=TR(t.data,e+2)}if(!(1&t.data[e+2])){var r=t.data[e+1];n.some(function(e,t){return 1&t&&e==r})||n.push(t.data[e],r)}i=e},i=this.stateSlot(e,1);!r(i);i+=3);return n}},{key:"configure",value:function(t){var n,r=Object.assign(Object.create(e.prototype),this);if(t.props&&(r.nodeSet=(n=this.nodeSet).extend.apply(n,K(t.props))),t.top){var i=this.topRules[t.top];if(!i)throw new RangeError("Invalid top rule name ".concat(t.top));r.top=i}return t.tokenizers&&(r.tokenizers=this.tokenizers.map(function(e){var n=t.tokenizers.find(function(t){return t.from==e});return n?n.to:e})),t.specializers&&(r.specializers=this.specializers.slice(),r.specializerSpecs=this.specializerSpecs.map(function(e,n){var i=t.specializers.find(function(t){return t.from==e.external});if(!i)return e;var o=Object.assign(Object.assign({},e),{external:i.to});return r.specializers[n]=RR(o),o})),t.contextTracker&&(r.context=t.contextTracker),t.dialect&&(r.dialect=this.parseDialect(t.dialect)),null!=t.strict&&(r.strict=t.strict),t.wrap&&(r.wrappers=r.wrappers.concat(t.wrap)),null!=t.bufferLength&&(r.bufferLength=t.bufferLength),r}},{key:"hasWrappers",value:function(){return this.wrappers.length>0}},{key:"getName",value:function(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}},{key:"eofTerm",get:function(){return this.maxNode+1}},{key:"topNode",get:function(){return this.nodeSet.types[this.top[1]]}},{key:"dynamicPrecedence",value:function(e){var t=this.dynamicPrecedences;return null==t?0:t[e]||0}},{key:"parseDialect",value:function(e){var t=Object.keys(this.dialects),n=t.map(function(){return!1});if(e){var r,i=D(e.split(" "));try{for(i.s();!(r=i.n()).done;){var o=r.value,s=t.indexOf(o);s>=0&&(n[s]=!0)}}catch(e){i.e(e)}finally{i.f()}}for(var a=null,l=0;l<t.length;l++)if(!n[l])for(var c,u=this.dialects[t[l]];65535!=(c=this.data[u++]);)(a||(a=new Uint8Array(this.maxTerm+1)))[c]=1;return new OR(e,n,a)}}],[{key:"deserialize",value:function(t){return new e(t)}}])}();function TR(e,t){return e[t]|e[t+1]<<16}function RR(e){if(e.external){var t=e.extend?1:0;return function(n,r){return e.external(n,r)<<1|t}}return e.get}var DR=IC({String:iE.string,Number:iE.number,"True False":iE.bool,PropertyName:iE.propertyName,Null:iE.null,", :":iE.separator,"[ ]":iE.squareBracket,"{ }":iE.brace}),PR=NR.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:"#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O",goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"⚠ JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array",maxTerm:25,nodeProps:[["isolate",-2,6,11,""],["openedBy",7,"{",14,"["],["closedBy",8,"}",15,"]"]],propSources:[DR],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0}),LR=hE.define({name:"json",parser:PR.configure({props:[NE.add({Object:BE({except:/^\s*\}/}),Array:BE({except:/^\s*\]/})}),_E.add({"Object Array":function(e){var t=e.firstChild,n=e.lastChild;return t&&t.to<n.from?{from:t.to,to:n.type.isError?e.to:n.from}:null}})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});let BR=[],IR=[];function _R(e){if(e<768)return!1;for(let t=0,n=BR.length;;){let r=t+n>>1;if(e<BR[r])n=r;else{if(!(e>=IR[r]))return!0;t=r+1}if(t==n)return!1}}function FR(e){return e>=127462&&e<=127487}(()=>{let e="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let t=0,n=0;t<e.length;t++)(t%2?IR:BR).push(n+=e[t])})();function WR(e,t,n=!0,r=!0){return(n?jR:HR)(e,t,r)}function jR(e,t,n){if(t==e.length)return t;t&&VR(e.charCodeAt(t))&&qR(e.charCodeAt(t-1))&&t--;let r=zR(e,t);for(t+=UR(r);t<e.length;){let i=zR(e,t);if(8205==r||8205==i||n&&_R(i))t+=UR(i),r=i;else{if(!FR(i))break;{let n=0,r=t-2;for(;r>=0&&FR(zR(e,r));)n++,r-=2;if(n%2==0)break;t+=2}}}return t}function HR(e,t,n){for(;t>0;){let r=jR(e,t-2,n);if(r<t)return r;t--}return 0}function zR(e,t){let n=e.charCodeAt(t);if(!qR(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return VR(r)?r-56320+(n-55296<<10)+65536:n}function VR(e){return e>=56320&&e<57344}function qR(e){return e>=55296&&e<56320}function UR(e){return e<65536?1:2}class KR{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=tD(this,e,t);let r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(t,this.length,r,1),YR.from(r,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=tD(this,e,t);let n=[];return this.decompose(e,t,n,0),YR.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),r=new JR(this),i=new JR(e);for(let e=t,o=t;;){if(r.next(e),i.next(e),e=0,r.lineBreak!=i.lineBreak||r.done!=i.done||r.value!=i.value)return!1;if(o+=r.value.length,r.done||o>=n)return!0}}iter(e=1){return new JR(this,e)}iterRange(e,t=this.length){return new QR(this,e,t)}iterLines(e,t){let n;if(null==e)n=this.iter();else{null==t&&(t=this.lines+1);let r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new ZR(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(0==e.length)throw new RangeError("A document must have at least one line");return 1!=e.length||e[0]?e.length<=32?new GR(e):YR.from(GR.split(e,[])):KR.empty}}class GR extends KR{constructor(e,t=function(e){let t=-1;for(let n of e)t+=n.length+1;return t}(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,r){for(let i=0;;i++){let o=this.text[i],s=r+o.length;if((t?n:s)>=e)return new eD(r,s,n,o);r=s+1,n++}}decompose(e,t,n,r){let i=e<=0&&t>=this.length?this:new GR(XR(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(1&r){let e=n.pop(),t=$R(i.text,e.text.slice(),0,i.length);if(t.length<=32)n.push(new GR(t,e.length+i.length));else{let e=t.length>>1;n.push(new GR(t.slice(0,e)),new GR(t.slice(e)))}}else n.push(i)}replace(e,t,n){if(!(n instanceof GR))return super.replace(e,t,n);[e,t]=tD(this,e,t);let r=$R(this.text,$R(n.text,XR(this.text,0,e)),t),i=this.length+n.length-(t-e);return r.length<=32?new GR(r,i):YR.from(GR.split(r,[]),i)}sliceString(e,t=this.length,n="\n"){[e,t]=tD(this,e,t);let r="";for(let i=0,o=0;i<=t&&o<this.text.length;o++){let s=this.text[o],a=i+s.length;i>e&&o&&(r+=n),e<a&&t>i&&(r+=s.slice(Math.max(0,e-i),t-i)),i=a+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let n=[],r=-1;for(let i of e)n.push(i),r+=i.length+1,32==n.length&&(t.push(new GR(n,r)),n=[],r=-1);return r>-1&&t.push(new GR(n,r)),t}}class YR extends KR{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let t of e)this.lines+=t.lines}lineInner(e,t,n,r){for(let i=0;;i++){let o=this.children[i],s=r+o.length,a=n+o.lines-1;if((t?a:s)>=e)return o.lineInner(e,t,n,r);r=s+1,n=a+1}}decompose(e,t,n,r){for(let i=0,o=0;o<=t&&i<this.children.length;i++){let s=this.children[i],a=o+s.length;if(e<=a&&t>=o){let i=r&((o<=e?1:0)|(a>=t?2:0));o>=e&&a<=t&&!i?n.push(s):s.decompose(e-o,t-o,n,i)}o=a+1}}replace(e,t,n){if([e,t]=tD(this,e,t),n.lines<this.lines)for(let r=0,i=0;r<this.children.length;r++){let o=this.children[r],s=i+o.length;if(e>=i&&t<=s){let a=o.replace(e-i,t-i,n),l=this.lines-o.lines+a.lines;if(a.lines<l>>4&&a.lines>l>>6){let i=this.children.slice();return i[r]=a,new YR(i,this.length-(t-e)+n.length)}return super.replace(i,s,a)}i=s+1}return super.replace(e,t,n)}sliceString(e,t=this.length,n="\n"){[e,t]=tD(this,e,t);let r="";for(let i=0,o=0;i<this.children.length&&o<=t;i++){let s=this.children[i],a=o+s.length;o>e&&i&&(r+=n),e<a&&t>o&&(r+=s.sliceString(e-o,t-o,n)),o=a+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof YR))return 0;let n=0,[r,i,o,s]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;r+=t,i+=t){if(r==o||i==s)return n;let a=this.children[r],l=e.children[i];if(a!=l)return n+a.scanIdentical(l,t);n+=a.length+1}}static from(e,t=e.reduce((e,t)=>e+t.length+1,-1)){let n=0;for(let t of e)n+=t.lines;if(n<32){let n=[];for(let t of e)t.flatten(n);return new GR(n,t)}let r=Math.max(32,n>>5),i=r<<1,o=r>>1,s=[],a=0,l=-1,c=[];function u(e){let t;if(e.lines>i&&e instanceof YR)for(let t of e.children)u(t);else e.lines>o&&(a>o||!a)?(h(),s.push(e)):e instanceof GR&&a&&(t=c[c.length-1])instanceof GR&&e.lines+t.lines<=32?(a+=e.lines,l+=e.length+1,c[c.length-1]=new GR(t.text.concat(e.text),t.length+1+e.length)):(a+e.lines>r&&h(),a+=e.lines,l+=e.length+1,c.push(e))}function h(){0!=a&&(s.push(1==c.length?c[0]:YR.from(c,l)),l=-1,a=c.length=0)}for(let t of e)u(t);return h(),1==s.length?s[0]:new YR(s,t)}}function $R(e,t,n=0,r=1e9){for(let i=0,o=0,s=!0;o<e.length&&i<=r;o++){let a=e[o],l=i+a.length;l>=n&&(l>r&&(a=a.slice(0,r-i)),i<n&&(a=a.slice(n-i)),s?(t[t.length-1]+=a,s=!1):t.push(a)),i=l+1}return t}function XR(e,t,n){return $R(e,[""],t,n)}KR.empty=new GR([""],0);class JR{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof GR?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,r=this.nodes[n],i=this.offsets[n],o=i>>1,s=r instanceof GR?r.text.length:r.children.length;if(o==(t>0?s:0)){if(0==n)return this.done=!0,this.value="",this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&i)==(t>0?0:1)){if(this.offsets[n]+=t,0==e)return this.lineBreak=!0,this.value="\n",this;e--}else if(r instanceof GR){let i=r.text[o+(t<0?-1:0)];if(this.offsets[n]+=t,i.length>Math.max(0,e))return this.value=0==e?i:t>0?i.slice(e):i.slice(0,i.length-e),this;e-=i.length}else{let i=r.children[o+(t<0?-1:0)];e>i.length?(e-=i.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(i),this.offsets.push(t>0?1:(i instanceof GR?i.text.length:i.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class QR{constructor(e,t,n){this.value="",this.done=!1,this.cursor=new JR(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=n?r:t<0?r.slice(r.length-n):r.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&""!=this.value}}class ZR{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:n,value:r}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):n?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}}"undefined"!=typeof Symbol&&(KR.prototype[Symbol.iterator]=function(){return this.iter()},JR.prototype[Symbol.iterator]=QR.prototype[Symbol.iterator]=ZR.prototype[Symbol.iterator]=function(){return this});class eD{constructor(e,t,n,r){this.from=e,this.to=t,this.number=n,this.text=r}get length(){return this.to-this.from}}function tD(e,t,n){return[t=Math.max(0,Math.min(e.length,t)),Math.max(t,Math.min(e.length,n))]}function nD(e,t,n=!0,r=!0){return WR(e,t,n,r)}const rD=/\r\n?|\n/;var iD=function(e){return e[e.Simple=0]="Simple",e[e.TrackDel=1]="TrackDel",e[e.TrackBefore=2]="TrackBefore",e[e.TrackAfter=3]="TrackAfter",e}(iD||(iD={}));class oD{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t+1];e+=n<0?this.sections[t]:n}return e}get empty(){return 0==this.sections.length||2==this.sections.length&&this.sections[1]<0}iterGaps(e){for(let t=0,n=0,r=0;t<this.sections.length;){let i=this.sections[t++],o=this.sections[t++];o<0?(e(n,r,i),r+=i):r+=o,n+=i}}iterChangedRanges(e,t=!1){cD(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let n=this.sections[t++],r=this.sections[t++];r<0?e.push(n,r):e.push(r,n)}return new oD(e)}composeDesc(e){return this.empty?e:e.empty?this:hD(this,e)}mapDesc(e,t=!1){return e.empty?this:uD(this,e,t)}mapPos(e,t=-1,n=iD.Simple){let r=0,i=0;for(let o=0;o<this.sections.length;){let s=this.sections[o++],a=this.sections[o++],l=r+s;if(a<0){if(l>e)return i+(e-r);i+=s}else{if(n!=iD.Simple&&l>=e&&(n==iD.TrackDel&&r<e&&l>e||n==iD.TrackBefore&&r<e||n==iD.TrackAfter&&l>e))return null;if(l>e||l==e&&t<0&&!s)return e==r||t<0?i:i+a;i+=a}r=l}if(e>r)throw new RangeError(`Position ${e} is out of range for changeset of length ${r}`);return i}touchesRange(e,t=e){for(let n=0,r=0;n<this.sections.length&&r<=t;){let i=r+this.sections[n++];if(this.sections[n++]>=0&&r<=t&&i>=e)return!(r<e&&i>t)||"cover";r=i}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let n=this.sections[t++],r=this.sections[t++];e+=(e?" ":"")+n+(r>=0?":"+r:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(e=>"number"!=typeof e))throw new RangeError("Invalid JSON representation of ChangeDesc");return new oD(e)}static create(e){return new oD(e)}}class sD extends oD{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return cD(this,(t,n,r,i,o)=>e=e.replace(r,r+(n-t),o),!1),e}mapDesc(e,t=!1){return uD(this,e,t,!0)}invert(e){let t=this.sections.slice(),n=[];for(let r=0,i=0;r<t.length;r+=2){let o=t[r],s=t[r+1];if(s>=0){t[r]=s,t[r+1]=o;let a=r>>1;for(;n.length<a;)n.push(KR.empty);n.push(o?e.slice(i,i+o):KR.empty)}i+=o}return new sD(t,n)}compose(e){return this.empty?e:e.empty?this:hD(this,e,!0)}map(e,t=!1){return e.empty?this:uD(this,e,t,!0)}iterChanges(e,t=!1){cD(this,e,t)}get desc(){return oD.create(this.sections)}filter(e){let t=[],n=[],r=[],i=new fD(this);e:for(let o=0,s=0;;){let a=o==e.length?1e9:e[o++];for(;s<a||s==a&&0==i.len;){if(i.done)break e;let e=Math.min(i.len,a-s);aD(r,e,-1);let o=-1==i.ins?-1:0==i.off?i.ins:0;aD(t,e,o),o>0&&lD(n,t,i.text),i.forward(e),s+=e}let l=e[o++];for(;s<l;){if(i.done)break e;let e=Math.min(i.len,l-s);aD(t,e,-1),aD(r,e,-1==i.ins?-1:0==i.off?i.ins:0),i.forward(e),s+=e}}return{changes:new sD(t,n),filtered:oD.create(r)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t],r=this.sections[t+1];r<0?e.push(n):0==r?e.push([n]):e.push([n].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,n){let r=[],i=[],o=0,s=null;function a(e=!1){if(!e&&!r.length)return;o<t&&aD(r,t-o,-1);let n=new sD(r,i);s=s?s.compose(n.map(s)):n,r=[],i=[],o=0}return function e(l){if(Array.isArray(l))for(let t of l)e(t);else if(l instanceof sD){if(l.length!=t)throw new RangeError(`Mismatched change set length (got ${l.length}, expected ${t})`);a(),s=s?s.compose(l.map(s)):l}else{let{from:e,to:s=e,insert:c}=l;if(e>s||e<0||s>t)throw new RangeError(`Invalid change range ${e} to ${s} (in doc of length ${t})`);let u=c?"string"==typeof c?KR.of(c.split(n||rD)):c:KR.empty,h=u.length;if(e==s&&0==h)return;e<o&&a(),e>o&&aD(r,e-o,-1),aD(r,s-e,h),lD(i,r,u),o=s}}(e),a(!s),s}static empty(e){return new sD(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],n=[];for(let r=0;r<e.length;r++){let i=e[r];if("number"==typeof i)t.push(i,-1);else{if(!Array.isArray(i)||"number"!=typeof i[0]||i.some((e,t)=>t&&"string"!=typeof e))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==i.length)t.push(i[0],0);else{for(;n.length<r;)n.push(KR.empty);n[r]=KR.of(i.slice(1)),t.push(i[0],n[r].length)}}}return new sD(t,n)}static createSet(e,t){return new sD(e,t)}}function aD(e,t,n,r=!1){if(0==t&&n<=0)return;let i=e.length-2;i>=0&&n<=0&&n==e[i+1]?e[i]+=t:i>=0&&0==t&&0==e[i]?e[i+1]+=n:r?(e[i]+=t,e[i+1]+=n):e.push(t,n)}function lD(e,t,n){if(0==n.length)return;let r=t.length-2>>1;if(r<e.length)e[e.length-1]=e[e.length-1].append(n);else{for(;e.length<r;)e.push(KR.empty);e.push(n)}}function cD(e,t,n){let r=e.inserted;for(let i=0,o=0,s=0;s<e.sections.length;){let a=e.sections[s++],l=e.sections[s++];if(l<0)i+=a,o+=a;else{let c=i,u=o,h=KR.empty;for(;c+=a,u+=l,l&&r&&(h=h.append(r[s-2>>1])),!(n||s==e.sections.length||e.sections[s+1]<0);)a=e.sections[s++],l=e.sections[s++];t(i,c,o,u,h),i=c,o=u}}}function uD(e,t,n,r=!1){let i=[],o=r?[]:null,s=new fD(e),a=new fD(t);for(let e=-1;;){if(s.done&&a.len||a.done&&s.len)throw new Error("Mismatched change set lengths");if(-1==s.ins&&-1==a.ins){let e=Math.min(s.len,a.len);aD(i,e,-1),s.forward(e),a.forward(e)}else if(a.ins>=0&&(s.ins<0||e==s.i||0==s.off&&(a.len<s.len||a.len==s.len&&!n))){let t=a.len;for(aD(i,a.ins,-1);t;){let n=Math.min(s.len,t);s.ins>=0&&e<s.i&&s.len<=n&&(aD(i,0,s.ins),o&&lD(o,i,s.text),e=s.i),s.forward(n),t-=n}a.next()}else{if(!(s.ins>=0)){if(s.done&&a.done)return o?sD.createSet(i,o):oD.create(i);throw new Error("Mismatched change set lengths")}{let t=0,n=s.len;for(;n;)if(-1==a.ins){let e=Math.min(n,a.len);t+=e,n-=e,a.forward(e)}else{if(!(0==a.ins&&a.len<n))break;n-=a.len,a.next()}aD(i,t,e<s.i?s.ins:0),o&&e<s.i&&lD(o,i,s.text),e=s.i,s.forward(s.len-n)}}}}function hD(e,t,n=!1){let r=[],i=n?[]:null,o=new fD(e),s=new fD(t);for(let e=!1;;){if(o.done&&s.done)return i?sD.createSet(r,i):oD.create(r);if(0==o.ins)aD(r,o.len,0,e),o.next();else if(0!=s.len||s.done){if(o.done||s.done)throw new Error("Mismatched change set lengths");{let t=Math.min(o.len2,s.len),n=r.length;if(-1==o.ins){let n=-1==s.ins?-1:s.off?0:s.ins;aD(r,t,n,e),i&&n&&lD(i,r,s.text)}else-1==s.ins?(aD(r,o.off?0:o.len,t,e),i&&lD(i,r,o.textBit(t))):(aD(r,o.off?0:o.len,s.off?0:s.ins,e),i&&!s.off&&lD(i,r,s.text));e=(o.ins>t||s.ins>=0&&s.len>t)&&(e||r.length>n),o.forward2(t),s.forward(t)}}else aD(r,0,s.ins,e),i&&lD(i,r,s.text),s.next()}}class fD{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return-2==this.ins}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?KR.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?KR.empty:t[n].slice(this.off,null==e?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){-1==this.ins?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class dD{constructor(e,t,n){this.from=e,this.to=t,this.flags=n}get anchor(){return 32&this.flags?this.to:this.from}get head(){return 32&this.flags?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return 8&this.flags?-1:16&this.flags?1:0}get bidiLevel(){let e=7&this.flags;return 7==e?null:e}get goalColumn(){let e=this.flags>>6;return 16777215==e?void 0:e}map(e,t=-1){let n,r;return this.empty?n=r=e.mapPos(this.from,t):(n=e.mapPos(this.from,1),r=e.mapPos(this.to,-1)),n==this.from&&r==this.to?this:new dD(n,r,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return pD.range(e,t);let n=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return pD.range(this.anchor,n)}eq(e,t=!1){return!(this.anchor!=e.anchor||this.head!=e.head||this.goalColumn!=e.goalColumn||t&&this.empty&&this.assoc!=e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||"number"!=typeof e.anchor||"number"!=typeof e.head)throw new RangeError("Invalid JSON representation for SelectionRange");return pD.range(e.anchor,e.head)}static create(e,t,n){return new dD(e,t,n)}}class pD{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:pD.create(this.ranges.map(n=>n.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return 1==this.ranges.length?this:new pD([this.main],0)}addRange(e,t=!0){return pD.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let n=this.ranges.slice();return n[t]=e,pD.create(n,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||"number"!=typeof e.main||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new pD(e.ranges.map(e=>dD.fromJSON(e)),e.main)}static single(e,t=e){return new pD([pD.range(e,t)],0)}static create(e,t=0){if(0==e.length)throw new RangeError("A selection needs at least one range");for(let n=0,r=0;r<e.length;r++){let i=e[r];if(i.empty?i.from<=n:i.from<n)return pD.normalized(e.slice(),t);n=i.to}return new pD(e,t)}static cursor(e,t=0,n,r){return dD.create(e,e,(0==t?0:t<0?8:16)|(null==n?7:Math.min(6,n))|(null!=r?r:16777215)<<6)}static range(e,t,n,r){let i=(null!=n?n:16777215)<<6|(null==r?7:Math.min(6,r));return t<e?dD.create(t,e,48|i):dD.create(e,t,(t>e?8:0)|i)}static normalized(e,t=0){let n=e[t];e.sort((e,t)=>e.from-t.from),t=e.indexOf(n);for(let n=1;n<e.length;n++){let r=e[n],i=e[n-1];if(r.empty?r.from<=i.to:r.from<i.to){let o=i.from,s=Math.max(r.to,i.to);n<=t&&t--,e.splice(--n,2,r.anchor>r.head?pD.range(s,o):pD.range(o,s))}}return new pD(e,t)}}function mD(e,t){for(let n of e.ranges)if(n.to>t)throw new RangeError("Selection points outside of document")}let gD=0;class vD{constructor(e,t,n,r,i){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=r,this.id=gD++,this.default=e([]),this.extensions="function"==typeof i?i(this):i}get reader(){return this}static define(e={}){return new vD(e.combine||(e=>e),e.compareInput||((e,t)=>e===t),e.compare||(e.combine?(e,t)=>e===t:yD),!!e.static,e.enables)}of(e){return new bD([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new bD(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new bD(e,this,2,t)}from(e,t){return t||(t=e=>e),this.compute([e],n=>t(n.field(e)))}}function yD(e,t){return e==t||e.length==t.length&&e.every((e,n)=>e===t[n])}class bD{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=gD++}dynamicSlot(e){var t;let n=this.value,r=this.facet.compareInput,i=this.id,o=e[i]>>1,s=2==this.type,a=!1,l=!1,c=[];for(let n of this.dependencies)"doc"==n?a=!0:"selection"==n?l=!0:1&(null!==(t=e[n.id])&&void 0!==t?t:1)||c.push(e[n.id]);return{create:e=>(e.values[o]=n(e),1),update(e,t){if(a&&t.docChanged||l&&(t.docChanged||t.selection)||kD(e,c)){let t=n(e);if(s?!wD(t,e.values[o],r):!r(t,e.values[o]))return e.values[o]=t,1}return 0},reconfigure:(e,t)=>{let a,l=t.config.address[i];if(null!=l){let i=ID(t,l);if(this.dependencies.every(n=>n instanceof vD?t.facet(n)===e.facet(n):!(n instanceof CD)||t.field(n,!1)==e.field(n,!1))||(s?wD(a=n(e),i,r):r(a=n(e),i)))return e.values[o]=i,0}else a=n(e);return e.values[o]=a,1}}}}function wD(e,t,n){if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!n(e[r],t[r]))return!1;return!0}function kD(e,t){let n=!1;for(let r of t)1&BD(e,r)&&(n=!0);return n}function xD(e,t,n){let r=n.map(t=>e[t.id]),i=n.map(e=>e.type),o=r.filter(e=>!(1&e)),s=e[t.id]>>1;function a(e){let n=[];for(let t=0;t<r.length;t++){let o=ID(e,r[t]);if(2==i[t])for(let e of o)n.push(e);else n.push(o)}return t.combine(n)}return{create(e){for(let t of r)BD(e,t);return e.values[s]=a(e),1},update(e,n){if(!kD(e,o))return 0;let r=a(e);return t.compare(r,e.values[s])?0:(e.values[s]=r,1)},reconfigure(e,i){let o=kD(e,r),l=i.config.facets[t.id],c=i.facet(t);if(l&&!o&&yD(n,l))return e.values[s]=c,0;let u=a(e);return t.compare(u,c)?(e.values[s]=c,0):(e.values[s]=u,1)}}}const SD=vD.define({static:!0});class CD{constructor(e,t,n,r,i){this.id=e,this.createF=t,this.updateF=n,this.compareF=r,this.spec=i,this.provides=void 0}static define(e){let t=new CD(gD++,e.create,e.update,e.compare||((e,t)=>e===t),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(SD).find(e=>e.field==this);return((null==t?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:e=>(e.values[t]=this.create(e),1),update:(e,n)=>{let r=e.values[t],i=this.updateF(r,n);return this.compareF(r,i)?0:(e.values[t]=i,1)},reconfigure:(e,n)=>{let r,i=e.facet(SD),o=n.facet(SD);return(r=i.find(e=>e.field==this))&&r!=o.find(e=>e.field==this)?(e.values[t]=r.create(e),1):null!=n.config.address[this.id]?(e.values[t]=n.field(this),0):(e.values[t]=this.create(e),1)}}}init(e){return[this,SD.of({field:this,create:e})]}get extension(){return this}}const ED=4,AD=3,MD=2,OD=1;function ND(e){return t=>new RD(t,e)}const TD={highest:ND(0),high:ND(OD),default:ND(MD),low:ND(AD),lowest:ND(ED)};class RD{constructor(e,t){this.inner=e,this.prec=t}}class DD{of(e){return new PD(this,e)}reconfigure(e){return DD.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class PD{constructor(e,t){this.compartment=e,this.inner=t}}class LD{constructor(e,t,n,r,i,o){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=r,this.staticValues=i,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return null==t?e.default:this.staticValues[t>>1]}static resolve(e,t,n){let r=[],i=Object.create(null),o=new Map;for(let n of function(e,t,n){let r=[[],[],[],[],[]],i=new Map;function o(e,s){let a=i.get(e);if(null!=a){if(a<=s)return;let t=r[a].indexOf(e);t>-1&&r[a].splice(t,1),e instanceof PD&&n.delete(e.compartment)}if(i.set(e,s),Array.isArray(e))for(let t of e)o(t,s);else if(e instanceof PD){if(n.has(e.compartment))throw new RangeError("Duplicate use of compartment in extensions");let r=t.get(e.compartment)||e.inner;n.set(e.compartment,r),o(r,s)}else if(e instanceof RD)o(e.inner,e.prec);else if(e instanceof CD)r[s].push(e),e.provides&&o(e.provides,s);else if(e instanceof bD)r[s].push(e),e.facet.extensions&&o(e.facet.extensions,MD);else{let t=e.extension;if(!t)throw new Error(`Unrecognized extension value in extension set (${e}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);o(t,s)}}return o(e,MD),r.reduce((e,t)=>e.concat(t))}(e,t,o))n instanceof CD?r.push(n):(i[n.facet.id]||(i[n.facet.id]=[])).push(n);let s=Object.create(null),a=[],l=[];for(let e of r)s[e.id]=l.length<<1,l.push(t=>e.slot(t));let c=null==n?void 0:n.config.facets;for(let e in i){let t=i[e],r=t[0].facet,o=c&&c[e]||[];if(t.every(e=>0==e.type))if(s[r.id]=a.length<<1|1,yD(o,t))a.push(n.facet(r));else{let e=r.combine(t.map(e=>e.value));a.push(n&&r.compare(e,n.facet(r))?n.facet(r):e)}else{for(let e of t)0==e.type?(s[e.id]=a.length<<1|1,a.push(e.value)):(s[e.id]=l.length<<1,l.push(t=>e.dynamicSlot(t)));s[r.id]=l.length<<1,l.push(e=>xD(e,r,t))}}let u=l.map(e=>e(s));return new LD(e,o,u,s,a,i)}}function BD(e,t){if(1&t)return 2;let n=t>>1,r=e.status[n];if(4==r)throw new Error("Cyclic dependency between fields and/or facets");if(2&r)return r;e.status[n]=4;let i=e.computeSlot(e,e.config.dynamicSlots[n]);return e.status[n]=2|i}function ID(e,t){return 1&t?e.config.staticValues[t>>1]:e.values[t>>1]}const _D=vD.define(),FD=vD.define({combine:e=>e.some(e=>e),static:!0}),WD=vD.define({combine:e=>e.length?e[0]:void 0,static:!0}),jD=vD.define(),HD=vD.define(),zD=vD.define(),VD=vD.define({combine:e=>!!e.length&&e[0]});class qD{constructor(e,t){this.type=e,this.value=t}static define(){return new UD}}class UD{of(e){return new qD(this,e)}}class KD{constructor(e){this.map=e}of(e){return new GD(this,e)}}class GD{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return void 0===t?void 0:t==this.value?this:new GD(this.type,t)}is(e){return this.type==e}static define(e={}){return new KD(e.map||(e=>e))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let r of e){let e=r.map(t);e&&n.push(e)}return n}}GD.reconfigure=GD.define(),GD.appendConfig=GD.define();class YD{constructor(e,t,n,r,i,o){this.startState=e,this.changes=t,this.selection=n,this.effects=r,this.annotations=i,this.scrollIntoView=o,this._doc=null,this._state=null,n&&mD(n,t.newLength),i.some(e=>e.type==YD.time)||(this.annotations=i.concat(YD.time.of(Date.now())))}static create(e,t,n,r,i,o){return new YD(e,t,n,r,i,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(YD.userEvent);return!(!t||!(t==e||t.length>e.length&&t.slice(0,e.length)==e&&"."==t[e.length]))}}function $D(e,t){let n=[];for(let r=0,i=0;;){let o,s;if(r<e.length&&(i==t.length||t[i]>=e[r]))o=e[r++],s=e[r++];else{if(!(i<t.length))return n;o=t[i++],s=t[i++]}!n.length||n[n.length-1]<o?n.push(o,s):n[n.length-1]<s&&(n[n.length-1]=s)}}function XD(e,t,n){var r;let i,o,s;return n?(i=t.changes,o=sD.empty(t.changes.length),s=e.changes.compose(t.changes)):(i=t.changes.map(e.changes),o=e.changes.mapDesc(t.changes,!0),s=e.changes.compose(i)),{changes:s,selection:t.selection?t.selection.map(o):null===(r=e.selection)||void 0===r?void 0:r.map(i),effects:GD.mapEffects(e.effects,i).concat(GD.mapEffects(t.effects,o)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function JD(e,t,n){let r=t.selection,i=eP(t.annotations);return t.userEvent&&(i=i.concat(YD.userEvent.of(t.userEvent))),{changes:t.changes instanceof sD?t.changes:sD.of(t.changes||[],n,e.facet(WD)),selection:r&&(r instanceof pD?r:pD.single(r.anchor,r.head)),effects:eP(t.effects),annotations:i,scrollIntoView:!!t.scrollIntoView}}function QD(e,t,n){let r=JD(e,t.length?t[0]:{},e.doc.length);t.length&&!1===t[0].filter&&(n=!1);for(let i=1;i<t.length;i++){!1===t[i].filter&&(n=!1);let o=!!t[i].sequential;r=XD(r,JD(e,t[i],o?r.changes.newLength:e.doc.length),o)}let i=YD.create(e,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return function(e){let t=e.startState,n=t.facet(zD),r=e;for(let i=n.length-1;i>=0;i--){let o=n[i](e);o&&Object.keys(o).length&&(r=XD(r,JD(t,o,e.changes.newLength),!0))}return r==e?e:YD.create(t,e.changes,e.selection,r.effects,r.annotations,r.scrollIntoView)}(n?function(e){let t=e.startState,n=!0;for(let r of t.facet(jD)){let t=r(e);if(!1===t){n=!1;break}Array.isArray(t)&&(n=!0===n?t:$D(n,t))}if(!0!==n){let r,i;if(!1===n)i=e.changes.invertedDesc,r=sD.empty(t.doc.length);else{let t=e.changes.filter(n);r=t.changes,i=t.filtered.mapDesc(t.changes).invertedDesc}e=YD.create(t,r,e.selection&&e.selection.map(i),GD.mapEffects(e.effects,i),e.annotations,e.scrollIntoView)}let r=t.facet(HD);for(let n=r.length-1;n>=0;n--){let i=r[n](e);e=i instanceof YD?i:Array.isArray(i)&&1==i.length&&i[0]instanceof YD?i[0]:QD(t,eP(i),!1)}return e}(i):i)}YD.time=qD.define(),YD.userEvent=qD.define(),YD.addToHistory=qD.define(),YD.remote=qD.define();const ZD=[];function eP(e){return null==e?ZD:Array.isArray(e)?e:[e]}var tP=function(e){return e[e.Word=0]="Word",e[e.Space=1]="Space",e[e.Other=2]="Other",e}(tP||(tP={}));const nP=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let rP;try{rP=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(e){}function iP(e){return t=>{if(!/\S/.test(t))return tP.Space;if(function(e){if(rP)return rP.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>"€"&&(n.toUpperCase()!=n.toLowerCase()||nP.test(n)))return!0}return!1}(t))return tP.Word;for(let n=0;n<e.length;n++)if(t.indexOf(e[n])>-1)return tP.Word;return tP.Other}}class oP{constructor(e,t,n,r,i,o){this.config=e,this.doc=t,this.selection=n,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=i,o&&(o._state=this);for(let e=0;e<this.config.dynamicSlots.length;e++)BD(this,e<<1);this.computeSlot=null}field(e,t=!0){let n=this.config.address[e.id];if(null!=n)return BD(this,n),ID(this,n);if(t)throw new RangeError("Field is not present in this state")}update(...e){return QD(this,e,!0)}applyTransaction(e){let t,n=this.config,{base:r,compartments:i}=n;for(let t of e.effects)t.is(DD.reconfigure)?(n&&(i=new Map,n.compartments.forEach((e,t)=>i.set(t,e)),n=null),i.set(t.value.compartment,t.value.extension)):t.is(GD.reconfigure)?(n=null,r=t.value):t.is(GD.appendConfig)&&(n=null,r=eP(r).concat(t.value));if(n)t=e.startState.values.slice();else{n=LD.resolve(r,i,this);let e=new oP(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(e,t)=>t.reconfigure(e,this),null);t=e.values}let o=e.startState.facet(FD)?e.newSelection:e.newSelection.asSingle();new oP(n,e.newDoc,o,t,(t,n)=>n.update(t,e),e)}replaceSelection(e){return"string"==typeof e&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:pD.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),r=this.changes(n.changes),i=[n.range],o=eP(n.effects);for(let n=1;n<t.ranges.length;n++){let s=e(t.ranges[n]),a=this.changes(s.changes),l=a.map(r);for(let e=0;e<n;e++)i[e]=i[e].map(l);let c=r.mapDesc(a,!0);i.push(s.range.map(c)),r=r.compose(l),o=GD.mapEffects(o,l).concat(GD.mapEffects(eP(s.effects),c))}return{changes:r,selection:pD.create(i,t.mainIndex),effects:o}}changes(e=[]){return e instanceof sD?e:sD.of(e,this.doc.length,this.facet(oP.lineSeparator))}toText(e){return KR.of(e.split(this.facet(oP.lineSeparator)||rD))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return null==t?e.default:(BD(this,t),ID(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let r=e[n];r instanceof CD&&null!=this.config.address[r.id]&&(t[n]=r.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(e,t={},n){if(!e||"string"!=typeof e.doc)throw new RangeError("Invalid JSON representation for EditorState");let r=[];if(n)for(let t in n)if(Object.prototype.hasOwnProperty.call(e,t)){let i=n[t],o=e[t];r.push(i.init(e=>i.spec.fromJSON(o,e)))}return oP.create({doc:e.doc,selection:pD.fromJSON(e.selection),extensions:t.extensions?r.concat([t.extensions]):r})}static create(e={}){let t=LD.resolve(e.extensions||[],new Map),n=e.doc instanceof KR?e.doc:KR.of((e.doc||"").split(t.staticFacet(oP.lineSeparator)||rD)),r=e.selection?e.selection instanceof pD?e.selection:pD.single(e.selection.anchor,e.selection.head):pD.single(0);return mD(r,n.length),t.staticFacet(FD)||(r=r.asSingle()),new oP(t,n,r,t.dynamicSlots.map(()=>null),(e,t)=>t.create(e),null)}get tabSize(){return this.facet(oP.tabSize)}get lineBreak(){return this.facet(oP.lineSeparator)||"\n"}get readOnly(){return this.facet(VD)}phrase(e,...t){for(let t of this.facet(oP.phrases))if(Object.prototype.hasOwnProperty.call(t,e)){e=t[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(e,n)=>{if("$"==n)return"$";let r=+(n||1);return!r||r>t.length?e:t[r-1]})),e}languageDataAt(e,t,n=-1){let r=[];for(let i of this.facet(_D))for(let o of i(this,t,n))Object.prototype.hasOwnProperty.call(o,e)&&r.push(o[e]);return r}charCategorizer(e){let t=this.languageDataAt("wordChars",e);return iP(t.length?t[0]:"")}wordAt(e){let{text:t,from:n,length:r}=this.doc.lineAt(e),i=this.charCategorizer(e),o=e-n,s=e-n;for(;o>0;){let e=nD(t,o,!1);if(i(t.slice(e,o))!=tP.Word)break;o=e}for(;s<r;){let e=nD(t,s);if(i(t.slice(s,e))!=tP.Word)break;s=e}return o==s?null:pD.range(o+n,s+n)}}oP.allowMultipleSelections=FD,oP.tabSize=vD.define({combine:e=>e.length?e[0]:4}),oP.lineSeparator=WD,oP.readOnly=VD,oP.phrases=vD.define({compare(e,t){let n=Object.keys(e),r=Object.keys(t);return n.length==r.length&&n.every(n=>e[n]==t[n])}}),oP.languageData=_D,oP.changeFilter=jD,oP.transactionFilter=HD,oP.transactionExtender=zD,DD.reconfigure=GD.define();class sP{eq(e){return this==e}range(e,t=e){return lP.create(e,t,this)}}function aP(e,t){return e==t||e.constructor==t.constructor&&e.eq(t)}sP.prototype.startSide=sP.prototype.endSide=0,sP.prototype.point=!1,sP.prototype.mapMode=iD.TrackDel;class lP{constructor(e,t,n){this.from=e,this.to=t,this.value=n}static create(e,t,n){return new lP(e,t,n)}}function cP(e,t){return e.from-t.from||e.value.startSide-t.value.startSide}class uP{constructor(e,t,n,r){this.from=e,this.to=t,this.value=n,this.maxPoint=r}get length(){return this.to[this.to.length-1]}findIndex(e,t,n,r=0){let i=n?this.to:this.from;for(let o=r,s=i.length;;){if(o==s)return o;let r=o+s>>1,a=i[r]-e||(n?this.value[r].endSide:this.value[r].startSide)-t;if(r==o)return a>=0?o:s;a>=0?s=r:o=r+1}}between(e,t,n,r){for(let i=this.findIndex(t,-1e9,!0),o=this.findIndex(n,1e9,!1,i);i<o;i++)if(!1===r(this.from[i]+e,this.to[i]+e,this.value[i]))return!1}map(e,t){let n=[],r=[],i=[],o=-1,s=-1;for(let a=0;a<this.value.length;a++){let l,c,u=this.value[a],h=this.from[a]+e,f=this.to[a]+e;if(h==f){let e=t.mapPos(h,u.startSide,u.mapMode);if(null==e)continue;if(l=c=e,u.startSide!=u.endSide&&(c=t.mapPos(h,u.endSide),c<l))continue}else if(l=t.mapPos(h,u.startSide),c=t.mapPos(f,u.endSide),l>c||l==c&&u.startSide>0&&u.endSide<=0)continue;(c-l||u.endSide-u.startSide)<0||(o<0&&(o=l),u.point&&(s=Math.max(s,c-l)),n.push(u),r.push(l-o),i.push(c-o))}return{mapped:n.length?new uP(r,i,n,s):null,pos:o}}}class hP{constructor(e,t,n,r){this.chunkPos=e,this.chunk=t,this.nextLayer=n,this.maxPoint=r}static create(e,t,n,r){return new hP(e,t,n,r)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:n=!1,filterFrom:r=0,filterTo:i=this.length}=e,o=e.filter;if(0==t.length&&!o)return this;if(n&&(t=t.slice().sort(cP)),this.isEmpty)return t.length?hP.of(t):this;let s=new pP(this,null,-1).goto(0),a=0,l=[],c=new fP;for(;s.value||a<t.length;)if(a<t.length&&(s.from-t[a].from||s.startSide-t[a].value.startSide)>=0){let e=t[a++];c.addInner(e.from,e.to,e.value)||l.push(e)}else 1==s.rangeIndex&&s.chunkIndex<this.chunk.length&&(a==t.length||this.chunkEnd(s.chunkIndex)<t[a].from)&&(!o||r>this.chunkEnd(s.chunkIndex)||i<this.chunkPos[s.chunkIndex])&&c.addChunk(this.chunkPos[s.chunkIndex],this.chunk[s.chunkIndex])?s.nextChunk():((!o||r>s.to||i<s.from||o(s.from,s.to,s.value))&&(c.addInner(s.from,s.to,s.value)||l.push(lP.create(s.from,s.to,s.value))),s.next());return c.finishInner(this.nextLayer.isEmpty&&!l.length?hP.empty:this.nextLayer.update({add:l,filter:o,filterFrom:r,filterTo:i}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],n=[],r=-1;for(let i=0;i<this.chunk.length;i++){let o=this.chunkPos[i],s=this.chunk[i],a=e.touchesRange(o,o+s.length);if(!1===a)r=Math.max(r,s.maxPoint),t.push(s),n.push(e.mapPos(o));else if(!0===a){let{mapped:i,pos:a}=s.map(o,e);i&&(r=Math.max(r,i.maxPoint),t.push(i),n.push(a))}}let i=this.nextLayer.map(e);return 0==t.length?i:new hP(n,t,i||hP.empty,r)}between(e,t,n){if(!this.isEmpty){for(let r=0;r<this.chunk.length;r++){let i=this.chunkPos[r],o=this.chunk[r];if(t>=i&&e<=i+o.length&&!1===o.between(i,e-i,t-i,n))return}this.nextLayer.between(e,t,n)}}iter(e=0){return mP.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return mP.from(e).goto(t)}static compare(e,t,n,r,i=-1){let o=e.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=i),s=t.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=i),a=dP(o,s,n),l=new vP(o,a,i),c=new vP(s,a,i);n.iterGaps((e,t,n)=>yP(l,e,c,t,n,r)),n.empty&&0==n.length&&yP(l,0,c,0,0,r)}static eq(e,t,n=0,r){null==r&&(r=999999999);let i=e.filter(e=>!e.isEmpty&&t.indexOf(e)<0),o=t.filter(t=>!t.isEmpty&&e.indexOf(t)<0);if(i.length!=o.length)return!1;if(!i.length)return!0;let s=dP(i,o),a=new vP(i,s,0).goto(n),l=new vP(o,s,0).goto(n);for(;;){if(a.to!=l.to||!bP(a.active,l.active)||a.point&&(!l.point||!aP(a.point,l.point)))return!1;if(a.to>r)return!0;a.next(),l.next()}}static spans(e,t,n,r,i=-1){let o=new vP(e,null,i).goto(t),s=t,a=o.openStart;for(;;){let e=Math.min(o.to,n);if(o.point){let n=o.activeForPoint(o.to),i=o.pointFrom<t?n.length+1:o.point.startSide<0?n.length:Math.min(n.length,a);r.point(s,e,o.point,n,i,o.pointRank),a=Math.min(o.openEnd(e),n.length)}else e>s&&(r.span(s,e,o.active,a),a=o.openEnd(e));if(o.to>n)return a+(o.point&&o.to>n?1:0);s=o.to,o.next()}}static of(e,t=!1){let n=new fP;for(let r of e instanceof lP?[e]:t?function(e){if(e.length>1)for(let t=e[0],n=1;n<e.length;n++){let r=e[n];if(cP(t,r)>0)return e.slice().sort(cP);t=r}return e}(e):e)n.add(r.from,r.to,r.value);return n.finish()}static join(e){if(!e.length)return hP.empty;let t=e[e.length-1];for(let n=e.length-2;n>=0;n--)for(let r=e[n];r!=hP.empty;r=r.nextLayer)t=new hP(r.chunkPos,r.chunk,t,Math.max(r.maxPoint,t.maxPoint));return t}}hP.empty=new hP([],[],null,-1),hP.empty.nextLayer=hP.empty;class fP{finishChunk(e){this.chunks.push(new uP(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,n){this.addInner(e,t,n)||(this.nextLayer||(this.nextLayer=new fP)).add(e,t,n)}addInner(e,t,n){let r=e-this.lastTo||n.startSide-this.last.endSide;if(r<=0&&(e-this.lastFrom||n.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return!(r<0)&&(250==this.from.length&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=n,this.lastFrom=e,this.lastTo=t,this.value.push(n),n.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let n=t.value.length-1;return this.last=t.value[n],this.lastFrom=t.from[n]+e,this.lastTo=t.to[n]+e,!0}finish(){return this.finishInner(hP.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return e;let t=hP.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function dP(e,t,n){let r=new Map;for(let t of e)for(let e=0;e<t.chunk.length;e++)t.chunk[e].maxPoint<=0&&r.set(t.chunk[e],t.chunkPos[e]);let i=new Set;for(let e of t)for(let t=0;t<e.chunk.length;t++){let o=r.get(e.chunk[t]);null==o||(n?n.mapPos(o):o)!=e.chunkPos[t]||(null==n?void 0:n.touchesRange(o,o+e.chunk[t].length))||i.add(e.chunk[t])}return i}class pP{constructor(e,t,n,r=0){this.layer=e,this.skip=t,this.minPoint=n,this.rank=r}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,n){for(;this.chunkIndex<this.layer.chunk.length;){let t=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(t)||this.layer.chunkEnd(this.chunkIndex)<e||t.maxPoint<this.minPoint))break;this.chunkIndex++,n=!1}if(this.chunkIndex<this.layer.chunk.length){let r=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!n||this.rangeIndex<r)&&this.setRangeIndex(r)}this.next()}forward(e,t){(this.to-e||this.endSide-t)<0&&this.gotoInner(e,t,!0)}next(){for(;;){if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],n=e+t.from[this.rangeIndex];if(this.from=n,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}}class mP{constructor(e){this.heap=e}static from(e,t=null,n=-1){let r=[];for(let i=0;i<e.length;i++)for(let o=e[i];!o.isEmpty;o=o.nextLayer)o.maxPoint>=n&&r.push(new pP(o,t,n,i));return 1==r.length?r[0]:new mP(r)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let n of this.heap)n.goto(e,t);for(let e=this.heap.length>>1;e>=0;e--)gP(this.heap,e);return this.next(),this}forward(e,t){for(let n of this.heap)n.forward(e,t);for(let e=this.heap.length>>1;e>=0;e--)gP(this.heap,e);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(0==this.heap.length)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),gP(this.heap,0)}}}function gP(e,t){for(let n=e[t];;){let r=1+(t<<1);if(r>=e.length)break;let i=e[r];if(r+1<e.length&&i.compare(e[r+1])>=0&&(i=e[r+1],r++),n.compare(i)<0)break;e[r]=n,e[t]=i,t=r}}class vP{constructor(e,t,n){this.minPoint=n,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=mP.from(e,t,n)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){wP(this.active,e),wP(this.activeTo,e),wP(this.activeRank,e),this.minActive=xP(this.active,this.activeTo)}addActive(e){let t=0,{value:n,to:r,rank:i}=this.cursor;for(;t<this.activeRank.length&&(i-this.activeRank[t]||r-this.activeTo[t])>0;)t++;kP(this.active,t,n),kP(this.activeTo,t,r),kP(this.activeRank,t,i),e&&kP(e,t,this.cursor.from),this.minActive=xP(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let n=this.openStart<0?[]:null;for(;;){let r=this.minActive;if(r>-1&&(this.activeTo[r]-this.cursor.from||this.active[r].endSide-this.cursor.startSide)<0){if(this.activeTo[r]>e){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),n&&wP(n,r)}else{if(!this.cursor.value){this.to=this.endSide=1e9;break}if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}{let e=this.cursor.value;if(e.point){if(!(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)){this.point=e,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=e.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}this.cursor.next()}else this.addActive(n),this.cursor.next()}}}if(n){this.openStart=0;for(let t=n.length-1;t>=0&&n[t]<e;t--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let n=this.active.length-1;n>=0&&!(this.activeRank[n]<this.pointRank);n--)(this.activeTo[n]>e||this.activeTo[n]==e&&this.active[n].endSide>=this.point.endSide)&&t.push(this.active[n]);return t.reverse()}openEnd(e){let t=0;for(let n=this.activeTo.length-1;n>=0&&this.activeTo[n]>e;n--)t++;return t}}function yP(e,t,n,r,i,o){e.goto(t),n.goto(r);let s=r+i,a=r,l=r-t,c=!!o.boundChange;for(let t=!1;;){let r=e.to+l-n.to,i=r||e.endSide-n.endSide,u=i<0?e.to+l:n.to,h=Math.min(u,s);if(e.point||n.point?(e.point&&n.point&&aP(e.point,n.point)&&bP(e.activeForPoint(e.to),n.activeForPoint(n.to))||o.comparePoint(a,h,e.point,n.point),t=!1):(t&&o.boundChange(a),h>a&&!bP(e.active,n.active)&&o.compareRange(a,h,e.active,n.active),c&&h<s&&(r||e.openEnd(u)!=n.openEnd(u))&&(t=!0)),u>s)break;a=u,i<=0&&e.next(),i>=0&&n.next()}}function bP(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n]&&!aP(e[n],t[n]))return!1;return!0}function wP(e,t){for(let n=t,r=e.length-1;n<r;n++)e[n]=e[n+1];e.pop()}function kP(e,t,n){for(let n=e.length-1;n>=t;n--)e[n+1]=e[n];e[t]=n}function xP(e,t){let n=-1,r=1e9;for(let i=0;i<t.length;i++)(t[i]-r||e[i].endSide-e[n].endSide)<0&&(n=i,r=t[i]);return n}const SP="undefined"==typeof Symbol?"__ͼ":Symbol.for("ͼ"),CP="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),EP="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class AP{constructor(e,t){this.rules=[];let{finish:n}=t||{};function r(e){return/^@/.test(e)?[e]:e.split(/,\s*/)}function i(e,t,o,s){let a=[],l=/^@(\w+)\b/.exec(e[0]),c=l&&"keyframes"==l[1];if(l&&null==t)return o.push(e[0]+";");for(let n in t){let s=t[n];if(/&/.test(n))i(n.split(/,\s*/).map(t=>e.map(e=>t.replace(/&/,e))).reduce((e,t)=>e.concat(t)),s,o);else if(s&&"object"==typeof s){if(!l)throw new RangeError("The value of a property ("+n+") should be a primitive value.");i(r(n),s,a,c)}else null!=s&&a.push(n.replace(/_.*/,"").replace(/[A-Z]/g,e=>"-"+e.toLowerCase())+": "+s+";")}(a.length||c)&&o.push((!n||l||s?e:e.map(n)).join(", ")+" {"+a.join(" ")+"}")}for(let t in e)i(r(t),e[t],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let e=EP[SP]||1;return EP[SP]=e+1,"ͼ"+e.toString(36)}static mount(e,t,n){let r=e[CP],i=n&&n.nonce;r?i&&r.setNonce(i):r=new OP(e,i),r.mount(Array.isArray(t)?t:[t],e)}}let MP=new Map;class OP{constructor(e,t){let n=e.ownerDocument||e,r=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let t=MP.get(n);if(t)return e[CP]=t;this.sheet=new r.CSSStyleSheet,MP.set(n,this)}else this.styleTag=n.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[CP]=this}mount(e,t){let n=this.sheet,r=0,i=0;for(let t=0;t<e.length;t++){let o=e[t],s=this.modules.indexOf(o);if(s<i&&s>-1&&(this.modules.splice(s,1),i--,s=-1),-1==s){if(this.modules.splice(i++,0,o),n)for(let e=0;e<o.rules.length;e++)n.insertRule(o.rules[e],r++)}else{for(;i<s;)r+=this.modules[i++].rules.length;r+=o.rules.length,i++}}if(n)t.adoptedStyleSheets.indexOf(this.sheet)<0&&(t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets]);else{let e="";for(let t=0;t<this.modules.length;t++)e+=this.modules[t].getRules()+"\n";this.styleTag.textContent=e;let n=t.head||t;this.styleTag.parentNode!=n&&n.insertBefore(this.styleTag,n.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}}for(var NP={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},TP={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},RP=0;RP<10;RP++)NP[48+RP]=NP[96+RP]=String(RP);for(RP=1;RP<=24;RP++)NP[RP+111]="F"+RP;for(RP=65;RP<=90;RP++)NP[RP]=String.fromCharCode(RP+32),TP[RP]=String.fromCharCode(RP);for(var DP in NP)TP.hasOwnProperty(DP)||(TP[DP]=NP[DP]);let PP="undefined"!=typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},LP="undefined"!=typeof document?document:{documentElement:{style:{}}};const BP=/Edge\/(\d+)/.exec(PP.userAgent),IP=/MSIE \d/.test(PP.userAgent),_P=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(PP.userAgent),FP=!!(IP||_P||BP),WP=!FP&&/gecko\/(\d+)/i.test(PP.userAgent),jP=!FP&&/Chrome\/(\d+)/.exec(PP.userAgent),HP="webkitFontSmoothing"in LP.documentElement.style,zP=!FP&&/Apple Computer/.test(PP.vendor),VP=zP&&(/Mobile\/\w+/.test(PP.userAgent)||PP.maxTouchPoints>2);var qP={mac:VP||/Mac/.test(PP.platform),windows:/Win/.test(PP.platform),linux:/Linux|X11/.test(PP.platform),ie:FP,ie_version:IP?LP.documentMode||6:_P?+_P[1]:BP?+BP[1]:0,gecko:WP,gecko_version:WP?+(/Firefox\/(\d+)/.exec(PP.userAgent)||[0,0])[1]:0,chrome:!!jP,chrome_version:jP?+jP[1]:0,ios:VP,android:/Android\b/.test(PP.userAgent),webkit:HP,webkit_version:HP?+(/\bAppleWebKit\/(\d+)/.exec(PP.userAgent)||[0,0])[1]:0,safari:zP,safari_version:zP?+(/\bVersion\/(\d+(\.\d+)?)/.exec(PP.userAgent)||[0,0])[1]:0,tabSize:null!=LP.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};function UP(e,t){for(let n in e)"class"==n&&t.class?t.class+=" "+e.class:"style"==n&&t.style?t.style+=";"+e.style:t[n]=e[n];return t}const KP=Object.create(null);function GP(e,t,n){if(e==t)return!0;e||(e=KP),t||(t=KP);let r=Object.keys(e),i=Object.keys(t);if(r.length-(n&&r.indexOf(n)>-1?1:0)!=i.length-(n&&i.indexOf(n)>-1?1:0))return!1;for(let o of r)if(o!=n&&(-1==i.indexOf(o)||e[o]!==t[o]))return!1;return!0}function YP(e,t,n){let r=!1;if(t)for(let i in t)n&&i in n||(r=!0,"style"==i?e.style.cssText="":e.removeAttribute(i));if(n)for(let i in n)t&&t[i]==n[i]||(r=!0,"style"==i?e.style.cssText=n[i]:e.setAttribute(i,n[i]));return r}function $P(e){let t=Object.create(null);for(let n=0;n<e.attributes.length;n++){let r=e.attributes[n];t[r.name]=r.value}return t}class XP{eq(e){return!1}updateDOM(e,t){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,n){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}}var JP=function(e){return e[e.Text=0]="Text",e[e.WidgetBefore=1]="WidgetBefore",e[e.WidgetAfter=2]="WidgetAfter",e[e.WidgetRange=3]="WidgetRange",e}(JP||(JP={}));class QP extends sP{constructor(e,t,n,r){super(),this.startSide=e,this.endSide=t,this.widget=n,this.spec=r}get heightRelevant(){return!1}static mark(e){return new ZP(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),n=!!e.block;return t+=n&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new tL(e,t,t,n,e.widget||null,!1)}static replace(e){let t,n,r=!!e.block;if(e.isBlockGap)t=-5e8,n=4e8;else{let{start:i,end:o}=nL(e,r);t=(i?r?-3e8:-1:5e8)-1,n=1+(o?r?2e8:1:-6e8)}return new tL(e,t,n,r,e.widget||null,!0)}static line(e){return new eL(e)}static set(e,t=!1){return hP.of(e,t)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}QP.none=hP.empty;class ZP extends QP{constructor(e){let{start:t,end:n}=nL(e);super(t?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?UP(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||KP}eq(e){return this==e||e instanceof ZP&&this.tagName==e.tagName&&GP(this.attrs,e.attrs)}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}}ZP.prototype.point=!1;class eL extends QP{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof eL&&this.spec.class==e.spec.class&&GP(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}}eL.prototype.mapMode=iD.TrackBefore,eL.prototype.point=!0;class tL extends QP{constructor(e,t,n,r,i,o){super(t,n,i,e),this.block=r,this.isReplace=o,this.mapMode=r?t<=0?iD.TrackBefore:iD.TrackAfter:iD.TrackDel}get type(){return this.startSide!=this.endSide?JP.WidgetRange:this.startSide<=0?JP.WidgetBefore:JP.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof tL&&(t=this.widget,n=e.widget,t==n||!!(t&&n&&t.compare(n)))&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide;var t,n}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}}function nL(e,t=!1){let{inclusiveStart:n,inclusiveEnd:r}=e;return null==n&&(n=e.inclusive),null==r&&(r=e.inclusive),{start:null!=n?n:t,end:null!=r?r:t}}function rL(e,t,n,r=0){let i=n.length-1;i>=0&&n[i]+r>=e?n[i]=Math.max(n[i],t):n.push(e,t)}tL.prototype.point=!0;class iL extends sP{constructor(e,t){super(),this.tagName=e,this.attributes=t}eq(e){return e==this||e instanceof iL&&this.tagName==e.tagName&&GP(this.attributes,e.attributes)}static create(e){return new iL(e.tagName,e.attributes||KP)}static set(e,t=!1){return hP.of(e,t)}}function oL(e){let t;return t=11==e.nodeType?e.getSelection?e:e.ownerDocument:e,t.getSelection()}function sL(e,t){return!!t&&(e==t||e.contains(1!=t.nodeType?t.parentNode:t))}function aL(e,t){if(!t.anchorNode)return!1;try{return sL(e,t.anchorNode)}catch(e){return!1}}function lL(e){return 3==e.nodeType?kL(e,0,e.nodeValue.length).getClientRects():1==e.nodeType?e.getClientRects():[]}function cL(e,t,n,r){return!!n&&(fL(e,t,n,r,-1)||fL(e,t,n,r,1))}function uL(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t}function hL(e){return 1==e.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(e.nodeName)}function fL(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:dL(e))){if("DIV"==e.nodeName)return!1;let n=e.parentNode;if(!n||1!=n.nodeType)return!1;t=uL(e)+(i<0?0:1),e=n}else{if(1!=e.nodeType)return!1;if(1==(e=e.childNodes[t+(i<0?-1:0)]).nodeType&&"false"==e.contentEditable)return!1;t=i<0?dL(e):0}}}function dL(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function pL(e,t){let n=t?e.left:e.right;return{left:n,right:n,top:e.top,bottom:e.bottom}}function mL(e){let t=e.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.innerWidth,top:0,bottom:e.innerHeight}}function gL(e,t){let n=t.width/e.offsetWidth,r=t.height/e.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(t.width-e.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(t.height-e.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}iL.prototype.startSide=iL.prototype.endSide=-1;class vL{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:n}=e;this.set(t,Math.min(e.anchorOffset,t?dL(t):0),n,Math.min(e.focusOffset,n?dL(n):0))}set(e,t,n,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=r}}let yL,bL=null;function wL(e){if(e.setActive)return e.setActive();if(bL)return e.focus(bL);let t=[];for(let n=e;n&&(t.push(n,n.scrollTop,n.scrollLeft),n!=n.ownerDocument);n=n.parentNode);if(e.focus(null==bL?{get preventScroll(){return bL={preventScroll:!0},!0}}:void 0),!bL){bL=!1;for(let e=0;e<t.length;){let n=t[e++],r=t[e++],i=t[e++];n.scrollTop!=r&&(n.scrollTop=r),n.scrollLeft!=i&&(n.scrollLeft=i)}}}function kL(e,t,n=t){let r=yL||(yL=document.createRange());return r.setEnd(e,n),r.setStart(e,t),r}function xL(e,t,n,r){let i={key:t,code:t,keyCode:n,which:n,cancelable:!0};r&&({altKey:i.altKey,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey,metaKey:i.metaKey}=r);let o=new KeyboardEvent("keydown",i);o.synthetic=!0,e.dispatchEvent(o);let s=new KeyboardEvent("keyup",i);return s.synthetic=!0,e.dispatchEvent(s),o.defaultPrevented||s.defaultPrevented}function SL(e){return e.scrollTop>Math.max(1,e.scrollHeight-e.clientHeight-4)}function CL(e,t){for(let n=e,r=t;;){if(3==n.nodeType&&r>0)return{node:n,offset:r};if(1==n.nodeType&&r>0){if("false"==n.contentEditable)return null;n=n.childNodes[r-1],r=dL(n)}else{if(!n.parentNode||hL(n))return null;r=uL(n),n=n.parentNode}}}function EL(e,t){for(let n=e,r=t;;){if(3==n.nodeType&&r<n.nodeValue.length)return{node:n,offset:r};if(1==n.nodeType&&r<n.childNodes.length){if("false"==n.contentEditable)return null;n=n.childNodes[r],r=0}else{if(!n.parentNode||hL(n))return null;r=uL(n)+1,n=n.parentNode}}}qP.safari&&qP.safari_version>=26&&(bL=!1);class AL{constructor(e,t,n=!0){this.node=e,this.offset=t,this.precise=n}static before(e,t){return new AL(e.parentNode,uL(e),t)}static after(e,t){return new AL(e.parentNode,uL(e)+1,t)}}var ML=function(e){return e[e.LTR=0]="LTR",e[e.RTL=1]="RTL",e}(ML||(ML={}));const OL=ML.LTR,NL=ML.RTL;function TL(e){let t=[];for(let n=0;n<e.length;n++)t.push(1<<+e[n]);return t}const RL=TL("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),DL=TL("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),PL=Object.create(null),LL=[];for(let e of["()","[]","{}"]){let t=e.charCodeAt(0),n=e.charCodeAt(1);PL[t]=n,PL[n]=-t}function BL(e){return e<=247?RL[e]:1424<=e&&e<=1524?2:1536<=e&&e<=1785?DL[e-1536]:1774<=e&&e<=2220?4:8192<=e&&e<=8204?256:64336<=e&&e<=65023?4:1}const IL=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class _L{get dir(){return this.level%2?NL:OL}constructor(e,t,n){this.from=e,this.to=t,this.level=n}side(e,t){return this.dir==t==e?this.to:this.from}forward(e,t){return e==(this.dir==t)}static find(e,t,n,r){let i=-1;for(let o=0;o<e.length;o++){let s=e[o];if(s.from<=t&&s.to>=t){if(s.level==n)return o;(i<0||(0!=r?r<0?s.from<t:s.to>t:e[i].level>s.level))&&(i=o)}}if(i<0)throw new RangeError("Index out of range");return i}}function FL(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r.from!=i.from||r.to!=i.to||r.direction!=i.direction||!FL(r.inner,i.inner))return!1}return!0}const WL=[];function jL(e,t,n,r,i,o,s){let a=r%2?2:1;if(r%2==i%2)for(let l=t,c=0;l<n;){let t=!0,u=!1;if(c==o.length||l<o[c].from){let e=WL[l];e!=a&&(t=!1,u=16==e)}let h=t||1!=a?null:[],f=t?r:r+1,d=l;e:for(;;)if(c<o.length&&d==o[c].from){if(u)break e;let p=o[c];if(!t)for(let e=p.to,t=c+1;;){if(e==n)break e;if(!(t<o.length&&o[t].from==e)){if(WL[e]==a)break e;break}e=o[t++].to}if(c++,h)h.push(p);else{p.from>l&&s.push(new _L(l,p.from,f)),HL(e,p.direction==OL!=!(f%2)?r+1:r,i,p.inner,p.from,p.to,s),l=p.to}d=p.to}else{if(d==n||(t?WL[d]!=a:WL[d]==a))break;d++}h?jL(e,l,d,r+1,i,h,s):l<d&&s.push(new _L(l,d,f)),l=d}else for(let l=n,c=o.length;l>t;){let n=!0,u=!1;if(!c||l>o[c-1].to){let e=WL[l-1];e!=a&&(n=!1,u=16==e)}let h=n||1!=a?null:[],f=n?r:r+1,d=l;e:for(;;)if(c&&d==o[c-1].to){if(u)break e;let p=o[--c];if(!n)for(let e=p.from,n=c;;){if(e==t)break e;if(!n||o[n-1].to!=e){if(WL[e-1]==a)break e;break}e=o[--n].from}if(h)h.push(p);else{p.to<l&&s.push(new _L(p.to,l,f)),HL(e,p.direction==OL!=!(f%2)?r+1:r,i,p.inner,p.from,p.to,s),l=p.from}d=p.from}else{if(d==t||(n?WL[d-1]!=a:WL[d-1]==a))break;d--}h?jL(e,d,l,r+1,i,h,s):d<l&&s.push(new _L(d,l,f)),l=d}}function HL(e,t,n,r,i,o,s){let a=t%2?2:1;!function(e,t,n,r,i){for(let o=0;o<=r.length;o++){let s=o?r[o-1].to:t,a=o<r.length?r[o].from:n,l=o?256:i;for(let t=s,n=l,r=l;t<a;t++){let i=BL(e.charCodeAt(t));512==i?i=n:8==i&&4==r&&(i=16),WL[t]=4==i?2:i,7&i&&(r=i),n=i}for(let e=s,t=l,r=l;e<a;e++){let i=WL[e];if(128==i)e<a-1&&t==WL[e+1]&&24&t?i=WL[e]=t:WL[e]=256;else if(64==i){let i=e+1;for(;i<a&&64==WL[i];)i++;let o=e&&8==t||i<n&&8==WL[i]?1==r?1:8:256;for(let t=e;t<i;t++)WL[t]=o;e=i-1}else 8==i&&1==r&&(WL[e]=1);t=i,7&i&&(r=i)}}}(e,i,o,r,a),function(e,t,n,r,i){let o=1==i?2:1;for(let s=0,a=0,l=0;s<=r.length;s++){let c=s?r[s-1].to:t,u=s<r.length?r[s].from:n;for(let t,n,r,s=c;s<u;s++)if(n=PL[t=e.charCodeAt(s)])if(n<0){for(let e=a-3;e>=0;e-=3)if(LL[e+1]==-n){let t=LL[e+2],n=2&t?i:4&t?1&t?o:i:0;n&&(WL[s]=WL[LL[e]]=n),a=e;break}}else{if(189==LL.length)break;LL[a++]=s,LL[a++]=t,LL[a++]=l}else if(2==(r=WL[s])||1==r){let e=r==i;l=e?0:1;for(let t=a-3;t>=0;t-=3){let n=LL[t+2];if(2&n)break;if(e)LL[t+2]|=2;else{if(4&n)break;LL[t+2]|=4}}}}}(e,i,o,r,a),function(e,t,n,r){for(let i=0,o=r;i<=n.length;i++){let s=i?n[i-1].to:e,a=i<n.length?n[i].from:t;for(let l=s;l<a;){let s=WL[l];if(256==s){let s=l+1;for(;;)if(s==a){if(i==n.length)break;s=n[i++].to,a=i<n.length?n[i].from:t}else{if(256!=WL[s])break;s++}let c=1==o,u=c==(1==(s<t?WL[s]:r))?c?1:2:r;for(let t=s,r=i,o=r?n[r-1].to:e;t>l;)t==o&&(t=n[--r].from,o=r?n[r-1].to:e),WL[--t]=u;l=s}else o=s,l++}}}(i,o,r,a),jL(e,i,o,t,n,r,s)}function zL(e){return[new _L(0,e,0)]}let VL="";function qL(e,t,n,r,i){var o;let s=r.head-e.from,a=_L.find(t,s,null!==(o=r.bidiLevel)&&void 0!==o?o:-1,r.assoc),l=t[a],c=l.side(i,n);if(s==c){let e=a+=i?1:-1;if(e<0||e>=t.length)return null;l=t[a=e],s=l.side(!i,n),c=l.side(i,n)}let u=nD(e.text,s,l.forward(i,n));(u<l.from||u>l.to)&&(u=c),VL=e.text.slice(Math.min(s,u),Math.max(s,u));let h=a==(i?t.length-1:0)?null:t[a+(i?1:-1)];return h&&u==c&&h.level+(i?0:1)<l.level?pD.cursor(h.side(!i,n)+e.from,h.forward(i,n)?1:-1,h.level):pD.cursor(u+e.from,l.forward(i,n)?-1:1,l.level)}function UL(e,t,n){for(let r=t;r<n;r++){let t=BL(e.charCodeAt(r));if(1==t)return OL;if(2==t||4==t)return NL}return OL}const KL=vD.define(),GL=vD.define(),YL=vD.define(),$L=vD.define(),XL=vD.define(),JL=vD.define(),QL=vD.define(),ZL=vD.define(),eB=vD.define(),tB=vD.define({combine:e=>e.some(e=>e)}),nB=vD.define({combine:e=>e.some(e=>e)}),rB=vD.define();class iB{constructor(e,t="nearest",n="nearest",r=5,i=5,o=!1){this.range=e,this.y=t,this.x=n,this.yMargin=r,this.xMargin=i,this.isSnapshot=o}map(e){return e.empty?this:new iB(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new iB(pD.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const oB=GD.define({map:(e,t)=>e.map(t)}),sB=GD.define();function aB(e,t,n){let r=e.facet($L);r.length?r[0](t):window.onerror&&window.onerror(String(t),n,void 0,void 0,t)}const lB=vD.define({combine:e=>!e.length||e[0]});let cB=0;const uB=vD.define({combine:e=>e.filter((t,n)=>{for(let r=0;r<n;r++)if(e[r].plugin==t.plugin)return!1;return!0})});class hB{constructor(e,t,n,r,i){this.id=e,this.create=t,this.domEventHandlers=n,this.domEventObservers=r,this.baseExtensions=i(this),this.extension=this.baseExtensions.concat(uB.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(uB.of({plugin:this,arg:e}))}static define(e,t){const{eventHandlers:n,eventObservers:r,provide:i,decorations:o}=t||{};return new hB(cB++,e,n,r,e=>{let t=[];return o&&t.push(mB.of(t=>{let n=t.plugin(e);return n?o(n):QP.none})),i&&t.push(i(e)),t})}static fromClass(e,t){return hB.define((t,n)=>new e(t,n),t)}}class fB{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let e=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(e)}catch(t){if(aB(e.state,t,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(e){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){aB(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(null===(t=this.value)||void 0===t?void 0:t.destroy)try{this.value.destroy()}catch(t){aB(e.state,t,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const dB=vD.define(),pB=vD.define(),mB=vD.define(),gB=vD.define(),vB=vD.define(),yB=vD.define(),bB=vD.define();function wB(e,t){let n=e.state.facet(bB);if(!n.length)return n;let r=n.map(t=>t instanceof Function?t(e):t),i=[];return hP.spans(r,t.from,t.to,{point(){},span(e,n,r,o){let s=e-t.from,a=n-t.from,l=i;for(let e=r.length-1;e>=0;e--,o--){let n,i=r[e].spec.bidiIsolate;if(null==i&&(i=UL(t.text,s,a)),o>0&&l.length&&(n=l[l.length-1]).to==s&&n.direction==i)n.to=a,l=n.inner;else{let e={from:s,to:a,direction:i,inner:[]};l.push(e),l=e.inner}}}}),i}const kB=vD.define();function xB(e){let t=0,n=0,r=0,i=0;for(let o of e.state.facet(kB)){let s=o(e);s&&(null!=s.left&&(t=Math.max(t,s.left)),null!=s.right&&(n=Math.max(n,s.right)),null!=s.top&&(r=Math.max(r,s.top)),null!=s.bottom&&(i=Math.max(i,s.bottom)))}return{left:t,right:n,top:r,bottom:i}}const SB=vD.define();class CB{constructor(e,t,n,r){this.fromA=e,this.toA=t,this.fromB=n,this.toB=r}join(e){return new CB(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,n=this;for(;t>0;t--){let r=e[t-1];if(!(r.fromA>n.toA)){if(r.toA<n.fromA)break;n=n.join(r),e.splice(t-1,1)}}return e.splice(t,0,n),e}static extendWithRanges(e,t){if(0==t.length)return e;let n=[];for(let r=0,i=0,o=0;;){let s=r<e.length?e[r].fromB:1e9,a=i<t.length?t[i]:1e9,l=Math.min(s,a);if(1e9==l)break;let c=l+o,u=l,h=c;for(;;)if(i<t.length&&t[i]<=u){let n=t[i+1];i+=2,u=Math.max(u,n);for(let t=r;t<e.length&&e[t].fromB<=u;t++)o=e[t].toA-e[t].toB;h=Math.max(h,n+o)}else{if(!(r<e.length&&e[r].fromB<=u))break;{let t=e[r++];u=Math.max(u,t.toB),h=Math.max(h,t.toA),o=t.toA-t.toB}}n.push(new CB(c,h,l,u))}return n}}class EB{constructor(e,t,n){this.view=e,this.state=t,this.transactions=n,this.flags=0,this.startState=e.state,this.changes=sD.empty(this.startState.doc.length);for(let e of n)this.changes=this.changes.compose(e.changes);let r=[];this.changes.iterChangedRanges((e,t,n,i)=>r.push(new CB(e,t,n,i))),this.changedRanges=r}static create(e,t,n){return new EB(e,t,n)}get viewportChanged(){return(4&this.flags)>0}get viewportMoved(){return(8&this.flags)>0}get heightChanged(){return(2&this.flags)>0}get geometryChanged(){return this.docChanged||(18&this.flags)>0}get focusChanged(){return(1&this.flags)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return 0==this.flags&&0==this.transactions.length}}const AB=[];class MB{constructor(e,t,n=0){this.dom=e,this.length=t,this.flags=n,this.parent=null,e.cmTile=this}get breakAfter(){return 1&this.flags}get children(){return AB}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,4&this.flags){this.flags&=-5;let e=this.domAttrs;e&&function(e,t){for(let n=e.attributes.length-1;n>=0;n--){let r=e.attributes[n].name;null==t[r]&&e.removeAttribute(r)}for(let n in t){let r=t[n];"style"==n?e.style.cssText=r:e.getAttribute(n)!=r&&e.setAttribute(n,r)}}(this.dom,e)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,t=this.posAtStart){let n=t;for(let t of this.children){if(t==e)return n;n+=t.length+t.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,t){return null}domPosFor(e,t){let n=uL(this.dom),r=this.length?e>0:t>0;return new AL(this.parent.dom,n+(r?1:0),0==e||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&2&this.parent.flags&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof TB)return e;return null}static get(e){return e.cmTile}}class OB extends MB{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(2&this.flags)return;super.sync(e);let t,n=this.dom,r=null,i=(null==e?void 0:e.node)==n?e:null,o=0;for(let s of this.children){if(s.sync(e),o+=s.length+s.breakAfter,t=r?r.nextSibling:n.firstChild,i&&t!=s.dom&&(i.written=!0),s.dom.parentNode==n)for(;t&&t!=s.dom;)t=NB(t);else n.insertBefore(s.dom,t);r=s.dom}for(t=r?r.nextSibling:n.firstChild,i&&t&&(i.written=!0);t;)t=NB(t);this.length=o}}function NB(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}class TB extends OB{constructor(e,t){super(t),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let t=MB.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],n=this,r=0,i=0;;)if(r==n.children.length){if(!t.length)return;n=n.parent,n.breakAfter&&i++,r=t.pop()}else{let o=n.children[r++];if(o instanceof RB)t.push(r),n=o,r=0;else{let t=i+o.length,n=e(o,i);if(void 0!==n)return n;i=t+o.breakAfter}}}resolveBlock(e,t){let n,r,i=-1,o=-1;if(this.blockTiles((s,a)=>{let l=a+s.length;if(e>=a&&e<=l){if(s.isWidget()&&t>=-1&&t<=1){if(32&s.flags)return!0;16&s.flags&&(n=void 0)}(a<e||e==l&&(t<-1?s.length:s.covers(1)))&&(!n||!s.isWidget()&&n.isWidget())&&(n=s,i=e-a),(l>e||e==a&&(t>1?s.length:s.covers(-1)))&&(!r||!s.isWidget()&&r.isWidget())&&(r=s,o=e-a)}}),!n&&!r)throw new Error("No tile at position "+e);return n&&t<0||!r?{tile:n,offset:i}:{tile:r,offset:o}}}class RB extends OB{constructor(e,t){super(e),this.wrapper=t}isBlock(){return!0}covers(e){return!!this.children.length&&(e<0?this.children[0].covers(-1):this.lastChild.covers(1))}get domAttrs(){return this.wrapper.attributes}static of(e,t){let n=new RB(t||document.createElement(e.tagName),e);return t||(n.flags|=4),n}}class DB extends OB{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(e,t,n){let r=new DB(t||document.createElement("div"),e);return t&&n||(r.flags|=4),r}get domAttrs(){return this.attrs}resolveInline(e,t,n){let r=null,i=-1,o=null,s=-1;!function e(a,l){for(let c=0,u=0;c<a.children.length&&u<=l;c++){let h=a.children[c],f=u+h.length;f>=l&&(h.isComposite()?e(h,l-u):(!o||o.isHidden&&(t>0||n&&PB(o,h)))&&(f>l||32&h.flags)?(o=h,s=l-u):(u<l||16&h.flags&&!h.isHidden)&&(r=h,i=l-u)),u=f}}(this,e);let a=(t<0?r:o)||r||o;return a?{tile:a,offset:a==r?i:s}:null}coordsIn(e,t){let n=this.resolveInline(e,t,!0);return n?n.tile.coordsIn(Math.max(0,n.offset),t):function(e){let t=e.dom.lastChild;if(!t)return e.dom.getBoundingClientRect();let n=lL(t);return n[n.length-1]||null}(this)}domIn(e,t){let n=this.resolveInline(e,t);if(n){let{tile:e,offset:r}=n;if(this.dom.contains(e.dom))return e.isText()?new AL(e.dom,Math.min(e.dom.nodeValue.length,r)):e.domPosFor(r,16&e.flags?1:32&e.flags?-1:t);let i=n.tile.parent,o=!1;for(let e of i.children){if(o)return new AL(e.dom,0);e==n.tile&&(o=!0)}}return new AL(this.dom,0)}}function PB(e,t){let n=e.coordsIn(0,1),r=t.coordsIn(0,1);return n&&r&&r.top<n.bottom}class LB extends OB{constructor(e,t){super(e),this.mark=t}get domAttrs(){return this.mark.attrs}static of(e,t){let n=new LB(t||document.createElement(e.tagName),e);return t||(n.flags|=4),n}}class BB extends MB{constructor(e,t){super(e,t.length),this.text=t}sync(e){2&this.flags||(super.sync(e),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text))}isText(){return!0}toString(){return JSON.stringify(this.text)}coordsIn(e,t){let n=this.dom.nodeValue.length;e>n&&(e=n);let r=e,i=e,o=0;0==e&&t<0||e==n&&t>=0?qP.chrome||qP.gecko||(e?(r--,o=1):i<n&&(i++,o=-1)):t<0?r--:i<n&&i++;let s=kL(this.dom,r,i).getClientRects();if(!s.length)return null;let a=s[(o?o<0:t>=0)?0:s.length-1];return qP.safari&&!o&&0==a.width&&(a=Array.prototype.find.call(s,e=>e.width)||a),o?pL(a,o<0):a||null}static of(e,t){let n=new BB(t||document.createTextNode(e),e);return t||(n.flags|=2),n}}class IB extends MB{constructor(e,t,n,r){super(e,t,r),this.widget=n}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return!(48&this.flags)&&(this.flags&(e<0?64:128))>0}coordsIn(e,t){return this.coordsInWidget(e,t,!1)}coordsInWidget(e,t,n){let r=this.widget.coordsAt(this.dom,e,t);if(r)return r;if(n)return pL(this.dom.getBoundingClientRect(),this.length?0==e:t<=0);{let t=this.dom.getClientRects(),n=null;if(!t.length)return null;let r=!!(16&this.flags)||!(32&this.flags)&&e>0;for(let i=r?t.length-1:0;n=t[i],!(e>0?0==i:i==t.length-1||n.top<n.bottom);i+=r?-1:1);return pL(n,!r)}}get overrideDOMText(){if(!this.length)return KR.empty;let{root:e}=this;if(!e)return KR.empty;let t=this.posAtStart;return e.view.state.doc.slice(t,t+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(e,t,n,r,i){return i||(i=e.toDOM(t),e.editable||(i.contentEditable="false")),new IB(i,n,e,r)}}class _B extends MB{constructor(e){let t=document.createElement("img");t.className="cm-widgetBuffer",t.setAttribute("aria-hidden","true"),super(t,0,e)}get isHidden(){return!0}get overrideDOMText(){return KR.empty}coordsIn(e){return this.dom.getBoundingClientRect()}}class FB{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,n){let{tile:r,index:i,beforeBreak:o,parents:s}=this;for(;e||t>0;)if(r.isComposite())if(o){if(!e)break;n&&n.break(),e--,o=!1}else if(i==r.children.length){if(!e&&!s.length)break;n&&n.leave(r),o=!!r.breakAfter,({tile:r,index:i}=s.pop()),i++}else{let a=r.children[i],l=a.breakAfter;!(t>0?a.length<=e:a.length<e)||n&&!1===n.skip(a,0,a.length)&&a.isComposite?(s.push({tile:r,index:i}),r=a,i=0,n&&a.isComposite()&&n.enter(a)):(o=!!l,i++,e-=a.length)}else if(i==r.length)o=!!r.breakAfter,({tile:r,index:i}=s.pop()),i++;else{if(!e)break;{let t=Math.min(e,r.length-i);n&&n.skip(r,i,i+t),e-=t,i+=t}}return this.tile=r,this.index=i,this.beforeBreak=o,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}}class WB{constructor(e,t,n,r){this.from=e,this.to=t,this.wrapper=n,this.rank=r}}class jB{constructor(e,t,n){this.cache=e,this.root=t,this.blockWrappers=n,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(e,t,n,r){var i;this.flushBuffer();let o=this.ensureMarks(t,n),s=o.lastChild;if(!s||!s.isText()||8&s.flags)o.append(r||BB.of(e,null===(i=this.cache.find(BB))||void 0===i?void 0:i.dom));else{this.cache.reused.set(s,2),(o.children[o.children.length-1]=new BB(s.dom,s.text+e)).parent=o}this.pos+=e.length,this.afterWidget=null}addComposition(e,t){let n=this.curLine;n.dom!=t.line.dom&&(n.setDOM(this.cache.reused.has(t.line)?GB(t.line.dom):t.line.dom),this.cache.reused.set(t.line,2));let r=n;for(let e=t.marks.length-1;e>=0;e--){let n=t.marks[e],i=r.lastChild;if(i instanceof LB&&i.mark.eq(n.mark))i.dom!=n.dom&&i.setDOM(GB(n.dom)),r=i;else{if(this.cache.reused.get(n)){let e=MB.get(n.dom);e&&e.setDOM(GB(n.dom))}let e=LB.of(n.mark,n.dom);r.append(e),r=e}this.cache.reused.set(n,2)}let i=MB.get(e.text);i&&this.cache.reused.set(i,2);let o=new BB(e.text,e.text.nodeValue);o.flags|=8,r.append(o)}addInlineWidget(e,t,n){let r=this.afterWidget&&48&e.flags&&(48&this.afterWidget.flags)==(48&e.flags);r||this.flushBuffer();let i=this.ensureMarks(t,n);r||16&e.flags||i.append(this.getBuffer(1)),i.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,n){this.flushBuffer(),this.ensureMarks(t,n).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){(this.afterWidget||this.lastBlock).length+=e,this.pos+=e}addLineStart(e,t){var n;e||(e=KB);let r=DB.start(e,t||(null===(n=this.cache.find(DB))||void 0===n?void 0:n.dom),!!t);this.getBlockPos().append(this.lastBlock=this.curLine=r)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,t){var n;let r=this.curLine;for(let i=e.length-1;i>=0;i--){let o,s=e[i];if(t>0&&(o=r.lastChild)&&o instanceof LB&&o.mark.eq(s))r=o,t--;else{let e=LB.of(s,null===(n=this.cache.find(LB,e=>e.mark.eq(s)))||void 0===n?void 0:n.dom);r.append(e),r=e,t=0}}return r}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;e&&UB(this.curLine,!1)&&("BR"==e.dom.nodeName||!e.isWidget()||qP.ios&&UB(this.curLine,!0))||this.curLine.append(this.cache.findWidget($B,0,32)||new IB($B.toDOM(),0,$B,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to<this.pos&&this.wrappers.splice(e,1);for(let e=this.blockWrappers;e.value&&e.from<=this.pos;e.next())if(e.to>=this.pos){let t=new WB(e.from,e.to,e.value,e.rank),n=this.wrappers.length;for(;n>0&&(this.wrappers[n-1].rank-t.rank||this.wrappers[n-1].to-t.to)<0;)n--;this.wrappers.splice(n,0,t)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let t=this.root;for(let n of this.wrappers){let r=t.lastChild;if(n.from<this.pos&&r instanceof RB&&r.wrapper.eq(n.wrapper))t=r;else{let r=RB.of(n.wrapper,null===(e=this.cache.find(RB,e=>e.wrapper.eq(n.wrapper)))||void 0===e?void 0:e.dom);t.append(r),t=r}}return t}blockPosCovered(){let e=this.lastBlock;return null!=e&&!e.breakAfter&&(!e.isWidget()||(160&e.flags)>0)}getBuffer(e){let t=2|(e<0?16:32),n=this.cache.find(_B,void 0,1);return n&&(n.flags=t),n||new _B(t)}flushBuffer(){!this.afterWidget||32&this.afterWidget.flags||(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class HB{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:t,lineBreak:n,done:r}=this.cursor.next(this.skipCount);if(this.skipCount=0,r)throw new Error("Ran out of text content when drawing inline views");this.text=t;let i=this.textOff=Math.min(e,t.length);return n?null:t.slice(0,i)}let t=Math.min(this.text.length,this.textOff+e),n=this.text.slice(this.textOff,t);return this.textOff=t,n}}const zB=[IB,DB,BB,LB,_B,RB,TB];for(let e=0;e<zB.length;e++)zB[e].bucket=e;class VB{constructor(e){this.view=e,this.buckets=zB.map(()=>[]),this.index=zB.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,n=this.buckets[t];n.length<6?n.push(e):n[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,n=2){let r=e.bucket,i=this.buckets[r],o=this.index[r];for(let e=i.length-1;e>=0;e--){let s=(e+o)%i.length,a=i[s];if((!t||t(a))&&!this.reused.has(a))return i.splice(s,1),s<o&&this.index[r]--,this.reused.set(a,n),a}return null}findWidget(e,t,n){let r=this.buckets[0];if(r.length)for(let i=0,o=0;;i++){if(i==r.length){if(o)return null;o=1,i=0}let s=r[i];if(!this.reused.has(s)&&(0==o?s.widget.compare(e):s.widget.constructor==e.constructor&&e.updateDOM(s.dom,this.view)))return r.splice(i,1),i<this.index[0]&&this.index[0]--,s.widget==e&&s.length==t&&(497&s.flags)==n?(this.reused.set(s,1),s):(this.reused.set(s,2),new IB(s.dom,t,e,-498&s.flags|n))}}reuse(e){return this.reused.set(e,1),e}maybeReuse(e,t=2){if(!this.reused.has(e))return this.reused.set(e,t),e.dom}clear(){for(let e=0;e<this.buckets.length;e++)this.buckets[e].length=this.index[e]=0}}class qB{constructor(e,t,n,r,i){this.view=e,this.decorations=r,this.disallowBlockEffectsFor=i,this.openWidget=!1,this.openMarks=0,this.cache=new VB(e),this.text=new HB(e.state.doc),this.builder=new jB(this.cache,new TB(e,e.contentDOM),hP.iter(n)),this.cache.reused.set(t,2),this.old=new FB(t),this.reuseWalker={skip:(e,t,n)=>{if(this.cache.add(e),e.isComposite())return!1},enter:e=>this.cache.add(e),leave:()=>{},break:()=>{}}}run(e,t){let n=t&&this.getCompositionContext(t.text);for(let r=0,i=0,o=0;;){let s=o<e.length?e[o++]:null,a=s?s.fromA:this.old.root.length;if(a>r){let e=a-r;this.preserve(e,!o,!s),r=a,i+=e}if(!s)break;t&&s.fromA<=t.range.fromA&&s.toA>=t.range.toA?(this.forward(s.fromA,t.range.fromA,t.range.fromA<t.range.toA?1:-1),this.emit(i,t.range.fromB),this.cache.clear(),this.builder.addComposition(t,n),this.text.skip(t.range.toB-t.range.fromB),this.forward(t.range.fromA,s.toA),this.emit(t.range.toB,s.toB)):(this.forward(s.fromA,s.toA),this.emit(i,s.toB)),i=s.toB,r=s.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(e,t,n){let r=function(e){let t=[];for(let n=e.parents.length;n>1;n--){let r=n==e.parents.length?e.tile:e.parents[n].tile;r instanceof LB&&t.push(r.mark)}return t}(this.old),i=this.openMarks;this.old.advance(e,n?1:-1,{skip:(e,t,n)=>{if(e.isWidget())if(this.openWidget)this.builder.continueWidget(n-t);else{let o=n>0||t<e.length?IB.of(e.widget,this.view,n-t,496&e.flags,this.cache.maybeReuse(e)):this.cache.reuse(e);256&o.flags?(o.flags&=-2,this.builder.addBlockWidget(o)):(this.builder.ensureLine(null),this.builder.addInlineWidget(o,r,i),i=r.length)}else if(e.isText())this.builder.ensureLine(null),t||n!=e.length?(this.cache.add(e),this.builder.addText(e.text.slice(t,n),r,i)):this.builder.addText(e.text,r,i,this.cache.reuse(e)),i=r.length;else if(e.isLine())e.flags&=-2,this.cache.reused.set(e,1),this.builder.addLine(e);else if(e instanceof _B)this.cache.add(e);else{if(!(e instanceof LB))return!1;this.builder.ensureLine(null),this.builder.addMark(e,r,i),this.cache.reused.set(e,1),i=r.length}this.openWidget=!1},enter:e=>{e.isLine()?this.builder.addLineStart(e.attrs,this.cache.maybeReuse(e)):(this.cache.add(e),e instanceof LB&&r.unshift(e.mark)),this.openWidget=!1},leave:e=>{e.isLine()?r.length&&(r.length=i=0):e instanceof LB&&(r.shift(),i=Math.min(i,r.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let n=null,r=this.builder,i=0,o=hP.spans(this.decorations,e,t,{point:(e,t,o,s,a,l)=>{if(o instanceof tL){if(this.disallowBlockEffectsFor[l]){if(o.block)throw new RangeError("Block decorations may not be specified via plugins");if(t>this.view.state.doc.lineAt(e).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(i=s.length,a>s.length)r.continueWidget(t-e);else{let i=o.widget||(o.block?YB.block:YB.inline),l=function(e){let t=e.isReplace?(e.startSide<0?64:0)|(e.endSide>0?128:0):e.startSide>0?32:16;e.block&&(t|=256);return t}(o),c=this.cache.findWidget(i,t-e,l)||IB.of(i,this.view,t-e,l);o.block?(o.startSide>0&&r.addLineStartIfNotCovered(n),r.addBlockWidget(c)):(r.ensureLine(n),r.addInlineWidget(c,s,a))}n=null}else n=function(e,t){let n=t.spec.attributes,r=t.spec.class;if(!n&&!r)return e;e||(e={class:"cm-line"});n&&UP(n,e);r&&(e.class+=" "+r);return e}(n,o);t>e&&this.text.skip(t-e)},span:(e,t,i,o)=>{for(let s=e;s<t;){let e=this.text.next(Math.min(512,t-s));null==e?(r.addLineStartIfNotCovered(n),r.addBreak(),s++):(r.ensureLine(n),r.addText(e,i,o),s+=e.length),n=null}}});r.addLineStartIfNotCovered(n),this.openWidget=o>i,this.openMarks=o}forward(e,t,n=1){t-e<=10?this.old.advance(t-e,n,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,n,this.reuseWalker))}getCompositionContext(e){let t=[],n=null;for(let r=e.parentNode;;r=r.parentNode){let e=MB.get(r);if(r==this.view.contentDOM)break;e instanceof LB?t.push(e):(null==e?void 0:e.isLine())?n=e:"DIV"!=r.nodeName||n||r==this.view.contentDOM?t.push(LB.of(new ZP({tagName:r.nodeName.toLowerCase(),attributes:$P(r)}),r)):n=new DB(r,KB)}return{line:n,marks:t}}}function UB(e,t){let n=e=>{for(let r of e.children)if((t?r.isText():r.length)||n(r))return!0;return!1};return n(e)}const KB={class:"cm-line"};function GB(e){let t=MB.get(e);return t&&t.setDOM(e.cloneNode()),e}class YB extends XP{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}YB.inline=new YB("span"),YB.block=new YB("div");const $B=new class extends XP{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class XB{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=QP.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new TB(e,e.contentDOM),this.updateInner([new CB(0,0,0,e.state.doc.length)],null)}update(e){var t;let n=e.changedRanges;this.minWidth>0&&n.length&&(n.every(({fromA:e,toA:t})=>t<this.minWidthFrom||e>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let r=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&((null===(t=this.domChanged)||void 0===t?void 0:t.newSel)?r=this.domChanged.newSel.head:function(e,t){let n=!1;t&&e.iterChangedRanges((e,r)=>{e<t.to&&r>t.from&&(n=!0)});return n}(e.changes,this.hasComposition)||e.selectionSet||(r=e.state.selection.main.head));let i=r>-1?function(e,t,n){let r=QB(e,n);if(!r)return null;let{node:i,from:o,to:s}=r,a=i.nodeValue;if(/[\n\r]/.test(a))return null;if(e.state.doc.sliceString(r.from,r.to)!=a)return null;let l=t.invertedDesc;return{range:new CB(l.mapPos(o),l.mapPos(s),o,s),text:i}}(this.view,e.changes,r):null;if(this.domChanged=null,this.hasComposition){let{from:t,to:r}=this.hasComposition;n=new CB(t,r,e.changes.mapPos(t,-1),e.changes.mapPos(r,1)).addToSet(n.slice())}this.hasComposition=i?{from:i.range.fromB,to:i.range.toB}:null,(qP.ie||qP.chrome)&&!i&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,s=this.blockWrappers;this.updateDeco();let a=function(e,t,n){let r=new ZB;return hP.compare(e,t,n,r),r.changes}(o,this.decorations,e.changes);a.length&&(n=CB.extendWithRanges(n,a));let l=function(e,t,n){let r=new eI;return hP.compare(e,t,n,r),r.changes}(s,this.blockWrappers,e.changes);return l.length&&(n=CB.extendWithRanges(n,l)),i&&!n.some(e=>e.fromA<=i.range.fromA&&e.toA>=i.range.toA)&&(n=i.range.addToSet(n.slice())),!(2&this.tile.flags&&0==n.length)&&(this.updateInner(n,i),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:n}=this.view;n.ignore(()=>{if(t||e.length){let n=this.tile,r=new qB(this.view,n,this.blockWrappers,this.decorations,this.dynamicDecorationMap);this.tile=r.run(e,t),JB(n,r.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let r=qP.chrome||qP.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(r),!r||!r.written&&n.selectionRange.focusNode==r.node&&this.tile.dom.contains(r.node)||(this.forceSelection=!0),this.tile.dom.style.height=""});let r=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let e of this.tile.children)e.isWidget()&&e.widget instanceof tI&&r.push(e.dom);n.updateGaps(r)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let t of e.transactions)for(let e of t.effects)e.is(sB)&&(this.editContextFormatting=e.value)}updateSelection(e=!1,t=!1){!e&&this.view.observer.selectionRange.focusNode||this.view.observer.readSelectionRange();let{dom:n}=this.tile,r=this.view.root.activeElement,i=r==n,o=!i&&!(this.view.state.facet(lB)||n.tabIndex>-1)&&aL(n,this.view.observer.selectionRange)&&!(r&&n.contains(r));if(!(i||t||o))return;let s=this.forceSelection;this.forceSelection=!1;let a,l,c=this.view.state.selection.main;if(c.empty?l=a=this.inlineDOMNearPos(c.anchor,c.assoc||1):(l=this.inlineDOMNearPos(c.head,c.head==c.from?1:-1),a=this.inlineDOMNearPos(c.anchor,c.anchor==c.from?1:-1)),qP.gecko&&c.empty&&!this.hasComposition&&(1==(u=a).node.nodeType&&u.node.firstChild&&(0==u.offset||"false"==u.node.childNodes[u.offset-1].contentEditable)&&(u.offset==u.node.childNodes.length||"false"==u.node.childNodes[u.offset].contentEditable))){let e=document.createTextNode("");this.view.observer.ignore(()=>a.node.insertBefore(e,a.node.childNodes[a.offset]||null)),a=l=new AL(e,0),s=!0}var u;let h=this.view.observer.selectionRange;!s&&h.focusNode&&(cL(a.node,a.offset,h.anchorNode,h.anchorOffset)&&cL(l.node,l.offset,h.focusNode,h.focusOffset)||this.suppressWidgetCursorChange(h,c))||(this.view.observer.ignore(()=>{qP.android&&qP.chrome&&n.contains(h.focusNode)&&function(e,t){for(let n=e;n&&n!=t;n=n.assignedSlot||n.parentNode)if(1==n.nodeType&&"false"==n.contentEditable)return!0;return!1}(h.focusNode,n)&&(n.blur(),n.focus({preventScroll:!0}));let e=oL(this.view.root);if(e)if(c.empty){if(qP.gecko){let e=function(e,t){return 1!=e.nodeType?0:(t&&"false"==e.childNodes[t-1].contentEditable?1:0)|(t<e.childNodes.length&&"false"==e.childNodes[t].contentEditable?2:0)}(a.node,a.offset);if(e&&3!=e){let t=(1==e?CL:EL)(a.node,a.offset);t&&(a=new AL(t.node,t.offset))}}e.collapse(a.node,a.offset),null!=c.bidiLevel&&void 0!==e.caretBidiLevel&&(e.caretBidiLevel=c.bidiLevel)}else if(e.extend){e.collapse(a.node,a.offset);try{e.extend(l.node,l.offset)}catch(e){}}else{let t=document.createRange();c.anchor>c.head&&([a,l]=[l,a]),t.setEnd(l.node,l.offset),t.setStart(a.node,a.offset),e.removeAllRanges(),e.addRange(t)}else;o&&this.view.root.activeElement==n&&(n.blur(),r&&r.focus())}),this.view.observer.setSelectionRange(a,l)),this.impreciseAnchor=a.precise?null:new AL(h.anchorNode,h.anchorOffset),this.impreciseHead=l.precise?null:new AL(h.focusNode,h.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&cL(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,n=oL(e.root),{anchorNode:r,anchorOffset:i}=e.observer.selectionRange;if(!(n&&t.empty&&t.assoc&&n.modify))return;let o=this.lineAt(t.head,t.assoc);if(!o)return;let s=o.posAtStart;if(t.head==s||t.head==s+o.length)return;let a=this.coordsAt(t.head,-1),l=this.coordsAt(t.head,1);if(!a||!l||a.bottom>l.top)return;let c=this.domAtPos(t.head+t.assoc,t.assoc);n.collapse(c.node,c.offset),n.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let u=e.observer.selectionRange;e.docView.posFromDOM(u.anchorNode,u.anchorOffset)!=t.from&&n.collapse(r,i)}posFromDOM(e,t){let n=this.tile.nearest(e);if(!n)return 2&this.tile.dom.compareDocumentPosition(e)?0:this.view.state.doc.length;let r=n.posAtStart;if(!n.isComposite())return n.isText()?e==n.dom?r+t:r+(t?n.length:0):r;{let i;if(e==n.dom)i=n.dom.childNodes[t];else{let r=0==dL(e)?0:0==t?-1:1;for(;;){let t=e.parentNode;if(t==n.dom)break;0==r&&t.firstChild!=t.lastChild&&(r=e==t.firstChild?-1:1),e=t}i=r<0?e:e.nextSibling}if(i==n.dom.firstChild)return r;for(;i&&!MB.get(i);)i=i.nextSibling;if(!i)return r+n.length;for(let e=0,t=r;;e++){let r=n.children[e];if(r.dom==i)return t;t+=r.length+r.breakAfter}}}domAtPos(e,t){let{tile:n,offset:r}=this.tile.resolveBlock(e,t);return n.isWidget()?n.domPosFor(e,t):n.domIn(r,t)}inlineDOMNearPos(e,t){let n,r,i=-1,o=!1,s=-1,a=!1;return this.tile.blockTiles((t,l)=>{if(t.isWidget()){if(32&t.flags&&l>=e)return!0;16&t.flags&&(o=!0)}else{let c=l+t.length;if(l<=e&&(n=t,i=e-l,o=c<e),c>=e&&!r&&(r=t,s=e-l,a=l>e),l>e&&r)return!0}}),n||r?(o&&r?n=null:a&&n&&(r=null),n&&t<0||!r?n.domIn(i,t):r.domIn(s,t)):this.domAtPos(e,t)}coordsAt(e,t){let{tile:n,offset:r}=this.tile.resolveBlock(e,t);return n.isWidget()?n.widget instanceof tI?null:n.coordsInWidget(r,t,!0):n.coordsIn(r,t)}lineAt(e,t){let{tile:n}=this.tile.resolveBlock(e,t);return n.isLine()?n:null}coordsForChar(e){let{tile:t,offset:n}=this.tile.resolveBlock(e,1);if(!t.isLine())return null;return function e(t,n){if(t.isComposite())for(let r of t.children){if(r.length>=n){let t=e(r,n);if(t)return t}if((n-=r.length)<0)break}else if(t.isText()&&n<t.length){let e=nD(t.text,n);if(e==n)return null;let r=kL(t.dom,n,e).getClientRects();for(let e=0;e<r.length;e++){let t=r[e];if(e==r.length-1||t.top<t.bottom&&t.left<t.right)return t}}return null}(t,n)}measureVisibleLineHeights(e){let t=[],{from:n,to:r}=e,i=this.view.contentDOM.clientWidth,o=i>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,s=-1,a=this.view.textDirection==ML.LTR,l=0,c=(e,u,h)=>{for(let f=0;f<e.children.length&&!(u>r);f++){let r=e.children[f],d=u+r.length,p=r.dom.getBoundingClientRect(),{height:m}=p;if(h&&!f&&(l+=p.top-h.top),r instanceof RB)d>n&&c(r,u,p);else if(u>=n&&(l>0&&t.push(-l),t.push(m+l),l=0,o)){let e=r.dom.lastChild,t=e?lL(e):[];if(t.length){let e=t[t.length-1],n=a?e.right-p.left:p.right-e.left;n>s&&(s=n,this.minWidth=i,this.minWidthFrom=u,this.minWidthTo=d)}}h&&f==e.children.length-1&&(l+=h.bottom-p.bottom),u=d+r.breakAfter}};return c(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return"rtl"==getComputedStyle(t.dom).direction?ML.RTL:ML.LTR}measureTextSize(){let e=this.tile.blockTiles(e=>{if(e.isLine()&&e.children.length&&e.length<=20){let t,n=0;for(let r of e.children){if(!r.isText()||/[^ -~]/.test(r.text))return;let e=lL(r.dom);if(1!=e.length)return;n+=e[0].width,t=e[0].height}if(n)return{lineHeight:e.dom.getBoundingClientRect().height,charWidth:n/e.length,textHeight:t}}});if(e)return e;let t,n,r,i=document.createElement("div");return i.className="cm-line",i.style.width="99999px",i.style.position="absolute",i.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(i);let e=lL(i.firstChild)[0];t=i.getBoundingClientRect().height,n=e&&e.width?e.width/27:7,r=e&&e.height?e.height:t,i.remove()}),{lineHeight:t,charWidth:n,textHeight:r}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let n=0,r=0;;r++){let i=r==t.viewports.length?null:t.viewports[r],o=i?i.from-1:this.view.state.doc.length;if(o>n){let r=(t.lineBlockAt(o).bottom-t.lineBlockAt(n).top)/this.view.scaleY;e.push(QP.replace({widget:new tI(r),block:!0,inclusive:!0,isBlockGap:!0}).range(n,o))}if(!i)break;n=i.to+1}return QP.set(e)}updateDeco(){let e=1,t=this.view.state.facet(mB).map(t=>(this.dynamicDecorationMap[e++]="function"==typeof t)?t(this.view):t),n=!1,r=this.view.state.facet(vB).map((e,t)=>{let r="function"==typeof e;return r&&(n=!0),r?e(this.view):e});for(r.length&&(this.dynamicDecorationMap[e++]=n,t.push(hP.join(r))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;this.blockWrappers=this.view.state.facet(gB).map(e=>"function"==typeof e?e(this.view):e)}scrollIntoView(e){if(e.isSnapshot){let t=this.view.viewState.lineBlockAt(e.range.head);return this.view.scrollDOM.scrollTop=t.top-e.yMargin,void(this.view.scrollDOM.scrollLeft=e.xMargin)}for(let t of this.view.state.facet(rB))try{if(t(this.view,e.range,e))return!0}catch(e){aB(this.view.state,e,"scroll handler")}let t,{range:n}=e,r=this.coordsAt(n.head,n.empty?n.assoc:n.head>n.anchor?-1:1);if(!r)return;!n.empty&&(t=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(r={left:Math.min(r.left,t.left),top:Math.min(r.top,t.top),right:Math.max(r.right,t.right),bottom:Math.max(r.bottom,t.bottom)});let i=xB(this.view),o={left:r.left-i.left,top:r.top-i.top,right:r.right+i.right,bottom:r.bottom+i.bottom},{offsetWidth:s,offsetHeight:a}=this.view.scrollDOM;!function(e,t,n,r,i,o,s,a){let l=e.ownerDocument,c=l.defaultView||window;for(let u=e,h=!1;u&&!h;)if(1==u.nodeType){let e,f=u==l.body,d=1,p=1;if(f)e=mL(c);else{if(/^(fixed|sticky)$/.test(getComputedStyle(u).position)&&(h=!0),u.scrollHeight<=u.clientHeight&&u.scrollWidth<=u.clientWidth){u=u.assignedSlot||u.parentNode;continue}let t=u.getBoundingClientRect();({scaleX:d,scaleY:p}=gL(u,t)),e={left:t.left,right:t.left+u.clientWidth*d,top:t.top,bottom:t.top+u.clientHeight*p}}let m=0,g=0;if("nearest"==i)t.top<e.top?(g=t.top-(e.top+s),n>0&&t.bottom>e.bottom+g&&(g=t.bottom-e.bottom+s)):t.bottom>e.bottom&&(g=t.bottom-e.bottom+s,n<0&&t.top-g<e.top&&(g=t.top-(e.top+s)));else{let r=t.bottom-t.top,o=e.bottom-e.top;g=("center"==i&&r<=o?t.top+r/2-o/2:"start"==i||"center"==i&&n<0?t.top-s:t.bottom-o+s)-e.top}if("nearest"==r?t.left<e.left?(m=t.left-(e.left+o),n>0&&t.right>e.right+m&&(m=t.right-e.right+o)):t.right>e.right&&(m=t.right-e.right+o,n<0&&t.left<e.left+m&&(m=t.left-(e.left+o))):m=("center"==r?t.left+(t.right-t.left)/2-(e.right-e.left)/2:"start"==r==a?t.left-o:t.right-(e.right-e.left)+o)-e.left,m||g)if(f)c.scrollBy(m,g);else{let e=0,n=0;if(g){let e=u.scrollTop;u.scrollTop+=g/p,n=(u.scrollTop-e)*p}if(m){let t=u.scrollLeft;u.scrollLeft+=m/d,e=(u.scrollLeft-t)*d}t={left:t.left-e,top:t.top-n,right:t.right-e,bottom:t.bottom-n},e&&Math.abs(e-m)<1&&(r="nearest"),n&&Math.abs(n-g)<1&&(i="nearest")}if(f)break;(t.top<e.top||t.bottom>e.bottom||t.left<e.left||t.right>e.right)&&(t={left:Math.max(t.left,e.left),right:Math.min(t.right,e.right),top:Math.max(t.top,e.top),bottom:Math.min(t.bottom,e.bottom)}),u=u.assignedSlot||u.parentNode}else{if(11!=u.nodeType)break;u=u.host}}(this.view.scrollDOM,o,n.head<n.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,s),-s),Math.max(Math.min(e.yMargin,a),-a),this.view.textDirection==ML.LTR)}lineHasWidget(e){let t=e=>e.isWidget()||e.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){JB(this.tile)}}function JB(e,t){let n=null==t?void 0:t.get(e);if(1!=n){null==n&&e.destroy();for(let n of e.children)JB(n,t)}}function QB(e,t){let n=e.observer.selectionRange;if(!n.focusNode)return null;let r=CL(n.focusNode,n.focusOffset),i=EL(n.focusNode,n.focusOffset),o=r||i;if(i&&r&&i.node!=r.node){let t=MB.get(i.node);if(!t||t.isText()&&t.text!=i.node.nodeValue)o=i;else if(e.docView.lastCompositionAfterCursor){let e=MB.get(r.node);!e||e.isText()&&e.text!=r.node.nodeValue||(o=i)}}if(e.docView.lastCompositionAfterCursor=o!=r,!o)return null;let s=t-o.offset;return{from:s,to:s+o.node.nodeValue.length,node:o.node}}let ZB=class{constructor(){this.changes=[]}compareRange(e,t){rL(e,t,this.changes)}comparePoint(e,t){rL(e,t,this.changes)}boundChange(e){rL(e,e,this.changes)}};class eI{constructor(){this.changes=[]}compareRange(e,t){rL(e,t,this.changes)}comparePoint(){}boundChange(e){rL(e,e,this.changes)}}class tI extends XP{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function nI(e,t,n,r,i){let o=Math.round((r-t.left)*e.defaultCharacterWidth);if(e.lineWrapping&&n.height>1.5*e.defaultLineHeight){let t=e.viewState.heightOracle.textHeight;o+=Math.floor((i-n.top-.5*(e.defaultLineHeight-t))/t)*e.viewState.heightOracle.lineLength}let s=e.state.sliceDoc(n.from,n.to);return n.from+function(e,t,n,r){for(let r=0,i=0;;){if(i>=t)return r;if(r==e.length)break;i+=9==e.charCodeAt(r)?n-i%n:1,r=nD(e,r)}return!0===r?-1:e.length}(s,o,e.state.tabSize)}function rI(e,t,n,r){let i=function(e,t,n){let r=e.lineBlockAt(t);if(Array.isArray(r.type)){let e;for(let i of r.type){if(i.from>t)break;if(!(i.to<t)){if(i.from<t&&i.to>t)return i;e&&(i.type!=JP.Text||e.type==i.type&&!(n<0?i.from<t:i.to>t))||(e=i)}}return e||r}return r}(e,t.head,t.assoc||-1),o=r&&i.type==JP.Text&&(e.lineWrapping||i.widgetLineBreaks)?e.coordsAtPos(t.assoc<0&&t.head>i.from?t.head-1:t.head):null;if(o){let t=e.dom.getBoundingClientRect(),r=e.textDirectionAt(i.from),s=e.posAtCoords({x:n==(r==ML.LTR)?t.right-1:t.left+1,y:(o.top+o.bottom)/2});if(null!=s)return pD.cursor(s,n?-1:1)}return pD.cursor(n?i.to:i.from,n?-1:1)}function iI(e,t,n,r){let i=e.state.doc.lineAt(t.head),o=e.bidiSpans(i),s=e.textDirectionAt(i.from);for(let a=t,l=null;;){let t=qL(i,o,s,a,n),c=VL;if(!t){if(i.number==(n?e.state.doc.lines:1))return a;c="\n",i=e.state.doc.line(i.number+(n?1:-1)),o=e.bidiSpans(i),t=e.visualLineSide(i,!n)}if(l){if(!l(c))return a}else{if(!r)return t;l=r(c)}a=t}}function oI(e,t,n){for(;;){let r=0;for(let i of e)i.between(t-1,t+1,(e,i,o)=>{if(t>e&&t<i){let o=r||n||(t-e<i-t?-1:1);t=o<0?e:i,r=o}});if(!r)return t}}function sI(e,t){let n=null;for(let r=0;r<t.ranges.length;r++){let i=t.ranges[r],o=null;if(i.empty){let t=oI(e,i.from,0);t!=i.from&&(o=pD.cursor(t,-1))}else{let t=oI(e,i.from,-1),n=oI(e,i.to,1);t==i.from&&n==i.to||(o=pD.range(i.from==i.anchor?t:n,i.from==i.head?t:n))}o&&(n||(n=t.ranges.slice()),n[r]=o)}return n?pD.create(n,t.mainIndex):t}function aI(e,t,n){let r=oI(e.state.facet(yB).map(t=>t(e)),n.from,t.head>n.from?-1:1);return r==n.from?n:pD.cursor(r,r<n.from?1:-1)}class lI{constructor(e,t){this.pos=e,this.assoc=t}}function cI(e,t,n,r){let i,o=e.contentDOM.getBoundingClientRect(),s=o.top+e.viewState.paddingTop,{x:a,y:l}=t,c=l-s;for(;;){if(c<0)return new lI(0,1);if(c>e.viewState.docHeight)return new lI(e.state.doc.length,-1);if(i=e.elementAtHeight(c),null==r)break;if(i.type==JP.Text){let t=e.docView.coordsAt(r<0?i.from:i.to,r);if(t&&(r<0?t.top<=c+s:t.bottom>=c+s))break}let t=e.viewState.heightOracle.textHeight/2;c=r>0?i.bottom+t:i.top-t}if(e.viewport.from>=i.to||e.viewport.to<=i.from){if(n)return null;if(i.type==JP.Text){let t=nI(e,o,i,a,l);return new lI(t,t==i.from?1:-1)}}if(i.type!=JP.Text)return c<(i.top+i.bottom)/2?new lI(i.from,1):new lI(i.to,-1);let u=e.docView.lineAt(i.from,2);return u&&u.length==i.length||(u=e.docView.lineAt(i.from,-2)),uI(e,u,i.from,a,l)}function uI(e,t,n,r,i){let o=-1,s=null,a=1e9,l=1e9,c=i,u=i,h=(e,t)=>{for(let n=0;n<e.length;n++){let h=e[n];if(h.top==h.bottom)continue;let f=h.left>r?h.left-r:h.right<r?r-h.right:0,d=h.top>i?h.top-i:h.bottom<i?i-h.bottom:0;h.top<=u&&h.bottom>=c&&(c=Math.min(h.top,c),u=Math.max(h.bottom,u),d=0),(o<0||(d-l||f-a)<0)&&(o>=0&&l&&a<f&&s.top<=u-2&&s.bottom>=c+2?l=0:(o=t,a=f,l=d,s=h))}};if(t.isText()){for(let e=0;e<t.length;){let n=nD(t.text,e);if(h(kL(t.dom,e,n).getClientRects(),e),!a&&!l)break;e=n}return r>(s.left+s.right)/2==(hI(e,o+n)==ML.LTR)?new lI(n+nD(t.text,o),-1):new lI(n+o,1)}{if(!t.length)return new lI(n,1);for(let e=0;e<t.children.length;e++){let n=t.children[e];if(!(48&n.flags)&&(h((1==n.dom.nodeType?n.dom:kL(n.dom,0,n.length)).getClientRects(),e),!a&&!l))break}let c=t.children[o],u=t.posBefore(c,n);return c.isComposite()||c.isText()?uI(e,c,u,Math.max(s.left,Math.min(s.right,r)),i):r>(s.left+s.right)/2==(hI(e,o+n)==ML.LTR)?new lI(u+c.length,-1):new lI(u,1)}}function hI(e,t){let n=e.state.doc.lineAt(t);return e.bidiSpans(n)[_L.find(e.bidiSpans(n),t-n.from,-1,1)].dir}const fI="￿";class dI{constructor(e,t){this.points=e,this.view=t,this.text="",this.lineSeparator=t.state.facet(oP.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=fI}readRange(e,t){if(!e)return this;let n=e.parentNode;for(let r=e;;){this.findPointBefore(n,r);let e=this.text.length;this.readNode(r);let i=MB.get(r),o=r.nextSibling;if(o==t){(null==i?void 0:i.breakAfter)&&!o&&n!=this.view.contentDOM&&this.lineBreak();break}let s=MB.get(o);(i&&s?i.breakAfter:(i?i.breakAfter:hL(r))||hL(o)&&("BR"!=r.nodeName||(null==i?void 0:i.isWidget()))&&this.text.length>e)&&!mI(o,t)&&this.lineBreak(),r=o}return this.findPointBefore(n,t),this}readTextNode(e){let t=e.nodeValue;for(let n of this.points)n.node==e&&(n.pos=this.text.length+Math.min(n.offset,t.length));for(let n=0,r=this.lineSeparator?null:/\r\n?|\n/g;;){let i,o=-1,s=1;if(this.lineSeparator?(o=t.indexOf(this.lineSeparator,n),s=this.lineSeparator.length):(i=r.exec(t))&&(o=i.index,s=i[0].length),this.append(t.slice(n,o<0?t.length:o)),o<0)break;if(this.lineBreak(),s>1)for(let t of this.points)t.node==e&&t.pos>this.text.length&&(t.pos-=s-1);n=o+s}}readNode(e){let t=MB.get(e),n=t&&t.overrideDOMText;if(null!=n){this.findPointInside(e,n.length);for(let e=n.iter();!e.next().done;)e.lineBreak?this.lineBreak():this.append(e.value)}else 3==e.nodeType?this.readTextNode(e):"BR"==e.nodeName?e.nextSibling&&this.lineBreak():1==e.nodeType&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let n of this.points)n.node==e&&e.childNodes[n.offset]==t&&(n.pos=this.text.length)}findPointInside(e,t){for(let n of this.points)(3==e.nodeType?n.node==e:e.contains(n.node))&&(n.pos=this.text.length+(pI(e,n.node,n.offset)?t:0))}}function pI(e,t,n){for(;;){if(!t||n<dL(t))return!1;if(t==e)return!0;n=uL(t)+1,t=t.parentNode}}function mI(e,t){let n;for(;e!=t&&e;e=e.nextSibling){let t=MB.get(e);if(!(null==t?void 0:t.isWidget()))return!1;t&&(n||(n=[])).push(t)}if(n)for(let e of n){let t=e.overrideDOMText;if(null==t?void 0:t.length)return!1}return!0}class gI{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}}class vI{constructor(e,t,n,r){this.typeOver=r,this.bounds=null,this.text="",this.domChanged=t>-1;let{impreciseHead:i,impreciseAnchor:o}=e.docView;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=yI(e.docView.tile,t,n,0))){let t=i||o?[]:function(e){let t=[];if(e.root.activeElement!=e.contentDOM)return t;let{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:o}=e.observer.selectionRange;n&&(t.push(new gI(n,r)),i==n&&o==r||t.push(new gI(i,o)));return t}(e),n=new dI(t,e);n.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=n.text,this.newSel=function(e,t){if(0==e.length)return null;let n=e[0].pos,r=2==e.length?e[1].pos:n;return n>-1&&r>-1?pD.single(n+t,r+t):null}(t,this.bounds.from)}else{let t=e.observer.selectionRange,n=i&&i.node==t.focusNode&&i.offset==t.focusOffset||!sL(e.contentDOM,t.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(t.focusNode,t.focusOffset),r=o&&o.node==t.anchorNode&&o.offset==t.anchorOffset||!sL(e.contentDOM,t.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(t.anchorNode,t.anchorOffset),s=e.viewport;if((qP.ios||qP.chrome)&&e.state.selection.main.empty&&n!=r&&(s.from>0||s.to<e.state.doc.length)){let t=Math.min(n,r),i=Math.max(n,r),o=s.from-t,a=s.to-i;0!=o&&1!=o&&0!=t||0!=a&&-1!=a&&i!=e.state.doc.length||(n=0,r=e.state.doc.length)}e.inputState.composing>-1&&e.state.selection.ranges.length>1?this.newSel=e.state.selection.replaceRange(pD.range(r,n)):this.newSel=pD.single(r,n)}}}function yI(e,t,n,r){if(e.isComposite()){let i=-1,o=-1,s=-1,a=-1;for(let l=0,c=r,u=r;l<e.children.length;l++){let r=e.children[l],h=c+r.length;if(c<t&&h>n)return yI(r,t,n,c);if(h>=t&&-1==i&&(i=l,o=c),c>n&&r.dom.parentNode==e.dom){s=l,a=u;break}u=h,c=h+r.breakAfter}return{from:o,to:a<0?r+e.length:a,startDOM:(i?e.children[i-1].dom.nextSibling:null)||e.dom.firstChild,endDOM:s<e.children.length&&s>=0?e.children[s].dom:null}}return e.isText()?{from:r,to:r+e.length,startDOM:e.dom,endDOM:e.dom.nextSibling}:null}function bI(e,t){let n,{newSel:r}=t,i=e.state.selection.main,o=e.inputState.lastKeyTime>Date.now()-100?e.inputState.lastKeyCode:-1;if(t.bounds){let{from:r,to:s}=t.bounds,a=i.from,l=null;(8===o||qP.android&&t.text.length<s-r)&&(a=i.to,l="end");let c=kI(e.state.doc.sliceString(r,s,fI),t.text,a-r,l);c&&(qP.chrome&&13==o&&c.toB==c.from+2&&t.text.slice(c.from,c.toB)==fI+fI&&c.toB--,n={from:r+c.from,to:r+c.toA,insert:KR.of(t.text.slice(c.from,c.toB).split(fI))})}else r&&(!e.hasFocus&&e.state.facet(lB)||xI(r,i))&&(r=null);if(!n&&!r)return!1;if(!n&&t.typeOver&&!i.empty&&r&&r.main.empty?n={from:i.from,to:i.to,insert:e.state.doc.slice(i.from,i.to)}:(qP.mac||qP.android)&&n&&n.from==n.to&&n.from==i.head-1&&/^\. ?$/.test(n.insert.toString())&&"off"==e.contentDOM.getAttribute("autocorrect")?(r&&2==n.insert.length&&(r=pD.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:KR.of([n.insert.toString().replace("."," ")])}):n&&n.from>=i.from&&n.to<=i.to&&(n.from!=i.from||n.to!=i.to)&&i.to-i.from-(n.to-n.from)<=4?n={from:i.from,to:i.to,insert:e.state.doc.slice(i.from,n.from).append(n.insert).append(e.state.doc.slice(n.to,i.to))}:e.state.doc.lineAt(i.from).to<i.to&&e.docView.lineHasWidget(i.to)&&e.inputState.insertingTextAt>Date.now()-50?n={from:i.from,to:i.to,insert:e.state.toText(e.inputState.insertingText)}:qP.chrome&&n&&n.from==n.to&&n.from==i.head&&"\n "==n.insert.toString()&&e.lineWrapping&&(r&&(r=pD.single(r.main.anchor-1,r.main.head-1)),n={from:i.from,to:i.to,insert:KR.of([" "])}),n)return wI(e,n,r,o);if(r&&!xI(r,i)){let t=!1,n="select";return e.inputState.lastSelectionTime>Date.now()-50&&("select"==e.inputState.lastSelectionOrigin&&(t=!0),n=e.inputState.lastSelectionOrigin,"select.pointer"==n&&(r=sI(e.state.facet(yB).map(t=>t(e)),r))),e.dispatch({selection:r,scrollIntoView:t,userEvent:n}),!0}return!1}function wI(e,t,n,r=-1){if(qP.ios&&e.inputState.flushIOSKey(t))return!0;let i=e.state.selection.main;if(qP.android&&(t.to==i.to&&(t.from==i.from||t.from==i.from-1&&" "==e.state.sliceDoc(t.from,i.from))&&1==t.insert.length&&2==t.insert.lines&&xL(e.contentDOM,"Enter",13)||(t.from==i.from-1&&t.to==i.to&&0==t.insert.length||8==r&&t.insert.length<t.to-t.from&&t.to>i.head)&&xL(e.contentDOM,"Backspace",8)||t.from==i.from&&t.to==i.to+1&&0==t.insert.length&&xL(e.contentDOM,"Delete",46)))return!0;let o,s=t.insert.toString();e.inputState.composing>=0&&e.inputState.composing++;let a=()=>o||(o=function(e,t,n){let r,i=e.state,o=i.selection.main,s=-1;if(t.from==t.to&&t.from<o.from||t.from>o.to){let n=t.from<o.from?-1:1,r=n<0?o.from:o.to,a=oI(i.facet(yB).map(t=>t(e)),r,n);t.from==a&&(s=a)}if(s>-1)r={changes:t,selection:pD.cursor(t.from+t.insert.length,-1)};else if(t.from>=o.from&&t.to<=o.to&&t.to-t.from>=(o.to-o.from)/3&&(!n||n.main.empty&&n.main.from==t.from+t.insert.length)&&e.inputState.composing<0){let n=o.from<t.from?i.sliceDoc(o.from,t.from):"",s=o.to>t.to?i.sliceDoc(t.to,o.to):"";r=i.replaceSelection(e.state.toText(n+t.insert.sliceString(0,void 0,e.state.lineBreak)+s))}else{let s=i.changes(t),a=n&&n.main.to<=s.newLength?n.main:void 0;if(i.selection.ranges.length>1&&(e.inputState.composing>=0||e.inputState.compositionPendingChange)&&t.to<=o.to+10&&t.to>=o.to-10){let l,c=e.state.sliceDoc(t.from,t.to),u=n&&QB(e,n.main.head);if(u){let e=t.insert.length-(t.to-t.from);l={from:u.from,to:u.to-e}}else l=e.state.doc.lineAt(o.head);let h=o.to-t.to;r=i.changeByRange(n=>{if(n.from==o.from&&n.to==o.to)return{changes:s,range:a||n.map(s)};let r=n.to-h,u=r-c.length;if(e.state.sliceDoc(u,r)!=c||r>=l.from&&u<=l.to)return{range:n};let f=i.changes({from:u,to:r,insert:t.insert}),d=n.to-o.to;return{changes:f,range:a?pD.range(Math.max(0,a.anchor+d),Math.max(0,a.head+d)):n.map(f)}})}else r={changes:s,selection:a&&i.selection.replaceRange(a)}}let a="input.type";(e.composing||e.inputState.compositionPendingChange&&e.inputState.compositionEndedAt>Date.now()-50)&&(e.inputState.compositionPendingChange=!1,a+=".compose",e.inputState.compositionFirstChange&&(a+=".start",e.inputState.compositionFirstChange=!1));return i.update(r,{userEvent:a,scrollIntoView:!0})}(e,t,n));return e.state.facet(JL).some(n=>n(e,t.from,t.to,s,a))||e.dispatch(a()),!0}function kI(e,t,n,r){let i=Math.min(e.length,t.length),o=0;for(;o<i&&e.charCodeAt(o)==t.charCodeAt(o);)o++;if(o==i&&e.length==t.length)return null;let s=e.length,a=t.length;for(;s>0&&a>0&&e.charCodeAt(s-1)==t.charCodeAt(a-1);)s--,a--;if("end"==r){n-=s+Math.max(0,o-Math.min(s,a))-o}if(s<o&&e.length<t.length){o-=n<=o&&n>=s?o-n:0,a=o+(a-s),s=o}else if(a<o){o-=n<=o&&n>=a?o-n:0,s=o+(s-a),a=o}return{from:o,toA:s,toB:a}}function xI(e,t){return t.head==e.main.head&&t.anchor==e.main.anchor}class SI{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,qP.safari&&e.contentDOM.addEventListener("input",()=>null),qP.gecko&&function(e){GI.has(e)||(GI.add(e),e.addEventListener("copy",()=>{}),e.addEventListener("cut",()=>{}))}(e.contentDOM.ownerDocument)}handleEvent(e){(function(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n,r=t.target;r!=e.contentDOM;r=r.parentNode)if(!r||11==r.nodeType||(n=MB.get(r))&&n.isWidget()&&!n.isHidden&&n.widget.ignoreEvent(t))return!1;return!0})(this.view,e)&&!this.ignoreDuringComposition(e)&&("keydown"==e.type&&this.keydown(e)||(0!=this.view.updateState?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e)))}runHandlers(e,t){let n=this.handlers[e];if(n){for(let e of n.observers)e(this.view,t);for(let e of n.handlers){if(t.defaultPrevented)break;if(e(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=EI(e),n=this.handlers,r=this.view.contentDOM;for(let e in t)if("scroll"!=e){let i=!t[e].handlers.length,o=n[e];o&&i!=!o.handlers.length&&(r.removeEventListener(e,this.handleEvent),o=null),o||r.addEventListener(e,this.handleEvent,{passive:i})}for(let e in n)"scroll"==e||t[e]||r.removeEventListener(e,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),9==e.keyCode&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&27!=e.keyCode&&OI.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),qP.android&&qP.chrome&&!e.synthetic&&(13==e.keyCode||8==e.keyCode))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return!qP.ios||e.synthetic||e.altKey||e.metaKey||!((t=AI.find(t=>t.keyCode==e.keyCode))&&!e.ctrlKey||MI.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey)?(229!=e.keyCode&&this.view.observer.forceFlush(),!1):(this.pendingIOSKey=t||e,setTimeout(()=>this.flushIOSKey(),250),!0)}flushIOSKey(e){let t=this.pendingIOSKey;return!!t&&(!("Enter"==t.key&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString()))&&(this.pendingIOSKey=void 0,xL(this.view.contentDOM,t.key,t.keyCode,t instanceof KeyboardEvent?t:void 0)))}ignoreDuringComposition(e){return!(!/^key/.test(e.type)||e.synthetic)&&(this.composing>0||!!(qP.safari&&!qP.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100)&&(this.compositionPendingKey=!1,!0))}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function CI(e,t){return(n,r)=>{try{return t.call(e,r,n)}catch(e){aB(n.state,e)}}}function EI(e){let t=Object.create(null);function n(e){return t[e]||(t[e]={observers:[],handlers:[]})}for(let t of e){let e=t.spec,r=e&&e.plugin.domEventHandlers,i=e&&e.plugin.domEventObservers;if(r)for(let e in r){let i=r[e];i&&n(e).handlers.push(CI(t.value,i))}if(i)for(let e in i){let r=i[e];r&&n(e).observers.push(CI(t.value,r))}}for(let e in RI)n(e).handlers.push(RI[e]);for(let e in DI)n(e).observers.push(DI[e]);return t}const AI=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],MI="dthko",OI=[16,17,18,20,91,92,224,225];function NI(e){return.7*Math.max(0,e)+8}class TI{constructor(e,t,n,r){this.view=e,this.startEvent=t,this.style=n,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=function(e){let t,n,r=e.ownerDocument;for(let i=e.parentNode;i&&!(i==r.body||t&&n);)if(1==i.nodeType)!n&&i.scrollHeight>i.clientHeight&&(n=i),!t&&i.scrollWidth>i.clientWidth&&(t=i),i=i.assignedSlot||i.parentNode;else{if(11!=i.nodeType)break;i=i.host}return{x:t,y:n}}(e.contentDOM),this.atoms=e.state.facet(yB).map(t=>t(e));let i=e.contentDOM.ownerDocument;i.addEventListener("mousemove",this.move=this.move.bind(this)),i.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(oP.allowMultipleSelections)&&function(e,t){let n=e.state.facet(KL);return n.length?n[0](t):qP.mac?t.metaKey:t.ctrlKey}(e,t),this.dragging=!(!function(e,t){let{main:n}=e.state.selection;if(n.empty)return!1;let r=oL(e.root);if(!r||0==r.rangeCount)return!0;let i=r.getRangeAt(0).getClientRects();for(let e=0;e<i.length;e++){let n=i[e];if(n.left<=t.clientX&&n.right>=t.clientX&&n.top<=t.clientY&&n.bottom>=t.clientY)return!0}return!1}(e,t)||1!=HI(t))&&null}start(e){!1===this.dragging&&this.select(e)}move(e){if(0==e.buttons)return this.destroy();if(this.dragging||null==this.dragging&&(t=this.startEvent,n=e,Math.max(Math.abs(t.clientX-n.clientX),Math.abs(t.clientY-n.clientY))<10))return;var t,n;this.select(this.lastEvent=e);let r=0,i=0,o=0,s=0,a=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:o,right:a}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:l}=this.scrollParents.y.getBoundingClientRect());let c=xB(this.view);e.clientX-c.left<=o+6?r=-NI(o-e.clientX):e.clientX+c.right>=a-6&&(r=NI(e.clientX-a)),e.clientY-c.top<=s+6?i=-NI(s-e.clientY):e.clientY+c.bottom>=l-6&&(i=NI(e.clientY-l)),this.setScrollSpeed(r,i)}up(e){null==this.dragging&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),!1===this.dragging&&this.select(this.lastEvent)}select(e){let{view:t}=this,n=sI(this.atoms,this.style.get(e,this.extend,this.multiple));!this.mustSelect&&n.eq(t.state.selection,!1===this.dragging)||this.view.dispatch({selection:n,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(e=>e.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}const RI=Object.create(null),DI=Object.create(null),PI=qP.ie&&qP.ie_version<15||qP.ios&&qP.webkit_version<604;function LI(e,t,n){for(let r of e.facet(t))n=r(n,e);return n}function BI(e,t){t=LI(e.state,ZL,t);let n,{state:r}=e,i=1,o=r.toText(t),s=o.lines==r.selection.ranges.length,a=null!=VI&&r.selection.ranges.every(e=>e.empty)&&VI==o.toString();if(a){let e=-1;n=r.changeByRange(n=>{let a=r.doc.lineAt(n.from);if(a.from==e)return{range:n};e=a.from;let l=r.toText((s?o.line(i++).text:t)+r.lineBreak);return{changes:{from:a.from,insert:l},range:pD.cursor(n.from+l.length)}})}else n=s?r.changeByRange(e=>{let t=o.line(i++);return{changes:{from:e.from,to:e.to,insert:t.text},range:pD.cursor(e.from+t.length)}}):r.replaceSelection(o);e.dispatch(n,{userEvent:"input.paste",scrollIntoView:!0})}function II(e,t,n,r){if(1==r)return pD.cursor(t,n);if(2==r)return function(e,t,n=1){let r=e.charCategorizer(t),i=e.doc.lineAt(t),o=t-i.from;if(0==i.length)return pD.cursor(t);0==o?n=1:o==i.length&&(n=-1);let s=o,a=o;n<0?s=nD(i.text,o,!1):a=nD(i.text,o);let l=r(i.text.slice(s,a));for(;s>0;){let e=nD(i.text,s,!1);if(r(i.text.slice(e,s))!=l)break;s=e}for(;a<i.length;){let e=nD(i.text,a);if(r(i.text.slice(a,e))!=l)break;a=e}return pD.range(s+i.from,a+i.from)}(e.state,t,n);{let r=e.docView.lineAt(t,n),i=e.state.doc.lineAt(r?r.posAtEnd:t),o=r?r.posAtStart:i.from,s=r?r.posAtEnd:i.to;return s<e.state.doc.length&&s==i.to&&s++,pD.range(o,s)}}DI.scroll=e=>{e.inputState.lastScrollTop=e.scrollDOM.scrollTop,e.inputState.lastScrollLeft=e.scrollDOM.scrollLeft},RI.keydown=(e,t)=>(e.inputState.setSelectionOrigin("select"),27==t.keyCode&&0!=e.inputState.tabFocusMode&&(e.inputState.tabFocusMode=Date.now()+2e3),!1),DI.touchstart=(e,t)=>{e.inputState.lastTouchTime=Date.now(),e.inputState.setSelectionOrigin("select.pointer")},DI.touchmove=e=>{e.inputState.setSelectionOrigin("select.pointer")},RI.mousedown=(e,t)=>{if(e.observer.flush(),e.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of e.state.facet(YL))if(n=r(e,t),n)break;if(n||0!=t.button||(n=function(e,t){let n=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),r=HI(t),i=e.state.selection;return{update(e){e.docChanged&&(n.pos=e.changes.mapPos(n.pos),i=i.map(e.changes))},get(t,o,s){let a,l=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),c=II(e,l.pos,l.assoc,r);if(n.pos!=l.pos&&!o){let t=II(e,n.pos,n.assoc,r),i=Math.min(t.from,c.from),o=Math.max(t.to,c.to);c=i<c.from?pD.range(i,o):pD.range(o,i)}return o?i.replaceRange(i.main.extend(c.from,c.to)):s&&1==r&&i.ranges.length>1&&(a=function(e,t){for(let n=0;n<e.ranges.length;n++){let{from:r,to:i}=e.ranges[n];if(r<=t&&i>=t)return pD.create(e.ranges.slice(0,n).concat(e.ranges.slice(n+1)),e.mainIndex==n?0:e.mainIndex-(e.mainIndex>n?1:0))}return null}(i,l.pos))?a:s?i.addRange(c):pD.create([c])}}}(e,t)),n){let r=!e.hasFocus;e.inputState.startMouseSelection(new TI(e,t,n,r)),r&&e.observer.ignore(()=>{wL(e.contentDOM);let t=e.root.activeElement;t&&!t.contains(e.contentDOM)&&t.blur()});let i=e.inputState.mouseSelection;if(i)return i.start(t),!1===i.dragging}else e.inputState.setSelectionOrigin("select.pointer");return!1};const _I=qP.ie&&qP.ie_version<=11;let FI=null,WI=0,jI=0;function HI(e){if(!_I)return e.detail;let t=FI,n=jI;return FI=e,jI=Date.now(),WI=!t||n>Date.now()-400&&Math.abs(t.clientX-e.clientX)<2&&Math.abs(t.clientY-e.clientY)<2?(WI+1)%3:1}function zI(e,t,n,r){if(!(n=LI(e.state,ZL,n)))return;let i=e.posAtCoords({x:t.clientX,y:t.clientY},!1),{draggedContent:o}=e.inputState,s=r&&o&&function(e,t){let n=e.state.facet(GL);return n.length?n[0](t):qP.mac?!t.altKey:!t.ctrlKey}(e,t)?{from:o.from,to:o.to}:null,a={from:i,insert:n},l=e.state.changes(s?[s,a]:a);e.focus(),e.dispatch({changes:l,selection:{anchor:l.mapPos(i,-1),head:l.mapPos(i,1)},userEvent:s?"move.drop":"input.drop"}),e.inputState.draggedContent=null}RI.dragstart=(e,t)=>{let{selection:{main:n}}=e.state;if(t.target.draggable){let r=e.docView.tile.nearest(t.target);if(r&&r.isWidget()){let e=r.posAtStart,t=e+r.length;(e>=n.to||t<=n.from)&&(n=pD.range(e,t))}}let{inputState:r}=e;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,t.dataTransfer&&(t.dataTransfer.setData("Text",LI(e.state,eB,e.state.sliceDoc(n.from,n.to))),t.dataTransfer.effectAllowed="copyMove"),!1},RI.dragend=e=>(e.inputState.draggedContent=null,!1),RI.drop=(e,t)=>{if(!t.dataTransfer)return!1;if(e.state.readOnly)return!0;let n=t.dataTransfer.files;if(n&&n.length){let r=Array(n.length),i=0,o=()=>{++i==n.length&&zI(e,t,r.filter(e=>null!=e).join(e.state.lineBreak),!1)};for(let e=0;e<n.length;e++){let t=new FileReader;t.onerror=o,t.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(t.result)||(r[e]=t.result),o()},t.readAsText(n[e])}return!0}{let n=t.dataTransfer.getData("Text");if(n)return zI(e,t,n,!0),!0}return!1},RI.paste=(e,t)=>{if(e.state.readOnly)return!0;e.observer.flush();let n=PI?null:t.clipboardData;return n?(BI(e,n.getData("text/plain")||n.getData("text/uri-list")),!0):(function(e){let t=e.dom.parentNode;if(!t)return;let n=t.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{e.focus(),n.remove(),BI(e,n.value)},50)}(e),!1)};let VI=null;RI.copy=RI.cut=(e,t)=>{let n=oL(e.root);if(n&&!aL(e.contentDOM,n))return!1;let{text:r,ranges:i,linewise:o}=function(e){let t=[],n=[],r=!1;for(let r of e.selection.ranges)r.empty||(t.push(e.sliceDoc(r.from,r.to)),n.push(r));if(!t.length){let i=-1;for(let{from:r}of e.selection.ranges){let o=e.doc.lineAt(r);o.number>i&&(t.push(o.text),n.push({from:o.from,to:Math.min(e.doc.length,o.to+1)})),i=o.number}r=!0}return{text:LI(e,eB,t.join(e.lineBreak)),ranges:n,linewise:r}}(e.state);if(!r&&!o)return!1;VI=o?r:null,"cut"!=t.type||e.state.readOnly||e.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let s=PI?null:t.clipboardData;return s?(s.clearData(),s.setData("text/plain",r),!0):(function(e,t){let n=e.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement("textarea"));r.style.cssText="position: fixed; left: -10000px; top: 10px",r.value=t,r.focus(),r.selectionEnd=t.length,r.selectionStart=0,setTimeout(()=>{r.remove(),e.focus()},50)}(e,r),!1)};const qI=qD.define();function UI(e,t){let n=[];for(let r of e.facet(QL)){let i=r(e,t);i&&n.push(i)}return n.length?e.update({effects:n,annotations:qI.of(!0)}):null}function KI(e){setTimeout(()=>{let t=e.hasFocus;if(t!=e.inputState.notifiedFocused){let n=UI(e.state,t);n?e.dispatch(n):e.update([])}},10)}DI.focus=e=>{e.inputState.lastFocusTime=Date.now(),e.scrollDOM.scrollTop||!e.inputState.lastScrollTop&&!e.inputState.lastScrollLeft||(e.scrollDOM.scrollTop=e.inputState.lastScrollTop,e.scrollDOM.scrollLeft=e.inputState.lastScrollLeft),KI(e)},DI.blur=e=>{e.observer.clearSelectionRange(),KI(e)},DI.compositionstart=DI.compositionupdate=e=>{e.observer.editContext||(null==e.inputState.compositionFirstChange&&(e.inputState.compositionFirstChange=!0),e.inputState.composing<0&&(e.inputState.composing=0))},DI.compositionend=e=>{e.observer.editContext||(e.inputState.composing=-1,e.inputState.compositionEndedAt=Date.now(),e.inputState.compositionPendingKey=!0,e.inputState.compositionPendingChange=e.observer.pendingRecords().length>0,e.inputState.compositionFirstChange=null,qP.chrome&&qP.android?e.observer.flushSoon():e.inputState.compositionPendingChange?Promise.resolve().then(()=>e.observer.flush()):setTimeout(()=>{e.inputState.composing<0&&e.docView.hasComposition&&e.update([])},50))},DI.contextmenu=e=>{e.inputState.lastContextMenu=Date.now()},RI.beforeinput=(e,t)=>{var n,r;if("insertText"!=t.inputType&&"insertCompositionText"!=t.inputType||(e.inputState.insertingText=t.data,e.inputState.insertingTextAt=Date.now()),"insertReplacementText"==t.inputType&&e.observer.editContext){let r=null===(n=t.dataTransfer)||void 0===n?void 0:n.getData("text/plain"),i=t.getTargetRanges();if(r&&i.length){let t=i[0],n=e.posAtDOM(t.startContainer,t.startOffset),o=e.posAtDOM(t.endContainer,t.endOffset);return wI(e,{from:n,to:o,insert:e.state.toText(r)},null),!0}}let i;if(qP.chrome&&qP.android&&(i=AI.find(e=>e.inputType==t.inputType))&&(e.observer.delayAndroidKey(i.key,i.keyCode),"Backspace"==i.key||"Delete"==i.key)){let t=(null===(r=window.visualViewport)||void 0===r?void 0:r.height)||0;setTimeout(()=>{var n;((null===(n=window.visualViewport)||void 0===n?void 0:n.height)||0)>t+10&&e.hasFocus&&(e.contentDOM.blur(),e.focus())},100)}return qP.ios&&"deleteContentForward"==t.inputType&&e.observer.flushSoon(),qP.safari&&"insertText"==t.inputType&&e.inputState.composing>=0&&setTimeout(()=>DI.compositionend(e,t),20),!1};const GI=new Set;const YI=["pre-wrap","normal","pre-line","break-spaces"];let $I=!1;function XI(){$I=!1}class JI{constructor(e){this.lineWrapping=e,this.doc=KR.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let n=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(n+=Math.max(0,Math.ceil((t-e-n*this.lineLength*.5)/this.lineLength))),this.lineHeight*n}heightForLine(e){if(!this.lineWrapping)return this.lineHeight;return(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return YI.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let n=0;n<e.length;n++){let r=e[n];r<0?n++:this.heightSamples[Math.floor(10*r)]||(t=!0,this.heightSamples[Math.floor(10*r)]=!0)}return t}refresh(e,t,n,r,i,o){let s=YI.indexOf(e)>-1,a=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=s||Math.abs(n-this.charWidth)>.1;if(this.lineWrapping=s,this.lineHeight=t,this.charWidth=n,this.textHeight=r,this.lineLength=i,a){this.heightSamples={};for(let e=0;e<o.length;e++){let t=o[e];t<0?e++:this.heightSamples[Math.floor(10*t)]=!0}}return a}}class QI{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}}class ZI{constructor(e,t,n,r,i){this.from=e,this.length=t,this.top=n,this.height=r,this._content=i}get type(){return"number"==typeof this._content?JP.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof tL?this._content.widget:null}get widgetLineBreaks(){return"number"==typeof this._content?this._content:0}join(e){let t=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new ZI(this.from,this.length+e.length,this.top,this.height+e.height,t)}}var e_=function(e){return e[e.ByPos=0]="ByPos",e[e.ByHeight=1]="ByHeight",e[e.ByPosNoHeight=2]="ByPosNoHeight",e}(e_||(e_={}));const t_=.001;class n_{constructor(e,t,n=2){this.length=e,this.height=t,this.flags=n}get outdated(){return(2&this.flags)>0}set outdated(e){this.flags=(e?2:0)|-3&this.flags}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>t_&&($I=!0),this.height=e)}replace(e,t,n){return n_.of(n)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,n,r){let i=this,o=n.doc;for(let s=r.length-1;s>=0;s--){let{fromA:a,toA:l,fromB:c,toB:u}=r[s],h=i.lineAt(a,e_.ByPosNoHeight,n.setDoc(t),0,0),f=h.to>=l?h:i.lineAt(l,e_.ByPosNoHeight,n,0,0);for(u+=f.to-l,l=f.to;s>0&&h.from<=r[s-1].toA;)a=r[s-1].fromA,c=r[s-1].fromB,s--,a<h.from&&(h=i.lineAt(a,e_.ByPosNoHeight,n,0,0));c+=h.from-a,a=h.from;let d=u_.build(n.setDoc(o),e,c,u);i=r_(i,i.replace(a,l,d))}return i.updateHeight(n,0)}static empty(){return new s_(0,0,0)}static of(e){if(1==e.length)return e[0];let t=0,n=e.length,r=0,i=0;for(;;)if(t==n)if(r>2*i){let i=e[t-1];i.break?e.splice(--t,1,i.left,null,i.right):e.splice(--t,1,i.left,i.right),n+=1+i.break,r-=i.size}else{if(!(i>2*r))break;{let t=e[n];t.break?e.splice(n,1,t.left,null,t.right):e.splice(n,1,t.left,t.right),n+=2+t.break,i-=t.size}}else if(r<i){let n=e[t++];n&&(r+=n.size)}else{let t=e[--n];t&&(i+=t.size)}let o=0;return null==e[t-1]?(o=1,t--):null==e[t]&&(o=1,n++),new l_(n_.of(e.slice(0,t)),o,n_.of(e.slice(n)))}}function r_(e,t){return e==t?e:(e.constructor!=t.constructor&&($I=!0),t)}n_.prototype.size=1;const i_=QP.replace({});class o_ extends n_{constructor(e,t,n){super(e,t),this.deco=n,this.spaceAbove=0}mainBlock(e,t){return new ZI(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(e,t,n,r){return this.spaceAbove&&e<n+this.spaceAbove?new ZI(r,0,n,this.spaceAbove,i_):this.mainBlock(n,r)}lineAt(e,t,n,r,i){let o=this.mainBlock(r,i);return this.spaceAbove?this.blockAt(0,n,r,i).join(o):o}forEachLine(e,t,n,r,i,o){e<=i+this.length&&t>=i&&o(this.lineAt(0,e_.ByPos,n,r,i))}setMeasuredHeight(e){let t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more&&this.setMeasuredHeight(r),this.outdated=!1,this}toString(){return`block(${this.length})`}}class s_ extends o_{constructor(e,t,n){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=n}mainBlock(e,t){return new ZI(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,t,n){let r=n[0];return 1==n.length&&(r instanceof s_||r instanceof a_&&4&r.flags)&&Math.abs(this.length-r.length)<10?(r instanceof a_?r=new s_(r.length,this.height,this.spaceAbove):r.height=this.height,this.outdated||(r.outdated=!1),r):n_.of(n)}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more?this.setMeasuredHeight(r):(n||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class a_ extends n_{constructor(e){super(e,0)}heightMetrics(e,t){let n,r=e.doc.lineAt(t).number,i=e.doc.lineAt(t+this.length).number,o=i-r+1,s=0;if(e.lineWrapping){let t=Math.min(this.height,e.lineHeight*o);n=t/o,this.length>o+1&&(s=(this.height-t)/(this.length-o-1))}else n=this.height/o;return{firstLine:r,lastLine:i,perLine:n,perChar:s}}blockAt(e,t,n,r){let{firstLine:i,lastLine:o,perLine:s,perChar:a}=this.heightMetrics(t,r);if(t.lineWrapping){let i=r+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-n)/this.height))*this.length)),o=t.doc.lineAt(i),l=s+o.length*a,c=Math.max(n,e-l/2);return new ZI(o.from,o.length,c,l,0)}{let r=Math.max(0,Math.min(o-i,Math.floor((e-n)/s))),{from:a,length:l}=t.doc.line(i+r);return new ZI(a,l,n+s*r,s,0)}}lineAt(e,t,n,r,i){if(t==e_.ByHeight)return this.blockAt(e,n,r,i);if(t==e_.ByPosNoHeight){let{from:t,to:r}=n.doc.lineAt(e);return new ZI(t,r-t,0,0,0)}let{firstLine:o,perLine:s,perChar:a}=this.heightMetrics(n,i),l=n.doc.lineAt(e),c=s+l.length*a,u=l.number-o,h=r+s*u+a*(l.from-i-u);return new ZI(l.from,l.length,Math.max(r,Math.min(h,r+this.height-c)),c,0)}forEachLine(e,t,n,r,i,o){e=Math.max(e,i),t=Math.min(t,i+this.length);let{firstLine:s,perLine:a,perChar:l}=this.heightMetrics(n,i);for(let c=e,u=r;c<=t;){let t=n.doc.lineAt(c);if(c==e){let n=t.number-s;u+=a*n+l*(e-i-n)}let r=a+l*t.length;o(new ZI(t.from,t.length,u,r,0)),u+=r,c=t.to+1}}replace(e,t,n){let r=this.length-t;if(r>0){let e=n[n.length-1];e instanceof a_?n[n.length-1]=new a_(e.length+r):n.push(null,new a_(r-1))}if(e>0){let t=n[0];t instanceof a_?n[0]=new a_(e+t.length):n.unshift(new a_(e-1),null)}return n_.of(n)}decomposeLeft(e,t){t.push(new a_(e-1),null)}decomposeRight(e,t){t.push(null,new a_(this.length-e-1))}updateHeight(e,t=0,n=!1,r){let i=t+this.length;if(r&&r.from<=t+this.length&&r.more){let n=[],o=Math.max(t,r.from),s=-1;for(r.from>t&&n.push(new a_(r.from-t-1).updateHeight(e,t));o<=i&&r.more;){let t=e.doc.lineAt(o).length;n.length&&n.push(null);let i=r.heights[r.index++],a=0;i<0&&(a=-i,i=r.heights[r.index++]),-1==s?s=i:Math.abs(i-s)>=t_&&(s=-2);let l=new s_(t,i,a);l.outdated=!1,n.push(l),o+=t+1}o<=i&&n.push(null,new a_(i-o).updateHeight(e,o));let a=n_.of(n);return(s<0||Math.abs(a.height-this.height)>=t_||Math.abs(s-this.heightMetrics(e,t).perLine)>=t_)&&($I=!0),r_(this,a)}return(n||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class l_ extends n_{constructor(e,t,n){super(e.length+t+n.length,e.height+n.height,t|(e.outdated||n.outdated?2:0)),this.left=e,this.right=n,this.size=e.size+n.size}get break(){return 1&this.flags}blockAt(e,t,n,r){let i=n+this.left.height;return e<i?this.left.blockAt(e,t,n,r):this.right.blockAt(e,t,i,r+this.left.length+this.break)}lineAt(e,t,n,r,i){let o=r+this.left.height,s=i+this.left.length+this.break,a=t==e_.ByHeight?e<o:e<s,l=a?this.left.lineAt(e,t,n,r,i):this.right.lineAt(e,t,n,o,s);if(this.break||(a?l.to<s:l.from>s))return l;let c=t==e_.ByPosNoHeight?e_.ByPosNoHeight:e_.ByPos;return a?l.join(this.right.lineAt(s,c,n,o,s)):this.left.lineAt(s,c,n,r,i).join(l)}forEachLine(e,t,n,r,i,o){let s=r+this.left.height,a=i+this.left.length+this.break;if(this.break)e<a&&this.left.forEachLine(e,t,n,r,i,o),t>=a&&this.right.forEachLine(e,t,n,s,a,o);else{let l=this.lineAt(a,e_.ByPos,n,r,i);e<l.from&&this.left.forEachLine(e,l.from-1,n,r,i,o),l.to>=e&&l.from<=t&&o(l),t>l.to&&this.right.forEachLine(l.to+1,t,n,s,a,o)}}replace(e,t,n){let r=this.left.length+this.break;if(t<r)return this.balanced(this.left.replace(e,t,n),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-r,t-r,n));let i=[];e>0&&this.decomposeLeft(e,i);let o=i.length;for(let e of n)i.push(e);if(e>0&&c_(i,o-1),t<this.length){let e=i.length;this.decomposeRight(t,i),c_(i,e)}return n_.of(i)}decomposeLeft(e,t){let n=this.left.length;if(e<=n)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(n++,e>=n&&t.push(null)),e>n&&this.right.decomposeLeft(e-n,t)}decomposeRight(e,t){let n=this.left.length,r=n+this.break;if(e>=r)return this.right.decomposeRight(e-r,t);e<n&&this.left.decomposeRight(e,t),this.break&&e<r&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?n_.of(this.break?[e,null,t]:[e,t]):(this.left=r_(this.left,e),this.right=r_(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,n=!1,r){let{left:i,right:o}=this,s=t+i.length+this.break,a=null;return r&&r.from<=t+i.length&&r.more?a=i=i.updateHeight(e,t,n,r):i.updateHeight(e,t,n),r&&r.from<=s+o.length&&r.more?a=o=o.updateHeight(e,s,n,r):o.updateHeight(e,s,n),a?this.balanced(i,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function c_(e,t){let n,r;null==e[t]&&(n=e[t-1])instanceof a_&&(r=e[t+1])instanceof a_&&e.splice(t-1,3,new a_(n.length+1+r.length))}class u_{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let e=Math.min(t,this.lineEnd),n=this.nodes[this.nodes.length-1];n instanceof s_?n.length+=e-this.pos:(e>this.pos||!this.isCovered)&&this.nodes.push(new s_(e-this.pos,-1,0)),this.writtenTo=e,t>e&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,n){if(e<t||n.heightRelevant){let r=n.widget?n.widget.estimatedHeight:0,i=n.widget?n.widget.lineBreaks:0;r<0&&(r=this.oracle.lineHeight);let o=t-e;n.block?this.addBlock(new o_(o,r,n)):(o||i||r>=5)&&this.addLineDeco(r,i,o)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||null==this.nodes[this.nodes.length-1])&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new s_(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let n=new a_(t-e);return this.oracle.doc.lineAt(e).to==t&&(n.flags|=4),n}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof s_)return e;let t=new s_(0,-1,0);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,n){let r=this.ensureLine();r.length+=n,r.collapsed+=n,r.widgetHeight=Math.max(r.widgetHeight,e),r.breaks+=t,this.writtenTo=this.pos=this.pos+n}finish(e){let t=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||t instanceof s_||this.isCovered?(this.writtenTo<this.pos||null==t)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new s_(0,-1,0));let n=e;for(let e of this.nodes)e instanceof s_&&e.updateHeight(this.oracle,n),n+=e?e.length:1;return this.nodes}static build(e,t,n,r){let i=new u_(n,e);return hP.spans(t,n,r,i,0),i.finish(n)}}class h_{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,n,r){(e<t||n&&n.heightRelevant||r&&r.heightRelevant)&&rL(e,t,this.changes,5)}}function f_(e,t){let n=e.getBoundingClientRect(),r=e.ownerDocument,i=r.defaultView||window,o=Math.max(0,n.left),s=Math.min(i.innerWidth,n.right),a=Math.max(0,n.top),l=Math.min(i.innerHeight,n.bottom);for(let t=e.parentNode;t&&t!=r.body;)if(1==t.nodeType){let n=t,r=window.getComputedStyle(n);if((n.scrollHeight>n.clientHeight||n.scrollWidth>n.clientWidth)&&"visible"!=r.overflow){let r=n.getBoundingClientRect();o=Math.max(o,r.left),s=Math.min(s,r.right),a=Math.max(a,r.top),l=Math.min(t==e.parentNode?i.innerHeight:l,r.bottom)}t="absolute"==r.position||"fixed"==r.position?n.offsetParent:n.parentNode}else{if(11!=t.nodeType)break;t=t.host}return{left:o-n.left,right:Math.max(o,s)-n.left,top:a-(n.top+t),bottom:Math.max(a,l)-(n.top+t)}}function d_(e,t){let n=e.getBoundingClientRect();return{left:0,right:n.right-n.left,top:t,bottom:n.bottom-(n.top+t)}}class p_{constructor(e,t,n,r){this.from=e,this.to=t,this.size=n,this.displaySize=r}static same(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r.from!=i.from||r.to!=i.to||r.size!=i.size)return!1}return!0}draw(e,t){return QP.replace({widget:new m_(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}}class m_ extends XP{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}}class g_{constructor(e){this.state=e,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scrollTop=0,this.scrolledToBottom=!1,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=w_,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=ML.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let t=e.facet(pB).some(e=>"function"!=typeof e&&"cm-lineWrapping"==e.class);this.heightOracle=new JI(t),this.stateDeco=k_(e),this.heightMap=n_.empty().applyChanges(this.stateDeco,KR.empty,this.heightOracle.setDoc(e.doc),[new CB(0,0,0,e.doc.length)]);for(let e=0;e<2&&(this.viewport=this.getViewport(0,null),this.updateForViewport());e++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=QP.set(this.lineGaps.map(e=>e.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let n=0;n<=1;n++){let r=n?t.head:t.anchor;if(!e.some(({from:e,to:t})=>r>=e&&r<=t)){let{from:t,to:n}=this.lineBlockAt(r);e.push(new v_(t,n))}}return this.viewports=e.sort((e,t)=>e.from-t.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?w_:new x_(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(S_(e,this.scaler))})}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=k_(this.state);let r=e.changedRanges,i=CB.extendWithRanges(r,function(e,t,n){let r=new h_;return hP.compare(e,t,n,r,0),r.changes}(n,this.stateDeco,e?e.changes:sD.empty(this.state.doc.length))),o=this.heightMap.height,s=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);XI(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),i),(this.heightMap.height!=o||$I)&&(e.flags|=2),s?(this.scrollAnchorPos=e.changes.mapPos(s.from,-1),this.scrollAnchorHeight=s.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let a=i.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<a.from||t.range.head>a.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,t));let l=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,e.flags|=this.updateForViewport(),(l||!e.changes.empty||2&e.flags)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(nB)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,n=window.getComputedStyle(t),r=this.heightOracle,i=n.whiteSpace;this.defaultTextDirection="rtl"==n.direction?ML.RTL:ML.LTR;let o=this.heightOracle.mustRefreshForWrapping(i)||this.mustMeasureContent,s=t.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=s.height;this.contentDOMHeight=s.height,this.mustMeasureContent=!1;let l=0,c=0;if(s.width&&s.height){let{scaleX:e,scaleY:n}=gL(t,s);(e>.005&&Math.abs(this.scaleX-e)>.005||n>.005&&Math.abs(this.scaleY-n)>.005)&&(this.scaleX=e,this.scaleY=n,l|=16,o=a=!0)}let u=(parseInt(n.paddingTop)||0)*this.scaleY,h=(parseInt(n.paddingBottom)||0)*this.scaleY;this.paddingTop==u&&this.paddingBottom==h||(this.paddingTop=u,this.paddingBottom=h,l|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,l|=16);let f=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=f&&(this.scrollAnchorHeight=-1,this.scrollTop=f),this.scrolledToBottom=SL(e.scrollDOM);let d=(this.printing?d_:f_)(t,this.paddingTop),p=d.top-this.pixelViewport.top,m=d.bottom-this.pixelViewport.bottom;this.pixelViewport=d;let g=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(g!=this.inView&&(this.inView=g,g&&(a=!0)),!this.inView&&!this.scrollTarget&&!function(e){let t=e.getBoundingClientRect(),n=e.ownerDocument.defaultView||window;return t.left<n.innerWidth&&t.right>0&&t.top<n.innerHeight&&t.bottom>0}(e.dom))return 0;let v=s.width;if(this.contentDOMWidth==v&&this.editorHeight==e.scrollDOM.clientHeight||(this.contentDOMWidth=s.width,this.editorHeight=e.scrollDOM.clientHeight,l|=16),a){let t=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(t)&&(o=!0),o||r.lineWrapping&&Math.abs(v-this.contentDOMWidth)>r.charWidth){let{lineHeight:n,charWidth:s,textHeight:a}=e.docView.measureTextSize();o=n>0&&r.refresh(i,n,s,a,Math.max(5,v/s),t),o&&(e.docView.minWidth=0,l|=16)}p>0&&m>0?c=Math.max(p,m):p<0&&m<0&&(c=Math.min(p,m)),XI();for(let n of this.viewports){let i=n.from==this.viewport.from?t:e.docView.measureVisibleLineHeights(n);this.heightMap=(o?n_.empty().applyChanges(this.stateDeco,KR.empty,this.heightOracle,[new CB(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,o,new QI(n.from,i))}$I&&(l|=2)}let y=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return y&&(2&l&&(l|=this.updateScaler()),this.viewport=this.getViewport(c,this.scrollTarget),l|=this.updateForViewport()),(2&l||y)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),l|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),l}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let n=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),r=this.heightMap,i=this.heightOracle,{visibleTop:o,visibleBottom:s}=this,a=new v_(r.lineAt(o-1e3*n,e_.ByHeight,i,0,0).from,r.lineAt(s+1e3*(1-n),e_.ByHeight,i,0,0).to);if(t){let{head:e}=t.range;if(e<a.from||e>a.to){let n,o=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),s=r.lineAt(e,e_.ByPos,i,0,0);n="center"==t.y?(s.top+s.bottom)/2-o/2:"start"==t.y||"nearest"==t.y&&e<a.from?s.top:s.bottom-o,a=new v_(r.lineAt(n-500,e_.ByHeight,i,0,0).from,r.lineAt(n+o+500,e_.ByHeight,i,0,0).to)}}return a}mapViewport(e,t){let n=t.mapPos(e.from,-1),r=t.mapPos(e.to,1);return new v_(this.heightMap.lineAt(n,e_.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(r,e_.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},n=0){if(!this.inView)return!0;let{top:r}=this.heightMap.lineAt(e,e_.ByPos,this.heightOracle,0,0),{bottom:i}=this.heightMap.lineAt(t,e_.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:s}=this;return(0==e||r<=o-Math.max(10,Math.min(-n,250)))&&(t==this.state.doc.length||i>=s+Math.max(10,Math.min(n,250)))&&r>o-2e3&&i<s+2e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let n=[];for(let r of e)t.touchesRange(r.from,r.to)||n.push(new p_(t.mapPos(r.from),t.mapPos(r.to),r.size,r.displaySize));return n}ensureLineGaps(e,t){let n=this.heightOracle.lineWrapping,r=n?1e4:2e3,i=r>>1,o=r<<1;if(this.defaultTextDirection!=ML.LTR&&!n)return[];let s=[],a=(r,o,l,c)=>{if(o-r<i)return;let u=this.state.selection.main,h=[u.from];u.empty||h.push(u.to);for(let e of h)if(e>r&&e<o)return a(r,e-10,l,c),void a(e+10,o,l,c);let f=function(e,t){for(let n of e)if(t(n))return n;return}(e,e=>e.from>=l.from&&e.to<=l.to&&Math.abs(e.from-r)<i&&Math.abs(e.to-o)<i&&!h.some(t=>e.from<t&&e.to>t));if(!f){if(o<l.to&&t&&n&&t.visibleRanges.some(e=>e.from<=o&&e.to>=o)){let e=t.moveToLineBoundary(pD.cursor(o),!1,!0).head;e>r&&(o=e)}let e=this.gapSize(l,r,o,c);f=new p_(r,o,e,n||e<2e6?e:2e6)}s.push(f)},l=t=>{if(t.length<o||t.type!=JP.Text)return;let i=function(e,t,n){let r=[],i=e,o=0;hP.spans(n,e,t,{span(){},point(e,t){e>i&&(r.push({from:i,to:e}),o+=e-i),i=t}},20),i<t&&(r.push({from:i,to:t}),o+=t-i);return{total:o,ranges:r}}(t.from,t.to,this.stateDeco);if(i.total<o)return;let s,l,c=this.scrollTarget?this.scrollTarget.range.head:null;if(n){let e,n,o=r/this.heightOracle.lineLength*this.heightOracle.lineHeight;if(null!=c){let r=b_(i,c),s=((this.visibleBottom-this.visibleTop)/2+o)/t.height;e=r-s,n=r+s}else e=(this.visibleTop-t.top-o)/t.height,n=(this.visibleBottom-t.top+o)/t.height;s=y_(i,e),l=y_(i,n)}else{let n=i.total*this.heightOracle.charWidth,o=r*this.heightOracle.charWidth,a=0;if(n>2e6)for(let n of e)n.from>=t.from&&n.from<t.to&&n.size!=n.displaySize&&n.from*this.heightOracle.charWidth+a<this.pixelViewport.left&&(a=n.size-n.displaySize);let u,h,f=this.pixelViewport.left+a,d=this.pixelViewport.right+a;if(null!=c){let e=b_(i,c),t=((d-f)/2+o)/n;u=e-t,h=e+t}else u=(f-o)/n,h=(d+o)/n;s=y_(i,u),l=y_(i,h)}s>t.from&&a(t.from,s,t,i),l<t.to&&a(l,t.to,t,i)};for(let e of this.viewportLines)Array.isArray(e.type)?e.type.forEach(l):l(e);return s}gapSize(e,t,n,r){let i=b_(r,n)-b_(r,t);return this.heightOracle.lineWrapping?e.height*i:r.total*this.heightOracle.charWidth*i}updateLineGaps(e){p_.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=QP.set(e.map(e=>e.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let n=[];hP.spans(t,this.viewport.from,this.viewport.to,{span(e,t){n.push({from:e,to:t})},point(){}},20);let r=0;if(n.length!=this.visibleRanges.length)r=12;else for(let t=0;t<n.length&&!(8&r);t++){let i=this.visibleRanges[t],o=n[t];i.from==o.from&&i.to==o.to||(r|=4,e&&e.mapPos(i.from,-1)==o.from&&e.mapPos(i.to,1)==o.to||(r|=8))}return this.visibleRanges=n,r}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||S_(this.heightMap.lineAt(e,e_.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||S_(this.heightMap.lineAt(this.scaler.fromDOM(e),e_.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return S_(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class v_{constructor(e,t){this.from=e,this.to=t}}function y_({total:e,ranges:t},n){if(n<=0)return t[0].from;if(n>=1)return t[t.length-1].to;let r=Math.floor(e*n);for(let e=0;;e++){let{from:n,to:i}=t[e],o=i-n;if(r<=o)return n+r;r-=o}}function b_(e,t){let n=0;for(let{from:r,to:i}of e.ranges){if(t<=i){n+=t-r;break}n+=i-r}return n/e.total}const w_={toDOM:e=>e,fromDOM:e=>e,scale:1,eq(e){return e==this}};function k_(e){let t=e.facet(mB).filter(e=>"function"!=typeof e),n=e.facet(vB).filter(e=>"function"!=typeof e);return n.length&&t.push(hP.join(n)),t}class x_{constructor(e,t,n){let r=0,i=0,o=0;this.viewports=n.map(({from:n,to:i})=>{let o=t.lineAt(n,e_.ByPos,e,0,0).top,s=t.lineAt(i,e_.ByPos,e,0,0).bottom;return r+=s-o,{from:n,to:i,top:o,bottom:s,domTop:0,domBottom:0}}),this.scale=(7e6-r)/(t.height-r);for(let e of this.viewports)e.domTop=o+(e.top-i)*this.scale,o=e.domBottom=e.domTop+(e.bottom-e.top),i=e.bottom}toDOM(e){for(let t=0,n=0,r=0;;t++){let i=t<this.viewports.length?this.viewports[t]:null;if(!i||e<i.top)return r+(e-n)*this.scale;if(e<=i.bottom)return i.domTop+(e-i.top);n=i.bottom,r=i.domBottom}}fromDOM(e){for(let t=0,n=0,r=0;;t++){let i=t<this.viewports.length?this.viewports[t]:null;if(!i||e<i.domTop)return n+(e-r)/this.scale;if(e<=i.domBottom)return i.top+(e-i.domTop);n=i.bottom,r=i.domBottom}}eq(e){return e instanceof x_&&(this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every((t,n)=>t.from==e.viewports[n].from&&t.to==e.viewports[n].to))}}function S_(e,t){if(1==t.scale)return e;let n=t.toDOM(e.top),r=t.toDOM(e.bottom);return new ZI(e.from,e.length,n,r-n,Array.isArray(e._content)?e._content.map(e=>S_(e,t)):e._content)}const C_=vD.define({combine:e=>e.join(" ")}),E_=vD.define({combine:e=>e.indexOf(!0)>-1}),A_=AP.newName(),M_=AP.newName(),O_=AP.newName(),N_={"&light":"."+M_,"&dark":"."+O_};function T_(e,t,n){return new AP(t,{finish:t=>/&/.test(t)?t.replace(/&\w*/,t=>{if("&"==t)return e;if(!n||!n[t])throw new RangeError(`Unsupported selector: ${t}`);return n[t]}):e+" "+t})}const R_=T_("."+A_,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:'url(\'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>\')',backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},N_),D_={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},P_=qP.ie&&qP.ie_version<=11;class L_{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new vL,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let e of t)this.queue.push(e);(qP.ie&&qP.ie_version<=11||qP.ios&&e.composing)&&t.some(e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():this.flush()}),!window.EditContext||!qP.android||!1===e.constructor.EDIT_CONTEXT||qP.chrome&&qP.chrome_version<126||(this.editContext=new __(e),e.state.facet(lB)&&(e.contentDOM.editContext=this.editContext.editContext)),P_&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),"function"==typeof ResizeObserver&&(this.resizeScroll=new ResizeObserver(()=>{var e;(null===(e=this.view.docView)||void 0===e?void 0:e.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),"function"==typeof IntersectionObserver&&(this.intersection=new IntersectionObserver(e=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),e.length>0&&e[e.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(e=>{e.length>0&&e[e.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){("change"!=e.type&&e.type||e.matches)&&(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,n)=>t!=e[n]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:n}=this,r=this.selectionRange;if(n.state.facet(lB)?n.root.activeElement!=this.dom:!aL(this.dom,r))return;let i=r.anchorNode&&n.docView.tile.nearest(r.anchorNode);i&&i.isWidget()&&i.widget.ignoreEvent(e)?t||(this.selectionChanged=!1):(qP.ie&&qP.ie_version<=11||qP.android&&qP.chrome)&&!n.state.selection.main.empty&&r.focusNode&&cL(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=oL(e.root);if(!t)return!1;let n=qP.safari&&11==e.root.nodeType&&e.root.activeElement==this.dom&&function(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return I_(e,n)}let n=null;function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.contentDOM.addEventListener("beforeinput",r,!0),e.dom.ownerDocument.execCommand("indent"),e.contentDOM.removeEventListener("beforeinput",r,!0),n?I_(e,n):null}(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;let r=aL(this.dom,n);return r&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&function(e,t){let n=t.focusNode,r=t.focusOffset;if(!n||t.anchorNode!=n||t.anchorOffset!=r)return!1;for(r=Math.min(r,dL(n));;)if(r){if(1!=n.nodeType)return!1;let e=n.childNodes[r-1];"false"==e.contentEditable?r--:(n=e,r=dL(n))}else{if(n==e)return!0;r=uL(n),n=n.parentNode}}(this.dom,n)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(n),r&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let n=this.dom;n;)if(1==n.nodeType)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==n?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(n),n=n.assignedSlot||n.parentNode;else{if(11!=n.nodeType)break;n=n.host}if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let e of this.scrollTargets)e.removeEventListener("scroll",this.onScroll);for(let e of this.scrollTargets=t)e.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,D_),P_&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),P_&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){var n;if(!this.delayedAndroidKey){let e=()=>{let e=this.delayedAndroidKey;if(e){this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=e.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&e.force&&xL(this.dom,e.key,e.keyCode)}};this.flushingAndroidKey=this.view.win.requestAnimationFrame(e)}this.delayedAndroidKey&&"Enter"!=e||(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(null===(n=this.delayedAndroidKey)||void 0===n?void 0:n.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,n=-1,r=!1;for(let i of e){let e=this.readMutation(i);e&&(e.typeOver&&(r=!0),-1==t?({from:t,to:n}=e):(t=Math.min(e.from,t),n=Math.max(e.to,n)))}return{from:t,to:n,typeOver:r}}readChange(){let{from:e,to:t,typeOver:n}=this.processRecords(),r=this.selectionChanged&&aL(this.dom,this.selectionRange);if(e<0&&!r)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let i=new vI(this.view,e,t,n);return this.view.docView.domChanged={newSel:i.newSel?i.newSel.main:null},i}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let n=this.view.state,r=bI(this.view,t);return this.view.state==n&&(t.domChanged||t.newSel&&!xI(this.view.state.selection,t.newSel.main))&&this.view.update([]),r}readMutation(e){let t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty("attributes"==e.type),"childList"==e.type){let n=B_(t,e.previousSibling||e.target.previousSibling,-1),r=B_(t,e.nextSibling||e.target.nextSibling,1);return{from:n?t.posAfter(n):t.posAtStart,to:r?t.posBefore(r):t.posAtEnd,typeOver:!1}}return"characterData"==e.type?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(lB)!=e.state.facet(lB)&&(e.view.contentDOM.editContext=e.state.facet(lB)?this.editContext.editContext:null))}destroy(){var e,t,n;this.stop(),null===(e=this.intersection)||void 0===e||e.disconnect(),null===(t=this.gapIntersection)||void 0===t||t.disconnect(),null===(n=this.resizeScroll)||void 0===n||n.disconnect();for(let e of this.scrollTargets)e.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function B_(e,t,n){for(;t;){let r=MB.get(t);if(r&&r.parent==e)return r;let i=t.parentNode;t=i!=e.dom?i:n>0?t.nextSibling:t.previousSibling}return null}function I_(e,t){let n=t.startContainer,r=t.startOffset,i=t.endContainer,o=t.endOffset,s=e.docView.domAtPos(e.state.selection.main.anchor,1);return cL(s.node,s.offset,i,o)&&([n,r,i,o]=[i,o,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:o}}class __{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=n=>{let r=e.state.selection.main,{anchor:i,head:o}=r,s=this.toEditorPos(n.updateRangeStart),a=this.toEditorPos(n.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:n.updateRangeStart,editorBase:s,drifted:!1});let l=a-s>n.text.length;s==this.from&&i<this.from?s=i:a==this.to&&i>this.to&&(a=i);let c=kI(e.state.sliceDoc(s,a),n.text,(l?r.from:r.to)-s,l?"end":null);if(!c){let t=pD.single(this.toEditorPos(n.selectionStart),this.toEditorPos(n.selectionEnd));return void(xI(t,r)||e.dispatch({selection:t,userEvent:"select"}))}let u={from:c.from+s,to:c.toA+s,insert:KR.of(n.text.slice(c.from,c.toB).split("\n"))};if((qP.mac||qP.android)&&u.from==o-1&&/^\. ?$/.test(n.text)&&"off"==e.contentDOM.getAttribute("autocorrect")&&(u={from:s,to:a,insert:KR.of([n.text.replace("."," ")])}),this.pendingContextChange=u,!e.state.readOnly){let t=this.to-this.from+(u.to-u.from+u.insert.length);wI(e,u,pD.single(this.toEditorPos(n.selectionStart,t),this.toEditorPos(n.selectionEnd,t)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),u.from<u.to&&!u.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,n.updateRangeStart-1),Math.min(t.text.length,n.updateRangeStart+1)))&&this.handlers.compositionend(n)},this.handlers.characterboundsupdate=n=>{let r=[],i=null;for(let t=this.toEditorPos(n.rangeStart),o=this.toEditorPos(n.rangeEnd);t<o;t++){let n=e.coordsForChar(t);i=n&&new DOMRect(n.left,n.top,n.right-n.left,n.bottom-n.top)||i||new DOMRect,r.push(i)}t.updateCharacterBounds(n.rangeStart,r)},this.handlers.textformatupdate=t=>{let n=[];for(let e of t.getTextFormats()){let t=e.underlineStyle,r=e.underlineThickness;if(!/none/i.test(t)&&!/none/i.test(r)){let i=this.toEditorPos(e.rangeStart),o=this.toEditorPos(e.rangeEnd);if(i<o){let e=`text-decoration: underline ${/^[a-z]/.test(t)?t+" ":"Dashed"==t?"dashed ":"Squiggle"==t?"wavy ":""}${/thin/i.test(r)?1:2}px`;n.push(QP.mark({attributes:{style:e}}).range(i,o))}}}e.dispatch({effects:sB.of(QP.set(n))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:t}=this.composing;this.composing=null,t&&this.reset(e.state)}};for(let e in this.handlers)t.addEventListener(e,this.handlers[e]);this.measureReq={read:e=>{this.editContext.updateControlBounds(e.contentDOM.getBoundingClientRect());let t=oL(e.root);t&&t.rangeCount&&this.editContext.updateSelectionBounds(t.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,n=!1,r=this.pendingContextChange;return e.changes.iterChanges((i,o,s,a,l)=>{if(n)return;let c=l.length-(o-i);if(r&&o>=r.to){if(r.from==i&&r.to==o&&r.insert.eq(l))return r=this.pendingContextChange=null,t+=c,void(this.to+=c);r=null,this.revertPending(e.state)}if(i+=t,(o+=t)<=this.from)this.from+=c,this.to+=c;else if(i<this.to){if(i<this.from||o>this.to||this.to-this.from+l.length>3e4)return void(n=!0);this.editContext.updateText(this.toContextPos(i),this.toContextPos(o),l.toString()),this.to+=c}t+=c}),r&&!n&&this.revertPending(e.state),!n}update(e){let t=this.pendingContextChange,n=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(n.from,n.to)&&e.transactions.some(e=>!e.isUserEvent("input.type")&&e.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):this.applyEdits(e)&&this.rangeIsValid(e.state)?(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state):(this.pendingContextChange=null,this.reset(e.state)),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,n=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),r=this.toContextPos(t.head);this.editContext.selectionStart==n&&this.editContext.selectionEnd==r||this.editContext.updateSelection(n,r)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>3e4)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let n=this.composing;return n&&n.drifted?n.editorBase+(e-n.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class F_{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:n}=e;this.dispatchTransactions=e.dispatchTransactions||n&&(e=>e.forEach(e=>n(e,this)))||(e=>this.update(e)),this.dispatch=this.dispatch.bind(this),this._root=e.root||function(e){for(;e;){if(e&&(9==e.nodeType||11==e.nodeType&&e.host))return e;e=e.assignedSlot||e.parentNode}return null}(e.parent)||document,this.viewState=new g_(e.state||oP.create(e)),e.scrollTo&&e.scrollTo.is(oB)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(uB).map(e=>new fB(e));for(let e of this.plugins)e.update(this);this.observer=new L_(this),this.inputState=new SI(this),this.inputState.ensureHandlers(this.plugins),this.docView=new XB(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),(null===(t=document.fonts)||void 0===t?void 0:t.ready)&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent=!0,this.requestMeasure()})}dispatch(...e){let t=1==e.length&&e[0]instanceof YD?e:1==e.length&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(0!=this.updateState)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t,n=!1,r=!1,i=this.state;for(let t of e){if(t.startState!=i)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");i=t.state}if(this.destroyed)return void(this.viewState.state=i);let o=this.hasFocus,s=0,a=null;e.some(e=>e.annotation(qI))?(this.inputState.notifiedFocused=o,s=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=UI(i,o),a||(s=1));let l=this.observer.delayedAndroidKey,c=null;if(l?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(i.doc)||!this.state.selection.eq(i.selection))&&(c=null)):this.observer.clear(),i.facet(oP.phrases)!=this.state.facet(oP.phrases))return this.setState(i);t=EB.create(this,i,e),t.flags|=s;let u=this.viewState.scrollTarget;try{this.updateState=2;for(let t of e){if(u&&(u=u.map(t.changes)),t.scrollIntoView){let{main:e}=t.state.selection;u=new iB(e.empty?e:pD.cursor(e.head,e.head>e.anchor?-1:1))}for(let e of t.effects)e.is(oB)&&(u=e.value.clip(this.state))}this.viewState.update(t,u),this.bidiCache=H_.update(this.bidiCache,t.changes),t.empty||(this.updatePlugins(t),this.inputState.update(t)),n=this.docView.update(t),this.state.facet(SB)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(e=>e.isUserEvent("select.pointer")))}finally{this.updateState=0}if(t.startState.facet(C_)!=t.state.facet(C_)&&(this.viewState.mustMeasureContent=!0),(n||r||u||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!t.empty)for(let e of this.state.facet(XL))try{e(t)}catch(e){aB(this.state,e,"update listener")}(a||c)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!bI(this,c)&&l.force&&xL(this.contentDOM,l.key,l.keyCode)})}setState(e){if(0!=this.updateState)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed)return void(this.viewState.state=e);this.updateState=2;let t=this.hasFocus;try{for(let e of this.plugins)e.destroy(this);this.viewState=new g_(e),this.plugins=e.facet(uB).map(e=>new fB(e)),this.pluginMap.clear();for(let e of this.plugins)e.update(this);this.docView.destroy(),this.docView=new XB(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(uB),n=e.state.facet(uB);if(t!=n){let r=[];for(let i of n){let n=t.indexOf(i);if(n<0)r.push(new fB(i));else{let t=this.plugins[n];t.mustUpdate=e,r.push(t)}}for(let t of this.plugins)t.mustUpdate!=e&&t.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let t of this.plugins)t.mustUpdate=e;for(let e=0;e<this.plugins.length;e++)this.plugins[e].update(this);t!=n&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(e){aB(this.state,e,"doc view update listener")}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey)return this.measureScheduled=-1,void this.requestMeasure();this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,n=this.scrollDOM,r=n.scrollTop*this.scaleY,{scrollAnchorPos:i,scrollAnchorHeight:o}=this.viewState;Math.abs(r-this.viewState.scrollTop)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let e=0;;e++){if(o<0)if(SL(n))i=-1,o=this.viewState.heightMap.height;else{let e=this.viewState.scrollAnchorAt(r);i=e.from,o=e.top}this.updateState=1;let s=this.viewState.measure(this);if(!s&&!this.measureRequests.length&&null==this.viewState.scrollTarget)break;if(e>5)break;let a=[];4&s||([this.measureRequests,a]=[a,this.measureRequests]);let l=a.map(e=>{try{return e.read(this)}catch(e){return aB(this.state,e),j_}}),c=EB.create(this,this.state,[]),u=!1;c.flags|=s,t?t.flags|=s:t=c,this.updateState=2,c.empty||(this.updatePlugins(c),this.inputState.update(c),this.updateAttrs(),u=this.docView.update(c),u&&this.docViewUpdate());for(let e=0;e<a.length;e++)if(l[e]!=j_)try{let t=a[e];t.write&&t.write(l[e],this)}catch(e){aB(this.state,e)}if(u&&this.docView.updateSelection(!0),!c.viewportChanged&&0==this.measureRequests.length){if(this.viewState.editorHeight){if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}{let e=(i<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(i).top)-o;if(e>1||e<-1){r+=e,n.scrollTop=r/this.scaleY,o=-1;continue}}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let e of this.state.facet(XL))e(t)}get themeClasses(){return A_+" "+(this.state.facet(E_)?O_:M_)+" "+this.state.facet(C_)}updateAttrs(){let e=z_(this,dB,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(lB)?"true":"false",class:"cm-content",style:`${qP.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),z_(this,pB,t);let n=this.observer.ignore(()=>{let n=YP(this.contentDOM,this.contentAttrs,t),r=YP(this.dom,this.editorAttrs,e);return n||r});return this.editorAttrs=e,this.contentAttrs=t,n}showAnnouncements(e){let t=!0;for(let n of e)for(let e of n.effects)if(e.is(F_.announce)){t&&(this.announceDOM.textContent=""),t=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=e.value}}mountStyles(){this.styleModules=this.state.facet(SB);let e=this.state.facet(F_.cspNonce);AP.mount(this.root,this.styleModules.concat(R_).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(2==this.updateState)throw new Error("Reading the editor layout isn't allowed during an update");0==this.updateState&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(null!=e.key)for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key)return void(this.measureRequests[t]=e);this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(void 0===t||t&&t.plugin!=e)&&this.pluginMap.set(e,t=this.plugins.find(t=>t.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,n){return aI(this,e,iI(this,e,t,n))}moveByGroup(e,t){return aI(this,e,iI(this,e,t,t=>function(e,t,n){let r=e.state.charCategorizer(t),i=r(n);return e=>{let t=r(e);return i==tP.Space&&(i=t),i==t}}(this,e.head,t)))}visualLineSide(e,t){let n=this.bidiSpans(e),r=this.textDirectionAt(e.from),i=n[t?n.length-1:0];return pD.cursor(i.side(t,r)+e.from,i.forward(!t,r)?1:-1)}moveToLineBoundary(e,t,n=!0){return rI(this,e,t,n)}moveVertically(e,t,n){return aI(this,e,function(e,t,n,r){let i=t.head,o=n?1:-1;if(i==(n?e.state.doc.length:0))return pD.cursor(i,t.assoc);let s,a=t.goalColumn,l=e.contentDOM.getBoundingClientRect(),c=e.coordsAtPos(i,t.assoc||-1),u=e.documentTop;if(c)null==a&&(a=c.left-l.left),s=o<0?c.top:c.bottom;else{let t=e.viewState.lineBlockAt(i);null==a&&(a=Math.min(l.right-l.left,e.defaultCharacterWidth*(i-t.from))),s=(o<0?t.top:t.bottom)+u}let h=cI(e,{x:l.left+a,y:s+(null!=r?r:e.viewState.heightOracle.textHeight>>1)*o},!1,o);return pD.cursor(h.pos,h.assoc,void 0,a)}(this,e,t,n))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let n=cI(this,e,t);return n&&n.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),cI(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let n=this.docView.coordsAt(e,t);if(!n||n.left==n.right)return n;let r=this.state.doc.lineAt(e),i=this.bidiSpans(r);return pL(n,i[_L.find(i,e-r.from,-1,t)].dir==ML.LTR==t>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(tB)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>W_)return zL(e.length);let t,n=this.textDirectionAt(e.from);for(let r of this.bidiCache)if(r.from==e.from&&r.dir==n&&(r.fresh||FL(r.isolates,t=wB(this,e))))return r.order;t||(t=wB(this,e));let r=function(e,t,n){if(!e)return[new _L(0,0,t==NL?1:0)];if(t==OL&&!n.length&&!IL.test(e))return zL(e.length);if(n.length)for(;e.length>WL.length;)WL[WL.length]=256;let r=[],i=t==OL?0:1;return HL(e,i,i,n,0,e.length,r),r}(e.text,n,t);return this.bidiCache.push(new H_(e.from,e.to,n,t,!0,r)),r}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||qP.safari&&(null===(e=this.inputState)||void 0===e?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{wL(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((9==e.nodeType?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return oB.of(new iB("number"==typeof e?pD.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,n=this.viewState.scrollAnchorAt(e);return oB.of(new iB(pD.cursor(n.from),"start","start",n.top-e,t,!0))}setTabFocusMode(e){null==e?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:"boolean"==typeof e?this.inputState.tabFocusMode=e?0:-1:0!=this.inputState.tabFocusMode&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return hB.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return hB.define(()=>({}),{eventObservers:e})}static theme(e,t){let n=AP.newName(),r=[C_.of(n),SB.of(T_(`.${n}`,e))];return t&&t.dark&&r.push(E_.of(!0)),r}static baseTheme(e){return TD.lowest(SB.of(T_("."+A_,e,N_)))}static findFromDOM(e){var t;let n=e.querySelector(".cm-content"),r=n&&MB.get(n)||MB.get(e);return(null===(t=null==r?void 0:r.root)||void 0===t?void 0:t.view)||null}}F_.styleModule=SB,F_.inputHandler=JL,F_.clipboardInputFilter=ZL,F_.clipboardOutputFilter=eB,F_.scrollHandler=rB,F_.focusChangeEffect=QL,F_.perLineTextDirection=tB,F_.exceptionSink=$L,F_.updateListener=XL,F_.editable=lB,F_.mouseSelectionStyle=YL,F_.dragMovesSelection=GL,F_.clickAddsSelectionRange=KL,F_.decorations=mB,F_.blockWrappers=gB,F_.outerDecorations=vB,F_.atomicRanges=yB,F_.bidiIsolatedRanges=bB,F_.scrollMargins=kB,F_.darkTheme=E_,F_.cspNonce=vD.define({combine:e=>e.length?e[0]:""}),F_.contentAttributes=pB,F_.editorAttributes=dB,F_.lineWrapping=F_.contentAttributes.of({class:"cm-lineWrapping"}),F_.announce=GD.define();const W_=4096,j_={};class H_{constructor(e,t,n,r,i,o){this.from=e,this.to=t,this.dir=n,this.isolates=r,this.fresh=i,this.order=o}static update(e,t){if(t.empty&&!e.some(e=>e.fresh))return e;let n=[],r=e.length?e[e.length-1].dir:ML.LTR;for(let i=Math.max(0,e.length-10);i<e.length;i++){let o=e[i];o.dir!=r||t.touchesRange(o.from,o.to)||n.push(new H_(t.mapPos(o.from,1),t.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return n}}function z_(e,t,n){for(let r=e.state.facet(t),i=r.length-1;i>=0;i--){let t=r[i],o="function"==typeof t?t(e):t;o&&UP(o,n)}return n}class V_ extends sP{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}function q_(e){return U_.apply(this,arguments)}function U_(){return U_=A(j().m(function e(t){var n,r;return j().w(function(e){for(;;)switch(e.n){case 0:if(t){e.n=1;break}return e.a(2);case 1:if(!(null===(n=null===navigator||void 0===navigator?void 0:navigator.clipboard)||void 0===n?void 0:n.writeText)){e.n=3;break}return e.n=2,navigator.clipboard.writeText(t);case 2:return e.a(2);case 3:(r=document.createElement("textarea")).value=t,r.style.position="fixed",r.style.left="-9999px",document.body.appendChild(r),r.select(),document.execCommand("copy"),document.body.removeChild(r);case 4:return e.a(2)}},e)})),U_.apply(this,arguments)}function K_(t){var n=t.value,r=t.title;if(null==n||""===n)return e.createElement("span",null,"-");var i,o=qm(n),s=o.ok,a=o.pretty,l=o.compact,c=l.length>80?l.slice(0,80)+"…":l;return e.createElement(vm,null,e.createElement(ym,{asChild:!0},e.createElement("button",{type:"button",className:"max-w-xs truncate text-left font-mono text-xs text-muted-foreground hover:underline",title:"点击查看 JSON"},c)),e.createElement(km,{className:"max-w-3xl"},e.createElement(xm,null,e.createElement(Cm,null,r||"JSON")),e.createElement("div",{className:"flex items-center justify-end gap-2"},e.createElement(qt,{variant:"outline",size:"sm",onClick:(i=A(j().m(function e(){return j().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,q_(a);case 1:Lu.success("已复制 JSON"),e.n=3;break;case 2:e.p=2,e.v,Lu.error("复制失败");case 3:return e.a(2)}},e,null,[[0,2]])})),function(){return i.apply(this,arguments)})},"复制")),e.createElement("pre",{className:"max-h-[60vh] overflow-auto rounded-md bg-muted p-3 text-xs font-mono whitespace-pre-wrap break-all"},a),!s&&e.createElement("div",{className:"text-xs text-destructive"},o.ok?"":o.message)))}function G_(t){t.id;var n=t.value;t.required;var r,i=t.disabled,o=t.onChange,s=q(e.useState(null),2),a=s[0],l=s[1];return e.createElement("div",{className:"space-y-2"},e.createElement("div",{className:"flex items-center justify-end gap-2"},e.createElement(qt,{type:"button",variant:"outline",size:"sm",disabled:!!i,onClick:function(){if(!i){var e=(n||"").trim();if(e){var t=Um(e,2);t.ok?(o(t.formatted),l(null)):l(t.message)}}}},"格式化"),e.createElement(qt,{type:"button",variant:"outline",size:"sm",onClick:(r=A(j().m(function e(){return j().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,q_(n||"");case 1:Lu.success("已复制"),e.n=3;break;case 2:e.p=2,e.v,Lu.error("复制失败");case 3:return e.a(2)}},e,null,[[0,2]])})),function(){return r.apply(this,arguments)})},"复制")),e.createElement("div",{className:"w-full max-w-full overflow-hidden rounded-md border bg-background"},e.createElement(lR,{className:"w-full max-w-full",editable:!i,value:n||"",height:"220px",basicSetup:{lineNumbers:!0,foldGutter:!0,highlightActiveLine:!0},extensions:[new xE(LR),F_.lineWrapping],onChange:function(e){i||(o(e),function(e){var t=(e||"").trim();if(!t)return l(null),!0;var n=qm(t);n.ok?l(null):l(n.message)}(e))}})),a&&e.createElement("div",{className:"text-xs text-destructive"},a))}V_.prototype.elementClass="",V_.prototype.toDOM=void 0,V_.prototype.mapMode=iD.TrackBefore,V_.prototype.startSide=V_.prototype.endSide=-1,V_.prototype.point=!0;var Y_=e.forwardRef(function(t,n){var r=t.className,i=Z(t,["className"]);return e.createElement("div",{className:"relative w-full overflow-x-auto"},e.createElement("table",Object.assign({ref:n,className:Mt("w-full min-w-max caption-bottom text-sm",r)},i)))});Y_.displayName="Table";var $_=e.forwardRef(function(t,n){var r=t.className,i=Z(t,["className"]);return e.createElement("thead",Object.assign({ref:n,className:Mt("[&_tr]:border-b",r)},i))});$_.displayName="TableHeader";var X_=e.forwardRef(function(t,n){var r=t.className,i=Z(t,["className"]);return e.createElement("tbody",Object.assign({ref:n,className:Mt("[&_tr:last-child]:border-0",r)},i))});X_.displayName="TableBody";var J_=e.forwardRef(function(t,n){var r=t.className,i=Z(t,["className"]);return e.createElement("tfoot",Object.assign({ref:n,className:Mt("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",r)},i))});J_.displayName="TableFooter";var Q_=e.forwardRef(function(t,n){var r=t.className,i=Z(t,["className"]);return e.createElement("tr",Object.assign({ref:n,className:Mt("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",r)},i))});Q_.displayName="TableRow";var Z_=e.forwardRef(function(t,n){var r=t.className,i=Z(t,["className"]);return e.createElement("th",Object.assign({ref:n,className:Mt("h-12 px-4 text-left align-middle font-medium text-muted-foreground whitespace-nowrap [&:has([role=checkbox])]:pr-0",r)},i))});Z_.displayName="TableHead";var eF=e.forwardRef(function(t,n){var r=t.className,i=Z(t,["className"]);return e.createElement("td",Object.assign({ref:n,className:Mt("p-4 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0",r)},i))});eF.displayName="TableCell";var tF=e.forwardRef(function(t,n){var r=t.className,i=Z(t,["className"]);return e.createElement("caption",Object.assign({ref:n,className:Mt("mt-4 text-sm text-muted-foreground",r)},i))});tF.displayName="TableCaption";var nF=zt("inline-flex items-center rounded-full border px-3 py-1 text-xs font-bold transition-all duration-300",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow-[0_2px_8px_-1px_rgba(93,112,82,0.15)] hover:scale-105",secondary:"border-transparent bg-secondary text-secondary-foreground shadow-[0_2px_8px_-1px_rgba(193,140,93,0.15)] hover:scale-105",destructive:"border-transparent bg-destructive text-destructive-foreground shadow-[0_2px_8px_-1px_rgba(168,84,72,0.15)] hover:scale-105",outline:"text-foreground border-border"}},defaultVariants:{variant:"default"}});function rF(t){var n=t.className,r=t.variant,i=Z(t,["className","variant"]);return e.createElement("div",Object.assign({className:Mt(nF({variant:r}),n)},i))}function iF(){return"".concat(Date.now(),"_").concat(Math.random().toString(16).slice(2))}function oF(e){return"integer"===e||"float"===e?[{value:"eq",label:"等于"},{value:"neq",label:"不等于"},{value:"gt",label:"大于"},{value:"gte",label:"大于等于"},{value:"lt",label:"小于"},{value:"lte",label:"小于等于"},{value:"in",label:"属于(多个)"},{value:"isNull",label:"为空(NULL)"}]:"boolean"===e?[{value:"eq",label:"等于"},{value:"neq",label:"不等于"},{value:"isNull",label:"为空(NULL)"}]:"date"===e||"datetime"===e?[{value:"eq",label:"等于"},{value:"neq",label:"不等于"},{value:"gt",label:"晚于/大于"},{value:"gte",label:"晚于等于/大于等于"},{value:"lt",label:"早于/小于"},{value:"lte",label:"早于等于/小于等于"},{value:"isNull",label:"为空(NULL)"}]:[{value:"contains",label:"包含"},{value:"startsWith",label:"开头是"},{value:"endsWith",label:"结尾是"},{value:"eq",label:"等于"},{value:"neq",label:"不等于"},{value:"in",label:"属于(多个)"},{value:"isNull",label:"为空(NULL)"}]}function sF(e){var n,r,o=s(function(){var t=[];t.push.apply(t,K([{column:"id",label:"ID",type:"id"},{column:"created_at",label:"创建时间",type:"datetime"},{column:"updated_at",label:"更新时间",type:"datetime"}]));var n,r=D(e.fields||[]);try{for(r.s();!(n=r.n()).done;){var i=n.value;if((null==i?void 0:i.name)&&("json"!==i.type&&"jsonb"!==i.type))if("relation"===i.type&&i.relation){var o=i.relation.foreignKey||"".concat(i.relation.target,"_id");t.push({column:o,label:"".concat(i.comment||i.name,"(关联)"),type:"relation"})}else t.push({column:i.name,label:i.comment||i.name,type:i.type})}}catch(e){r.e(e)}finally{r.f()}var s=new Set;return t.filter(function(e){return!s.has(e.column)&&(s.add(e.column),!0)})},[e.fields]),l=s(function(){return new Map(o.map(function(e){return[e.column,e]}))},[o]),c=s(function(){return new Map(o.map(function(e){return[e.column,e.type]}))},[o]),u=q(i([]),2),h=u[0],f=u[1];a(function(){f(function(e,t){return(e||[]).map(function(e){if(t.get(e.column),"is"===e.operator&&(null===e.value||"null"===e.value))return{id:iF(),column:e.column,operator:"isNull",value:""};if(("ilike"===e.operator||"like"===e.operator)&&"string"==typeof e.value){var n=e.value;if(n.startsWith("%")&&n.endsWith("%")&&n.length>=2)return{id:iF(),column:e.column,operator:"contains",value:n.slice(1,-1)};if(n.endsWith("%"))return{id:iF(),column:e.column,operator:"startsWith",value:n.slice(0,-1)};if(n.startsWith("%"))return{id:iF(),column:e.column,operator:"endsWith",value:n.slice(1)}}if("in"===e.operator){var r=Array.isArray(e.value)?e.value:[];return{id:iF(),column:e.column,operator:"in",value:r.join(",")}}return{id:iF(),column:e.column,operator:["eq","neq","gt","gte","lt","lte"].includes(e.operator)?e.operator:"eq",value:void 0===e.value||null===e.value?"":String(e.value)}})}(e.value||[],c))},[JSON.stringify(e.value),o.length]);var d=function(e,t){f(function(n){return n.map(function(n){var r,i;if(n.id!==e)return n;var o=Object.assign(Object.assign({},n),t);if(t.column&&t.column!==n.column){var s=oF((null===(r=l.get(t.column))||void 0===r?void 0:r.type)||"string");o.operator=(null===(i=s[0])||void 0===i?void 0:i.value)||"eq",o.value=""}return t.operator&&"isNull"===t.operator&&(o.value=""),o})})};return t.createElement("div",{className:"space-y-3"},t.createElement("div",{className:"flex items-center justify-between gap-3"},t.createElement(pu,{className:"text-base font-medium flex items-center gap-2"},t.createElement(me,{className:"h-4 w-4"}),"动态筛选"),t.createElement("div",{className:"flex items-center gap-2"},(null===(n=e.value)||void 0===n?void 0:n.length)>0&&t.createElement(rF,{variant:"secondary"},"已应用 ",e.value.length," 条"),t.createElement(qt,{type:"button",variant:"outline",size:"sm",onClick:function(){var e=o[0];if(e){var t=oF(e.type);f(function(n){var r;return[].concat(K(n),[{id:iF(),column:e.column,operator:(null===(r=t[0])||void 0===r?void 0:r.value)||"eq",value:""}])})}}},t.createElement(Ce,{className:"h-4 w-4 mr-1"}),"添加条件"))),0===h.length?t.createElement("div",{className:"text-sm text-muted-foreground border rounded-lg p-3 bg-muted/20"},"暂无筛选条件(可添加条件后点击“应用”)"):t.createElement("div",{className:"space-y-2"},h.map(function(e){var n=l.get(e.column),r=(null==n?void 0:n.type)||"string",i=oF(r),s="isNull"!==e.operator;return t.createElement("div",{key:e.id,className:"grid grid-cols-12 gap-2 items-center"},t.createElement("div",{className:"col-span-5"},t.createElement(Yp,{value:e.column,onValueChange:function(t){return d(e.id,{column:t})}},t.createElement(Xp,{className:"h-10"},t.createElement($p,{placeholder:"字段"})),t.createElement(Zp,null,o.map(function(e){return t.createElement(tm,{key:e.column,value:e.column},e.label," (",e.column,")")})))),t.createElement("div",{className:"col-span-3"},t.createElement(Yp,{value:e.operator,onValueChange:function(t){return d(e.id,{operator:t})}},t.createElement(Xp,{className:"h-10"},t.createElement($p,{placeholder:"操作符"})),t.createElement(Zp,null,i.map(function(e){return t.createElement(tm,{key:e.value,value:e.value},e.label)})))),t.createElement("div",{className:"col-span-3"},s?"boolean"===r?t.createElement(Yp,{value:e.value,onValueChange:function(t){return d(e.id,{value:t})}},t.createElement(Xp,{className:"h-10"},t.createElement($p,{placeholder:"值"})),t.createElement(Zp,null,t.createElement(tm,{value:"true"},"true"),t.createElement(tm,{value:"false"},"false"))):t.createElement(Ut,{className:"h-10",placeholder:"in"===e.operator?"多个值用逗号分隔":"值",type:"integer"===r||"float"===r?"number":"date"===r?"date":"datetime"===r?"datetime-local":"text",value:e.value,onChange:function(t){return d(e.id,{value:t.target.value})}}):t.createElement("div",{className:"h-10 flex items-center text-sm text-muted-foreground"},"无需填写")),t.createElement("div",{className:"col-span-1 flex justify-end"},t.createElement(qt,{type:"button",variant:"ghost",size:"sm",className:"h-9 w-9 p-0",onClick:function(){return t=e.id,void f(function(e){return e.filter(function(e){return e.id!==t})});var t}},t.createElement(De,{className:"h-4 w-4"}))))})),t.createElement("div",{className:"flex items-center justify-end gap-2"},t.createElement(qt,{type:"button",variant:"outline",onClick:function(){f([]),e.onChange([])},disabled:0===h.length&&0===((null===(r=e.value)||void 0===r?void 0:r.length)||0)},"清空"),t.createElement(qt,{type:"button",onClick:function(){var t=function(e,t){var n,r,i=[],o=D(e);try{for(o.s();!(r=o.n()).done;){var s=r.value,a=t.get(s.column);if(a&&s.operator)if("isNull"!==s.operator){var l=null!==(n=s.value)&&void 0!==n?n:"",c=String(l).trim();if(c)if("contains"!==s.operator)if("startsWith"!==s.operator)if("endsWith"!==s.operator)if("in"!==s.operator)i.push({column:a.column,operator:s.operator,value:c});else{var u=c.split(",").map(function(e){return e.trim()}).filter(Boolean);i.push({column:a.column,operator:"in",value:u})}else i.push({column:a.column,operator:"ilike",value:"%".concat(c)});else i.push({column:a.column,operator:"ilike",value:"".concat(c,"%")});else i.push({column:a.column,operator:"ilike",value:"%".concat(c,"%")})}else i.push({column:a.column,operator:"is",value:null})}}catch(e){o.e(e)}finally{o.f()}return i}(h,l);e.onChange(t)},disabled:0===h.length},"应用")))}function aF(){var e,n=q(i([]),2),r=n[0],o=n[1],s=q(i(null),2),l=s[0],c=s[1],u=q(i([]),2),h=u[0],f=u[1],d=q(i(!1),2),p=d[0],m=d[1],g=q(i(!1),2),v=g[0],y=g[1],w=q(i(null),2),k=w[0],x=w[1],S=q(i({}),2),C=S[0],E=S[1],M=q(i(1),2),O=M[0],N=M[1],T=q(i(10),2),R=T[0];T[1];var D=q(i(0),2),L=D[0],B=D[1],I=q(i(""),2),_=I[0],F=I[1],W=q(i(!1),2),H=W[0],z=W[1],V=q(i(null),2),U=V[0],K=V[1],G=q(i(!0),2),Y=G[0],$=G[1],X=q(i([]),2),J=X[0],Q=X[1],Z=q(i(!1),2),ee=Z[0],te=Z[1],ne=function(e){return Array.isArray(e)?e:Array.isArray(null==e?void 0:e.models)?e.models:Array.isArray(null==e?void 0:e.data)?e.data:Array.isArray(null==e?void 0:e.items)?e.items:[]},re=function(e){var t;if(e&&Array.isArray(e.data)){var n="number"==typeof e.total?e.total:"number"==typeof(null===(t=e.pagination)||void 0===t?void 0:t.total)?e.pagination.total:e.data.length;return{rows:e.data,total:n}}if(e&&Array.isArray(e.rows)){var r="number"==typeof e.total?e.total:e.rows.length;return{rows:e.rows,total:r}}return Array.isArray(e)?{rows:e,total:e.length}:{rows:[],total:0}},ie=function(e){return!e||!e.readOnly&&!1!==e.editable};a(function(){oe()},[]),a(function(){l&&se()},[l,O,R,_,J]);var oe=function(){var e=A(j().m(function e(){var t;return j().w(function(e){for(;;)switch(e.p=e.n){case 0:return $(!0),e.p=1,e.n=2,ud();case 2:t=e.v,o(ne(t.data)),e.n=4;break;case 3:e.p=3,e.v,Lu.error("加载模型列表失败");case 4:return e.p=4,$(!1),e.f(4);case 5:return e.a(2)}},e,null,[[1,3,4,5]])}));return function(){return e.apply(this,arguments)}}(),se=function(){var e=A(j().m(function e(){var t,n,r;return j().w(function(e){for(;;)switch(e.p=e.n){case 0:if(l){e.n=1;break}return e.a(2);case 1:return m(!0),e.p=2,t={page:O,limit:R},_&&(t.search=_),J.length>0&&(t.filters=J),e.n=3,bd(l.table_name,t);case 3:if((n=e.v).success){e.n=4;break}return Lu.error(n.message||"加载数据失败"),f([]),B(0),e.a(2);case 4:r=re(n.data),f(r.rows),B(r.total),e.n=6;break;case 5:e.p=5,e.v,Lu.error("加载数据失败"),f([]),B(0);case 6:return e.p=6,m(!1),e.f(6);case 7:return e.a(2)}},e,null,[[2,5,6,7]])}));return function(){return e.apply(this,arguments)}}(),ae=function(){var e=A(j().m(function e(t){var n;return j().w(function(e){for(;;)switch(e.p=e.n){case 0:if(confirm("确定要删除这条数据吗?此操作不可撤销。")){e.n=1;break}return e.a(2);case 1:return K(t.id),e.p=2,e.n=3,Sd(null==l?void 0:l.table_name,t.id);case 3:(n=e.v).success?(Lu.success("删除成功"),se()):Lu.error(n.message||"删除失败"),e.n=5;break;case 4:e.p=4,e.v,Lu.error("删除失败");case 5:return e.p=5,K(null),e.f(5);case 6:return e.a(2)}},e,null,[[2,4,5,6]])}));return function(t){return e.apply(this,arguments)}}(),ue=function(){var e=A(j().m(function e(){var t,n,r,i,o;return j().w(function(e){for(;;)switch(e.p=e.n){case 0:if(l){e.n=1;break}return e.a(2);case 1:if(z(!0),e.p=2,t={},l.json_schema.fields.forEach(function(e){if("id"!==e.name&&ie(e)){var n=C[e.name];if("date"!==e.type&&"datetime"!==e.type||(n=n?new Date(n).toISOString():null),"json"===e.type||"jsonb"===e.type){var r=(n||"").toString().trim();if(r){var i=qm(r);if(!i.ok)throw new Error("字段 ".concat(e.comment||e.name,":").concat(i.message));n=i.value}else n=null}t[e.name]=n}}),!k){e.n=4;break}return e.n=3,xd(l.table_name,Object.assign(Object.assign({},t),{id:k.id}));case 3:(n=e.v).success?(Lu.success("更新成功"),y(!1),se()):Lu.error(n.message||"更新失败"),e.n=6;break;case 4:return e.n=5,kd(l.table_name,t);case 5:(r=e.v).success?(Lu.success("创建成功"),y(!1),se()):Lu.error(r.message||"创建失败");case 6:e.n=8;break;case 7:e.p=7,o=e.v,i=o instanceof Error?o.message:"操作失败",Lu.error(i);case 8:return e.p=8,z(!1),e.f(8);case 9:return e.a(2)}},e,null,[[2,7,8,9]])}));return function(){return e.apply(this,arguments)}}();return t.createElement("div",{className:"min-h-[calc(100vh-4rem)] bg-gradient-to-br from-background via-background to-muted/20"},t.createElement("div",{className:"container mx-auto px-6 py-8 space-y-6"},t.createElement("div",{className:"space-y-2"},t.createElement("h1",{className:"text-3xl font-bold tracking-tight"},"数据列表"),t.createElement("p",{className:"text-muted-foreground"},"选择模型查看和管理数据")),t.createElement(mu,{className:"border-2 shadow-lg"},t.createElement(gu,{className:"bg-muted/30"},t.createElement("div",{className:"flex flex-col md:flex-row md:items-center md:justify-between gap-4"},t.createElement("div",null,t.createElement(vu,null,"数据管理"),t.createElement(yu,null,"选择数据模型进行查看和管理")),l&&t.createElement(qt,{onClick:function(){x(null),E({}),y(!0)},className:"w-full md:w-auto"},t.createElement(Ce,{className:"h-4 w-4 mr-2"}),"新建数据"))),t.createElement(bu,{className:"space-y-6 pt-6"},t.createElement("div",{className:"flex flex-col md:flex-row gap-4"},t.createElement("div",{className:"flex-1 space-y-2"},t.createElement(pu,{htmlFor:"model",className:"text-base font-medium flex items-center gap-2"},t.createElement(me,{className:"h-4 w-4"}),"选择数据模型"),t.createElement(Yp,{value:(null===(e=null==l?void 0:l.id)||void 0===e?void 0:e.toString())||"",onValueChange:function(e){var t=r.find(function(t){return t.id.toString()===e});c(t||null),N(1),F(""),Q([])},disabled:Y},t.createElement(Xp,{className:"h-11"},Y?t.createElement("div",{className:"flex items-center gap-2"},t.createElement(be,{className:"h-4 w-4 animate-spin"}),t.createElement("span",null,"加载中...")):t.createElement($p,{placeholder:"请选择模型"})),t.createElement(Zp,null,r.map(function(e){return t.createElement(tm,{key:e.id,value:e.id.toString()},e.name," (",e.table_name,")")})))),l&&t.createElement("div",{className:"flex-1 space-y-2"},t.createElement(pu,{htmlFor:"search",className:"text-base font-medium flex items-center gap-2"},t.createElement(Ee,{className:"h-4 w-4"}),"搜索"),t.createElement("div",{className:"relative"},t.createElement(Ee,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),t.createElement(Ut,{id:"search",placeholder:"搜索数据...",value:_,onChange:function(e){return F(e.target.value)},className:"pl-10 h-11"})))),l&&t.createElement(t.Fragment,null,t.createElement("div",{className:"flex items-center justify-end"},t.createElement(qt,{type:"button",variant:"outline",className:"h-10",onClick:function(){return te(!0)}},t.createElement(me,{className:"h-4 w-4 mr-2"}),"筛选",J.length>0?"(".concat(J.length,")"):"")),t.createElement("div",{className:"flex items-center justify-between p-4 rounded-lg bg-muted/50 border"},t.createElement("div",{className:"text-sm text-muted-foreground"},"共 ",t.createElement("span",{className:"font-semibold text-foreground"},L)," 条数据"),t.createElement(rF,{variant:"outline"},l.name)),t.createElement("div",{className:"rounded-lg border overflow-hidden"},t.createElement("div",{className:"overflow-x-auto"},t.createElement(Y_,null,t.createElement($_,null,t.createElement(Q_,{className:"bg-muted/50"},t.createElement(Z_,{className:"font-semibold w-20"},"ID"),l.json_schema.fields.map(function(e){return t.createElement(Z_,{key:e.name,className:"font-semibold"},e.comment||e.name)}),t.createElement(Z_,{className:"font-semibold"},"创建时间"),t.createElement(Z_,{className:"font-semibold"},"更新时间"),t.createElement(Z_,{className:"font-semibold w-32 text-center"},"操作"))),t.createElement(X_,null,p?Array.from({length:3}).map(function(e,n){return t.createElement(Q_,{key:n},t.createElement(eF,{colSpan:l.json_schema.fields.length+4},t.createElement("div",{className:"flex items-center gap-2 py-4"},t.createElement(be,{className:"h-4 w-4 animate-spin text-muted-foreground"}),t.createElement("span",{className:"text-sm text-muted-foreground"},"加载中..."))))}):0===h.length?t.createElement(Q_,null,t.createElement(eF,{colSpan:l.json_schema.fields.length+4,className:"text-center py-12"},t.createElement("div",{className:"flex flex-col items-center gap-2 text-muted-foreground"},t.createElement(Ee,{className:"h-8 w-8"}),t.createElement("p",null,"暂无数据")))):h.map(function(e,n){return t.createElement(Q_,{key:e.id,className:n%2==0?"bg-muted/20":""},t.createElement(eF,{className:"font-mono font-medium"},e.id),l.json_schema.fields.map(function(n){return t.createElement(eF,{key:n.name},function(e,n){return"boolean"===e.type?t.createElement(rF,{variant:n?"default":"secondary"},n?"是":"否"):"date"===e.type||"datetime"===e.type?n?b(n).format("YYYY-MM-DD HH:mm:ss"):"-":"text"===e.type&&n&&n.length>50?t.createElement("span",{className:"max-w-xs truncate block",title:n},n.substring(0,50),"..."):"json"===e.type||"jsonb"===e.type?t.createElement(K_,{value:n,title:e.comment||e.name}):n||"-"}(n,e[n.name]))}),t.createElement(eF,{className:"text-sm text-muted-foreground"},b(e.created_at).format("YYYY-MM-DD HH:mm")),t.createElement(eF,{className:"text-sm text-muted-foreground"},b(e.updated_at).format("YYYY-MM-DD HH:mm")),t.createElement(eF,null,t.createElement("div",{className:"flex items-center justify-center gap-2"},t.createElement(qt,{variant:"ghost",size:"sm",onClick:function(){return function(e){x(e);var t={};null==l||l.json_schema.fields.forEach(function(n){if("id"!==n.name){var r=e[n.name];"date"!==n.type&&"datetime"!==n.type||(r=r?b(r).format("YYYY-MM-DDTHH:mm"):""),"json"!==n.type&&"jsonb"!==n.type||(r=null==r||""===r?"":"string"==typeof r?r:JSON.stringify(r,null,2)),t[n.name]=r}}),E(t),y(!0)}(e)},className:"h-8 w-8 p-0"},t.createElement(Me,{className:"h-4 w-4"})),t.createElement(qt,{variant:"ghost",size:"sm",onClick:function(){return ae(e)},disabled:U===e.id,className:"h-8 w-8 p-0 text-destructive hover:text-destructive"},U===e.id?t.createElement(be,{className:"h-4 w-4 animate-spin"}):t.createElement(Ne,{className:"h-4 w-4"})))))}))))),L>R&&t.createElement("div",{className:"flex items-center justify-between p-4 rounded-lg bg-muted/50 border"},t.createElement("div",{className:"text-sm text-muted-foreground"},"第 ",t.createElement("span",{className:"font-semibold text-foreground"},O)," 页, 共 ",t.createElement("span",{className:"font-semibold text-foreground"},Math.ceil(L/R))," 页"),t.createElement("div",{className:"flex gap-2"},t.createElement(qt,{variant:"outline",size:"sm",onClick:function(){return N(Math.max(1,O-1))},disabled:1===O||p},t.createElement(le,{className:"h-4 w-4 mr-1"}),"上一页"),t.createElement(qt,{variant:"outline",size:"sm",onClick:function(){return N(Math.min(Math.ceil(L/R),O+1))},disabled:O>=Math.ceil(L/R)||p},"下一页",t.createElement(ce,{className:"h-4 w-4 ml-1"}))))))),l&&t.createElement(vm,{open:ee,onOpenChange:te},t.createElement(km,{className:"max-w-3xl"},t.createElement(xm,null,t.createElement(Cm,{className:"text-xl"},"筛选"),t.createElement(Am,{className:"text-sm"},l.name," - ",l.table_name)),t.createElement("div",{className:"py-2"},t.createElement(sF,{fields:l.json_schema.fields,value:J,onChange:function(e){Q(e),N(1)}})),t.createElement(Sm,{className:"gap-2"},t.createElement(qt,{variant:"outline",onClick:function(){return te(!1)}},"关闭")))),t.createElement(vm,{open:v,onOpenChange:y},t.createElement(km,{className:"max-w-3xl max-h-[85vh] overflow-y-auto"},t.createElement(xm,null,t.createElement(Cm,{className:"text-2xl"},k?"编辑数据":"新建数据"),t.createElement(Am,{className:"text-base"},null==l?void 0:l.name," - ",null==l?void 0:l.table_name)),t.createElement("div",{className:"space-y-4 py-4"},null==l?void 0:l.json_schema.fields.map(function(e){return function(e){if("id"===e.name)return null;var n=ie(e);switch(e.type){case"boolean":return t.createElement("div",{key:e.name,className:"flex items-center space-x-3 p-4 rounded-lg border bg-card"},t.createElement(mm,{id:e.name,checked:C[e.name]||!1,disabled:!n,onCheckedChange:function(t){return E(Object.assign(Object.assign({},C),P({},e.name,t)))}}),t.createElement(pu,{htmlFor:e.name,className:"text-base font-medium cursor-pointer"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")));case"date":return t.createElement("div",{key:e.name,className:"space-y-2"},t.createElement(pu,{htmlFor:e.name,className:"text-base font-medium"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")),t.createElement(Ut,{id:e.name,type:"date",value:C[e.name]||"",disabled:!n,onChange:function(t){return E(Object.assign(Object.assign({},C),P({},e.name,t.target.value)))},required:e.required,className:"h-11"}));case"datetime":return t.createElement("div",{key:e.name,className:"space-y-2"},t.createElement(pu,{htmlFor:e.name,className:"text-base font-medium"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")),t.createElement(Ut,{id:e.name,type:"datetime-local",value:C[e.name]||"",disabled:!n,onChange:function(t){return E(Object.assign(Object.assign({},C),P({},e.name,t.target.value)))},required:e.required,className:"h-11"}));case"text":return t.createElement("div",{key:e.name,className:"space-y-2"},t.createElement(pu,{htmlFor:e.name,className:"text-base font-medium"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")),t.createElement(gm,{id:e.name,rows:4,value:C[e.name]||"",disabled:!n,onChange:function(t){return E(Object.assign(Object.assign({},C),P({},e.name,t.target.value)))},required:e.required,className:"resize-none"}));case"json":case"jsonb":return t.createElement("div",{key:e.name,className:"space-y-2"},t.createElement(pu,{htmlFor:e.name,className:"text-base font-medium"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")),t.createElement(G_,{id:e.name,value:C[e.name]||"",required:e.required,disabled:!n,onChange:function(t){return E(Object.assign(Object.assign({},C),P({},e.name,t)))}}));case"integer":case"float":return t.createElement("div",{key:e.name,className:"space-y-2"},t.createElement(pu,{htmlFor:e.name,className:"text-base font-medium"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")),t.createElement(Ut,{id:e.name,type:"number",value:C[e.name]||"",disabled:!n,onChange:function(t){return E(Object.assign(Object.assign({},C),P({},e.name,t.target.value)))},required:e.required,className:"h-11"}));default:return t.createElement("div",{key:e.name,className:"space-y-2"},t.createElement(pu,{htmlFor:e.name,className:"text-base font-medium"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")),t.createElement(Ut,{id:e.name,type:"email"===e.type?"email":"text",maxLength:e.maxLength,value:C[e.name]||"",disabled:!n,onChange:function(t){return E(Object.assign(Object.assign({},C),P({},e.name,t.target.value)))},required:e.required,className:"h-11"}))}}(e)})),t.createElement(Sm,{className:"gap-2"},t.createElement(qt,{variant:"outline",onClick:function(){return y(!1)},disabled:H},"取消"),t.createElement(qt,{onClick:ue,disabled:H},H?t.createElement(t.Fragment,null,t.createElement(be,{className:"h-4 w-4 mr-2 animate-spin"}),k?"更新中...":"创建中..."):k?"更新":"创建"))))))}function lF(e){return/^https?:\/\//i.test(e)}function cF(e){var n=e.url;return t.createElement("div",{className:"flex items-center gap-2 max-w-[360px]"},t.createElement(ya,null,t.createElement(ba,{asChild:!0},t.createElement("a",{href:n,target:"_blank",rel:"noreferrer",className:"inline-flex h-10 w-10 shrink-0 items-center justify-center overflow-hidden rounded border bg-muted",title:"点击打开原图"},t.createElement("img",{src:n,alt:"",className:"h-full w-full object-cover",onError:function(e){e.currentTarget.style.display="none"}}))),t.createElement(wa,{side:"right",className:"p-2"},t.createElement("img",{src:n,alt:"",className:"max-h-64 max-w-64 rounded object-contain",onError:function(e){e.currentTarget.style.display="none"}}))),t.createElement("a",{href:n,target:"_blank",rel:"noreferrer",className:"truncate text-primary underline-offset-2 hover:underline",title:n},n))}function uF(e){var n=e.model,r=q(i([]),2),o=r[0],l=r[1],c=q(i(!1),2),u=c[0],h=c[1],f=q(i(!1),2),d=f[0],p=f[1],m=q(i(!1),2),g=m[0],v=m[1],y=q(i(null),2),w=y[0],k=y[1],x=q(i({}),2),S=x[0],C=x[1],E=q(i(1),2),M=E[0],O=E[1],N=q(i(10),2),T=N[0];N[1];var R=q(i(0),2),D=R[0],L=R[1],B=q(i(""),2),I=B[0],_=B[1],F=q(i(!1),2),W=F[0],H=F[1],z=q(i(null),2),V=z[0],U=z[1],K=q(i({}),2),G=K[0],Y=K[1],$=q(i([]),2),X=$[0],J=$[1],Q=s(function(){return X.length?JSON.stringify(X):""},[X]),Z=function(e){return!e.readOnly&&!1!==e.editable};a(function(){n&&te()},[null==n?void 0:n.table_name,M,T,I,Q]);var ee=function(){var e=A(j().m(function e(t){var n,r,i,o,s;return j().w(function(e){for(;;)switch(e.p=e.n){case 0:if("relation"===t.type&&t.relation){e.n=1;break}return e.a(2);case 1:if(n=t.relation,r=n.target,i=n.displayField,o="".concat(r,"_").concat(i||"name"),!G[o]){e.n=2;break}return e.a(2);case 2:return e.p=2,e.n=3,wd(r,{displayField:i||"name",limit:200});case 3:(s=e.v).success&&s.data&&Y(function(e){return Object.assign(Object.assign({},e),P({},o,s.data))}),e.n=5;break;case 4:e.p=4,e.v;case 5:return e.a(2)}},e,null,[[2,4]])}));return function(t){return e.apply(this,arguments)}}();a(function(){d&&n&&n.json_schema.fields.filter(function(e){return"relation"===e.type&&e.relation}).forEach(function(e){return ee(e)})},[d,n]);var te=function(){var e=A(j().m(function e(){var t,r,i,o;return j().w(function(e){for(;;)switch(e.p=e.n){case 0:if(n){e.n=1;break}return e.a(2);case 1:return h(!0),e.p=2,i={page:M,limit:T},I&&(i.search=I),X.length>0&&(i.filters=X),e.n=3,bd(n.table_name,i);case 3:if((o=e.v).success){e.n=4;break}return Lu.error(o.message||"加载数据失败"),l([]),L(0),e.a(2);case 4:l((null===(t=o.data)||void 0===t?void 0:t.data)||[]),L((null===(r=o.data)||void 0===r?void 0:r.total)||0),e.n=6;break;case 5:e.p=5,e.v,Lu.error("加载数据失败"),l([]),L(0);case 6:return e.p=6,h(!1),e.f(6);case 7:return e.a(2)}},e,null,[[2,5,6,7]])}));return function(){return e.apply(this,arguments)}}(),ne=function(){var e=A(j().m(function e(t){var r;return j().w(function(e){for(;;)switch(e.p=e.n){case 0:if(confirm("确定要删除这条数据吗?此操作不可撤销。")){e.n=1;break}return e.a(2);case 1:return U(t.id),e.p=2,e.n=3,Sd(null==n?void 0:n.table_name,t.id);case 3:(r=e.v).success?(Lu.success("删除成功"),te()):Lu.error(r.message||"删除失败"),e.n=5;break;case 4:e.p=4,e.v,Lu.error("删除失败");case 5:return e.p=5,U(null),e.f(5);case 6:return e.a(2)}},e,null,[[2,4,5,6]])}));return function(t){return e.apply(this,arguments)}}(),re=function(){var e=A(j().m(function e(){var t,r,i,o,s,a;return j().w(function(e){for(;;)switch(e.p=e.n){case 0:if(n){e.n=1;break}return e.a(2);case 1:if(H(!0),e.p=2,t={},n.json_schema.fields.forEach(function(e){if("id"!==e.name&&Z(e))if("relation"===e.type&&e.relation){var n=e.relation.foreignKey||"".concat(e.relation.target,"_id");t[n]=S[n]}else{var r=S[e.name];if("date"!==e.type&&"datetime"!==e.type||(r=r?new Date(r).toISOString():null),"json"===e.type||"jsonb"===e.type){var i=(r||"").toString().trim();if(i){var o=qm(i);if(!o.ok)throw new Error("字段 ".concat(e.comment||e.name,":").concat(o.message));r=o.value}else r=null}t[e.name]=r}}),!w){e.n=4;break}return r=Object.assign(Object.assign({},t),{id:w.id}),e.n=3,xd(n.table_name,r);case 3:(i=e.v).success?(Lu.success("更新成功"),p(!1),te()):Lu.error(i.message||"更新失败"),e.n=6;break;case 4:return e.n=5,kd(n.table_name,t);case 5:(o=e.v).success?(Lu.success("创建成功"),p(!1),te()):Lu.error(o.message||"创建失败");case 6:e.n=8;break;case 7:e.p=7,a=e.v,s=a instanceof Error?a.message:"操作失败",Lu.error(s);case 8:return e.p=8,H(!1),e.f(8);case 9:return e.a(2)}},e,null,[[2,7,8,9]])}));return function(){return e.apply(this,arguments)}}(),ie=function(e,n,r){if("string"==typeof n){var i=n.trim();if(i&&function(e){var t,n=e.trim();if(!n)return!1;if(n.startsWith("data:image/"))return!0;if(!lF(n))return!1;var r=(null===(t=n.split("#")[0])||void 0===t?void 0:t.split("?")[0])||n;return/\.(png|jpe?g|gif|webp|bmp|svg)$/i.test(r)}(i))return t.createElement(cF,{url:i});if(i&&lF(i))return t.createElement("a",{href:i,target:"_blank",rel:"noreferrer",className:"max-w-[360px] truncate text-primary underline-offset-2 hover:underline block",title:i},i)}if("boolean"===e.type)return t.createElement(rF,{variant:n?"default":"secondary"},n?"是":"否");if("date"===e.type||"datetime"===e.type)return n?b(n).format("YYYY-MM-DD HH:mm:ss"):"-";if("text"===e.type&&n&&n.length>50)return t.createElement("span",{className:"max-w-xs truncate block",title:n},n.substring(0,50),"...");if("json"===e.type||"jsonb"===e.type)return t.createElement(K_,{value:n,title:e.comment||e.name});if("relation"===e.type&&e.relation&&r){var o=e.relation.displayField,s=void 0===o?"name":o,a=r["".concat(e.name,"_data")];if(a)return t.createElement(rF,{variant:"outline"},a[s]||"ID: ".concat(a.id));var l=r[e.relation.foreignKey||"".concat(e.relation.target,"_id")];return l?"ID: ".concat(l):"-"}return n||"-"};return n?t.createElement("div",{className:"min-h-[calc(100vh-4rem)] bg-gradient-to-br from-background via-background to-muted/20"},t.createElement("div",{className:"w-full py-4 space-y-4"},t.createElement("div",{className:"space-y-1"},t.createElement("div",{className:"flex items-center gap-3"},t.createElement("div",{className:"inline-flex items-center justify-center w-9 h-9 rounded-lg bg-primary/10 text-primary"},t.createElement(de,{className:"h-4 w-4"})),t.createElement("div",null,t.createElement("h1",{className:"text-2xl font-bold tracking-tight leading-tight"},n.name),t.createElement("p",{className:"text-sm text-muted-foreground"},"表名: ",n.table_name)))),t.createElement(mu,{className:"border-2 shadow-lg"},t.createElement(gu,{className:"bg-muted/30"},t.createElement("div",{className:"flex flex-col md:flex-row md:items-center md:justify-between gap-4"},t.createElement("div",null,t.createElement(vu,null,"数据管理"),t.createElement(yu,null,"查看和管理 ",n.name," 的数据")),t.createElement(qt,{onClick:function(){k(null),C({}),p(!0)},className:"w-full md:w-auto"},t.createElement(Ce,{className:"h-4 w-4 mr-2"}),"新建数据"))),t.createElement(bu,{className:"space-y-4 pt-4"},t.createElement("div",{className:"flex flex-col md:flex-row md:items-center gap-3"},t.createElement("div",{className:"flex-1"},t.createElement(pu,{htmlFor:"search",className:"sr-only"},"搜索"),t.createElement("div",{className:"relative"},t.createElement(Ee,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),t.createElement(Ut,{id:"search",placeholder:"搜索数据...",value:I,onChange:function(e){return _(e.target.value)},className:"pl-10 h-10"}))),t.createElement(qt,{type:"button",variant:"outline",className:"h-10",onClick:function(){return v(!0)}},t.createElement(me,{className:"h-4 w-4 mr-2"}),"筛选",X.length>0?"(".concat(X.length,")"):"")),t.createElement("div",{className:"flex items-center justify-between p-4 rounded-lg bg-muted/50 border"},t.createElement("div",{className:"text-sm text-muted-foreground"},"共 ",t.createElement("span",{className:"font-semibold text-foreground"},D)," 条数据"),t.createElement(rF,{variant:"outline"},n.name)),t.createElement("div",{className:"rounded-lg border overflow-hidden"},t.createElement(Y_,null,t.createElement($_,null,t.createElement(Q_,{className:"bg-muted/50"},t.createElement(Z_,{className:"font-semibold w-20"},"ID"),n.json_schema.fields.map(function(e){return t.createElement(Z_,{key:e.name,className:"font-semibold"},e.comment||e.name)}),t.createElement(Z_,{className:"font-semibold"},"创建时间"),t.createElement(Z_,{className:"font-semibold"},"更新时间"),t.createElement(Z_,{className:Mt("font-semibold w-32 text-center sticky right-0 z-30 bg-background","before:content-[''] before:absolute before:inset-y-0 before:left-0 before:w-px before:bg-border","after:content-[''] after:absolute after:inset-y-0 after:left-[-16px] after:w-4 after:bg-gradient-to-l after:from-background after:to-transparent","shadow-[-10px_0_16px_-14px_rgba(0,0,0,0.35)]")},"操作"))),t.createElement(X_,null,u?Array.from({length:3}).map(function(e,r){return t.createElement(Q_,{key:r},t.createElement(eF,{colSpan:n.json_schema.fields.length+4},t.createElement("div",{className:"flex items-center gap-2 py-4"},t.createElement(be,{className:"h-4 w-4 animate-spin text-muted-foreground"}),t.createElement("span",{className:"text-sm text-muted-foreground"},"加载中..."))))}):0===o.length?t.createElement(Q_,null,t.createElement(eF,{colSpan:n.json_schema.fields.length+4,className:"text-center py-12"},t.createElement("div",{className:"flex flex-col items-center gap-2 text-muted-foreground"},t.createElement(Ee,{className:"h-8 w-8"}),t.createElement("p",null,"暂无数据")))):o.map(function(e,r){return t.createElement(Q_,{key:e.id,className:Mt("group hover:bg-muted",r%2==0?"bg-muted/20":"")},t.createElement(eF,{className:"font-mono font-medium max-w-[220px] truncate",title:String(e.id)},e.id),n.json_schema.fields.map(function(n){return t.createElement(eF,{key:n.name},ie(n,e[n.name],e))}),t.createElement(eF,{className:"text-sm text-muted-foreground"},b(e.created_at).format("YYYY-MM-DD HH:mm")),t.createElement(eF,{className:"text-sm text-muted-foreground"},b(e.updated_at).format("YYYY-MM-DD HH:mm")),t.createElement(eF,{className:Mt("sticky right-0 z-20 bg-background","before:content-[''] before:absolute before:inset-y-0 before:left-0 before:w-px before:bg-border","after:content-[''] after:absolute after:inset-y-0 after:left-[-16px] after:w-4 after:bg-gradient-to-l after:from-background after:to-transparent","shadow-[-10px_0_16px_-14px_rgba(0,0,0,0.25)]","group-hover:bg-muted")},t.createElement("div",{className:"flex items-center justify-center gap-2"},t.createElement(qt,{variant:"ghost",size:"sm",onClick:function(){return function(e){k(e);var t={};null==n||n.json_schema.fields.forEach(function(n){if("id"!==n.name)if("relation"===n.type&&n.relation){var r=n.relation.foreignKey||"".concat(n.relation.target,"_id");t[r]=e[r]}else{var i=e[n.name];"date"!==n.type&&"datetime"!==n.type||(i=i?b(i).format("YYYY-MM-DDTHH:mm"):""),"json"!==n.type&&"jsonb"!==n.type||(i=null==i||""===i?"":"string"==typeof i?i:JSON.stringify(i,null,2)),t[n.name]=i}}),C(t),p(!0)}(e)},className:"h-8 w-8 p-0"},t.createElement(Me,{className:"h-4 w-4"})),t.createElement(qt,{variant:"ghost",size:"sm",onClick:function(){return ne(e)},disabled:V===e.id,className:"h-8 w-8 p-0 text-destructive hover:text-destructive"},V===e.id?t.createElement(be,{className:"h-4 w-4 animate-spin"}):t.createElement(Ne,{className:"h-4 w-4"})))))})))),D>T&&t.createElement("div",{className:"flex items-center justify-between p-4 rounded-lg bg-muted/50 border"},t.createElement("div",{className:"text-sm text-muted-foreground"},"第 ",t.createElement("span",{className:"font-semibold text-foreground"},M)," 页, 共 ",t.createElement("span",{className:"font-semibold text-foreground"},Math.ceil(D/T))," 页"),t.createElement("div",{className:"flex gap-2"},t.createElement(qt,{variant:"outline",size:"sm",onClick:function(){return O(Math.max(1,M-1))},disabled:1===M||u},t.createElement(le,{className:"h-4 w-4 mr-1"}),"上一页"),t.createElement(qt,{variant:"outline",size:"sm",onClick:function(){return O(Math.min(Math.ceil(D/T),M+1))},disabled:M>=Math.ceil(D/T)||u},"下一页",t.createElement(ce,{className:"h-4 w-4 ml-1"})))))),t.createElement(vm,{open:g,onOpenChange:v},t.createElement(km,{className:"max-w-3xl"},t.createElement(xm,null,t.createElement(Cm,{className:"text-xl"},"筛选"),t.createElement(Am,{className:"text-sm"},n.name," - ",n.table_name)),t.createElement("div",{className:"py-2"},t.createElement(sF,{fields:n.json_schema.fields,value:X,onChange:function(e){J(e),O(1)}})),t.createElement(Sm,{className:"gap-2"},t.createElement(qt,{variant:"outline",onClick:function(){return v(!1)}},"关闭")))),t.createElement(vm,{open:d,onOpenChange:p},t.createElement(km,{className:"max-w-3xl max-h-[85vh] overflow-y-auto"},t.createElement(xm,null,t.createElement(Cm,{className:"text-2xl"},w?"编辑数据":"新建数据"),t.createElement(Am,{className:"text-base"},n.name," - ",n.table_name)),t.createElement("div",{className:"space-y-6 py-4"},n.json_schema.fields.map(function(e){return function(e){if("id"===e.name)return null;var n=Z(e);switch(e.type){case"boolean":return t.createElement("div",{key:e.name,className:"flex items-center space-x-3 p-4 rounded-lg border bg-card"},t.createElement(mm,{id:e.name,checked:S[e.name]||!1,disabled:!n,onCheckedChange:function(t){return C(Object.assign(Object.assign({},S),P({},e.name,t)))}}),t.createElement(pu,{htmlFor:e.name,className:"text-sm font-semibold cursor-pointer"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")));case"date":return t.createElement("div",{key:e.name,className:"space-y-2.5"},t.createElement(pu,{htmlFor:e.name,className:"text-sm font-semibold"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")),t.createElement(Ut,{id:e.name,type:"date",value:S[e.name]||"",disabled:!n,onChange:function(t){return C(Object.assign(Object.assign({},S),P({},e.name,t.target.value)))},required:e.required,className:"h-11"}));case"datetime":return t.createElement("div",{key:e.name,className:"space-y-2.5"},t.createElement(pu,{htmlFor:e.name,className:"text-sm font-semibold"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")),t.createElement(Ut,{id:e.name,type:"datetime-local",value:S[e.name]||"",disabled:!n,onChange:function(t){return C(Object.assign(Object.assign({},S),P({},e.name,t.target.value)))},required:e.required,className:"h-11"}));case"text":return t.createElement("div",{key:e.name,className:"space-y-2.5"},t.createElement(pu,{htmlFor:e.name,className:"text-sm font-semibold"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")),t.createElement(gm,{id:e.name,rows:4,value:S[e.name]||"",disabled:!n,onChange:function(t){return C(Object.assign(Object.assign({},S),P({},e.name,t.target.value)))},required:e.required,className:"resize-none"}));case"json":case"jsonb":return t.createElement("div",{key:e.name,className:"space-y-2.5"},t.createElement(pu,{htmlFor:e.name,className:"text-sm font-semibold"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")),t.createElement(G_,{id:e.name,value:S[e.name]||"",required:e.required,disabled:!n,onChange:function(t){return C(Object.assign(Object.assign({},S),P({},e.name,t)))}}));case"integer":case"float":return t.createElement("div",{key:e.name,className:"space-y-2.5"},t.createElement(pu,{htmlFor:e.name,className:"text-sm font-semibold"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")),t.createElement(Ut,{id:e.name,type:"number",value:S[e.name]||"",disabled:!n,onChange:function(t){return C(Object.assign(Object.assign({},S),P({},e.name,t.target.value)))},required:e.required,className:"h-11"}));case"relation":if(!e.relation)return null;var r=e.relation,i=r.target,o=r.displayField,s=void 0===o?"name":o,a="".concat(i,"_").concat(s),l=G[a]||[],c=e.relation.foreignKey||"".concat(i,"_id"),u=void 0!==S[c]&&null!==S[c]?String(S[c]):"",h=l.find(function(e){return String(e.id)===u});return t.createElement("div",{key:e.name,className:"space-y-2.5"},t.createElement(pu,{htmlFor:e.name,className:"text-sm font-semibold"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")),t.createElement(Yp,{value:u,disabled:!n,onValueChange:function(e){var t=parseInt(e,10),n=!isNaN(t)&&String(t)===e;C(Object.assign(Object.assign({},S),P({},c,n?t:e)))}},t.createElement(Xp,{className:"h-11"},t.createElement($p,{placeholder:"请选择".concat(e.comment||e.name)},h?h.label:u?"ID: ".concat(u):"请选择".concat(e.comment||e.name))),t.createElement(Zp,null,0===l.length?t.createElement(tm,{value:"_loading",disabled:!0},"加载中..."):l.map(function(e){return t.createElement(tm,{key:e.id,value:String(e.id)},e.label)}))));default:return t.createElement("div",{key:e.name,className:"space-y-2.5"},t.createElement(pu,{htmlFor:e.name,className:"text-sm font-semibold"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")),t.createElement(Ut,{id:e.name,type:"email"===e.type?"email":"text",maxLength:e.maxLength,value:S[e.name]||"",disabled:!n,onChange:function(t){return C(Object.assign(Object.assign({},S),P({},e.name,t.target.value)))},required:e.required,className:"h-11"}))}}(e)})),t.createElement(Sm,{className:"gap-2"},t.createElement(qt,{variant:"outline",onClick:function(){return p(!1)},disabled:W},"取消"),t.createElement(qt,{onClick:re,disabled:W},W?t.createElement(t.Fragment,null,t.createElement(be,{className:"h-4 w-4 mr-2 animate-spin"}),w?"更新中...":"创建中..."):w?"更新":"创建")))))):t.createElement("div",{className:"min-h-[calc(100vh-4rem)] bg-gradient-to-br from-background via-background to-muted/20"},t.createElement("div",{className:"w-full py-4"},t.createElement(mu,{className:"border-2"},t.createElement(bu,{className:"py-16 text-center"},t.createElement(de,{className:"h-12 w-12 mx-auto mb-4 text-muted-foreground"}),t.createElement("p",{className:"text-lg text-muted-foreground"},"请选择数据模型")))))}function hF(e){var n=e.model;return t.createElement(uF,{key:n.id,model:n})}function fF(e){return e.models.map(function(e){return{path:"/data/list-".concat(e.id),name:e.name,icon:t.createElement(Oe),component:function(){return t.createElement(hF,{model:e})}}})}var dF=function(e){return[{path:"/login",name:"登录",icon:t.createElement(ke),component:Td},{name:"数据管理",icon:t.createElement(fe),path:"/data",component:aF,routes:K(fF(e))}]},pF=Ae,mF=Te,gF=xe,vF=ye;function yF(e){var n=e.inputModels,r=e.skipAuth,o=void 0!==r&&r,l=e.brandName,c=void 0===l?"WE0-CMS":l,u=Od(),h=Nd(),f=h.locale,d=h.setLocale,p=q(i("/data"),2),m=p[0],g=p[1],v=q(i([]),2);v[0],v[1];var y=q(i(!1),2),b=y[0],w=y[1],k=q(i(null),2),x=k[0],S=k[1],C=q(i(!0),2),E=C[0],M=C[1],O=s(function(){return dF({models:n.models})},[n.models]);a(function(){if(o)return w(!0),S(null),M(!1),void("/login"===m&&g("/data"));var e=function(){var e=A(j().m(function e(){var t,n;return j().w(function(e){for(;;)switch(e.p=e.n){case 0:if(e.p=0,vd()){e.n=1;break}return w(!1),g("/login"),M(!1),e.a(2);case 1:return e.p=1,e.n=2,pd();case 2:if(e.v.success){e.n=3;break}throw new Error("token验证失败");case 3:if(!(t=yd())){e.n=4;break}S(t),e.n=6;break;case 4:return e.n=5,md();case 5:(n=e.v).success&&n.data&&(S(n.data),localStorage.setItem("cms_user",JSON.stringify(n.data)));case 6:w(!0),"/login"===m&&g("/data"),e.n=8;break;case 7:e.p=7,e.v,gd(),w(!1),S(null),g("/login");case 8:e.n=10;break;case 9:e.p=9,e.v,w(!1),S(null),g("/login");case 10:return e.p=10,M(!1),e.f(10);case 11:return e.a(2)}},e,null,[[1,7],[0,9,10,11]])}));return function(){return e.apply(this,arguments)}}();e()},[o]);var N=function(e,t){S(t),w(!0),g("/data"),Lu.success("".concat(u("auth.welcome"),", ").concat(t.username,"!"))},T=function(e,t){var n,r=D(e);try{for(r.s();!(n=r.n()).done;){var i=n.value;if(i.path===t)return i;if(i.routes){var o=T(i.routes,t);if(o)return o}}}catch(e){r.e(e)}finally{r.f()}return null};if(E)return t.createElement("div",{className:"flex min-h-screen items-center justify-center bg-background"},t.createElement("div",{className:"space-y-4"},t.createElement(Ot,{className:"h-12 w-48"}),t.createElement(Ot,{className:"h-4 w-64"})));if(!b)return t.createElement(Td,{onLoginSuccess:N});var R=O.filter(function(e){return"/login"!==e.path}),P=function(e){if(!e)return de;if(t.isValidElement(e)){var n=e.type;if(n&&"function"==typeof n){var r=n.name||"";if(r.includes("Home"))return ge;if(r.includes("Table"))return Oe;if(r.includes("Database"))return de;if(r.includes("File"))return pe}}return de},L=R.flatMap(function(e){return e.routes&&e.routes.length>0?e.routes.map(function(e){return{title:e.name,icon:P(e.icon),path:e.path}}):[{title:e.name,icon:P(e.icon),path:e.path}]});return t.createElement("div",{className:"we0-cms-root"},t.createElement(Sa,null,t.createElement(Ca,{variant:"inset"},t.createElement(Ma,{className:"border-b border-sidebar-border p-4"},t.createElement("div",{className:"flex items-center gap-3"},t.createElement("div",{className:"flex items-center justify-center w-12 h-12 rounded-2xl bg-primary shadow-[0_4px_12px_-2px_rgba(93,112,82,0.2)] transition-all duration-300 hover:scale-105"},t.createElement(pF,{className:"w-5 h-5 text-primary-foreground"})),t.createElement("span",{className:"font-bold text-xl text-foreground"},c))),t.createElement(Na,null,t.createElement(Ta,null,t.createElement(Ra,null,"Navigation"),t.createElement(Da,null,t.createElement(Pa,null,L.map(function(e){return t.createElement(La,{key:e.path},t.createElement(Ia,{onClick:function(){return g(e.path)},isActive:(n=e.path,m===n||m.startsWith(n+"/")),tooltip:e.title},t.createElement(e.icon,{className:"w-4 h-4"}),t.createElement("span",null,e.title)));var n}))))),t.createElement(Oa,{className:"border-t border-sidebar-border"},t.createElement(Pa,null,t.createElement(La,null,t.createElement(tu,null,t.createElement(nu,{asChild:!0},t.createElement(Ia,{tooltip:u("settings.language")},t.createElement(vF,{className:"w-4 h-4"}),t.createElement("span",null,"zh-CN"===f?"中文":"English"))),t.createElement(ou,{align:"end",className:"w-48"},t.createElement(su,{onClick:function(){return d("zh-CN")},className:"zh-CN"===f?"bg-accent":""},"简体中文"),t.createElement(su,{onClick:function(){return d("en-US")},className:"en-US"===f?"bg-accent":""},"English")))),!o&&x&&t.createElement(t.Fragment,null,t.createElement(La,null,t.createElement(Ia,{tooltip:x.username||"User"},t.createElement(mF,{className:"w-4 h-4"}),t.createElement("span",{className:"truncate"},x.username))),t.createElement(La,null,t.createElement(Ia,{onClick:function(){window.confirm(u("auth.logoutConfirm"))&&(gd(),localStorage.removeItem("cms_token"),localStorage.removeItem("cms_user"),w(!1),S(null),g("/login"),Lu.success(u("auth.logoutSuccess")))},tooltip:u("auth.logout")},t.createElement(gF,{className:"w-4 h-4"}),t.createElement("span",null,u("auth.logout")))))))),t.createElement(Aa,null,t.createElement("header",{className:"flex h-16 items-center gap-4 border-b border-border/50 bg-background/80 backdrop-blur-sm px-6 sticky top-0 z-10"},t.createElement(Ea,null),t.createElement("h1",{className:"text-xl font-bold text-foreground"},function(){if("/login"===m)return u("auth.login");var e=T(O,m);return(null==e?void 0:e.name)||u("data.dataManagement")}())),t.createElement("main",{className:"flex-1 min-w-0 p-8 bg-gradient-to-br from-background via-background to-muted/20"},function(){if(!o&&"/login"===m)return t.createElement(Td,{onLoginSuccess:N});if(o&&"/login"===m)return t.createElement(aF,null);var e=T(O,m);if(e){var n=e.component;return t.createElement(n,null)}return t.createElement(aF,null)}()))))}function bF(e){var n=e.defaultLocale,r=Z(e,["defaultLocale"]);return t.createElement(Ad,{defaultLocale:n},t.createElement(yF,Object.assign({},r)))}export{bF as CmsLayoutShadcn,Ad as I18nProvider,dF as cmsRoutes,bF as default,cd as setSessionId,Nd as useLocale,Od as useT,Md as useTranslation};
17
11
  //# sourceMappingURL=index.esm.js.map