@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.js CHANGED
@@ -1,17 +1,11 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("react/jsx-runtime"),n=require("react-dom"),r=require("react-dom/client"),i=require("dayjs");function o(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e,Object.freeze(t)}var s=o(e),a=o(n);function l(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 c(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 u(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var o=e.apply(t,n);function s(e){c(o,r,i,s,a,"next",e)}function a(e){c(o,r,i,s,a,"throw",e)}s(void 0)})}}function h(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=b(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 d(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 f(){
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("react/jsx-runtime"),n=require("react-dom"),r=require("react-dom/client"),i=require("dayjs");function o(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e,Object.freeze(t)}var s=o(e),a=o(n);function l(e,t){this.v=e,this.k=t}function c(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 u(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 l(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 h(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 f(t.call(e));n="@@asyncIterator",r="@@iterator"}throw new TypeError("Object is not async iterable")}function f(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 f=function(e){this.s=e,this.n=e.next},f.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 f(e)}function d(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 p(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var o=e.apply(t,n);function s(e){d(o,r,i,s,a,"next",e)}function a(e){d(o,r,i,s,a,"throw",e)}s(void 0)})}}function m(e){return new l(e,0)}function g(e,t,n){return t=S(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,E()?Reflect.construct(t,n||[],S(e).constructor):t.apply(e,n))}function v(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function y(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,B(r.key),r)}}function b(e,t,n){return t&&y(e.prototype,t),n&&y(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function w(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 k(e,t,n){return(t=B(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function x(){return x="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=S(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}},x.apply(null,arguments)}function S(e){return S=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},S(e)}function C(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&&R(e,t)}function E(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(E=function(){return!!e})()}function A(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 M(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?A(Object(n),!0).forEach(function(t){k(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):A(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function O(){
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 p(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]())):(p(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,p(e,i,"GeneratorFunction")),e.prototype=Object.create(h),e}return l.prototype=c,p(h,"constructor",c),p(c,"constructor",l),l.displayName="GeneratorFunction",p(c,i,"GeneratorFunction"),p(h),p(h,i,"Generator"),p(h,r,function(){return this}),p(h,"toString",function(){return"[object Generator]"}),(f=function(){return{w:o,m:d}})()}function p(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}p=function(e,t,n,r){function o(t,n){p(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))},p(e,t,n,r)}function m(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)||b(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 g(e){return function(e){if(Array.isArray(e))return l(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||b(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 v(e){return v="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},v(e)}function b(e,t){if(e){if("string"==typeof e)return l(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)?l(e,t):void 0}}var y=function(){return y=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},y.apply(this,arguments)};function w(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 N(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]())):(N(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,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]"}),(O=function(){return{w:o,m:f}})()}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 T(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 R(e,t){return R=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},R(e,t)}function D(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 P(e,t,n,r){var i=x(S(1&r?e.prototype:e),t,n);return 2&r&&"function"==typeof i?function(e){return i.apply(n,e)}:i}function L(e){return function(e){if(Array.isArray(e))return c(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 B(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 I(e){return I="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},I(e)}function _(e,t){if(e){if("string"==typeof e)return c(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)?c(e,t):void 0}}function j(e){return function(){return new F(e.apply(this,arguments))}}function F(e){var t,n;function r(t,n){try{var o=e[t](n),s=o.value,a=s instanceof l;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)}F.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},F.prototype.next=function(e){return this._invoke("next",e)},F.prototype.throw=function(e){return this._invoke("throw",e)},F.prototype.return=function(e){return this._invoke("return",e)};var W=function(){return W=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},W.apply(this,arguments)};function H(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 x={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 k=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase().trim(),S=(t,n)=>{const r=e.forwardRef(({color:r="currentColor",size:i=24,strokeWidth:o=2,absoluteStrokeWidth:s,className:a="",children:l,...c},u)=>e.createElement("svg",{ref:u,...x,width:i,height:i,stroke:r,strokeWidth:s?24*Number(o)/Number(i):o,className:["lucide",`lucide-${k(t)}`,a].join(" "),...c},[...n.map(([t,n])=>e.createElement(t,n)),...Array.isArray(l)?l:[l]]));return r.displayName=`${t}`,r},E=S("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"}]]),C=S("CheckCircle2",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),N=S("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]),O=S("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]),A=S("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]),M=S("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]),T=S("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]),R=S("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]),D=S("Crown",[["path",{d:"m2 4 3 12h14l3-12-6 7-4-7-4 7-6-7zm3 16h14",key:"zkxr6b"}]]),P=S("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"}]]),L=S("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"}]]),I=S("Filter",[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]]),_=S("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"}]]),j=S("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]),B=S("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"}]]),F=S("Loader2",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]),W=S("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=S("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"}]]),H=S("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"}]]),V=S("PanelLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),q=S("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]),U=S("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]),$=S("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"}]]),K=S("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"}]]),Y=S("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"}]]),G=S("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"}]]),X=S("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"}]]),J=S("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"}]]),Q=S("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function Z(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=Z(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function ee(){for(var e,t,n=0,r="",i=arguments.length;n<i;n++)(e=arguments[n])&&(t=Z(e))&&(r&&(r+=" "),r+=t);return r}const te=e=>{const t=oe(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{const n=e.split("-");return""===n[0]&&1!==n.length&&n.shift(),ne(n,t)||ie(e)},getConflictingClassGroupIds:(e,t)=>{const i=n[e]||[];return t&&r[e]?[...i,...r[e]]:i}}},ne=(e,t)=>{if(0===e.length)return t.classGroupId;const n=e[0],r=t.nextPart.get(n),i=r?ne(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},re=/^\[(.+)\]$/,ie=e=>{if(re.test(e)){const t=re.exec(e)[1],n=t?.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},oe=e=>{const{theme:t,prefix:n}=e,r={nextPart:new Map,validators:[]};return ce(Object.entries(e.classGroups),n).forEach(([e,n])=>{se(n,r,e,t)}),r},se=(e,t,n,r)=>{e.forEach(e=>{if("string"==typeof e){return void((""===e?t:ae(t,e)).classGroupId=n)}if("function"==typeof e)return le(e)?void se(e(r),t,n,r):void t.validators.push({validator:e,classGroupId:n});Object.entries(e).forEach(([e,i])=>{se(i,ae(t,e),n,r)})})},ae=(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},le=e=>e.isThemeGetter,ce=(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,ue=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)}}},he=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},de=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},fe=/\s+/;function pe(){let e,t,n=0,r="";for(;n<arguments.length;)(e=arguments[n++])&&(t=me(e))&&(r&&(r+=" "),r+=t);return r}const me=e=>{if("string"==typeof e)return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=me(e[r]))&&(n&&(n+=" "),n+=t);return n};function ge(e,...t){let n,r,i,o=function(a){const l=t.reduce((e,t)=>t(e),e());return n=(e=>({cache:ue(e.cacheSize),parseClassName:he(e),...te(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(fe);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=de(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(pe.apply(null,arguments))}}const ve=e=>{const t=t=>t[e]||[];return t.isThemeGetter=!0,t},be=/^\[(?:([a-z-]+):)?(.+)\]$/i,ye=/^\d+\/\d+$/,we=new Set(["px","full","screen"]),xe=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,ke=/\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$/,Se=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,Ee=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Ce=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Ne=e=>Ae(e)||we.has(e)||ye.test(e),Oe=e=>ze(e,"length",He),Ae=e=>Boolean(e)&&!Number.isNaN(Number(e)),Me=e=>ze(e,"number",Ae),Te=e=>Boolean(e)&&Number.isInteger(Number(e)),Re=e=>e.endsWith("%")&&Ae(e.slice(0,-1)),De=e=>be.test(e),Pe=e=>xe.test(e),Le=new Set(["length","size","percentage"]),Ie=e=>ze(e,Le,Ve),_e=e=>ze(e,"position",Ve),je=new Set(["image","url"]),Be=e=>ze(e,je,Ue),Fe=e=>ze(e,"",qe),We=()=>!0,ze=(e,t,n)=>{const r=be.exec(e);return!!r&&(r[1]?"string"==typeof t?r[1]===t:t.has(r[1]):n(r[2]))},He=e=>ke.test(e)&&!Se.test(e),Ve=()=>!1,qe=e=>Ee.test(e),Ue=e=>Ce.test(e),$e=ge(()=>{const e=ve("colors"),t=ve("spacing"),n=ve("blur"),r=ve("brightness"),i=ve("borderColor"),o=ve("borderRadius"),s=ve("borderSpacing"),a=ve("borderWidth"),l=ve("contrast"),c=ve("grayscale"),u=ve("hueRotate"),h=ve("invert"),d=ve("gap"),f=ve("gradientColorStops"),p=ve("gradientColorStopPositions"),m=ve("inset"),g=ve("margin"),v=ve("opacity"),b=ve("padding"),y=ve("saturate"),w=ve("scale"),x=ve("sepia"),k=ve("skew"),S=ve("space"),E=ve("translate"),C=()=>["auto",De,t],N=()=>[De,t],O=()=>["",Ne,Oe],A=()=>["auto",Ae,De],M=()=>["","0",De],T=()=>[Ae,De];return{cacheSize:500,separator:":",theme:{colors:[We],spacing:[Ne,Oe],blur:["none","",Pe,De],brightness:T(),borderColor:[e],borderRadius:["none","","full",Pe,De],borderSpacing:N(),borderWidth:O(),contrast:T(),grayscale:M(),hueRotate:T(),invert:M(),gap:N(),gradientColorStops:[e],gradientColorStopPositions:[Re,Oe],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",De]}],container:["container"],columns:[{columns:[Pe]}],"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",De]}],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",Te,De]}],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",De]}],grow:[{grow:M()}],shrink:[{shrink:M()}],order:[{order:["first","last","none",Te,De]}],"grid-cols":[{"grid-cols":[We]}],"col-start-end":[{col:["auto",{span:["full",Te,De]},De]}],"col-start":[{"col-start":A()}],"col-end":[{"col-end":A()}],"grid-rows":[{"grid-rows":[We]}],"row-start-end":[{row:["auto",{span:[Te,De]},De]}],"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",De]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",De]}],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",De,t]}],"min-w":[{"min-w":[De,t,"min","max","fit"]}],"max-w":[{"max-w":[De,t,"none","full","min","max","fit","prose",{screen:[Pe]},Pe]}],h:[{h:[De,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[De,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[De,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[De,t,"auto","min","max","fit"]}],"font-size":[{text:["base",Pe,Oe]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Me]}],"font-family":[{font:[We]}],"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",De]}],"line-clamp":[{"line-clamp":["none",Ae,Me]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Ne,De]}],"list-image":[{"list-image":["none",De]}],"list-style-type":[{list:["none","disc","decimal",De]}],"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",Ne,Oe]}],"underline-offset":[{"underline-offset":["auto",Ne,De]}],"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",De]}],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",De]}],"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",_e]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",Ie]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},Be]}],"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":[Ne,De]}],"outline-w":[{outline:[Ne,Oe]}],"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":[Ne,Oe]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",Pe,Fe]}],"shadow-color":[{shadow:[We]}],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",Pe,De]}],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",De]}],duration:[{duration:T()}],ease:[{ease:["linear","in","out","in-out",De]}],delay:[{delay:T()}],animate:[{animate:["none","spin","ping","pulse","bounce",De]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[w]}],"scale-x":[{"scale-x":[w]}],"scale-y":[{"scale-y":[w]}],rotate:[{rotate:[Te,De]}],"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",De]}],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",De]}],"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",De]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[Ne,Oe,Me]}],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 Ke(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return $e(ee(t))}function Ye(e){var t=e.className,n=w(e,["className"]);return s.createElement("div",Object.assign({className:Ke("animate-pulse rounded-md bg-muted",t)},n))}function Ge(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function Xe(...e){return t=>{let n=!1;const r=e.map(e=>{const r=Ge(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():Ge(e[t],null)}}}}function Je(...e){return s.useCallback(Xe(...e),e)}var Qe=Symbol.for("react.lazy"),Ze=s[" use ".trim().toString()];function et(e){return null!=e&&"object"==typeof e&&"$$typeof"in e&&e.$$typeof===Qe&&"_payload"in e&&("object"==typeof(t=e._payload)&&null!==t&&"then"in t);var t}function tt(e){const n=rt(e),r=s.forwardRef((e,r)=>{let{children:i,...o}=e;et(i)&&"function"==typeof Ze&&(i=Ze(i._payload));const a=s.Children.toArray(i),l=a.find(ot);if(l){const e=l.props.children,i=a.map(t=>t===l?s.Children.count(e)>1?s.Children.only(null):s.isValidElement(e)?e.props.children:null:t);return t.jsx(n,{...o,ref:r,children:s.isValidElement(e)?s.cloneElement(e,void 0,i):null})}return t.jsx(n,{...o,ref:r,children:i})});return r.displayName=`${e}.Slot`,r}var nt=tt("Slot");function rt(e){const t=s.forwardRef((e,t)=>{let{children:n,...r}=e;if(et(n)&&"function"==typeof Ze&&(n=Ze(n._payload)),s.isValidElement(n)){const e=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}(n),i=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}}(r,n.props);return n.type!==s.Fragment&&(i.ref=t?Xe(t,e):e),s.cloneElement(n,i)}return s.Children.count(n)>1?s.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var it=Symbol("radix.slottable");function ot(e){return s.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===it}const st=e=>"boolean"==typeof e?`${e}`:0===e?"0":e,at=ee,lt=(e,t)=>n=>{var r;if(null==(null==t?void 0:t.variants))return at(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=st(t)||st(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 at(e,s,l,null==n?void 0:n.class,null==n?void 0:n.className)};var ct=lt("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"}}),ut=s.forwardRef(function(e,t){var n=e.className,r=e.variant,i=e.size,o=e.asChild,a=void 0!==o&&o,l=w(e,["className","variant","size","asChild"]),c=a?nt:"button";return s.createElement(c,Object.assign({className:Ke(ct({variant:r,size:i,className:n})),ref:t},l))});ut.displayName="Button";var ht=s.forwardRef(function(e,t){var n=e.className,r=e.type,i=w(e,["className","type"]);return s.createElement("input",Object.assign({type:r,className:Ke("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",n),ref:t},i))});ht.displayName="Input";var dt=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,n)=>{const r=tt(`Primitive.${n}`),i=s.forwardRef((e,i)=>{const{asChild:o,...s}=e,a=o?r:n;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),t.jsx(a,{...s,ref:i})});return i.displayName=`Primitive.${n}`,{...e,[n]:i}},{}),ft="horizontal",pt=["horizontal","vertical"],mt=s.forwardRef((e,n)=>{const{decorative:r,orientation:i=ft,...o}=e,s=function(e){return pt.includes(e)}(i)?i:ft,a=r?{role:"none"}:{"aria-orientation":"vertical"===s?s:void 0,role:"separator"};return t.jsx(dt.div,{"data-orientation":s,...a,...o,ref:n})});mt.displayName="Separator";var gt=mt,vt=s.forwardRef(function(e,t){var n=e.className,r=e.orientation,i=void 0===r?"horizontal":r,o=e.decorative,a=void 0===o||o,l=w(e,["className","orientation","decorative"]);return s.createElement(gt,Object.assign({ref:t,decorative:a,orientation:i,className:Ke("shrink-0 bg-border","horizontal"===i?"h-[1px] w-full":"h-full w-[1px]",n)},l))});function bt(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),!1===n||!r.defaultPrevented)return t?.(r)}}function yt(e,n=[]){let r=[];const i=()=>{const t=r.map(e=>s.createContext(e));return function(n){const r=n?.[e]||t;return s.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return i.scopeName=e,[function(n,i){const o=s.createContext(i),a=r.length;r=[...r,i];const l=n=>{const{scope:r,children:i,...l}=n,c=r?.[e]?.[a]||o,u=s.useMemo(()=>l,Object.values(l));return t.jsx(c.Provider,{value:u,children:i})};return l.displayName=n+"Provider",[l,function(t,r){const l=r?.[e]?.[a]||o,c=s.useContext(l);if(c)return c;if(void 0!==i)return i;throw new Error(`\`${t}\` must be used within \`${n}\``)}]},wt(i,...n)]}function wt(...e){const t=e[0];if(1===e.length)return t;const n=()=>{const n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){const r=n.reduce((t,{useScope:n,scopeName:r})=>({...t,...n(e)[`__scope${r}`]}),{});return s.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}vt.displayName=gt.displayName;var xt=globalThis?.document?s.useLayoutEffect:()=>{},kt=s[" useId ".trim().toString()]||(()=>{}),St=0;function Et(e){const[t,n]=s.useState(kt());return xt(()=>{e||n(e=>e??String(St++))},[e]),e||(t?`radix-${t}`:"")}var Ct=s[" useInsertionEffect ".trim().toString()]||xt;function Nt({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[i,o,a]=function({defaultProp:e,onChange:t}){const[n,r]=s.useState(e),i=s.useRef(n),o=s.useRef(t);return Ct(()=>{o.current=t},[t]),s.useEffect(()=>{i.current!==n&&(o.current?.(n),i.current=n)},[n,i]),[n,r,o]}({defaultProp:t,onChange:n}),l=void 0!==e,c=l?e:i;{const t=s.useRef(void 0!==e);s.useEffect(()=>{const e=t.current;if(e!==l){}t.current=l},[l,r])}const u=s.useCallback(t=>{if(l){const n=function(e){return"function"==typeof e}(t)?t(e):t;n!==e&&a.current?.(n)}else o(t)},[l,e,o,a]);return[c,u]}function Ot(e){const n=At(e),r=s.forwardRef((e,r)=>{const{children:i,...o}=e,a=s.Children.toArray(i),l=a.find(Tt);if(l){const e=l.props.children,i=a.map(t=>t===l?s.Children.count(e)>1?s.Children.only(null):s.isValidElement(e)?e.props.children:null:t);return t.jsx(n,{...o,ref:r,children:s.isValidElement(e)?s.cloneElement(e,void 0,i):null})}return t.jsx(n,{...o,ref:r,children:i})});return r.displayName=`${e}.Slot`,r}function At(e){const t=s.forwardRef((e,t)=>{const{children:n,...r}=e;if(s.isValidElement(n)){const e=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}(n),i=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}}(r,n.props);return n.type!==s.Fragment&&(i.ref=t?Xe(t,e):e),s.cloneElement(n,i)}return s.Children.count(n)>1?s.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Mt=Symbol("radix.slottable");function Tt(e){return s.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===Mt}var Rt=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,n)=>{const r=Ot(`Primitive.${n}`),i=s.forwardRef((e,i)=>{const{asChild:o,...s}=e,a=o?r:n;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),t.jsx(a,{...s,ref:i})});return i.displayName=`Primitive.${n}`,{...e,[n]:i}},{});function Dt(e){const t=s.useRef(e);return s.useEffect(()=>{t.current=e}),s.useMemo(()=>(...e)=>t.current?.(...e),[])}function Pt(e,t=globalThis?.document){const n=Dt(e);s.useEffect(()=>{const e=e=>{"Escape"===e.key&&n(e)};return t.addEventListener("keydown",e,{capture:!0}),()=>t.removeEventListener("keydown",e,{capture:!0})},[n,t])}var Lt,It="dismissableLayer.update",_t="dismissableLayer.pointerDownOutside",jt="dismissableLayer.focusOutside",Bt=s.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Ft=s.forwardRef((e,n)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:l,onDismiss:c,...u}=e,h=s.useContext(Bt),[d,f]=s.useState(null),p=d?.ownerDocument??globalThis?.document,[,m]=s.useState({}),g=Je(n,e=>f(e)),v=Array.from(h.layers),[b]=[...h.layersWithOutsidePointerEventsDisabled].slice(-1),y=v.indexOf(b),w=d?v.indexOf(d):-1,x=h.layersWithOutsidePointerEventsDisabled.size>0,k=w>=y,S=function(e,t=globalThis?.document){const n=Dt(e),r=s.useRef(!1),i=s.useRef(()=>{});return s.useEffect(()=>{const e=e=>{if(e.target&&!r.current){let r=function(){zt(_t,n,o,{discrete:!0})};const o={originalEvent:e};"touch"===e.pointerType?(t.removeEventListener("click",i.current),i.current=r,t.addEventListener("click",i.current,{once:!0})):r()}else t.removeEventListener("click",i.current);r.current=!1},o=window.setTimeout(()=>{t.addEventListener("pointerdown",e)},0);return()=>{window.clearTimeout(o),t.removeEventListener("pointerdown",e),t.removeEventListener("click",i.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}(e=>{const t=e.target,n=[...h.branches].some(e=>e.contains(t));k&&!n&&(o?.(e),l?.(e),e.defaultPrevented||c?.())},p),E=function(e,t=globalThis?.document){const n=Dt(e),r=s.useRef(!1);return s.useEffect(()=>{const e=e=>{if(e.target&&!r.current){zt(jt,n,{originalEvent:e},{discrete:!1})}};return t.addEventListener("focusin",e),()=>t.removeEventListener("focusin",e)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}(e=>{const t=e.target;[...h.branches].some(e=>e.contains(t))||(a?.(e),l?.(e),e.defaultPrevented||c?.())},p);return Pt(e=>{w===h.layers.size-1&&(i?.(e),!e.defaultPrevented&&c&&(e.preventDefault(),c()))},p),s.useEffect(()=>{if(d)return r&&(0===h.layersWithOutsidePointerEventsDisabled.size&&(Lt=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),h.layersWithOutsidePointerEventsDisabled.add(d)),h.layers.add(d),Wt(),()=>{r&&1===h.layersWithOutsidePointerEventsDisabled.size&&(p.body.style.pointerEvents=Lt)}},[d,p,r,h]),s.useEffect(()=>()=>{d&&(h.layers.delete(d),h.layersWithOutsidePointerEventsDisabled.delete(d),Wt())},[d,h]),s.useEffect(()=>{const e=()=>m({});return document.addEventListener(It,e),()=>document.removeEventListener(It,e)},[]),t.jsx(Rt.div,{...u,ref:g,style:{pointerEvents:x?k?"auto":"none":void 0,...e.style},onFocusCapture:bt(e.onFocusCapture,E.onFocusCapture),onBlurCapture:bt(e.onBlurCapture,E.onBlurCapture),onPointerDownCapture:bt(e.onPointerDownCapture,S.onPointerDownCapture)})});Ft.displayName="DismissableLayer";function Wt(){const e=new CustomEvent(It);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&&a.flushSync(()=>e.dispatchEvent(t))}(i,o):i.dispatchEvent(o)}s.forwardRef((e,n)=>{const r=s.useContext(Bt),i=s.useRef(null),o=Je(n,i);return s.useEffect(()=>{const e=i.current;if(e)return r.branches.add(e),()=>{r.branches.delete(e)}},[r.branches]),t.jsx(Rt.div,{...e,ref:o})}).displayName="DismissableLayerBranch";var Ht="focusScope.autoFocusOnMount",Vt="focusScope.autoFocusOnUnmount",qt={bubbles:!1,cancelable:!0},Ut=s.forwardRef((e,n)=>{const{loop:r=!1,trapped:i=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...l}=e,[c,u]=s.useState(null),h=Dt(o),d=Dt(a),f=s.useRef(null),p=Je(n,e=>u(e)),m=s.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;s.useEffect(()=>{if(i){let e=function(e){if(m.paused||!c)return;const t=e.target;c.contains(t)?f.current=t:Gt(f.current,{select:!0})},t=function(e){if(m.paused||!c)return;const t=e.relatedTarget;null!==t&&(c.contains(t)||Gt(f.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(const t of e)t.removedNodes.length>0&&Gt(c)};document.addEventListener("focusin",e),document.addEventListener("focusout",t);const r=new MutationObserver(n);return c&&r.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",e),document.removeEventListener("focusout",t),r.disconnect()}}},[i,c,m.paused]),s.useEffect(()=>{if(c){Xt.add(m);const t=document.activeElement;if(!c.contains(t)){const n=new CustomEvent(Ht,qt);c.addEventListener(Ht,h),c.dispatchEvent(n),n.defaultPrevented||(!function(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Gt(r,{select:t}),document.activeElement!==n)return}((e=$t(c),e.filter(e=>"A"!==e.tagName)),{select:!0}),document.activeElement===t&&Gt(c))}return()=>{c.removeEventListener(Ht,h),setTimeout(()=>{const e=new CustomEvent(Vt,qt);c.addEventListener(Vt,d),c.dispatchEvent(e),e.defaultPrevented||Gt(t??document.body,{select:!0}),c.removeEventListener(Vt,d),Xt.remove(m)},0)}}var e},[c,h,d,m]);const g=s.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=$t(e),n=Kt(t,e),r=Kt(t.reverse(),e);return[n,r]}(t);i&&o?e.shiftKey||n!==o?e.shiftKey&&n===i&&(e.preventDefault(),r&&Gt(o,{select:!0})):(e.preventDefault(),r&&Gt(i,{select:!0})):n===t&&e.preventDefault()}},[r,i,m.paused]);return t.jsx(Rt.div,{tabIndex:-1,...l,ref:p,onKeyDown:g})});function $t(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 Kt(e,t){for(const n of e)if(!Yt(n,{upTo:t}))return n}function Yt(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 Gt(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()}}Ut.displayName="FocusScope";var Xt=function(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=Jt(e,t),e.unshift(t)},remove(t){e=Jt(e,t),e[0]?.resume()}}}();function Jt(e,t){const n=[...e],r=n.indexOf(t);return-1!==r&&n.splice(r,1),n}var Qt=s.forwardRef((e,r)=>{const{container:i,...o}=e,[a,l]=s.useState(!1);xt(()=>l(!0),[]);const c=i||a&&globalThis?.document?.body;return c?n.createPortal(t.jsx(Rt.div,{...o,ref:r}),c):null});Qt.displayName="Portal";var Zt=e=>{const{present:t,children:n}=e,r=function(e){const[t,n]=s.useState(),r=s.useRef(null),i=s.useRef(e),o=s.useRef("none"),a=e?"mounted":"unmounted",[l,c]=function(e,t){return s.useReducer((e,n)=>t[e][n]??e,e)}(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return s.useEffect(()=>{const e=en(r.current);o.current="mounted"===l?e:"none"},[l]),xt(()=>{const t=r.current,n=i.current;if(n!==e){const r=o.current,s=en(t);if(e)c("MOUNT");else if("none"===s||"none"===t?.display)c("UNMOUNT");else{c(n&&r!==s?"ANIMATION_OUT":"UNMOUNT")}i.current=e}},[e,c]),xt(()=>{if(t){let e;const n=t.ownerDocument.defaultView??window,s=o=>{const s=en(r.current).includes(CSS.escape(o.animationName));if(o.target===t&&s&&(c("ANIMATION_END"),!i.current)){const r=t.style.animationFillMode;t.style.animationFillMode="forwards",e=n.setTimeout(()=>{"forwards"===t.style.animationFillMode&&(t.style.animationFillMode=r)})}},a=e=>{e.target===t&&(o.current=en(r.current))};return t.addEventListener("animationstart",a),t.addEventListener("animationcancel",s),t.addEventListener("animationend",s),()=>{n.clearTimeout(e),t.removeEventListener("animationstart",a),t.removeEventListener("animationcancel",s),t.removeEventListener("animationend",s)}}c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:s.useCallback(e=>{r.current=e?getComputedStyle(e):null,n(e)},[])}}(t),i="function"==typeof n?n({present:r.isPresent}):s.Children.only(n),o=Je(r.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}(i));return"function"==typeof n||r.isPresent?s.cloneElement(i,{ref:o}):null};function en(e){return e?.animationName||"none"}Zt.displayName="Presence";var tn=0;function nn(){s.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??rn()),document.body.insertAdjacentElement("beforeend",e[1]??rn()),tn++,()=>{1===tn&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),tn--}},[])}function rn(){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 on="right-scroll-bar-position",sn="width-before-scroll-bar";function an(e,t){return"function"==typeof e?e(t):e&&(e.current=t),e}var ln="undefined"!=typeof window?s.useLayoutEffect:s.useEffect,cn=new WeakMap;function un(t,n){var r,i,o,s=(r=n||null,i=function(e){return t.forEach(function(t){return an(t,e)})},(o=e.useState(function(){return{value:r,callback:i,facade:{get current(){return o.value},set current(e){var t=o.value;t!==e&&(o.value=e,o.callback(e,t))}}}})[0]).callback=i,o.facade);return ln(function(){var e=cn.get(s);if(e){var n=new Set(e),r=new Set(t),i=s.current;n.forEach(function(e){r.has(e)||an(e,null)}),r.forEach(function(e){n.has(e)||an(e,i)})}cn.set(s,t)},[t]),s}function hn(e){return e}var dn=function(e){var t=e.sideCar,n=w(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return s.createElement(r,y({},n))};dn.isSideCarExport=!0;var fn=function(e){void 0===e&&(e={});var t=function(e,t){void 0===t&&(t=hn);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=y({async:!0,ssr:!1},e),t}(),pn=function(){},mn=s.forwardRef(function(e,t){var n=s.useRef(null),r=s.useState({onScrollCapture:pn,onWheelCapture:pn,onTouchMoveCapture:pn}),i=r[0],o=r[1],a=e.forwardProps,l=e.children,c=e.className,u=e.removeScrollBar,h=e.enabled,d=e.shards,f=e.sideCar,p=e.noRelative,m=e.noIsolation,g=e.inert,v=e.allowPinchZoom,b=e.as,x=void 0===b?"div":b,k=e.gapMode,S=w(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),E=f,C=un([n,t]),N=y(y({},S),i);return s.createElement(s.Fragment,null,h&&s.createElement(E,{sideCar:fn,removeScrollBar:u,shards:d,noRelative:p,noIsolation:m,inert:g,setCallbacks:o,allowPinchZoom:!!v,lockRef:n,gapMode:k}),a?s.cloneElement(s.Children.only(l),y(y({},N),{ref:C})):s.createElement(x,y({},N,{className:c,ref:C}),l))});mn.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},mn.classNames={fullWidth:sn,zeroRight:on};function gn(){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 vn=function(){var e=0,t=null;return{add:function(n){var r,i;0==e&&(t=gn())&&(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)}}},bn=function(){var e,t=(e=vn(),function(t,n){s.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])});return function(e){var n=e.styles,r=e.dynamic;return t(n,r),null}},yn={left:0,top:0,right:0,gap:0},wn=function(e){return parseInt(e||"",10)||0},xn=function(e){if(void 0===e&&(e="margin"),"undefined"==typeof window)return yn;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[wn(n),wn(r),wn(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])}},kn=bn(),Sn="data-scroll-locked",En=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(Sn,"] {\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(on," {\n right: ").concat(a,"px ").concat(r,";\n }\n \n .").concat(sn," {\n margin-right: ").concat(a,"px ").concat(r,";\n }\n \n .").concat(on," .").concat(on," {\n right: 0 ").concat(r,";\n }\n \n .").concat(sn," .").concat(sn," {\n margin-right: 0 ").concat(r,";\n }\n \n body[").concat(Sn,"] {\n ").concat("--removed-body-scroll-bar-size",": ").concat(a,"px;\n }\n")},Cn=function(){var e=parseInt(document.body.getAttribute(Sn)||"0",10);return isFinite(e)?e:0},Nn=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=void 0===r?"margin":r;s.useEffect(function(){return document.body.setAttribute(Sn,(Cn()+1).toString()),function(){var e=Cn()-1;e<=0?document.body.removeAttribute(Sn):document.body.setAttribute(Sn,e.toString())}},[]);var o=s.useMemo(function(){return xn(i)},[i]);return s.createElement(kn,{styles:En(o,!t,i,n?"":"!important")})},On=!1;if("undefined"!=typeof window)try{var An=Object.defineProperty({},"passive",{get:function(){return On=!0,!0}});window.addEventListener("test",An,An),window.removeEventListener("test",An,An)}catch(e){On=!1}var Mn=!!On&&{passive:!1},Tn=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])},Rn=function(e,t){var n=t.ownerDocument,r=t;do{if("undefined"!=typeof ShadowRoot&&r instanceof ShadowRoot&&(r=r.host),Dn(e,r)){var i=Pn(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Dn=function(e,t){return"v"===e?function(e){return Tn(e,"overflowY")}(t):function(e){return Tn(e,"overflowX")}(t)},Pn=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)},Ln=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},In=function(e){return[e.deltaX,e.deltaY]},_n=function(e){return e&&"current"in e?e.current:e},jn=function(e){return"\n .block-interactivity-".concat(e," {pointer-events: none;}\n .allow-interactivity-").concat(e," {pointer-events: all;}\n")},Bn=0,Fn=[];function Wn(e){for(var t=null;null!==e;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var zn,Hn=(zn=function(e){var t=s.useRef([]),n=s.useRef([0,0]),r=s.useRef(),i=s.useState(Bn++)[0],o=s.useState(bn)[0],a=s.useRef(e);s.useEffect(function(){a.current=e},[e]),s.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(i));var t=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))}([e.lockRef.current],(e.shards||[]).map(_n),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),t.forEach(function(e){return e.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var l=s.useCallback(function(e,t){if("touches"in e&&2===e.touches.length||"wheel"===e.type&&e.ctrlKey)return!a.current.allowPinchZoom;var i,o=Ln(e),s=n.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=Rn(h,u);if(!p)return!0;if(p?i=h:(i="v"===h?"h":"v",p=Rn(h,u)),!p)return!1;if(!r.current&&"changedTouches"in e&&(l||c)&&(r.current=i),!i)return!0;var m=r.current||i;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=Pn(e,a),p=f[0],m=f[1]-f[2]-o*p;(p||m)&&Dn(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=s.useCallback(function(e){var n=e;if(Fn.length&&Fn[Fn.length-1]===o){var r="deltaY"in n?In(n):Ln(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&(t=e.delta,i=r,t[0]===i[0]&&t[1]===i[1]);var t,i})[0];if(i&&i.should)n.cancelable&&n.preventDefault();else if(!i){var s=(a.current.shards||[]).map(_n).filter(Boolean).filter(function(e){return e.contains(n.target)});(s.length>0?l(n,s[0]):!a.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),u=s.useCallback(function(e,n,r,i){var o={name:e,delta:n,target:r,should:i,shadowParent:Wn(r)};t.current.push(o),setTimeout(function(){t.current=t.current.filter(function(e){return e!==o})},1)},[]),h=s.useCallback(function(e){n.current=Ln(e),r.current=void 0},[]),d=s.useCallback(function(t){u(t.type,In(t),t.target,l(t,e.lockRef.current))},[]),f=s.useCallback(function(t){u(t.type,Ln(t),t.target,l(t,e.lockRef.current))},[]);s.useEffect(function(){return Fn.push(o),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener("wheel",c,Mn),document.addEventListener("touchmove",c,Mn),document.addEventListener("touchstart",h,Mn),function(){Fn=Fn.filter(function(e){return e!==o}),document.removeEventListener("wheel",c,Mn),document.removeEventListener("touchmove",c,Mn),document.removeEventListener("touchstart",h,Mn)}},[]);var p=e.removeScrollBar,m=e.inert;return s.createElement(s.Fragment,null,m?s.createElement(o,{styles:jn(i)}):null,p?s.createElement(Nn,{noRelative:e.noRelative,gapMode:e.gapMode}):null)},fn.useMedium(zn),dn),Vn=s.forwardRef(function(e,t){return s.createElement(mn,y({},e,{ref:t,sideCar:Hn}))});Vn.classNames=mn.classNames;var qn=Vn,Un=new WeakMap,$n=new WeakMap,Kn={},Yn=0,Gn=function(e){return e&&(e.host||Gn(e.parentNode))},Xn=function(e,t,n,r){var i=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=Gn(t);return n&&e.contains(n)?n:null}).filter(function(e){return Boolean(e)})}(t,Array.isArray(e)?e:[e]);Kn[n]||(Kn[n]=new WeakMap);var o=Kn[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=(Un.get(e)||0)+1,c=(o.get(e)||0)+1;Un.set(e,l),o.set(e,c),s.push(e),1===l&&i&&$n.set(e,!0),1===c&&e.setAttribute(n,"true"),i||e.setAttribute(r,"true")}catch(e){}})};return u(t),a.clear(),Yn++,function(){s.forEach(function(e){var t=Un.get(e)-1,i=o.get(e)-1;Un.set(e,t),o.set(e,i),t||($n.has(e)||e.removeAttribute(r),$n.delete(e)),i||e.removeAttribute(n)}),--Yn||(Un=new WeakMap,Un=new WeakMap,$n=new WeakMap,Kn={})}},Jn=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"))),Xn(r,i,n,"aria-hidden")):function(){return null}},Qn="Dialog",[Zn,er]=yt(Qn),[tr,nr]=Zn(Qn),rr=e=>{const{__scopeDialog:n,children:r,open:i,defaultOpen:o,onOpenChange:a,modal:l=!0}=e,c=s.useRef(null),u=s.useRef(null),[h,d]=Nt({prop:i,defaultProp:o??!1,onChange:a,caller:Qn});return t.jsx(tr,{scope:n,triggerRef:c,contentRef:u,contentId:Et(),titleId:Et(),descriptionId:Et(),open:h,onOpenChange:d,onOpenToggle:s.useCallback(()=>d(e=>!e),[d]),modal:l,children:r})};rr.displayName=Qn;var ir="DialogTrigger",or=s.forwardRef((e,n)=>{const{__scopeDialog:r,...i}=e,o=nr(ir,r),s=Je(n,o.triggerRef);return t.jsx(Rt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Cr(o.open),...i,ref:s,onClick:bt(e.onClick,o.onOpenToggle)})});or.displayName=ir;var sr="DialogPortal",[ar,lr]=Zn(sr,{forceMount:void 0}),cr=e=>{const{__scopeDialog:n,forceMount:r,children:i,container:o}=e,a=nr(sr,n);return t.jsx(ar,{scope:n,forceMount:r,children:s.Children.map(i,e=>t.jsx(Zt,{present:r||a.open,children:t.jsx(Qt,{asChild:!0,container:o,children:e})}))})};cr.displayName=sr;var ur="DialogOverlay",hr=s.forwardRef((e,n)=>{const r=lr(ur,e.__scopeDialog),{forceMount:i=r.forceMount,...o}=e,s=nr(ur,e.__scopeDialog);return s.modal?t.jsx(Zt,{present:i||s.open,children:t.jsx(fr,{...o,ref:n})}):null});hr.displayName=ur;var dr=Ot("DialogOverlay.RemoveScroll"),fr=s.forwardRef((e,n)=>{const{__scopeDialog:r,...i}=e,o=nr(ur,r);return t.jsx(qn,{as:dr,allowPinchZoom:!0,shards:[o.contentRef],children:t.jsx(Rt.div,{"data-state":Cr(o.open),...i,ref:n,style:{pointerEvents:"auto",...i.style}})})}),pr="DialogContent",mr=s.forwardRef((e,n)=>{const r=lr(pr,e.__scopeDialog),{forceMount:i=r.forceMount,...o}=e,s=nr(pr,e.__scopeDialog);return t.jsx(Zt,{present:i||s.open,children:s.modal?t.jsx(gr,{...o,ref:n}):t.jsx(vr,{...o,ref:n})})});mr.displayName=pr;var gr=s.forwardRef((e,n)=>{const r=nr(pr,e.__scopeDialog),i=s.useRef(null),o=Je(n,r.contentRef,i);return s.useEffect(()=>{const e=i.current;if(e)return Jn(e)},[]),t.jsx(br,{...e,ref:o,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:bt(e.onCloseAutoFocus,e=>{e.preventDefault(),r.triggerRef.current?.focus()}),onPointerDownOutside:bt(e.onPointerDownOutside,e=>{const t=e.detail.originalEvent,n=0===t.button&&!0===t.ctrlKey;(2===t.button||n)&&e.preventDefault()}),onFocusOutside:bt(e.onFocusOutside,e=>e.preventDefault())})}),vr=s.forwardRef((e,n)=>{const r=nr(pr,e.__scopeDialog),i=s.useRef(!1),o=s.useRef(!1);return t.jsx(br,{...e,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(i.current||r.triggerRef.current?.focus(),t.preventDefault()),i.current=!1,o.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(i.current=!0,"pointerdown"===t.detail.originalEvent.type&&(o.current=!0));const n=t.target,s=r.triggerRef.current?.contains(n);s&&t.preventDefault(),"focusin"===t.detail.originalEvent.type&&o.current&&t.preventDefault()}})}),br=s.forwardRef((e,n)=>{const{__scopeDialog:r,trapFocus:i,onOpenAutoFocus:o,onCloseAutoFocus:a,...l}=e,c=nr(pr,r),u=s.useRef(null),h=Je(n,u);return nn(),t.jsxs(t.Fragment,{children:[t.jsx(Ut,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:o,onUnmountAutoFocus:a,children:t.jsx(Ft,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":Cr(c.open),...l,ref:h,onDismiss:()=>c.onOpenChange(!1)})}),t.jsxs(t.Fragment,{children:[t.jsx(Mr,{titleId:c.titleId}),t.jsx(Tr,{contentRef:u,descriptionId:c.descriptionId})]})]})}),yr="DialogTitle",wr=s.forwardRef((e,n)=>{const{__scopeDialog:r,...i}=e,o=nr(yr,r);return t.jsx(Rt.h2,{id:o.titleId,...i,ref:n})});wr.displayName=yr;var xr="DialogDescription",kr=s.forwardRef((e,n)=>{const{__scopeDialog:r,...i}=e,o=nr(xr,r);return t.jsx(Rt.p,{id:o.descriptionId,...i,ref:n})});kr.displayName=xr;var Sr="DialogClose",Er=s.forwardRef((e,n)=>{const{__scopeDialog:r,...i}=e,o=nr(Sr,r);return t.jsx(Rt.button,{type:"button",...i,ref:n,onClick:bt(e.onClick,()=>o.onOpenChange(!1))})});function Cr(e){return e?"open":"closed"}Er.displayName=Sr;var Nr="DialogTitleWarning",[Or,Ar]=function(e,n){const r=s.createContext(n),i=e=>{const{children:n,...i}=e,o=s.useMemo(()=>i,Object.values(i));return t.jsx(r.Provider,{value:o,children:n})};return i.displayName=e+"Provider",[i,function(t){const i=s.useContext(r);if(i)return i;if(void 0!==n)return n;throw new Error(`\`${t}\` must be used within \`${e}\``)}]}(Nr,{contentName:pr,titleName:yr,docsSlug:"dialog"}),Mr=({titleId:e})=>{const t=Ar(Nr),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.\n\nIf you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.\n\nFor more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return s.useEffect(()=>{if(e){document.getElementById(e)}},[n,e]),null},Tr=({contentRef:e,descriptionId:t})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Ar("DialogDescriptionWarning").contentName}}.`;return s.useEffect(()=>{const n=e.current?.getAttribute("aria-describedby");if(t&&n){document.getElementById(t)}},[n,e,t]),null},Rr=rr,Dr=or,Pr=cr,Lr=hr,Ir=mr,_r=wr,jr=kr,Br=Er,Fr=Rr,Wr=Pr,zr=s.forwardRef(function(e,t){var n=e.className,r=w(e,["className"]);return s.createElement(Lr,Object.assign({className:Ke("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",n)},r,{ref:t}))});zr.displayName=Lr.displayName;var Hr=lt("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"}}),Vr=s.forwardRef(function(e,t){var n=e.side,r=void 0===n?"right":n,i=e.className,o=e.children,a=w(e,["side","className","children"]);return s.createElement(Wr,null,s.createElement(zr,null),s.createElement(Ir,Object.assign({ref:t,className:Ke(Hr({side:r}),i)},a),o,s.createElement(Br,{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"},s.createElement(Q,{className:"h-4 w-4"}),s.createElement("span",{className:"sr-only"},"Close"))))});Vr.displayName=Ir.displayName;var qr=function(e){var t=e.className,n=w(e,["className"]);return s.createElement("div",Object.assign({className:Ke("flex flex-col space-y-2 text-center sm:text-left",t)},n))};qr.displayName="SheetHeader";var Ur=s.forwardRef(function(e,t){var n=e.className,r=w(e,["className"]);return s.createElement(_r,Object.assign({ref:t,className:Ke("text-lg font-semibold text-foreground",n)},r))});Ur.displayName=_r.displayName;var $r=s.forwardRef(function(e,t){var n=e.className,r=w(e,["className"]);return s.createElement(jr,Object.assign({ref:t,className:Ke("text-sm text-muted-foreground",n)},r))});function Kr(e){const t=s.forwardRef((e,t)=>{const{children:n,...r}=e;if(s.isValidElement(n)){const e=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}(n),i=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}}(r,n.props);return n.type!==s.Fragment&&(i.ref=t?Xe(t,e):e),s.cloneElement(n,i)}return s.Children.count(n)>1?s.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}$r.displayName=jr.displayName;var Yr=Symbol("radix.slottable");function Gr(e){return s.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===Yr}var Xr=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,n)=>{const r=function(e){const n=Kr(e),r=s.forwardRef((e,r)=>{const{children:i,...o}=e,a=s.Children.toArray(i),l=a.find(Gr);if(l){const e=l.props.children,i=a.map(t=>t===l?s.Children.count(e)>1?s.Children.only(null):s.isValidElement(e)?e.props.children:null:t);return t.jsx(n,{...o,ref:r,children:s.isValidElement(e)?s.cloneElement(e,void 0,i):null})}return t.jsx(n,{...o,ref:r,children:i})});return r.displayName=`${e}.Slot`,r}(`Primitive.${n}`),i=s.forwardRef((e,i)=>{const{asChild:o,...s}=e,a=o?r:n;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),t.jsx(a,{...s,ref:i})});return i.displayName=`Primitive.${n}`,{...e,[n]:i}},{});var Jr,Qr="dismissableLayer.update",Zr="dismissableLayer.pointerDownOutside",ei="dismissableLayer.focusOutside",ti=s.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),ni=s.forwardRef((e,n)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:l,onDismiss:c,...u}=e,h=s.useContext(ti),[d,f]=s.useState(null),p=d?.ownerDocument??globalThis?.document,[,m]=s.useState({}),g=Je(n,e=>f(e)),v=Array.from(h.layers),[b]=[...h.layersWithOutsidePointerEventsDisabled].slice(-1),y=v.indexOf(b),w=d?v.indexOf(d):-1,x=h.layersWithOutsidePointerEventsDisabled.size>0,k=w>=y,S=function(e,t=globalThis?.document){const n=Dt(e),r=s.useRef(!1),i=s.useRef(()=>{});return s.useEffect(()=>{const e=e=>{if(e.target&&!r.current){let r=function(){ii(Zr,n,o,{discrete:!0})};const o={originalEvent:e};"touch"===e.pointerType?(t.removeEventListener("click",i.current),i.current=r,t.addEventListener("click",i.current,{once:!0})):r()}else t.removeEventListener("click",i.current);r.current=!1},o=window.setTimeout(()=>{t.addEventListener("pointerdown",e)},0);return()=>{window.clearTimeout(o),t.removeEventListener("pointerdown",e),t.removeEventListener("click",i.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}(e=>{const t=e.target,n=[...h.branches].some(e=>e.contains(t));k&&!n&&(o?.(e),l?.(e),e.defaultPrevented||c?.())},p),E=function(e,t=globalThis?.document){const n=Dt(e),r=s.useRef(!1);return s.useEffect(()=>{const e=e=>{if(e.target&&!r.current){ii(ei,n,{originalEvent:e},{discrete:!1})}};return t.addEventListener("focusin",e),()=>t.removeEventListener("focusin",e)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}(e=>{const t=e.target;[...h.branches].some(e=>e.contains(t))||(a?.(e),l?.(e),e.defaultPrevented||c?.())},p);return Pt(e=>{w===h.layers.size-1&&(i?.(e),!e.defaultPrevented&&c&&(e.preventDefault(),c()))},p),s.useEffect(()=>{if(d)return r&&(0===h.layersWithOutsidePointerEventsDisabled.size&&(Jr=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),h.layersWithOutsidePointerEventsDisabled.add(d)),h.layers.add(d),ri(),()=>{r&&1===h.layersWithOutsidePointerEventsDisabled.size&&(p.body.style.pointerEvents=Jr)}},[d,p,r,h]),s.useEffect(()=>()=>{d&&(h.layers.delete(d),h.layersWithOutsidePointerEventsDisabled.delete(d),ri())},[d,h]),s.useEffect(()=>{const e=()=>m({});return document.addEventListener(Qr,e),()=>document.removeEventListener(Qr,e)},[]),t.jsx(Xr.div,{...u,ref:g,style:{pointerEvents:x?k?"auto":"none":void 0,...e.style},onFocusCapture:bt(e.onFocusCapture,E.onFocusCapture),onBlurCapture:bt(e.onBlurCapture,E.onBlurCapture),onPointerDownCapture:bt(e.onPointerDownCapture,S.onPointerDownCapture)})});ni.displayName="DismissableLayer";function ri(){const e=new CustomEvent(Qr);document.dispatchEvent(e)}function ii(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&&a.flushSync(()=>e.dispatchEvent(t))}(i,o):i.dispatchEvent(o)}s.forwardRef((e,n)=>{const r=s.useContext(ti),i=s.useRef(null),o=Je(n,i);return s.useEffect(()=>{const e=i.current;if(e)return r.branches.add(e),()=>{r.branches.delete(e)}},[r.branches]),t.jsx(Xr.div,{...e,ref:o})}).displayName="DismissableLayerBranch";const oi=["top","right","bottom","left"],si=Math.min,ai=Math.max,li=Math.round,ci=Math.floor,ui=e=>({x:e,y:e}),hi={left:"right",right:"left",bottom:"top",top:"bottom"},di={start:"end",end:"start"};function fi(e,t,n){return ai(e,si(t,n))}function pi(e,t){return"function"==typeof e?e(t):e}function mi(e){return e.split("-")[0]}function gi(e){return e.split("-")[1]}function vi(e){return"x"===e?"y":"x"}function bi(e){return"y"===e?"height":"width"}const yi=new Set(["top","bottom"]);function wi(e){return yi.has(mi(e))?"y":"x"}function xi(e){return vi(wi(e))}function ki(e){return e.replace(/start|end/g,e=>di[e])}const Si=["left","right"],Ei=["right","left"],Ci=["top","bottom"],Ni=["bottom","top"];function Oi(e,t,n,r){const i=gi(e);let o=function(e,t,n){switch(e){case"top":case"bottom":return n?t?Ei:Si:t?Si:Ei;case"left":case"right":return t?Ci:Ni;default:return[]}}(mi(e),"start"===n,r);return i&&(o=o.map(e=>e+"-"+i),t&&(o=o.concat(o.map(ki)))),o}function Ai(e){return e.replace(/left|right|bottom|top/g,e=>hi[e])}function Mi(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 Ti(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 Ri(e,t,n){let{reference:r,floating:i}=e;const o=wi(t),s=xi(t),a=bi(s),l=mi(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(gi(t)){case"start":f[s]-=d*(n&&c?-1:1);break;case"end":f[s]+=d*(n&&c?-1:1)}return f}async function Di(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}=pi(t,e),p=Mi(f),m=a[d?"floating"===h?"reference":"floating":h],g=Ti(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=Ti(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 Pi(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Li(e){return oi.some(t=>e[t]>=0)}const Ii=new Set(["left","top"]);function _i(){return"undefined"!=typeof window}function ji(e){return Wi(e)?(e.nodeName||"").toLowerCase():"#document"}function Bi(e){var t;return(null==e||null==(t=e.ownerDocument)?void 0:t.defaultView)||window}function Fi(e){var t;return null==(t=(Wi(e)?e.ownerDocument:e.document)||window.document)?void 0:t.documentElement}function Wi(e){return!!_i()&&(e instanceof Node||e instanceof Bi(e).Node)}function zi(e){return!!_i()&&(e instanceof Element||e instanceof Bi(e).Element)}function Hi(e){return!!_i()&&(e instanceof HTMLElement||e instanceof Bi(e).HTMLElement)}function Vi(e){return!(!_i()||"undefined"==typeof ShadowRoot)&&(e instanceof ShadowRoot||e instanceof Bi(e).ShadowRoot)}const qi=new Set(["inline","contents"]);function Ui(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=ro(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!qi.has(i)}const $i=new Set(["table","td","th"]);function Ki(e){return $i.has(ji(e))}const Yi=[":popover-open",":modal"];function Gi(e){return Yi.some(t=>{try{return e.matches(t)}catch(e){return!1}})}const Xi=["transform","translate","scale","rotate","perspective"],Ji=["transform","translate","scale","rotate","perspective","filter"],Qi=["paint","layout","strict","content"];function Zi(e){const t=eo(),n=zi(e)?ro(e):e;return Xi.some(e=>!!n[e]&&"none"!==n[e])||!!n.containerType&&"normal"!==n.containerType||!t&&!!n.backdropFilter&&"none"!==n.backdropFilter||!t&&!!n.filter&&"none"!==n.filter||Ji.some(e=>(n.willChange||"").includes(e))||Qi.some(e=>(n.contain||"").includes(e))}function eo(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}const to=new Set(["html","body","#document"]);function no(e){return to.has(ji(e))}function ro(e){return Bi(e).getComputedStyle(e)}function io(e){return zi(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function oo(e){if("html"===ji(e))return e;const t=e.assignedSlot||e.parentNode||Vi(e)&&e.host||Fi(e);return Vi(t)?t.host:t}function so(e){const t=oo(e);return no(t)?e.ownerDocument?e.ownerDocument.body:e.body:Hi(t)&&Ui(t)?t:so(t)}function ao(e,t,n){var r;void 0===t&&(t=[]),void 0===n&&(n=!0);const i=so(e),o=i===(null==(r=e.ownerDocument)?void 0:r.body),s=Bi(i);if(o){const e=lo(s);return t.concat(s,s.visualViewport||[],Ui(i)?i:[],e&&n?ao(e):[])}return t.concat(i,ao(i,[],n))}function lo(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function co(e){const t=ro(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=Hi(e),o=i?e.offsetWidth:n,s=i?e.offsetHeight:r,a=li(n)!==o||li(r)!==s;return a&&(n=o,r=s),{width:n,height:r,$:a}}function uo(e){return zi(e)?e:e.contextElement}function ho(e){const t=uo(e);if(!Hi(t))return ui(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:o}=co(t);let s=(o?li(n.width):n.width)/r,a=(o?li(n.height):n.height)/i;return s&&Number.isFinite(s)||(s=1),a&&Number.isFinite(a)||(a=1),{x:s,y:a}}const fo=ui(0);function po(e){const t=Bi(e);return eo()&&t.visualViewport?{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}:fo}function mo(e,t,n,r){void 0===t&&(t=!1),void 0===n&&(n=!1);const i=e.getBoundingClientRect(),o=uo(e);let s=ui(1);t&&(r?zi(r)&&(s=ho(r)):s=ho(e));const a=function(e,t,n){return void 0===t&&(t=!1),!(!n||t&&n!==Bi(e))&&t}(o,n,r)?po(o):ui(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=Bi(o),t=r&&zi(r)?Bi(r):r;let n=e,i=lo(n);for(;i&&r&&t!==n;){const e=ho(i),t=i.getBoundingClientRect(),r=ro(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=Bi(i),i=lo(n)}}return Ti({width:u,height:h,x:l,y:c})}function go(e,t){const n=io(e).scrollLeft;return t?t.left+n:mo(Fi(e)).left+n}function vo(e,t){const n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-go(e,n),y:n.top+t.scrollTop}}const bo=new Set(["absolute","fixed"]);function yo(e,t,n){let r;if("viewport"===t)r=function(e,t){const n=Bi(e),r=Fi(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=eo();(!e||e&&"fixed"===t)&&(a=i.offsetLeft,l=i.offsetTop)}const c=go(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=Fi(e),n=io(e),r=e.ownerDocument.body,i=ai(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),o=ai(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let s=-n.scrollLeft+go(e);const a=-n.scrollTop;return"rtl"===ro(r).direction&&(s+=ai(t.clientWidth,r.clientWidth)-i),{width:i,height:o,x:s,y:a}}(Fi(e));else if(zi(t))r=function(e,t){const n=mo(e,!0,"fixed"===t),r=n.top+e.clientTop,i=n.left+e.clientLeft,o=Hi(e)?ho(e):ui(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=po(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return Ti(r)}function wo(e,t){const n=oo(e);return!(n===t||!zi(n)||no(n))&&("fixed"===ro(n).position||wo(n,t))}function xo(e,t,n){const r=Hi(t),i=Fi(t),o="fixed"===n,s=mo(e,!0,o,t);let a={scrollLeft:0,scrollTop:0};const l=ui(0);function c(){l.x=go(i)}if(r||!r&&!o)if(("body"!==ji(t)||Ui(i))&&(a=io(t)),r){const e=mo(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?ui(0):vo(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 ko(e){return"static"===ro(e).position}function So(e,t){if(!Hi(e)||"fixed"===ro(e).position)return null;if(t)return t(e);let n=e.offsetParent;return Fi(e)===n&&(n=n.ownerDocument.body),n}function Eo(e,t){const n=Bi(e);if(Gi(e))return n;if(!Hi(e)){let t=oo(e);for(;t&&!no(t);){if(zi(t)&&!ko(t))return t;t=oo(t)}return n}let r=So(e,t);for(;r&&Ki(r)&&ko(r);)r=So(r,t);return r&&no(r)&&ko(r)&&!Zi(r)?n:r||function(e){let t=oo(e);for(;Hi(t)&&!no(t);){if(Zi(t))return t;if(Gi(t))return null;t=oo(t)}return null}(e)||n}const Co={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const o="fixed"===i,s=Fi(r),a=!!t&&Gi(t.floating);if(r===s||a&&o)return n;let l={scrollLeft:0,scrollTop:0},c=ui(1);const u=ui(0),h=Hi(r);if((h||!h&&!o)&&(("body"!==ji(r)||Ui(s))&&(l=io(r)),Hi(r))){const e=mo(r);c=ho(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}const d=!s||h||o?ui(0):vo(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:Fi,getClippingRect:function(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const o=[..."clippingAncestors"===n?Gi(t)?[]:function(e,t){const n=t.get(e);if(n)return n;let r=ao(e,[],!1).filter(e=>zi(e)&&"body"!==ji(e)),i=null;const o="fixed"===ro(e).position;let s=o?oo(e):e;for(;zi(s)&&!no(s);){const t=ro(s),n=Zi(s);n||"fixed"!==t.position||(i=null),(o?!n&&!i:!n&&"static"===t.position&&i&&bo.has(i.position)||Ui(s)&&!n&&wo(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=yo(t,n,i);return e.top=ai(r.top,e.top),e.right=si(r.right,e.right),e.bottom=si(r.bottom,e.bottom),e.left=ai(r.left,e.left),e},yo(t,s,i));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}},getOffsetParent:Eo,getElementRects:async function(e){const t=this.getOffsetParent||Eo,n=this.getDimensions,r=await n(e.floating);return{reference:xo(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}=co(e);return{width:t,height:n}},getScale:ho,isElement:zi,isRTL:function(e){return"rtl"===ro(e).direction}};function No(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Oo(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=uo(e),u=i||o?[...c?ao(c):[],...ao(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=Fi(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:-ci(h)+"px "+-ci(i.clientWidth-(u+d))+"px "+-ci(i.clientHeight-(h+f))+"px "+-ci(u)+"px",threshold:ai(0,si(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||No(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?mo(e):null;return l&&function t(){const r=mo(e);m&&!No(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 Ao=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=mi(n),a=gi(n),l="y"===wi(n),c=Ii.has(s)?-1:1,u=o&&l?-1:1,h=pi(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}}}}},Mo=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}=pi(e,t),c={x:n,y:r},u=await Di(t,l),h=wi(mi(i)),d=vi(h);let f=c[d],p=c[h];if(o){const e="y"===d?"bottom":"right";f=fi(f+u["y"===d?"top":"left"],f,f-u[e])}if(s){const e="y"===h?"bottom":"right";p=fi(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}}}}}},To=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}=pi(e,t);if(null!=(n=o.arrow)&&n.alignmentOffset)return{};const v=mi(i),b=wi(a),y=mi(a)===a,w=await(null==l.isRTL?void 0:l.isRTL(c.floating)),x=d||(y||!m?[Ai(a)]:function(e){const t=Ai(e);return[ki(e),t,ki(t)]}(a)),k="none"!==p;!d&&k&&x.push(...Oi(a,m,p,w));const S=[a,...x],E=await Di(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=gi(e),i=xi(e),o=bi(i);let s="x"===i?r===(n?"end":"start")?"right":"left":"start"===r?"bottom":"top";return t.reference[o]>t.floating[o]&&(s=Ai(s)),[s,Ai(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!==wi(t))||N.every(e=>wi(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=wi(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{}}}},Ro=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}=pi(e,t),u=await Di(t,c),h=mi(i),d=gi(i),f="y"===wi(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=si(m-u[g],b),x=si(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=ai(u.left,0),t=ai(u.right,0),n=ai(u.top,0),r=ai(u.bottom,0);f?E=p-2*(0!==e||0!==t?e+t:ai(u.left,u.right)):S=m-2*(0!==n||0!==r?n+r:ai(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}}:{}}}},Do=function(e){return void 0===e&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...i}=pi(e,t);switch(r){case"referenceHidden":{const e=Pi(await Di(t,{...i,elementContext:"reference"}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:Li(e)}}}case"escaped":{const e=Pi(await Di(t,{...i,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:Li(e)}}}default:return{}}}}},Po=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}=pi(e,t)||{};if(null==c)return{};const h=Mi(u),d={x:n,y:r},f=xi(i),p=bi(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=si(h[v],C),O=si(h[b],C),A=N,M=S-m[p]-O,T=S/2-m[p]/2+E,R=fi(A,T,M),D=!l.arrow&&null!=gi(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}}}),Lo=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}=pi(e,t),u={x:n,y:r},h=wi(i),d=vi(h);let f=u[d],p=u[h];const m=pi(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=Ii.has(mi(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}}}},Io=(e,t,n)=>{const r=new Map,i={platform:Co,...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}=Ri(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}=Ri(c,d,l))),n=-1)}return{x:u,y:h,placement:d,strategy:i,middlewareData:f}})(e,t,{...i,platform:o})};var _o="undefined"!=typeof document?e.useLayoutEffect:function(){};function jo(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(!jo(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)&&!jo(e[n],t[n]))return!1}return!0}return e!=e&&t!=t}function Bo(e){if("undefined"==typeof window)return 1;return(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Fo(e,t){const n=Bo(e);return Math.round(t*n)/n}function Wo(e){const t=s.useRef(e);return _o(()=>{t.current=e}),t}function zo(e){void 0===e&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:o,floating:l}={},transform:c=!0,whileElementsMounted:u,open:h}=e,[d,f]=s.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,m]=s.useState(r);jo(p,r)||m(r);const[g,v]=s.useState(null),[b,y]=s.useState(null),w=s.useCallback(e=>{e!==E.current&&(E.current=e,v(e))},[]),x=s.useCallback(e=>{e!==C.current&&(C.current=e,y(e))},[]),k=o||g,S=l||b,E=s.useRef(null),C=s.useRef(null),N=s.useRef(d),O=null!=u,A=Wo(u),M=Wo(i),T=Wo(h),R=s.useCallback(()=>{if(!E.current||!C.current)return;const e={placement:t,strategy:n,middleware:p};M.current&&(e.platform=M.current),Io(E.current,C.current,e).then(e=>{const t={...e,isPositioned:!1!==T.current};D.current&&!jo(N.current,t)&&(N.current=t,a.flushSync(()=>{f(t)}))})},[p,t,n,M,T]);_o(()=>{!1===h&&N.current.isPositioned&&(N.current.isPositioned=!1,f(e=>({...e,isPositioned:!1})))},[h]);const D=s.useRef(!1);_o(()=>(D.current=!0,()=>{D.current=!1}),[]),_o(()=>{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=s.useMemo(()=>({reference:E,floating:C,setReference:w,setFloating:x}),[w,x]),L=s.useMemo(()=>({reference:k,floating:S}),[k,S]),I=s.useMemo(()=>{const e={position:n,left:0,top:0};if(!L.floating)return e;const t=Fo(L.floating,d.x),r=Fo(L.floating,d.y);return c?{...e,transform:"translate("+t+"px, "+r+"px)",...Bo(L.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:t,top:r}},[n,c,L.floating,d.x,d.y]);return s.useMemo(()=>({...d,update:R,refs:P,elements:L,floatingStyles:I}),[d,R,P,L,I])}const Ho=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?Po({element:n.current,padding:r}).fn(t):{}:n?Po({element:n,padding:r}).fn(t):{};var i}}),Vo=(e,t)=>({...Ao(e),options:[e,t]}),qo=(e,t)=>({...Mo(e),options:[e,t]}),Uo=(e,t)=>({...Lo(e),options:[e,t]}),$o=(e,t)=>({...To(e),options:[e,t]}),Ko=(e,t)=>({...Ro(e),options:[e,t]}),Yo=(e,t)=>({...Do(e),options:[e,t]}),Go=(e,t)=>({...Ho(e),options:[e,t]});var Xo=s.forwardRef((e,n)=>{const{children:r,width:i=10,height:o=5,...s}=e;return t.jsx(Xr.svg,{...s,ref:n,width:i,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?r:t.jsx("polygon",{points:"0,0 30,0 15,10"})})});Xo.displayName="Arrow";var Jo=Xo;function Qo(e){const[t,n]=s.useState(void 0);return xt(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const t=new ResizeObserver(t=>{if(!Array.isArray(t))return;if(!t.length)return;const r=t[0];let i,o;if("borderBoxSize"in r){const e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,o=t.blockSize}else i=e.offsetWidth,o=e.offsetHeight;n({width:i,height:o})});return t.observe(e,{box:"border-box"}),()=>t.unobserve(e)}n(void 0)},[e]),t}var Zo="Popper",[es,ts]=yt(Zo),[ns,rs]=es(Zo),is=e=>{const{__scopePopper:n,children:r}=e,[i,o]=s.useState(null);return t.jsx(ns,{scope:n,anchor:i,onAnchorChange:o,children:r})};is.displayName=Zo;var os="PopperAnchor",ss=s.forwardRef((e,n)=>{const{__scopePopper:r,virtualRef:i,...o}=e,a=rs(os,r),l=s.useRef(null),c=Je(n,l),u=s.useRef(null);return s.useEffect(()=>{const e=u.current;u.current=i?.current||l.current,e!==u.current&&a.onAnchorChange(u.current)}),i?null:t.jsx(Xr.div,{...o,ref:c})});ss.displayName=os;var as="PopperContent",[ls,cs]=es(as),us=s.forwardRef((e,n)=>{const{__scopePopper:r,side:i="bottom",sideOffset:o=0,align:a="center",alignOffset:l=0,arrowPadding:c=0,avoidCollisions:u=!0,collisionBoundary:h=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:p=!1,updatePositionStrategy:m="optimized",onPlaced:g,...v}=e,b=rs(as,r),[y,w]=s.useState(null),x=Je(n,e=>w(e)),[k,S]=s.useState(null),E=Qo(k),C=E?.width??0,N=E?.height??0,O=i+("center"!==a?"-"+a:""),A="number"==typeof d?d:{top:0,right:0,bottom:0,left:0,...d},M=Array.isArray(h)?h:[h],T=M.length>0,R={padding:A,boundary:M.filter(ps),altBoundary:T},{refs:D,floatingStyles:P,placement:L,isPositioned:I,middlewareData:_}=zo({strategy:"fixed",placement:O,whileElementsMounted:(...e)=>Oo(...e,{animationFrame:"always"===m}),elements:{reference:b.anchor},middleware:[Vo({mainAxis:o+N,alignmentAxis:l}),u&&qo({mainAxis:!0,crossAxis:!1,limiter:"partial"===f?Uo():void 0,...R}),u&&$o({...R}),Ko({...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&&Go({element:k,padding:c}),ms({arrowWidth:C,arrowHeight:N}),p&&Yo({strategy:"referenceHidden",...R})]}),[j,B]=gs(L),F=Dt(g);xt(()=>{I&&F?.()},[I,F]);const W=_.arrow?.x,z=_.arrow?.y,H=0!==_.arrow?.centerOffset,[V,q]=s.useState();return xt(()=>{y&&q(window.getComputedStyle(y).zIndex)},[y]),t.jsx("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:e.dir,children:t.jsx(ls,{scope:r,placedSide:j,onArrowChange:S,arrowX:W,arrowY:z,shouldHideArrow:H,children:t.jsx(Xr.div,{"data-side":j,"data-align":B,...v,ref:x,style:{...v.style,animation:I?void 0:"none"}})})})});us.displayName=as;var hs="PopperArrow",ds={top:"bottom",right:"left",bottom:"top",left:"right"},fs=s.forwardRef(function(e,n){const{__scopePopper:r,...i}=e,o=cs(hs,r),s=ds[o.placedSide];return t.jsx("span",{ref:o.onArrowChange,style:{position:"absolute",left:o.arrowX,top:o.arrowY,[s]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[o.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[o.placedSide],visibility:o.shouldHideArrow?"hidden":void 0},children:t.jsx(Jo,{...i,ref:n,style:{...i.style,display:"block"}})})});function ps(e){return null!==e}fs.displayName=hs;var ms=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]=gs(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 gs(e){const[t,n="center"]=e.split("-");return[t,n]}var vs=is,bs=ss,ys=us,ws=fs;var xs=e=>{const{present:t,children:n}=e,r=function(e){const[t,n]=s.useState(),r=s.useRef(null),i=s.useRef(e),o=s.useRef("none"),a=e?"mounted":"unmounted",[l,c]=function(e,t){return s.useReducer((e,n)=>t[e][n]??e,e)}(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return s.useEffect(()=>{const e=ks(r.current);o.current="mounted"===l?e:"none"},[l]),xt(()=>{const t=r.current,n=i.current;if(n!==e){const r=o.current,s=ks(t);if(e)c("MOUNT");else if("none"===s||"none"===t?.display)c("UNMOUNT");else{c(n&&r!==s?"ANIMATION_OUT":"UNMOUNT")}i.current=e}},[e,c]),xt(()=>{if(t){let e;const n=t.ownerDocument.defaultView??window,s=o=>{const s=ks(r.current).includes(CSS.escape(o.animationName));if(o.target===t&&s&&(c("ANIMATION_END"),!i.current)){const r=t.style.animationFillMode;t.style.animationFillMode="forwards",e=n.setTimeout(()=>{"forwards"===t.style.animationFillMode&&(t.style.animationFillMode=r)})}},a=e=>{e.target===t&&(o.current=ks(r.current))};return t.addEventListener("animationstart",a),t.addEventListener("animationcancel",s),t.addEventListener("animationend",s),()=>{n.clearTimeout(e),t.removeEventListener("animationstart",a),t.removeEventListener("animationcancel",s),t.removeEventListener("animationend",s)}}c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:s.useCallback(e=>{r.current=e?getComputedStyle(e):null,n(e)},[])}}(t),i="function"==typeof n?n({present:r.isPresent}):s.Children.only(n),o=Je(r.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}(i));return"function"==typeof n||r.isPresent?s.cloneElement(i,{ref:o}):null};function ks(e){return e?.animationName||"none"}xs.displayName="Presence";var Ss=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"}),Es=s.forwardRef((e,n)=>t.jsx(Xr.span,{...e,ref:n,style:{...Ss,...e.style}}));Es.displayName="VisuallyHidden";var Cs=Es,[Ns,Os]=yt("Tooltip",[ts]),As=ts(),Ms="TooltipProvider",Ts=700,Rs="tooltip.open",[Ds,Ps]=Ns(Ms),Ls=e=>{const{__scopeTooltip:n,delayDuration:r=Ts,skipDelayDuration:i=300,disableHoverableContent:o=!1,children:a}=e,l=s.useRef(!0),c=s.useRef(!1),u=s.useRef(0);return s.useEffect(()=>{const e=u.current;return()=>window.clearTimeout(e)},[]),t.jsx(Ds,{scope:n,isOpenDelayedRef:l,delayDuration:r,onOpen:s.useCallback(()=>{window.clearTimeout(u.current),l.current=!1},[]),onClose:s.useCallback(()=>{window.clearTimeout(u.current),u.current=window.setTimeout(()=>l.current=!0,i)},[i]),isPointerInTransitRef:c,onPointerInTransitChange:s.useCallback(e=>{c.current=e},[]),disableHoverableContent:o,children:a})};Ls.displayName=Ms;var Is="Tooltip",[_s,js]=Ns(Is),Bs=e=>{const{__scopeTooltip:n,children:r,open:i,defaultOpen:o,onOpenChange:a,disableHoverableContent:l,delayDuration:c}=e,u=Ps(Is,e.__scopeTooltip),h=As(n),[d,f]=s.useState(null),p=Et(),m=s.useRef(0),g=l??u.disableHoverableContent,v=c??u.delayDuration,b=s.useRef(!1),[y,w]=Nt({prop:i,defaultProp:o??!1,onChange:e=>{e?(u.onOpen(),document.dispatchEvent(new CustomEvent(Rs))):u.onClose(),a?.(e)},caller:Is}),x=s.useMemo(()=>y?b.current?"delayed-open":"instant-open":"closed",[y]),k=s.useCallback(()=>{window.clearTimeout(m.current),m.current=0,b.current=!1,w(!0)},[w]),S=s.useCallback(()=>{window.clearTimeout(m.current),m.current=0,w(!1)},[w]),E=s.useCallback(()=>{window.clearTimeout(m.current),m.current=window.setTimeout(()=>{b.current=!0,w(!0),m.current=0},v)},[v,w]);return s.useEffect(()=>()=>{m.current&&(window.clearTimeout(m.current),m.current=0)},[]),t.jsx(vs,{...h,children:t.jsx(_s,{scope:n,contentId:p,open:y,stateAttribute:x,trigger:d,onTriggerChange:f,onTriggerEnter:s.useCallback(()=>{u.isOpenDelayedRef.current?E():k()},[u.isOpenDelayedRef,E,k]),onTriggerLeave:s.useCallback(()=>{g?S():(window.clearTimeout(m.current),m.current=0)},[S,g]),onOpen:k,onClose:S,disableHoverableContent:g,children:r})})};Bs.displayName=Is;var Fs="TooltipTrigger",Ws=s.forwardRef((e,n)=>{const{__scopeTooltip:r,...i}=e,o=js(Fs,r),a=Ps(Fs,r),l=As(r),c=Je(n,s.useRef(null),o.onTriggerChange),u=s.useRef(!1),h=s.useRef(!1),d=s.useCallback(()=>u.current=!1,[]);return s.useEffect(()=>()=>document.removeEventListener("pointerup",d),[d]),t.jsx(bs,{asChild:!0,...l,children:t.jsx(Xr.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...i,ref:c,onPointerMove:bt(e.onPointerMove,e=>{"touch"!==e.pointerType&&(h.current||a.isPointerInTransitRef.current||(o.onTriggerEnter(),h.current=!0))}),onPointerLeave:bt(e.onPointerLeave,()=>{o.onTriggerLeave(),h.current=!1}),onPointerDown:bt(e.onPointerDown,()=>{o.open&&o.onClose(),u.current=!0,document.addEventListener("pointerup",d,{once:!0})}),onFocus:bt(e.onFocus,()=>{u.current||o.onOpen()}),onBlur:bt(e.onBlur,o.onClose),onClick:bt(e.onClick,o.onClose)})})});Ws.displayName=Fs;var[zs,Hs]=Ns("TooltipPortal",{forceMount:void 0}),Vs="TooltipContent",qs=s.forwardRef((e,n)=>{const r=Hs(Vs,e.__scopeTooltip),{forceMount:i=r.forceMount,side:o="top",...s}=e,a=js(Vs,e.__scopeTooltip);return t.jsx(xs,{present:i||a.open,children:a.disableHoverableContent?t.jsx(Gs,{side:o,...s,ref:n}):t.jsx(Us,{side:o,...s,ref:n})})}),Us=s.forwardRef((e,n)=>{const r=js(Vs,e.__scopeTooltip),i=Ps(Vs,e.__scopeTooltip),o=s.useRef(null),a=Je(n,o),[l,c]=s.useState(null),{trigger:u,onClose:h}=r,d=o.current,{onPointerInTransitChange:f}=i,p=s.useCallback(()=>{c(null),f(!1)},[f]),m=s.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]);c(a),f(!0)},[f]);return s.useEffect(()=>()=>p(),[p]),s.useEffect(()=>{if(u&&d){const e=e=>m(e,d),t=e=>m(e,u);return u.addEventListener("pointerleave",e),d.addEventListener("pointerleave",t),()=>{u.removeEventListener("pointerleave",e),d.removeEventListener("pointerleave",t)}}},[u,d,m,p]),s.useEffect(()=>{if(l){const e=e=>{const t=e.target,n={x:e.clientX,y:e.clientY},r=u?.contains(t)||d?.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,l);r?p():i&&(p(),h())};return document.addEventListener("pointermove",e),()=>document.removeEventListener("pointermove",e)}},[u,d,l,h,p]),t.jsx(Gs,{...e,ref:a})}),[$s,Ks]=Ns(Is,{isInside:!1}),Ys=function(e){const n=({children:e})=>t.jsx(t.Fragment,{children:e});return n.displayName=`${e}.Slottable`,n.__radixId=Yr,n}("TooltipContent"),Gs=s.forwardRef((e,n)=>{const{__scopeTooltip:r,children:i,"aria-label":o,onEscapeKeyDown:a,onPointerDownOutside:l,...c}=e,u=js(Vs,r),h=As(r),{onClose:d}=u;return s.useEffect(()=>(document.addEventListener(Rs,d),()=>document.removeEventListener(Rs,d)),[d]),s.useEffect(()=>{if(u.trigger){const e=e=>{const t=e.target;t?.contains(u.trigger)&&d()};return window.addEventListener("scroll",e,{capture:!0}),()=>window.removeEventListener("scroll",e,{capture:!0})}},[u.trigger,d]),t.jsx(ni,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:e=>e.preventDefault(),onDismiss:d,children:t.jsxs(ys,{"data-state":u.stateAttribute,...h,...c,ref:n,style:{...c.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:[t.jsx(Ys,{children:i}),t.jsx($s,{scope:r,isInside:!0,children:t.jsx(Cs,{id:u.contentId,role:"tooltip",children:o||i})})]})})});qs.displayName=Vs;var Xs="TooltipArrow";s.forwardRef((e,n)=>{const{__scopeTooltip:r,...i}=e,o=As(r);return Ks(Xs,r).isInside?null:t.jsx(ws,{...o,...i,ref:n})}).displayName=Xs;var Js=qs,Qs=Ls,Zs=Bs,ea=Ws,ta=s.forwardRef(function(e,t){var n=e.className,r=e.sideOffset,i=void 0===r?4:r,o=w(e,["className","sideOffset"]);return s.createElement(Js,Object.assign({ref:t,sideOffset:i,className:Ke("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]",n)},o))});ta.displayName=Js.displayName;var na=s.createContext(null);function ra(){var e=s.useContext(na);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}function ia(e){var t=e.defaultOpen,n=void 0===t||t,r=e.open,i=e.onOpenChange,o=e.className,a=e.style,l=e.children,c=w(e,["defaultOpen","open","onOpenChange","className","style","children"]),u=function(){var e=m(s.useState(void 0),2),t=e[0],n=e[1];return s.useEffect(function(){var e=window.matchMedia("(max-width: ".concat(767,"px)")),t=function(){n(window.innerWidth<768)};return e.addEventListener("change",t),n(window.innerWidth<768),function(){return e.removeEventListener("change",t)}},[]),!!t}(),h=m(s.useState(!1),2),d=h[0],f=h[1],p=m(s.useState(n),2),g=p[0],v=p[1],b=null!=r?r:g,y=s.useCallback(function(e){var t="function"==typeof e?e(b):e;i?i(t):v(t),document.cookie="".concat("sidebar_state","=").concat(t,"; path=/; max-age=").concat(604800)},[i,b]),x=s.useCallback(function(){return u?f(function(e){return!e}):y(function(e){return!e})},[u,y,f]);s.useEffect(function(){var e=function(e){"b"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),x())};return window.addEventListener("keydown",e),function(){return window.removeEventListener("keydown",e)}},[x]);var k=b?"expanded":"collapsed",S=s.useMemo(function(){return{state:k,open:b,setOpen:y,isMobile:u,openMobile:d,setOpenMobile:f,toggleSidebar:x}},[k,b,y,u,d,f,x]);return s.createElement(na.Provider,{value:S},s.createElement(Qs,{delayDuration:0},s.createElement("div",Object.assign({style:Object.assign({"--sidebar-width":"16rem","--sidebar-width-icon":"3rem"},a),className:Ke("group/sidebar-wrapper flex min-h-svh w-full",o)},c),l)))}function oa(e){var t=e.side,n=void 0===t?"left":t,r=e.variant,i=void 0===r?"sidebar":r,o=e.collapsible,a=void 0===o?"offcanvas":o,l=e.className,c=e.children,u=w(e,["side","variant","collapsible","className","children"]),h=ra(),d=h.isMobile,f=h.state,p=h.openMobile,m=h.setOpenMobile;return"none"===a?s.createElement("div",Object.assign({className:Ke("bg-sidebar text-sidebar-foreground flex h-full w-[var(--sidebar-width)] flex-col",l)},u),c):d?s.createElement(Fr,Object.assign({open:p,onOpenChange:m},u),s.createElement(Vr,{className:"bg-sidebar text-sidebar-foreground w-[var(--sidebar-width)] p-0 [&>button]:hidden",style:{"--sidebar-width":"18rem"},side:n},s.createElement(qr,{className:"sr-only"},s.createElement(Ur,null,"Sidebar"),s.createElement($r,null,"Displays the mobile sidebar.")),s.createElement("div",{className:"flex h-full w-full flex-col"},c))):s.createElement("div",{className:"group peer text-sidebar-foreground hidden md:block","data-state":f,"data-collapsible":"collapsed"===f?a:"","data-variant":i,"data-side":n},s.createElement("div",{className:Ke("relative w-[var(--sidebar-width)] bg-transparent transition-[width] duration-200 ease-linear","group-data-[collapsible=offcanvas]:w-0","floating"===i||"inset"===i?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+1rem)]":"group-data-[collapsible=icon]:w-[var(--sidebar-width-icon)]")}),s.createElement("div",Object.assign({className:Ke("fixed inset-y-0 z-10 hidden h-svh w-[var(--sidebar-width)] transition-[left,right,width] duration-200 ease-linear md:flex","left"===n?"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"===i||"inset"===i?"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),s.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 sa(e){var t=e.className,n=e.onClick,r=w(e,["className","onClick"]),i=ra().toggleSidebar;return s.createElement(ut,Object.assign({variant:"ghost",size:"icon",className:Ke("h-7 w-7",t),onClick:function(e){null==n||n(e),i()}},r),s.createElement(V,null),s.createElement("span",{className:"sr-only"},"Toggle Sidebar"))}function aa(e){var t=e.className,n=w(e,["className"]);return s.createElement("main",Object.assign({className:Ke("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",t)},n))}function la(e){var t=e.className,n=w(e,["className"]);return s.createElement("div",Object.assign({className:Ke("flex flex-col gap-2 p-2",t)},n))}function ca(e){var t=e.className,n=w(e,["className"]);return s.createElement("div",Object.assign({className:Ke("flex flex-col gap-2 p-2",t)},n))}function ua(e){var t=e.className,n=w(e,["className"]);return s.createElement("div",Object.assign({className:Ke("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",t)},n))}function ha(e){var t=e.className,n=w(e,["className"]);return s.createElement("div",Object.assign({className:Ke("relative flex w-full min-w-0 flex-col p-2",t)},n))}function da(e){var t=e.className,n=e.asChild,r=void 0!==n&&n,i=w(e,["className","asChild"]),o=r?nt:"div";return s.createElement(o,Object.assign({className:Ke("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",t)},i))}function fa(e){var t=e.className,n=w(e,["className"]);return s.createElement("div",Object.assign({className:Ke("w-full text-sm",t)},n))}function pa(e){var t=e.className,n=w(e,["className"]);return s.createElement("ul",Object.assign({className:Ke("flex w-full min-w-0 flex-col gap-1",t)},n))}function ma(e){var t=e.className,n=w(e,["className"]);return s.createElement("li",Object.assign({className:Ke("group/menu-item relative",t)},n))}var ga=lt("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 va(e){var t=e.asChild,n=void 0!==t&&t,r=e.isActive,i=void 0!==r&&r,o=e.variant,a=void 0===o?"default":o,l=e.size,c=void 0===l?"default":l,u=e.tooltip,h=e.className,d=w(e,["asChild","isActive","variant","size","tooltip","className"]),f=n?nt:"button",p=ra(),m=p.isMobile,g=p.state,v=s.createElement(f,Object.assign({"data-size":c,"data-active":i,className:Ke(ga({variant:a,size:c}),h)},d));return u?("string"==typeof u&&(u={children:u}),s.createElement(Zs,null,s.createElement(ea,{asChild:!0},v),s.createElement(ta,Object.assign({side:"right",align:"center",hidden:"collapsed"!==g||m},u)))):v}function ba(e){const n=ya(e),r=s.forwardRef((e,r)=>{const{children:i,...o}=e,a=s.Children.toArray(i),l=a.find(xa);if(l){const e=l.props.children,i=a.map(t=>t===l?s.Children.count(e)>1?s.Children.only(null):s.isValidElement(e)?e.props.children:null:t);return t.jsx(n,{...o,ref:r,children:s.isValidElement(e)?s.cloneElement(e,void 0,i):null})}return t.jsx(n,{...o,ref:r,children:i})});return r.displayName=`${e}.Slot`,r}function ya(e){const t=s.forwardRef((e,t)=>{const{children:n,...r}=e;if(s.isValidElement(n)){const e=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}(n),i=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}}(r,n.props);return n.type!==s.Fragment&&(i.ref=t?Xe(t,e):e),s.cloneElement(n,i)}return s.Children.count(n)>1?s.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var wa=Symbol("radix.slottable");function xa(e){return s.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===wa}var ka=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,n)=>{const r=ba(`Primitive.${n}`),i=s.forwardRef((e,i)=>{const{asChild:o,...s}=e,a=o?r:n;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),t.jsx(a,{...s,ref:i})});return i.displayName=`Primitive.${n}`,{...e,[n]:i}},{});function Sa(e,t){e&&a.flushSync(()=>e.dispatchEvent(t))}function Ea(n){const r=n+"CollectionProvider",[i,o]=yt(r),[s,a]=i(r,{collectionRef:{current:null},itemMap:new Map}),l=n=>{const{scope:r,children:i}=n,o=e.useRef(null),a=e.useRef(new Map).current;return t.jsx(s,{scope:r,itemMap:a,collectionRef:o,children:i})};l.displayName=r;const c=n+"CollectionSlot",u=ba(c),h=e.forwardRef((e,n)=>{const{scope:r,children:i}=e,o=Je(n,a(c,r).collectionRef);return t.jsx(u,{ref:o,children:i})});h.displayName=c;const d=n+"CollectionItemSlot",f="data-radix-collection-item",p=ba(d),m=e.forwardRef((n,r)=>{const{scope:i,children:o,...s}=n,l=e.useRef(null),c=Je(r,l),u=a(d,i);return e.useEffect(()=>(u.itemMap.set(l,{ref:l,...s}),()=>{u.itemMap.delete(l)})),t.jsx(p,{[f]:"",ref:c,children:o})});return m.displayName=d,[{Provider:l,Slot:h,ItemSlot:m},function(t){const r=a(n+"CollectionConsumer",t);return e.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])},o]}var Ca=s.createContext(void 0);function Na(e){const t=s.useContext(Ca);return e||t||"ltr"}var Oa,Aa="dismissableLayer.update",Ma="dismissableLayer.pointerDownOutside",Ta="dismissableLayer.focusOutside",Ra=s.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Da=s.forwardRef((e,n)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:l,onDismiss:c,...u}=e,h=s.useContext(Ra),[d,f]=s.useState(null),p=d?.ownerDocument??globalThis?.document,[,m]=s.useState({}),g=Je(n,e=>f(e)),v=Array.from(h.layers),[b]=[...h.layersWithOutsidePointerEventsDisabled].slice(-1),y=v.indexOf(b),w=d?v.indexOf(d):-1,x=h.layersWithOutsidePointerEventsDisabled.size>0,k=w>=y,S=function(e,t=globalThis?.document){const n=Dt(e),r=s.useRef(!1),i=s.useRef(()=>{});return s.useEffect(()=>{const e=e=>{if(e.target&&!r.current){let r=function(){La(Ma,n,o,{discrete:!0})};const o={originalEvent:e};"touch"===e.pointerType?(t.removeEventListener("click",i.current),i.current=r,t.addEventListener("click",i.current,{once:!0})):r()}else t.removeEventListener("click",i.current);r.current=!1},o=window.setTimeout(()=>{t.addEventListener("pointerdown",e)},0);return()=>{window.clearTimeout(o),t.removeEventListener("pointerdown",e),t.removeEventListener("click",i.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}(e=>{const t=e.target,n=[...h.branches].some(e=>e.contains(t));k&&!n&&(o?.(e),l?.(e),e.defaultPrevented||c?.())},p),E=function(e,t=globalThis?.document){const n=Dt(e),r=s.useRef(!1);return s.useEffect(()=>{const e=e=>{if(e.target&&!r.current){La(Ta,n,{originalEvent:e},{discrete:!1})}};return t.addEventListener("focusin",e),()=>t.removeEventListener("focusin",e)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}(e=>{const t=e.target;[...h.branches].some(e=>e.contains(t))||(a?.(e),l?.(e),e.defaultPrevented||c?.())},p);return Pt(e=>{w===h.layers.size-1&&(i?.(e),!e.defaultPrevented&&c&&(e.preventDefault(),c()))},p),s.useEffect(()=>{if(d)return r&&(0===h.layersWithOutsidePointerEventsDisabled.size&&(Oa=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),h.layersWithOutsidePointerEventsDisabled.add(d)),h.layers.add(d),Pa(),()=>{r&&1===h.layersWithOutsidePointerEventsDisabled.size&&(p.body.style.pointerEvents=Oa)}},[d,p,r,h]),s.useEffect(()=>()=>{d&&(h.layers.delete(d),h.layersWithOutsidePointerEventsDisabled.delete(d),Pa())},[d,h]),s.useEffect(()=>{const e=()=>m({});return document.addEventListener(Aa,e),()=>document.removeEventListener(Aa,e)},[]),t.jsx(ka.div,{...u,ref:g,style:{pointerEvents:x?k?"auto":"none":void 0,...e.style},onFocusCapture:bt(e.onFocusCapture,E.onFocusCapture),onBlurCapture:bt(e.onBlurCapture,E.onBlurCapture),onPointerDownCapture:bt(e.onPointerDownCapture,S.onPointerDownCapture)})});Da.displayName="DismissableLayer";function Pa(){const e=new CustomEvent(Aa);document.dispatchEvent(e)}function La(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?Sa(i,o):i.dispatchEvent(o)}s.forwardRef((e,n)=>{const r=s.useContext(Ra),i=s.useRef(null),o=Je(n,i);return s.useEffect(()=>{const e=i.current;if(e)return r.branches.add(e),()=>{r.branches.delete(e)}},[r.branches]),t.jsx(ka.div,{...e,ref:o})}).displayName="DismissableLayerBranch";var Ia="focusScope.autoFocusOnMount",_a="focusScope.autoFocusOnUnmount",ja={bubbles:!1,cancelable:!0},Ba=s.forwardRef((e,n)=>{const{loop:r=!1,trapped:i=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...l}=e,[c,u]=s.useState(null),h=Dt(o),d=Dt(a),f=s.useRef(null),p=Je(n,e=>u(e)),m=s.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;s.useEffect(()=>{if(i){let e=function(e){if(m.paused||!c)return;const t=e.target;c.contains(t)?f.current=t:Ha(f.current,{select:!0})},t=function(e){if(m.paused||!c)return;const t=e.relatedTarget;null!==t&&(c.contains(t)||Ha(f.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(const t of e)t.removedNodes.length>0&&Ha(c)};document.addEventListener("focusin",e),document.addEventListener("focusout",t);const r=new MutationObserver(n);return c&&r.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",e),document.removeEventListener("focusout",t),r.disconnect()}}},[i,c,m.paused]),s.useEffect(()=>{if(c){Va.add(m);const t=document.activeElement;if(!c.contains(t)){const n=new CustomEvent(Ia,ja);c.addEventListener(Ia,h),c.dispatchEvent(n),n.defaultPrevented||(!function(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Ha(r,{select:t}),document.activeElement!==n)return}((e=Fa(c),e.filter(e=>"A"!==e.tagName)),{select:!0}),document.activeElement===t&&Ha(c))}return()=>{c.removeEventListener(Ia,h),setTimeout(()=>{const e=new CustomEvent(_a,ja);c.addEventListener(_a,d),c.dispatchEvent(e),e.defaultPrevented||Ha(t??document.body,{select:!0}),c.removeEventListener(_a,d),Va.remove(m)},0)}}var e},[c,h,d,m]);const g=s.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=Fa(e),n=Wa(t,e),r=Wa(t.reverse(),e);return[n,r]}(t);i&&o?e.shiftKey||n!==o?e.shiftKey&&n===i&&(e.preventDefault(),r&&Ha(o,{select:!0})):(e.preventDefault(),r&&Ha(i,{select:!0})):n===t&&e.preventDefault()}},[r,i,m.paused]);return t.jsx(ka.div,{tabIndex:-1,...l,ref:p,onKeyDown:g})});function Fa(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 Wa(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 Ha(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()}}Ba.displayName="FocusScope";var Va=function(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=qa(e,t),e.unshift(t)},remove(t){e=qa(e,t),e[0]?.resume()}}}();function qa(e,t){const n=[...e],r=n.indexOf(t);return-1!==r&&n.splice(r,1),n}var Ua=s.forwardRef((e,n)=>{const{children:r,width:i=10,height:o=5,...s}=e;return t.jsx(ka.svg,{...s,ref:n,width:i,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?r:t.jsx("polygon",{points:"0,0 30,0 15,10"})})});Ua.displayName="Arrow";var $a=Ua,Ka="Popper",[Ya,Ga]=yt(Ka),[Xa,Ja]=Ya(Ka),Qa=e=>{const{__scopePopper:n,children:r}=e,[i,o]=s.useState(null);return t.jsx(Xa,{scope:n,anchor:i,onAnchorChange:o,children:r})};Qa.displayName=Ka;var Za="PopperAnchor",el=s.forwardRef((e,n)=>{const{__scopePopper:r,virtualRef:i,...o}=e,a=Ja(Za,r),l=s.useRef(null),c=Je(n,l),u=s.useRef(null);return s.useEffect(()=>{const e=u.current;u.current=i?.current||l.current,e!==u.current&&a.onAnchorChange(u.current)}),i?null:t.jsx(ka.div,{...o,ref:c})});el.displayName=Za;var tl="PopperContent",[nl,rl]=Ya(tl),il=s.forwardRef((e,n)=>{const{__scopePopper:r,side:i="bottom",sideOffset:o=0,align:a="center",alignOffset:l=0,arrowPadding:c=0,avoidCollisions:u=!0,collisionBoundary:h=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:p=!1,updatePositionStrategy:m="optimized",onPlaced:g,...v}=e,b=Ja(tl,r),[y,w]=s.useState(null),x=Je(n,e=>w(e)),[k,S]=s.useState(null),E=Qo(k),C=E?.width??0,N=E?.height??0,O=i+("center"!==a?"-"+a:""),A="number"==typeof d?d:{top:0,right:0,bottom:0,left:0,...d},M=Array.isArray(h)?h:[h],T=M.length>0,R={padding:A,boundary:M.filter(ll),altBoundary:T},{refs:D,floatingStyles:P,placement:L,isPositioned:I,middlewareData:_}=zo({strategy:"fixed",placement:O,whileElementsMounted:(...e)=>Oo(...e,{animationFrame:"always"===m}),elements:{reference:b.anchor},middleware:[Vo({mainAxis:o+N,alignmentAxis:l}),u&&qo({mainAxis:!0,crossAxis:!1,limiter:"partial"===f?Uo():void 0,...R}),u&&$o({...R}),Ko({...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&&Go({element:k,padding:c}),cl({arrowWidth:C,arrowHeight:N}),p&&Yo({strategy:"referenceHidden",...R})]}),[j,B]=ul(L),F=Dt(g);xt(()=>{I&&F?.()},[I,F]);const W=_.arrow?.x,z=_.arrow?.y,H=0!==_.arrow?.centerOffset,[V,q]=s.useState();return xt(()=>{y&&q(window.getComputedStyle(y).zIndex)},[y]),t.jsx("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:e.dir,children:t.jsx(nl,{scope:r,placedSide:j,onArrowChange:S,arrowX:W,arrowY:z,shouldHideArrow:H,children:t.jsx(ka.div,{"data-side":j,"data-align":B,...v,ref:x,style:{...v.style,animation:I?void 0:"none"}})})})});il.displayName=tl;var ol="PopperArrow",sl={top:"bottom",right:"left",bottom:"top",left:"right"},al=s.forwardRef(function(e,n){const{__scopePopper:r,...i}=e,o=rl(ol,r),s=sl[o.placedSide];return t.jsx("span",{ref:o.onArrowChange,style:{position:"absolute",left:o.arrowX,top:o.arrowY,[s]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[o.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[o.placedSide],visibility:o.shouldHideArrow?"hidden":void 0},children:t.jsx($a,{...i,ref:n,style:{...i.style,display:"block"}})})});function ll(e){return null!==e}al.displayName=ol;var cl=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]=ul(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 ul(e){const[t,n="center"]=e.split("-");return[t,n]}var hl=Qa,dl=el,fl=il,pl=al,ml=s.forwardRef((e,r)=>{const{container:i,...o}=e,[a,l]=s.useState(!1);xt(()=>l(!0),[]);const c=i||a&&globalThis?.document?.body;return c?n.createPortal(t.jsx(ka.div,{...o,ref:r}),c):null});ml.displayName="Portal";var gl=e=>{const{present:t,children:n}=e,r=function(e){const[t,n]=s.useState(),r=s.useRef(null),i=s.useRef(e),o=s.useRef("none"),a=e?"mounted":"unmounted",[l,c]=function(e,t){return s.useReducer((e,n)=>t[e][n]??e,e)}(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return s.useEffect(()=>{const e=vl(r.current);o.current="mounted"===l?e:"none"},[l]),xt(()=>{const t=r.current,n=i.current;if(n!==e){const r=o.current,s=vl(t);if(e)c("MOUNT");else if("none"===s||"none"===t?.display)c("UNMOUNT");else{c(n&&r!==s?"ANIMATION_OUT":"UNMOUNT")}i.current=e}},[e,c]),xt(()=>{if(t){let e;const n=t.ownerDocument.defaultView??window,s=o=>{const s=vl(r.current).includes(CSS.escape(o.animationName));if(o.target===t&&s&&(c("ANIMATION_END"),!i.current)){const r=t.style.animationFillMode;t.style.animationFillMode="forwards",e=n.setTimeout(()=>{"forwards"===t.style.animationFillMode&&(t.style.animationFillMode=r)})}},a=e=>{e.target===t&&(o.current=vl(r.current))};return t.addEventListener("animationstart",a),t.addEventListener("animationcancel",s),t.addEventListener("animationend",s),()=>{n.clearTimeout(e),t.removeEventListener("animationstart",a),t.removeEventListener("animationcancel",s),t.removeEventListener("animationend",s)}}c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:s.useCallback(e=>{r.current=e?getComputedStyle(e):null,n(e)},[])}}(t),i="function"==typeof n?n({present:r.isPresent}):s.Children.only(n),o=Je(r.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}(i));return"function"==typeof n||r.isPresent?s.cloneElement(i,{ref:o}):null};function vl(e){return e?.animationName||"none"}gl.displayName="Presence";var bl="rovingFocusGroup.onEntryFocus",yl={bubbles:!1,cancelable:!0},wl="RovingFocusGroup",[xl,kl,Sl]=Ea(wl),[El,Cl]=yt(wl,[Sl]),[Nl,Ol]=El(wl),Al=s.forwardRef((e,n)=>t.jsx(xl.Provider,{scope:e.__scopeRovingFocusGroup,children:t.jsx(xl.Slot,{scope:e.__scopeRovingFocusGroup,children:t.jsx(Ml,{...e,ref:n})})}));Al.displayName=wl;var Ml=s.forwardRef((e,n)=>{const{__scopeRovingFocusGroup:r,orientation:i,loop:o=!1,dir:a,currentTabStopId:l,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:u,onEntryFocus:h,preventScrollOnEntryFocus:d=!1,...f}=e,p=s.useRef(null),m=Je(n,p),g=Na(a),[v,b]=Nt({prop:l,defaultProp:c??null,onChange:u,caller:wl}),[y,w]=s.useState(!1),x=Dt(h),k=kl(r),S=s.useRef(!1),[E,C]=s.useState(0);return s.useEffect(()=>{const e=p.current;if(e)return e.addEventListener(bl,x),()=>e.removeEventListener(bl,x)},[x]),t.jsx(Nl,{scope:r,orientation:i,dir:g,loop:o,currentTabStopId:v,onItemFocus:s.useCallback(e=>b(e),[b]),onItemShiftTab:s.useCallback(()=>w(!0),[]),onFocusableItemAdd:s.useCallback(()=>C(e=>e+1),[]),onFocusableItemRemove:s.useCallback(()=>C(e=>e-1),[]),children:t.jsx(ka.div,{tabIndex:y||0===E?-1:0,"data-orientation":i,...f,ref:m,style:{outline:"none",...e.style},onMouseDown:bt(e.onMouseDown,()=>{S.current=!0}),onFocus:bt(e.onFocus,e=>{const t=!S.current;if(e.target===e.currentTarget&&t&&!y){const t=new CustomEvent(bl,yl);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){const e=k().filter(e=>e.focusable);Pl([e.find(e=>e.active),e.find(e=>e.id===v),...e].filter(Boolean).map(e=>e.ref.current),d)}}S.current=!1}),onBlur:bt(e.onBlur,()=>w(!1))})})}),Tl="RovingFocusGroupItem",Rl=s.forwardRef((e,n)=>{const{__scopeRovingFocusGroup:r,focusable:i=!0,active:o=!1,tabStopId:a,children:l,...c}=e,u=Et(),h=a||u,d=Ol(Tl,r),f=d.currentTabStopId===h,p=kl(r),{onFocusableItemAdd:m,onFocusableItemRemove:g,currentTabStopId:v}=d;return s.useEffect(()=>{if(i)return m(),()=>g()},[i,m,g]),t.jsx(xl.ItemSlot,{scope:r,id:h,focusable:i,active:o,children:t.jsx(ka.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...c,ref:n,onMouseDown:bt(e.onMouseDown,e=>{i?d.onItemFocus(h):e.preventDefault()}),onFocus:bt(e.onFocus,()=>d.onItemFocus(h)),onKeyDown:bt(e.onKeyDown,e=>{if("Tab"===e.key&&e.shiftKey)return void d.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:Dl[r]}(e,d.orientation,d.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=d.loop?(r=o+1,(n=i).map((e,t)=>n[(r+t)%n.length])):i.slice(o+1)}setTimeout(()=>Pl(i))}var n,r}),children:"function"==typeof l?l({isCurrentTabStop:f,hasTabStop:null!=v}):l})})});Rl.displayName=Tl;var Dl={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Pl(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 Ll=Al,Il=Rl,_l=["Enter"," "],jl=["ArrowUp","PageDown","End"],Bl=["ArrowDown","PageUp","Home",...jl],Fl={ltr:[..._l,"ArrowRight"],rtl:[..._l,"ArrowLeft"]},Wl={ltr:["ArrowLeft"],rtl:["ArrowRight"]},zl="Menu",[Hl,Vl,ql]=Ea(zl),[Ul,$l]=yt(zl,[ql,Ga,Cl]),Kl=Ga(),Yl=Cl(),[Gl,Xl]=Ul(zl),[Jl,Ql]=Ul(zl),Zl=e=>{const{__scopeMenu:n,open:r=!1,children:i,dir:o,onOpenChange:a,modal:l=!0}=e,c=Kl(n),[u,h]=s.useState(null),d=s.useRef(!1),f=Dt(a),p=Na(o);return s.useEffect(()=>{const e=()=>{d.current=!0,document.addEventListener("pointerdown",t,{capture:!0,once:!0}),document.addEventListener("pointermove",t,{capture:!0,once:!0})},t=()=>d.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})}},[]),t.jsx(hl,{...c,children:t.jsx(Gl,{scope:n,open:r,onOpenChange:f,content:u,onContentChange:h,children:t.jsx(Jl,{scope:n,onClose:s.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:p,modal:l,children:i})})})};Zl.displayName=zl;var ec=s.forwardRef((e,n)=>{const{__scopeMenu:r,...i}=e,o=Kl(r);return t.jsx(dl,{...o,...i,ref:n})});ec.displayName="MenuAnchor";var tc="MenuPortal",[nc,rc]=Ul(tc,{forceMount:void 0}),ic=e=>{const{__scopeMenu:n,forceMount:r,children:i,container:o}=e,s=Xl(tc,n);return t.jsx(nc,{scope:n,forceMount:r,children:t.jsx(gl,{present:r||s.open,children:t.jsx(ml,{asChild:!0,container:o,children:i})})})};ic.displayName=tc;var oc="MenuContent",[sc,ac]=Ul(oc),lc=s.forwardRef((e,n)=>{const r=rc(oc,e.__scopeMenu),{forceMount:i=r.forceMount,...o}=e,s=Xl(oc,e.__scopeMenu),a=Ql(oc,e.__scopeMenu);return t.jsx(Hl.Provider,{scope:e.__scopeMenu,children:t.jsx(gl,{present:i||s.open,children:t.jsx(Hl.Slot,{scope:e.__scopeMenu,children:a.modal?t.jsx(cc,{...o,ref:n}):t.jsx(uc,{...o,ref:n})})})})}),cc=s.forwardRef((e,n)=>{const r=Xl(oc,e.__scopeMenu),i=s.useRef(null),o=Je(n,i);return s.useEffect(()=>{const e=i.current;if(e)return Jn(e)},[]),t.jsx(dc,{...e,ref:o,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:bt(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})}),uc=s.forwardRef((e,n)=>{const r=Xl(oc,e.__scopeMenu);return t.jsx(dc,{...e,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})}),hc=ba("MenuContent.ScrollLock"),dc=s.forwardRef((e,n)=>{const{__scopeMenu:r,loop:i=!1,trapFocus:o,onOpenAutoFocus:a,onCloseAutoFocus:l,disableOutsidePointerEvents:c,onEntryFocus:u,onEscapeKeyDown:h,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:p,onDismiss:m,disableOutsideScroll:g,...v}=e,b=Xl(oc,r),y=Ql(oc,r),w=Kl(r),x=Yl(r),k=Vl(r),[S,E]=s.useState(null),C=s.useRef(null),N=Je(n,C,b.onContentChange),O=s.useRef(0),A=s.useRef(""),M=s.useRef(0),T=s.useRef(null),R=s.useRef("right"),D=s.useRef(0),P=g?qn:s.Fragment,L=g?{as:hc,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())};s.useEffect(()=>()=>window.clearTimeout(O.current),[]),nn();const _=s.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 t.jsx(sc,{scope:r,searchRef:A,onItemEnter:s.useCallback(e=>{_(e)&&e.preventDefault()},[_]),onItemLeave:s.useCallback(e=>{_(e)||(C.current?.focus(),E(null))},[_]),onTriggerLeave:s.useCallback(e=>{_(e)&&e.preventDefault()},[_]),pointerGraceTimerRef:M,onPointerGraceIntentChange:s.useCallback(e=>{T.current=e},[]),children:t.jsx(P,{...L,children:t.jsx(Ba,{asChild:!0,trapped:o,onMountAutoFocus:bt(a,e=>{e.preventDefault(),C.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:l,children:t.jsx(Da,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:h,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:p,onDismiss:m,children:t.jsx(Ll,{asChild:!0,...x,dir:y.dir,orientation:"vertical",loop:i,currentTabStopId:S,onCurrentTabStopIdChange:E,onEntryFocus:bt(u,e=>{y.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:t.jsx(fl,{role:"menu","aria-orientation":"vertical","data-state":Bc(b.open),"data-radix-menu-content":"",dir:y.dir,...w,...v,ref:N,style:{outline:"none",...v.style},onKeyDown:bt(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(!Bl.includes(e.key))return;e.preventDefault();const o=k().filter(e=>!e.disabled).map(e=>e.ref.current);jl.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:bt(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(O.current),A.current="")}),onPointerMove:bt(e.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}}))})})})})})})});lc.displayName=oc;var fc=s.forwardRef((e,n)=>{const{__scopeMenu:r,...i}=e;return t.jsx(ka.div,{role:"group",...i,ref:n})});fc.displayName="MenuGroup";var pc=s.forwardRef((e,n)=>{const{__scopeMenu:r,...i}=e;return t.jsx(ka.div,{...i,ref:n})});pc.displayName="MenuLabel";var mc="MenuItem",gc="menu.itemSelect",vc=s.forwardRef((e,n)=>{const{disabled:r=!1,onSelect:i,...o}=e,a=s.useRef(null),l=Ql(mc,e.__scopeMenu),c=ac(mc,e.__scopeMenu),u=Je(n,a),h=s.useRef(!1);return t.jsx(bc,{...o,ref:u,disabled:r,onClick:bt(e.onClick,()=>{const e=a.current;if(!r&&e){const t=new CustomEvent(gc,{bubbles:!0,cancelable:!0});e.addEventListener(gc,e=>i?.(e),{once:!0}),Sa(e,t),t.defaultPrevented?h.current=!1:l.onClose()}}),onPointerDown:t=>{e.onPointerDown?.(t),h.current=!0},onPointerUp:bt(e.onPointerUp,e=>{h.current||e.currentTarget?.click()}),onKeyDown:bt(e.onKeyDown,e=>{const t=""!==c.searchRef.current;r||t&&" "===e.key||_l.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});vc.displayName=mc;var bc=s.forwardRef((e,n)=>{const{__scopeMenu:r,disabled:i=!1,textValue:o,...a}=e,l=ac(mc,r),c=Yl(r),u=s.useRef(null),h=Je(n,u),[d,f]=s.useState(!1),[p,m]=s.useState("");return s.useEffect(()=>{const e=u.current;e&&m((e.textContent??"").trim())},[a.children]),t.jsx(Hl.ItemSlot,{scope:r,disabled:i,textValue:o??p,children:t.jsx(Il,{asChild:!0,...c,focusable:!i,children:t.jsx(ka.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":i||void 0,"data-disabled":i?"":void 0,...a,ref:h,onPointerMove:bt(e.onPointerMove,zc(e=>{if(i)l.onItemLeave(e);else if(l.onItemEnter(e),!e.defaultPrevented){e.currentTarget.focus({preventScroll:!0})}})),onPointerLeave:bt(e.onPointerLeave,zc(e=>l.onItemLeave(e))),onFocus:bt(e.onFocus,()=>f(!0)),onBlur:bt(e.onBlur,()=>f(!1))})})})}),yc=s.forwardRef((e,n)=>{const{checked:r=!1,onCheckedChange:i,...o}=e;return t.jsx(Oc,{scope:e.__scopeMenu,checked:r,children:t.jsx(vc,{role:"menuitemcheckbox","aria-checked":Fc(r)?"mixed":r,...o,ref:n,"data-state":Wc(r),onSelect:bt(o.onSelect,()=>i?.(!!Fc(r)||!r),{checkForDefaultPrevented:!1})})})});yc.displayName="MenuCheckboxItem";var wc="MenuRadioGroup",[xc,kc]=Ul(wc,{value:void 0,onValueChange:()=>{}}),Sc=s.forwardRef((e,n)=>{const{value:r,onValueChange:i,...o}=e,s=Dt(i);return t.jsx(xc,{scope:e.__scopeMenu,value:r,onValueChange:s,children:t.jsx(fc,{...o,ref:n})})});Sc.displayName=wc;var Ec="MenuRadioItem",Cc=s.forwardRef((e,n)=>{const{value:r,...i}=e,o=kc(Ec,e.__scopeMenu),s=r===o.value;return t.jsx(Oc,{scope:e.__scopeMenu,checked:s,children:t.jsx(vc,{role:"menuitemradio","aria-checked":s,...i,ref:n,"data-state":Wc(s),onSelect:bt(i.onSelect,()=>o.onValueChange?.(r),{checkForDefaultPrevented:!1})})})});Cc.displayName=Ec;var Nc="MenuItemIndicator",[Oc,Ac]=Ul(Nc,{checked:!1}),Mc=s.forwardRef((e,n)=>{const{__scopeMenu:r,forceMount:i,...o}=e,s=Ac(Nc,r);return t.jsx(gl,{present:i||Fc(s.checked)||!0===s.checked,children:t.jsx(ka.span,{...o,ref:n,"data-state":Wc(s.checked)})})});Mc.displayName=Nc;var Tc=s.forwardRef((e,n)=>{const{__scopeMenu:r,...i}=e;return t.jsx(ka.div,{role:"separator","aria-orientation":"horizontal",...i,ref:n})});Tc.displayName="MenuSeparator";var Rc=s.forwardRef((e,n)=>{const{__scopeMenu:r,...i}=e,o=Kl(r);return t.jsx(pl,{...o,...i,ref:n})});Rc.displayName="MenuArrow";var[Dc,Pc]=Ul("MenuSub"),Lc="MenuSubTrigger",Ic=s.forwardRef((e,n)=>{const r=Xl(Lc,e.__scopeMenu),i=Ql(Lc,e.__scopeMenu),o=Pc(Lc,e.__scopeMenu),a=ac(Lc,e.__scopeMenu),l=s.useRef(null),{pointerGraceTimerRef:c,onPointerGraceIntentChange:u}=a,h={__scopeMenu:e.__scopeMenu},d=s.useCallback(()=>{l.current&&window.clearTimeout(l.current),l.current=null},[]);return s.useEffect(()=>d,[d]),s.useEffect(()=>{const e=c.current;return()=>{window.clearTimeout(e),u(null)}},[c,u]),t.jsx(ec,{asChild:!0,...h,children:t.jsx(bc,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":r.open,"aria-controls":o.contentId,"data-state":Bc(r.open),...e,ref:Xe(n,o.onTriggerChange),onClick:t=>{e.onClick?.(t),e.disabled||t.defaultPrevented||(t.currentTarget.focus(),r.open||r.onOpenChange(!0))},onPointerMove:bt(e.onPointerMove,zc(t=>{a.onItemEnter(t),t.defaultPrevented||e.disabled||r.open||l.current||(a.onPointerGraceIntentChange(null),l.current=window.setTimeout(()=>{r.onOpenChange(!0),d()},100))})),onPointerLeave:bt(e.onPointerLeave,zc(e=>{d();const t=r.content?.getBoundingClientRect();if(t){const n=r.content?.dataset.side,i="right"===n,o=i?-5:5,s=t[i?"left":"right"],l=t[i?"right":"left"];a.onPointerGraceIntentChange({area:[{x:e.clientX+o,y:e.clientY},{x:s,y:t.top},{x:l,y:t.top},{x:l,y:t.bottom},{x:s,y:t.bottom}],side:n}),window.clearTimeout(c.current),c.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(e),e.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:bt(e.onKeyDown,t=>{const n=""!==a.searchRef.current;e.disabled||n&&" "===t.key||Fl[i.dir].includes(t.key)&&(r.onOpenChange(!0),r.content?.focus(),t.preventDefault())})})})});Ic.displayName=Lc;var _c="MenuSubContent",jc=s.forwardRef((e,n)=>{const r=rc(oc,e.__scopeMenu),{forceMount:i=r.forceMount,...o}=e,a=Xl(oc,e.__scopeMenu),l=Ql(oc,e.__scopeMenu),c=Pc(_c,e.__scopeMenu),u=s.useRef(null),h=Je(n,u);return t.jsx(Hl.Provider,{scope:e.__scopeMenu,children:t.jsx(gl,{present:i||a.open,children:t.jsx(Hl.Slot,{scope:e.__scopeMenu,children:t.jsx(dc,{id:c.contentId,"aria-labelledby":c.triggerId,...o,ref:h,align:"start",side:"rtl"===l.dir?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{l.isUsingKeyboardRef.current&&u.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:bt(e.onFocusOutside,e=>{e.target!==c.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:bt(e.onEscapeKeyDown,e=>{l.onClose(),e.preventDefault()}),onKeyDown:bt(e.onKeyDown,e=>{const t=e.currentTarget.contains(e.target),n=Wl[l.dir].includes(e.key);t&&n&&(a.onOpenChange(!1),c.trigger?.focus(),e.preventDefault())})})})})})});function Bc(e){return e?"open":"closed"}function Fc(e){return"indeterminate"===e}function Wc(e){return Fc(e)?"indeterminate":e?"checked":"unchecked"}function zc(e){return t=>"mouse"===t.pointerType?e(t):void 0}jc.displayName=_c;var Hc=Zl,Vc=ec,qc=ic,Uc=lc,$c=fc,Kc=pc,Yc=vc,Gc=yc,Xc=Sc,Jc=Cc,Qc=Mc,Zc=Tc,eu=Rc,tu=Ic,nu=jc,ru="DropdownMenu",[iu,ou]=yt(ru,[$l]),su=$l(),[au,lu]=iu(ru),cu=e=>{const{__scopeDropdownMenu:n,children:r,dir:i,open:o,defaultOpen:a,onOpenChange:l,modal:c=!0}=e,u=su(n),h=s.useRef(null),[d,f]=Nt({prop:o,defaultProp:a??!1,onChange:l,caller:ru});return t.jsx(au,{scope:n,triggerId:Et(),triggerRef:h,contentId:Et(),open:d,onOpenChange:f,onOpenToggle:s.useCallback(()=>f(e=>!e),[f]),modal:c,children:t.jsx(Hc,{...u,open:d,onOpenChange:f,dir:i,modal:c,children:r})})};cu.displayName=ru;var uu="DropdownMenuTrigger",hu=s.forwardRef((e,n)=>{const{__scopeDropdownMenu:r,disabled:i=!1,...o}=e,s=lu(uu,r),a=su(r);return t.jsx(Vc,{asChild:!0,...a,children:t.jsx(ka.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":i?"":void 0,disabled:i,...o,ref:Xe(n,s.triggerRef),onPointerDown:bt(e.onPointerDown,e=>{i||0!==e.button||!1!==e.ctrlKey||(s.onOpenToggle(),s.open||e.preventDefault())}),onKeyDown:bt(e.onKeyDown,e=>{i||(["Enter"," "].includes(e.key)&&s.onOpenToggle(),"ArrowDown"===e.key&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(e.key)&&e.preventDefault())})})})});hu.displayName=uu;var du=e=>{const{__scopeDropdownMenu:n,...r}=e,i=su(n);return t.jsx(qc,{...i,...r})};du.displayName="DropdownMenuPortal";var fu="DropdownMenuContent",pu=s.forwardRef((e,n)=>{const{__scopeDropdownMenu:r,...i}=e,o=lu(fu,r),a=su(r),l=s.useRef(!1);return t.jsx(Uc,{id:o.contentId,"aria-labelledby":o.triggerId,...a,...i,ref:n,onCloseAutoFocus:bt(e.onCloseAutoFocus,e=>{l.current||o.triggerRef.current?.focus(),l.current=!1,e.preventDefault()}),onInteractOutside:bt(e.onInteractOutside,e=>{const t=e.detail.originalEvent,n=0===t.button&&!0===t.ctrlKey,r=2===t.button||n;o.modal&&!r||(l.current=!0)}),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)"}})});pu.displayName=fu;s.forwardRef((e,n)=>{const{__scopeDropdownMenu:r,...i}=e,o=su(r);return t.jsx($c,{...o,...i,ref:n})}).displayName="DropdownMenuGroup";var mu=s.forwardRef((e,n)=>{const{__scopeDropdownMenu:r,...i}=e,o=su(r);return t.jsx(Kc,{...o,...i,ref:n})});mu.displayName="DropdownMenuLabel";var gu=s.forwardRef((e,n)=>{const{__scopeDropdownMenu:r,...i}=e,o=su(r);return t.jsx(Yc,{...o,...i,ref:n})});gu.displayName="DropdownMenuItem";var vu=s.forwardRef((e,n)=>{const{__scopeDropdownMenu:r,...i}=e,o=su(r);return t.jsx(Gc,{...o,...i,ref:n})});vu.displayName="DropdownMenuCheckboxItem";s.forwardRef((e,n)=>{const{__scopeDropdownMenu:r,...i}=e,o=su(r);return t.jsx(Xc,{...o,...i,ref:n})}).displayName="DropdownMenuRadioGroup";var bu=s.forwardRef((e,n)=>{const{__scopeDropdownMenu:r,...i}=e,o=su(r);return t.jsx(Jc,{...o,...i,ref:n})});bu.displayName="DropdownMenuRadioItem";var yu=s.forwardRef((e,n)=>{const{__scopeDropdownMenu:r,...i}=e,o=su(r);return t.jsx(Qc,{...o,...i,ref:n})});yu.displayName="DropdownMenuItemIndicator";var wu=s.forwardRef((e,n)=>{const{__scopeDropdownMenu:r,...i}=e,o=su(r);return t.jsx(Zc,{...o,...i,ref:n})});wu.displayName="DropdownMenuSeparator";s.forwardRef((e,n)=>{const{__scopeDropdownMenu:r,...i}=e,o=su(r);return t.jsx(eu,{...o,...i,ref:n})}).displayName="DropdownMenuArrow";var xu=s.forwardRef((e,n)=>{const{__scopeDropdownMenu:r,...i}=e,o=su(r);return t.jsx(tu,{...o,...i,ref:n})});xu.displayName="DropdownMenuSubTrigger";var ku=s.forwardRef((e,n)=>{const{__scopeDropdownMenu:r,...i}=e,o=su(r);return t.jsx(nu,{...o,...i,ref:n,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)"}})});ku.displayName="DropdownMenuSubContent";var Su=du,Eu=pu,Cu=mu,Nu=gu,Ou=vu,Au=bu,Mu=yu,Tu=wu,Ru=xu,Du=ku,Pu=cu,Lu=hu,Iu=s.forwardRef(function(e,t){var n=e.className,r=e.inset,i=e.children,o=w(e,["className","inset","children"]);return s.createElement(Ru,Object.assign({ref:t,className:Ke("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",r&&"pl-8",n)},o),i,s.createElement(M,{className:"ml-auto"}))});Iu.displayName=Ru.displayName;var _u=s.forwardRef(function(e,t){var n=e.className,r=w(e,["className"]);return s.createElement(Du,Object.assign({ref:t,className:Ke("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]",n)},r))});_u.displayName=Du.displayName;var ju=s.forwardRef(function(e,t){var n=e.className,r=e.sideOffset,i=void 0===r?4:r,o=w(e,["className","sideOffset"]);return s.createElement(Su,null,s.createElement(Eu,Object.assign({ref:t,sideOffset:i,className:Ke("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]",n)},o)))});ju.displayName=Eu.displayName;var Bu=s.forwardRef(function(e,t){var n=e.className,r=e.inset,i=w(e,["className","inset"]);return s.createElement(Nu,Object.assign({ref:t,className:Ke("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",r&&"pl-8",n)},i))});Bu.displayName=Nu.displayName;var Fu=s.forwardRef(function(e,t){var n=e.className,r=e.children,i=e.checked,o=w(e,["className","children","checked"]);return s.createElement(Ou,Object.assign({ref:t,className:Ke("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",n),checked:i},o),s.createElement("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center"},s.createElement(Mu,null,s.createElement(N,{className:"h-4 w-4"}))),r)});Fu.displayName=Ou.displayName;var Wu=s.forwardRef(function(e,t){var n=e.className,r=e.children,i=w(e,["className","children"]);return s.createElement(Au,Object.assign({ref:t,className:Ke("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",n)},i),s.createElement("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center"},s.createElement(Mu,null,s.createElement(R,{className:"h-2 w-2 fill-current"}))),r)});Wu.displayName=Au.displayName;var zu=s.forwardRef(function(e,t){var n=e.className,r=e.inset,i=w(e,["className","inset"]);return s.createElement(Cu,Object.assign({ref:t,className:Ke("px-2 py-1.5 text-sm font-semibold",r&&"pl-8",n)},i))});zu.displayName=Cu.displayName;var Hu=s.forwardRef(function(e,t){var n=e.className,r=w(e,["className"]);return s.createElement(Tu,Object.assign({ref:t,className:Ke("-mx-1 my-1 h-px bg-muted",n)},r))});Hu.displayName=Tu.displayName;var Vu=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,n)=>{const r=tt(`Primitive.${n}`),i=s.forwardRef((e,i)=>{const{asChild:o,...s}=e,a=o?r:n;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),t.jsx(a,{...s,ref:i})});return i.displayName=`Primitive.${n}`,{...e,[n]:i}},{}),qu=s.forwardRef((e,n)=>t.jsx(Vu.label,{...e,ref:n,onMouseDown:t=>{t.target.closest("button, input, select, textarea")||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));qu.displayName="Label";var Uu=qu,$u=lt("text-sm font-bold leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 text-foreground"),Ku=s.forwardRef(function(e,t){var n=e.className,r=w(e,["className"]);return s.createElement(Uu,Object.assign({ref:t,className:Ke($u(),n)},r))});Ku.displayName=Uu.displayName;var Yu=s.forwardRef(function(e,t){var n=e.className,r=w(e,["className"]);return s.createElement("div",Object.assign({ref:t,className:Ke("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",n)},r))});Yu.displayName="Card";var Gu=s.forwardRef(function(e,t){var n=e.className,r=w(e,["className"]);return s.createElement("div",Object.assign({ref:t,className:Ke("flex flex-col space-y-1.5 p-6",n)},r))});Gu.displayName="CardHeader";var Xu=s.forwardRef(function(e,t){var n=e.className,r=w(e,["className"]);return s.createElement("div",Object.assign({ref:t,className:Ke("text-2xl font-bold leading-none tracking-tight",n)},r))});Xu.displayName="CardTitle";var Ju=s.forwardRef(function(e,t){var n=e.className,r=w(e,["className"]);return s.createElement("div",Object.assign({ref:t,className:Ke("text-sm text-muted-foreground",n)},r))});Ju.displayName="CardDescription";var Qu=s.forwardRef(function(e,t){var n=e.className,r=w(e,["className"]);return s.createElement("div",Object.assign({ref:t,className:Ke("p-6 pt-0",n)},r))});Qu.displayName="CardContent";var Zu=s.forwardRef(function(e,t){var n=e.className,r=w(e,["className"]);return s.createElement("div",Object.assign({ref:t,className:Ke("flex items-center p-6 pt-0",n)},r))});Zu.displayName="CardFooter";var eh={items:[],config:Object.assign({},{top:24,duration:3,maxCount:5})},th=new Set;function nh(){th.forEach(function(e){return e(eh.items.slice())})}function rh(t){switch(t){case"success":return e.createElement(C,null);case"error":return e.createElement(J,null);case"warning":return e.createElement(E,null);case"loading":return e.createElement(F,{className:"animate-spin"});default:return e.createElement(j,null)}}function ih(e){var t,n,r;lh();var i=Date.now(),o=null!==(t=e.key)&&void 0!==t?t:"msg_".concat(i,"_").concat(Math.random().toString(36).slice(2)),s=eh.items.findIndex(function(e){return e.key===o}),a={key:o,content:e.content,duration:null!==(n=e.duration)&&void 0!==n?n:eh.config.duration,type:e.type,onClose:e.onClose,icon:null!==(r=e.icon)&&void 0!==r?r:rh(e.type),className:e.className,createdAt:i};return s>=0?eh.items[s]=Object.assign({},eh.items[s],a):(eh.items.length>=eh.config.maxCount&&eh.items.shift(),eh.items.push(a)),nh(),a.duration>0&&"loading"!==a.type&&window.setTimeout(function(){oh(o)},1e3*a.duration),{close:function(){return oh(o)}}}function oh(e){var t;if(void 0===e)return eh.items.forEach(function(e){var t;return null===(t=e.onClose)||void 0===t?void 0:t.call(e)}),eh.items=[],void nh();var n=eh.items.findIndex(function(t){return t.key===e});if(n>=0){var r=m(eh.items.splice(n,1),1)[0];null===(t=null==r?void 0:r.onClose)||void 0===t||t.call(r),nh()}}var sh=null,ah=null;function lh(){"undefined"!=typeof window&&(ah||((ah=document.createElement("div")).setAttribute("data-custom-message-holder",""),document.body.appendChild(ah)),sh||(sh=r.createRoot(ah)).render(e.createElement(ch,null)))}function ch(){var t=function(){var t=m(e.useState(eh.items),2),n=t[0],r=t[1];return e.useEffect(function(){var e=r;return th.add(e),function(){th.delete(e)}},[]),n}(),n=eh.config.top;return e.createElement("div",{className:"fixed left-1/2 -translate-x-1/2 z-[1000] w-80 pointer-events-none",style:{top:n}},e.createElement("div",{className:"mx-auto flex w-full max-w-xl flex-col items-center gap-2 px-4"},t.map(function(t){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"}}}(t.type);return e.createElement("div",{key:t.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=t.className)&&void 0!==n?n:"")},e.createElement("span",{className:"text-[18px] leading-none ".concat(i.icon)},null!==(r=t.icon)&&void 0!==r?r:rh(t.type)),e.createElement("div",{className:"min-w-0 flex-1 text-[14px] leading-normal ".concat(i.text)},"string"==typeof t.content?e.createElement("span",{className:"break-words align-middle"},t.content):t.content))})))}function uh(t,n,r,i){if(e.isValidElement(n)||"string"==typeof n||"number"==typeof n)return{type:t,content:n,duration:r,onClose:i};var o=n;return Object.assign({},o,{type:t})}var hh,dh,fh=(dh={open:function(e){var t;return ih(Object.assign({},e,{type:null!==(t=e.type)&&void 0!==t?t:"info"}))},info:function(e,t,n){return ih(uh("info",e,t,n))},success:function(e,t,n){return ih(uh("success",e,t,n))},error:function(e,t,n){return ih(uh("error",e,t,n))},warning:function(e,t,n){return ih(uh("warning",e,t,n))},loading:function(e,t,n){return ih(uh("loading",e,null!=t?t:0,n))},destroy:function(e){return oh(e)},config:function(e){return t=e,eh.config=Object.assign({},eh.config,t),void nh();var t},useMessage:function(){var t=e.useMemo(function(){return"undefined"!=typeof window&&lh(),e.createElement(e.Fragment,null)},[]);return[hh.current,t]}},(hh={}).current=dh,dh);function ph(e,t){return function(){return e.apply(t,arguments)}}const{toString:mh}=Object.prototype,{getPrototypeOf:gh}=Object,{iterator:vh,toStringTag:bh}=Symbol,yh=(wh=Object.create(null),e=>{const t=mh.call(e);return wh[t]||(wh[t]=t.slice(8,-1).toLowerCase())});var wh;const xh=e=>(e=e.toLowerCase(),t=>yh(t)===e),kh=e=>t=>typeof t===e,{isArray:Sh}=Array,Eh=kh("undefined");function Ch(e){return null!==e&&!Eh(e)&&null!==e.constructor&&!Eh(e.constructor)&&Ah(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Nh=xh("ArrayBuffer");const Oh=kh("string"),Ah=kh("function"),Mh=kh("number"),Th=e=>null!==e&&"object"==typeof e,Rh=e=>{if("object"!==yh(e))return!1;const t=gh(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||bh in e||vh in e)},Dh=xh("Date"),Ph=xh("File"),Lh=xh("Blob"),Ih=xh("FileList"),_h=xh("URLSearchParams"),[jh,Bh,Fh,Wh]=["ReadableStream","Request","Response","Headers"].map(xh);function zh(e,t,{allOwnKeys:n=!1}={}){if(null==e)return;let r,i;if("object"!=typeof e&&(e=[e]),Sh(e))for(r=0,i=e.length;r<i;r++)t.call(null,e[r],r,e);else{if(Ch(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 Hh(e,t){if(Ch(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 Vh="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,qh=e=>!Eh(e)&&e!==Vh;const Uh=($h="undefined"!=typeof Uint8Array&&gh(Uint8Array),e=>$h&&e instanceof $h);var $h;const Kh=xh("HTMLFormElement"),Yh=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Gh=xh("RegExp"),Xh=(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 Jh=xh("AsyncFunction"),Qh=(Zh="function"==typeof setImmediate,ed=Ah(Vh.postMessage),Zh?setImmediate:ed?(td=`axios@${Math.random()}`,nd=[],Vh.addEventListener("message",({source:e,data:t})=>{e===Vh&&t===td&&nd.length&&nd.shift()()},!1),e=>{nd.push(e),Vh.postMessage(td,"*")}):e=>setTimeout(e));var Zh,ed,td,nd;const rd="undefined"!=typeof queueMicrotask?queueMicrotask.bind(Vh):"undefined"!=typeof process&&process.nextTick||Qh;var id={isArray:Sh,isArrayBuffer:Nh,isBuffer:Ch,isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||Ah(e.append)&&("formdata"===(t=yh(e))||"object"===t&&Ah(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&Nh(e.buffer),t},isString:Oh,isNumber:Mh,isBoolean:e=>!0===e||!1===e,isObject:Th,isPlainObject:Rh,isEmptyObject:e=>{if(!Th(e)||Ch(e))return!1;try{return 0===Object.keys(e).length&&Object.getPrototypeOf(e)===Object.prototype}catch(e){return!1}},isReadableStream:jh,isRequest:Bh,isResponse:Fh,isHeaders:Wh,isUndefined:Eh,isDate:Dh,isFile:Ph,isBlob:Lh,isRegExp:Gh,isFunction:Ah,isStream:e=>Th(e)&&Ah(e.pipe),isURLSearchParams:_h,isTypedArray:Uh,isFileList:Ih,forEach:zh,merge:function e(){const{caseless:t,skipUndefined:n}=qh(this)&&this||{},r={},i=(i,o)=>{const s=t&&Hh(r,o)||o;Rh(r[s])&&Rh(i)?r[s]=e(r[s],i):Rh(i)?r[s]=e({},i):Sh(i)?r[s]=i.slice():n&&Eh(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&&Ah(t)?e[r]=ph(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&&gh(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kindOf:yh,kindOfTest:xh,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(Sh(e))return e;let t=e.length;if(!Mh(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},forEachEntry:(e,t)=>{const n=(e&&e[vh]).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:Kh,hasOwnProperty:Yh,hasOwnProp:Yh,reduceDescriptors:Xh,freezeMethods:e=>{Xh(e,(t,n)=>{if(Ah(e)&&-1!==["arguments","caller","callee"].indexOf(n))return!1;const r=e[n];Ah(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 Sh(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:Hh,global:Vh,isContextDefined:qh,isSpecCompliantForm:function(e){return!!(e&&Ah(e.append)&&"FormData"===e[bh]&&e[vh])},toJSONObject:e=>{const t=new Array(10),n=(e,r)=>{if(Th(e)){if(t.indexOf(e)>=0)return;if(Ch(e))return e;if(!("toJSON"in e)){t[r]=e;const i=Sh(e)?[]:{};return zh(e,(e,t)=>{const o=n(e,r+1);!Eh(o)&&(i[t]=o)}),t[r]=void 0,i}}return e};return n(e,0)},isAsyncFn:Jh,isThenable:e=>e&&(Th(e)||Ah(e))&&Ah(e.then)&&Ah(e.catch),setImmediate:Qh,asap:rd,isIterable:e=>null!=e&&Ah(e[vh])};function od(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)}id.inherits(od,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:id.toJSONObject(this.config),code:this.code,status:this.status}}});const sd=od.prototype,ad={};["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=>{ad[e]={value:e}}),Object.defineProperties(od,ad),Object.defineProperty(sd,"isAxiosError",{value:!0}),od.from=(e,t,n,r,i,o)=>{const s=Object.create(sd);id.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 od.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 ld(e){return id.isPlainObject(e)||id.isArray(e)}function cd(e){return id.endsWith(e,"[]")?e.slice(0,-2):e}function ud(e,t,n){return e?e.concat(t).map(function(e,t){return e=cd(e),!n&&t?"["+e+"]":e}).join(n?".":""):t}const hd=id.toFlatObject(id,{},null,function(e){return/^is[A-Z]/.test(e)});function dd(e,t,n){if(!id.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const r=(n=id.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(e,t){return!id.isUndefined(t[e])})).metaTokens,i=n.visitor||c,o=n.dots,s=n.indexes,a=(n.Blob||"undefined"!=typeof Blob&&Blob)&&id.isSpecCompliantForm(t);if(!id.isFunction(i))throw new TypeError("visitor must be a function");function l(e){if(null===e)return"";if(id.isDate(e))return e.toISOString();if(id.isBoolean(e))return e.toString();if(!a&&id.isBlob(e))throw new od("Blob is not supported. Use a Buffer instead.");return id.isArrayBuffer(e)||id.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(id.endsWith(n,"{}"))n=r?n:n.slice(0,-2),e=JSON.stringify(e);else if(id.isArray(e)&&function(e){return id.isArray(e)&&!e.some(ld)}(e)||(id.isFileList(e)||id.endsWith(n,"[]"))&&(a=id.toArray(e)))return n=cd(n),a.forEach(function(e,r){!id.isUndefined(e)&&null!==e&&t.append(!0===s?ud([n],r,o):null===s?n:n+"[]",l(e))}),!1;return!!ld(e)||(t.append(ud(i,n,o),l(e)),!1)}const u=[],h=Object.assign(hd,{defaultVisitor:c,convertValue:l,isVisitable:ld});if(!id.isObject(e))throw new TypeError("data must be an object");return function e(n,r){if(!id.isUndefined(n)){if(-1!==u.indexOf(n))throw Error("Circular reference detected in "+r.join("."));u.push(n),id.forEach(n,function(n,o){!0===(!(id.isUndefined(n)||null===n)&&i.call(t,n,id.isString(o)?o.trim():o,r,h))&&e(n,r?r.concat(o):[o])}),u.pop()}}(e),t}function fd(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(e){return t[e]})}function pd(e,t){this._pairs=[],e&&dd(e,this,t)}const md=pd.prototype;function gd(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function vd(e,t,n){if(!t)return e;const r=n&&n.encode||gd;id.isFunction(n)&&(n={serialize:n});const i=n&&n.serialize;let o;if(o=i?i(t,n):id.isURLSearchParams(t)?t.toString():new pd(t,n).toString(r),o){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+o}return e}md.append=function(e,t){this._pairs.push([e,t])},md.toString=function(e){const t=e?function(t){return e.call(this,t,fd)}:fd;return this._pairs.map(function(e){return t(e[0])+"="+t(e[1])},"").join("&")};var bd=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){id.forEach(this.handlers,function(t){null!==t&&e(t)})}},yd={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},wd={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:pd,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]};const xd="undefined"!=typeof window&&"undefined"!=typeof document,kd="object"==typeof navigator&&navigator||void 0,Sd=xd&&(!kd||["ReactNative","NativeScript","NS"].indexOf(kd.product)<0),Ed="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,Cd=xd&&window.location.href||"http://localhost";var Nd={...Object.freeze({__proto__:null,hasBrowserEnv:xd,hasStandardBrowserEnv:Sd,hasStandardBrowserWebWorkerEnv:Ed,navigator:kd,origin:Cd}),...wd};function Od(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&&id.isArray(r)?r.length:o,a)return id.hasOwnProp(r,o)?r[o]=[r[o],n]:r[o]=n,!s;r[o]&&id.isObject(r[o])||(r[o]=[]);return t(e,n,r[o],i)&&id.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(id.isFormData(e)&&id.isFunction(e.entries)){const n={};return id.forEachEntry(e,(e,r)=>{t(function(e){return id.matchAll(/\w+|\[(\w*)]/g,e).map(e=>"[]"===e[0]?"":e[1]||e[0])}(e),r,n,0)}),n}return null}const Ad={transitional:yd,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const n=t.getContentType()||"",r=n.indexOf("application/json")>-1,i=id.isObject(e);i&&id.isHTMLForm(e)&&(e=new FormData(e));if(id.isFormData(e))return r?JSON.stringify(Od(e)):e;if(id.isArrayBuffer(e)||id.isBuffer(e)||id.isStream(e)||id.isFile(e)||id.isBlob(e)||id.isReadableStream(e))return e;if(id.isArrayBufferView(e))return e.buffer;if(id.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 dd(e,new Nd.classes.URLSearchParams,{visitor:function(e,t,n,r){return Nd.isNode&&id.isBuffer(e)?(this.append(t,e.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)},...t})}(e,this.formSerializer).toString();if((o=id.isFileList(e))||n.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return dd(o?{"files[]":e}:e,t&&new t,this.formSerializer)}}return i||r?(t.setContentType("application/json",!1),function(e,t,n){if(id.isString(e))try{return(t||JSON.parse)(e),id.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(n||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||Ad.transitional,n=t&&t.forcedJSONParsing,r="json"===this.responseType;if(id.isResponse(e)||id.isReadableStream(e))return e;if(e&&id.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 od.from(e,od.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:Nd.classes.FormData,Blob:Nd.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};id.forEach(["delete","get","head","post","put","patch"],e=>{Ad.headers[e]={}});var Md=Ad;const Td=id.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 Rd=Symbol("internals");function Dd(e){return e&&String(e).trim().toLowerCase()}function Pd(e){return!1===e||null==e?e:id.isArray(e)?e.map(Pd):String(e)}function Ld(e,t,n,r,i){return id.isFunction(r)?r.call(this,t,n):(i&&(t=n),id.isString(t)?id.isString(r)?-1!==t.indexOf(r):id.isRegExp(r)?r.test(t):void 0:void 0)}class Id{constructor(e){e&&this.set(e)}set(e,t,n){const r=this;function i(e,t,n){const i=Dd(t);if(!i)throw new Error("header name must be a non-empty string");const o=id.findKey(r,i);(!o||void 0===r[o]||!0===n||void 0===n&&!1!==r[o])&&(r[o||t]=Pd(e))}const o=(e,t)=>id.forEach(e,(e,n)=>i(e,n,t));if(id.isPlainObject(e)||e instanceof this.constructor)o(e,t);else if(id.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]&&Td[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(id.isObject(e)&&id.isIterable(e)){let n,r,i={};for(const t of e){if(!id.isArray(t))throw TypeError("Object iterator must return a key-value pair");i[r=t[0]]=(n=i[r])?id.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=Dd(e)){const n=id.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(id.isFunction(t))return t.call(this,e,n);if(id.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=Dd(e)){const n=id.findKey(this,e);return!(!n||void 0===this[n]||t&&!Ld(0,this[n],n,t))}return!1}delete(e,t){const n=this;let r=!1;function i(e){if(e=Dd(e)){const i=id.findKey(n,e);!i||t&&!Ld(0,n[i],i,t)||(delete n[i],r=!0)}}return id.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&&!Ld(0,this[i],i,e,!0)||(delete this[i],r=!0)}return r}normalize(e){const t=this,n={};return id.forEach(this,(r,i)=>{const o=id.findKey(n,i);if(o)return t[o]=Pd(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]=Pd(r),n[s]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return id.forEach(this,(n,r)=>{null!=n&&!1!==n&&(t[r]=e&&id.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[Rd]=this[Rd]={accessors:{}}).accessors,n=this.prototype;function r(e){const r=Dd(e);t[r]||(!function(e,t){const n=id.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 id.isArray(e)?e.forEach(r):r(e),this}}Id.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),id.reduceDescriptors(Id.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[n]=e}}}),id.freezeMethods(Id);var _d=Id;function jd(e,t){const n=this||Md,r=t||n,i=_d.from(r.headers);let o=r.data;return id.forEach(e,function(e){o=e.call(n,o,i.normalize(),t?t.status:void 0)}),i.normalize(),o}function Bd(e){return!(!e||!e.__CANCEL__)}function Fd(e,t,n){od.call(this,null==e?"canceled":e,od.ERR_CANCELED,t,n),this.name="CanceledError"}function Wd(e,t,n){const r=n.config.validateStatus;n.status&&r&&!r(n.status)?t(new od("Request failed with status code "+n.status,[od.ERR_BAD_REQUEST,od.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n)):e(n)}id.inherits(Fd,od,{__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)},Hd=(e,t)=>{const n=null!=e;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Vd=e=>(...t)=>id.asap(()=>e(...t));var qd=Nd.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,Nd.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(Nd.origin),Nd.navigator&&/(msie|trident)/i.test(Nd.navigator.userAgent)):()=>!0,Ud=Nd.hasStandardBrowserEnv?{write(e,t,n,r,i,o,s){if("undefined"==typeof document)return;const a=[`${e}=${encodeURIComponent(t)}`];id.isNumber(n)&&a.push(`expires=${new Date(n).toUTCString()}`),id.isString(r)&&a.push(`path=${r}`),id.isString(i)&&a.push(`domain=${i}`),!0===o&&a.push("secure"),id.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 $d(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 Kd=e=>e instanceof _d?{...e}:e;function Yd(e,t){t=t||{};const n={};function r(e,t,n,r){return id.isPlainObject(e)&&id.isPlainObject(t)?id.merge.call({caseless:r},e,t):id.isPlainObject(t)?id.merge({},t):id.isArray(t)?t.slice():t}function i(e,t,n,i){return id.isUndefined(t)?id.isUndefined(e)?void 0:r(void 0,e,0,i):r(e,t,0,i)}function o(e,t){if(!id.isUndefined(t))return r(void 0,t)}function s(e,t){return id.isUndefined(t)?id.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(Kd(e),Kd(t),0,!0)};return id.forEach(Object.keys({...e,...t}),function(r){const o=l[r]||i,s=o(e[r],t[r],r);id.isUndefined(s)&&o!==a||(n[r]=s)}),n}var Gd=e=>{const t=Yd({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:i,xsrfCookieName:o,headers:s,auth:a}=t;if(t.headers=s=_d.from(s),t.url=vd($d(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&s.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),id.isFormData(n))if(Nd.hasStandardBrowserEnv||Nd.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if(id.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(Nd.hasStandardBrowserEnv&&(r&&id.isFunction(r)&&(r=r(t)),r||!1!==r&&qd(t.url))){const e=i&&o&&Ud.read(o);e&&s.set(i,e)}return t};var Xd="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise(function(t,n){const r=Gd(e);let i=r.data;const o=_d.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=_d.from("getAllResponseHeaders"in m&&m.getAllResponseHeaders());Wd(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 od("Request aborted",od.ECONNABORTED,e,m)),m=null)},m.onerror=function(t){const r=new od(t&&t.message?t.message:"Network Error",od.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||yd;r.timeoutErrorMessage&&(t=r.timeoutErrorMessage),n(new od(t,i.clarifyTimeoutError?od.ETIMEDOUT:od.ECONNABORTED,e,m)),m=null},void 0===i&&o.setContentType(null),"setRequestHeader"in m&&id.forEach(o.toJSON(),function(e,t){m.setRequestHeader(t,e)}),id.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 Fd(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===Nd.protocols.indexOf(v)?n(new od("Unsupported protocol "+v+":",od.ERR_BAD_REQUEST,e)):m.send(i||null)})};var Jd=(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 od?t:new Fd(t instanceof Error?t.message:t))}};let o=t&&setTimeout(()=>{o=null,i(new od(`timeout ${t} of ms exceeded`,od.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=()=>id.asap(s),a}};const Qd=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},Zd=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()}},ef=(e,t,n,r)=>{const i=async function*(e,t){for await(const n of Zd(e))yield*Qd(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:tf}=id,nf=(({Request:e,Response:t})=>({Request:e,Response:t}))(id.global),{ReadableStream:rf,TextEncoder:of}=id.global,sf=(e,...t)=>{try{return!!e(...t)}catch(e){return!1}},af=e=>{e=id.merge.call({skipUndefined:!0},nf,e);const{fetch:t,Request:n,Response:r}=e,i=t?tf(t):"function"==typeof fetch,o=tf(n),s=tf(r);if(!i)return!1;const a=i&&tf(rf),l=i&&("function"==typeof of?(c=new of,e=>c.encode(e)):async e=>new Uint8Array(await new n(e).arrayBuffer()));var c;const u=o&&a&&sf(()=>{let e=!1;const t=new n(Nd.origin,{body:new rf,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),h=s&&a&&sf(()=>id.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 od(`Response type '${e}' is not supported`,od.ERR_NOT_SUPPORT,n)})});const f=async(e,t)=>{const r=id.toFiniteNumber(e.getContentLength());return null==r?(async e=>{if(null==e)return 0;if(id.isBlob(e))return e.size;if(id.isSpecCompliantForm(e)){const t=new n(Nd.origin,{method:"POST",body:e});return(await t.arrayBuffer()).byteLength}return id.isArrayBufferView(e)||id.isArrayBuffer(e)?e.byteLength:(id.isURLSearchParams(e)&&(e+=""),id.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}=Gd(e),x=t||fetch;v=v?(v+"").toLowerCase():"text";let k=Jd([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(id.isFormData(a)&&(e=t.headers.get("content-type"))&&b.setContentType(e),t.body){const[e,n]=Hd(C,zd(Vd(g)));a=ef(t.body,65536,e,n)}}id.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=id.toFiniteNumber(c.headers.get("content-length")),[n,i]=m&&Hd(t,zd(Vd(m),!0))||[];c=new r(ef(c.body,65536,n,()=>{i&&i(),E&&E()}),e)}v=v||"text";let N=await d[id.findKey(d,v)||"text"](c,e);return!p&&E&&E(),await new Promise((t,n)=>{Wd(t,n,{data:N,headers:_d.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 od("Network Error",od.ERR_NETWORK,e,S),{cause:t.cause||t});throw od.from(t,t&&t.code,e,S)}}},lf=new Map,cf=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=lf;for(;l--;)s=o[l],a=c.get(s),void 0===a&&c.set(s,a=l?new Map:af(t)),c=a;return a};cf();const uf={http:null,xhr:Xd,fetch:{get:cf}};id.forEach(uf,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}});const hf=e=>`- ${e}`,df=e=>id.isFunction(e)||null===e||!1===e;var ff={getAdapter:function(e,t){e=id.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,!df(r)&&(i=uf[(n=String(r)).toLowerCase()],void 0===i))throw new od(`Unknown adapter '${n}'`);if(i&&(id.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 od("There is no suitable adapter to dispatch the request "+(n?e.length>1?"since :\n"+e.map(hf).join("\n"):" "+hf(e[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return i},adapters:uf};function pf(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Fd(null,e)}function mf(e){pf(e),e.headers=_d.from(e.headers),e.data=jd.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1);return ff.getAdapter(e.adapter||Md.adapter,e)(e).then(function(t){return pf(e),t.data=jd.call(e,e.transformResponse,t),t.headers=_d.from(t.headers),t},function(t){return Bd(t)||(pf(e),t&&t.response&&(t.response.data=jd.call(e,e.transformResponse,t.response),t.response.headers=_d.from(t.response.headers))),Promise.reject(t)})}const gf="1.13.2",vf={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{vf[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});const bf={};vf.transitional=function(e,t,n){return(r,i,o)=>{if(!1===e)throw new od(function(e,t){return"[Axios v"+gf+"] Transitional option '"+e+"'"+t+(n?". "+n:"")}(i," has been removed"+(t?" in "+t:"")),od.ERR_DEPRECATED);return t&&!bf[i]&&(bf[i]=!0),!e||e(r,i,o)}},vf.spelling=function(e){return(e,t)=>!0};var yf={assertOptions:function(e,t,n){if("object"!=typeof e)throw new od("options must be an object",od.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 od("option "+o+" must be "+n,od.ERR_BAD_OPTION_VALUE);continue}if(!0!==n)throw new od("Unknown option "+o,od.ERR_BAD_OPTION)}},validators:vf};const wf=yf.validators;class xf{constructor(e){this.defaults=e||{},this.interceptors={request:new bd,response:new bd}}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=Yd(this.defaults,t);const{transitional:n,paramsSerializer:r,headers:i}=t;void 0!==n&&yf.assertOptions(n,{silentJSONParsing:wf.transitional(wf.boolean),forcedJSONParsing:wf.transitional(wf.boolean),clarifyTimeoutError:wf.transitional(wf.boolean)},!1),null!=r&&(id.isFunction(r)?t.paramsSerializer={serialize:r}:yf.assertOptions(r,{encode:wf.function,serialize:wf.function},!0)),void 0!==t.allowAbsoluteUrls||(void 0!==this.defaults.allowAbsoluteUrls?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),yf.assertOptions(t,{baseUrl:wf.spelling("baseURL"),withXsrfToken:wf.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let o=i&&id.merge(i.common,i[t.method]);i&&id.forEach(["delete","get","head","post","put","patch","common"],e=>{delete i[e]}),t.headers=_d.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=[mf.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=mf.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 vd($d((e=Yd(this.defaults,e)).baseURL,e.url,e.allowAbsoluteUrls),e.params,e.paramsSerializer)}}id.forEach(["delete","get","head","options"],function(e){xf.prototype[e]=function(t,n){return this.request(Yd(n||{},{method:e,url:t,data:(n||{}).data}))}}),id.forEach(["post","put","patch"],function(e){function t(t){return function(n,r,i){return this.request(Yd(i||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:n,data:r}))}}xf.prototype[e]=t(),xf.prototype[e+"Form"]=t(!0)});var kf=xf;class Sf{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 Fd(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 Sf(function(t){e=t}),cancel:e}}}var Ef=Sf;const Cf={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(Cf).forEach(([e,t])=>{Cf[t]=e});var Nf=Cf;const Of=function e(t){const n=new kf(t),r=ph(kf.prototype.request,n);return id.extend(r,kf.prototype,n,{allOwnKeys:!0}),id.extend(r,n,null,{allOwnKeys:!0}),r.create=function(n){return e(Yd(t,n))},r}(Md);Of.Axios=kf,Of.CanceledError=Fd,Of.CancelToken=Ef,Of.isCancel=Bd,Of.VERSION=gf,Of.toFormData=dd,Of.AxiosError=od,Of.Cancel=Of.CanceledError,Of.all=function(e){return Promise.all(e)},Of.spread=function(e){return function(t){return e.apply(null,t)}},Of.isAxiosError=function(e){return id.isObject(e)&&!0===e.isAxiosError},Of.mergeConfig=Yd,Of.AxiosHeaders=_d,Of.formToJSON=e=>Od(id.isHTMLForm(e)?new FormData(e):e),Of.getAdapter=ff.getAdapter,Of.HttpStatusCode=Nf,Of.default=Of;var Af=Of.create({baseURL:"/api/cms",timeout:1e4,headers:{"Content-Type":"application/json"}}),Mf=new Map;Af.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)}),Af.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&&(fh.error(t),setTimeout(function(){window.location.reload()},1e3))):fh.error(t),Promise.reject(e)});var Tf,Rf=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=Mf.get(o);if(s)return s;var a=Af.get(r,n).then(function(e){return e.data}).finally(function(){Mf.delete(o)});return Mf.set(o,a),a},Df=function(e,t,n){return Af.post(e,t,n).then(function(e){return e.data})},Pf=function(e,t,n){return Af.put(e,t,n).then(function(e){return e.data})},Lf=function(e,t){return Af.delete(e,t).then(function(e){return e.data})};try{var If=localStorage.getItem("cms_session_id")||void 0;Tf=If}catch(CN){}var _f=function(){return Rf("/models")},jf=function(){return Rf("/auth/signup/status/".concat(Tf?Tf+"_":"","cms_users"))},Bf=function(e){return Df("/auth/signup/".concat(Tf?Tf+"_":"","cms_users"),e)},Ff=function(e){return Df("/auth/login/".concat(Tf?Tf+"_":"","cms_users"),e)},Wf=function(){return Df("/auth/verify/".concat(Tf?Tf+"_":"","cms_users"))},zf=function(){return Rf("/auth/user/".concat(Tf?Tf+"_":"","cms_users"))},Hf=function(){localStorage.removeItem("cms_token"),localStorage.removeItem("cms_user")},Vf=function(){return localStorage.getItem("cms_token")},qf=function(){var e=localStorage.getItem("cms_user");return e?JSON.parse(e):null},Uf=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)),Rf("/data/".concat(Tf?Tf+"_":"").concat(e),n)},$f=function(e,t){return Rf("/relation/".concat(Tf?Tf+"_":"").concat(e,"/options"),t)},Kf=function(e,t){return Df("/data/".concat(Tf?Tf+"_":"").concat(e),t)},Yf=function(e,t){return Pf("/data/".concat(Tf?Tf+"_":"").concat(e),t)},Gf=function(e,t){return Lf("/data/".concat(Tf?Tf+"_":"").concat(e,"?id=").concat(t))},Xf={"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"}}},Jf=e.createContext(void 0);function Qf(t){var n=t.children,r=t.defaultLocale,i=m(e.useState(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),o=i[0],s=i[1],a={locale:o,setLocale:function(e){s(e),function(e){try{localStorage.setItem("cms_locale",e)}catch(e){}}(e)},t:function(e){var t,n=e.split("."),r=Xf[o],i=h(n);try{for(i.s();!(t=i.n()).done;){var s=t.value;if(!r||"object"!==v(r)||!(s in r))return e;r=r[s]}}catch(e){i.e(e)}finally{i.f()}return"string"==typeof r?r:e},messages:Xf[o]};return e.createElement(Jf.Provider,{value:a},n)}function Zf(){var t=e.useContext(Jf);if(!t)throw new Error("useTranslation must be used within I18nProvider");return t}function ep(){return Zf().t}function tp(){var e=Zf();return{locale:e.locale,setLocale:e.setLocale}}function np(t){var n=t.onLoginSuccess,r=ep(),i=m(e.useState(""),2),o=i[0],s=i[1],a=m(e.useState(""),2),l=a[0],c=a[1],h=m(e.useState(!1),2),d=h[0],p=h[1],g=m(e.useState("login"),2),v=g[0],b=g[1];e.useEffect(function(){var e=Vf();if(e){var t=function(){var t=u(f().m(function t(){var r;return f().w(function(t){for(;;)switch(t.p=t.n){case 0:return p(!0),t.p=1,t.n=2,Wf();case 2:if(t.v.success){t.n=3;break}throw new Error("token验证失败");case 3:return t.n=4,zf();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,Hf();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]),e.useEffect(function(){if(!Vf()){var e=function(){var e=u(f().m(function e(){var t,n;return f().w(function(e){for(;;)switch(e.p=e.n){case 0:return p(!0),e.p=1,e.n=2,jf();case 2:(n=e.v).success&&(null===(t=n.data)||void 0===t?void 0:t.allowSignup)?b("signup"):b("login"),e.n=4;break;case 3:e.p=3,e.v,b("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=u(f().m(function e(t){var i,s,a,c,u;return f().w(function(e){for(;;)switch(e.p=e.n){case 0:if(t.preventDefault(),o&&l){e.n=1;break}return fh.error(r("validation.required")),e.a(2);case 1:if(p(!0),e.p=2,"signup"!==v){e.n=4;break}return e.n=3,Bf({username:o,password:l});case 3:c=e.v,e.n=6;break;case 4:return e.n=5,Ff({username:o,password:l});case 5:c=e.v;case 6:if((a=c).success&&(null===(i=a.data)||void 0===i?void 0:i.token)){e.n=7;break}return fh.error(a.message||r("auth.loginFailed")),"signup"===v&&(null===(s=a.message)||void 0===s?void 0:s.includes("已存在管理员"))&&b("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,u=e.v,fh.error("".concat(r("auth.loginFailed"),", ").concat(u.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 e.createElement("div",{className:"we0-cms-root"},e.createElement("div",{className:"min-h-screen flex relative overflow-hidden bg-white"},e.createElement("div",{className:"pointer-events-none absolute inset-0"},e.createElement("div",{className:"absolute inset-0 bg-[linear-gradient(110deg,#ffffff_0%,#f7fbff_40%,#edf6ff_70%,#eaf3ff_100%)]"}),e.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)]"}),e.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%)]"})),e.createElement("div",{className:"flex-1 relative flex items-center justify-center"},e.createElement("div",{className:"relative z-10 max-w-4xl w-full px-16 text-left"},e.createElement("div",{className:"mb-12"},e.createElement("div",{className:"inline-flex items-center rounded-2xl px-4 py-2 bg-white/70 backdrop-blur border border-white/60"},e.createElement("span",{className:"text-2xl font-semibold tracking-tight text-gray-900"},r("data.dataManagement"))),e.createElement("h1",{className:"mt-8 text-5xl md:text-6xl font-extrabold leading-tight text-gray-900"},"WE0-CMS"),e.createElement("p",{className:"mt-6 text-2xl text-gray-600"},r("auth.welcome"))))),e.createElement("div",{className:"w-[480px] min-w-[380px] flex items-center justify-center p-8 mt-30"},e.createElement("div",{className:"w-full max-w-sm"},d?e.createElement(Yu,{className:"bg-white/30 backdrop-blur-xl border border-white/50 shadow-none rounded-3xl overflow-hidden"},e.createElement(Qu,{className:"p-8"},e.createElement("div",{className:"space-y-4"},e.createElement(Ye,{className:"h-12 w-48"}),e.createElement(Ye,{className:"h-4 w-64"}),e.createElement(Ye,{className:"h-10 w-full"}),e.createElement(Ye,{className:"h-10 w-full"})))):e.createElement(Yu,{className:"bg-white/30 backdrop-blur-xl border border-white/50 shadow-none rounded-3xl overflow-hidden"},e.createElement(Gu,{className:"p-8 pb-6"},e.createElement(Xu,{className:"text-center text-2xl mb-2 text-gray-800"},r("signup"===v?"auth.createAdminAccount":"auth.welcome")),e.createElement(Ju,{className:"text-center text-gray-500"},r("signup"===v?"auth.firstTimeSetup":"auth.pleaseLogin"))),e.createElement(Qu,{className:"p-8 pt-0"},e.createElement("form",{onSubmit:y,className:"space-y-6"},e.createElement("div",{className:"space-y-2"},e.createElement(Ku,{htmlFor:"username"},r("auth.username"),"/",r("auth.email")),e.createElement("div",{className:"relative"},e.createElement(X,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400"}),e.createElement(ht,{id:"username",type:"text",placeholder:r("auth.email"),value:o,onChange:function(e){return s(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}))),e.createElement("div",{className:"space-y-2"},e.createElement(Ku,{htmlFor:"password"},r("auth.password")),e.createElement("div",{className:"relative"},e.createElement(W,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400"}),e.createElement(ht,{id:"password",type:"password",placeholder:r("auth.password"),value:l,onChange:function(e){return c(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}))),e.createElement(ut,{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},e.createElement(z,{className:"h-4 w-4 mr-2"}),r(d?"common.loading":"signup"===v?"auth.signup":"auth.login")))))))))}function rp(e,[t,n]){return Math.min(n,Math.max(t,e))}function ip(e){const n=op(e),r=s.forwardRef((e,r)=>{const{children:i,...o}=e,a=s.Children.toArray(i),l=a.find(ap);if(l){const e=l.props.children,i=a.map(t=>t===l?s.Children.count(e)>1?s.Children.only(null):s.isValidElement(e)?e.props.children:null:t);return t.jsx(n,{...o,ref:r,children:s.isValidElement(e)?s.cloneElement(e,void 0,i):null})}return t.jsx(n,{...o,ref:r,children:i})});return r.displayName=`${e}.Slot`,r}function op(e){const t=s.forwardRef((e,t)=>{const{children:n,...r}=e;if(s.isValidElement(n)){const e=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}(n),i=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}}(r,n.props);return n.type!==s.Fragment&&(i.ref=t?Xe(t,e):e),s.cloneElement(n,i)}return s.Children.count(n)>1?s.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var sp=Symbol("radix.slottable");function ap(e){return s.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===sp}var lp=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,n)=>{const r=ip(`Primitive.${n}`),i=s.forwardRef((e,i)=>{const{asChild:o,...s}=e,a=o?r:n;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),t.jsx(a,{...s,ref:i})});return i.displayName=`Primitive.${n}`,{...e,[n]:i}},{});var cp,up="dismissableLayer.update",hp="dismissableLayer.pointerDownOutside",dp="dismissableLayer.focusOutside",fp=s.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),pp=s.forwardRef((e,n)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:l,onDismiss:c,...u}=e,h=s.useContext(fp),[d,f]=s.useState(null),p=d?.ownerDocument??globalThis?.document,[,m]=s.useState({}),g=Je(n,e=>f(e)),v=Array.from(h.layers),[b]=[...h.layersWithOutsidePointerEventsDisabled].slice(-1),y=v.indexOf(b),w=d?v.indexOf(d):-1,x=h.layersWithOutsidePointerEventsDisabled.size>0,k=w>=y,S=function(e,t=globalThis?.document){const n=Dt(e),r=s.useRef(!1),i=s.useRef(()=>{});return s.useEffect(()=>{const e=e=>{if(e.target&&!r.current){let r=function(){gp(hp,n,o,{discrete:!0})};const o={originalEvent:e};"touch"===e.pointerType?(t.removeEventListener("click",i.current),i.current=r,t.addEventListener("click",i.current,{once:!0})):r()}else t.removeEventListener("click",i.current);r.current=!1},o=window.setTimeout(()=>{t.addEventListener("pointerdown",e)},0);return()=>{window.clearTimeout(o),t.removeEventListener("pointerdown",e),t.removeEventListener("click",i.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}(e=>{const t=e.target,n=[...h.branches].some(e=>e.contains(t));k&&!n&&(o?.(e),l?.(e),e.defaultPrevented||c?.())},p),E=function(e,t=globalThis?.document){const n=Dt(e),r=s.useRef(!1);return s.useEffect(()=>{const e=e=>{if(e.target&&!r.current){gp(dp,n,{originalEvent:e},{discrete:!1})}};return t.addEventListener("focusin",e),()=>t.removeEventListener("focusin",e)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}(e=>{const t=e.target;[...h.branches].some(e=>e.contains(t))||(a?.(e),l?.(e),e.defaultPrevented||c?.())},p);return Pt(e=>{w===h.layers.size-1&&(i?.(e),!e.defaultPrevented&&c&&(e.preventDefault(),c()))},p),s.useEffect(()=>{if(d)return r&&(0===h.layersWithOutsidePointerEventsDisabled.size&&(cp=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),h.layersWithOutsidePointerEventsDisabled.add(d)),h.layers.add(d),mp(),()=>{r&&1===h.layersWithOutsidePointerEventsDisabled.size&&(p.body.style.pointerEvents=cp)}},[d,p,r,h]),s.useEffect(()=>()=>{d&&(h.layers.delete(d),h.layersWithOutsidePointerEventsDisabled.delete(d),mp())},[d,h]),s.useEffect(()=>{const e=()=>m({});return document.addEventListener(up,e),()=>document.removeEventListener(up,e)},[]),t.jsx(lp.div,{...u,ref:g,style:{pointerEvents:x?k?"auto":"none":void 0,...e.style},onFocusCapture:bt(e.onFocusCapture,E.onFocusCapture),onBlurCapture:bt(e.onBlurCapture,E.onBlurCapture),onPointerDownCapture:bt(e.onPointerDownCapture,S.onPointerDownCapture)})});pp.displayName="DismissableLayer";function mp(){const e=new CustomEvent(up);document.dispatchEvent(e)}function gp(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&&a.flushSync(()=>e.dispatchEvent(t))}(i,o):i.dispatchEvent(o)}s.forwardRef((e,n)=>{const r=s.useContext(fp),i=s.useRef(null),o=Je(n,i);return s.useEffect(()=>{const e=i.current;if(e)return r.branches.add(e),()=>{r.branches.delete(e)}},[r.branches]),t.jsx(lp.div,{...e,ref:o})}).displayName="DismissableLayerBranch";var vp="focusScope.autoFocusOnMount",bp="focusScope.autoFocusOnUnmount",yp={bubbles:!1,cancelable:!0},wp=s.forwardRef((e,n)=>{const{loop:r=!1,trapped:i=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...l}=e,[c,u]=s.useState(null),h=Dt(o),d=Dt(a),f=s.useRef(null),p=Je(n,e=>u(e)),m=s.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;s.useEffect(()=>{if(i){let e=function(e){if(m.paused||!c)return;const t=e.target;c.contains(t)?f.current=t:Ep(f.current,{select:!0})},t=function(e){if(m.paused||!c)return;const t=e.relatedTarget;null!==t&&(c.contains(t)||Ep(f.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(const t of e)t.removedNodes.length>0&&Ep(c)};document.addEventListener("focusin",e),document.addEventListener("focusout",t);const r=new MutationObserver(n);return c&&r.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",e),document.removeEventListener("focusout",t),r.disconnect()}}},[i,c,m.paused]),s.useEffect(()=>{if(c){Cp.add(m);const t=document.activeElement;if(!c.contains(t)){const n=new CustomEvent(vp,yp);c.addEventListener(vp,h),c.dispatchEvent(n),n.defaultPrevented||(!function(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Ep(r,{select:t}),document.activeElement!==n)return}((e=xp(c),e.filter(e=>"A"!==e.tagName)),{select:!0}),document.activeElement===t&&Ep(c))}return()=>{c.removeEventListener(vp,h),setTimeout(()=>{const e=new CustomEvent(bp,yp);c.addEventListener(bp,d),c.dispatchEvent(e),e.defaultPrevented||Ep(t??document.body,{select:!0}),c.removeEventListener(bp,d),Cp.remove(m)},0)}}var e},[c,h,d,m]);const g=s.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=xp(e),n=kp(t,e),r=kp(t.reverse(),e);return[n,r]}(t);i&&o?e.shiftKey||n!==o?e.shiftKey&&n===i&&(e.preventDefault(),r&&Ep(o,{select:!0})):(e.preventDefault(),r&&Ep(i,{select:!0})):n===t&&e.preventDefault()}},[r,i,m.paused]);return t.jsx(lp.div,{tabIndex:-1,...l,ref:p,onKeyDown:g})});function xp(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 kp(e,t){for(const n of e)if(!Sp(n,{upTo:t}))return n}function Sp(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 Ep(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()}}wp.displayName="FocusScope";var Cp=function(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=Np(e,t),e.unshift(t)},remove(t){e=Np(e,t),e[0]?.resume()}}}();function Np(e,t){const n=[...e],r=n.indexOf(t);return-1!==r&&n.splice(r,1),n}var Op=s.forwardRef((e,n)=>{const{children:r,width:i=10,height:o=5,...s}=e;return t.jsx(lp.svg,{...s,ref:n,width:i,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?r:t.jsx("polygon",{points:"0,0 30,0 15,10"})})});Op.displayName="Arrow";var Ap=Op,Mp="Popper",[Tp,Rp]=yt(Mp),[Dp,Pp]=Tp(Mp),Lp=e=>{const{__scopePopper:n,children:r}=e,[i,o]=s.useState(null);return t.jsx(Dp,{scope:n,anchor:i,onAnchorChange:o,children:r})};Lp.displayName=Mp;var Ip="PopperAnchor",_p=s.forwardRef((e,n)=>{const{__scopePopper:r,virtualRef:i,...o}=e,a=Pp(Ip,r),l=s.useRef(null),c=Je(n,l),u=s.useRef(null);return s.useEffect(()=>{const e=u.current;u.current=i?.current||l.current,e!==u.current&&a.onAnchorChange(u.current)}),i?null:t.jsx(lp.div,{...o,ref:c})});_p.displayName=Ip;var jp="PopperContent",[Bp,Fp]=Tp(jp),Wp=s.forwardRef((e,n)=>{const{__scopePopper:r,side:i="bottom",sideOffset:o=0,align:a="center",alignOffset:l=0,arrowPadding:c=0,avoidCollisions:u=!0,collisionBoundary:h=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:p=!1,updatePositionStrategy:m="optimized",onPlaced:g,...v}=e,b=Pp(jp,r),[y,w]=s.useState(null),x=Je(n,e=>w(e)),[k,S]=s.useState(null),E=Qo(k),C=E?.width??0,N=E?.height??0,O=i+("center"!==a?"-"+a:""),A="number"==typeof d?d:{top:0,right:0,bottom:0,left:0,...d},M=Array.isArray(h)?h:[h],T=M.length>0,R={padding:A,boundary:M.filter(qp),altBoundary:T},{refs:D,floatingStyles:P,placement:L,isPositioned:I,middlewareData:_}=zo({strategy:"fixed",placement:O,whileElementsMounted:(...e)=>Oo(...e,{animationFrame:"always"===m}),elements:{reference:b.anchor},middleware:[Vo({mainAxis:o+N,alignmentAxis:l}),u&&qo({mainAxis:!0,crossAxis:!1,limiter:"partial"===f?Uo():void 0,...R}),u&&$o({...R}),Ko({...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&&Go({element:k,padding:c}),Up({arrowWidth:C,arrowHeight:N}),p&&Yo({strategy:"referenceHidden",...R})]}),[j,B]=$p(L),F=Dt(g);xt(()=>{I&&F?.()},[I,F]);const W=_.arrow?.x,z=_.arrow?.y,H=0!==_.arrow?.centerOffset,[V,q]=s.useState();return xt(()=>{y&&q(window.getComputedStyle(y).zIndex)},[y]),t.jsx("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:e.dir,children:t.jsx(Bp,{scope:r,placedSide:j,onArrowChange:S,arrowX:W,arrowY:z,shouldHideArrow:H,children:t.jsx(lp.div,{"data-side":j,"data-align":B,...v,ref:x,style:{...v.style,animation:I?void 0:"none"}})})})});Wp.displayName=jp;var zp="PopperArrow",Hp={top:"bottom",right:"left",bottom:"top",left:"right"},Vp=s.forwardRef(function(e,n){const{__scopePopper:r,...i}=e,o=Fp(zp,r),s=Hp[o.placedSide];return t.jsx("span",{ref:o.onArrowChange,style:{position:"absolute",left:o.arrowX,top:o.arrowY,[s]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[o.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[o.placedSide],visibility:o.shouldHideArrow?"hidden":void 0},children:t.jsx(Ap,{...i,ref:n,style:{...i.style,display:"block"}})})});function qp(e){return null!==e}Vp.displayName=zp;var Up=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]=$p(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 $p(e){const[t,n="center"]=e.split("-");return[t,n]}var Kp=Lp,Yp=_p,Gp=Wp,Xp=Vp,Jp=s.forwardRef((e,r)=>{const{container:i,...o}=e,[a,l]=s.useState(!1);xt(()=>l(!0),[]);const c=i||a&&globalThis?.document?.body;return c?n.createPortal(t.jsx(lp.div,{...o,ref:r}),c):null});function Qp(e){const t=s.useRef({value:e,previous:e});return s.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}Jp.displayName="Portal";var Zp=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.forwardRef((e,n)=>t.jsx(lp.span,{...e,ref:n,style:{...Zp,...e.style}})).displayName="VisuallyHidden";var em=[" ","Enter","ArrowUp","ArrowDown"],tm=[" ","Enter"],nm="Select",[rm,im,om]=function(n){const r=n+"CollectionProvider",[i,o]=yt(r),[s,a]=i(r,{collectionRef:{current:null},itemMap:new Map}),l=n=>{const{scope:r,children:i}=n,o=e.useRef(null),a=e.useRef(new Map).current;return t.jsx(s,{scope:r,itemMap:a,collectionRef:o,children:i})};l.displayName=r;const c=n+"CollectionSlot",u=ip(c),h=e.forwardRef((e,n)=>{const{scope:r,children:i}=e,o=Je(n,a(c,r).collectionRef);return t.jsx(u,{ref:o,children:i})});h.displayName=c;const d=n+"CollectionItemSlot",f="data-radix-collection-item",p=ip(d),m=e.forwardRef((n,r)=>{const{scope:i,children:o,...s}=n,l=e.useRef(null),c=Je(r,l),u=a(d,i);return e.useEffect(()=>(u.itemMap.set(l,{ref:l,...s}),()=>{u.itemMap.delete(l)})),t.jsx(p,{[f]:"",ref:c,children:o})});return m.displayName=d,[{Provider:l,Slot:h,ItemSlot:m},function(t){const r=a(n+"CollectionConsumer",t);return e.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])},o]}(nm),[sm,am]=yt(nm,[om,Rp]),lm=Rp(),[cm,um]=sm(nm),[hm,dm]=sm(nm),fm=e=>{const{__scopeSelect:n,children:r,open:i,defaultOpen:o,onOpenChange:a,value:l,defaultValue:c,onValueChange:u,dir:h,name:d,autoComplete:f,disabled:p,required:m,form:g}=e,v=lm(n),[b,y]=s.useState(null),[w,x]=s.useState(null),[k,S]=s.useState(!1),E=Na(h),[C,N]=Nt({prop:i,defaultProp:o??!1,onChange:a,caller:nm}),[O,A]=Nt({prop:l,defaultProp:c,onChange:u,caller:nm}),M=s.useRef(null),T=!b||(g||!!b.closest("form")),[R,D]=s.useState(new Set),P=Array.from(R).map(e=>e.props.value).join(";");return t.jsx(Kp,{...v,children:t.jsxs(cm,{required:m,scope:n,trigger:b,onTriggerChange:y,valueNode:w,onValueNodeChange:x,valueNodeHasChildren:k,onValueNodeHasChildrenChange:S,contentId:Et(),value:O,onValueChange:A,open:C,onOpenChange:N,dir:E,triggerPointerDownPosRef:M,disabled:p,children:[t.jsx(rm.Provider,{scope:n,children:t.jsx(hm,{scope:e.__scopeSelect,onNativeOptionAdd:s.useCallback(e=>{D(t=>new Set(t).add(e))},[]),onNativeOptionRemove:s.useCallback(e=>{D(t=>{const n=new Set(t);return n.delete(e),n})},[]),children:r})}),T?t.jsxs(Zm,{"aria-hidden":!0,required:m,tabIndex:-1,name:d,autoComplete:f,value:O,onChange:e=>A(e.target.value),disabled:p,form:g,children:[void 0===O?t.jsx("option",{value:""}):null,Array.from(R)]},P):null]})})};fm.displayName=nm;var pm="SelectTrigger",mm=s.forwardRef((e,n)=>{const{__scopeSelect:r,disabled:i=!1,...o}=e,a=lm(r),l=um(pm,r),c=l.disabled||i,u=Je(n,l.onTriggerChange),h=im(r),d=s.useRef("touch"),[f,p,m]=tg(e=>{const t=h().filter(e=>!e.disabled),n=t.find(e=>e.value===l.value),r=ng(t,e,n);void 0!==r&&l.onValueChange(r.value)}),g=e=>{c||(l.onOpenChange(!0),m()),e&&(l.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return t.jsx(Yp,{asChild:!0,...a,children:t.jsx(lp.button,{type:"button",role:"combobox","aria-controls":l.contentId,"aria-expanded":l.open,"aria-required":l.required,"aria-autocomplete":"none",dir:l.dir,"data-state":l.open?"open":"closed",disabled:c,"data-disabled":c?"":void 0,"data-placeholder":eg(l.value)?"":void 0,...o,ref:u,onClick:bt(o.onClick,e=>{e.currentTarget.focus(),"mouse"!==d.current&&g(e)}),onPointerDown:bt(o.onPointerDown,e=>{d.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:bt(o.onKeyDown,e=>{const t=""!==f.current;e.ctrlKey||e.altKey||e.metaKey||1!==e.key.length||p(e.key),t&&" "===e.key||em.includes(e.key)&&(g(),e.preventDefault())})})})});mm.displayName=pm;var gm="SelectValue",vm=s.forwardRef((e,n)=>{const{__scopeSelect:r,className:i,style:o,children:s,placeholder:a="",...l}=e,c=um(gm,r),{onValueNodeHasChildrenChange:u}=c,h=void 0!==s,d=Je(n,c.onValueNodeChange);return xt(()=>{u(h)},[u,h]),t.jsx(lp.span,{...l,ref:d,style:{pointerEvents:"none"},children:eg(c.value)?t.jsx(t.Fragment,{children:a}):s})});vm.displayName=gm;var bm=s.forwardRef((e,n)=>{const{__scopeSelect:r,children:i,...o}=e;return t.jsx(lp.span,{"aria-hidden":!0,...o,ref:n,children:i||"▼"})});bm.displayName="SelectIcon";var ym=e=>t.jsx(Jp,{asChild:!0,...e});ym.displayName="SelectPortal";var wm="SelectContent",xm=s.forwardRef((e,n)=>{const r=um(wm,e.__scopeSelect),[i,o]=s.useState();if(xt(()=>{o(new DocumentFragment)},[]),!r.open){const n=i;return n?a.createPortal(t.jsx(Sm,{scope:e.__scopeSelect,children:t.jsx(rm.Slot,{scope:e.__scopeSelect,children:t.jsx("div",{children:e.children})})}),n):null}return t.jsx(Nm,{...e,ref:n})});xm.displayName=wm;var km=10,[Sm,Em]=sm(wm),Cm=ip("SelectContent.RemoveScroll"),Nm=s.forwardRef((e,n)=>{const{__scopeSelect:r,position:i="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:a,onPointerDownOutside:l,side:c,sideOffset:u,align:h,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:g,hideWhenDetached:v,avoidCollisions:b,...y}=e,w=um(wm,r),[x,k]=s.useState(null),[S,E]=s.useState(null),C=Je(n,e=>k(e)),[N,O]=s.useState(null),[A,M]=s.useState(null),T=im(r),[R,D]=s.useState(!1),P=s.useRef(!1);s.useEffect(()=>{if(x)return Jn(x)},[x]),nn();const L=s.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=s.useCallback(()=>L([N,x]),[L,N,x]);s.useEffect(()=>{R&&I()},[R,I]);const{onOpenChange:_,triggerPointerDownPosRef:j}=w;s.useEffect(()=>{if(x){let e={x:0,y:0};const t=t=>{e={x:Math.abs(Math.round(t.pageX)-(j.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(j.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():x.contains(n.target)||_(!1),document.removeEventListener("pointermove",t),j.current=null};return null!==j.current&&(document.addEventListener("pointermove",t),document.addEventListener("pointerup",n,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",t),document.removeEventListener("pointerup",n,{capture:!0})}}},[x,_,j]),s.useEffect(()=>{const e=()=>_(!1);return window.addEventListener("blur",e),window.addEventListener("resize",e),()=>{window.removeEventListener("blur",e),window.removeEventListener("resize",e)}},[_]);const[B,F]=tg(e=>{const t=T().filter(e=>!e.disabled),n=t.find(e=>e.ref.current===document.activeElement),r=ng(t,e,n);r&&setTimeout(()=>r.ref.current.focus())}),W=s.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=s.useCallback(()=>x?.focus(),[x]),H=s.useCallback((e,t,n)=>{const r=!P.current&&!n;(void 0!==w.value&&w.value===t||r)&&M(e)},[w.value]),V="popper"===i?Am:Om,q=V===Am?{side:c,sideOffset:u,align:h,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:g,hideWhenDetached:v,avoidCollisions:b}:{};return t.jsx(Sm,{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:B,children:t.jsx(qn,{as:Cm,allowPinchZoom:!0,children:t.jsx(wp,{asChild:!0,trapped:w.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:bt(o,e=>{w.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:t.jsx(pp,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:t.jsx(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:bt(y.onKeyDown,e=>{const t=e.ctrlKey||e.altKey||e.metaKey;if("Tab"===e.key&&e.preventDefault(),t||1!==e.key.length||F(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()}})})})})})})});Nm.displayName="SelectContentImpl";var Om=s.forwardRef((e,n)=>{const{__scopeSelect:r,onPlaced:i,...o}=e,a=um(wm,r),l=Em(wm,r),[c,u]=s.useState(null),[h,d]=s.useState(null),f=Je(n,e=>d(e)),p=im(r),m=s.useRef(!1),g=s.useRef(!0),{viewport:v,selectedItem:b,selectedItemText:y,focusSelectedItem:w}=l,x=s.useCallback(()=>{if(a.trigger&&a.valueNode&&c&&h&&v&&b&&y){const e=a.trigger.getBoundingClientRect(),t=h.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),r=y.getBoundingClientRect();if("rtl"!==a.dir){const i=r.left-t.left,o=n.left-i,s=e.left-o,a=e.width+s,l=Math.max(a,t.width),u=window.innerWidth-km,h=rp(o,[km,Math.max(km,u-l)]);c.style.minWidth=a+"px",c.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,l=Math.max(a,t.width),u=window.innerWidth-km,h=rp(o,[km,Math.max(km,u-l)]);c.style.minWidth=a+"px",c.style.right=h+"px"}const o=p(),s=window.innerHeight-2*km,l=v.scrollHeight,u=window.getComputedStyle(h),d=parseInt(u.borderTopWidth,10),f=parseInt(u.paddingTop,10),g=parseInt(u.borderBottomWidth,10),w=d+f+l+parseInt(u.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-km,N=s-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;c.style.bottom="0px";const t=h.clientHeight-v.offsetTop-v.offsetHeight,n=A+Math.max(N,O+(e?E:0)+t+g);c.style.height=n+"px"}else{const e=o.length>0&&b===o[0].ref.current;c.style.top="0px";const t=Math.max(C,d+v.offsetTop+(e?S:0)+O)+M;c.style.height=t+"px",v.scrollTop=A-C+v.offsetTop}c.style.margin=`${km}px 0`,c.style.minHeight=x+"px",c.style.maxHeight=s+"px",i?.(),requestAnimationFrame(()=>m.current=!0)}},[p,a.trigger,a.valueNode,c,h,v,b,y,a.dir,i]);xt(()=>x(),[x]);const[k,S]=s.useState();xt(()=>{h&&S(window.getComputedStyle(h).zIndex)},[h]);const E=s.useCallback(e=>{e&&!0===g.current&&(x(),w?.(),g.current=!1)},[x,w]);return t.jsx(Mm,{scope:r,contentWrapper:c,shouldExpandOnScrollRef:m,onScrollButtonChange:E,children:t.jsx("div",{ref:u,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:k},children:t.jsx(lp.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Om.displayName="SelectItemAlignedPosition";var Am=s.forwardRef((e,n)=>{const{__scopeSelect:r,align:i="start",collisionPadding:o=km,...s}=e,a=lm(r);return t.jsx(Gp,{...a,...s,ref:n,align:i,collisionPadding:o,style:{boxSizing:"border-box",...s.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)"}})});Am.displayName="SelectPopperPosition";var[Mm,Tm]=sm(wm,{}),Rm="SelectViewport",Dm=s.forwardRef((e,n)=>{const{__scopeSelect:r,nonce:i,...o}=e,a=Em(Rm,r),l=Tm(Rm,r),c=Je(n,a.onViewportChange),u=s.useRef(0);return t.jsxs(t.Fragment,{children:[t.jsx("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}),t.jsx(rm.Slot,{scope:r,children:t.jsx(lp.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:c,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:bt(o.onScroll,e=>{const t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=l;if(r?.current&&n){const e=Math.abs(u.current-t.scrollTop);if(e>0){const r=window.innerHeight-2*km,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")}}}u.current=t.scrollTop})})})]})});Dm.displayName=Rm;var Pm="SelectGroup",[Lm,Im]=sm(Pm);s.forwardRef((e,n)=>{const{__scopeSelect:r,...i}=e,o=Et();return t.jsx(Lm,{scope:r,id:o,children:t.jsx(lp.div,{role:"group","aria-labelledby":o,...i,ref:n})})}).displayName=Pm;var _m="SelectLabel",jm=s.forwardRef((e,n)=>{const{__scopeSelect:r,...i}=e,o=Im(_m,r);return t.jsx(lp.div,{id:o.id,...i,ref:n})});jm.displayName=_m;var Bm="SelectItem",[Fm,Wm]=sm(Bm),zm=s.forwardRef((e,n)=>{const{__scopeSelect:r,value:i,disabled:o=!1,textValue:a,...l}=e,c=um(Bm,r),u=Em(Bm,r),h=c.value===i,[d,f]=s.useState(a??""),[p,m]=s.useState(!1),g=Je(n,e=>u.itemRefCallback?.(e,i,o)),v=Et(),b=s.useRef("touch"),y=()=>{o||(c.onValueChange(i),c.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 t.jsx(Fm,{scope:r,value:i,disabled:o,textId:v,isSelected:h,onItemTextChange:s.useCallback(e=>{f(t=>t||(e?.textContent??"").trim())},[]),children:t.jsx(rm.ItemSlot,{scope:r,value:i,disabled:o,textValue:d,children:t.jsx(lp.div,{role:"option","aria-labelledby":v,"data-highlighted":p?"":void 0,"aria-selected":h&&p,"data-state":h?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...l,ref:g,onFocus:bt(l.onFocus,()=>m(!0)),onBlur:bt(l.onBlur,()=>m(!1)),onClick:bt(l.onClick,()=>{"mouse"!==b.current&&y()}),onPointerUp:bt(l.onPointerUp,()=>{"mouse"===b.current&&y()}),onPointerDown:bt(l.onPointerDown,e=>{b.current=e.pointerType}),onPointerMove:bt(l.onPointerMove,e=>{b.current=e.pointerType,o?u.onItemLeave?.():"mouse"===b.current&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:bt(l.onPointerLeave,e=>{e.currentTarget===document.activeElement&&u.onItemLeave?.()}),onKeyDown:bt(l.onKeyDown,e=>{""!==u.searchRef?.current&&" "===e.key||(tm.includes(e.key)&&y()," "===e.key&&e.preventDefault())})})})})});zm.displayName=Bm;var Hm="SelectItemText",Vm=s.forwardRef((e,n)=>{const{__scopeSelect:r,className:i,style:o,...l}=e,c=um(Hm,r),u=Em(Hm,r),h=Wm(Hm,r),d=dm(Hm,r),[f,p]=s.useState(null),m=Je(n,e=>p(e),h.onItemTextChange,e=>u.itemTextRefCallback?.(e,h.value,h.disabled)),g=f?.textContent,v=s.useMemo(()=>t.jsx("option",{value:h.value,disabled:h.disabled,children:g},h.value),[h.disabled,h.value,g]),{onNativeOptionAdd:b,onNativeOptionRemove:y}=d;return xt(()=>(b(v),()=>y(v)),[b,y,v]),t.jsxs(t.Fragment,{children:[t.jsx(lp.span,{id:h.textId,...l,ref:m}),h.isSelected&&c.valueNode&&!c.valueNodeHasChildren?a.createPortal(l.children,c.valueNode):null]})});Vm.displayName=Hm;var qm="SelectItemIndicator",Um=s.forwardRef((e,n)=>{const{__scopeSelect:r,...i}=e;return Wm(qm,r).isSelected?t.jsx(lp.span,{"aria-hidden":!0,...i,ref:n}):null});Um.displayName=qm;var $m="SelectScrollUpButton",Km=s.forwardRef((e,n)=>{const r=Em($m,e.__scopeSelect),i=Tm($m,e.__scopeSelect),[o,a]=s.useState(!1),l=Je(n,i.onScrollButtonChange);return xt(()=>{if(r.viewport&&r.isPositioned){let e=function(){const e=t.scrollTop>0;a(e)};const t=r.viewport;return e(),t.addEventListener("scroll",e),()=>t.removeEventListener("scroll",e)}},[r.viewport,r.isPositioned]),o?t.jsx(Xm,{...e,ref:l,onAutoScroll:()=>{const{viewport:e,selectedItem:t}=r;e&&t&&(e.scrollTop=e.scrollTop-t.offsetHeight)}}):null});Km.displayName=$m;var Ym="SelectScrollDownButton",Gm=s.forwardRef((e,n)=>{const r=Em(Ym,e.__scopeSelect),i=Tm(Ym,e.__scopeSelect),[o,a]=s.useState(!1),l=Je(n,i.onScrollButtonChange);return xt(()=>{if(r.viewport&&r.isPositioned){let e=function(){const e=t.scrollHeight-t.clientHeight,n=Math.ceil(t.scrollTop)<e;a(n)};const t=r.viewport;return e(),t.addEventListener("scroll",e),()=>t.removeEventListener("scroll",e)}},[r.viewport,r.isPositioned]),o?t.jsx(Xm,{...e,ref:l,onAutoScroll:()=>{const{viewport:e,selectedItem:t}=r;e&&t&&(e.scrollTop=e.scrollTop+t.offsetHeight)}}):null});Gm.displayName=Ym;var Xm=s.forwardRef((e,n)=>{const{__scopeSelect:r,onAutoScroll:i,...o}=e,a=Em("SelectScrollButton",r),l=s.useRef(null),c=im(r),u=s.useCallback(()=>{null!==l.current&&(window.clearInterval(l.current),l.current=null)},[]);return s.useEffect(()=>()=>u(),[u]),xt(()=>{const e=c().find(e=>e.ref.current===document.activeElement);e?.ref.current?.scrollIntoView({block:"nearest"})},[c]),t.jsx(lp.div,{"aria-hidden":!0,...o,ref:n,style:{flexShrink:0,...o.style},onPointerDown:bt(o.onPointerDown,()=>{null===l.current&&(l.current=window.setInterval(i,50))}),onPointerMove:bt(o.onPointerMove,()=>{a.onItemLeave?.(),null===l.current&&(l.current=window.setInterval(i,50))}),onPointerLeave:bt(o.onPointerLeave,()=>{u()})})}),Jm=s.forwardRef((e,n)=>{const{__scopeSelect:r,...i}=e;return t.jsx(lp.div,{"aria-hidden":!0,...i,ref:n})});Jm.displayName="SelectSeparator";var Qm="SelectArrow";s.forwardRef((e,n)=>{const{__scopeSelect:r,...i}=e,o=lm(r),s=um(Qm,r),a=Em(Qm,r);return s.open&&"popper"===a.position?t.jsx(Xp,{...o,...i,ref:n}):null}).displayName=Qm;var Zm=s.forwardRef(({__scopeSelect:e,value:n,...r},i)=>{const o=s.useRef(null),a=Je(i,o),l=Qp(n);return s.useEffect(()=>{const e=o.current;if(!e)return;const t=window.HTMLSelectElement.prototype,r=Object.getOwnPropertyDescriptor(t,"value").set;if(l!==n&&r){const t=new Event("change",{bubbles:!0});r.call(e,n),e.dispatchEvent(t)}},[l,n]),t.jsx(lp.select,{...r,style:{...Zp,...r.style},ref:a,defaultValue:n})});function eg(e){return""===e||void 0===e}function tg(e){const t=Dt(e),n=s.useRef(""),r=s.useRef(0),i=s.useCallback(e=>{const i=n.current+e;t(i),function e(t){n.current=t,window.clearTimeout(r.current),""!==t&&(r.current=window.setTimeout(()=>e(""),1e3))}(i)},[t]),o=s.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return s.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,o]}function ng(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}Zm.displayName="SelectBubbleInput";var rg=mm,ig=bm,og=ym,sg=xm,ag=Dm,lg=jm,cg=zm,ug=Vm,hg=Um,dg=Km,fg=Gm,pg=Jm,mg=fm,gg=vm,vg=s.forwardRef(function(e,t){var n=e.className,r=e.children,i=w(e,["className","children"]);return s.createElement(rg,Object.assign({ref:t,className:Ke("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",n)},i),r,s.createElement(ig,{asChild:!0},s.createElement(O,{className:"h-4 w-4 opacity-50"})))});vg.displayName=rg.displayName;var bg=s.forwardRef(function(e,t){var n=e.className,r=w(e,["className"]);return s.createElement(dg,Object.assign({ref:t,className:Ke("flex cursor-default items-center justify-center py-1",n)},r),s.createElement(T,{className:"h-4 w-4"}))});bg.displayName=dg.displayName;var yg=s.forwardRef(function(e,t){var n=e.className,r=w(e,["className"]);return s.createElement(fg,Object.assign({ref:t,className:Ke("flex cursor-default items-center justify-center py-1",n)},r),s.createElement(O,{className:"h-4 w-4"}))});yg.displayName=fg.displayName;var wg=s.forwardRef(function(e,t){var n=e.className,r=e.children,i=e.position,o=void 0===i?"popper":i,a=w(e,["className","children","position"]);return s.createElement(og,null,s.createElement(sg,Object.assign({ref:t,className:Ke("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"===o&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",n),position:o},a),s.createElement(bg,null),s.createElement(ag,{className:Ke("p-1","popper"===o&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]")},r),s.createElement(yg,null)))});wg.displayName=sg.displayName;var xg=s.forwardRef(function(e,t){var n=e.className,r=w(e,["className"]);return s.createElement(lg,Object.assign({ref:t,className:Ke("py-1.5 pl-8 pr-2 text-sm font-semibold",n)},r))});xg.displayName=lg.displayName;var kg=s.forwardRef(function(e,t){var n=e.className,r=e.children,i=w(e,["className","children"]);return s.createElement(cg,Object.assign({ref:t,className:Ke("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",n)},i),s.createElement("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center"},s.createElement(hg,null,s.createElement(N,{className:"h-4 w-4"}))),s.createElement(ug,null,r))});kg.displayName=cg.displayName;var Sg=s.forwardRef(function(e,t){var n=e.className,r=w(e,["className"]);return s.createElement(pg,Object.assign({ref:t,className:Ke("-mx-1 my-1 h-px bg-muted",n)},r))});function Eg(e){const t=s.forwardRef((e,t)=>{const{children:n,...r}=e;if(s.isValidElement(n)){const e=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}(n),i=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}}(r,n.props);return n.type!==s.Fragment&&(i.ref=t?Xe(t,e):e),s.cloneElement(n,i)}return s.Children.count(n)>1?s.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}Sg.displayName=pg.displayName;var Cg=Symbol("radix.slottable");function Ng(e){return s.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===Cg}var Og=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,n)=>{const r=function(e){const n=Eg(e),r=s.forwardRef((e,r)=>{const{children:i,...o}=e,a=s.Children.toArray(i),l=a.find(Ng);if(l){const e=l.props.children,i=a.map(t=>t===l?s.Children.count(e)>1?s.Children.only(null):s.isValidElement(e)?e.props.children:null:t);return t.jsx(n,{...o,ref:r,children:s.isValidElement(e)?s.cloneElement(e,void 0,i):null})}return t.jsx(n,{...o,ref:r,children:i})});return r.displayName=`${e}.Slot`,r}(`Primitive.${n}`),i=s.forwardRef((e,i)=>{const{asChild:o,...s}=e,a=o?r:n;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),t.jsx(a,{...s,ref:i})});return i.displayName=`Primitive.${n}`,{...e,[n]:i}},{}),Ag="Switch",[Mg,Tg]=yt(Ag),[Rg,Dg]=Mg(Ag),Pg=s.forwardRef((e,n)=>{const{__scopeSwitch:r,name:i,checked:o,defaultChecked:a,required:l,disabled:c,value:u="on",onCheckedChange:h,form:d,...f}=e,[p,m]=s.useState(null),g=Je(n,e=>m(e)),v=s.useRef(!1),b=!p||(d||!!p.closest("form")),[y,w]=Nt({prop:o,defaultProp:a??!1,onChange:h,caller:Ag});return t.jsxs(Rg,{scope:r,checked:y,disabled:c,children:[t.jsx(Og.button,{type:"button",role:"switch","aria-checked":y,"aria-required":l,"data-state":jg(y),"data-disabled":c?"":void 0,disabled:c,value:u,...f,ref:g,onClick:bt(e.onClick,e=>{w(e=>!e),b&&(v.current=e.isPropagationStopped(),v.current||e.stopPropagation())})}),b&&t.jsx(_g,{control:p,bubbles:!v.current,name:i,value:u,checked:y,required:l,disabled:c,form:d,style:{transform:"translateX(-100%)"}})]})});Pg.displayName=Ag;var Lg="SwitchThumb",Ig=s.forwardRef((e,n)=>{const{__scopeSwitch:r,...i}=e,o=Dg(Lg,r);return t.jsx(Og.span,{"data-state":jg(o.checked),"data-disabled":o.disabled?"":void 0,...i,ref:n})});Ig.displayName=Lg;var _g=s.forwardRef(({__scopeSwitch:e,control:n,checked:r,bubbles:i=!0,...o},a)=>{const l=s.useRef(null),c=Je(l,a),u=Qp(r),h=Qo(n);return s.useEffect(()=>{const e=l.current;if(!e)return;const t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,"checked").set;if(u!==r&&n){const t=new Event("click",{bubbles:i});n.call(e,r),e.dispatchEvent(t)}},[u,r,i]),t.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:r,...o,tabIndex:-1,ref:c,style:{...o.style,...h,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});function jg(e){return e?"checked":"unchecked"}_g.displayName="SwitchBubbleInput";var Bg=Pg,Fg=Ig,Wg=s.forwardRef(function(e,t){var n=e.className,r=w(e,["className"]);return s.createElement(Bg,Object.assign({className:Ke("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",n)},r,{ref:t}),s.createElement(Fg,{className:Ke("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")}))});Wg.displayName=Bg.displayName;var zg=s.forwardRef(function(e,t){var n=e.className,r=w(e,["className"]);return s.createElement("textarea",Object.assign({className:Ke("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",n),ref:t},r))});zg.displayName="Textarea";var Hg=Rr,Vg=Dr,qg=Pr,Ug=s.forwardRef(function(e,t){var n=e.className,r=w(e,["className"]);return s.createElement(Lr,Object.assign({ref:t,className:Ke("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",n)},r))});Ug.displayName=Lr.displayName;var $g=s.forwardRef(function(e,t){var n=e.className,r=e.children,i=w(e,["className","children"]);return s.createElement(qg,null,s.createElement(Ug,null),s.createElement(Ir,Object.assign({ref:t,className:Ke("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]",n)},i),r,s.createElement(Br,{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"},s.createElement(Q,{className:"h-4 w-4"}),s.createElement("span",{className:"sr-only"},"Close"))))});$g.displayName=Ir.displayName;var Kg=function(e){var t=e.className,n=w(e,["className"]);return s.createElement("div",Object.assign({className:Ke("flex flex-col space-y-1.5 text-center sm:text-left",t)},n))};Kg.displayName="DialogHeader";var Yg=function(e){var t=e.className,n=w(e,["className"]);return s.createElement("div",Object.assign({className:Ke("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t)},n))};Yg.displayName="DialogFooter";var Gg=s.forwardRef(function(e,t){var n=e.className,r=w(e,["className"]);return s.createElement(_r,Object.assign({ref:t,className:Ke("text-lg font-semibold leading-none tracking-tight",n)},r))});Gg.displayName=_r.displayName;var Xg,Jg=s.forwardRef(function(e,t){var n=e.className,r=w(e,["className"]);return s.createElement(jr,Object.assign({ref:t,className:Ke("text-sm text-muted-foreground",n)},r))});function Qg(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(Zg(t)){do{r++,i+=String.fromCharCode(t),t=e.charCodeAt(r)}while(Zg(t));return s=15}if(ev(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(ev(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&&!ev(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++,ev(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||!tv(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&&tv(e.charCodeAt(r));)r++;if(r<e.length&&46===e.charCodeAt(r)){if(r++,!(r<e.length&&tv(e.charCodeAt(r))))return h=3,e.substring(t,r);for(r++;r<e.length&&tv(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&&tv(e.charCodeAt(r))){for(r++;r<e.length&&tv(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(Zg(e)||ev(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 Zg(e){return 32===e||9===e}function ev(e){return 10===e||13===e}function tv(e){return e>=48&&e<=57}Jg.displayName=jr.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"}(Xg||(Xg={}));const nv=new Array(20).fill(0).map((e,t)=>" ".repeat(t)),rv=200,iv={" ":{"\n":new Array(rv).fill(0).map((e,t)=>"\n"+" ".repeat(t)),"\r":new Array(rv).fill(0).map((e,t)=>"\r"+" ".repeat(t)),"\r\n":new Array(rv).fill(0).map((e,t)=>"\r\n"+" ".repeat(t))},"\t":{"\n":new Array(rv).fill(0).map((e,t)=>"\n"+"\t".repeat(t)),"\r":new Array(rv).fill(0).map((e,t)=>"\r"+"\t".repeat(t)),"\r\n":new Array(rv).fill(0).map((e,t)=>"\r\n"+"\t".repeat(t))}},ov=["\n","\r","\r\n"];function sv(e,t,n){let r,i,o,s,a;if(t){for(s=t.offset,a=s+t.length,o=s;o>0&&!lv(e,o-1);)o--;let l=a;for(;l<e.length&&!lv(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===nv[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=ov.includes(l);let u,h=0,d=0;u=n.insertSpaces?nv[n.tabSize||4]??av(nv[1],n.tabSize||4):"\t";const f="\t"===u?"\t":" ";let p=Qg(i,!1),m=!1;function g(){if(h>1)return av(l,h)+av(u,r+d);const e=u.length*(r+d);return!c||e>iv[f][l].length?l+av(u,r+d):e<=0?l:iv[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(av(l,h),0,0),17!==w){let e=p.getTokenOffset()+o;y(u.length*r<20&&n.insertSpaces?nv[u.length*r]:av(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(nv[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=nv[1]);else if(4===t)3!==w&&d--,n.keepLines&&h>0||!n.keepLines&&3!==w?r=g():n.keepLines&&(r=nv[1]);else{switch(w){case 3:case 1:d++,r=n.keepLines&&h>0||!n.keepLines?g():nv[1];break;case 5:r=n.keepLines&&h>0||!n.keepLines?g():nv[1];break;case 12:r=g();break;case 13:h>0?r=g():i||(r=nv[1]);break;case 6:n.keepLines&&h>0?r=g():i||(r=nv[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=nv[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 av(e,t){let n="";for(let r=0;r<t;r++)n+=e;return n}function lv(e,t){return-1!=="\r\n".indexOf(e.charAt(t))}var cv,uv,hv;!function(e){e.DEFAULT={allowTrailingComma:!1}}(cv||(cv={})),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"}(uv||(uv={})),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"}(hv||(hv={}));const dv=function(e,t=[],n=cv.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=cv.DEFAULT){const r=Qg(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 fv;function pv(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 mv(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=dv(t,n,{allowTrailingComma:!0,disallowComments:!1});return n.length?{ok:!1,message:pv(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 gv(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,n=(e||"").toString(),r=[];if(dv(n,r,{allowTrailingComma:!0,disallowComments:!1}),r.length)return{ok:!1,message:pv(n,r)};for(var i=function(e,t,n){return sv(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 vv(){return vv=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},vv.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"}(fv||(fv={}));let bv=[],yv=[];function wv(e){if(e<768)return!1;for(let t=0,n=bv.length;;){let r=t+n>>1;if(e<bv[r])n=r;else{if(!(e>=yv[r]))return!0;t=r+1}if(t==n)return!1}}function xv(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?yv:bv).push(n+=e[t])})();function kv(e,t,n=!0,r=!0){return(n?Sv:Ev)(e,t,r)}function Sv(e,t,n){if(t==e.length)return t;t&&Nv(e.charCodeAt(t))&&Ov(e.charCodeAt(t-1))&&t--;let r=Cv(e,t);for(t+=Av(r);t<e.length;){let i=Cv(e,t);if(8205==r||8205==i||n&&wv(i))t+=Av(i),r=i;else{if(!xv(i))break;{let n=0,r=t-2;for(;r>=0&&xv(Cv(e,r));)n++,r-=2;if(n%2==0)break;t+=2}}}return t}function Ev(e,t,n){for(;t>0;){let r=Sv(e,t-2,n);if(r<t)return r;t--}return 0}function Cv(e,t){let n=e.charCodeAt(t);if(!Ov(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return Nv(r)?r-56320+(n-55296<<10)+65536:n}function Nv(e){return e>=56320&&e<57344}function Ov(e){return e>=55296&&e<56320}function Av(e){return e<65536?1:2}class Mv{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]=Bv(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),Rv.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]=Bv(this,e,t);let n=[];return this.decompose(e,t,n,0),Rv.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 Lv(this),i=new Lv(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 Lv(this,e)}iterRange(e,t=this.length){return new Iv(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 _v(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 Tv(e):Rv.from(Tv.split(e,[])):Mv.empty}}class Tv extends Mv{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 jv(r,s,n,o);r=s+1,n++}}decompose(e,t,n,r){let i=e<=0&&t>=this.length?this:new Tv(Pv(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(1&r){let e=n.pop(),t=Dv(i.text,e.text.slice(),0,i.length);if(t.length<=32)n.push(new Tv(t,e.length+i.length));else{let e=t.length>>1;n.push(new Tv(t.slice(0,e)),new Tv(t.slice(e)))}}else n.push(i)}replace(e,t,n){if(!(n instanceof Tv))return super.replace(e,t,n);[e,t]=Bv(this,e,t);let r=Dv(this.text,Dv(n.text,Pv(this.text,0,e)),t),i=this.length+n.length-(t-e);return r.length<=32?new Tv(r,i):Rv.from(Tv.split(r,[]),i)}sliceString(e,t=this.length,n="\n"){[e,t]=Bv(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 Tv(n,r)),n=[],r=-1);return r>-1&&t.push(new Tv(n,r)),t}}class Rv extends Mv{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]=Bv(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 Rv(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]=Bv(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 Rv))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 Tv(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 Rv)for(let t of e.children)u(t);else e.lines>o&&(a>o||!a)?(h(),s.push(e)):e instanceof Tv&&a&&(t=c[c.length-1])instanceof Tv&&e.lines+t.lines<=32?(a+=e.lines,l+=e.length+1,c[c.length-1]=new Tv(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]:Rv.from(c,l)),l=-1,a=c.length=0)}for(let t of e)u(t);return h(),1==s.length?s[0]:new Rv(s,t)}}function Dv(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 Pv(e,t,n){return Dv(e,[""],t,n)}Mv.empty=new Tv([""],0);class Lv{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 Tv?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 Tv?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 Tv){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 Tv?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 Iv{constructor(e,t,n){this.value="",this.done=!1,this.cursor=new Lv(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 _v{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&&(Mv.prototype[Symbol.iterator]=function(){return this.iter()},Lv.prototype[Symbol.iterator]=Iv.prototype[Symbol.iterator]=_v.prototype[Symbol.iterator]=function(){return this});class jv{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 Bv(e,t,n){return[t=Math.max(0,Math.min(e.length,t)),Math.max(t,Math.min(e.length,n))]}function Fv(e,t,n=!0,r=!0){return kv(e,t,n,r)}function Wv(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 zv(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode(55296+(e>>10),56320+(1023&e)))}function Hv(e){return e<65536?1:2}const Vv=/\r\n?|\n/;var qv=function(e){return e[e.Simple=0]="Simple",e[e.TrackDel=1]="TrackDel",e[e.TrackBefore=2]="TrackBefore",e[e.TrackAfter=3]="TrackAfter",e}(qv||(qv={}));class Uv{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){Gv(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 Uv(e)}composeDesc(e){return this.empty?e:e.empty?this:Jv(this,e)}mapDesc(e,t=!1){return e.empty?this:Xv(this,e,t)}mapPos(e,t=-1,n=qv.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!=qv.Simple&&l>=e&&(n==qv.TrackDel&&r<e&&l>e||n==qv.TrackBefore&&r<e||n==qv.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 Uv(e)}static create(e){return new Uv(e)}}class $v extends Uv{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 Gv(this,(t,n,r,i,o)=>e=e.replace(r,r+(n-t),o),!1),e}mapDesc(e,t=!1){return Xv(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(Mv.empty);n.push(o?e.slice(i,i+o):Mv.empty)}i+=o}return new $v(t,n)}compose(e){return this.empty?e:e.empty?this:Jv(this,e,!0)}map(e,t=!1){return e.empty?this:Xv(this,e,t,!0)}iterChanges(e,t=!1){Gv(this,e,t)}get desc(){return Uv.create(this.sections)}filter(e){let t=[],n=[],r=[],i=new Qv(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);Kv(r,e,-1);let o=-1==i.ins?-1:0==i.off?i.ins:0;Kv(t,e,o),o>0&&Yv(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);Kv(t,e,-1),Kv(r,e,-1==i.ins?-1:0==i.off?i.ins:0),i.forward(e),s+=e}}return{changes:new $v(t,n),filtered:Uv.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&&Kv(r,t-o,-1);let n=new $v(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 $v){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?Mv.of(c.split(n||Vv)):c:Mv.empty,h=u.length;if(e==s&&0==h)return;e<o&&a(),e>o&&Kv(r,e-o,-1),Kv(r,s-e,h),Yv(i,r,u),o=s}}(e),a(!s),s}static empty(e){return new $v(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(Mv.empty);n[r]=Mv.of(i.slice(1)),t.push(i[0],n[r].length)}}}return new $v(t,n)}static createSet(e,t){return new $v(e,t)}}function Kv(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 Yv(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(Mv.empty);e.push(n)}}function Gv(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=Mv.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 Xv(e,t,n,r=!1){let i=[],o=r?[]:null,s=new Qv(e),a=new Qv(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);Kv(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(Kv(i,a.ins,-1);t;){let n=Math.min(s.len,t);s.ins>=0&&e<s.i&&s.len<=n&&(Kv(i,0,s.ins),o&&Yv(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?$v.createSet(i,o):Uv.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()}Kv(i,t,e<s.i?s.ins:0),o&&e<s.i&&Yv(o,i,s.text),e=s.i,s.forward(s.len-n)}}}}function Jv(e,t,n=!1){let r=[],i=n?[]:null,o=new Qv(e),s=new Qv(t);for(let e=!1;;){if(o.done&&s.done)return i?$v.createSet(r,i):Uv.create(r);if(0==o.ins)Kv(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;Kv(r,t,n,e),i&&n&&Yv(i,r,s.text)}else-1==s.ins?(Kv(r,o.off?0:o.len,t,e),i&&Yv(i,r,o.textBit(t))):(Kv(r,o.off?0:o.len,s.off?0:s.ins,e),i&&!s.off&&Yv(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 Kv(r,0,s.ins,e),i&&Yv(i,r,s.text),s.next()}}class Qv{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?Mv.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?Mv.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 Zv{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 Zv(n,r,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return eb.range(e,t);let n=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return eb.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 eb.range(e.anchor,e.head)}static create(e,t,n){return new Zv(e,t,n)}}class eb{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:eb.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 eb([this.main],0)}addRange(e,t=!0){return eb.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let n=this.ranges.slice();return n[t]=e,eb.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 eb(e.ranges.map(e=>Zv.fromJSON(e)),e.main)}static single(e,t=e){return new eb([eb.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 eb.normalized(e.slice(),t);n=i.to}return new eb(e,t)}static cursor(e,t=0,n,r){return Zv.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?Zv.create(t,e,48|i):Zv.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?eb.range(s,o):eb.range(o,s))}}return new eb(e,t)}}function tb(e,t){for(let n of e.ranges)if(n.to>t)throw new RangeError("Selection points outside of document")}let nb=0;class rb{constructor(e,t,n,r,i){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=r,this.id=nb++,this.default=e([]),this.extensions="function"==typeof i?i(this):i}get reader(){return this}static define(e={}){return new rb(e.combine||(e=>e),e.compareInput||((e,t)=>e===t),e.compare||(e.combine?(e,t)=>e===t:ib),!!e.static,e.enables)}of(e){return new ob([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new ob(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new ob(e,this,2,t)}from(e,t){return t||(t=e=>e),this.compute([e],n=>t(n.field(e)))}}function ib(e,t){return e==t||e.length==t.length&&e.every((e,n)=>e===t[n])}class ob{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=nb++}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)||ab(e,c)){let t=n(e);if(s?!sb(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=kb(t,l);if(this.dependencies.every(n=>n instanceof rb?t.facet(n)===e.facet(n):!(n instanceof ub)||t.field(n,!1)==e.field(n,!1))||(s?sb(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 sb(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 ab(e,t){let n=!1;for(let r of t)1&xb(e,r)&&(n=!0);return n}function lb(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=kb(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)xb(e,t);return e.values[s]=a(e),1},update(e,n){if(!ab(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=ab(e,r),l=i.config.facets[t.id],c=i.facet(t);if(l&&!o&&ib(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 cb=rb.define({static:!0});class ub{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 ub(nb++,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(cb).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(cb),o=n.facet(cb);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,cb.of({field:this,create:e})]}get extension(){return this}}const hb=4,db=3,fb=2,pb=1;function mb(e){return t=>new vb(t,e)}const gb={highest:mb(0),high:mb(pb),default:mb(fb),low:mb(db),lowest:mb(hb)};class vb{constructor(e,t){this.inner=e,this.prec=t}}class bb{of(e){return new yb(this,e)}reconfigure(e){return bb.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class yb{constructor(e,t){this.compartment=e,this.inner=t}}class wb{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 yb&&n.delete(e.compartment)}if(i.set(e,s),Array.isArray(e))for(let t of e)o(t,s);else if(e instanceof yb){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 vb)o(e.inner,e.prec);else if(e instanceof ub)r[s].push(e),e.provides&&o(e.provides,s);else if(e instanceof ob)r[s].push(e),e.facet.extensions&&o(e.facet.extensions,fb);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,fb),r.reduce((e,t)=>e.concat(t))}(e,t,o))n instanceof ub?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,ib(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=>lb(e,r,t))}}let u=l.map(e=>e(s));return new wb(e,o,u,s,a,i)}}function xb(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 kb(e,t){return 1&t?e.config.staticValues[t>>1]:e.values[t>>1]}const Sb=rb.define(),Eb=rb.define({combine:e=>e.some(e=>e),static:!0}),Cb=rb.define({combine:e=>e.length?e[0]:void 0,static:!0}),Nb=rb.define(),Ob=rb.define(),Ab=rb.define(),Mb=rb.define({combine:e=>!!e.length&&e[0]});class Tb{constructor(e,t){this.type=e,this.value=t}static define(){return new Rb}}class Rb{of(e){return new Tb(this,e)}}class Db{constructor(e){this.map=e}of(e){return new Pb(this,e)}}class Pb{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 Pb(this.type,t)}is(e){return this.type==e}static define(e={}){return new Db(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}}Pb.reconfigure=Pb.define(),Pb.appendConfig=Pb.define();class Lb{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&&tb(n,t.newLength),i.some(e=>e.type==Lb.time)||(this.annotations=i.concat(Lb.time.of(Date.now())))}static create(e,t,n,r,i,o){return new Lb(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(Lb.userEvent);return!(!t||!(t==e||t.length>e.length&&t.slice(0,e.length)==e&&"."==t[e.length]))}}function Ib(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 _b(e,t,n){var r;let i,o,s;return n?(i=t.changes,o=$v.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:Pb.mapEffects(e.effects,i).concat(Pb.mapEffects(t.effects,o)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function jb(e,t,n){let r=t.selection,i=Wb(t.annotations);return t.userEvent&&(i=i.concat(Lb.userEvent.of(t.userEvent))),{changes:t.changes instanceof $v?t.changes:$v.of(t.changes||[],n,e.facet(Cb)),selection:r&&(r instanceof eb?r:eb.single(r.anchor,r.head)),effects:Wb(t.effects),annotations:i,scrollIntoView:!!t.scrollIntoView}}function Bb(e,t,n){let r=jb(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=_b(r,jb(e,t[i],o?r.changes.newLength:e.doc.length),o)}let i=Lb.create(e,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return function(e){let t=e.startState,n=t.facet(Ab),r=e;for(let i=n.length-1;i>=0;i--){let o=n[i](e);o&&Object.keys(o).length&&(r=_b(r,jb(t,o,e.changes.newLength),!0))}return r==e?e:Lb.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(Nb)){let t=r(e);if(!1===t){n=!1;break}Array.isArray(t)&&(n=!0===n?t:Ib(n,t))}if(!0!==n){let r,i;if(!1===n)i=e.changes.invertedDesc,r=$v.empty(t.doc.length);else{let t=e.changes.filter(n);r=t.changes,i=t.filtered.mapDesc(t.changes).invertedDesc}e=Lb.create(t,r,e.selection&&e.selection.map(i),Pb.mapEffects(e.effects,i),e.annotations,e.scrollIntoView)}let r=t.facet(Ob);for(let n=r.length-1;n>=0;n--){let i=r[n](e);e=i instanceof Lb?i:Array.isArray(i)&&1==i.length&&i[0]instanceof Lb?i[0]:Bb(t,Wb(i),!1)}return e}(i):i)}Lb.time=Tb.define(),Lb.userEvent=Tb.define(),Lb.addToHistory=Tb.define(),Lb.remote=Tb.define();const Fb=[];function Wb(e){return null==e?Fb:Array.isArray(e)?e:[e]}var zb=function(e){return e[e.Word=0]="Word",e[e.Space=1]="Space",e[e.Other=2]="Other",e}(zb||(zb={}));const Hb=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Vb;try{Vb=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(e){}function qb(e){return t=>{if(!/\S/.test(t))return zb.Space;if(function(e){if(Vb)return Vb.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>"€"&&(n.toUpperCase()!=n.toLowerCase()||Hb.test(n)))return!0}return!1}(t))return zb.Word;for(let n=0;n<e.length;n++)if(t.indexOf(e[n])>-1)return zb.Word;return zb.Other}}class Ub{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++)xb(this,e<<1);this.computeSlot=null}field(e,t=!0){let n=this.config.address[e.id];if(null!=n)return xb(this,n),kb(this,n);if(t)throw new RangeError("Field is not present in this state")}update(...e){return Bb(this,e,!0)}applyTransaction(e){let t,n=this.config,{base:r,compartments:i}=n;for(let t of e.effects)t.is(bb.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(Pb.reconfigure)?(n=null,r=t.value):t.is(Pb.appendConfig)&&(n=null,r=Wb(r).concat(t.value));if(n)t=e.startState.values.slice();else{n=wb.resolve(r,i,this);let e=new Ub(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(e,t)=>t.reconfigure(e,this),null);t=e.values}let o=e.startState.facet(Eb)?e.newSelection:e.newSelection.asSingle();new Ub(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:eb.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=Wb(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=Pb.mapEffects(o,l).concat(Pb.mapEffects(Wb(s.effects),c))}return{changes:r,selection:eb.create(i,t.mainIndex),effects:o}}changes(e=[]){return e instanceof $v?e:$v.of(e,this.doc.length,this.facet(Ub.lineSeparator))}toText(e){return Mv.of(e.split(this.facet(Ub.lineSeparator)||Vv))}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:(xb(this,t),kb(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 ub&&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 Ub.create({doc:e.doc,selection:eb.fromJSON(e.selection),extensions:t.extensions?r.concat([t.extensions]):r})}static create(e={}){let t=wb.resolve(e.extensions||[],new Map),n=e.doc instanceof Mv?e.doc:Mv.of((e.doc||"").split(t.staticFacet(Ub.lineSeparator)||Vv)),r=e.selection?e.selection instanceof eb?e.selection:eb.single(e.selection.anchor,e.selection.head):eb.single(0);return tb(r,n.length),t.staticFacet(Eb)||(r=r.asSingle()),new Ub(t,n,r,t.dynamicSlots.map(()=>null),(e,t)=>t.create(e),null)}get tabSize(){return this.facet(Ub.tabSize)}get lineBreak(){return this.facet(Ub.lineSeparator)||"\n"}get readOnly(){return this.facet(Mb)}phrase(e,...t){for(let t of this.facet(Ub.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(Sb))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 qb(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=Fv(t,o,!1);if(i(t.slice(e,o))!=zb.Word)break;o=e}for(;s<r;){let e=Fv(t,s);if(i(t.slice(s,e))!=zb.Word)break;s=e}return o==s?null:eb.range(o+n,s+n)}}function $b(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}Ub.allowMultipleSelections=Eb,Ub.tabSize=rb.define({combine:e=>e.length?e[0]:4}),Ub.lineSeparator=Cb,Ub.readOnly=Mb,Ub.phrases=rb.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])}}),Ub.languageData=Sb,Ub.changeFilter=Nb,Ub.transactionFilter=Ob,Ub.transactionExtender=Ab,bb.reconfigure=Pb.define();class Kb{eq(e){return this==e}range(e,t=e){return Gb.create(e,t,this)}}function Yb(e,t){return e==t||e.constructor==t.constructor&&e.eq(t)}Kb.prototype.startSide=Kb.prototype.endSide=0,Kb.prototype.point=!1,Kb.prototype.mapMode=qv.TrackDel;let Gb=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 Xb(e,t){return e.from-t.from||e.value.startSide-t.value.startSide}class Jb{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 Jb(r,i,n,s):null,pos:o}}}class Qb{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 Qb(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(Xb)),this.isEmpty)return t.length?Qb.of(t):this;let s=new ty(this,null,-1).goto(0),a=0,l=[],c=new Zb;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(Gb.create(s.from,s.to,s.value))),s.next());return c.finishInner(this.nextLayer.isEmpty&&!l.length?Qb.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 Qb(n,t,i||Qb.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 ny.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return ny.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=ey(o,s,n),l=new iy(o,a,i),c=new iy(s,a,i);n.iterGaps((e,t,n)=>oy(l,e,c,t,n,r)),n.empty&&0==n.length&&oy(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=ey(i,o),a=new iy(i,s,0).goto(n),l=new iy(o,s,0).goto(n);for(;;){if(a.to!=l.to||!sy(a.active,l.active)||a.point&&(!l.point||!Yb(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 iy(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 Zb;for(let r of e instanceof Gb?[e]:t?function(e){if(e.length>1)for(let t=e[0],n=1;n<e.length;n++){let r=e[n];if(Xb(t,r)>0)return e.slice().sort(Xb);t=r}return e}(e):e)n.add(r.from,r.to,r.value);return n.finish()}static join(e){if(!e.length)return Qb.empty;let t=e[e.length-1];for(let n=e.length-2;n>=0;n--)for(let r=e[n];r!=Qb.empty;r=r.nextLayer)t=new Qb(r.chunkPos,r.chunk,t,Math.max(r.maxPoint,t.maxPoint));return t}}Qb.empty=new Qb([],[],null,-1),Qb.empty.nextLayer=Qb.empty;class Zb{finishChunk(e){this.chunks.push(new Jb(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 Zb)).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(Qb.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return e;let t=Qb.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function ey(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 ty{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 ny{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 ty(o,t,n,i));return 1==r.length?r[0]:new ny(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--)ry(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--)ry(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(),ry(this.heap,0)}}}function ry(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 iy{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=ny.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){ay(this.active,e),ay(this.activeTo,e),ay(this.activeRank,e),this.minActive=cy(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++;ly(this.active,t,n),ly(this.activeTo,t,r),ly(this.activeRank,t,i),e&&ly(e,t,this.cursor.from),this.minActive=cy(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&&ay(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 oy(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&&Yb(e.point,n.point)&&sy(e.activeForPoint(e.to),n.activeForPoint(n.to))||o.comparePoint(a,h,e.point,n.point),t=!1):(t&&o.boundChange(a),h>a&&!sy(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 sy(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n]&&!Yb(e[n],t[n]))return!1;return!0}function ay(e,t){for(let n=t,r=e.length-1;n<r;n++)e[n]=e[n+1];e.pop()}function ly(e,t,n){for(let n=e.length-1;n>=t;n--)e[n+1]=e[n];e[t]=n}function cy(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 uy(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=Fv(e,i));return r}function hy(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=Fv(e,r)}return!0===r?-1:e.length}const dy="undefined"==typeof Symbol?"__ͼ":Symbol.for("ͼ"),fy="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),py="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class my{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=py[dy]||1;return py[dy]=e+1,"ͼ"+e.toString(36)}static mount(e,t,n){let r=e[fy],i=n&&n.nonce;r?i&&r.setNonce(i):r=new vy(e,i),r.mount(Array.isArray(t)?t:[t],e)}}let gy=new Map;class vy{constructor(e,t){let n=e.ownerDocument||e,r=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let t=gy.get(n);if(t)return e[fy]=t;this.sheet=new r.CSSStyleSheet,gy.set(n,this)}else this.styleTag=n.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[fy]=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 by={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:"'"},yy={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},wy="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),xy="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),ky=0;ky<10;ky++)by[48+ky]=by[96+ky]=String(ky);for(ky=1;ky<=24;ky++)by[ky+111]="F"+ky;for(ky=65;ky<=90;ky++)by[ky]=String.fromCharCode(ky+32),yy[ky]=String.fromCharCode(ky);for(var Sy in by)yy.hasOwnProperty(Sy)||(yy[Sy]=by[Sy]);function Ey(){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++)Cy(e,arguments[t]);return e}function Cy(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++)Cy(e,t[n])}}let Ny="undefined"!=typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},Oy="undefined"!=typeof document?document:{documentElement:{style:{}}};const Ay=/Edge\/(\d+)/.exec(Ny.userAgent),My=/MSIE \d/.test(Ny.userAgent),Ty=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ny.userAgent),Ry=!!(My||Ty||Ay),Dy=!Ry&&/gecko\/(\d+)/i.test(Ny.userAgent),Py=!Ry&&/Chrome\/(\d+)/.exec(Ny.userAgent),Ly="webkitFontSmoothing"in Oy.documentElement.style,Iy=!Ry&&/Apple Computer/.test(Ny.vendor),_y=Iy&&(/Mobile\/\w+/.test(Ny.userAgent)||Ny.maxTouchPoints>2);var jy={mac:_y||/Mac/.test(Ny.platform),windows:/Win/.test(Ny.platform),linux:/Linux|X11/.test(Ny.platform),ie:Ry,ie_version:My?Oy.documentMode||6:Ty?+Ty[1]:Ay?+Ay[1]:0,gecko:Dy,gecko_version:Dy?+(/Firefox\/(\d+)/.exec(Ny.userAgent)||[0,0])[1]:0,chrome:!!Py,chrome_version:Py?+Py[1]:0,ios:_y,android:/Android\b/.test(Ny.userAgent),webkit:Ly,webkit_version:Ly?+(/\bAppleWebKit\/(\d+)/.exec(Ny.userAgent)||[0,0])[1]:0,safari:Iy,safari_version:Iy?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Ny.userAgent)||[0,0])[1]:0,tabSize:null!=Oy.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};function By(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 Fy=Object.create(null);function Wy(e,t,n){if(e==t)return!0;e||(e=Fy),t||(t=Fy);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 zy(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 Hy(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 Vy{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 qy=function(e){return e[e.Text=0]="Text",e[e.WidgetBefore=1]="WidgetBefore",e[e.WidgetAfter=2]="WidgetAfter",e[e.WidgetRange=3]="WidgetRange",e}(qy||(qy={}));class Uy extends Kb{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 $y(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 Yy(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}=Gy(e,r);t=(i?r?-3e8:-1:5e8)-1,n=1+(o?r?2e8:1:-6e8)}return new Yy(e,t,n,r,e.widget||null,!0)}static line(e){return new Ky(e)}static set(e,t=!1){return Qb.of(e,t)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}Uy.none=Qb.empty;class $y extends Uy{constructor(e){let{start:t,end:n}=Gy(e);super(t?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?By(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||Fy}eq(e){return this==e||e instanceof $y&&this.tagName==e.tagName&&Wy(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)}}$y.prototype.point=!1;class Ky extends Uy{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof Ky&&this.spec.class==e.spec.class&&Wy(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)}}Ky.prototype.mapMode=qv.TrackBefore,Ky.prototype.point=!0;class Yy extends Uy{constructor(e,t,n,r,i,o){super(t,n,i,e),this.block=r,this.isReplace=o,this.mapMode=r?t<=0?qv.TrackBefore:qv.TrackAfter:qv.TrackDel}get type(){return this.startSide!=this.endSide?qy.WidgetRange:this.startSide<=0?qy.WidgetBefore:qy.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof Yy&&(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 Gy(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 Xy(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)}Yy.prototype.point=!0;class Jy extends Kb{constructor(e,t){super(),this.tagName=e,this.attributes=t}eq(e){return e==this||e instanceof Jy&&this.tagName==e.tagName&&Wy(this.attributes,e.attributes)}static create(e){return new Jy(e.tagName,e.attributes||Fy)}static set(e,t=!1){return Qb.of(e,t)}}function Qy(e){let t;return t=11==e.nodeType?e.getSelection?e:e.ownerDocument:e,t.getSelection()}function Zy(e,t){return!!t&&(e==t||e.contains(1!=t.nodeType?t.parentNode:t))}function ew(e,t){if(!t.anchorNode)return!1;try{return Zy(e,t.anchorNode)}catch(e){return!1}}function tw(e){return 3==e.nodeType?pw(e,0,e.nodeValue.length).getClientRects():1==e.nodeType?e.getClientRects():[]}function nw(e,t,n,r){return!!n&&(ow(e,t,n,r,-1)||ow(e,t,n,r,1))}function rw(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t}function iw(e){return 1==e.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(e.nodeName)}function ow(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:sw(e))){if("DIV"==e.nodeName)return!1;let n=e.parentNode;if(!n||1!=n.nodeType)return!1;t=rw(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?sw(e):0}}}function sw(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function aw(e,t){let n=t?e.left:e.right;return{left:n,right:n,top:e.top,bottom:e.bottom}}function lw(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 cw(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}}Jy.prototype.startSide=Jy.prototype.endSide=-1;class uw{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?sw(t):0),n,Math.min(e.focusOffset,n?sw(n):0))}set(e,t,n,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=r}}let hw,dw=null;function fw(e){if(e.setActive)return e.setActive();if(dw)return e.focus(dw);let t=[];for(let n=e;n&&(t.push(n,n.scrollTop,n.scrollLeft),n!=n.ownerDocument);n=n.parentNode);if(e.focus(null==dw?{get preventScroll(){return dw={preventScroll:!0},!0}}:void 0),!dw){dw=!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 pw(e,t,n=t){let r=hw||(hw=document.createRange());return r.setEnd(e,n),r.setStart(e,t),r}function mw(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 gw(e){return e.scrollTop>Math.max(1,e.scrollHeight-e.clientHeight-4)}function vw(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=sw(n)}else{if(!n.parentNode||iw(n))return null;r=rw(n),n=n.parentNode}}}function bw(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||iw(n))return null;r=rw(n)+1,n=n.parentNode}}}jy.safari&&jy.safari_version>=26&&(dw=!1);class yw{constructor(e,t,n=!0){this.node=e,this.offset=t,this.precise=n}static before(e,t){return new yw(e.parentNode,rw(e),t)}static after(e,t){return new yw(e.parentNode,rw(e)+1,t)}}var ww=function(e){return e[e.LTR=0]="LTR",e[e.RTL=1]="RTL",e}(ww||(ww={}));const xw=ww.LTR,kw=ww.RTL;function Sw(e){let t=[];for(let n=0;n<e.length;n++)t.push(1<<+e[n]);return t}const Ew=Sw("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),Cw=Sw("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),Nw=Object.create(null),Ow=[];for(let e of["()","[]","{}"]){let t=e.charCodeAt(0),n=e.charCodeAt(1);Nw[t]=n,Nw[n]=-t}function Aw(e){return e<=247?Ew[e]:1424<=e&&e<=1524?2:1536<=e&&e<=1785?Cw[e-1536]:1774<=e&&e<=2220?4:8192<=e&&e<=8204?256:64336<=e&&e<=65023?4:1}const Mw=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class Tw{get dir(){return this.level%2?kw:xw}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 Rw(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||!Rw(r.inner,i.inner))return!1}return!0}const Dw=[];function Pw(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=Dw[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(Dw[e]==a)break e;break}e=o[t++].to}if(c++,h)h.push(p);else{p.from>l&&s.push(new Tw(l,p.from,d)),Lw(e,p.direction==xw!=!(d%2)?r+1:r,i,p.inner,p.from,p.to,s),l=p.to}f=p.to}else{if(f==n||(t?Dw[f]!=a:Dw[f]==a))break;f++}h?Pw(e,l,f,r+1,i,h,s):l<f&&s.push(new Tw(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=Dw[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(Dw[e-1]==a)break e;break}e=o[--n].from}if(h)h.push(p);else{p.to<l&&s.push(new Tw(p.to,l,d)),Lw(e,p.direction==xw!=!(d%2)?r+1:r,i,p.inner,p.from,p.to,s),l=p.from}f=p.from}else{if(f==t||(n?Dw[f-1]!=a:Dw[f-1]==a))break;f--}h?Pw(e,f,l,r+1,i,h,s):f<l&&s.push(new Tw(f,l,d)),l=f}}function Lw(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=Aw(e.charCodeAt(t));512==i?i=n:8==i&&4==r&&(i=16),Dw[t]=4==i?2:i,7&i&&(r=i),n=i}for(let e=s,t=l,r=l;e<a;e++){let i=Dw[e];if(128==i)e<a-1&&t==Dw[e+1]&&24&t?i=Dw[e]=t:Dw[e]=256;else if(64==i){let i=e+1;for(;i<a&&64==Dw[i];)i++;let o=e&&8==t||i<n&&8==Dw[i]?1==r?1:8:256;for(let t=e;t<i;t++)Dw[t]=o;e=i-1}else 8==i&&1==r&&(Dw[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=Nw[t=e.charCodeAt(s)])if(n<0){for(let e=a-3;e>=0;e-=3)if(Ow[e+1]==-n){let t=Ow[e+2],n=2&t?i:4&t?1&t?o:i:0;n&&(Dw[s]=Dw[Ow[e]]=n),a=e;break}}else{if(189==Ow.length)break;Ow[a++]=s,Ow[a++]=t,Ow[a++]=l}else if(2==(r=Dw[s])||1==r){let e=r==i;l=e?0:1;for(let t=a-3;t>=0;t-=3){let n=Ow[t+2];if(2&n)break;if(e)Ow[t+2]|=2;else{if(4&n)break;Ow[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=Dw[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!=Dw[s])break;s++}let c=1==o,u=c==(1==(s<t?Dw[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),Dw[--t]=u;l=s}else o=s,l++}}}(i,o,r,a),Pw(e,i,o,t,n,r,s)}function Iw(e){return[new Tw(0,e,0)]}let _w="";function jw(e,t,n,r,i){var o;let s=r.head-e.from,a=Tw.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=Fv(e.text,s,l.forward(i,n));(u<l.from||u>l.to)&&(u=c),_w=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?eb.cursor(h.side(!i,n)+e.from,h.forward(i,n)?1:-1,h.level):eb.cursor(u+e.from,l.forward(i,n)?-1:1,l.level)}function Bw(e,t,n){for(let r=t;r<n;r++){let t=Aw(e.charCodeAt(r));if(1==t)return xw;if(2==t||4==t)return kw}return xw}const Fw=rb.define(),Ww=rb.define(),zw=rb.define(),Hw=rb.define(),Vw=rb.define(),qw=rb.define(),Uw=rb.define(),$w=rb.define(),Kw=rb.define(),Yw=rb.define({combine:e=>e.some(e=>e)}),Gw=rb.define({combine:e=>e.some(e=>e)}),Xw=rb.define();class Jw{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 Jw(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 Jw(eb.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const Qw=Pb.define({map:(e,t)=>e.map(t)}),Zw=Pb.define();function ex(e,t,n){let r=e.facet(Hw);r.length?r[0](t):window.onerror&&window.onerror(String(t),n,void 0,void 0,t)}const tx=rb.define({combine:e=>!e.length||e[0]});let nx=0;const rx=rb.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 ix{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(rx.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(rx.of({plugin:this,arg:e}))}static define(e,t){const{eventHandlers:n,eventObservers:r,provide:i,decorations:o}=t||{};return new ix(nx++,e,n,r,e=>{let t=[];return o&&t.push(lx.of(t=>{let n=t.plugin(e);return n?o(n):Uy.none})),i&&t.push(i(e)),t})}static fromClass(e,t){return ix.define((t,n)=>new e(t,n),t)}}class ox{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(ex(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){ex(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){ex(e.state,t,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const sx=rb.define(),ax=rb.define(),lx=rb.define(),cx=rb.define(),ux=rb.define(),hx=rb.define(),dx=rb.define();function fx(e,t){let n=e.state.facet(dx);if(!n.length)return n;let r=n.map(t=>t instanceof Function?t(e):t),i=[];return Qb.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=Bw(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 px=rb.define();function mx(e){let t=0,n=0,r=0,i=0;for(let o of e.state.facet(px)){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 gx=rb.define();class vx{constructor(e,t,n,r){this.fromA=e,this.toA=t,this.fromB=n,this.toB=r}join(e){return new vx(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 vx(c,h,l,u))}return n}}class bx{constructor(e,t,n){this.view=e,this.state=t,this.transactions=n,this.flags=0,this.startState=e.state,this.changes=$v.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 vx(e,t,n,i))),this.changedRanges=r}static create(e,t,n){return new bx(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 yx=[];class wx{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 yx}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=rw(this.dom),r=this.length?e>0:t>0;return new yw(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 Sx)return e;return null}static get(e){return e.cmTile}}class xx extends wx{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=kx(t);else n.insertBefore(s.dom,t);r=s.dom}for(t=r?r.nextSibling:n.firstChild,i&&t&&(i.written=!0);t;)t=kx(t);this.length=o}}function kx(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}class Sx extends xx{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=wx.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 Ex)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 Ex extends xx{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 Ex(t||document.createElement(e.tagName),e);return t||(n.flags|=4),n}}class Cx extends xx{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(e,t,n){let r=new Cx(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&&Nx(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=tw(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 yw(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 yw(e.dom,0);e==n.tile&&(o=!0)}}return new yw(this.dom,0)}}function Nx(e,t){let n=e.coordsIn(0,1),r=t.coordsIn(0,1);return n&&r&&r.top<n.bottom}class Ox extends xx{constructor(e,t){super(e),this.mark=t}get domAttrs(){return this.mark.attrs}static of(e,t){let n=new Ox(t||document.createElement(e.tagName),e);return t||(n.flags|=4),n}}class Ax extends wx{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?jy.chrome||jy.gecko||(e?(r--,o=1):i<n&&(i++,o=-1)):t<0?r--:i<n&&i++;let s=pw(this.dom,r,i).getClientRects();if(!s.length)return null;let a=s[(o?o<0:t>=0)?0:s.length-1];return jy.safari&&!o&&0==a.width&&(a=Array.prototype.find.call(s,e=>e.width)||a),o?aw(a,o<0):a||null}static of(e,t){let n=new Ax(t||document.createTextNode(e),e);return t||(n.flags|=2),n}}class Mx extends wx{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 aw(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 aw(n,!r)}}get overrideDOMText(){if(!this.length)return Mv.empty;let{root:e}=this;if(!e)return Mv.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 Mx(i,n,e,r)}}class Tx extends wx{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 Mv.empty}coordsIn(e){return this.dom.getBoundingClientRect()}}class Rx{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 Dx{constructor(e,t,n,r){this.from=e,this.to=t,this.wrapper=n,this.rank=r}}class Px{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||Ax.of(e,null===(i=this.cache.find(Ax))||void 0===i?void 0:i.dom));else{this.cache.reused.set(s,2),(o.children[o.children.length-1]=new Ax(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)?Wx(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 Ox&&i.mark.eq(n.mark))i.dom!=n.dom&&i.setDOM(Wx(n.dom)),r=i;else{if(this.cache.reused.get(n)){let e=wx.get(n.dom);e&&e.setDOM(Wx(n.dom))}let e=Ox.of(n.mark,n.dom);r.append(e),r=e}this.cache.reused.set(n,2)}let i=wx.get(e.text);i&&this.cache.reused.set(i,2);let o=new Ax(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=Fx);let r=Cx.start(e,t||(null===(n=this.cache.find(Cx))||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 Ox&&o.mark.eq(s))r=o,t--;else{let e=Ox.of(s,null===(n=this.cache.find(Ox,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&&Bx(this.curLine,!1)&&("BR"==e.dom.nodeName||!e.isWidget()||jy.ios&&Bx(this.curLine,!0))||this.curLine.append(this.cache.findWidget(Hx,0,32)||new Mx(Hx.toDOM(),0,Hx,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 Dx(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 Ex&&r.wrapper.eq(n.wrapper))t=r;else{let r=Ex.of(n.wrapper,null===(e=this.cache.find(Ex,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(Tx,void 0,1);return n&&(n.flags=t),n||new Tx(t)}flushBuffer(){!this.afterWidget||32&this.afterWidget.flags||(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class Lx{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 Ix=[Mx,Cx,Ax,Ox,Tx,Ex,Sx];for(let e=0;e<Ix.length;e++)Ix[e].bucket=e;class _x{constructor(e){this.view=e,this.buckets=Ix.map(()=>[]),this.index=Ix.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 Mx(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 jx{constructor(e,t,n,r,i){this.view=e,this.decorations=r,this.disallowBlockEffectsFor=i,this.openWidget=!1,this.openMarks=0,this.cache=new _x(e),this.text=new Lx(e.state.doc),this.builder=new Px(this.cache,new Sx(e,e.contentDOM),Qb.iter(n)),this.cache.reused.set(t,2),this.old=new Rx(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 Ox&&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?Mx.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 Tx)this.cache.add(e);else{if(!(e instanceof Ox))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 Ox&&r.unshift(e.mark)),this.openWidget=!1},leave:e=>{e.isLine()?r.length&&(r.length=i=0):e instanceof Ox&&(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=Qb.spans(this.decorations,e,t,{point:(e,t,o,s,a,l)=>{if(o instanceof Yy){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?zx.block:zx.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)||Mx.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&&By(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=wx.get(r);if(r==this.view.contentDOM)break;e instanceof Ox?t.push(e):(null==e?void 0:e.isLine())?n=e:"DIV"!=r.nodeName||n||r==this.view.contentDOM?t.push(Ox.of(new $y({tagName:r.nodeName.toLowerCase(),attributes:Hy(r)}),r)):n=new Cx(r,Fx)}return{line:n,marks:t}}}function Bx(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 Fx={class:"cm-line"};function Wx(e){let t=wx.get(e);return t&&t.setDOM(e.cloneNode()),e}class zx extends Vy{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}}zx.inline=new zx("span"),zx.block=new zx("div");const Hx=new class extends Vy{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class Vx{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=Uy.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 Sx(e,e.contentDOM),this.updateInner([new vx(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=Ux(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 vx(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 vx(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,(jy.ie||jy.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 $x;return Qb.compare(e,t,n,r),r.changes}(o,this.decorations,e.changes);a.length&&(n=vx.extendWithRanges(n,a));let l=function(e,t,n){let r=new Kx;return Qb.compare(e,t,n,r),r.changes}(s,this.blockWrappers,e.changes);return l.length&&(n=vx.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 jx(this.view,n,this.blockWrappers,this.decorations,this.dynamicDecorationMap);this.tile=r.run(e,t),qx(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=jy.chrome||jy.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 Yx&&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(Zw)&&(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(tx)||n.tabIndex>-1)&&ew(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)),jy.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 yw(e,0),s=!0}var u;let h=this.view.observer.selectionRange;!s&&h.focusNode&&(nw(a.node,a.offset,h.anchorNode,h.anchorOffset)&&nw(l.node,l.offset,h.focusNode,h.focusOffset)||this.suppressWidgetCursorChange(h,c))||(this.view.observer.ignore(()=>{jy.android&&jy.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=Qy(this.view.root);if(e)if(c.empty){if(jy.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?vw:bw)(a.node,a.offset);t&&(a=new yw(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 yw(h.anchorNode,h.anchorOffset),this.impreciseHead=l.precise?null:new yw(h.focusNode,h.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&nw(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=Qy(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==sw(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&&!wx.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 Yx?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=Fv(t.text,n);if(e==n)return null;let r=pw(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==ww.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 Ex)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?tw(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?ww.RTL:ww.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=tw(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=tw(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(Uy.replace({widget:new Yx(r),block:!0,inclusive:!0,isBlockGap:!0}).range(n,o))}if(!i)break;n=i.to+1}return Uy.set(e)}updateDeco(){let e=1,t=this.view.state.facet(lx).map(t=>(this.dynamicDecorationMap[e++]="function"==typeof t)?t(this.view):t),n=!1,r=this.view.state.facet(ux).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(Qb.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(cx).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(Xw))try{if(t(this.view,e.range,e))return!0}catch(e){ex(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=mx(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=lw(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}=cw(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==ww.LTR)}lineHasWidget(e){let t=e=>e.isWidget()||e.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){qx(this.tile)}}function qx(e,t){let n=null==t?void 0:t.get(e);if(1!=n){null==n&&e.destroy();for(let n of e.children)qx(n,t)}}function Ux(e,t){let n=e.observer.selectionRange;if(!n.focusNode)return null;let r=vw(n.focusNode,n.focusOffset),i=bw(n.focusNode,n.focusOffset),o=r||i;if(i&&r&&i.node!=r.node){let t=wx.get(i.node);if(!t||t.isText()&&t.text!=i.node.nodeValue)o=i;else if(e.docView.lastCompositionAfterCursor){let e=wx.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 $x=class{constructor(){this.changes=[]}compareRange(e,t){Xy(e,t,this.changes)}comparePoint(e,t){Xy(e,t,this.changes)}boundChange(e){Xy(e,e,this.changes)}};class Kx{constructor(){this.changes=[]}compareRange(e,t){Xy(e,t,this.changes)}comparePoint(){}boundChange(e){Xy(e,e,this.changes)}}class Yx extends Vy{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 Gx(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!=qy.Text||e.type==i.type&&!(n<0?i.from<t:i.to>t))||(e=i)}}return e||r}return r}function Xx(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=jw(i,o,s,a,n),c=_w;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 Jx(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 Qx(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=Jx(e,i.from,0);t!=i.from&&(o=eb.cursor(t,-1))}else{let t=Jx(e,i.from,-1),n=Jx(e,i.to,1);t==i.from&&n==i.to||(o=eb.range(i.from==i.anchor?t:n,i.from==i.head?t:n))}o&&(n||(n=t.ranges.slice()),n[r]=o)}return n?eb.create(n,t.mainIndex):t}function Zx(e,t,n){let r=Jx(e.state.facet(hx).map(t=>t(e)),n.from,t.head>n.from?-1:1);return r==n.from?n:eb.cursor(r,r<n.from?1:-1)}class ek{constructor(e,t){this.pos=e,this.assoc=t}}function tk(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 ek(0,1);if(c>e.viewState.docHeight)return new ek(e.state.doc.length,-1);if(i=e.elementAtHeight(c),null==r)break;if(i.type==qy.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==qy.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+hy(s,o,e.state.tabSize)}(e,o,i,a,l);return new ek(t,t==i.from?1:-1)}}if(i.type!=qy.Text)return c<(i.top+i.bottom)/2?new ek(i.from,1):new ek(i.to,-1);let u=e.docView.lineAt(i.from,2);return u&&u.length==i.length||(u=e.docView.lineAt(i.from,-2)),nk(e,u,i.from,a,l)}function nk(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=Fv(t.text,e);if(h(pw(t.dom,e,n).getClientRects(),e),!a&&!l)break;e=n}return r>(s.left+s.right)/2==(rk(e,o+n)==ww.LTR)?new ek(n+Fv(t.text,o),-1):new ek(n+o,1)}{if(!t.length)return new ek(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:pw(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()?nk(e,c,u,Math.max(s.left,Math.min(s.right,r)),i):r>(s.left+s.right)/2==(rk(e,o+n)==ww.LTR)?new ek(u+c.length,-1):new ek(u,1)}}function rk(e,t){let n=e.state.doc.lineAt(t);return e.bidiSpans(n)[Tw.find(e.bidiSpans(n),t-n.from,-1,1)].dir}const ik="￿";class ok{constructor(e,t){this.points=e,this.view=t,this.text="",this.lineSeparator=t.state.facet(Ub.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=ik}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=wx.get(r),o=r.nextSibling;if(o==t){(null==i?void 0:i.breakAfter)&&!o&&n!=this.view.contentDOM&&this.lineBreak();break}let s=wx.get(o);(i&&s?i.breakAfter:(i?i.breakAfter:iw(r))||iw(o)&&("BR"!=r.nodeName||(null==i?void 0:i.isWidget()))&&this.text.length>e)&&!ak(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=wx.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+(sk(e,n.node,n.offset)?t:0))}}function sk(e,t,n){for(;;){if(!t||n<sw(t))return!1;if(t==e)return!0;n=rw(t)+1,t=t.parentNode}}function ak(e,t){let n;for(;e!=t&&e;e=e.nextSibling){let t=wx.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 lk{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}}class ck{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=uk(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 lk(n,r)),i==n&&o==r||t.push(new lk(i,o)));return t}(e),n=new ok(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?eb.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||!Zy(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||!Zy(e.contentDOM,t.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(t.anchorNode,t.anchorOffset),s=e.viewport;if((jy.ios||jy.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(eb.range(r,n)):this.newSel=eb.single(r,n)}}}function uk(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 uk(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 hk(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||jy.android&&t.text.length<s-r)&&(a=i.to,l="end");let c=fk(e.state.doc.sliceString(r,s,ik),t.text,a-r,l);c&&(jy.chrome&&13==o&&c.toB==c.from+2&&t.text.slice(c.from,c.toB)==ik+ik&&c.toB--,n={from:r+c.from,to:r+c.toA,insert:Mv.of(t.text.slice(c.from,c.toB).split(ik))})}else r&&(!e.hasFocus&&e.state.facet(tx)||pk(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)}:(jy.mac||jy.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=eb.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:Mv.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)}:jy.chrome&&n&&n.from==n.to&&n.from==i.head&&"\n "==n.insert.toString()&&e.lineWrapping&&(r&&(r=eb.single(r.main.anchor-1,r.main.head-1)),n={from:i.from,to:i.to,insert:Mv.of([" "])}),n)return dk(e,n,r,o);if(r&&!pk(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=Qx(e.state.facet(hx).map(t=>t(e)),r))),e.dispatch({selection:r,scrollIntoView:t,userEvent:n}),!0}return!1}function dk(e,t,n,r=-1){if(jy.ios&&e.inputState.flushIOSKey(t))return!0;let i=e.state.selection.main;if(jy.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&&mw(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)&&mw(e.contentDOM,"Backspace",8)||t.from==i.from&&t.to==i.to+1&&0==t.insert.length&&mw(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=Jx(i.facet(hx).map(t=>t(e)),r,n);t.from==a&&(s=a)}if(s>-1)r={changes:t,selection:eb.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&&Ux(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?eb.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(qw).some(n=>n(e,t.from,t.to,s,a))||e.dispatch(a()),!0}function fk(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 pk(e,t){return t.head==e.main.head&&t.anchor==e.main.anchor}class mk{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,jy.safari&&e.contentDOM.addEventListener("input",()=>null),jy.gecko&&function(e){Fk.has(e)||(Fk.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=wx.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=vk(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&&wk.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),jy.android&&jy.chrome&&!e.synthetic&&(13==e.keyCode||8==e.keyCode))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return!jy.ios||e.synthetic||e.altKey||e.metaKey||!((t=bk.find(t=>t.keyCode==e.keyCode))&&!e.ctrlKey||yk.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,mw(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||!!(jy.safari&&!jy.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 gk(e,t){return(n,r)=>{try{return t.call(e,r,n)}catch(e){ex(n.state,e)}}}function vk(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(gk(t.value,i))}if(i)for(let e in i){let r=i[e];r&&n(e).observers.push(gk(t.value,r))}}for(let e in Sk)n(e).handlers.push(Sk[e]);for(let e in Ek)n(e).observers.push(Ek[e]);return t}const bk=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],yk="dthko",wk=[16,17,18,20,91,92,224,225];function xk(e){return.7*Math.max(0,e)+8}class kk{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(hx).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(Ub.allowMultipleSelections)&&function(e,t){let n=e.state.facet(Fw);return n.length?n[0](t):jy.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=Qy(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!=Pk(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=mx(this.view);e.clientX-c.left<=o+6?r=-xk(o-e.clientX):e.clientX+c.right>=a-6&&(r=xk(e.clientX-a)),e.clientY-c.top<=s+6?i=-xk(s-e.clientY):e.clientY+c.bottom>=l-6&&(i=xk(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=Qx(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 Sk=Object.create(null),Ek=Object.create(null),Ck=jy.ie&&jy.ie_version<15||jy.ios&&jy.webkit_version<604;function Nk(e,t,n){for(let r of e.facet(t))n=r(n,e);return n}function Ok(e,t){t=Nk(e.state,$w,t);let n,{state:r}=e,i=1,o=r.toText(t),s=o.lines==r.selection.ranges.length,a=null!=Ik&&r.selection.ranges.every(e=>e.empty)&&Ik==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:eb.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:eb.cursor(e.from+t.length)}}):r.replaceSelection(o);e.dispatch(n,{userEvent:"input.paste",scrollIntoView:!0})}function Ak(e,t,n,r){if(1==r)return eb.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 eb.cursor(t);0==o?n=1:o==i.length&&(n=-1);let s=o,a=o;n<0?s=Fv(i.text,o,!1):a=Fv(i.text,o);let l=r(i.text.slice(s,a));for(;s>0;){let e=Fv(i.text,s,!1);if(r(i.text.slice(e,s))!=l)break;s=e}for(;a<i.length;){let e=Fv(i.text,a);if(r(i.text.slice(a,e))!=l)break;a=e}return eb.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++,eb.range(o,s)}}Ek.scroll=e=>{e.inputState.lastScrollTop=e.scrollDOM.scrollTop,e.inputState.lastScrollLeft=e.scrollDOM.scrollLeft},Sk.keydown=(e,t)=>(e.inputState.setSelectionOrigin("select"),27==t.keyCode&&0!=e.inputState.tabFocusMode&&(e.inputState.tabFocusMode=Date.now()+2e3),!1),Ek.touchstart=(e,t)=>{e.inputState.lastTouchTime=Date.now(),e.inputState.setSelectionOrigin("select.pointer")},Ek.touchmove=e=>{e.inputState.setSelectionOrigin("select.pointer")},Sk.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(zw))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=Pk(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=Ak(e,l.pos,l.assoc,r);if(n.pos!=l.pos&&!o){let t=Ak(e,n.pos,n.assoc,r),i=Math.min(t.from,c.from),o=Math.max(t.to,c.to);c=i<c.from?eb.range(i,o):eb.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 eb.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):eb.create([c])}}}(e,t)),n){let r=!e.hasFocus;e.inputState.startMouseSelection(new kk(e,t,n,r)),r&&e.observer.ignore(()=>{fw(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 Mk=jy.ie&&jy.ie_version<=11;let Tk=null,Rk=0,Dk=0;function Pk(e){if(!Mk)return e.detail;let t=Tk,n=Dk;return Tk=e,Dk=Date.now(),Rk=!t||n>Date.now()-400&&Math.abs(t.clientX-e.clientX)<2&&Math.abs(t.clientY-e.clientY)<2?(Rk+1)%3:1}function Lk(e,t,n,r){if(!(n=Nk(e.state,$w,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(Ww);return n.length?n[0](t):jy.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}Sk.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=eb.range(e,t))}}let{inputState:r}=e;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,t.dataTransfer&&(t.dataTransfer.setData("Text",Nk(e.state,Kw,e.state.sliceDoc(n.from,n.to))),t.dataTransfer.effectAllowed="copyMove"),!1},Sk.dragend=e=>(e.inputState.draggedContent=null,!1),Sk.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&&Lk(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 Lk(e,t,n,!0),!0}return!1},Sk.paste=(e,t)=>{if(e.state.readOnly)return!0;e.observer.flush();let n=Ck?null:t.clipboardData;return n?(Ok(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(),Ok(e,n.value)},50)}(e),!1)};let Ik=null;Sk.copy=Sk.cut=(e,t)=>{let n=Qy(e.root);if(n&&!ew(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:Nk(e,Kw,t.join(e.lineBreak)),ranges:n,linewise:r}}(e.state);if(!r&&!o)return!1;Ik=o?r:null,"cut"!=t.type||e.state.readOnly||e.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let s=Ck?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 _k=Tb.define();function jk(e,t){let n=[];for(let r of e.facet(Uw)){let i=r(e,t);i&&n.push(i)}return n.length?e.update({effects:n,annotations:_k.of(!0)}):null}function Bk(e){setTimeout(()=>{let t=e.hasFocus;if(t!=e.inputState.notifiedFocused){let n=jk(e.state,t);n?e.dispatch(n):e.update([])}},10)}Ek.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),Bk(e)},Ek.blur=e=>{e.observer.clearSelectionRange(),Bk(e)},Ek.compositionstart=Ek.compositionupdate=e=>{e.observer.editContext||(null==e.inputState.compositionFirstChange&&(e.inputState.compositionFirstChange=!0),e.inputState.composing<0&&(e.inputState.composing=0))},Ek.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,jy.chrome&&jy.android?e.observer.flushSoon():e.inputState.compositionPendingChange?Promise.resolve().then(()=>e.observer.flush()):setTimeout(()=>{e.inputState.composing<0&&e.docView.hasComposition&&e.update([])},50))},Ek.contextmenu=e=>{e.inputState.lastContextMenu=Date.now()},Sk.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 dk(e,{from:n,to:o,insert:e.state.toText(r)},null),!0}}let i;if(jy.chrome&&jy.android&&(i=bk.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 jy.ios&&"deleteContentForward"==t.inputType&&e.observer.flushSoon(),jy.safari&&"insertText"==t.inputType&&e.inputState.composing>=0&&setTimeout(()=>Ek.compositionend(e,t),20),!1};const Fk=new Set;const Wk=["pre-wrap","normal","pre-line","break-spaces"];let zk=!1;function Hk(){zk=!1}class Vk{constructor(e){this.lineWrapping=e,this.doc=Mv.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 Wk.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=Wk.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 qk{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}}class Uk{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?qy.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 Yy?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 Uk(this.from,this.length+e.length,this.top,this.height+e.height,t)}}var $k=function(e){return e[e.ByPos=0]="ByPos",e[e.ByHeight=1]="ByHeight",e[e.ByPosNoHeight=2]="ByPosNoHeight",e}($k||($k={}));const Kk=.001;class Yk{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)>Kk&&(zk=!0),this.height=e)}replace(e,t,n){return Yk.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,$k.ByPosNoHeight,n.setDoc(t),0,0),d=h.to>=l?h:i.lineAt(l,$k.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,$k.ByPosNoHeight,n,0,0));c+=h.from-a,a=h.from;let f=nS.build(n.setDoc(o),e,c,u);i=Gk(i,i.replace(a,l,f))}return i.updateHeight(n,0)}static empty(){return new Qk(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 eS(Yk.of(e.slice(0,t)),o,Yk.of(e.slice(n)))}}function Gk(e,t){return e==t?e:(e.constructor!=t.constructor&&(zk=!0),t)}Yk.prototype.size=1;const Xk=Uy.replace({});class Jk extends Yk{constructor(e,t,n){super(e,t),this.deco=n,this.spaceAbove=0}mainBlock(e,t){return new Uk(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 Uk(r,0,n,this.spaceAbove,Xk):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,$k.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 Qk extends Jk{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 Uk(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 Qk||r instanceof Zk&&4&r.flags)&&Math.abs(this.length-r.length)<10?(r instanceof Zk?r=new Qk(r.length,this.height,this.spaceAbove):r.height=this.height,this.outdated||(r.outdated=!1),r):Yk.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 Zk extends Yk{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 Uk(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 Uk(a,l,n+s*r,s,0)}}lineAt(e,t,n,r,i){if(t==$k.ByHeight)return this.blockAt(e,n,r,i);if(t==$k.ByPosNoHeight){let{from:t,to:r}=n.doc.lineAt(e);return new Uk(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 Uk(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 Uk(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 Zk?n[n.length-1]=new Zk(e.length+r):n.push(null,new Zk(r-1))}if(e>0){let t=n[0];t instanceof Zk?n[0]=new Zk(e+t.length):n.unshift(new Zk(e-1),null)}return Yk.of(n)}decomposeLeft(e,t){t.push(new Zk(e-1),null)}decomposeRight(e,t){t.push(null,new Zk(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 Zk(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)>=Kk&&(s=-2);let l=new Qk(t,i,a);l.outdated=!1,n.push(l),o+=t+1}o<=i&&n.push(null,new Zk(i-o).updateHeight(e,o));let a=Yk.of(n);return(s<0||Math.abs(a.height-this.height)>=Kk||Math.abs(s-this.heightMetrics(e,t).perLine)>=Kk)&&(zk=!0),Gk(this,a)}return(n||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class eS extends Yk{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==$k.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==$k.ByPosNoHeight?$k.ByPosNoHeight:$k.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,$k.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&&tS(i,o-1),t<this.length){let e=i.length;this.decomposeRight(t,i),tS(i,e)}return Yk.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?Yk.of(this.break?[e,null,t]:[e,t]):(this.left=Gk(this.left,e),this.right=Gk(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 tS(e,t){let n,r;null==e[t]&&(n=e[t-1])instanceof Zk&&(r=e[t+1])instanceof Zk&&e.splice(t-1,3,new Zk(n.length+1+r.length))}class nS{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 Qk?n.length+=e-this.pos:(e>this.pos||!this.isCovered)&&this.nodes.push(new Qk(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 Jk(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 Qk(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let n=new Zk(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 Qk)return e;let t=new Qk(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 Qk||this.isCovered?(this.writtenTo<this.pos||null==t)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new Qk(0,-1,0));let n=e;for(let e of this.nodes)e instanceof Qk&&e.updateHeight(this.oracle,n),n+=e?e.length:1;return this.nodes}static build(e,t,n,r){let i=new nS(n,e);return Qb.spans(t,n,r,i,0),i.finish(n)}}class rS{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,n,r){(e<t||n&&n.heightRelevant||r&&r.heightRelevant)&&Xy(e,t,this.changes,5)}}function iS(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 oS(e,t){let n=e.getBoundingClientRect();return{left:0,right:n.right-n.left,top:t,bottom:n.bottom-(n.top+t)}}class sS{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 Uy.replace({widget:new aS(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}}class aS extends Vy{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 lS{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=dS,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=ww.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let t=e.facet(ax).some(e=>"function"!=typeof e&&"cm-lineWrapping"==e.class);this.heightOracle=new Vk(t),this.stateDeco=fS(e),this.heightMap=Yk.empty().applyChanges(this.stateDeco,Mv.empty,this.heightOracle.setDoc(e.doc),[new vx(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=Uy.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 cS(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?dS:new pS(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(mS(e,this.scaler))})}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=fS(this.state);let r=e.changedRanges,i=vx.extendWithRanges(r,function(e,t,n){let r=new rS;return Qb.compare(e,t,n,r,0),r.changes}(n,this.stateDeco,e?e.changes:$v.empty(this.state.doc.length))),o=this.heightMap.height,s=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);Hk(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),i),(this.heightMap.height!=o||zk)&&(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(Gw)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,n=window.getComputedStyle(t),r=this.heightOracle,i=n.whiteSpace;this.defaultTextDirection="rtl"==n.direction?ww.RTL:ww.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}=cw(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=gw(e.scrollDOM);let f=(this.printing?oS:iS)(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)),Hk();for(let n of this.viewports){let i=n.from==this.viewport.from?t:e.docView.measureVisibleLineHeights(n);this.heightMap=(o?Yk.empty().applyChanges(this.stateDeco,Mv.empty,this.heightOracle,[new vx(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,o,new qk(n.from,i))}zk&&(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 cS(r.lineAt(o-1e3*n,$k.ByHeight,i,0,0).from,r.lineAt(s+1e3*(1-n),$k.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,$k.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 cS(r.lineAt(n-500,$k.ByHeight,i,0,0).from,r.lineAt(n+o+500,$k.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 cS(this.heightMap.lineAt(n,$k.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(r,$k.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,$k.ByPos,this.heightOracle,0,0),{bottom:i}=this.heightMap.lineAt(t,$k.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 sS(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!=ww.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(eb.cursor(o),!1,!0).head;e>r&&(o=e)}let e=this.gapSize(l,r,o,c);d=new sS(r,o,e,n||e<2e6?e:2e6)}s.push(d)},l=t=>{if(t.length<o||t.type!=qy.Text)return;let i=function(e,t,n){let r=[],i=e,o=0;Qb.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=hS(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=uS(i,e),l=uS(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=hS(i,c),t=((f-d)/2+o)/n;u=e-t,h=e+t}else u=(d-o)/n,h=(f+o)/n;s=uS(i,u),l=uS(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=hS(r,n)-hS(r,t);return this.heightOracle.lineWrapping?e.height*i:r.total*this.heightOracle.charWidth*i}updateLineGaps(e){sS.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=Uy.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=[];Qb.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)||mS(this.heightMap.lineAt(e,$k.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)||mS(this.heightMap.lineAt(this.scaler.fromDOM(e),$k.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 mS(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 cS{constructor(e,t){this.from=e,this.to=t}}function uS({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 hS(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 dS={toDOM:e=>e,fromDOM:e=>e,scale:1,eq(e){return e==this}};function fS(e){let t=e.facet(lx).filter(e=>"function"!=typeof e),n=e.facet(ux).filter(e=>"function"!=typeof e);return n.length&&t.push(Qb.join(n)),t}class pS{constructor(e,t,n){let r=0,i=0,o=0;this.viewports=n.map(({from:n,to:i})=>{let o=t.lineAt(n,$k.ByPos,e,0,0).top,s=t.lineAt(i,$k.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 pS&&(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 mS(e,t){if(1==t.scale)return e;let n=t.toDOM(e.top),r=t.toDOM(e.bottom);return new Uk(e.from,e.length,n,r-n,Array.isArray(e._content)?e._content.map(e=>mS(e,t)):e._content)}const gS=rb.define({combine:e=>e.join(" ")}),vS=rb.define({combine:e=>e.indexOf(!0)>-1}),bS=my.newName(),yS=my.newName(),wS=my.newName(),xS={"&light":"."+yS,"&dark":"."+wS};function kS(e,t,n){return new my(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 SS=kS("."+bS,{"&":{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"}},xS),ES={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},CS=jy.ie&&jy.ie_version<=11;class NS{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new uw,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);(jy.ie&&jy.ie_version<=11||jy.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||!jy.android||!1===e.constructor.EDIT_CONTEXT||jy.chrome&&jy.chrome_version<126||(this.editContext=new MS(e),e.state.facet(tx)&&(e.contentDOM.editContext=this.editContext.editContext)),CS&&(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(tx)?n.root.activeElement!=this.dom:!ew(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):(jy.ie&&jy.ie_version<=11||jy.android&&jy.chrome)&&!n.state.selection.main.empty&&r.focusNode&&nw(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=Qy(e.root);if(!t)return!1;let n=jy.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 AS(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?AS(e,n):null}(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;let r=ew(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,sw(n));;)if(r){if(1!=n.nodeType)return!1;let e=n.childNodes[r-1];"false"==e.contentEditable?r--:(n=e,r=sw(n))}else{if(n==e)return!0;r=rw(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,ES),CS&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),CS&&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&&mw(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&&ew(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 ck(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=hk(this.view,t);return this.view.state==n&&(t.domChanged||t.newSel&&!pk(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=OS(t,e.previousSibling||e.target.previousSibling,-1),r=OS(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(tx)!=e.state.facet(tx)&&(e.view.contentDOM.editContext=e.state.facet(tx)?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 OS(e,t,n){for(;t;){let r=wx.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 AS(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 nw(s.node,s.offset,i,o)&&([n,r,i,o]=[i,o,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:o}}class MS{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=fk(e.state.sliceDoc(s,a),n.text,(l?r.from:r.to)-s,l?"end":null);if(!c){let t=eb.single(this.toEditorPos(n.selectionStart),this.toEditorPos(n.selectionEnd));return void(pk(t,r)||e.dispatch({selection:t,userEvent:"select"}))}let u={from:c.from+s,to:c.toA+s,insert:Mv.of(n.text.slice(c.from,c.toB).split("\n"))};if((jy.mac||jy.android)&&u.from==o-1&&/^\. ?$/.test(n.text)&&"off"==e.contentDOM.getAttribute("autocorrect")&&(u={from:s,to:a,insert:Mv.of([n.text.replace("."," ")])}),this.pendingContextChange=u,!e.state.readOnly){let t=this.to-this.from+(u.to-u.from+u.insert.length);dk(e,u,eb.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(Uy.mark({attributes:{style:e}}).range(i,o))}}}e.dispatch({effects:Zw.of(Uy.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=Qy(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 TS{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 lS(e.state||Ub.create(e)),e.scrollTo&&e.scrollTo.is(Qw)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(rx).map(e=>new ox(e));for(let e of this.plugins)e.update(this);this.observer=new NS(this),this.inputState=new mk(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Vx(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 Lb?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(_k))?(this.inputState.notifiedFocused=o,s=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=jk(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(Ub.phrases)!=this.state.facet(Ub.phrases))return this.setState(i);t=bx.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 Jw(e.empty?e:eb.cursor(e.head,e.head>e.anchor?-1:1))}for(let e of t.effects)e.is(Qw)&&(u=e.value.clip(this.state))}this.viewState.update(t,u),this.bidiCache=PS.update(this.bidiCache,t.changes),t.empty||(this.updatePlugins(t),this.inputState.update(t)),n=this.docView.update(t),this.state.facet(gx)!=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(gS)!=t.state.facet(gS)&&(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(Vw))try{e(t)}catch(e){ex(this.state,e,"update listener")}(a||c)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!hk(this,c)&&l.force&&mw(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 lS(e),this.plugins=e.facet(rx).map(e=>new ox(e)),this.pluginMap.clear();for(let e of this.plugins)e.update(this);this.docView.destroy(),this.docView=new Vx(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(rx),n=e.state.facet(rx);if(t!=n){let r=[];for(let i of n){let n=t.indexOf(i);if(n<0)r.push(new ox(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){ex(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(gw(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 ex(this.state,e),DS}}),c=bx.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]!=DS)try{let t=a[e];t.write&&t.write(l[e],this)}catch(e){ex(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(Vw))e(t)}get themeClasses(){return bS+" "+(this.state.facet(vS)?wS:yS)+" "+this.state.facet(gS)}updateAttrs(){let e=LS(this,sx,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(tx)?"true":"false",class:"cm-content",style:`${jy.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),LS(this,ax,t);let n=this.observer.ignore(()=>{let n=zy(this.contentDOM,this.contentAttrs,t),r=zy(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(TS.announce)){t&&(this.announceDOM.textContent=""),t=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=e.value}}mountStyles(){this.styleModules=this.state.facet(gx);let e=this.state.facet(TS.cspNonce);my.mount(this.root,this.styleModules.concat(SS).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 Zx(this,e,Xx(this,e,t,n))}moveByGroup(e,t){return Zx(this,e,Xx(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==zb.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 eb.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=Gx(e,t.head,t.assoc||-1),o=r&&i.type==qy.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==ww.LTR)?t.right-1:t.left+1,y:(o.top+o.bottom)/2});if(null!=s)return eb.cursor(s,n?-1:1)}return eb.cursor(n?i.to:i.from,n?-1:1)}(this,e,t,n)}moveVertically(e,t,n){return Zx(this,e,function(e,t,n,r){let i=t.head,o=n?1:-1;if(i==(n?e.state.doc.length:0))return eb.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=tk(e,{x:l.left+a,y:s+(null!=r?r:e.viewState.heightOracle.textHeight>>1)*o},!1,o);return eb.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=tk(this,e,t);return n&&n.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),tk(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 aw(n,i[Tw.find(i,e-r.from,-1,t)].dir==ww.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(Yw)||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>RS)return Iw(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||Rw(r.isolates,t=fx(this,e))))return r.order;t||(t=fx(this,e));let r=function(e,t,n){if(!e)return[new Tw(0,0,t==kw?1:0)];if(t==xw&&!n.length&&!Mw.test(e))return Iw(e.length);if(n.length)for(;e.length>Dw.length;)Dw[Dw.length]=256;let r=[],i=t==xw?0:1;return Lw(e,i,i,n,0,e.length,r),r}(e.text,n,t);return this.bidiCache.push(new PS(e.from,e.to,n,t,!0,r)),r}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||jy.safari&&(null===(e=this.inputState)||void 0===e?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{fw(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 Qw.of(new Jw("number"==typeof e?eb.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 Qw.of(new Jw(eb.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 ix.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return ix.define(()=>({}),{eventObservers:e})}static theme(e,t){let n=my.newName(),r=[gS.of(n),gx.of(kS(`.${n}`,e))];return t&&t.dark&&r.push(vS.of(!0)),r}static baseTheme(e){return gb.lowest(gx.of(kS("."+bS,e,xS)))}static findFromDOM(e){var t;let n=e.querySelector(".cm-content"),r=n&&wx.get(n)||wx.get(e);return(null===(t=null==r?void 0:r.root)||void 0===t?void 0:t.view)||null}}TS.styleModule=gx,TS.inputHandler=qw,TS.clipboardInputFilter=$w,TS.clipboardOutputFilter=Kw,TS.scrollHandler=Xw,TS.focusChangeEffect=Uw,TS.perLineTextDirection=Yw,TS.exceptionSink=Hw,TS.updateListener=Vw,TS.editable=tx,TS.mouseSelectionStyle=zw,TS.dragMovesSelection=Ww,TS.clickAddsSelectionRange=Fw,TS.decorations=lx,TS.blockWrappers=cx,TS.outerDecorations=ux,TS.atomicRanges=hx,TS.bidiIsolatedRanges=dx,TS.scrollMargins=px,TS.darkTheme=vS,TS.cspNonce=rb.define({combine:e=>e.length?e[0]:""}),TS.contentAttributes=ax,TS.editorAttributes=sx,TS.lineWrapping=TS.contentAttributes.of({class:"cm-lineWrapping"}),TS.announce=Pb.define();const RS=4096,DS={};class PS{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:ww.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 PS(t.mapPos(o.from,1),t.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return n}}function LS(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&&By(o,n)}return n}const IS=jy.mac?"mac":jy.windows?"win":jy.linux?"linux":"key";function _S(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 jS=gb.default(TS.domEventHandlers({keydown:(e,t)=>qS(WS(t.state),e,t,"editor")})),BS=rb.define({enables:jS}),FS=new WeakMap;function WS(e){let t=e.facet(BS),n=FS.get(t);return n||FS.set(t,n=function(e,t=IS){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=zS={view:t,prefix:n,scope:e};return setTimeout(()=>{zS==r&&(zS=null)},HS),!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,VS))}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 zS=null;const HS=4e3;let VS=null;function qS(e,t,n,r){VS=t;let i=function(e){var t=!(wy&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||xy&&e.shiftKey&&e.key&&1==e.key.length||"Unidentified"==e.key)&&e.key||(e.shiftKey?yy:by)[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=Hv(Wv(i,0))==i.length&&" "!=i,s="",a=!1,l=!1,c=!1;zS&&zS.view==n&&zS.scope==r&&(s=zS.prefix+" ",wk.indexOf(t.keyCode)<0&&(l=!0,zS=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+_S(i,t,!o)])?a=!0:!o||!(t.altKey||t.metaKey||t.ctrlKey)||jy.windows&&t.ctrlKey&&t.altKey||jy.mac&&t.altKey&&!t.ctrlKey&&!t.metaKey||!(u=by[t.keyCode])||u==i?o&&t.shiftKey&&f(p[s+_S(i,t,!0)])&&(a=!0):(f(p[s+_S(u,t,!0)])||t.shiftKey&&(h=yy[t.keyCode])!=i&&h!=u&&f(p[s+_S(h,t,!1)]))&&(a=!0),!a&&f(p._any)&&(a=!0)),l&&(a=!0),a&&c&&t.stopPropagation(),VS=null,a}class US{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=$S(e);return[new US(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==ww.LTR,s=e.contentDOM,a=s.getBoundingClientRect(),l=$S(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=Gx(e,r,1),p=Gx(e,i,-1),m=f.type==qy.Text?f:null,g=p.type==qy.Text?p:null;m&&(e.lineWrapping||f.widgetLineBreaks)&&(m=KS(e,r,1,m));g&&(e.lineWrapping||p.widgetLineBreaks)&&(g=KS(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==qy.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 US(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==ww.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 $S(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==ww.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function KS(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 YS{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(GS)!=e.state.facet(GS)&&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(GS);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,jy.safari&&jy.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 GS=rb.define();function XS(e){return[ix.define(t=>new YS(t,e)),GS.of(e)]}const JS=rb.define({combine:e=>$b(e,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})});function QS(e){return e.startState.facet(JS)!=e.state.facet(JS)}const ZS=XS({above:!0,markers(e){let{state:t}=e,n=t.facet(JS),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:eb.cursor(i.head,i.head>i.anchor?-1:1);for(let i of US.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=QS(e);return n&&eE(e.state,t),e.docChanged||e.selectionSet||n},mount(e,t){eE(t.state,e)},class:"cm-cursorLayer"});function eE(e,t){t.style.animationDuration=e.facet(JS).cursorBlinkRate+"ms"}const tE=XS({above:!1,markers:e=>e.state.selection.ranges.map(t=>t.empty?[]:US.forRange(e,"cm-selectionBackground",t)).reduce((e,t)=>e.concat(t)),update:(e,t)=>e.docChanged||e.selectionSet||e.viewportChanged||QS(e),class:"cm-selectionLayer"}),nE=gb.highest(TS.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"}}}})),rE=Pb.define({map:(e,t)=>null==e?null:t.mapPos(e)}),iE=ub.define({create:()=>null,update:(e,t)=>(null!=e&&(e=t.changes.mapPos(e)),t.effects.reduce((e,t)=>t.is(rE)?t.value:e,e))}),oE=ix.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(iE);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(iE)!=n||e.docChanged||e.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:e}=this,t=e.state.field(iE),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(iE)!=e&&this.view.dispatch({effects:rE.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 sE(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 aE{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 Zb,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))sE(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 sE(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 lE=null!=/x/.unicode?"gu":"g",cE=new RegExp("[\0-\b\n--Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\ufeff-]",lE),uE={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 hE=null;const dE=rb.define({combine(e){let t=$b(e,{render:null,specialChars:cE,addSpecialChars:null});return(t.replaceTabs=!function(){var e;if(null==hE&&"undefined"!=typeof document&&document.body){let t=document.body.style;hE=null!=(null!==(e=t.tabSize)&&void 0!==e?e:t.MozTabSize)}return hE||!1}())&&(t.specialChars=new RegExp("\t|"+t.specialChars.source,lE)),t.addSpecialChars&&(t.specialChars=new RegExp(t.specialChars.source+"|"+t.addSpecialChars.source,lE)),t}});let fE=null;class pE extends Vy{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")+" "+(uE[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 mE extends Vy{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 gE=Uy.line({class:"cm-activeLine"}),vE=ix.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(gE.range(i.from)),t=i.from)}return Uy.set(n)}},{decorations:e=>e.decorations});class bE extends Vy{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?tw(e.firstChild):[];if(!t.length)return null;let n=window.getComputedStyle(e.parentNode),r=aw(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 yE=2e3;function wE(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>yE?-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):uy(r.text,e.state.tabSize,n-r.from);return{line:r.number,col:o,off:i}}function xE(e,t){let n=wE(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=wE(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>yE||n.off>yE||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(eb.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=hy(n.text,s,e.tabSize,!0);if(r<0)o.push(eb.cursor(n.to));else{let t=hy(n.text,a,e.tabSize);o.push(eb.range(n.from+r,n.from+t))}}}return o}(e.state,n,s);return a.length?o?eb.create(a.concat(r.ranges)):eb.create(a):r}}:null}const kE={Alt:[18,e=>!!e.altKey],Control:[17,e=>!!e.ctrlKey],Shift:[16,e=>!!e.shiftKey],Meta:[91,e=>!!e.metaKey]},SE={style:"cursor: crosshair"};const EE="-10000px";class CE{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 NE(e){let t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}const OE=rb.define({combine:e=>{var t,n,r;return{position:jy.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)||NE}}}),AE=new WeakMap,ME=ix.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(OE);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 CE(e,PE,(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(OE);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=EE,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(jy.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=mx(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(OE).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=EE;continue}let f=l.arrow?c.dom.querySelector(".cm-tooltip-arrow"):null,p=f?7:0,m=d.right-d.left,g=null!==(t=AE.get(c))&&void 0!==t?t:d.bottom-d.top,v=c.offset||DE,b=this.view.textDirection==ww.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=EE;continue}AE.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",TE(u,(y-e.parent.left)/i)):(u.style.top=k/o+"px",TE(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=EE}},{eventObservers:{scroll(){this.maybeMeasure()}}});function TE(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+"px")}const RE=TS.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"}}}),DE={x:0,y:0},PE=rb.define({enables:[ME,RE]}),LE=rb.define({combine:e=>e.reduce((e,t)=>e.concat(t),[])});class IE{static create(e){return new IE(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new CE(e,LE,(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 _E=PE.compute([LE],e=>{let t=e.facet(LE);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:IE.create,above:t[0].above,arrow:t.some(e=>e.arrow)}});class jE{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==ww.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=>ex(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(ME),t=e?e.manager.tooltips.findIndex(e=>e.create==IE.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-BE&&t.clientX<=i+BE&&t.clientY>=o-BE&&t.clientY<=s+BE}(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 BE=4;function FE(e,t={}){let n=Pb.define(),r=ub.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,qv.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(zE)&&(e=[]);return e},provide:e=>LE.from(e)});return{active:r,extension:[r,ix.define(i=>new jE(i,e,r,n,t.hoverTime||300)),_E]}}function WE(e,t){let n=e.plugin(ME);if(!n)return null;let r=n.manager.tooltips.indexOf(t);return r<0?null:n.manager.tooltipViews[r]}const zE=Pb.define(),HE=rb.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 VE(e,t){let n=e.plugin(qE),r=n?n.specs.indexOf(t):-1;return r>-1?n.panels[r]:null}const qE=ix.fromClass(class{constructor(e){this.input=e.state.facet(KE),this.specs=this.input.filter(e=>e),this.panels=this.specs.map(t=>t(e));let t=e.state.facet(HE);this.top=new UE(e,!0,t.topContainer),this.bottom=new UE(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(HE);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new UE(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new UE(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(KE);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=>TS.scrollMargins.of(t=>{let n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})});class UE{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=$E(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=$E(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 $E(e){let t=e.nextSibling;return e.remove(),t}const KE=rb.define({enables:qE});function YE(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=Ey("form"),t.input){let e=Ey("input",t.input);/^(text|password|number|email|tel|url)$/.test(e.type)&&e.classList.add("cm-textfield"),e.name||(e.name="input"),r.appendChild(Ey("label",(t.label||"")+": ",e))}else r.appendChild(document.createTextNode(t.label||""));r.appendChild(document.createTextNode(" ")),r.appendChild(Ey("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=Ey("div",r,Ey("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(GE,!1)?e.dispatch({effects:XE.of(i)}):e.dispatch({effects:Pb.appendConfig.of(GE.init(()=>[i]))});let o=JE.of(i);return{close:o,result:r.then(t=>((e.win.queueMicrotask||(t=>e.win.setTimeout(t,10)))(()=>{e.state.field(GE).indexOf(i)>-1&&e.dispatch({effects:o})}),t))}}const GE=ub.define({create:()=>[],update(e,t){for(let n of t.effects)n.is(XE)?e=[n.value].concat(e):n.is(JE)&&(e=e.filter(e=>e!=n.value));return e},provide:e=>KE.computeN([e],t=>t.field(e))}),XE=Pb.define(),JE=Pb.define();class QE extends Kb{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}QE.prototype.elementClass="",QE.prototype.toDOM=void 0,QE.prototype.mapMode=qv.TrackBefore,QE.prototype.startSide=QE.prototype.endSide=-1,QE.prototype.point=!0;const ZE=rb.define(),eC=rb.define(),tC={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>Qb.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},nC=rb.define();function rC(e){return[oC(),nC.of({...tC,...e})]}const iC=rb.define({combine:e=>e.some(e=>e)});function oC(e){let t=[sC];return e&&!1===e.fixed&&t.push(iC.of(!0)),t}const sC=ix.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(nC).map(t=>new uC(e,t)),this.fixed=!e.state.facet(iC);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(iC)!=!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=Qb.iter(this.view.state.facet(ZE),this.view.viewport.from),r=[],i=this.gutters.map(e=>new cC(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==qy.Text&&t){lC(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==qy.Text){lC(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(nC),n=e.state.facet(nC),r=e.docChanged||e.heightChanged||e.viewportChanged||!Qb.eq(e.startState.facet(ZE),e.state.facet(ZE),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 uC(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=>TS.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==ww.LTR?{left:r,right:i}:{right:r,left:i}})});function aC(e){return Array.isArray(e)?e:[e]}function lC(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}class cC{constructor(e,t,n){this.gutter=e,this.height=n,this.i=0,this.cursor=Qb.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 hC(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=[];lC(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(eC)){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 uC{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=aC(t.markers(e)),t.initialSpacer&&(this.spacer=new hC(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=aC(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!Qb.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 hC{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 dC=rb.define(),fC=rb.define(),pC=rb.define({combine:e=>$b(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 mC extends QE{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function gC(e,t){return e.state.facet(pC).formatNumber(t,e.state)}const vC=nC.compute([pC],e=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers:e=>e.state.facet(dC),lineMarker:(e,t,n)=>n.some(e=>e.toDOM)?null:new mC(gC(e,e.state.doc.lineAt(t.from).number)),widgetMarker:(e,t,n)=>{for(let r of e.state.facet(fC)){let i=r(e,t,n);if(i)return i}return null},lineMarkerChange:e=>e.startState.facet(pC)!=e.state.facet(pC),initialSpacer:e=>new mC(gC(e,bC(e.state.doc.lines))),updateSpacer(e,t){let n=gC(t.view,bC(t.view.state.doc.lines));return n==e.number?e:new mC(n)},domEventHandlers:e.facet(pC).domEventHandlers,side:"before"}));function bC(e){let t=9;for(;t<e;)t=10*t+9;return t}const yC=new class extends QE{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},wC=ZE.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(yC.range(i)))}return Qb.of(t)});const xC=1024;let kC=0;class SC{constructor(e,t){this.from=e,this.to=t}}class EC{constructor(e={}){this.id=kC++,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=OC.match(e)),t=>{let n=e(t);return void 0===n?null:[this,n]}}}EC.closedBy=new EC({deserialize:e=>e.split(" ")}),EC.openedBy=new EC({deserialize:e=>e.split(" ")}),EC.group=new EC({deserialize:e=>e.split(" ")}),EC.isolate=new EC({deserialize:e=>{if(e&&"rtl"!=e&&"ltr"!=e&&"auto"!=e)throw new RangeError("Invalid value for isolate: "+e);return e||"auto"}}),EC.contextHash=new EC({perNode:!0}),EC.lookAhead=new EC({perNode:!0}),EC.mounted=new EC({perNode:!0});class CC{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[EC.mounted.id]}}const NC=Object.create(null);class OC{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):NC,n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(null==e.name?8:0),r=new OC(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(EC.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(EC.group),r=-1;r<(n?n.length:0);r++){let i=t[r<0?e.name:n[r]];if(i)return i}}}}OC.none=new OC("",Object.create(null),0,8);class AC{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 OC(n.name,r,n.id,n.flags):n)}return new AC(t)}}const MC=new WeakMap,TC=new WeakMap;var RC;!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"}(RC||(RC={}));class DC{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=CC.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 UC(this.topNode,e)}cursorAt(e,t=0,n=0){let r=MC.get(this)||this.topNode,i=new UC(r);return i.moveTo(e,t),MC.set(this,i._tree),i}get topNode(){return new BC(this,0,0,null)}resolve(e,t=0){let n=_C(MC.get(this)||this.topNode,e,t,!1);return MC.set(this,n),n}resolveInner(e,t=0){let n=_C(TC.get(this)||this.topNode,e,t,!0);return TC.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 BC?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=CC.get(e.tree);if(o&&o.overlay&&o.overlay[0].from<=t&&o.overlay[o.overlay.length-1].to>=t){let s=new BC(o.tree,o.overlay[0].from+e.from,-1,e);(i||(i=[r])).push(_C(s,t,n,!1))}}return i?VC(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&RC.IncludeAnonymous)>0;for(let e=this.cursor(o|RC.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:GC(OC.none,this.children,this.positions,0,this.children.length,0,this.length,(e,t,n)=>new DC(this.type,e,t,n,this.propValues),e.makeTree||((e,t,n)=>new DC(OC.none,e,t,n)))}static build(e){return function(e){var t;let{buffer:n,nodeSet:r,maxBufferLength:i=xC,reused:o=[],minRepeatType:s=r.types.length}=e,a=Array.isArray(n)?new PC(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 LC(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=GC(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 LC(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 DC){if(!l&&o.type==e&&o.length==i)return o;(s=o.prop(EC.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=[EC.contextHash,o];s=s?[e].concat(s):[e]}if(i>25){let e=[EC.lookAhead,i];s=s?[e].concat(s):[e]}return new DC(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 DC(l[e.topID],b.reverse(),y.reverse(),w)}(e)}}DC.empty=new DC(OC.none,[],[],0);class PC{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 PC(this.buffer,this.index)}}class LC{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return OC.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&&!(IC(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 LC(i,o,this.set)}}function IC(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 _C(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 BC&&e.index<0?null:e.parent;if(!t)return e;e=t}let o=r?0:RC.IgnoreOverlays;if(r)for(let r=e,s=r.parent;s;r=s,s=r.parent)r instanceof BC&&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 jC{cursor(e=0){return new UC(this,e)}getChild(e,t=null,n=null){let r=FC(this,e,t,n);return r.length?r[0]:null}getChildren(e,t=null,n=null){return FC(this,e,t,n)}resolve(e,t=0){return _C(this,e,t,!1)}resolveInner(e,t=0){return _C(this,e,t,!0)}matchContext(e){return WC(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 BC extends jC{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&RC.EnterBracketed&&c instanceof DC&&null===(null===(o=CC.get(c))||void 0===o?void 0:o.overlay)&&(u>=n||u+c.length<=n)||IC(r,n,u,u+c.length))if(c instanceof LC){if(i&RC.ExcludeBuffers)continue;let o=c.findChild(0,c.buffer.length,t,n-u,r);if(o>-1)return new HC(new zC(s,c,e,u),null,o)}else if(i&RC.IncludeAnonymous||!c.type.isAnonymous||$C(c)){let o;if(!(i&RC.IgnoreMounts)&&(o=CC.get(c))&&!o.overlay)return new BC(o.tree,u,e,s);let a=new BC(c,u,e,s);return i&RC.IncludeAnonymous||!a.type.isAnonymous?a:a.nextChild(t<0?c.children.length-1:0,t,n,r,i)}}if(i&RC.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&RC.IgnoreOverlays)&&(r=CC.get(this._tree))&&r.overlay){let i=e-this.from,o=n&RC.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 BC(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 FC(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 WC(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 zC{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}}class HC extends jC{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 HC(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&RC.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 HC(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 HC(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 HC(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 DC(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function VC(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 BC&&n.index<0?null:n.parent,i=e.slice();return r?i[t]=r:i.splice(t,1),new qC(i,n)}class qC{constructor(e,t){this.heads=e,this.node=t}get next(){return VC(this.heads)}}class UC{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&~RC.EnterBracketed,e instanceof BC)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 BC?(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&RC.ExcludeBuffers)&&this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&RC.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&RC.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&RC.IncludeAnonymous||e instanceof LC||!e.type.isAnonymous||$C(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 HC(this.buffer,t,this.stack[e]);return this.bufferNode=new HC(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 WC(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 WC(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 $C(e){return e.children.some(e=>e instanceof LC||!e.type.isAnonymous||$C(e))}const KC=new WeakMap;function YC(e,t){if(!e.isAnonymous||t instanceof LC||t.type!=e)return 1;let n=KC.get(t);if(null==n){n=1;for(let r of t.children){if(r.type!=e||!(r instanceof DC)){n=1;break}n+=YC(e,r)}KC.set(t,n)}return n}function GC(e,t,n,r,i,o,s,a,l){let c=0;for(let n=r;n<i;n++)c+=YC(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=YC(e,n[c]);for(c++;c<s;c++){let t=YC(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(GC(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 XC{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 XC(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 XC(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 JC{startParse(e,t,n){return"string"==typeof e&&(e=new QC(e)),n=n?n.length?n.map(e=>new SC(e.from,e.to)):[new SC(0,0)]:[new SC(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 QC{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 EC({perNode:!0});let ZC=0;class eN{constructor(e,t,n,r){this.name=e,this.set=t,this.base=n,this.modified=r,this.id=ZC++}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 eN&&(t=e),null==t?void 0:t.base)throw new Error("Can not derive from a modified tag");let r=new eN(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 nN(e);return e=>e.modified.indexOf(t)>-1?e:nN.get(e.base||e,e.modified.concat(t).sort((e,t)=>e.id-t.id))}}let tN=0;class nN{constructor(e){this.name=e,this.instances=[],this.id=tN++}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 eN(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(nN.get(t,e));return i}}function rN(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 oN(r,i,s>0?n.slice(0,s):null);t[a]=l.sort(t[a])}}return iN.add(t)}const iN=new EC({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 oN(i.tags,i.mode,i.context);n?n.next=o:r=o,n=o}return r}});class oN{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 sN(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 aN(e,t,n,r=0,i=e.length){let o=new lN(r,Array.isArray(t)?t:[t],n);o.highlightRange(e.cursor(),r,i,"",o.highlighters),o.flush(i)}oN.empty=new oN([],2,null);class lN{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(iN);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}(e)||oN.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(EC.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 cN=eN.define,uN=cN(),hN=cN(),dN=cN(hN),fN=cN(hN),pN=cN(),mN=cN(pN),gN=cN(pN),vN=cN(),bN=cN(vN),yN=cN(),wN=cN(),xN=cN(),kN=cN(xN),SN=cN(),EN={comment:uN,lineComment:cN(uN),blockComment:cN(uN),docComment:cN(uN),name:hN,variableName:cN(hN),typeName:dN,tagName:cN(dN),propertyName:fN,attributeName:cN(fN),className:cN(hN),labelName:cN(hN),namespace:cN(hN),macroName:cN(hN),literal:pN,string:mN,docString:cN(mN),character:cN(mN),attributeValue:cN(mN),number:gN,integer:cN(gN),float:cN(gN),bool:cN(pN),regexp:cN(pN),escape:cN(pN),color:cN(pN),url:cN(pN),keyword:yN,self:cN(yN),null:cN(yN),atom:cN(yN),unit:cN(yN),modifier:cN(yN),operatorKeyword:cN(yN),controlKeyword:cN(yN),definitionKeyword:cN(yN),moduleKeyword:cN(yN),operator:wN,derefOperator:cN(wN),arithmeticOperator:cN(wN),logicOperator:cN(wN),bitwiseOperator:cN(wN),compareOperator:cN(wN),updateOperator:cN(wN),definitionOperator:cN(wN),typeOperator:cN(wN),controlOperator:cN(wN),punctuation:xN,separator:cN(xN),bracket:kN,angleBracket:cN(kN),squareBracket:cN(kN),paren:cN(kN),brace:cN(kN),content:vN,heading:bN,heading1:cN(bN),heading2:cN(bN),heading3:cN(bN),heading4:cN(bN),heading5:cN(bN),heading6:cN(bN),contentSeparator:cN(vN),list:cN(vN),quote:cN(vN),emphasis:cN(vN),strong:cN(vN),link:cN(vN),monospace:cN(vN),strikethrough:cN(vN),inserted:cN(),deleted:cN(),changed:cN(),invalid:cN(),meta:SN,documentMeta:cN(SN),annotation:cN(SN),processingInstruction:cN(SN),definition:eN.defineModifier("definition"),constant:eN.defineModifier("constant"),function:eN.defineModifier("function"),standard:eN.defineModifier("standard"),local:eN.defineModifier("local"),special:eN.defineModifier("special")};for(let e in EN){let t=EN[e];t instanceof eN&&(t.name=e)}var CN;sN([{tag:EN.link,class:"tok-link"},{tag:EN.heading,class:"tok-heading"},{tag:EN.emphasis,class:"tok-emphasis"},{tag:EN.strong,class:"tok-strong"},{tag:EN.keyword,class:"tok-keyword"},{tag:EN.atom,class:"tok-atom"},{tag:EN.bool,class:"tok-bool"},{tag:EN.url,class:"tok-url"},{tag:EN.labelName,class:"tok-labelName"},{tag:EN.inserted,class:"tok-inserted"},{tag:EN.deleted,class:"tok-deleted"},{tag:EN.literal,class:"tok-literal"},{tag:EN.string,class:"tok-string"},{tag:EN.number,class:"tok-number"},{tag:[EN.regexp,EN.escape,EN.special(EN.string)],class:"tok-string2"},{tag:EN.variableName,class:"tok-variableName"},{tag:EN.local(EN.variableName),class:"tok-variableName tok-local"},{tag:EN.definition(EN.variableName),class:"tok-variableName tok-definition"},{tag:EN.special(EN.variableName),class:"tok-variableName2"},{tag:EN.definition(EN.propertyName),class:"tok-propertyName tok-definition"},{tag:EN.typeName,class:"tok-typeName"},{tag:EN.namespace,class:"tok-namespace"},{tag:EN.className,class:"tok-className"},{tag:EN.macroName,class:"tok-macroName"},{tag:EN.propertyName,class:"tok-propertyName"},{tag:EN.operator,class:"tok-operator"},{tag:EN.comment,class:"tok-comment"},{tag:EN.meta,class:"tok-meta"},{tag:EN.invalid,class:"tok-invalid"},{tag:EN.punctuation,class:"tok-punctuation"}]);const NN=new EC;const ON=new EC;class AN{constructor(e,t,n=[],r=""){this.data=e,this.name=r,Ub.prototype.hasOwnProperty("tree")||Object.defineProperty(Ub.prototype,"tree",{get(){return RN(this)}}),this.parser=t,this.extension=[WN.of(this),Ub.languageData.of((e,t,n)=>{let r=MN(e,t,n),i=r.type.prop(NN);if(!i)return[];let o=e.facet(i),s=r.type.prop(ON);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 MN(e,t,n).type.prop(NN)==this.data}findRegions(e){let t=e.facet(WN);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(NN)==this.data)return void n.push({from:t,to:t+e.length});let i=e.prop(EC.mounted);if(i){if(i.tree.prop(NN)==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 DC&&r(i,e.positions[n]+t)}};return r(RN(e),0),n}get allowsNesting(){return!0}}function MN(e,t,n){let r=e.facet(WN),i=RN(e).topNode;if(!r||r.allowsNesting)for(let e=i;e;e=e.enter(t,n,RC.ExcludeBuffers|RC.EnterBracketed))e.type.isTop&&(i=e);return i}AN.setState=Pb.define();class TN extends AN{constructor(e,t,n){super(e,t,[],n),this.parser=t}static define(e){let t=(n=e.languageData,rb.define({combine:n?e=>e.concat(n):void 0}));var n;return new TN(t,e.parser.configure({props:[NN.add(e=>e.isTop?t:void 0)]}),e.name)}configure(e,t){return new TN(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function RN(e){let t=e.field(AN.state,!1);return t?t.tree:DC.empty}class DN{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 PN=null;class LN{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 LN(e,t,[],DC.empty,0,n,[],null)}startParse(){return this.parser.startParse(new DN(this.state.doc),this.fragments)}work(e,t){return null!=t&&t>=this.state.doc.length&&(t=void 0),this.tree!=DC.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(XC.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(XC.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=PN;PN=this;try{return e()}finally{PN=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=IN(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=XC.applyChanges(n,t),r=DC.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 LN(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=IN(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 JC{createParse(t,n,r){let i=r[0].from,o=r[r.length-1].to,s={parsedPos:i,advance(){let t=PN;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 DC(OC.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 PN}}function IN(e,t,n){return XC.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}class _N{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 _N(t)}static init(e){let t=Math.min(3e3,e.doc.length),n=LN.create(e.facet(WN).parser,e,{from:0,to:t});return n.work(20,t)||n.takeTree(),new _N(n)}}AN.state=ub.define({create:_N.init,update(e,t){for(let e of t.effects)if(e.is(AN.setState))return e.value;return t.startState.facet(WN)!=t.state.facet(WN)?_N.init(t.state):e.apply(t)}});let jN=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};"undefined"!=typeof requestIdleCallback&&(jN=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});const BN="undefined"!=typeof navigator&&(null===(CN=navigator.scheduling)||void 0===CN?void 0:CN.isInputPending)?()=>navigator.scheduling.isInputPending():null,FN=ix.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(AN.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(AN.state);t.tree==t.context.tree&&t.context.isDone(e.doc.length)||(this.working=jN(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(AN.state);if(i.tree==i.context.tree&&i.context.isDone(r+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!BN?Math.max(25,e.timeRemaining()-5):1e9),s=i.context.treeLen<r&&n.doc.length>r+1e3,a=i.context.work(()=>BN&&BN()||Date.now()>o,r+(s?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:AN.setState.of(new _N(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=>ex(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()}}}),WN=rb.define({combine:e=>e.length?e[0]:null,enables:e=>[AN.state,FN,TS.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]});class zN{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}const HN=rb.define(),VN=rb.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 qN(e){let t=e.facet(VN);return 9==t.charCodeAt(0)?e.tabSize*t.length:t.length}function UN(e,t){let n="",r=e.tabSize,i=e.facet(VN)[0];if("\t"==i){for(;t>=r;)n+="\t",t-=r;i=" "}for(let e=0;e<t;e++)n+=i;return n}function $N(e,t){e instanceof Ub&&(e=new KN(e));for(let n of e.state.facet(HN)){let r=n(e,t);if(void 0!==r)return r}let n=RN(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 GN(r,e,n)}(e,n,t):null}class KN{constructor(e,t={}){this.state=e,this.options=t,this.unit=qN(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 uy(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 YN=new EC;function GN(e,t,n){for(let r=e;r;r=r.next){let e=XN(r.node);if(e)return e(QN.create(t,n,r))}return 0}function XN(e){let t=e.type.prop(YN);if(t)return t;let n,r=e.firstChild;if(r&&(n=r.type.prop(EC.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?JN:null}function JN(){return 0}class QN extends KN{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 QN(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(ZN(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return GN(this.context.next,this.base,this.pos)}}function ZN(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function eO({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}const tO=rb.define(),nO=new EC;function rO(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function iO(e,t,n){for(let r of e.facet(tO)){let i=r(e,t,n);if(i)return i}return function(e,t,n){let r=RN(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(nO);if(a&&(s.to<r.length-50||r.length==e.doc.length||!rO(s))){let r=a(s,e);r&&r.from<=n&&r.from>=t&&r.to>n&&(i=r)}}return i}(e,t,n)}function oO(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 sO=Pb.define({map:oO}),aO=Pb.define({map:oO});function lO(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 cO=ub.define({create:()=>Uy.none,update(e,t){t.isUserEvent("delete")&&t.changes.iterChangedRanges((t,n)=>e=uO(e,t,n)),e=e.map(t.changes);for(let n of t.effects)if(n.is(sO)&&!dO(e,n.value.from,n.value.to)){let{preparePlaceholder:r}=t.state.facet(vO),i=r?Uy.replace({widget:new xO(r(t.state,n.value))}):wO;e=e.update({add:[i.range(n.value.from,n.value.to)]})}else n.is(aO)&&(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=uO(e,t.selection.main.head)),e},provide:e=>TS.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(wO.range(r,i))}return Uy.set(t,!0)}});function uO(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 hO(e,t,n){var r;let i=null;return null===(r=e.field(cO,!1))||void 0===r||r.between(t,n,(e,t)=>{(!i||i.from>e)&&(i={from:e,to:t})}),i}function dO(e,t,n){let r=!1;return e.between(t,t,(e,i)=>{e==t&&i==n&&(r=!0)}),r}function fO(e,t){return e.field(cO,!1)?t:t.concat(Pb.appendConfig.of(bO()))}function pO(e,t,n=!0){let r=e.state.doc.lineAt(t.from).number,i=e.state.doc.lineAt(t.to).number;return TS.announce.of(`${e.state.phrase(n?"Folded lines":"Unfolded lines")} ${r} ${e.state.phrase("to")} ${i}.`)}const mO=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:e=>{for(let t of lO(e)){let n=iO(e.state,t.from,t.to);if(n)return e.dispatch({effects:fO(e.state,[sO.of(n),pO(e,n)])}),!0}return!1}},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:e=>{if(!e.state.field(cO,!1))return!1;let t=[];for(let n of lO(e)){let r=hO(e.state,n.from,n.to);r&&t.push(aO.of(r),pO(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=iO(t,i.from,i.to);o&&n.push(sO.of(o)),r=(o?e.lineBlockAt(o.to):i).to+1}return n.length&&e.dispatch({effects:fO(e.state,n)}),!!n.length}},{key:"Ctrl-Alt-]",run:e=>{let t=e.state.field(cO,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,(e,t)=>{n.push(aO.of({from:e,to:t}))}),e.dispatch({effects:n}),!0}}],gO={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},vO=rb.define({combine:e=>$b(e,gO)});function bO(e){let t=[cO,EO];return e&&t.push(vO.of(e)),t}function yO(e,t){let{state:n}=e,r=n.facet(vO),i=t=>{let n=e.lineBlockAt(e.posAtDOM(t.target)),r=hO(e.state,n.from,n.to);r&&e.dispatch({effects:aO.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 wO=Uy.replace({widget:new class extends Vy{toDOM(e){return yO(e,null)}}});class xO extends Vy{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return yO(e,this.value)}}const kO={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class SO extends QE{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 EO=TS.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 CO{constructor(e,t){let n;function r(e){let t=my.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 AN?e=>e.prop(NN)==o.data:o?e=>e==o:void 0,this.style=sN(e.map(e=>({tag:e.tag,class:e.class||r(Object.assign({},e,{tag:null}))})),{all:i}).style,this.module=n?new my(n):null,this.themeType=t.themeType}static define(e,t){return new CO(e,t||{})}}const NO=rb.define(),OO=rb.define({combine:e=>e.length?[e[0]]:null});function AO(e){let t=e.facet(NO);return t.length?t:e.facet(OO)}function MO(e,t){let n,r=[RO];return e instanceof CO&&(e.module&&r.push(TS.styleModule.of(e.module)),n=e.themeType),(null==t?void 0:t.fallback)?r.push(OO.of(e)):n?r.push(NO.computeN([TS.darkTheme],t=>t.facet(TS.darkTheme)==("dark"==n)?[e]:[])):r.push(NO.of(e)),r}class TO{constructor(e){this.markCache=Object.create(null),this.tree=RN(e.state),this.decorations=this.buildDeco(e,AO(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=RN(e.state),n=AO(e.state),r=n!=AO(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 Uy.none;let n=new Zb;for(let{from:r,to:i}of e.visibleRanges)aN(this.tree,t,(e,t,r)=>{n.add(e,t,this.markCache[r]||(this.markCache[r]=Uy.mark({class:r})))},r,i);return n.finish()}}const RO=gb.high(ix.fromClass(TO,{decorations:e=>e.decorations})),DO=CO.define([{tag:EN.meta,color:"#404740"},{tag:EN.link,textDecoration:"underline"},{tag:EN.heading,textDecoration:"underline",fontWeight:"bold"},{tag:EN.emphasis,fontStyle:"italic"},{tag:EN.strong,fontWeight:"bold"},{tag:EN.strikethrough,textDecoration:"line-through"},{tag:EN.keyword,color:"#708"},{tag:[EN.atom,EN.bool,EN.url,EN.contentSeparator,EN.labelName],color:"#219"},{tag:[EN.literal,EN.inserted],color:"#164"},{tag:[EN.string,EN.deleted],color:"#a11"},{tag:[EN.regexp,EN.escape,EN.special(EN.string)],color:"#e40"},{tag:EN.definition(EN.variableName),color:"#00f"},{tag:EN.local(EN.variableName),color:"#30a"},{tag:[EN.typeName,EN.namespace],color:"#085"},{tag:EN.className,color:"#167"},{tag:[EN.special(EN.variableName),EN.macroName],color:"#256"},{tag:EN.definition(EN.propertyName),color:"#00c"},{tag:EN.comment,color:"#940"},{tag:EN.invalid,color:"#f00"}]),PO=TS.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),LO="()[]{}",IO=rb.define({combine:e=>$b(e,{afterCursor:!0,brackets:LO,maxScanDistance:1e4,renderMatch:BO})}),_O=Uy.mark({class:"cm-matchingBracket"}),jO=Uy.mark({class:"cm-nonmatchingBracket"});function BO(e){let t=[],n=e.matched?_O:jO;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 FO=ub.define({create:()=>Uy.none,update(e,t){if(!t.docChanged&&!t.selection)return e;let n=[],r=t.state.facet(IO);for(let e of t.state.selection.ranges){if(!e.empty)continue;let i=qO(t.state,e.head,-1,r)||e.head>0&&qO(t.state,e.head-1,1,r)||r.afterCursor&&(qO(t.state,e.head,1,r)||e.head<t.state.doc.length&&qO(t.state,e.head+1,-1,r));i&&(n=n.concat(r.renderMatch(i,t.state)))}return Uy.set(n,!0)},provide:e=>TS.decorations.from(e)}),WO=[FO,PO];const zO=new EC;function HO(e,t,n){let r=e.prop(t<0?EC.openedBy:EC.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 VO(e){let t=e.type.prop(zO);return t?t(e.node):e}function qO(e,t,n,r={}){let i=r.maxScanDistance||1e4,o=r.brackets||LO,s=RN(e),a=s.resolveInner(t,n);for(let r=a;r;r=r.parent){let i=HO(r.type,n,o);if(i&&r.from<r.to){let s=VO(r);if(s&&(n>0?t>=s.from&&t<s.to:t>s.from&&t<=s.to))return UO(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 UO(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=VO(u);return{start:l,end:e?{from:e.from,to:e.to}:void 0,matched:!0}}if(HO(u.type,n,s))c++;else if(HO(u.type,-n,s)){if(0==c){let e=VO(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 $O=Object.create(null),KO=[OC.none],YO=[],GO=Object.create(null),XO=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"]])XO[e]=QO($O,t);function JO(e,t){YO.indexOf(e)>-1||YO.push(e)}function QO(e,t){let n=[];for(let r of t.split(" ")){let t=[];for(let n of r.split(".")){let r=e[n]||EN[n];r?"function"==typeof r?t.length?t=t.map(r):JO(n):t.length?JO(n):t=Array.isArray(r)?r:[r]:JO(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=GO[i];if(o)return o.id;let s=GO[i]=OC.define({id:KO.length,name:r,props:[rN({[r]:n})]});return KO.push(s),s.id}ww.RTL,ww.LTR;function ZO(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 eA=ZO(sA,0),tA=ZO(oA,0),nA=ZO((e,t)=>oA(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 rA(e,t){let n=e.languageDataAt("commentTokens",t,1);return n.length?n[0]:{}}const iA=50;function oA(e,t,n=t.selection.ranges){let r=n.map(e=>rA(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-iA,r),l=e.sliceDoc(i,i+iA),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*iA?o=s=e.sliceDoc(r,i):(o=e.sliceDoc(r,r+iA),s=e.sliceDoc(i-iA,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 sA(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=rA(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 aA=Tb.define(),lA=Tb.define(),cA=rb.define(),uA=rb.define({combine:e=>$b(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)})}),hA=ub.define({create:()=>OA.empty,update(e,t){let n=t.state.facet(uA),r=t.annotation(aA);if(r){let i=vA.fromTransaction(t,r.selection),o=r.side,s=0==o?e.undone:e.done;return s=i?bA(s,s.length,n.minDepth,i):kA(s,t.startState.selection),new OA(0==o?r.rest:s,0==o?s:r.rest)}let i=t.annotation(lA);if("full"!=i&&"before"!=i||(e=e.isolate()),!1===t.annotation(Lb.addToHistory))return t.changes.empty?e:e.addMapping(t.changes.desc);let o=vA.fromTransaction(t),s=t.annotation(Lb.time),a=t.annotation(Lb.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 OA(e.done.map(vA.fromJSON),e.undone.map(vA.fromJSON))});function dA(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(hA,!1);if(!i)return!1;let o=i.pop(e,n,t);return!!o&&(r(o),!0)}}const fA=dA(0,!1),pA=dA(1,!1),mA=dA(0,!0),gA=dA(1,!0);class vA{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 vA(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 vA(e.changes&&$v.fromJSON(e.changes),[],e.mapped&&Uv.fromJSON(e.mapped),e.startSelection&&eb.fromJSON(e.startSelection),e.selectionsAfter.map(eb.fromJSON))}static fromTransaction(e,t){let n=wA;for(let t of e.startState.facet(cA)){let r=t(e);r.length&&(n=n.concat(r))}return!n.length&&e.changes.empty?null:new vA(e.changes.invert(e.startState.doc),n,void 0,t||e.startState.selection,wA)}static selection(e){return new vA(void 0,wA,void 0,void 0,e)}}function bA(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 yA(e,t){return e.length?t.length?e.concat(t):e:t}const wA=[],xA=200;function kA(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-xA));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),bA(e,e.length-1,1e9,n.setSelAfter(r)))}return[vA.selection([t])]}function SA(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 EA(e,t){if(!e.length)return e;let n=e.length,r=wA;for(;n;){let i=CA(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?[vA.selection(r)]:wA}function CA(e,t,n){let r=yA(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):wA,n);if(!e.changes)return vA.selection(r);let i=e.changes.map(t),o=t.mapDesc(e.changes,!0),s=e.mapped?e.mapped.composeDesc(o):o;return new vA(i,Pb.mapEffects(e.effects,t),s,e.startSelection.map(o),r)}const NA=/^(input\.type|delete)($|\.)/;class OA{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 OA(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||NA.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)?bA(o,o.length-1,r.minDepth,new vA(e.changes.compose(s.changes),yA(Pb.mapEffects(e.effects,s.changes),s.effects),s.mapped,s.startSelection,wA)):bA(o,o.length,r.minDepth,e),new OA(o,wA,t,n)}addSelection(e,t,n,r){let i=this.done.length?this.done[this.done.length-1].selectionsAfter:wA;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 OA(kA(this.done,e),this.undone,t,n);var o,s}addMapping(e){return new OA(EA(this.done,e),EA(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:aA.of({side:e,rest:SA(r),selection:o}),userEvent:0==e?"select.undo":"select.redo",scrollIntoView:!0});if(i.changes){let n=1==r.length?wA:r.slice(0,r.length-1);return i.mapped&&(n=EA(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:aA.of({side:e,rest:n,selection:o}),filter:!1,userEvent:0==e?"undo":"redo",scrollIntoView:!0})}return null}}OA.empty=new OA(wA,wA);const AA=[{key:"Mod-z",run:fA,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:pA,preventDefault:!0},{linux:"Ctrl-Shift-z",run:pA,preventDefault:!0},{key:"Mod-u",run:mA,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:gA,preventDefault:!0}];function MA(e,t){return eb.create(e.ranges.map(t),e.mainIndex)}function TA(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function RA({state:e,dispatch:t},n){let r=MA(e.selection,n);return!r.eq(e.selection,!0)&&(t(TA(e,r)),!0)}function DA(e,t){return eb.cursor(t?e.to:e.from)}function PA(e,t){return RA(e,n=>n.empty?e.moveByChar(n,t):DA(n,t))}function LA(e){return e.textDirectionAt(e.state.selection.main.head)==ww.LTR}const IA=e=>PA(e,!LA(e)),_A=e=>PA(e,LA(e));function jA(e,t){return RA(e,n=>n.empty?e.moveByGroup(n,t):DA(n,t))}function BA(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 FA(e,t,n){let r,i,o=RN(e).resolveInner(t.head),s=n?EC.closedBy:EC.openedBy;for(let r=t.head;;){let t=n?o.childAfter(r):o.childBefore(r);if(!t)break;BA(e,t,s)?o=t:r=n?t.to:t.from}return i=o.type.prop(s)&&(r=n?qO(e,o.from,1):qO(e,o.to,-1))&&r.matched?n?r.end.to:r.end.from:n?o.to:o.from,eb.cursor(i,n?-1:1)}function WA(e,t){return RA(e,n=>{if(!n.empty)return DA(n,t);let r=e.moveVertically(n,t);return r.head!=n.head?r:e.moveToLineBoundary(n,t)})}const zA=e=>WA(e,!1),HA=e=>WA(e,!0);function VA(e){let t,n=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,r=0,i=0;if(n){for(let t of e.state.facet(TS.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 qA(e,t){let n,r=VA(e),{state:i}=e,o=MA(i.selection,n=>n.empty?e.moveVertically(n,t,r.height):DA(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=TS.scrollIntoView(o.main.head,{y:"start",yMargin:t.top-a}))}return e.dispatch(TA(i,o),{effects:n}),!0}const UA=e=>qA(e,!1),$A=e=>qA(e,!0);function KA(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=eb.cursor(r.from+n))}return i}function YA(e,t){let n=MA(e.state.selection,e=>{let n=t(e);return eb.range(e.anchor,n.head,n.goalColumn,n.bidiLevel||void 0)});return!n.eq(e.state.selection)&&(e.dispatch(TA(e.state,n)),!0)}function GA(e,t){return YA(e,n=>e.moveByChar(n,t))}const XA=e=>GA(e,!LA(e)),JA=e=>GA(e,LA(e));function QA(e,t){return YA(e,n=>e.moveByGroup(n,t))}function ZA(e,t){return YA(e,n=>e.moveVertically(n,t))}const eM=e=>ZA(e,!1),tM=e=>ZA(e,!0);function nM(e,t){return YA(e,n=>e.moveVertically(n,t,VA(e).height))}const rM=e=>nM(e,!1),iM=e=>nM(e,!0),oM=({state:e,dispatch:t})=>(t(TA(e,{anchor:0})),!0),sM=({state:e,dispatch:t})=>(t(TA(e,{anchor:e.doc.length})),!0),aM=({state:e,dispatch:t})=>(t(TA(e,{anchor:e.selection.main.anchor,head:0})),!0),lM=({state:e,dispatch:t})=>(t(TA(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0);function cM(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(TA(n,eb.create(i,i.length-1))),!0)}function uM(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=hM(e,s,!1)):s>i&&(n="delete.forward",s=hM(e,s,!0)),i=Math.min(i,s),o=Math.max(o,s)}else i=hM(e,i,!1),o=hM(e,o,!0);return i==o?{range:r}:{changes:{from:i,to:o},range:eb.cursor(i,i<r.head?-1:1)}});return!i.changes.empty&&(e.dispatch(r.update(i,{scrollIntoView:!0,userEvent:n,effects:"delete.selection"==n?TS.announce.of(r.phrase("Selection deleted")):void 0})),!0)}function hM(e,t,n){if(e instanceof TS)for(let r of e.state.facet(TS.atomicRanges).map(t=>t(e)))r.between(t,t,(e,r)=>{e<t&&r>t&&(t=n?r:e)});return t}const dM=(e,t,n)=>uM(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=uy(i,a.tabSize)%qN(a)||qN(a);for(let t=0;t<e&&" "==i[i.length-1-t];t++)s--;o=s}else o=Fv(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=Fv(l.text,o-l.from,!1,!1)+l.from);return o}),fM=e=>dM(e,!1,!0),pM=e=>dM(e,!0,!1),mM=(e,t)=>uM(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=Fv(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}),gM=e=>mM(e,!1);function vM(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 bM(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let t of vM(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(eb.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(eb.range(e.anchor-s,e.head-s))}}return!!r.length&&(t(e.update({changes:r,scrollIntoView:!0,selection:eb.create(i,e.selection.mainIndex),userEvent:"move.line"})),!0)}function yM(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of vM(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 wM=kM(!1),xM=kM(!0);function kM(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=RN(e).resolveInner(t),i=r.childBefore(t),o=r.childAfter(t);return i&&o&&i.to<=t&&o.from>=t&&(n=i.type.prop(EC.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 KN(t,{simulateBreak:r,simulateDoubleBreak:!!s}),l=$N(a,r);for(null==l&&(l=uy(/^\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=["",UN(t,l)];return s&&c.push(UN(t,a.lineIndent(o.from,-1))),{changes:{from:r,to:i,insert:Mv.of(c)},range:eb.cursor(r+1+c[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:"input"})),!0}}function SM(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:eb.range(o.mapPos(r.anchor,1),o.mapPos(r.head,1))}})}const EM=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(SM(e,(t,n)=>{n.push({from:t.from,insert:e.facet(VN)})}),{userEvent:"input.indent"})),!0),CM=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(SM(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=uy(r,e.tabSize),o=0,s=UN(e,Math.max(0,i-qN(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),NM=[{key:"Ctrl-b",run:IA,shift:XA,preventDefault:!0},{key:"Ctrl-f",run:_A,shift:JA},{key:"Ctrl-p",run:zA,shift:eM},{key:"Ctrl-n",run:HA,shift:tM},{key:"Ctrl-a",run:e=>RA(e,t=>eb.cursor(e.lineBlockAt(t.head).from,1)),shift:e=>YA(e,t=>eb.cursor(e.lineBlockAt(t.head).from))},{key:"Ctrl-e",run:e=>RA(e,t=>eb.cursor(e.lineBlockAt(t.head).to,-1)),shift:e=>YA(e,t=>eb.cursor(e.lineBlockAt(t.head).to))},{key:"Ctrl-d",run:pM},{key:"Ctrl-h",run:fM},{key:"Ctrl-k",run:e=>uM(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:gM},{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:Mv.of(["",""])},range:eb.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:Fv(r.text,n-r.from,!1)+r.from,o=n==r.to?n+1:Fv(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:eb.cursor(o)}});return!n.changes.empty&&(t(e.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)}},{key:"Ctrl-v",run:$A}],OM=[{key:"ArrowLeft",run:IA,shift:XA,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:e=>jA(e,!LA(e)),shift:e=>QA(e,!LA(e)),preventDefault:!0},{mac:"Cmd-ArrowLeft",run:e=>RA(e,t=>KA(e,t,!LA(e))),shift:e=>YA(e,t=>KA(e,t,!LA(e))),preventDefault:!0},{key:"ArrowRight",run:_A,shift:JA,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:e=>jA(e,LA(e)),shift:e=>QA(e,LA(e)),preventDefault:!0},{mac:"Cmd-ArrowRight",run:e=>RA(e,t=>KA(e,t,LA(e))),shift:e=>YA(e,t=>KA(e,t,LA(e))),preventDefault:!0},{key:"ArrowUp",run:zA,shift:eM,preventDefault:!0},{mac:"Cmd-ArrowUp",run:oM,shift:aM},{mac:"Ctrl-ArrowUp",run:UA,shift:rM},{key:"ArrowDown",run:HA,shift:tM,preventDefault:!0},{mac:"Cmd-ArrowDown",run:sM,shift:lM},{mac:"Ctrl-ArrowDown",run:$A,shift:iM},{key:"PageUp",run:UA,shift:rM},{key:"PageDown",run:$A,shift:iM},{key:"Home",run:e=>RA(e,t=>KA(e,t,!1)),shift:e=>YA(e,t=>KA(e,t,!1)),preventDefault:!0},{key:"Mod-Home",run:oM,shift:aM},{key:"End",run:e=>RA(e,t=>KA(e,t,!0)),shift:e=>YA(e,t=>KA(e,t,!0)),preventDefault:!0},{key:"Mod-End",run:sM,shift:lM},{key:"Enter",run:wM,shift:wM},{key:"Mod-a",run:({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0)},{key:"Backspace",run:fM,shift:fM,preventDefault:!0},{key:"Delete",run:pM,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:gM,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:e=>mM(e,!0),preventDefault:!0},{mac:"Mod-Backspace",run:e=>uM(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=>uM(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(NM.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),AM=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:e=>RA(e,t=>FA(e.state,t,!LA(e))),shift:e=>YA(e,t=>FA(e.state,t,!LA(e)))},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:e=>RA(e,t=>FA(e.state,t,LA(e))),shift:e=>YA(e,t=>FA(e.state,t,LA(e)))},{key:"Alt-ArrowUp",run:({state:e,dispatch:t})=>bM(e,t,!1)},{key:"Shift-Alt-ArrowUp",run:({state:e,dispatch:t})=>yM(e,t,!1)},{key:"Alt-ArrowDown",run:({state:e,dispatch:t})=>bM(e,t,!0)},{key:"Shift-Alt-ArrowDown",run:({state:e,dispatch:t})=>yM(e,t,!0)},{key:"Mod-Alt-ArrowUp",run:e=>cM(e,!1)},{key:"Mod-Alt-ArrowDown",run:e=>cM(e,!0)},{key:"Escape",run:({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=eb.create([n.main]):n.main.empty||(r=eb.create([eb.cursor(n.main.head)])),!!r&&(t(TA(e,r)),!0)}},{key:"Mod-Enter",run:xM},{key:"Alt-l",mac:"Ctrl-l",run:({state:e,dispatch:t})=>{let n=vM(e).map(({from:t,to:n})=>eb.range(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:eb.create(n),userEvent:"select"})),!0}},{key:"Mod-i",run:({state:e,dispatch:t})=>{let n=MA(e.selection,t=>{let n=RN(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 eb.range(n.to,n.from)}return t});return!n.eq(e.selection)&&(t(TA(e,n)),!0)},preventDefault:!0},{key:"Mod-[",run:CM},{key:"Mod-]",run:EM},{key:"Mod-Alt-\\",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new KN(e,{overrideIndentation:e=>{let t=n[e];return null==t?-1:t}}),i=SM(e,(t,i,o)=>{let s=$N(r,t.from);if(null==s)return;/\S/.test(t.text)||(s=0);let a=/^\s*/.exec(t.text)[0],l=UN(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(vM(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=MA(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=MA(e.selection,t=>{let i=qO(e,t.head,-1)||qO(e,t.head,1)||t.head>0&&qO(e,t.head-1,1)||t.head<e.doc.length&&qO(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?eb.range(t.anchor,o):eb.cursor(o)});return!!r&&(t(TA(e,i)),!0)}(e,t,!1)},{key:"Mod-/",run:e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=rA(e.state,n.from);return r.line?eA(e):!!r.block&&nA(e)}},{key:"Alt-A",run:tA},{key:"Ctrl-m",mac:"Shift-Alt-m",run:e=>(e.setTabFocusMode(),!0)}].concat(OM),MM={key:"Tab",run:EM,shift:CM},TM="function"==typeof String.prototype.normalize?e=>e.normalize("NFKD"):e=>e;class RM{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(TM(e)):TM,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 Wv(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=zv(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=Hv(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&&(RM.prototype[Symbol.iterator]=function(){return this});const DM={from:-1,to:-1,match:/.*/.exec("")},PM="gm"+(null==/x/.unicode?"":"u");class LM{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine="",this.done=!1,this.value=DM,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new jM(e,t,n,r,i);this.re=new RegExp(t,PM+((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=BM(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=BM(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 IM=new WeakMap;class _M{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,n){let r=IM.get(e);if(!r||r.from>=n||r.to<=t){let r=new _M(t,e.sliceString(t,n));return IM.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)),IM.set(e,new _M(o,i)),new _M(t,i.slice(t-o,n-o))}}class jM{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=DM,this.matchPos=BM(e,r),this.re=new RegExp(t,PM+((null==n?void 0:n.ignoreCase)?"i":"")),this.test=null==n?void 0:n.test,this.flat=_M.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=BM(this.text,n+(e==n?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=_M.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+2*this.flat.text.length))}}}function BM(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&&(LM.prototype[Symbol.iterator]=jM.prototype[Symbol.iterator]=function(){return this});const FM={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},WM=rb.define({combine:e=>$b(e,FM,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})});const zM=Uy.mark({class:"cm-selectionMatch"}),HM=Uy.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function VM(e,t,n,r){return!(0!=n&&e(t.sliceDoc(n-1,n))==zb.Word||r!=t.doc.length&&e(t.sliceDoc(r,r+1))==zb.Word)}const qM=ix.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(WM),{state:n}=e,r=n.selection;if(r.ranges.length>1)return Uy.none;let i,o=r.main,s=null;if(o.empty){if(!t.highlightWordAroundCursor)return Uy.none;let e=n.wordAt(o.head);if(!e)return Uy.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 Uy.none;if(t.wholeWords){if(i=n.sliceDoc(o.from,o.to),s=n.charCategorizer(o.head),!VM(s,n,o.from,o.to)||!function(e,t,n,r){return e(t.sliceDoc(n,n+1))==zb.Word&&e(t.sliceDoc(r-1,r))==zb.Word}(s,n,o.from,o.to))return Uy.none}else if(i=n.sliceDoc(o.from,o.to),!i)return Uy.none}let a=[];for(let r of e.visibleRanges){let e=new RM(n.doc,i,r.from,r.to);for(;!e.next().done;){let{from:r,to:i}=e.value;if((!s||VM(s,n,r,i))&&(o.empty&&r<=o.from&&i>=o.to?a.push(HM.range(r,i)):(r>=o.to||i<=o.from)&&a.push(zM.range(r,i)),a.length>t.maxMatches))return Uy.none}}return Uy.set(a)}},{decorations:e=>e.decorations}),UM=TS.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}});const $M=rb.define({combine:e=>$b(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new xT(e),scrollToMatch:e=>TS.scrollIntoView(e)})});class KM{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,PM),!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 eT(this):new XM(this)}getCursor(e,t=0,n){let r=e.doc?e:Ub.create({doc:e});return null==n&&(n=r.doc.length),this.regexp?JM(this,r,t,n):GM(this,r,t,n)}}class YM{constructor(e){this.spec=e}}function GM(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(QM(i,n-o))==zb.Word&&t(ZM(i,n-o))==zb.Word||t(ZM(i,r-o))==zb.Word&&t(QM(i,r-o))==zb.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 RM(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}class XM extends YM{constructor(e){super(e)}nextMatch(e,t,n){let r=GM(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=GM(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=GM(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=GM(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=GM(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 JM(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(QM(n.input,n.index))!=zb.Word||o(ZM(n.input,n.index))!=zb.Word)&&(o(ZM(n.input,n.index+n[0].length))!=zb.Word||o(QM(n.input,n.index+n[0].length))!=zb.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 LM(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function QM(e,t){return e.slice(Fv(e,t,!1),t)}function ZM(e,t){return e.slice(t,Fv(e,t))}class eT extends YM{nextMatch(e,t,n){let r=JM(this.spec,e,n,e.doc.length).next();return r.done&&(r=JM(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=JM(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=JM(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=JM(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 tT=Pb.define(),nT=Pb.define(),rT=ub.define({create:e=>new iT(mT(e).create(),null),update(e,t){for(let n of t.effects)n.is(tT)?e=new iT(n.value.create(),e.panel):n.is(nT)&&(e=new iT(e.query,n.value?pT:null));return e},provide:e=>KE.from(e,e=>e.panel)});class iT{constructor(e,t){this.query=e,this.panel=t}}const oT=Uy.mark({class:"cm-searchMatch"}),sT=Uy.mark({class:"cm-searchMatch cm-searchMatch-selected"}),aT=ix.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(rT))}update(e){let t=e.state.field(rT);(t!=e.startState.field(rT)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return Uy.none;let{view:n}=this,r=new Zb;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?sT:oT)})}return r.finish()}},{decorations:e=>e.decorations});function lT(e){return t=>{let n=t.state.field(rT,!1);return n&&n.query.spec.valid?e(t,n):bT(t)}}const cT=lT((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let i=eb.single(r.from,r.to),o=e.state.facet($M);return e.dispatch({selection:i,effects:[CT(e,r),o.scrollToMatch(i.main,e)],userEvent:"select.search"}),vT(e),!0}),uT=lT((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,i=t.prevMatch(n,r,r);if(!i)return!1;let o=eb.single(i.from,i.to),s=e.state.facet($M);return e.dispatch({selection:o,effects:[CT(e,i),s.scrollToMatch(o.main,e)],userEvent:"select.search"}),vT(e),!0}),hT=lT((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!(!n||!n.length)&&(e.dispatch({selection:eb.create(n.map(e=>eb.range(e.from,e.to))),userEvent:"select.search.matches"}),!0)}),dT=lT((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(TS.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(r).number)+".")));let h=e.state.changes(c);return l&&(s=eb.single(l.from,l.to).map(h),u.push(CT(e,l)),u.push(n.facet($M).scrollToMatch(s.main,e))),e.dispatch({changes:h,selection:s,effects:u,userEvent:"input.replace"}),!0}),fT=lT((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:TS.announce.of(r),userEvent:"input.replace.all"}),!0});function pT(e){return e.state.facet($M).createPanel(e)}function mT(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($M);return new KM({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 gT(e){let t=VE(e,pT);return t&&t.dom.querySelector("[main-field]")}function vT(e){let t=gT(e);t&&t==e.root.activeElement&&t.select()}const bT=e=>{let t=e.state.field(rT,!1);if(t&&t.panel){let n=gT(e);if(n&&n!=e.root.activeElement){let r=mT(e.state,t.query.spec);r.valid&&e.dispatch({effects:tT.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[nT.of(!0),t?tT.of(mT(e.state,t.query.spec)):Pb.appendConfig.of(OT)]});return!0},yT=e=>{let t=e.state.field(rT,!1);if(!t||!t.panel)return!1;let n=VE(e,pT);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:nT.of(!1)}),!0},wT=[{key:"Mod-f",run:bT,scope:"editor search-panel"},{key:"F3",run:cT,shift:uT,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:cT,shift:uT,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:yT,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 RM(e.doc,e.sliceDoc(r,i));!t.next().done;){if(o.length>1e3)return!1;t.value.from==r&&(s=o.length),o.push(eb.range(t.value.from,t.value.to))}return t(e.update({selection:eb.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}=YE(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=eb.cursor(d.from+Math.max(0,Math.min(u,d.length)));e.dispatch({effects:[r,TS.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=eb.create(n.ranges.map(t=>e.wordAt(t.head)||eb.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 RM(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 RM(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(eb.range(i.from,i.to),!1),effects:TS.scrollIntoView(i.to)})),!0)},preventDefault:!0}];class xT{constructor(e){this.view=e;let t=this.query=e.state.field(rT).query.spec;function n(e,t,n){return Ey("button",{class:"cm-button",name:e,onclick:t,type:"button"},n)}this.commit=this.commit.bind(this),this.searchField=Ey("input",{value:t.search,placeholder:kT(e,"Find"),"aria-label":kT(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=Ey("input",{value:t.replace,placeholder:kT(e,"Replace"),"aria-label":kT(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=Ey("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=Ey("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=Ey("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit}),this.dom=Ey("div",{onkeydown:e=>this.keydown(e),class:"cm-search"},[this.searchField,n("next",()=>cT(e),[kT(e,"next")]),n("prev",()=>uT(e),[kT(e,"previous")]),n("select",()=>hT(e),[kT(e,"all")]),Ey("label",null,[this.caseField,kT(e,"match case")]),Ey("label",null,[this.reField,kT(e,"regexp")]),Ey("label",null,[this.wordField,kT(e,"by word")]),...e.state.readOnly?[]:[Ey("br"),this.replaceField,n("replace",()=>dT(e),[kT(e,"replace")]),n("replaceAll",()=>fT(e),[kT(e,"replace all")])],Ey("button",{name:"close",onclick:()=>yT(e),"aria-label":kT(e,"close"),type:"button"},["×"])])}commit(){let e=new KM({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:tT.of(e)}))}keydown(e){var t,n,r;t=this.view,n=e,r="search-panel",qS(WS(t.state),n,t,r)?e.preventDefault():13==e.keyCode&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?uT:cT)(this.view)):13==e.keyCode&&e.target==this.replaceField&&(e.preventDefault(),dT(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(tT)&&!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($M).top}}function kT(e,t){return e.state.phrase(t)}const ST=30,ET=/[\s\.,:;?!]/;function CT(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-ST),s=Math.min(i,n+ST),a=e.state.sliceDoc(o,s);if(o!=r.from)for(let e=0;e<ST;e++)if(!ET.test(a[e+1])&&ET.test(a[e])){a=a.slice(e);break}if(s!=i)for(let e=a.length-1;e>a.length-ST;e--)if(!ET.test(a[e-1])&&ET.test(a[e])){a=a.slice(0,e);break}return TS.announce.of(`${e.state.phrase("current match")}. ${a} ${e.state.phrase("on line")} ${r.number}.`)}const NT=TS.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"}}),OT=[rT,gb.low(aT),NT];class AT{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=RN(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(PT(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 MT(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 TT(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=MT(t)+MT(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 RT{constructor(e,t,n,r){this.completion=e,this.source=t,this.match=n,this.score=r}}function DT(e){return e.selection.main.from}function PT(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 LT=Tb.define();function IT(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:eb.cursor(a.from+o+l.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}const _T=new WeakMap;function jT(e){if(!Array.isArray(e))return e;let t=_T.get(e);return t||_T.set(e,t=TT(e)),t}const BT=Pb.define(),FT=Pb.define();class WT{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=Wv(e,t),r=Hv(n);this.chars.push(n);let i=e.slice(t,t+r),o=i.toUpperCase();this.folded.push(Wv(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=Wv(e,0),i=Hv(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=Wv(e,i);o!=t[l]&&o!=n[l]||(r[l++]=i),i+=Hv(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=Wv(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=zv(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+=Hv(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?Hv(Wv(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 zT{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 HT=rb.define({combine:e=>$b(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:qT,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=>VT(e(n),t(n)),optionClass:(e,t)=>n=>VT(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})});function VT(e,t){return e?t?e+" "+t:e:t}function qT(e,t,n,r,i,o){let s,a,l=e.textDirection==ww.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 UT(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 $T{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(HT);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=UT(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(HT).closeOnBlur&&t.relatedTarget!=e.contentDOM&&e.dispatch({effects:FT.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=UT(i.length,o,e.state.facet(HT).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=UT(t.options.length,t.selected,this.view.state.facet(HT).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=>ex(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(HT).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 KT(e,t){return n=>new $T(n,e,t)}function YT(e){return 100*(e.boost||0)+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}class GT{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 GT(this.options,ZT(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(HT);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 RT(t,r.source,e?e(t):[],1e9-n.length));else{let n,a=t.sliceDoc(r.from,r.to),l=s.filterStrict?new zT(a):new WT(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 RT(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):YT(e.completion)>YT(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(HT).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 GT(s,ZT(n,a),{pos:e.reduce((e,t)=>t.hasResult()?Math.min(e,t.from):e,1e8),create:lR,above:i.aboveCursor},r?r.timestamp:Date.now(),a,!1)}map(e){return new GT(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new GT(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class XT{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new XT(eR,"cm-ac-"+Math.floor(2e6*Math.random()).toString(36),null)}update(e){let{state:t}=e,n=t.facet(HT),r=(n.override||t.languageDataAt("autocomplete",DT(t)).map(jT)).map(t=>(this.active.find(e=>e.source==t)||new nR(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(iR));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=GT.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 nR(e.source,0):e));for(let t of e.effects)t.is(oR)&&(i=i&&i.setSelected(t.value,this.id));return r==this.active&&i==this.open?this:new XT(r,this.id,i)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?JT:QT}}const JT={"aria-autocomplete":"list"},QT={};function ZT(e,t){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(n["aria-activedescendant"]=e+"-"+t),n}const eR=[];function tR(e,t){if(e.isUserEvent("input.complete")){let n=e.annotation(LT);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 nR{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=tR(e,t),r=this;(8&n||16&n&&this.touches(e))&&(r=new nR(r.source,0)),4&n&&0==r.state&&(r=new nR(this.source,1)),r=r.updateFor(e,n);for(let t of e.effects)if(t.is(BT))r=new nR(r.source,1,t.value);else if(t.is(FT))r=new nR(r.source,0);else if(t.is(iR))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(DT(e.state))}}class rR extends nR{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=DT(e.state);if(s>o||!r||2&t&&(DT(e.startState)==this.from||s<this.limit))return new nR(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):PT(e,!0).test(i)}(r.validFor,e.state,i,o)?new rR(this.source,this.explicit,a,r,i,o):r.update&&(r=r.update(r,i,o,new AT(e.state,s,!1)))?new rR(this.source,this.explicit,a,r,r.from,null!==(n=r.to)&&void 0!==n?n:DT(e.state)):new nR(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 rR(this.source,this.explicit,e.mapPos(this.limit),this.result,e.mapPos(this.from),e.mapPos(this.to,1)):new nR(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}}const iR=Pb.define({map:(e,t)=>e.map(e=>e.map(t))}),oR=Pb.define(),sR=ub.define({create:()=>XT.start(),update:(e,t)=>e.update(t),provide:e=>[PE.from(e,e=>e.tooltip),TS.contentAttributes.from(e,e=>e.attrs)]});function aR(e,t){const n=t.completion.apply||t.completion.label;let r=e.state.field(sR).active.find(e=>e.source==t.source);return r instanceof rR&&("string"==typeof n?e.dispatch({...IT(e.state,n,r.from,r.to),annotations:LT.of(t.completion)}):n(e,t.completion,r.from,r.to),!0)}const lR=KT(sR,aR);function cR(e,t="option"){return n=>{let r=n.state.field(sR,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(HT).interactionDelay)return!1;let i,o=1;"page"==t&&(i=WE(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:oR.of(a)}),!0}}const uR=e=>!!e.state.field(sR,!1)&&(e.dispatch({effects:BT.of(!0)}),!0);class hR{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const dR=ix.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(sR).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(sR),n=e.state.facet(HT);if(!e.selectionSet&&!e.docChanged&&e.startState.field(sR)==t)return;let r=e.transactions.some(e=>{let t=tR(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){ex(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(BT)))&&(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(sR);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(HT).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=DT(t),r=new AT(t,n,e.explicit,this.view),i=new hR(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:FT.of(null)}),ex(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(HT).updateSyncTime))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],n=this.view.state.facet(HT),r=this.view.state.field(sR);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=DT(o.updates.length?o.updates[0].startState:this.view.state),i=Math.min(r,o.done.from+(o.active.explicit?0:1)),s=new rR(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 nR(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:iR.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(sR,!1);if(t&&t.tooltip&&this.view.state.facet(HT).closeOnBlur){let n=t.open&&WE(this.view,t.open.tooltip);n&&n.dom.contains(e.relatedTarget)||setTimeout(()=>this.view.dispatch({effects:FT.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){3==this.composing&&setTimeout(()=>this.view.dispatch({effects:BT.of(!1)}),20),this.composing=0}}}),fR="object"==typeof navigator&&/Win/.test(navigator.platform),pR=gb.highest(TS.domEventHandlers({keydown(e,t){let n=t.state.field(sR,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&(!fR||!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&&aR(t,r),!1}})),mR=TS.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"}}}),gR={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},vR=Pb.define({map(e,t){let n=t.mapPos(e,-1,qv.TrackAfter);return null==n?void 0:n}}),bR=new class extends Kb{};bR.startSide=1,bR.endSide=-1;const yR=ub.define({create:()=>Qb.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(vR)&&(e=e.update({add:[bR.range(n.value,n.value+1)]}));return e}});const wR="()[]{}<>«»»«[]{}";function xR(e){for(let t=0;t<16;t+=2)if(wR.charCodeAt(t)==e)return wR.charAt(t+1);return zv(e<128?e:e+1)}function kR(e,t){return e.languageDataAt("closeBrackets",t)[0]||gR}const SR="object"==typeof navigator&&/Android\b/.test(navigator.userAgent),ER=TS.inputHandler.of((e,t,n,r)=>{if((SR?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||2==r.length&&1==Hv(Wv(r,0))||t!=i.from||n!=i.to)return!1;let o=function(e,t){let n=kR(e,e.selection.main.head),r=n.brackets||gR.brackets;for(let i of r){let o=xR(Wv(i,0));if(t==i)return o==i?TR(e,i,r.indexOf(i+i+i)>-1,n):AR(e,i,o,n.before||gR.before);if(t==o&&NR(e,e.selection.main.from))return MR(e,i,o)}return null}(e.state,r);return!!o&&(e.dispatch(o),!0)}),CR=[{key:"Backspace",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=kR(e,e.selection.main.head).brackets||gR.brackets,r=null,i=e.changeByRange(t=>{if(t.empty){let r=function(e,t){let n=e.sliceString(t-2,t);return Hv(Wv(n,0))==n.length?n:n.slice(1)}(e.doc,t.head);for(let i of n)if(i==r&&OR(e.doc,t.head)==xR(Wv(i,0)))return{changes:{from:t.head-i.length,to:t.head+i.length},range:eb.cursor(t.head-i.length)}}return{range:r=t}});return r||t(e.update(i,{scrollIntoView:!0,userEvent:"delete.backward"})),!r}}];function NR(e,t){let n=!1;return e.field(yR).between(0,e.doc.length,e=>{e==t&&(n=!0)}),n}function OR(e,t){let n=e.sliceString(t,t+2);return n.slice(0,Hv(Wv(n,0)))}function AR(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:vR.of(o.to+t.length),range:eb.range(o.anchor+t.length,o.head+t.length)};let s=OR(e.doc,o.head);return!s||/\s/.test(s)||r.indexOf(s)>-1?{changes:{insert:t+n,from:o.head},effects:vR.of(o.head+t.length),range:eb.cursor(o.head+t.length)}:{range:i=o}});return i?null:e.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function MR(e,t,n){let r=null,i=e.changeByRange(t=>t.empty&&OR(e.doc,t.head)==n?{changes:{from:t.head,to:t.head+n.length,insert:n},range:eb.cursor(t.head+n.length)}:r={range:t});return r?null:e.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function TR(e,t,n,r){let i=r.stringPrefixes||gR.stringPrefixes,o=null,s=e.changeByRange(r=>{if(!r.empty)return{changes:[{insert:t,from:r.from},{insert:t,from:r.to}],effects:vR.of(r.to+t.length),range:eb.range(r.anchor+t.length,r.head+t.length)};let s,a=r.head,l=OR(e.doc,a);if(l==t){if(RR(e,a))return{changes:{insert:t+t,from:a},effects:vR.of(a+t.length),range:eb.cursor(a+t.length)};if(NR(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:eb.cursor(a+r.length)}}}else{if(n&&e.sliceDoc(a-2*t.length,a)==t+t&&(s=DR(e,a-2*t.length,i))>-1&&RR(e,s))return{changes:{insert:t+t+t+t,from:a},effects:vR.of(a+t.length),range:eb.cursor(a+t.length)};if(e.charCategorizer(a)(l)!=zb.Word&&DR(e,a,i)>-1&&!function(e,t,n,r){let i=RN(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:vR.of(a+t.length),range:eb.cursor(a+t.length)}}return{range:o=r}});return o?null:e.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function RR(e,t){let n=RN(e).resolveInner(t+1);return n.parent&&n.from==t}function DR(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=zb.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))!=zb.Word)return n}return-1}const PR=[{key:"Ctrl-Space",run:uR},{mac:"Alt-`",run:uR},{mac:"Alt-i",run:uR},{key:"Escape",run:e=>{let t=e.state.field(sR,!1);return!(!t||!t.active.some(e=>0!=e.state))&&(e.dispatch({effects:FT.of(null)}),!0)}},{key:"ArrowDown",run:cR(!0)},{key:"ArrowUp",run:cR(!1)},{key:"PageDown",run:cR(!0,"page")},{key:"PageUp",run:cR(!1,"page")},{key:"Enter",run:e=>{let t=e.state.field(sR,!1);return!(e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(HT).interactionDelay)&&aR(e,t.open.options[t.open.selected])}}],LR=gb.highest(BS.computeN([HT],e=>e.facet(HT).defaultKeymap?[PR]:[]));class IR{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}}class _R{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(e,t,n){let r=n.facet(YR).markerFilter;r&&(e=r(e,n));let i=e.slice().sort((e,t)=>e.from-t.from||e.to-t.to),o=new Zb,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=iD(s);if(h)o.add(t,t,Uy.widget({widget:new QR(d),diagnostics:s.slice()}));else{let e=s.reduce((e,t)=>t.markClass?e+" "+t.markClass:e,"");o.add(t,n,Uy.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 _R(h,t,jR(h))}}function jR(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 IR(r.from,n,r.diagnostic)}else r=new IR(e,n,t||i.diagnostics[0])}),r}function BR(e,t){return e.field(HR,!1)?t:t.concat(Pb.appendConfig.of(oD))}const FR=Pb.define(),WR=Pb.define(),zR=Pb.define(),HR=ub.define({create:()=>new _R(Uy.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=jR(n,e.selected.diagnostic,i)||jR(n,null,i)}!n.size&&i&&t.state.facet(YR).autoPanel&&(i=null),e=new _R(n,i,r)}for(let n of t.effects)if(n.is(FR)){let r=t.state.facet(YR).autoPanel?n.value.length?eD.open:null:e.panel;e=_R.init(n.value,r,t.state)}else n.is(WR)?e=new _R(e.diagnostics,n.value?eD.open:null,e.selected):n.is(zR)&&(e=new _R(e.diagnostics,e.panel,n.value));return e},provide:e=>[KE.from(e,e=>e.panel),TS.decorations.from(e,e=>e.diagnostics)]}),VR=Uy.mark({class:"cm-lintRange cm-lintRange-active"});function qR(e,t,n){let r,{diagnostics:i}=e.state.field(HR),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(YR).tooltipFilter;return r&&a&&(r=a(r,e.state)),r?{pos:o,end:s,above:e.state.doc.lineAt(o).to<s,create:()=>({dom:UR(e,r)})}:null}function UR(e,t){return Ey("ul",{class:"cm-tooltip-lint"},t.map(t=>JR(e,t,!1)))}const $R=e=>{let t=e.state.field(HR,!1);return!(!t||!t.panel)&&(e.dispatch({effects:WR.of(!1)}),!0)},KR=[{key:"Mod-Shift-m",run:e=>{let t=e.state.field(HR,!1);t&&t.panel||e.dispatch({effects:BR(e.state,[WR.of(!0)])});let n=VE(e,eD.open);return n&&n.dom.querySelector(".cm-panel-lint ul").focus(),!0},preventDefault:!0},{key:"F8",run:e=>{let t=e.state.field(HR,!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)}}],YR=rb.define({combine:e=>({sources:e.map(e=>e.source).filter(e=>null!=e),...$b(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:GR,tooltipFilter:GR,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 GR(e,t){return e?t?(n,r)=>t(e(n,r),r):e:t}function XR(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 JR(e,t,n){var r;let i=n?XR(t.actions):[];return Ey("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},Ey("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=jR(e.state.field(HR).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),Ey("u",a.slice(l,l+1)),a.slice(l+1)];return Ey("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&&Ey("div",{class:"cm-diagnosticSource"},t.source))}class QR extends Vy{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return Ey("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class ZR{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(4294967295*Math.random()).toString(16),this.dom=JR(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class eD{constructor(e){this.view=e,this.items=[];this.list=Ey("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t=>{if(27==t.keyCode)$R(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=XR(n.actions);for(let i=0;i<r.length;i++)if(r[i].toUpperCase().charCodeAt(0)==t.keyCode){let t=jR(this.view.state.field(HR).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=Ey("div",{class:"cm-panel-lint"},this.list,Ey("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>$R(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(HR).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(HR),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 ZR(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 ZR(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=jR(this.view.state.field(HR).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:zR.of(t)})}static open(e){return new eD(e)}}function tD(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 nD=TS.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:tD("#d11")},".cm-lintRange-warning":{backgroundImage:tD("orange")},".cm-lintRange-info":{backgroundImage:tD("#999")},".cm-lintRange-hint":{backgroundImage:tD("#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 rD(e){return"error"==e?4:"warning"==e?3:"info"==e?2:1}function iD(e){let t="hint",n=1;for(let r of e){let e=rD(r.severity);e>n&&(n=e,t=r.severity)}return t}const oD=[HR,TS.decorations.compute([HR],e=>{let{selected:t,panel:n}=e.field(HR);return t&&n&&t.from!=t.to?Uy.set([VR.range(t.from,t.to)]):Uy.none}),FE(qR,{hideOn:function(e,t){let n=t.pos,r=t.end||n,i=e.state.facet(YR).hideOn(e,n,r);if(null!=i)return i;let o=e.startState.doc.lineAt(t.pos);return!(!e.effects.some(e=>e.is(FR))&&!e.changes.touchesRange(o.from,Math.max(o.to,r)))}}),nD];var sD=function(e){void 0===e&&(e={});var{crosshairCursor:t=!1}=e,n=[];!1!==e.closeBracketsKeymap&&(n=n.concat(CR)),!1!==e.defaultKeymap&&(n=n.concat(AM)),!1!==e.searchKeymap&&(n=n.concat(wT)),!1!==e.historyKeymap&&(n=n.concat(AA)),!1!==e.foldKeymap&&(n=n.concat(mO)),!1!==e.completionKeymap&&(n=n.concat(PR)),!1!==e.lintKeymap&&(n=n.concat(KR));var r=[];return!1!==e.lineNumbers&&r.push(function(e={}){return[pC.of(e),oC(),vC]}()),!1!==e.highlightActiveLineGutter&&r.push(wC),!1!==e.highlightSpecialChars&&r.push(function(e={}){return[dE.of(e),fE||(fE=ix.fromClass(class{constructor(e){this.view=e,this.decorations=Uy.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(e.state.facet(dE)),this.decorations=this.decorator.createDeco(e)}makeDecorator(e){return new aE({regexp:e.specialChars,decoration:(t,n,r)=>{let{doc:i}=n.state,o=Wv(t[0],0);if(9==o){let e=i.lineAt(r),t=n.state.tabSize,o=uy(e.text,t,r-e.from);return Uy.replace({widget:new mE((t-o%t)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[o]||(this.decorationCache[o]=Uy.replace({widget:new pE(e,o)}))},boundary:e.replaceTabs?void 0:/[^]/})}update(e){let t=e.state.facet(dE);e.startState.facet(dE)!=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[hA,uA.of(e),TS.domEventHandlers({beforeinput(e,t){let n="historyUndo"==e.inputType?fA:"historyRedo"==e.inputType?pA:null;return!!n&&(e.preventDefault(),n(t))}})]}()),!1!==e.foldGutter&&r.push(function(e={}){let t={...kO,...e},n=new SO(t,!0),r=new SO(t,!1),i=ix.fromClass(class{constructor(e){this.from=e.viewport.from,this.markers=this.buildMarkers(e)}update(e){(e.docChanged||e.viewportChanged||e.startState.facet(WN)!=e.state.facet(WN)||e.startState.field(cO,!1)!=e.state.field(cO,!1)||RN(e.startState)!=RN(e.state)||t.foldingChanged(e))&&(this.markers=this.buildMarkers(e.view))}buildMarkers(e){let t=new Zb;for(let i of e.viewportLineBlocks){let o=hO(e.state,i.from,i.to)?r:iO(e.state,i.from,i.to)?n:null;o&&t.add(i.from,i.from,o)}return t.finish()}}),{domEventHandlers:o}=t;return[i,rC({class:"cm-foldGutter",markers(e){var t;return(null===(t=e.plugin(i))||void 0===t?void 0:t.markers)||Qb.empty},initialSpacer:()=>new SO(t,!1),domEventHandlers:{...o,click:(e,t,n)=>{if(o.click&&o.click(e,t,n))return!0;let r=hO(e.state,t.from,t.to);if(r)return e.dispatch({effects:aO.of(r)}),!0;let i=iO(e.state,t.from,t.to);return!!i&&(e.dispatch({effects:sO.of(i)}),!0)}}}),bO()]}()),!1!==e.drawSelection&&r.push(function(e={}){return[JS.of(e),ZS,tE,nE,Gw.of(!0)]}()),!1!==e.dropCursor&&r.push([iE,oE]),!1!==e.allowMultipleSelections&&r.push(Ub.allowMultipleSelections.of(!0)),!1!==e.indentOnInput&&r.push(Ub.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=$N(s,t.from);if(null==n)continue;let r=/^\s*/.exec(t.text)[0],i=UN(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(MO(DO,{fallback:!0})),!1!==e.bracketMatching&&r.push(function(e={}){return[IO.of(e),WO]}()),!1!==e.closeBrackets&&r.push([ER,yR]),!1!==e.autocompletion&&r.push(function(e={}){return[pR,sR,HT.of(e),dR,LR,mR]}()),!1!==e.rectangularSelection&&r.push(function(e){let t=(null==e?void 0:e.eventFilter)||(e=>e.altKey&&0==e.button);return TS.mouseSelectionStyle.of((e,n)=>t(n)?xE(e,n):null)}()),!1!==t&&r.push(function(e={}){let[t,n]=kE[e.key||"Alt"],r=ix.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,TS.contentAttributes.of(e=>{var t;return(null===(t=e.plugin(r))||void 0===t?void 0:t.isDown)?SE:null})]}()),!1!==e.highlightActiveLine&&r.push(vE),!1!==e.highlightSelectionMatches&&r.push(function(e){let t=[UM,qM];return e&&t.push(WM.of(e)),t}()),e.tabSize&&"number"==typeof e.tabSize&&r.push(VN.of(" ".repeat(e.tabSize))),r.concat([BS.of(n.flat())]).filter(Boolean)};const aD="#e06c75",lD="#abb2bf",cD="#7d8799",uD="#d19a66",hD="#2c313a",dD="#282c34",fD="#353a42",pD="#528bff",mD=[TS.theme({"&":{color:lD,backgroundColor:dD},".cm-content":{caretColor:pD},".cm-cursor, .cm-dropCursor":{borderLeftColor:pD},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:"#3E4451"},".cm-panels":{backgroundColor:"#21252b",color:lD},".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:dD,color:cD,border:"none"},".cm-activeLineGutter":{backgroundColor:hD},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:fD},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:fD,borderBottomColor:fD},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:hD,color:lD}}},{dark:!0}),MO(CO.define([{tag:EN.keyword,color:"#c678dd"},{tag:[EN.name,EN.deleted,EN.character,EN.propertyName,EN.macroName],color:aD},{tag:[EN.function(EN.variableName),EN.labelName],color:"#61afef"},{tag:[EN.color,EN.constant(EN.name),EN.standard(EN.name)],color:uD},{tag:[EN.definition(EN.name),EN.separator],color:lD},{tag:[EN.typeName,EN.className,EN.number,EN.changed,EN.annotation,EN.modifier,EN.self,EN.namespace],color:"#e5c07b"},{tag:[EN.operator,EN.operatorKeyword,EN.url,EN.escape,EN.regexp,EN.link,EN.special(EN.string)],color:"#56b6c2"},{tag:[EN.meta,EN.comment],color:cD},{tag:EN.strong,fontWeight:"bold"},{tag:EN.emphasis,fontStyle:"italic"},{tag:EN.strikethrough,textDecoration:"line-through"},{tag:EN.link,color:cD,textDecoration:"underline"},{tag:EN.heading,fontWeight:"bold",color:aD},{tag:[EN.atom,EN.bool,EN.special(EN.variableName)],color:uD},{tag:[EN.processingInstruction,EN.string,EN.inserted],color:"#98c379"},{tag:EN.invalid,color:"#ffffff"}]))];var gD=TS.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),vD=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(BS.of([MM])),s&&("boolean"==typeof s?a.unshift(sD()):a.unshift(sD(s))),o&&a.unshift(function(e){let t=ix.fromClass(class{constructor(t){this.view=t,this.placeholder=e?Uy.set([Uy.widget({widget:new bE(e),side:1}).range(0)]):Uy.none}get decorations(){return this.view.state.doc.length?Uy.none:this.placeholder}},{decorations:e=>e.decorations});return"string"==typeof e?[t,TS.contentAttributes.of({"aria-placeholder":e})]:t}(o)),i){case"light":a.push(gD);break;case"dark":a.push(mD);break;case"none":break;default:a.push(i)}return!1===n&&a.push(TS.editable.of(!1)),r&&a.push(Ub.readOnly.of(!0)),[...a]};class bD{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 yD{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 wD=null,xD=Tb.define(),kD=[];function SD(t){var{value:n,selection:r,onChange:i,onStatistics:o,onCreateEditor:s,onUpdate:a,extensions:l=kD,autoFocus:c,theme:u="light",height:h=null,minHeight:d=null,maxHeight:f=null,width:p=null,minWidth:m=null,maxWidth:g=null,placeholder:v="",editable:b=!0,readOnly:y=!1,indentWithTab:w=!0,basicSetup:x=!0,root:k,initialState:S}=t,[E,C]=e.useState(),[N,O]=e.useState(),[A,M]=e.useState(),T=e.useState(()=>({current:null}))[0],R=e.useState(()=>({current:null}))[0],D=TS.theme({"&":{height:h,minHeight:d,maxHeight:f,width:p,minWidth:m,maxWidth:g},"& .cm-scroller":{height:"100% !important"}}),P=TS.updateListener.of(e=>{if(e.docChanged&&"function"==typeof i&&!e.transactions.some(e=>e.annotation(xD))){T.current?T.current.reset():(T.current=new bD(()=>{if(R.current){var e=R.current;R.current=null,e()}T.current=null},200),("undefined"==typeof window?new yD:(wD||(wD=new yD),wD)).add(T.current));var t=e.state.doc.toString();i(t,e)}o&&o((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))}),L=[P,D,...vD({theme:u,editable:b,readOnly:y,placeholder:v,indentWithTab:w,basicSetup:x})];return a&&"function"==typeof a&&L.push(TS.updateListener.of(a)),L=L.concat(l),e.useLayoutEffect(()=>{if(E&&!A){var e={doc:n,selection:r,extensions:L},t=S?Ub.fromJSON(S.json,e,S.fields):Ub.create(e);if(M(t),!N){var i=new TS({state:t,parent:E,root:k});O(i),s&&s(i,t)}}return()=>{N&&(M(void 0),O(void 0))}},[E,A]),e.useEffect(()=>{t.container&&C(t.container)},[t.container]),e.useEffect(()=>()=>{N&&(N.destroy(),O(void 0)),T.current&&(T.current.cancel(),T.current=null)},[N]),e.useEffect(()=>{c&&N&&N.focus()},[c,N]),e.useEffect(()=>{N&&N.dispatch({effects:Pb.reconfigure.of(L)})},[u,l,h,d,f,p,m,g,v,b,y,w,x,i,a]),e.useEffect(()=>{if(void 0!==n){var e=N?N.state.doc.toString():"";if(N&&n!==e){var t=()=>{N&&n!==N.state.doc.toString()&&N.dispatch({changes:{from:0,to:N.state.doc.toString().length,insert:n||""},annotations:[xD.of(!0)]})};T.current&&!T.current.isDone?R.current=t:t()}}},[n,N]),{state:A,setState:M,view:N,setView:O,container:E,setContainer:C}}var ED=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],CD=e.forwardRef((n,r)=>{var{className:i,value:o="",selection:s,extensions:a=[],onChange:l,onStatistics:c,onCreateEditor:u,onUpdate:h,autoFocus:d,theme:f="light",height:p,minHeight:m,maxHeight:g,width:v,minWidth:b,maxWidth:y,basicSetup:w,placeholder:x,indentWithTab:k,editable:S,readOnly:E,root:C,initialState:N}=n,O=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}(n,ED),A=e.useRef(null),{state:M,view:T,container:R,setContainer:D}=SD({root:C,value:o,autoFocus:d,theme:f,height:p,minHeight:m,maxHeight:g,width:v,minWidth:b,maxWidth:y,basicSetup:w,placeholder:x,indentWithTab:k,editable:S,readOnly:E,selection:s,onChange:l,onStatistics:c,onCreateEditor:u,onUpdate:h,extensions:a,initialState:N});e.useImperativeHandle(r,()=>({editor:A.current,state:M,view:T}),[A,R,M,T]);var P=e.useCallback(e=>{A.current=e,D(e)},[D]);if("string"!=typeof o)throw new Error("value must be typeof string but got "+typeof o);var L="string"==typeof f?"cm-theme-"+f:"cm-theme";return t.jsx("div",vv({ref:P,className:L+(i?" "+i:"")},O))});CD.displayName="CodeMirror";class ND{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 ND(e,[],t,n,n,0,[],0,r?new OD(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 ND(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 AD(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 OD(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 OD{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}class AD{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 MD{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 MD(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 MD(this.stack,this.pos,this.index)}}function TD(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 RD{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const DD=new RD;class PD{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=DD,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=DD,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 LD{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||_D(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 ID(e,t,n){for(let r,i=t;65535!=(r=e[i]);i++)if(r==n)return i-t;return-1}function _D(e,t,n,r){let i=ID(n,r,t);return i<0||ID(n,r,e)<i}LD.prototype.contextual=LD.prototype.fallback=LD.prototype.extend=!1,LD.prototype.fallback=LD.prototype.extend=!1;const jD="undefined"!=typeof process&&process.env&&/\bparse\b/.test(process.env.LOG);let BD=null;function FD(e,t,n){let r=e.cursor(RC.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 WD{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?FD(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?FD(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 DC){if(o==e){if(o<this.safeFrom)return null;let e=o+i.length;if(e<=this.safeTo){let t=i.prop(EC.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 zD{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(e=>new RD)}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 RD,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 RD,{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($D(s,a+2),t,n,r));break}a=$D(s,a+2)}s[a]==t&&(r=this.putAction($D(s,a+1),t,n,r))}return r}}class HD{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 PD(t,r),this.tokens=new zD(e,this.stream),this.topTerm=e.top[1];let{from:i}=r[0];this.stacks=[ND.start(this,e.top[0],i)],this.fragments=n.length&&this.stream.end-i>4*e.bufferLength?new WD(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;jD&&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(EC.contextHash)||0)==n))return e.useNode(o,r),!0;if(!(o instanceof DC)||0==o.children.length||o.positions[0]>0)break;let s=o.children[0];if(!(s instanceof DC&&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 VD(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=jD?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;jD&&(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),VD(s,n)):(!r||r.score<u.score)&&(r=u)}return r}stackToTree(e){return e.close(),DC.build({buffer:MD.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=(BD||(BD=new WeakMap)).get(e);return t||BD.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}}function VD(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 qD{constructor(e,t,n){this.source=e,this.flags=t,this.disabled=n}allows(e){return!this.disabled||0==this.disabled[e]}}class UD extends JC{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=EC[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 AC(t.map((t,i)=>OC.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=xC;let o=TD(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(KD),this.states=TD(e.states,Uint32Array),this.data=TD(e.stateData),this.goto=TD(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(e=>"number"==typeof e?new LD(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 HD(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 $D(n,o+2);break}i=n[o=$D(n,o+2)]}if(i==t||0==i)return $D(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=$D(this.data,n+2)}r=t($D(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=$D(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(UD.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]=KD(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 qD(e,n,r)}static deserialize(e){return new UD(e)}}function $D(e,t){return e[t]|e[t+1]<<16}function KD(e){if(e.external){let t=e.extend?1:0;return(n,r)=>e.external(n,r)<<1|t}return e.get}const YD=rN({String:EN.string,Number:EN.number,"True False":EN.bool,PropertyName:EN.propertyName,Null:EN.null,", :":EN.separator,"[ ]":EN.squareBracket,"{ }":EN.brace}),GD=UD.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:[YD],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}),XD=TN.define({name:"json",parser:GD.configure({props:[YN.add({Object:eO({except:/^\s*\}/}),Array:eO({except:/^\s*\]/})}),nO.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 JD(e){return QD.apply(this,arguments)}function QD(){return QD=u(f().m(function e(t){var n,r;return f().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)})),QD.apply(this,arguments)}function ZD(e){var t=e.value,n=e.title;if(null==t||""===t)return s.createElement("span",null,"-");var r,i=mv(t),o=i.ok,a=i.pretty,l=i.compact,c=l.length>80?l.slice(0,80)+"…":l;return s.createElement(Hg,null,s.createElement(Vg,{asChild:!0},s.createElement("button",{type:"button",className:"max-w-xs truncate text-left font-mono text-xs text-muted-foreground hover:underline",title:"点击查看 JSON"},c)),s.createElement($g,{className:"max-w-3xl"},s.createElement(Kg,null,s.createElement(Gg,null,n||"JSON")),s.createElement("div",{className:"flex items-center justify-end gap-2"},s.createElement(ut,{variant:"outline",size:"sm",onClick:(r=u(f().m(function e(){return f().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,JD(a);case 1:fh.success("已复制 JSON"),e.n=3;break;case 2:e.p=2,e.v,fh.error("复制失败");case 3:return e.a(2)}},e,null,[[0,2]])})),function(){return r.apply(this,arguments)})},"复制")),s.createElement("pre",{className:"max-h-[60vh] overflow-auto rounded-md bg-muted p-3 text-xs font-mono whitespace-pre-wrap break-all"},a),!o&&s.createElement("div",{className:"text-xs text-destructive"},i.ok?"":i.message)))}function eP(e){e.id;var t=e.value;e.required;var n,r=e.disabled,i=e.onChange,o=m(s.useState(null),2),a=o[0],l=o[1];return s.createElement("div",{className:"space-y-2"},s.createElement("div",{className:"flex items-center justify-end gap-2"},s.createElement(ut,{type:"button",variant:"outline",size:"sm",disabled:!!r,onClick:function(){if(!r){var e=(t||"").trim();if(e){var n=gv(e,2);n.ok?(i(n.formatted),l(null)):l(n.message)}}}},"格式化"),s.createElement(ut,{type:"button",variant:"outline",size:"sm",onClick:(n=u(f().m(function e(){return f().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,JD(t||"");case 1:fh.success("已复制"),e.n=3;break;case 2:e.p=2,e.v,fh.error("复制失败");case 3:return e.a(2)}},e,null,[[0,2]])})),function(){return n.apply(this,arguments)})},"复制")),s.createElement("div",{className:"w-full max-w-full overflow-hidden rounded-md border bg-background"},s.createElement(CD,{className:"w-full max-w-full",editable:!r,value:t||"",height:"220px",basicSetup:{lineNumbers:!0,foldGutter:!0,highlightActiveLine:!0},extensions:[new zN(XD),TS.lineWrapping],onChange:function(e){r||(i(e),function(e){var t=(e||"").trim();if(!t)return l(null),!0;var n=mv(t);n.ok?l(null):l(n.message)}(e))}})),a&&s.createElement("div",{className:"text-xs text-destructive"},a))}var tP=s.forwardRef(function(e,t){var n=e.className,r=w(e,["className"]);return s.createElement("div",{className:"relative w-full overflow-x-auto"},s.createElement("table",Object.assign({ref:t,className:Ke("w-full min-w-max caption-bottom text-sm",n)},r)))});tP.displayName="Table";var nP=s.forwardRef(function(e,t){var n=e.className,r=w(e,["className"]);return s.createElement("thead",Object.assign({ref:t,className:Ke("[&_tr]:border-b",n)},r))});nP.displayName="TableHeader";var rP=s.forwardRef(function(e,t){var n=e.className,r=w(e,["className"]);return s.createElement("tbody",Object.assign({ref:t,className:Ke("[&_tr:last-child]:border-0",n)},r))});rP.displayName="TableBody";var iP=s.forwardRef(function(e,t){var n=e.className,r=w(e,["className"]);return s.createElement("tfoot",Object.assign({ref:t,className:Ke("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",n)},r))});iP.displayName="TableFooter";var oP=s.forwardRef(function(e,t){var n=e.className,r=w(e,["className"]);return s.createElement("tr",Object.assign({ref:t,className:Ke("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",n)},r))});oP.displayName="TableRow";var sP=s.forwardRef(function(e,t){var n=e.className,r=w(e,["className"]);return s.createElement("th",Object.assign({ref:t,className:Ke("h-12 px-4 text-left align-middle font-medium text-muted-foreground whitespace-nowrap [&:has([role=checkbox])]:pr-0",n)},r))});sP.displayName="TableHead";var aP=s.forwardRef(function(e,t){var n=e.className,r=w(e,["className"]);return s.createElement("td",Object.assign({ref:t,className:Ke("p-4 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0",n)},r))});aP.displayName="TableCell";var lP=s.forwardRef(function(e,t){var n=e.className,r=w(e,["className"]);return s.createElement("caption",Object.assign({ref:t,className:Ke("mt-4 text-sm text-muted-foreground",n)},r))});lP.displayName="TableCaption";var cP=lt("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 uP(e){var t=e.className,n=e.variant,r=w(e,["className","variant"]);return s.createElement("div",Object.assign({className:Ke(cP({variant:n}),t)},r))}function hP(){return"".concat(Date.now(),"_").concat(Math.random().toString(16).slice(2))}function dP(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 fP(t){var n,r,i=e.useMemo(function(){var e=[];e.push.apply(e,g([{column:"id",label:"ID",type:"id"},{column:"created_at",label:"创建时间",type:"datetime"},{column:"updated_at",label:"更新时间",type:"datetime"}]));var n,r=h(t.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");e.push({column:o,label:"".concat(i.comment||i.name,"(关联)"),type:"relation"})}else e.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 e.filter(function(e){return!s.has(e.column)&&(s.add(e.column),!0)})},[t.fields]),o=e.useMemo(function(){return new Map(i.map(function(e){return[e.column,e]}))},[i]),s=e.useMemo(function(){return new Map(i.map(function(e){return[e.column,e.type]}))},[i]),a=m(e.useState([]),2),l=a[0],c=a[1];e.useEffect(function(){c(function(e,t){return(e||[]).map(function(e){if(t.get(e.column),"is"===e.operator&&(null===e.value||"null"===e.value))return{id:hP(),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:hP(),column:e.column,operator:"contains",value:n.slice(1,-1)};if(n.endsWith("%"))return{id:hP(),column:e.column,operator:"startsWith",value:n.slice(0,-1)};if(n.startsWith("%"))return{id:hP(),column:e.column,operator:"endsWith",value:n.slice(1)}}if("in"===e.operator){var r=Array.isArray(e.value)?e.value:[];return{id:hP(),column:e.column,operator:"in",value:r.join(",")}}return{id:hP(),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)}})}(t.value||[],s))},[JSON.stringify(t.value),i.length]);var u=function(e,t){c(function(n){return n.map(function(n){var r,i;if(n.id!==e)return n;var s=Object.assign(Object.assign({},n),t);if(t.column&&t.column!==n.column){var a=dP((null===(r=o.get(t.column))||void 0===r?void 0:r.type)||"string");s.operator=(null===(i=a[0])||void 0===i?void 0:i.value)||"eq",s.value=""}return t.operator&&"isNull"===t.operator&&(s.value=""),s})})};return e.createElement("div",{className:"space-y-3"},e.createElement("div",{className:"flex items-center justify-between gap-3"},e.createElement(Ku,{className:"text-base font-medium flex items-center gap-2"},e.createElement(I,{className:"h-4 w-4"}),"动态筛选"),e.createElement("div",{className:"flex items-center gap-2"},(null===(n=t.value)||void 0===n?void 0:n.length)>0&&e.createElement(uP,{variant:"secondary"},"已应用 ",t.value.length," 条"),e.createElement(ut,{type:"button",variant:"outline",size:"sm",onClick:function(){var e=i[0];if(e){var t=dP(e.type);c(function(n){var r;return[].concat(g(n),[{id:hP(),column:e.column,operator:(null===(r=t[0])||void 0===r?void 0:r.value)||"eq",value:""}])})}}},e.createElement(q,{className:"h-4 w-4 mr-1"}),"添加条件"))),0===l.length?e.createElement("div",{className:"text-sm text-muted-foreground border rounded-lg p-3 bg-muted/20"},"暂无筛选条件(可添加条件后点击“应用”)"):e.createElement("div",{className:"space-y-2"},l.map(function(t){var n=o.get(t.column),r=(null==n?void 0:n.type)||"string",s=dP(r),a="isNull"!==t.operator;return e.createElement("div",{key:t.id,className:"grid grid-cols-12 gap-2 items-center"},e.createElement("div",{className:"col-span-5"},e.createElement(mg,{value:t.column,onValueChange:function(e){return u(t.id,{column:e})}},e.createElement(vg,{className:"h-10"},e.createElement(gg,{placeholder:"字段"})),e.createElement(wg,null,i.map(function(t){return e.createElement(kg,{key:t.column,value:t.column},t.label," (",t.column,")")})))),e.createElement("div",{className:"col-span-3"},e.createElement(mg,{value:t.operator,onValueChange:function(e){return u(t.id,{operator:e})}},e.createElement(vg,{className:"h-10"},e.createElement(gg,{placeholder:"操作符"})),e.createElement(wg,null,s.map(function(t){return e.createElement(kg,{key:t.value,value:t.value},t.label)})))),e.createElement("div",{className:"col-span-3"},a?"boolean"===r?e.createElement(mg,{value:t.value,onValueChange:function(e){return u(t.id,{value:e})}},e.createElement(vg,{className:"h-10"},e.createElement(gg,{placeholder:"值"})),e.createElement(wg,null,e.createElement(kg,{value:"true"},"true"),e.createElement(kg,{value:"false"},"false"))):e.createElement(ht,{className:"h-10",placeholder:"in"===t.operator?"多个值用逗号分隔":"值",type:"integer"===r||"float"===r?"number":"date"===r?"date":"datetime"===r?"datetime-local":"text",value:t.value,onChange:function(e){return u(t.id,{value:e.target.value})}}):e.createElement("div",{className:"h-10 flex items-center text-sm text-muted-foreground"},"无需填写")),e.createElement("div",{className:"col-span-1 flex justify-end"},e.createElement(ut,{type:"button",variant:"ghost",size:"sm",className:"h-9 w-9 p-0",onClick:function(){return e=t.id,void c(function(t){return t.filter(function(t){return t.id!==e})});var e}},e.createElement(Q,{className:"h-4 w-4"}))))})),e.createElement("div",{className:"flex items-center justify-end gap-2"},e.createElement(ut,{type:"button",variant:"outline",onClick:function(){c([]),t.onChange([])},disabled:0===l.length&&0===((null===(r=t.value)||void 0===r?void 0:r.length)||0)},"清空"),e.createElement(ut,{type:"button",onClick:function(){var e=function(e,t){var n,r,i=[],o=h(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}(l,o);t.onChange(e)},disabled:0===l.length},"应用")))}function pP(){var t,n=m(e.useState([]),2),r=n[0],o=n[1],s=m(e.useState(null),2),a=s[0],l=s[1],c=m(e.useState([]),2),h=c[0],p=c[1],g=m(e.useState(!1),2),v=g[0],b=g[1],y=m(e.useState(!1),2),w=y[0],x=y[1],k=m(e.useState(null),2),S=k[0],E=k[1],C=m(e.useState({}),2),N=C[0],O=C[1],T=m(e.useState(1),2),R=T[0],D=T[1],P=m(e.useState(10),2),L=P[0];P[1];var _=m(e.useState(0),2),j=_[0],B=_[1],W=m(e.useState(""),2),z=W[0],H=W[1],V=m(e.useState(!1),2),$=V[0],Y=V[1],X=m(e.useState(null),2),J=X[0],Q=X[1],Z=m(e.useState(!0),2),ee=Z[0],te=Z[1],ne=m(e.useState([]),2),re=ne[0],ie=ne[1],oe=m(e.useState(!1),2),se=oe[0],ae=oe[1],le=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:[]},ce=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}},ue=function(e){return!e||!e.readOnly&&!1!==e.editable};e.useEffect(function(){he()},[]),e.useEffect(function(){a&&de()},[a,R,L,z,re]);var he=function(){var e=u(f().m(function e(){var t;return f().w(function(e){for(;;)switch(e.p=e.n){case 0:return te(!0),e.p=1,e.n=2,_f();case 2:t=e.v,o(le(t.data)),e.n=4;break;case 3:e.p=3,e.v,fh.error("加载模型列表失败");case 4:return e.p=4,te(!1),e.f(4);case 5:return e.a(2)}},e,null,[[1,3,4,5]])}));return function(){return e.apply(this,arguments)}}(),de=function(){var e=u(f().m(function e(){var t,n,r;return f().w(function(e){for(;;)switch(e.p=e.n){case 0:if(a){e.n=1;break}return e.a(2);case 1:return b(!0),e.p=2,t={page:R,limit:L},z&&(t.search=z),re.length>0&&(t.filters=re),e.n=3,Uf(a.table_name,t);case 3:if((n=e.v).success){e.n=4;break}return fh.error(n.message||"加载数据失败"),p([]),B(0),e.a(2);case 4:r=ce(n.data),p(r.rows),B(r.total),e.n=6;break;case 5:e.p=5,e.v,fh.error("加载数据失败"),p([]),B(0);case 6:return e.p=6,b(!1),e.f(6);case 7:return e.a(2)}},e,null,[[2,5,6,7]])}));return function(){return e.apply(this,arguments)}}(),fe=function(){var e=u(f().m(function e(t){var n;return f().w(function(e){for(;;)switch(e.p=e.n){case 0:if(confirm("确定要删除这条数据吗?此操作不可撤销。")){e.n=1;break}return e.a(2);case 1:return Q(t.id),e.p=2,e.n=3,Gf(null==a?void 0:a.table_name,t.id);case 3:(n=e.v).success?(fh.success("删除成功"),de()):fh.error(n.message||"删除失败"),e.n=5;break;case 4:e.p=4,e.v,fh.error("删除失败");case 5:return e.p=5,Q(null),e.f(5);case 6:return e.a(2)}},e,null,[[2,4,5,6]])}));return function(t){return e.apply(this,arguments)}}(),pe=function(){var e=u(f().m(function e(){var t,n,r,i,o;return f().w(function(e){for(;;)switch(e.p=e.n){case 0:if(a){e.n=1;break}return e.a(2);case 1:if(Y(!0),e.p=2,t={},a.json_schema.fields.forEach(function(e){if("id"!==e.name&&ue(e)){var n=N[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=mv(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}}),!S){e.n=4;break}return e.n=3,Yf(a.table_name,Object.assign(Object.assign({},t),{id:S.id}));case 3:(n=e.v).success?(fh.success("更新成功"),x(!1),de()):fh.error(n.message||"更新失败"),e.n=6;break;case 4:return e.n=5,Kf(a.table_name,t);case 5:(r=e.v).success?(fh.success("创建成功"),x(!1),de()):fh.error(r.message||"创建失败");case 6:e.n=8;break;case 7:e.p=7,o=e.v,i=o instanceof Error?o.message:"操作失败",fh.error(i);case 8:return e.p=8,Y(!1),e.f(8);case 9:return e.a(2)}},e,null,[[2,7,8,9]])}));return function(){return e.apply(this,arguments)}}();return e.createElement("div",{className:"min-h-[calc(100vh-4rem)] bg-gradient-to-br from-background via-background to-muted/20"},e.createElement("div",{className:"container mx-auto px-6 py-8 space-y-6"},e.createElement("div",{className:"space-y-2"},e.createElement("h1",{className:"text-3xl font-bold tracking-tight"},"数据列表"),e.createElement("p",{className:"text-muted-foreground"},"选择模型查看和管理数据")),e.createElement(Yu,{className:"border-2 shadow-lg"},e.createElement(Gu,{className:"bg-muted/30"},e.createElement("div",{className:"flex flex-col md:flex-row md:items-center md:justify-between gap-4"},e.createElement("div",null,e.createElement(Xu,null,"数据管理"),e.createElement(Ju,null,"选择数据模型进行查看和管理")),a&&e.createElement(ut,{onClick:function(){E(null),O({}),x(!0)},className:"w-full md:w-auto"},e.createElement(q,{className:"h-4 w-4 mr-2"}),"新建数据"))),e.createElement(Qu,{className:"space-y-6 pt-6"},e.createElement("div",{className:"flex flex-col md:flex-row gap-4"},e.createElement("div",{className:"flex-1 space-y-2"},e.createElement(Ku,{htmlFor:"model",className:"text-base font-medium flex items-center gap-2"},e.createElement(I,{className:"h-4 w-4"}),"选择数据模型"),e.createElement(mg,{value:(null===(t=null==a?void 0:a.id)||void 0===t?void 0:t.toString())||"",onValueChange:function(e){var t=r.find(function(t){return t.id.toString()===e});l(t||null),D(1),H(""),ie([])},disabled:ee},e.createElement(vg,{className:"h-11"},ee?e.createElement("div",{className:"flex items-center gap-2"},e.createElement(F,{className:"h-4 w-4 animate-spin"}),e.createElement("span",null,"加载中...")):e.createElement(gg,{placeholder:"请选择模型"})),e.createElement(wg,null,r.map(function(t){return e.createElement(kg,{key:t.id,value:t.id.toString()},t.name," (",t.table_name,")")})))),a&&e.createElement("div",{className:"flex-1 space-y-2"},e.createElement(Ku,{htmlFor:"search",className:"text-base font-medium flex items-center gap-2"},e.createElement(U,{className:"h-4 w-4"}),"搜索"),e.createElement("div",{className:"relative"},e.createElement(U,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.createElement(ht,{id:"search",placeholder:"搜索数据...",value:z,onChange:function(e){return H(e.target.value)},className:"pl-10 h-11"})))),a&&e.createElement(e.Fragment,null,e.createElement("div",{className:"flex items-center justify-end"},e.createElement(ut,{type:"button",variant:"outline",className:"h-10",onClick:function(){return ae(!0)}},e.createElement(I,{className:"h-4 w-4 mr-2"}),"筛选",re.length>0?"(".concat(re.length,")"):"")),e.createElement("div",{className:"flex items-center justify-between p-4 rounded-lg bg-muted/50 border"},e.createElement("div",{className:"text-sm text-muted-foreground"},"共 ",e.createElement("span",{className:"font-semibold text-foreground"},j)," 条数据"),e.createElement(uP,{variant:"outline"},a.name)),e.createElement("div",{className:"rounded-lg border overflow-hidden"},e.createElement("div",{className:"overflow-x-auto"},e.createElement(tP,null,e.createElement(nP,null,e.createElement(oP,{className:"bg-muted/50"},e.createElement(sP,{className:"font-semibold w-20"},"ID"),a.json_schema.fields.map(function(t){return e.createElement(sP,{key:t.name,className:"font-semibold"},t.comment||t.name)}),e.createElement(sP,{className:"font-semibold"},"创建时间"),e.createElement(sP,{className:"font-semibold"},"更新时间"),e.createElement(sP,{className:"font-semibold w-32 text-center"},"操作"))),e.createElement(rP,null,v?Array.from({length:3}).map(function(t,n){return e.createElement(oP,{key:n},e.createElement(aP,{colSpan:a.json_schema.fields.length+4},e.createElement("div",{className:"flex items-center gap-2 py-4"},e.createElement(F,{className:"h-4 w-4 animate-spin text-muted-foreground"}),e.createElement("span",{className:"text-sm text-muted-foreground"},"加载中..."))))}):0===h.length?e.createElement(oP,null,e.createElement(aP,{colSpan:a.json_schema.fields.length+4,className:"text-center py-12"},e.createElement("div",{className:"flex flex-col items-center gap-2 text-muted-foreground"},e.createElement(U,{className:"h-8 w-8"}),e.createElement("p",null,"暂无数据")))):h.map(function(t,n){return e.createElement(oP,{key:t.id,className:n%2==0?"bg-muted/20":""},e.createElement(aP,{className:"font-mono font-medium"},t.id),a.json_schema.fields.map(function(n){return e.createElement(aP,{key:n.name},function(t,n){return"boolean"===t.type?e.createElement(uP,{variant:n?"default":"secondary"},n?"是":"否"):"date"===t.type||"datetime"===t.type?n?i(n).format("YYYY-MM-DD HH:mm:ss"):"-":"text"===t.type&&n&&n.length>50?e.createElement("span",{className:"max-w-xs truncate block",title:n},n.substring(0,50),"..."):"json"===t.type||"jsonb"===t.type?e.createElement(ZD,{value:n,title:t.comment||t.name}):n||"-"}(n,t[n.name]))}),e.createElement(aP,{className:"text-sm text-muted-foreground"},i(t.created_at).format("YYYY-MM-DD HH:mm")),e.createElement(aP,{className:"text-sm text-muted-foreground"},i(t.updated_at).format("YYYY-MM-DD HH:mm")),e.createElement(aP,null,e.createElement("div",{className:"flex items-center justify-center gap-2"},e.createElement(ut,{variant:"ghost",size:"sm",onClick:function(){return function(e){E(e);var t={};null==a||a.json_schema.fields.forEach(function(n){if("id"!==n.name){var r=e[n.name];"date"!==n.type&&"datetime"!==n.type||(r=r?i(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}}),O(t),x(!0)}(t)},className:"h-8 w-8 p-0"},e.createElement(K,{className:"h-4 w-4"})),e.createElement(ut,{variant:"ghost",size:"sm",onClick:function(){return fe(t)},disabled:J===t.id,className:"h-8 w-8 p-0 text-destructive hover:text-destructive"},J===t.id?e.createElement(F,{className:"h-4 w-4 animate-spin"}):e.createElement(G,{className:"h-4 w-4"})))))}))))),j>L&&e.createElement("div",{className:"flex items-center justify-between p-4 rounded-lg bg-muted/50 border"},e.createElement("div",{className:"text-sm text-muted-foreground"},"第 ",e.createElement("span",{className:"font-semibold text-foreground"},R)," 页, 共 ",e.createElement("span",{className:"font-semibold text-foreground"},Math.ceil(j/L))," 页"),e.createElement("div",{className:"flex gap-2"},e.createElement(ut,{variant:"outline",size:"sm",onClick:function(){return D(Math.max(1,R-1))},disabled:1===R||v},e.createElement(A,{className:"h-4 w-4 mr-1"}),"上一页"),e.createElement(ut,{variant:"outline",size:"sm",onClick:function(){return D(Math.min(Math.ceil(j/L),R+1))},disabled:R>=Math.ceil(j/L)||v},"下一页",e.createElement(M,{className:"h-4 w-4 ml-1"}))))))),a&&e.createElement(Hg,{open:se,onOpenChange:ae},e.createElement($g,{className:"max-w-3xl"},e.createElement(Kg,null,e.createElement(Gg,{className:"text-xl"},"筛选"),e.createElement(Jg,{className:"text-sm"},a.name," - ",a.table_name)),e.createElement("div",{className:"py-2"},e.createElement(fP,{fields:a.json_schema.fields,value:re,onChange:function(e){ie(e),D(1)}})),e.createElement(Yg,{className:"gap-2"},e.createElement(ut,{variant:"outline",onClick:function(){return ae(!1)}},"关闭")))),e.createElement(Hg,{open:w,onOpenChange:x},e.createElement($g,{className:"max-w-3xl max-h-[85vh] overflow-y-auto"},e.createElement(Kg,null,e.createElement(Gg,{className:"text-2xl"},S?"编辑数据":"新建数据"),e.createElement(Jg,{className:"text-base"},null==a?void 0:a.name," - ",null==a?void 0:a.table_name)),e.createElement("div",{className:"space-y-4 py-4"},null==a?void 0:a.json_schema.fields.map(function(t){return function(t){if("id"===t.name)return null;var n=ue(t);switch(t.type){case"boolean":return e.createElement("div",{key:t.name,className:"flex items-center space-x-3 p-4 rounded-lg border bg-card"},e.createElement(Wg,{id:t.name,checked:N[t.name]||!1,disabled:!n,onCheckedChange:function(e){return O(Object.assign(Object.assign({},N),d({},t.name,e)))}}),e.createElement(Ku,{htmlFor:t.name,className:"text-base font-medium cursor-pointer"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")));case"date":return e.createElement("div",{key:t.name,className:"space-y-2"},e.createElement(Ku,{htmlFor:t.name,className:"text-base font-medium"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")),e.createElement(ht,{id:t.name,type:"date",value:N[t.name]||"",disabled:!n,onChange:function(e){return O(Object.assign(Object.assign({},N),d({},t.name,e.target.value)))},required:t.required,className:"h-11"}));case"datetime":return e.createElement("div",{key:t.name,className:"space-y-2"},e.createElement(Ku,{htmlFor:t.name,className:"text-base font-medium"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")),e.createElement(ht,{id:t.name,type:"datetime-local",value:N[t.name]||"",disabled:!n,onChange:function(e){return O(Object.assign(Object.assign({},N),d({},t.name,e.target.value)))},required:t.required,className:"h-11"}));case"text":return e.createElement("div",{key:t.name,className:"space-y-2"},e.createElement(Ku,{htmlFor:t.name,className:"text-base font-medium"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")),e.createElement(zg,{id:t.name,rows:4,value:N[t.name]||"",disabled:!n,onChange:function(e){return O(Object.assign(Object.assign({},N),d({},t.name,e.target.value)))},required:t.required,className:"resize-none"}));case"json":case"jsonb":return e.createElement("div",{key:t.name,className:"space-y-2"},e.createElement(Ku,{htmlFor:t.name,className:"text-base font-medium"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")),e.createElement(eP,{id:t.name,value:N[t.name]||"",required:t.required,disabled:!n,onChange:function(e){return O(Object.assign(Object.assign({},N),d({},t.name,e)))}}));case"integer":case"float":return e.createElement("div",{key:t.name,className:"space-y-2"},e.createElement(Ku,{htmlFor:t.name,className:"text-base font-medium"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")),e.createElement(ht,{id:t.name,type:"number",value:N[t.name]||"",disabled:!n,onChange:function(e){return O(Object.assign(Object.assign({},N),d({},t.name,e.target.value)))},required:t.required,className:"h-11"}));default:return e.createElement("div",{key:t.name,className:"space-y-2"},e.createElement(Ku,{htmlFor:t.name,className:"text-base font-medium"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")),e.createElement(ht,{id:t.name,type:"email"===t.type?"email":"text",maxLength:t.maxLength,value:N[t.name]||"",disabled:!n,onChange:function(e){return O(Object.assign(Object.assign({},N),d({},t.name,e.target.value)))},required:t.required,className:"h-11"}))}}(t)})),e.createElement(Yg,{className:"gap-2"},e.createElement(ut,{variant:"outline",onClick:function(){return x(!1)},disabled:$},"取消"),e.createElement(ut,{onClick:pe,disabled:$},$?e.createElement(e.Fragment,null,e.createElement(F,{className:"h-4 w-4 mr-2 animate-spin"}),S?"更新中...":"创建中..."):S?"更新":"创建"))))))}function mP(e){return/^https?:\/\//i.test(e)}function gP(t){var n=t.url;return e.createElement("div",{className:"flex items-center gap-2 max-w-[360px]"},e.createElement(Zs,null,e.createElement(ea,{asChild:!0},e.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:"点击打开原图"},e.createElement("img",{src:n,alt:"",className:"h-full w-full object-cover",onError:function(e){e.currentTarget.style.display="none"}}))),e.createElement(ta,{side:"right",className:"p-2"},e.createElement("img",{src:n,alt:"",className:"max-h-64 max-w-64 rounded object-contain",onError:function(e){e.currentTarget.style.display="none"}}))),e.createElement("a",{href:n,target:"_blank",rel:"noreferrer",className:"truncate text-primary underline-offset-2 hover:underline",title:n},n))}function vP(t){var n=t.model,r=m(e.useState([]),2),o=r[0],s=r[1],a=m(e.useState(!1),2),l=a[0],c=a[1],h=m(e.useState(!1),2),p=h[0],g=h[1],v=m(e.useState(!1),2),b=v[0],y=v[1],w=m(e.useState(null),2),x=w[0],k=w[1],S=m(e.useState({}),2),E=S[0],C=S[1],N=m(e.useState(1),2),O=N[0],T=N[1],R=m(e.useState(10),2),D=R[0];R[1];var L=m(e.useState(0),2),_=L[0],j=L[1],B=m(e.useState(""),2),W=B[0],z=B[1],H=m(e.useState(!1),2),V=H[0],$=H[1],Y=m(e.useState(null),2),X=Y[0],J=Y[1],Q=m(e.useState({}),2),Z=Q[0],ee=Q[1],te=m(e.useState([]),2),ne=te[0],re=te[1],ie=e.useMemo(function(){return ne.length?JSON.stringify(ne):""},[ne]),oe=function(e){return!e.readOnly&&!1!==e.editable};e.useEffect(function(){n&&ae()},[null==n?void 0:n.table_name,O,D,W,ie]);var se=function(){var e=u(f().m(function e(t){var n,r,i,o,s;return f().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"),!Z[o]){e.n=2;break}return e.a(2);case 2:return e.p=2,e.n=3,$f(r,{displayField:i||"name",limit:200});case 3:(s=e.v).success&&s.data&&ee(function(e){return Object.assign(Object.assign({},e),d({},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)}}();e.useEffect(function(){p&&n&&n.json_schema.fields.filter(function(e){return"relation"===e.type&&e.relation}).forEach(function(e){return se(e)})},[p,n]);var ae=function(){var e=u(f().m(function e(){var t,r,i,o;return f().w(function(e){for(;;)switch(e.p=e.n){case 0:if(n){e.n=1;break}return e.a(2);case 1:return c(!0),e.p=2,i={page:O,limit:D},W&&(i.search=W),ne.length>0&&(i.filters=ne),e.n=3,Uf(n.table_name,i);case 3:if((o=e.v).success){e.n=4;break}return fh.error(o.message||"加载数据失败"),s([]),j(0),e.a(2);case 4:s((null===(t=o.data)||void 0===t?void 0:t.data)||[]),j((null===(r=o.data)||void 0===r?void 0:r.total)||0),e.n=6;break;case 5:e.p=5,e.v,fh.error("加载数据失败"),s([]),j(0);case 6:return e.p=6,c(!1),e.f(6);case 7:return e.a(2)}},e,null,[[2,5,6,7]])}));return function(){return e.apply(this,arguments)}}(),le=function(){var e=u(f().m(function e(t){var r;return f().w(function(e){for(;;)switch(e.p=e.n){case 0:if(confirm("确定要删除这条数据吗?此操作不可撤销。")){e.n=1;break}return e.a(2);case 1:return J(t.id),e.p=2,e.n=3,Gf(null==n?void 0:n.table_name,t.id);case 3:(r=e.v).success?(fh.success("删除成功"),ae()):fh.error(r.message||"删除失败"),e.n=5;break;case 4:e.p=4,e.v,fh.error("删除失败");case 5:return e.p=5,J(null),e.f(5);case 6:return e.a(2)}},e,null,[[2,4,5,6]])}));return function(t){return e.apply(this,arguments)}}(),ce=function(){var e=u(f().m(function e(){var t,r,i,o,s,a;return f().w(function(e){for(;;)switch(e.p=e.n){case 0:if(n){e.n=1;break}return e.a(2);case 1:if($(!0),e.p=2,t={},n.json_schema.fields.forEach(function(e){if("id"!==e.name&&oe(e))if("relation"===e.type&&e.relation){var n=e.relation.foreignKey||"".concat(e.relation.target,"_id");t[n]=E[n]}else{var r=E[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=mv(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}}),!x){e.n=4;break}return r=Object.assign(Object.assign({},t),{id:x.id}),e.n=3,Yf(n.table_name,r);case 3:(i=e.v).success?(fh.success("更新成功"),g(!1),ae()):fh.error(i.message||"更新失败"),e.n=6;break;case 4:return e.n=5,Kf(n.table_name,t);case 5:(o=e.v).success?(fh.success("创建成功"),g(!1),ae()):fh.error(o.message||"创建失败");case 6:e.n=8;break;case 7:e.p=7,a=e.v,s=a instanceof Error?a.message:"操作失败",fh.error(s);case 8:return e.p=8,$(!1),e.f(8);case 9:return e.a(2)}},e,null,[[2,7,8,9]])}));return function(){return e.apply(this,arguments)}}(),ue=function(t,n,r){if("string"==typeof n){var o=n.trim();if(o&&function(e){var t,n=e.trim();if(!n)return!1;if(n.startsWith("data:image/"))return!0;if(!mP(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)}(o))return e.createElement(gP,{url:o});if(o&&mP(o))return e.createElement("a",{href:o,target:"_blank",rel:"noreferrer",className:"max-w-[360px] truncate text-primary underline-offset-2 hover:underline block",title:o},o)}if("boolean"===t.type)return e.createElement(uP,{variant:n?"default":"secondary"},n?"是":"否");if("date"===t.type||"datetime"===t.type)return n?i(n).format("YYYY-MM-DD HH:mm:ss"):"-";if("text"===t.type&&n&&n.length>50)return e.createElement("span",{className:"max-w-xs truncate block",title:n},n.substring(0,50),"...");if("json"===t.type||"jsonb"===t.type)return e.createElement(ZD,{value:n,title:t.comment||t.name});if("relation"===t.type&&t.relation&&r){var s=t.relation.displayField,a=void 0===s?"name":s,l=r["".concat(t.name,"_data")];if(l)return e.createElement(uP,{variant:"outline"},l[a]||"ID: ".concat(l.id));var c=r[t.relation.foreignKey||"".concat(t.relation.target,"_id")];return c?"ID: ".concat(c):"-"}return n||"-"};return n?e.createElement("div",{className:"min-h-[calc(100vh-4rem)] bg-gradient-to-br from-background via-background to-muted/20"},e.createElement("div",{className:"w-full py-4 space-y-4"},e.createElement("div",{className:"space-y-1"},e.createElement("div",{className:"flex items-center gap-3"},e.createElement("div",{className:"inline-flex items-center justify-center w-9 h-9 rounded-lg bg-primary/10 text-primary"},e.createElement(P,{className:"h-4 w-4"})),e.createElement("div",null,e.createElement("h1",{className:"text-2xl font-bold tracking-tight leading-tight"},n.name),e.createElement("p",{className:"text-sm text-muted-foreground"},"表名: ",n.table_name)))),e.createElement(Yu,{className:"border-2 shadow-lg"},e.createElement(Gu,{className:"bg-muted/30"},e.createElement("div",{className:"flex flex-col md:flex-row md:items-center md:justify-between gap-4"},e.createElement("div",null,e.createElement(Xu,null,"数据管理"),e.createElement(Ju,null,"查看和管理 ",n.name," 的数据")),e.createElement(ut,{onClick:function(){k(null),C({}),g(!0)},className:"w-full md:w-auto"},e.createElement(q,{className:"h-4 w-4 mr-2"}),"新建数据"))),e.createElement(Qu,{className:"space-y-4 pt-4"},e.createElement("div",{className:"flex flex-col md:flex-row md:items-center gap-3"},e.createElement("div",{className:"flex-1"},e.createElement(Ku,{htmlFor:"search",className:"sr-only"},"搜索"),e.createElement("div",{className:"relative"},e.createElement(U,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.createElement(ht,{id:"search",placeholder:"搜索数据...",value:W,onChange:function(e){return z(e.target.value)},className:"pl-10 h-10"}))),e.createElement(ut,{type:"button",variant:"outline",className:"h-10",onClick:function(){return y(!0)}},e.createElement(I,{className:"h-4 w-4 mr-2"}),"筛选",ne.length>0?"(".concat(ne.length,")"):"")),e.createElement("div",{className:"flex items-center justify-between p-4 rounded-lg bg-muted/50 border"},e.createElement("div",{className:"text-sm text-muted-foreground"},"共 ",e.createElement("span",{className:"font-semibold text-foreground"},_)," 条数据"),e.createElement(uP,{variant:"outline"},n.name)),e.createElement("div",{className:"rounded-lg border overflow-hidden"},e.createElement(tP,null,e.createElement(nP,null,e.createElement(oP,{className:"bg-muted/50"},e.createElement(sP,{className:"font-semibold w-20"},"ID"),n.json_schema.fields.map(function(t){return e.createElement(sP,{key:t.name,className:"font-semibold"},t.comment||t.name)}),e.createElement(sP,{className:"font-semibold"},"创建时间"),e.createElement(sP,{className:"font-semibold"},"更新时间"),e.createElement(sP,{className:Ke("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)]")},"操作"))),e.createElement(rP,null,l?Array.from({length:3}).map(function(t,r){return e.createElement(oP,{key:r},e.createElement(aP,{colSpan:n.json_schema.fields.length+4},e.createElement("div",{className:"flex items-center gap-2 py-4"},e.createElement(F,{className:"h-4 w-4 animate-spin text-muted-foreground"}),e.createElement("span",{className:"text-sm text-muted-foreground"},"加载中..."))))}):0===o.length?e.createElement(oP,null,e.createElement(aP,{colSpan:n.json_schema.fields.length+4,className:"text-center py-12"},e.createElement("div",{className:"flex flex-col items-center gap-2 text-muted-foreground"},e.createElement(U,{className:"h-8 w-8"}),e.createElement("p",null,"暂无数据")))):o.map(function(t,r){return e.createElement(oP,{key:t.id,className:Ke("group hover:bg-muted",r%2==0?"bg-muted/20":"")},e.createElement(aP,{className:"font-mono font-medium max-w-[220px] truncate",title:String(t.id)},t.id),n.json_schema.fields.map(function(n){return e.createElement(aP,{key:n.name},ue(n,t[n.name],t))}),e.createElement(aP,{className:"text-sm text-muted-foreground"},i(t.created_at).format("YYYY-MM-DD HH:mm")),e.createElement(aP,{className:"text-sm text-muted-foreground"},i(t.updated_at).format("YYYY-MM-DD HH:mm")),e.createElement(aP,{className:Ke("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")},e.createElement("div",{className:"flex items-center justify-center gap-2"},e.createElement(ut,{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 o=e[n.name];"date"!==n.type&&"datetime"!==n.type||(o=o?i(o).format("YYYY-MM-DDTHH:mm"):""),"json"!==n.type&&"jsonb"!==n.type||(o=null==o||""===o?"":"string"==typeof o?o:JSON.stringify(o,null,2)),t[n.name]=o}}),C(t),g(!0)}(t)},className:"h-8 w-8 p-0"},e.createElement(K,{className:"h-4 w-4"})),e.createElement(ut,{variant:"ghost",size:"sm",onClick:function(){return le(t)},disabled:X===t.id,className:"h-8 w-8 p-0 text-destructive hover:text-destructive"},X===t.id?e.createElement(F,{className:"h-4 w-4 animate-spin"}):e.createElement(G,{className:"h-4 w-4"})))))})))),_>D&&e.createElement("div",{className:"flex items-center justify-between p-4 rounded-lg bg-muted/50 border"},e.createElement("div",{className:"text-sm text-muted-foreground"},"第 ",e.createElement("span",{className:"font-semibold text-foreground"},O)," 页, 共 ",e.createElement("span",{className:"font-semibold text-foreground"},Math.ceil(_/D))," 页"),e.createElement("div",{className:"flex gap-2"},e.createElement(ut,{variant:"outline",size:"sm",onClick:function(){return T(Math.max(1,O-1))},disabled:1===O||l},e.createElement(A,{className:"h-4 w-4 mr-1"}),"上一页"),e.createElement(ut,{variant:"outline",size:"sm",onClick:function(){return T(Math.min(Math.ceil(_/D),O+1))},disabled:O>=Math.ceil(_/D)||l},"下一页",e.createElement(M,{className:"h-4 w-4 ml-1"})))))),e.createElement(Hg,{open:b,onOpenChange:y},e.createElement($g,{className:"max-w-3xl"},e.createElement(Kg,null,e.createElement(Gg,{className:"text-xl"},"筛选"),e.createElement(Jg,{className:"text-sm"},n.name," - ",n.table_name)),e.createElement("div",{className:"py-2"},e.createElement(fP,{fields:n.json_schema.fields,value:ne,onChange:function(e){re(e),T(1)}})),e.createElement(Yg,{className:"gap-2"},e.createElement(ut,{variant:"outline",onClick:function(){return y(!1)}},"关闭")))),e.createElement(Hg,{open:p,onOpenChange:g},e.createElement($g,{className:"max-w-3xl max-h-[85vh] overflow-y-auto"},e.createElement(Kg,null,e.createElement(Gg,{className:"text-2xl"},x?"编辑数据":"新建数据"),e.createElement(Jg,{className:"text-base"},n.name," - ",n.table_name)),e.createElement("div",{className:"space-y-4 py-4"},n.json_schema.fields.map(function(t){return function(t){if("id"===t.name)return null;var n=oe(t);switch(t.type){case"boolean":return e.createElement("div",{key:t.name,className:"flex items-center space-x-3 p-4 rounded-lg border bg-card"},e.createElement(Wg,{id:t.name,checked:E[t.name]||!1,disabled:!n,onCheckedChange:function(e){return C(Object.assign(Object.assign({},E),d({},t.name,e)))}}),e.createElement(Ku,{htmlFor:t.name,className:"text-base font-medium cursor-pointer"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")));case"date":return e.createElement("div",{key:t.name,className:"space-y-2"},e.createElement(Ku,{htmlFor:t.name,className:"text-base font-medium"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")),e.createElement(ht,{id:t.name,type:"date",value:E[t.name]||"",disabled:!n,onChange:function(e){return C(Object.assign(Object.assign({},E),d({},t.name,e.target.value)))},required:t.required,className:"h-11"}));case"datetime":return e.createElement("div",{key:t.name,className:"space-y-2"},e.createElement(Ku,{htmlFor:t.name,className:"text-base font-medium"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")),e.createElement(ht,{id:t.name,type:"datetime-local",value:E[t.name]||"",disabled:!n,onChange:function(e){return C(Object.assign(Object.assign({},E),d({},t.name,e.target.value)))},required:t.required,className:"h-11"}));case"text":return e.createElement("div",{key:t.name,className:"space-y-2"},e.createElement(Ku,{htmlFor:t.name,className:"text-base font-medium"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")),e.createElement(zg,{id:t.name,rows:4,value:E[t.name]||"",disabled:!n,onChange:function(e){return C(Object.assign(Object.assign({},E),d({},t.name,e.target.value)))},required:t.required,className:"resize-none"}));case"json":case"jsonb":return e.createElement("div",{key:t.name,className:"space-y-2"},e.createElement(Ku,{htmlFor:t.name,className:"text-base font-medium"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")),e.createElement(eP,{id:t.name,value:E[t.name]||"",required:t.required,disabled:!n,onChange:function(e){return C(Object.assign(Object.assign({},E),d({},t.name,e)))}}));case"integer":case"float":return e.createElement("div",{key:t.name,className:"space-y-2"},e.createElement(Ku,{htmlFor:t.name,className:"text-base font-medium"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")),e.createElement(ht,{id:t.name,type:"number",value:E[t.name]||"",disabled:!n,onChange:function(e){return C(Object.assign(Object.assign({},E),d({},t.name,e.target.value)))},required:t.required,className:"h-11"}));case"relation":if(!t.relation)return null;var r=t.relation,i=r.target,o=r.displayField,s=void 0===o?"name":o,a="".concat(i,"_").concat(s),l=Z[a]||[],c=t.relation.foreignKey||"".concat(i,"_id"),u=void 0!==E[c]&&null!==E[c]?String(E[c]):"",h=l.find(function(e){return String(e.id)===u});return e.createElement("div",{key:t.name,className:"space-y-2"},e.createElement(Ku,{htmlFor:t.name,className:"text-base font-medium"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")),e.createElement(mg,{value:u,disabled:!n,onValueChange:function(e){var t=parseInt(e,10),n=!isNaN(t)&&String(t)===e;C(Object.assign(Object.assign({},E),d({},c,n?t:e)))}},e.createElement(vg,{className:"h-11"},e.createElement(gg,{placeholder:"请选择".concat(t.comment||t.name)},h?h.label:u?"ID: ".concat(u):"请选择".concat(t.comment||t.name))),e.createElement(wg,null,0===l.length?e.createElement(kg,{value:"_loading",disabled:!0},"加载中..."):l.map(function(t){return e.createElement(kg,{key:t.id,value:String(t.id)},t.label)}))));default:return e.createElement("div",{key:t.name,className:"space-y-2"},e.createElement(Ku,{htmlFor:t.name,className:"text-base font-medium"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")),e.createElement(ht,{id:t.name,type:"email"===t.type?"email":"text",maxLength:t.maxLength,value:E[t.name]||"",disabled:!n,onChange:function(e){return C(Object.assign(Object.assign({},E),d({},t.name,e.target.value)))},required:t.required,className:"h-11"}))}}(t)})),e.createElement(Yg,{className:"gap-2"},e.createElement(ut,{variant:"outline",onClick:function(){return g(!1)},disabled:V},"取消"),e.createElement(ut,{onClick:ce,disabled:V},V?e.createElement(e.Fragment,null,e.createElement(F,{className:"h-4 w-4 mr-2 animate-spin"}),x?"更新中...":"创建中..."):x?"更新":"创建")))))):e.createElement("div",{className:"min-h-[calc(100vh-4rem)] bg-gradient-to-br from-background via-background to-muted/20"},e.createElement("div",{className:"w-full py-4"},e.createElement(Yu,{className:"border-2"},e.createElement(Qu,{className:"py-16 text-center"},e.createElement(P,{className:"h-12 w-12 mx-auto mb-4 text-muted-foreground"}),e.createElement("p",{className:"text-lg text-muted-foreground"},"请选择数据模型")))))}function bP(t){var n=t.model;return e.createElement(vP,{key:n.id,model:n})}function yP(t){return t.models.map(function(t){return{path:"/data/list-".concat(t.id),name:t.name,icon:e.createElement(Y),component:function(){return e.createElement(bP,{model:t})}}})}var wP=function(t){return[{path:"/login",name:"登录",icon:e.createElement(z),component:np},{name:"数据管理",icon:e.createElement(D),path:"/data",component:pP,routes:g(yP(t))}]},xP=$,kP=X,SP=H,EP=B;function CP(t){var n=t.inputModels,r=t.skipAuth,i=void 0!==r&&r,o=t.brandName,s=void 0===o?"WE0-CMS":o,a=ep(),l=tp(),c=l.locale,d=l.setLocale,p=m(e.useState("/data"),2),g=p[0],v=p[1],b=m(e.useState([]),2);b[0],b[1];var y=m(e.useState(!1),2),w=y[0],x=y[1],k=m(e.useState(null),2),S=k[0],E=k[1],C=m(e.useState(!0),2),N=C[0],O=C[1],A=e.useMemo(function(){return wP({models:n.models})},[n.models]);e.useEffect(function(){if(i)return x(!0),E(null),O(!1),void("/login"===g&&v("/data"));var e=function(){var e=u(f().m(function e(){var t,n;return f().w(function(e){for(;;)switch(e.p=e.n){case 0:if(e.p=0,Vf()){e.n=1;break}return x(!1),v("/login"),O(!1),e.a(2);case 1:return e.p=1,e.n=2,Wf();case 2:if(e.v.success){e.n=3;break}throw new Error("token验证失败");case 3:if(!(t=qf())){e.n=4;break}E(t),e.n=6;break;case 4:return e.n=5,zf();case 5:(n=e.v).success&&n.data&&(E(n.data),localStorage.setItem("cms_user",JSON.stringify(n.data)));case 6:x(!0),"/login"===g&&v("/data"),e.n=8;break;case 7:e.p=7,e.v,Hf(),x(!1),E(null),v("/login");case 8:e.n=10;break;case 9:e.p=9,e.v,x(!1),E(null),v("/login");case 10:return e.p=10,O(!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()},[i]);var M=function(e,t){E(t),x(!0),v("/data"),fh.success("".concat(a("auth.welcome"),", ").concat(t.username,"!"))},T=function(e,t){var n,r=h(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(N)return e.createElement("div",{className:"flex min-h-screen items-center justify-center bg-background"},e.createElement("div",{className:"space-y-4"},e.createElement(Ye,{className:"h-12 w-48"}),e.createElement(Ye,{className:"h-4 w-64"})));if(!w)return e.createElement(np,{onLoginSuccess:M});var R=A.filter(function(e){return"/login"!==e.path}),D=function(t){if(!t)return P;if(e.isValidElement(t)){var n=t.type;if(n&&"function"==typeof n){var r=n.name||"";if(r.includes("Home"))return _;if(r.includes("Table"))return Y;if(r.includes("Database"))return P;if(r.includes("File"))return L}}return P},I=R.flatMap(function(e){return e.routes&&e.routes.length>0?e.routes.map(function(e){return{title:e.name,icon:D(e.icon),path:e.path}}):[{title:e.name,icon:D(e.icon),path:e.path}]});return e.createElement("div",{className:"we0-cms-root"},e.createElement(ia,null,e.createElement(oa,{variant:"inset"},e.createElement(la,{className:"border-b border-sidebar-border p-4"},e.createElement("div",{className:"flex items-center gap-3"},e.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"},e.createElement(xP,{className:"w-5 h-5 text-primary-foreground"})),e.createElement("span",{className:"font-bold text-xl text-foreground"},s))),e.createElement(ua,null,e.createElement(ha,null,e.createElement(da,null,"Navigation"),e.createElement(fa,null,e.createElement(pa,null,I.map(function(t){return e.createElement(ma,{key:t.path},e.createElement(va,{onClick:function(){return v(t.path)},isActive:(n=t.path,g===n||g.startsWith(n+"/")),tooltip:t.title},e.createElement(t.icon,{className:"w-4 h-4"}),e.createElement("span",null,t.title)));var n}))))),e.createElement(ca,{className:"border-t border-sidebar-border"},e.createElement(pa,null,e.createElement(ma,null,e.createElement(Pu,null,e.createElement(Lu,{asChild:!0},e.createElement(va,{tooltip:a("settings.language")},e.createElement(EP,{className:"w-4 h-4"}),e.createElement("span",null,"zh-CN"===c?"中文":"English"))),e.createElement(ju,{align:"end",className:"w-48"},e.createElement(Bu,{onClick:function(){return d("zh-CN")},className:"zh-CN"===c?"bg-accent":""},"简体中文"),e.createElement(Bu,{onClick:function(){return d("en-US")},className:"en-US"===c?"bg-accent":""},"English")))),!i&&S&&e.createElement(e.Fragment,null,e.createElement(ma,null,e.createElement(va,{tooltip:S.username||"User"},e.createElement(kP,{className:"w-4 h-4"}),e.createElement("span",{className:"truncate"},S.username))),e.createElement(ma,null,e.createElement(va,{onClick:function(){window.confirm(a("auth.logoutConfirm"))&&(Hf(),localStorage.removeItem("cms_token"),localStorage.removeItem("cms_user"),x(!1),E(null),v("/login"),fh.success(a("auth.logoutSuccess")))},tooltip:a("auth.logout")},e.createElement(SP,{className:"w-4 h-4"}),e.createElement("span",null,a("auth.logout")))))))),e.createElement(aa,null,e.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"},e.createElement(sa,null),e.createElement("h1",{className:"text-xl font-bold text-foreground"},function(){if("/login"===g)return a("auth.login");var e=T(A,g);return(null==e?void 0:e.name)||a("data.dataManagement")}())),e.createElement("main",{className:"flex-1 min-w-0 p-8 bg-gradient-to-br from-background via-background to-muted/20"},function(){if(!i&&"/login"===g)return e.createElement(np,{onLoginSuccess:M});if(i&&"/login"===g)return e.createElement(pP,null);var t=T(A,g);if(t){var n=t.component;return e.createElement(n,null)}return e.createElement(pP,null)}()))))}function NP(t){var n=t.defaultLocale,r=w(t,["defaultLocale"]);return e.createElement(Qf,{defaultLocale:n},e.createElement(CP,Object.assign({},r)))}exports.CmsLayoutShadcn=NP,exports.I18nProvider=Qf,exports.cmsRoutes=wP,exports.default=NP,exports.setSessionId=function(e){Tf=e;try{localStorage.setItem("cms_session_id",e)}catch(e){}},exports.useLocale=tp,exports.useT=ep,exports.useTranslation=Zf;
10
+ var z={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"},V=["color","size","strokeWidth","absoluteStrokeWidth","className","children"],q=function(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase().trim()},U=function(t,n){var r=e.forwardRef(function(r,i){var o=r.color,s=void 0===o?"currentColor":o,a=r.size,l=void 0===a?24:a,c=r.strokeWidth,u=void 0===c?2:c,h=r.absoluteStrokeWidth,f=r.className,d=void 0===f?"":f,p=r.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}(r,V);return e.createElement("svg",M(M({ref:i},z),{},{width:l,height:l,stroke:s,strokeWidth:h?24*Number(u)/Number(l):u,className:["lucide","lucide-".concat(q(t)),d].join(" ")},m),[].concat(L(n.map(function(t){var n=D(t,2),r=n[0],i=n[1];return e.createElement(r,i)})),L(Array.isArray(p)?p:[p])))});return r.displayName="".concat(t),r},K=U("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"}]]),G=U("CheckCircle2",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),Y=U("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]),$=U("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]),X=U("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]),J=U("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]),Q=U("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]),Z=U("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]),ee=U("Crown",[["path",{d:"m2 4 3 12h14l3-12-6 7-4-7-4 7-6-7zm3 16h14",key:"zkxr6b"}]]),te=U("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"}]]),ne=U("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"}]]),re=U("Filter",[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]]),ie=U("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"}]]),oe=U("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]),se=U("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"}]]),ae=U("Loader2",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]),le=U("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"}]]),ce=U("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"}]]),ue=U("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"}]]),he=U("PanelLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),fe=U("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]),de=U("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]),pe=U("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=U("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"}]]),ge=U("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"}]]),ve=U("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"}]]),ye=U("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"}]]),be=U("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"}]]),we=U("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function ke(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=ke(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function xe(){for(var e,t,n=0,r="",i=arguments.length;n<i;n++)(e=arguments[n])&&(t=ke(e))&&(r&&(r+=" "),r+=t);return r}const Se=e=>{const t=Me(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{const n=e.split("-");return""===n[0]&&1!==n.length&&n.shift(),Ce(n,t)||Ae(e)},getConflictingClassGroupIds:(e,t)=>{const i=n[e]||[];return t&&r[e]?[...i,...r[e]]:i}}},Ce=(e,t)=>{if(0===e.length)return t.classGroupId;const n=e[0],r=t.nextPart.get(n),i=r?Ce(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},Ee=/^\[(.+)\]$/,Ae=e=>{if(Ee.test(e)){const t=Ee.exec(e)[1],n=t?.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},Me=e=>{const{theme:t,prefix:n}=e,r={nextPart:new Map,validators:[]};return Re(Object.entries(e.classGroups),n).forEach(([e,n])=>{Oe(n,r,e,t)}),r},Oe=(e,t,n,r)=>{e.forEach(e=>{if("string"==typeof e){return void((""===e?t:Ne(t,e)).classGroupId=n)}if("function"==typeof e)return Te(e)?void Oe(e(r),t,n,r):void t.validators.push({validator:e,classGroupId:n});Object.entries(e).forEach(([e,i])=>{Oe(i,Ne(t,e),n,r)})})},Ne=(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},Te=e=>e.isThemeGetter,Re=(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,De=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)}}},Pe=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},Le=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},Be=/\s+/;function Ie(){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 je(e,...t){let n,r,i,o=function(a){const l=t.reduce((e,t)=>t(e),e());return n=(e=>({cache:De(e.cacheSize),parseClassName:Pe(e),...Se(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(Be);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=Le(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(Ie.apply(null,arguments))}}const Fe=e=>{const t=t=>t[e]||[];return t.isThemeGetter=!0,t},We=/^\[(?:([a-z-]+):)?(.+)\]$/i,He=/^\d+\/\d+$/,ze=new Set(["px","full","screen"]),Ve=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,qe=/\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$/,Ue=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,Ke=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Ge=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Ye=e=>Xe(e)||ze.has(e)||He.test(e),$e=e=>ct(e,"length",ut),Xe=e=>Boolean(e)&&!Number.isNaN(Number(e)),Je=e=>ct(e,"number",Xe),Qe=e=>Boolean(e)&&Number.isInteger(Number(e)),Ze=e=>e.endsWith("%")&&Xe(e.slice(0,-1)),et=e=>We.test(e),tt=e=>Ve.test(e),nt=new Set(["length","size","percentage"]),rt=e=>ct(e,nt,ht),it=e=>ct(e,"position",ht),ot=new Set(["image","url"]),st=e=>ct(e,ot,dt),at=e=>ct(e,"",ft),lt=()=>!0,ct=(e,t,n)=>{const r=We.exec(e);return!!r&&(r[1]?"string"==typeof t?r[1]===t:t.has(r[1]):n(r[2]))},ut=e=>qe.test(e)&&!Ue.test(e),ht=()=>!1,ft=e=>Ke.test(e),dt=e=>Ge.test(e),pt=je(()=>{const e=Fe("colors"),t=Fe("spacing"),n=Fe("blur"),r=Fe("brightness"),i=Fe("borderColor"),o=Fe("borderRadius"),s=Fe("borderSpacing"),a=Fe("borderWidth"),l=Fe("contrast"),c=Fe("grayscale"),u=Fe("hueRotate"),h=Fe("invert"),f=Fe("gap"),d=Fe("gradientColorStops"),p=Fe("gradientColorStopPositions"),m=Fe("inset"),g=Fe("margin"),v=Fe("opacity"),y=Fe("padding"),b=Fe("saturate"),w=Fe("scale"),k=Fe("sepia"),x=Fe("skew"),S=Fe("space"),C=Fe("translate"),E=()=>["auto",et,t],A=()=>[et,t],M=()=>["",Ye,$e],O=()=>["auto",Xe,et],N=()=>["","0",et],T=()=>[Xe,et];return{cacheSize:500,separator:":",theme:{colors:[lt],spacing:[Ye,$e],blur:["none","",tt,et],brightness:T(),borderColor:[e],borderRadius:["none","","full",tt,et],borderSpacing:A(),borderWidth:M(),contrast:T(),grayscale:N(),hueRotate:T(),invert:N(),gap:A(),gradientColorStops:[e],gradientColorStopPositions:[Ze,$e],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",et]}],container:["container"],columns:[{columns:[tt]}],"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",et]}],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",Qe,et]}],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",et]}],grow:[{grow:N()}],shrink:[{shrink:N()}],order:[{order:["first","last","none",Qe,et]}],"grid-cols":[{"grid-cols":[lt]}],"col-start-end":[{col:["auto",{span:["full",Qe,et]},et]}],"col-start":[{"col-start":O()}],"col-end":[{"col-end":O()}],"grid-rows":[{"grid-rows":[lt]}],"row-start-end":[{row:["auto",{span:[Qe,et]},et]}],"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",et]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",et]}],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",et,t]}],"min-w":[{"min-w":[et,t,"min","max","fit"]}],"max-w":[{"max-w":[et,t,"none","full","min","max","fit","prose",{screen:[tt]},tt]}],h:[{h:[et,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[et,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[et,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[et,t,"auto","min","max","fit"]}],"font-size":[{text:["base",tt,$e]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Je]}],"font-family":[{font:[lt]}],"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",et]}],"line-clamp":[{"line-clamp":["none",Xe,Je]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Ye,et]}],"list-image":[{"list-image":["none",et]}],"list-style-type":[{list:["none","disc","decimal",et]}],"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",Ye,$e]}],"underline-offset":[{"underline-offset":["auto",Ye,et]}],"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",et]}],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",et]}],"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",it]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",rt]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},st]}],"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":[Ye,et]}],"outline-w":[{outline:[Ye,$e]}],"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":[Ye,$e]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",tt,at]}],"shadow-color":[{shadow:[lt]}],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",tt,et]}],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",et]}],duration:[{duration:T()}],ease:[{ease:["linear","in","out","in-out",et]}],delay:[{delay:T()}],animate:[{animate:["none","spin","ping","pulse","bounce",et]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[w]}],"scale-x":[{"scale-x":[w]}],"scale-y":[{"scale-y":[w]}],rotate:[{rotate:[Qe,et]}],"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",et]}],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",et]}],"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",et]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[Ye,$e,Je]}],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 pt(xe(t))}function gt(e){var t=e.className,n=H(e,["className"]);return s.createElement("div",Object.assign({className:mt("animate-pulse rounded-md bg-muted",t)},n))}function vt(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function yt(...e){return t=>{let n=!1;const r=e.map(e=>{const r=vt(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():vt(e[t],null)}}}}function bt(...e){return s.useCallback(yt(...e),e)}var wt=Symbol.for("react.lazy"),kt=s[" use ".trim().toString()];function xt(e){return null!=e&&"object"==typeof e&&"$$typeof"in e&&e.$$typeof===wt&&"_payload"in e&&("object"==typeof(t=e._payload)&&null!==t&&"then"in t);var t}function St(e){const n=Et(e),r=s.forwardRef((e,r)=>{let{children:i,...o}=e;xt(i)&&"function"==typeof kt&&(i=kt(i._payload));const a=s.Children.toArray(i),l=a.find(Mt);if(l){const e=l.props.children,i=a.map(t=>t===l?s.Children.count(e)>1?s.Children.only(null):s.isValidElement(e)?e.props.children:null:t);return t.jsx(n,{...o,ref:r,children:s.isValidElement(e)?s.cloneElement(e,void 0,i):null})}return t.jsx(n,{...o,ref:r,children:i})});return r.displayName=`${e}.Slot`,r}var Ct=St("Slot");function Et(e){const t=s.forwardRef((e,t)=>{let{children:n,...r}=e;if(xt(n)&&"function"==typeof kt&&(n=kt(n._payload)),s.isValidElement(n)){const e=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}(n),i=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}}(r,n.props);return n.type!==s.Fragment&&(i.ref=t?yt(t,e):e),s.cloneElement(n,i)}return s.Children.count(n)>1?s.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var At=Symbol("radix.slottable");function Mt(e){return s.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===At}const Ot=e=>"boolean"==typeof e?`${e}`:0===e?"0":e,Nt=xe,Tt=(e,t)=>n=>{var r;if(null==(null==t?void 0:t.variants))return Nt(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=Ot(t)||Ot(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 Nt(e,s,l,null==n?void 0:n.class,null==n?void 0:n.className)};var Rt=Tt("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"}}),Dt=s.forwardRef(function(e,t){var n=e.className,r=e.variant,i=e.size,o=e.asChild,a=void 0!==o&&o,l=H(e,["className","variant","size","asChild"]),c=a?Ct:"button";return s.createElement(c,Object.assign({className:mt(Rt({variant:r,size:i,className:n})),ref:t},l))});Dt.displayName="Button";var Pt=s.forwardRef(function(e,t){var n=e.className,r=e.type,i=H(e,["className","type"]);return s.createElement("input",Object.assign({type:r,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",n),ref:t},i))});Pt.displayName="Input";var Lt=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,n)=>{const r=St(`Primitive.${n}`),i=s.forwardRef((e,i)=>{const{asChild:o,...s}=e,a=o?r:n;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),t.jsx(a,{...s,ref:i})});return i.displayName=`Primitive.${n}`,{...e,[n]:i}},{}),Bt="horizontal",It=["horizontal","vertical"],_t=s.forwardRef((e,n)=>{const{decorative:r,orientation:i=Bt,...o}=e,s=function(e){return It.includes(e)}(i)?i:Bt,a=r?{role:"none"}:{"aria-orientation":"vertical"===s?s:void 0,role:"separator"};return t.jsx(Lt.div,{"data-orientation":s,...a,...o,ref:n})});_t.displayName="Separator";var jt=_t,Ft=s.forwardRef(function(e,t){var n=e.className,r=e.orientation,i=void 0===r?"horizontal":r,o=e.decorative,a=void 0===o||o,l=H(e,["className","orientation","decorative"]);return s.createElement(jt,Object.assign({ref:t,decorative:a,orientation:i,className:mt("shrink-0 bg-border","horizontal"===i?"h-[1px] w-full":"h-full w-[1px]",n)},l))});function Wt(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),!1===n||!r.defaultPrevented)return t?.(r)}}function Ht(e,n=[]){let r=[];const i=()=>{const t=r.map(e=>s.createContext(e));return function(n){const r=n?.[e]||t;return s.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return i.scopeName=e,[function(n,i){const o=s.createContext(i),a=r.length;r=[...r,i];const l=n=>{const{scope:r,children:i,...l}=n,c=r?.[e]?.[a]||o,u=s.useMemo(()=>l,Object.values(l));return t.jsx(c.Provider,{value:u,children:i})};return l.displayName=n+"Provider",[l,function(t,r){const l=r?.[e]?.[a]||o,c=s.useContext(l);if(c)return c;if(void 0!==i)return i;throw new Error(`\`${t}\` must be used within \`${n}\``)}]},zt(i,...n)]}function zt(...e){const t=e[0];if(1===e.length)return t;const n=()=>{const n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){const r=n.reduce((t,{useScope:n,scopeName:r})=>({...t,...n(e)[`__scope${r}`]}),{});return s.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}Ft.displayName=jt.displayName;var Vt=globalThis?.document?s.useLayoutEffect:()=>{},qt=s[" useId ".trim().toString()]||(()=>{}),Ut=0;function Kt(e){const[t,n]=s.useState(qt());return Vt(()=>{e||n(e=>e??String(Ut++))},[e]),e||(t?`radix-${t}`:"")}var Gt=s[" useInsertionEffect ".trim().toString()]||Vt;function Yt({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[i,o,a]=function({defaultProp:e,onChange:t}){const[n,r]=s.useState(e),i=s.useRef(n),o=s.useRef(t);return Gt(()=>{o.current=t},[t]),s.useEffect(()=>{i.current!==n&&(o.current?.(n),i.current=n)},[n,i]),[n,r,o]}({defaultProp:t,onChange:n}),l=void 0!==e,c=l?e:i;{const t=s.useRef(void 0!==e);s.useEffect(()=>{const e=t.current;if(e!==l){}t.current=l},[l,r])}const u=s.useCallback(t=>{if(l){const n=function(e){return"function"==typeof e}(t)?t(e):t;n!==e&&a.current?.(n)}else o(t)},[l,e,o,a]);return[c,u]}function $t(e){const n=Xt(e),r=s.forwardRef((e,r)=>{const{children:i,...o}=e,a=s.Children.toArray(i),l=a.find(Qt);if(l){const e=l.props.children,i=a.map(t=>t===l?s.Children.count(e)>1?s.Children.only(null):s.isValidElement(e)?e.props.children:null:t);return t.jsx(n,{...o,ref:r,children:s.isValidElement(e)?s.cloneElement(e,void 0,i):null})}return t.jsx(n,{...o,ref:r,children:i})});return r.displayName=`${e}.Slot`,r}function Xt(e){const t=s.forwardRef((e,t)=>{const{children:n,...r}=e;if(s.isValidElement(n)){const e=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}(n),i=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}}(r,n.props);return n.type!==s.Fragment&&(i.ref=t?yt(t,e):e),s.cloneElement(n,i)}return s.Children.count(n)>1?s.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Jt=Symbol("radix.slottable");function Qt(e){return s.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===Jt}var Zt=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,n)=>{const r=$t(`Primitive.${n}`),i=s.forwardRef((e,i)=>{const{asChild:o,...s}=e,a=o?r:n;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),t.jsx(a,{...s,ref:i})});return i.displayName=`Primitive.${n}`,{...e,[n]:i}},{});function en(e,t){e&&a.flushSync(()=>e.dispatchEvent(t))}function tn(e){const t=s.useRef(e);return s.useEffect(()=>{t.current=e}),s.useMemo(()=>(...e)=>t.current?.(...e),[])}var nn,rn="dismissableLayer.update",on="dismissableLayer.pointerDownOutside",sn="dismissableLayer.focusOutside",an=s.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),ln=s.forwardRef((e,n)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:l,onDismiss:c,...u}=e,h=s.useContext(an),[f,d]=s.useState(null),p=f?.ownerDocument??globalThis?.document,[,m]=s.useState({}),g=bt(n,e=>d(e)),v=Array.from(h.layers),[y]=[...h.layersWithOutsidePointerEventsDisabled].slice(-1),b=v.indexOf(y),w=f?v.indexOf(f):-1,k=h.layersWithOutsidePointerEventsDisabled.size>0,x=w>=b,S=function(e,t=globalThis?.document){const n=tn(e),r=s.useRef(!1),i=s.useRef(()=>{});return s.useEffect(()=>{const e=e=>{if(e.target&&!r.current){let r=function(){un(on,n,o,{discrete:!0})};const o={originalEvent:e};"touch"===e.pointerType?(t.removeEventListener("click",i.current),i.current=r,t.addEventListener("click",i.current,{once:!0})):r()}else t.removeEventListener("click",i.current);r.current=!1},o=window.setTimeout(()=>{t.addEventListener("pointerdown",e)},0);return()=>{window.clearTimeout(o),t.removeEventListener("pointerdown",e),t.removeEventListener("click",i.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}(e=>{const t=e.target,n=[...h.branches].some(e=>e.contains(t));x&&!n&&(o?.(e),l?.(e),e.defaultPrevented||c?.())},p),C=function(e,t=globalThis?.document){const n=tn(e),r=s.useRef(!1);return s.useEffect(()=>{const e=e=>{if(e.target&&!r.current){un(sn,n,{originalEvent:e},{discrete:!1})}};return t.addEventListener("focusin",e),()=>t.removeEventListener("focusin",e)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}(e=>{const t=e.target;[...h.branches].some(e=>e.contains(t))||(a?.(e),l?.(e),e.defaultPrevented||c?.())},p);return function(e,t=globalThis?.document){const n=tn(e);s.useEffect(()=>{const e=e=>{"Escape"===e.key&&n(e)};return t.addEventListener("keydown",e,{capture:!0}),()=>t.removeEventListener("keydown",e,{capture:!0})},[n,t])}(e=>{w===h.layers.size-1&&(i?.(e),!e.defaultPrevented&&c&&(e.preventDefault(),c()))},p),s.useEffect(()=>{if(f)return r&&(0===h.layersWithOutsidePointerEventsDisabled.size&&(nn=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),h.layersWithOutsidePointerEventsDisabled.add(f)),h.layers.add(f),cn(),()=>{r&&1===h.layersWithOutsidePointerEventsDisabled.size&&(p.body.style.pointerEvents=nn)}},[f,p,r,h]),s.useEffect(()=>()=>{f&&(h.layers.delete(f),h.layersWithOutsidePointerEventsDisabled.delete(f),cn())},[f,h]),s.useEffect(()=>{const e=()=>m({});return document.addEventListener(rn,e),()=>document.removeEventListener(rn,e)},[]),t.jsx(Zt.div,{...u,ref:g,style:{pointerEvents:k?x?"auto":"none":void 0,...e.style},onFocusCapture:Wt(e.onFocusCapture,C.onFocusCapture),onBlurCapture:Wt(e.onBlurCapture,C.onBlurCapture),onPointerDownCapture:Wt(e.onPointerDownCapture,S.onPointerDownCapture)})});ln.displayName="DismissableLayer";function cn(){const e=new CustomEvent(rn);document.dispatchEvent(e)}function un(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?en(i,o):i.dispatchEvent(o)}s.forwardRef((e,n)=>{const r=s.useContext(an),i=s.useRef(null),o=bt(n,i);return s.useEffect(()=>{const e=i.current;if(e)return r.branches.add(e),()=>{r.branches.delete(e)}},[r.branches]),t.jsx(Zt.div,{...e,ref:o})}).displayName="DismissableLayerBranch";var hn="focusScope.autoFocusOnMount",fn="focusScope.autoFocusOnUnmount",dn={bubbles:!1,cancelable:!0},pn=s.forwardRef((e,n)=>{const{loop:r=!1,trapped:i=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...l}=e,[c,u]=s.useState(null),h=tn(o),f=tn(a),d=s.useRef(null),p=bt(n,e=>u(e)),m=s.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;s.useEffect(()=>{if(i){let e=function(e){if(m.paused||!c)return;const t=e.target;c.contains(t)?d.current=t:yn(d.current,{select:!0})},t=function(e){if(m.paused||!c)return;const t=e.relatedTarget;null!==t&&(c.contains(t)||yn(d.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(const t of e)t.removedNodes.length>0&&yn(c)};document.addEventListener("focusin",e),document.addEventListener("focusout",t);const r=new MutationObserver(n);return c&&r.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",e),document.removeEventListener("focusout",t),r.disconnect()}}},[i,c,m.paused]),s.useEffect(()=>{if(c){bn.add(m);const t=document.activeElement;if(!c.contains(t)){const n=new CustomEvent(hn,dn);c.addEventListener(hn,h),c.dispatchEvent(n),n.defaultPrevented||(!function(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(yn(r,{select:t}),document.activeElement!==n)return}((e=mn(c),e.filter(e=>"A"!==e.tagName)),{select:!0}),document.activeElement===t&&yn(c))}return()=>{c.removeEventListener(hn,h),setTimeout(()=>{const e=new CustomEvent(fn,dn);c.addEventListener(fn,f),c.dispatchEvent(e),e.defaultPrevented||yn(t??document.body,{select:!0}),c.removeEventListener(fn,f),bn.remove(m)},0)}}var e},[c,h,f,m]);const g=s.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=gn(t,e),r=gn(t.reverse(),e);return[n,r]}(t);i&&o?e.shiftKey||n!==o?e.shiftKey&&n===i&&(e.preventDefault(),r&&yn(o,{select:!0})):(e.preventDefault(),r&&yn(i,{select:!0})):n===t&&e.preventDefault()}},[r,i,m.paused]);return t.jsx(Zt.div,{tabIndex:-1,...l,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 gn(e,t){for(const n of e)if(!vn(n,{upTo:t}))return n}function vn(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 yn(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()}}pn.displayName="FocusScope";var bn=function(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=wn(e,t),e.unshift(t)},remove(t){e=wn(e,t),e[0]?.resume()}}}();function wn(e,t){const n=[...e],r=n.indexOf(t);return-1!==r&&n.splice(r,1),n}var kn=s.forwardRef((e,r)=>{const{container:i,...o}=e,[a,l]=s.useState(!1);Vt(()=>l(!0),[]);const c=i||a&&globalThis?.document?.body;return c?n.createPortal(t.jsx(Zt.div,{...o,ref:r}),c):null});kn.displayName="Portal";var xn=e=>{const{present:t,children:n}=e,r=function(e){const[t,n]=s.useState(),r=s.useRef(null),i=s.useRef(e),o=s.useRef("none"),a=e?"mounted":"unmounted",[l,c]=function(e,t){return s.useReducer((e,n)=>t[e][n]??e,e)}(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return s.useEffect(()=>{const e=Sn(r.current);o.current="mounted"===l?e:"none"},[l]),Vt(()=>{const t=r.current,n=i.current;if(n!==e){const r=o.current,s=Sn(t);if(e)c("MOUNT");else if("none"===s||"none"===t?.display)c("UNMOUNT");else{c(n&&r!==s?"ANIMATION_OUT":"UNMOUNT")}i.current=e}},[e,c]),Vt(()=>{if(t){let e;const n=t.ownerDocument.defaultView??window,s=o=>{const s=Sn(r.current).includes(CSS.escape(o.animationName));if(o.target===t&&s&&(c("ANIMATION_END"),!i.current)){const r=t.style.animationFillMode;t.style.animationFillMode="forwards",e=n.setTimeout(()=>{"forwards"===t.style.animationFillMode&&(t.style.animationFillMode=r)})}},a=e=>{e.target===t&&(o.current=Sn(r.current))};return t.addEventListener("animationstart",a),t.addEventListener("animationcancel",s),t.addEventListener("animationend",s),()=>{n.clearTimeout(e),t.removeEventListener("animationstart",a),t.removeEventListener("animationcancel",s),t.removeEventListener("animationend",s)}}c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:s.useCallback(e=>{r.current=e?getComputedStyle(e):null,n(e)},[])}}(t),i="function"==typeof n?n({present:r.isPresent}):s.Children.only(n),o=bt(r.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}(i));return"function"==typeof n||r.isPresent?s.cloneElement(i,{ref:o}):null};function Sn(e){return e?.animationName||"none"}xn.displayName="Presence";var Cn=0;function En(){s.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??An()),document.body.insertAdjacentElement("beforeend",e[1]??An()),Cn++,()=>{1===Cn&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),Cn--}},[])}function An(){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 Mn="right-scroll-bar-position",On="width-before-scroll-bar";function Nn(e,t){return"function"==typeof e?e(t):e&&(e.current=t),e}var Tn="undefined"!=typeof window?s.useLayoutEffect:s.useEffect,Rn=new WeakMap;function Dn(t,n){var r,i,o,s=(r=n||null,i=function(e){return t.forEach(function(t){return Nn(t,e)})},(o=e.useState(function(){return{value:r,callback:i,facade:{get current(){return o.value},set current(e){var t=o.value;t!==e&&(o.value=e,o.callback(e,t))}}}})[0]).callback=i,o.facade);return Tn(function(){var e=Rn.get(s);if(e){var n=new Set(e),r=new Set(t),i=s.current;n.forEach(function(e){r.has(e)||Nn(e,null)}),r.forEach(function(e){n.has(e)||Nn(e,i)})}Rn.set(s,t)},[t]),s}function Pn(e){return e}var Ln=function(e){var t=e.sideCar,n=H(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return s.createElement(r,W({},n))};Ln.isSideCarExport=!0;var Bn=function(e){void 0===e&&(e={});var t=function(e,t){void 0===t&&(t=Pn);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=W({async:!0,ssr:!1},e),t}(),In=function(){},_n=s.forwardRef(function(e,t){var n=s.useRef(null),r=s.useState({onScrollCapture:In,onWheelCapture:In,onTouchMoveCapture:In}),i=r[0],o=r[1],a=e.forwardProps,l=e.children,c=e.className,u=e.removeScrollBar,h=e.enabled,f=e.shards,d=e.sideCar,p=e.noRelative,m=e.noIsolation,g=e.inert,v=e.allowPinchZoom,y=e.as,b=void 0===y?"div":y,w=e.gapMode,k=H(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),x=d,S=Dn([n,t]),C=W(W({},k),i);return s.createElement(s.Fragment,null,h&&s.createElement(x,{sideCar:Bn,removeScrollBar:u,shards:f,noRelative:p,noIsolation:m,inert:g,setCallbacks:o,allowPinchZoom:!!v,lockRef:n,gapMode:w}),a?s.cloneElement(s.Children.only(l),W(W({},C),{ref:S})):s.createElement(b,W({},C,{className:c,ref:S}),l))});_n.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},_n.classNames={fullWidth:On,zeroRight:Mn};function jn(){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 Fn=function(){var e=0,t=null;return{add:function(n){var r,i;0==e&&(t=jn())&&(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)}}},Wn=function(){var e,t=(e=Fn(),function(t,n){s.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])});return function(e){var n=e.styles,r=e.dynamic;return t(n,r),null}},Hn={left:0,top:0,right:0,gap:0},zn=function(e){return parseInt(e||"",10)||0},Vn=function(e){if(void 0===e&&(e="margin"),"undefined"==typeof window)return Hn;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[zn(n),zn(r),zn(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])}},qn=Wn(),Un="data-scroll-locked",Kn=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(Un,"] {\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(Mn," {\n right: ").concat(a,"px ").concat(r,";\n }\n \n .").concat(On," {\n margin-right: ").concat(a,"px ").concat(r,";\n }\n \n .").concat(Mn," .").concat(Mn," {\n right: 0 ").concat(r,";\n }\n \n .").concat(On," .").concat(On," {\n margin-right: 0 ").concat(r,";\n }\n \n body[").concat(Un,"] {\n ").concat("--removed-body-scroll-bar-size",": ").concat(a,"px;\n }\n")},Gn=function(){var e=parseInt(document.body.getAttribute(Un)||"0",10);return isFinite(e)?e:0},Yn=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=void 0===r?"margin":r;s.useEffect(function(){return document.body.setAttribute(Un,(Gn()+1).toString()),function(){var e=Gn()-1;e<=0?document.body.removeAttribute(Un):document.body.setAttribute(Un,e.toString())}},[]);var o=s.useMemo(function(){return Vn(i)},[i]);return s.createElement(qn,{styles:Kn(o,!t,i,n?"":"!important")})},$n=!1;if("undefined"!=typeof window)try{var Xn=Object.defineProperty({},"passive",{get:function(){return $n=!0,!0}});window.addEventListener("test",Xn,Xn),window.removeEventListener("test",Xn,Xn)}catch(e){$n=!1}var Jn=!!$n&&{passive:!1},Qn=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])},Zn=function(e,t){var n=t.ownerDocument,r=t;do{if("undefined"!=typeof ShadowRoot&&r instanceof ShadowRoot&&(r=r.host),er(e,r)){var i=tr(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},er=function(e,t){return"v"===e?function(e){return Qn(e,"overflowY")}(t):function(e){return Qn(e,"overflowX")}(t)},tr=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)},nr=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},rr=function(e){return[e.deltaX,e.deltaY]},ir=function(e){return e&&"current"in e?e.current:e},or=function(e){return"\n .block-interactivity-".concat(e," {pointer-events: none;}\n .allow-interactivity-").concat(e," {pointer-events: all;}\n")},sr=0,ar=[];function lr(e){for(var t=null;null!==e;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var cr,ur=(cr=function(e){var t=s.useRef([]),n=s.useRef([0,0]),r=s.useRef(),i=s.useState(sr++)[0],o=s.useState(Wn)[0],a=s.useRef(e);s.useEffect(function(){a.current=e},[e]),s.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(i));var t=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))}([e.lockRef.current],(e.shards||[]).map(ir),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),t.forEach(function(e){return e.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var l=s.useCallback(function(e,t){if("touches"in e&&2===e.touches.length||"wheel"===e.type&&e.ctrlKey)return!a.current.allowPinchZoom;var i,o=nr(e),s=n.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=Zn(h,u);if(!p)return!0;if(p?i=h:(i="v"===h?"h":"v",p=Zn(h,u)),!p)return!1;if(!r.current&&"changedTouches"in e&&(l||c)&&(r.current=i),!i)return!0;var m=r.current||i;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=tr(e,a),p=d[0],m=d[1]-d[2]-o*p;(p||m)&&er(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=s.useCallback(function(e){var n=e;if(ar.length&&ar[ar.length-1]===o){var r="deltaY"in n?rr(n):nr(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&(t=e.delta,i=r,t[0]===i[0]&&t[1]===i[1]);var t,i})[0];if(i&&i.should)n.cancelable&&n.preventDefault();else if(!i){var s=(a.current.shards||[]).map(ir).filter(Boolean).filter(function(e){return e.contains(n.target)});(s.length>0?l(n,s[0]):!a.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),u=s.useCallback(function(e,n,r,i){var o={name:e,delta:n,target:r,should:i,shadowParent:lr(r)};t.current.push(o),setTimeout(function(){t.current=t.current.filter(function(e){return e!==o})},1)},[]),h=s.useCallback(function(e){n.current=nr(e),r.current=void 0},[]),f=s.useCallback(function(t){u(t.type,rr(t),t.target,l(t,e.lockRef.current))},[]),d=s.useCallback(function(t){u(t.type,nr(t),t.target,l(t,e.lockRef.current))},[]);s.useEffect(function(){return ar.push(o),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:d}),document.addEventListener("wheel",c,Jn),document.addEventListener("touchmove",c,Jn),document.addEventListener("touchstart",h,Jn),function(){ar=ar.filter(function(e){return e!==o}),document.removeEventListener("wheel",c,Jn),document.removeEventListener("touchmove",c,Jn),document.removeEventListener("touchstart",h,Jn)}},[]);var p=e.removeScrollBar,m=e.inert;return s.createElement(s.Fragment,null,m?s.createElement(o,{styles:or(i)}):null,p?s.createElement(Yn,{noRelative:e.noRelative,gapMode:e.gapMode}):null)},Bn.useMedium(cr),Ln),hr=s.forwardRef(function(e,t){return s.createElement(_n,W({},e,{ref:t,sideCar:ur}))});hr.classNames=_n.classNames;var fr=hr,dr=new WeakMap,pr=new WeakMap,mr={},gr=0,vr=function(e){return e&&(e.host||vr(e.parentNode))},yr=function(e,t,n,r){var i=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=vr(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=(dr.get(e)||0)+1,c=(o.get(e)||0)+1;dr.set(e,l),o.set(e,c),s.push(e),1===l&&i&&pr.set(e,!0),1===c&&e.setAttribute(n,"true"),i||e.setAttribute(r,"true")}catch(e){}})};return u(t),a.clear(),gr++,function(){s.forEach(function(e){var t=dr.get(e)-1,i=o.get(e)-1;dr.set(e,t),o.set(e,i),t||(pr.has(e)||e.removeAttribute(r),pr.delete(e)),i||e.removeAttribute(n)}),--gr||(dr=new WeakMap,dr=new WeakMap,pr=new WeakMap,mr={})}},br=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"))),yr(r,i,n,"aria-hidden")):function(){return null}},wr="Dialog",[kr,xr]=Ht(wr),[Sr,Cr]=kr(wr),Er=e=>{const{__scopeDialog:n,children:r,open:i,defaultOpen:o,onOpenChange:a,modal:l=!0}=e,c=s.useRef(null),u=s.useRef(null),[h,f]=Yt({prop:i,defaultProp:o??!1,onChange:a,caller:wr});return t.jsx(Sr,{scope:n,triggerRef:c,contentRef:u,contentId:Kt(),titleId:Kt(),descriptionId:Kt(),open:h,onOpenChange:f,onOpenToggle:s.useCallback(()=>f(e=>!e),[f]),modal:l,children:r})};Er.displayName=wr;var Ar="DialogTrigger",Mr=s.forwardRef((e,n)=>{const{__scopeDialog:r,...i}=e,o=Cr(Ar,r),s=bt(n,o.triggerRef);return t.jsx(Zt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Gr(o.open),...i,ref:s,onClick:Wt(e.onClick,o.onOpenToggle)})});Mr.displayName=Ar;var Or="DialogPortal",[Nr,Tr]=kr(Or,{forceMount:void 0}),Rr=e=>{const{__scopeDialog:n,forceMount:r,children:i,container:o}=e,a=Cr(Or,n);return t.jsx(Nr,{scope:n,forceMount:r,children:s.Children.map(i,e=>t.jsx(xn,{present:r||a.open,children:t.jsx(kn,{asChild:!0,container:o,children:e})}))})};Rr.displayName=Or;var Dr="DialogOverlay",Pr=s.forwardRef((e,n)=>{const r=Tr(Dr,e.__scopeDialog),{forceMount:i=r.forceMount,...o}=e,s=Cr(Dr,e.__scopeDialog);return s.modal?t.jsx(xn,{present:i||s.open,children:t.jsx(Br,{...o,ref:n})}):null});Pr.displayName=Dr;var Lr=$t("DialogOverlay.RemoveScroll"),Br=s.forwardRef((e,n)=>{const{__scopeDialog:r,...i}=e,o=Cr(Dr,r);return t.jsx(fr,{as:Lr,allowPinchZoom:!0,shards:[o.contentRef],children:t.jsx(Zt.div,{"data-state":Gr(o.open),...i,ref:n,style:{pointerEvents:"auto",...i.style}})})}),Ir="DialogContent",_r=s.forwardRef((e,n)=>{const r=Tr(Ir,e.__scopeDialog),{forceMount:i=r.forceMount,...o}=e,s=Cr(Ir,e.__scopeDialog);return t.jsx(xn,{present:i||s.open,children:s.modal?t.jsx(jr,{...o,ref:n}):t.jsx(Fr,{...o,ref:n})})});_r.displayName=Ir;var jr=s.forwardRef((e,n)=>{const r=Cr(Ir,e.__scopeDialog),i=s.useRef(null),o=bt(n,r.contentRef,i);return s.useEffect(()=>{const e=i.current;if(e)return br(e)},[]),t.jsx(Wr,{...e,ref:o,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Wt(e.onCloseAutoFocus,e=>{e.preventDefault(),r.triggerRef.current?.focus()}),onPointerDownOutside:Wt(e.onPointerDownOutside,e=>{const t=e.detail.originalEvent,n=0===t.button&&!0===t.ctrlKey;(2===t.button||n)&&e.preventDefault()}),onFocusOutside:Wt(e.onFocusOutside,e=>e.preventDefault())})}),Fr=s.forwardRef((e,n)=>{const r=Cr(Ir,e.__scopeDialog),i=s.useRef(!1),o=s.useRef(!1);return t.jsx(Wr,{...e,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(i.current||r.triggerRef.current?.focus(),t.preventDefault()),i.current=!1,o.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(i.current=!0,"pointerdown"===t.detail.originalEvent.type&&(o.current=!0));const n=t.target,s=r.triggerRef.current?.contains(n);s&&t.preventDefault(),"focusin"===t.detail.originalEvent.type&&o.current&&t.preventDefault()}})}),Wr=s.forwardRef((e,n)=>{const{__scopeDialog:r,trapFocus:i,onOpenAutoFocus:o,onCloseAutoFocus:a,...l}=e,c=Cr(Ir,r),u=s.useRef(null),h=bt(n,u);return En(),t.jsxs(t.Fragment,{children:[t.jsx(pn,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:o,onUnmountAutoFocus:a,children:t.jsx(ln,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":Gr(c.open),...l,ref:h,onDismiss:()=>c.onOpenChange(!1)})}),t.jsxs(t.Fragment,{children:[t.jsx(Jr,{titleId:c.titleId}),t.jsx(Qr,{contentRef:u,descriptionId:c.descriptionId})]})]})}),Hr="DialogTitle",zr=s.forwardRef((e,n)=>{const{__scopeDialog:r,...i}=e,o=Cr(Hr,r);return t.jsx(Zt.h2,{id:o.titleId,...i,ref:n})});zr.displayName=Hr;var Vr="DialogDescription",qr=s.forwardRef((e,n)=>{const{__scopeDialog:r,...i}=e,o=Cr(Vr,r);return t.jsx(Zt.p,{id:o.descriptionId,...i,ref:n})});qr.displayName=Vr;var Ur="DialogClose",Kr=s.forwardRef((e,n)=>{const{__scopeDialog:r,...i}=e,o=Cr(Ur,r);return t.jsx(Zt.button,{type:"button",...i,ref:n,onClick:Wt(e.onClick,()=>o.onOpenChange(!1))})});function Gr(e){return e?"open":"closed"}Kr.displayName=Ur;var Yr="DialogTitleWarning",[$r,Xr]=function(e,n){const r=s.createContext(n),i=e=>{const{children:n,...i}=e,o=s.useMemo(()=>i,Object.values(i));return t.jsx(r.Provider,{value:o,children:n})};return i.displayName=e+"Provider",[i,function(t){const i=s.useContext(r);if(i)return i;if(void 0!==n)return n;throw new Error(`\`${t}\` must be used within \`${e}\``)}]}(Yr,{contentName:Ir,titleName:Hr,docsSlug:"dialog"}),Jr=({titleId:e})=>{const t=Xr(Yr),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.\n\nIf you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.\n\nFor more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return s.useEffect(()=>{if(e){document.getElementById(e)}},[n,e]),null},Qr=({contentRef:e,descriptionId:t})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Xr("DialogDescriptionWarning").contentName}}.`;return s.useEffect(()=>{const n=e.current?.getAttribute("aria-describedby");if(t&&n){document.getElementById(t)}},[n,e,t]),null},Zr=Er,ei=Mr,ti=Rr,ni=Pr,ri=_r,ii=zr,oi=qr,si=Kr,ai=Zr,li=ti,ci=s.forwardRef(function(e,t){var n=e.className,r=H(e,["className"]);return s.createElement(ni,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",n)},r,{ref:t}))});ci.displayName=ni.displayName;var ui=Tt("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"}}),hi=s.forwardRef(function(e,t){var n=e.side,r=void 0===n?"right":n,i=e.className,o=e.children,a=H(e,["side","className","children"]);return s.createElement(li,null,s.createElement(ci,null),s.createElement(ri,Object.assign({ref:t,className:mt(ui({side:r}),i)},a),o,s.createElement(si,{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"},s.createElement(we,{className:"h-4 w-4"}),s.createElement("span",{className:"sr-only"},"Close"))))});hi.displayName=ri.displayName;var fi=function(e){var t=e.className,n=H(e,["className"]);return s.createElement("div",Object.assign({className:mt("flex flex-col space-y-2 text-center sm:text-left",t)},n))};fi.displayName="SheetHeader";var di=s.forwardRef(function(e,t){var n=e.className,r=H(e,["className"]);return s.createElement(ii,Object.assign({ref:t,className:mt("text-lg font-semibold text-foreground",n)},r))});di.displayName=ii.displayName;var pi=s.forwardRef(function(e,t){var n=e.className,r=H(e,["className"]);return s.createElement(oi,Object.assign({ref:t,className:mt("text-sm text-muted-foreground",n)},r))});pi.displayName=oi.displayName;const mi=["top","right","bottom","left"],gi=Math.min,vi=Math.max,yi=Math.round,bi=Math.floor,wi=e=>({x:e,y:e}),ki={left:"right",right:"left",bottom:"top",top:"bottom"},xi={start:"end",end:"start"};function Si(e,t,n){return vi(e,gi(t,n))}function Ci(e,t){return"function"==typeof e?e(t):e}function Ei(e){return e.split("-")[0]}function Ai(e){return e.split("-")[1]}function Mi(e){return"x"===e?"y":"x"}function Oi(e){return"y"===e?"height":"width"}const Ni=new Set(["top","bottom"]);function Ti(e){return Ni.has(Ei(e))?"y":"x"}function Ri(e){return Mi(Ti(e))}function Di(e){return e.replace(/start|end/g,e=>xi[e])}const Pi=["left","right"],Li=["right","left"],Bi=["top","bottom"],Ii=["bottom","top"];function _i(e,t,n,r){const i=Ai(e);let o=function(e,t,n){switch(e){case"top":case"bottom":return n?t?Li:Pi:t?Pi:Li;case"left":case"right":return t?Bi:Ii;default:return[]}}(Ei(e),"start"===n,r);return i&&(o=o.map(e=>e+"-"+i),t&&(o=o.concat(o.map(Di)))),o}function ji(e){return e.replace(/left|right|bottom|top/g,e=>ki[e])}function Fi(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 Wi(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 Hi(e,t,n){let{reference:r,floating:i}=e;const o=Ti(t),s=Ri(t),a=Oi(s),l=Ei(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(Ai(t)){case"start":d[s]-=f*(n&&c?-1:1);break;case"end":d[s]+=f*(n&&c?-1:1)}return d}async function zi(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}=Ci(t,e),p=Fi(d),m=a[f?"floating"===h?"reference":"floating":h],g=Wi(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=Wi(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 Vi(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function qi(e){return mi.some(t=>e[t]>=0)}const Ui=new Set(["left","top"]);function Ki(){return"undefined"!=typeof window}function Gi(e){return Xi(e)?(e.nodeName||"").toLowerCase():"#document"}function Yi(e){var t;return(null==e||null==(t=e.ownerDocument)?void 0:t.defaultView)||window}function $i(e){var t;return null==(t=(Xi(e)?e.ownerDocument:e.document)||window.document)?void 0:t.documentElement}function Xi(e){return!!Ki()&&(e instanceof Node||e instanceof Yi(e).Node)}function Ji(e){return!!Ki()&&(e instanceof Element||e instanceof Yi(e).Element)}function Qi(e){return!!Ki()&&(e instanceof HTMLElement||e instanceof Yi(e).HTMLElement)}function Zi(e){return!(!Ki()||"undefined"==typeof ShadowRoot)&&(e instanceof ShadowRoot||e instanceof Yi(e).ShadowRoot)}const eo=new Set(["inline","contents"]);function to(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=po(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!eo.has(i)}const no=new Set(["table","td","th"]);function ro(e){return no.has(Gi(e))}const io=[":popover-open",":modal"];function oo(e){return io.some(t=>{try{return e.matches(t)}catch(e){return!1}})}const so=["transform","translate","scale","rotate","perspective"],ao=["transform","translate","scale","rotate","perspective","filter"],lo=["paint","layout","strict","content"];function co(e){const t=uo(),n=Ji(e)?po(e):e;return so.some(e=>!!n[e]&&"none"!==n[e])||!!n.containerType&&"normal"!==n.containerType||!t&&!!n.backdropFilter&&"none"!==n.backdropFilter||!t&&!!n.filter&&"none"!==n.filter||ao.some(e=>(n.willChange||"").includes(e))||lo.some(e=>(n.contain||"").includes(e))}function uo(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}const ho=new Set(["html","body","#document"]);function fo(e){return ho.has(Gi(e))}function po(e){return Yi(e).getComputedStyle(e)}function mo(e){return Ji(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function go(e){if("html"===Gi(e))return e;const t=e.assignedSlot||e.parentNode||Zi(e)&&e.host||$i(e);return Zi(t)?t.host:t}function vo(e){const t=go(e);return fo(t)?e.ownerDocument?e.ownerDocument.body:e.body:Qi(t)&&to(t)?t:vo(t)}function yo(e,t,n){var r;void 0===t&&(t=[]),void 0===n&&(n=!0);const i=vo(e),o=i===(null==(r=e.ownerDocument)?void 0:r.body),s=Yi(i);if(o){const e=bo(s);return t.concat(s,s.visualViewport||[],to(i)?i:[],e&&n?yo(e):[])}return t.concat(i,yo(i,[],n))}function bo(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function wo(e){const t=po(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=Qi(e),o=i?e.offsetWidth:n,s=i?e.offsetHeight:r,a=yi(n)!==o||yi(r)!==s;return a&&(n=o,r=s),{width:n,height:r,$:a}}function ko(e){return Ji(e)?e:e.contextElement}function xo(e){const t=ko(e);if(!Qi(t))return wi(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:o}=wo(t);let s=(o?yi(n.width):n.width)/r,a=(o?yi(n.height):n.height)/i;return s&&Number.isFinite(s)||(s=1),a&&Number.isFinite(a)||(a=1),{x:s,y:a}}const So=wi(0);function Co(e){const t=Yi(e);return uo()&&t.visualViewport?{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}:So}function Eo(e,t,n,r){void 0===t&&(t=!1),void 0===n&&(n=!1);const i=e.getBoundingClientRect(),o=ko(e);let s=wi(1);t&&(r?Ji(r)&&(s=xo(r)):s=xo(e));const a=function(e,t,n){return void 0===t&&(t=!1),!(!n||t&&n!==Yi(e))&&t}(o,n,r)?Co(o):wi(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=Yi(o),t=r&&Ji(r)?Yi(r):r;let n=e,i=bo(n);for(;i&&r&&t!==n;){const e=xo(i),t=i.getBoundingClientRect(),r=po(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=Yi(i),i=bo(n)}}return Wi({width:u,height:h,x:l,y:c})}function Ao(e,t){const n=mo(e).scrollLeft;return t?t.left+n:Eo($i(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 Oo=new Set(["absolute","fixed"]);function No(e,t,n){let r;if("viewport"===t)r=function(e,t){const n=Yi(e),r=$i(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=uo();(!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=$i(e),n=mo(e),r=e.ownerDocument.body,i=vi(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),o=vi(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let s=-n.scrollLeft+Ao(e);const a=-n.scrollTop;return"rtl"===po(r).direction&&(s+=vi(t.clientWidth,r.clientWidth)-i),{width:i,height:o,x:s,y:a}}($i(e));else if(Ji(t))r=function(e,t){const n=Eo(e,!0,"fixed"===t),r=n.top+e.clientTop,i=n.left+e.clientLeft,o=Qi(e)?xo(e):wi(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=Co(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return Wi(r)}function To(e,t){const n=go(e);return!(n===t||!Ji(n)||fo(n))&&("fixed"===po(n).position||To(n,t))}function Ro(e,t,n){const r=Qi(t),i=$i(t),o="fixed"===n,s=Eo(e,!0,o,t);let a={scrollLeft:0,scrollTop:0};const l=wi(0);function c(){l.x=Ao(i)}if(r||!r&&!o)if(("body"!==Gi(t)||to(i))&&(a=mo(t)),r){const e=Eo(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?wi(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 Do(e){return"static"===po(e).position}function Po(e,t){if(!Qi(e)||"fixed"===po(e).position)return null;if(t)return t(e);let n=e.offsetParent;return $i(e)===n&&(n=n.ownerDocument.body),n}function Lo(e,t){const n=Yi(e);if(oo(e))return n;if(!Qi(e)){let t=go(e);for(;t&&!fo(t);){if(Ji(t)&&!Do(t))return t;t=go(t)}return n}let r=Po(e,t);for(;r&&ro(r)&&Do(r);)r=Po(r,t);return r&&fo(r)&&Do(r)&&!co(r)?n:r||function(e){let t=go(e);for(;Qi(t)&&!fo(t);){if(co(t))return t;if(oo(t))return null;t=go(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=$i(r),a=!!t&&oo(t.floating);if(r===s||a&&o)return n;let l={scrollLeft:0,scrollTop:0},c=wi(1);const u=wi(0),h=Qi(r);if((h||!h&&!o)&&(("body"!==Gi(r)||to(s))&&(l=mo(r)),Qi(r))){const e=Eo(r);c=xo(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}const f=!s||h||o?wi(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+f.x,y:n.y*c.y-l.scrollTop*c.y+u.y+f.y}},getDocumentElement:$i,getClippingRect:function(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const o=[..."clippingAncestors"===n?oo(t)?[]:function(e,t){const n=t.get(e);if(n)return n;let r=yo(e,[],!1).filter(e=>Ji(e)&&"body"!==Gi(e)),i=null;const o="fixed"===po(e).position;let s=o?go(e):e;for(;Ji(s)&&!fo(s);){const t=po(s),n=co(s);n||"fixed"!==t.position||(i=null),(o?!n&&!i:!n&&"static"===t.position&&i&&Oo.has(i.position)||to(s)&&!n&&To(e,s))?r=r.filter(e=>e!==s):i=t,s=go(s)}return t.set(e,r),r}(t,this._c):[].concat(n),r],s=o[0],a=o.reduce((e,n)=>{const r=No(t,n,i);return e.top=vi(r.top,e.top),e.right=gi(r.right,e.right),e.bottom=gi(r.bottom,e.bottom),e.left=vi(r.left,e.left),e},No(t,s,i));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}},getOffsetParent:Lo,getElementRects:async function(e){const t=this.getOffsetParent||Lo,n=this.getDimensions,r=await n(e.floating);return{reference:Ro(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}=wo(e);return{width:t,height:n}},getScale:xo,isElement:Ji,isRTL:function(e){return"rtl"===po(e).direction}};function Io(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=ko(e),u=i||o?[...c?yo(c):[],...yo(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=$i(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:-bi(h)+"px "+-bi(i.clientWidth-(u+f))+"px "+-bi(i.clientHeight-(h+d))+"px "+-bi(u)+"px",threshold:vi(0,gi(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||Io(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?Eo(e):null;return l&&function t(){const r=Eo(e);m&&!Io(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 jo=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=Ei(n),a=Ai(n),l="y"===Ti(n),c=Ui.has(s)?-1:1,u=o&&l?-1:1,h=Ci(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}}}}},Fo=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}=Ci(e,t),c={x:n,y:r},u=await zi(t,l),h=Ti(Ei(i)),f=Mi(h);let d=c[f],p=c[h];if(o){const e="y"===f?"bottom":"right";d=Si(d+u["y"===f?"top":"left"],d,d-u[e])}if(s){const e="y"===h?"bottom":"right";p=Si(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}}}}}},Wo=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}=Ci(e,t);if(null!=(n=o.arrow)&&n.alignmentOffset)return{};const v=Ei(i),y=Ti(a),b=Ei(a)===a,w=await(null==l.isRTL?void 0:l.isRTL(c.floating)),k=f||(b||!m?[ji(a)]:function(e){const t=ji(e);return[Di(e),t,Di(t)]}(a)),x="none"!==p;!f&&x&&k.push(..._i(a,m,p,w));const S=[a,...k],C=await zi(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=Ai(e),i=Ri(e),o=Oi(i);let s="x"===i?r===(n?"end":"start")?"right":"left":"start"===r?"bottom":"top";return t.reference[o]>t.floating[o]&&(s=ji(s)),[s,ji(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!==Ti(t))||A.every(e=>Ti(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=Ti(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{}}}},Ho=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}=Ci(e,t),u=await zi(t,c),h=Ei(i),f=Ai(i),d="y"===Ti(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=gi(m-u[g],y),k=gi(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=vi(u.left,0),t=vi(u.right,0),n=vi(u.top,0),r=vi(u.bottom,0);d?C=p-2*(0!==e||0!==t?e+t:vi(u.left,u.right)):S=m-2*(0!==n||0!==r?n+r:vi(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}}:{}}}},zo=function(e){return void 0===e&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...i}=Ci(e,t);switch(r){case"referenceHidden":{const e=Vi(await zi(t,{...i,elementContext:"reference"}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:qi(e)}}}case"escaped":{const e=Vi(await zi(t,{...i,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:qi(e)}}}default:return{}}}}},Vo=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}=Ci(e,t)||{};if(null==c)return{};const h=Fi(u),f={x:n,y:r},d=Ri(i),p=Oi(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=gi(h[v],E),M=gi(h[y],E),O=A,N=S-m[p]-M,T=S/2-m[p]/2+C,R=Si(O,T,N),D=!l.arrow&&null!=Ai(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}}}),qo=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}=Ci(e,t),u={x:n,y:r},h=Ti(i),f=Mi(h);let d=u[f],p=u[h];const m=Ci(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=Ui.has(Ei(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}}}},Uo=(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}=Hi(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}=Hi(c,f,l))),n=-1)}return{x:u,y:h,placement:f,strategy:i,middlewareData:d}})(e,t,{...i,platform:o})};var Ko="undefined"!=typeof document?e.useLayoutEffect: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 Yo(e){if("undefined"==typeof window)return 1;return(e.ownerDocument.defaultView||window).devicePixelRatio||1}function $o(e,t){const n=Yo(e);return Math.round(t*n)/n}function Xo(e){const t=s.useRef(e);return Ko(()=>{t.current=e}),t}const Jo=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?Vo({element:n.current,padding:r}).fn(t):{}:n?Vo({element:n,padding:r}).fn(t):{};var i}}),Qo=(e,t)=>({...jo(e),options:[e,t]}),Zo=(e,t)=>({...Fo(e),options:[e,t]}),es=(e,t)=>({...qo(e),options:[e,t]}),ts=(e,t)=>({...Wo(e),options:[e,t]}),ns=(e,t)=>({...Ho(e),options:[e,t]}),rs=(e,t)=>({...zo(e),options:[e,t]}),is=(e,t)=>({...Jo(e),options:[e,t]});var os=s.forwardRef((e,n)=>{const{children:r,width:i=10,height:o=5,...s}=e;return t.jsx(Zt.svg,{...s,ref:n,width:i,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?r:t.jsx("polygon",{points:"0,0 30,0 15,10"})})});os.displayName="Arrow";var ss=os;function as(e){const[t,n]=s.useState(void 0);return Vt(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const t=new ResizeObserver(t=>{if(!Array.isArray(t))return;if(!t.length)return;const r=t[0];let i,o;if("borderBoxSize"in r){const e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,o=t.blockSize}else i=e.offsetWidth,o=e.offsetHeight;n({width:i,height:o})});return t.observe(e,{box:"border-box"}),()=>t.unobserve(e)}n(void 0)},[e]),t}var ls="Popper",[cs,us]=Ht(ls),[hs,fs]=cs(ls),ds=e=>{const{__scopePopper:n,children:r}=e,[i,o]=s.useState(null);return t.jsx(hs,{scope:n,anchor:i,onAnchorChange:o,children:r})};ds.displayName=ls;var ps="PopperAnchor",ms=s.forwardRef((e,n)=>{const{__scopePopper:r,virtualRef:i,...o}=e,a=fs(ps,r),l=s.useRef(null),c=bt(n,l),u=s.useRef(null);return s.useEffect(()=>{const e=u.current;u.current=i?.current||l.current,e!==u.current&&a.onAnchorChange(u.current)}),i?null:t.jsx(Zt.div,{...o,ref:c})});ms.displayName=ps;var gs="PopperContent",[vs,ys]=cs(gs),bs=s.forwardRef((e,n)=>{const{__scopePopper:r,side:i="bottom",sideOffset:o=0,align:l="center",alignOffset:c=0,arrowPadding:u=0,avoidCollisions:h=!0,collisionBoundary:f=[],collisionPadding:d=0,sticky:p="partial",hideWhenDetached:m=!1,updatePositionStrategy:g="optimized",onPlaced:v,...y}=e,b=fs(gs,r),[w,k]=s.useState(null),x=bt(n,e=>k(e)),[S,C]=s.useState(null),E=as(S),A=E?.width??0,M=E?.height??0,O=i+("center"!==l?"-"+l:""),N="number"==typeof d?d:{top:0,right:0,bottom:0,left:0,...d},T=Array.isArray(f)?f:[f],R=T.length>0,D={padding:N,boundary:T.filter(Ss),altBoundary:R},{refs:P,floatingStyles:L,placement:B,isPositioned:I,middlewareData:_}=function(e){void 0===e&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:o,floating:l}={},transform:c=!0,whileElementsMounted:u,open:h}=e,[f,d]=s.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,m]=s.useState(r);Go(p,r)||m(r);const[g,v]=s.useState(null),[y,b]=s.useState(null),w=s.useCallback(e=>{e!==C.current&&(C.current=e,v(e))},[]),k=s.useCallback(e=>{e!==E.current&&(E.current=e,b(e))},[]),x=o||g,S=l||y,C=s.useRef(null),E=s.useRef(null),A=s.useRef(f),M=null!=u,O=Xo(u),N=Xo(i),T=Xo(h),R=s.useCallback(()=>{if(!C.current||!E.current)return;const e={placement:t,strategy:n,middleware:p};N.current&&(e.platform=N.current),Uo(C.current,E.current,e).then(e=>{const t={...e,isPositioned:!1!==T.current};D.current&&!Go(A.current,t)&&(A.current=t,a.flushSync(()=>{d(t)}))})},[p,t,n,N,T]);Ko(()=>{!1===h&&A.current.isPositioned&&(A.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[h]);const D=s.useRef(!1);Ko(()=>(D.current=!0,()=>{D.current=!1}),[]),Ko(()=>{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=s.useMemo(()=>({reference:C,floating:E,setReference:w,setFloating:k}),[w,k]),L=s.useMemo(()=>({reference:x,floating:S}),[x,S]),B=s.useMemo(()=>{const e={position:n,left:0,top:0};if(!L.floating)return e;const t=$o(L.floating,f.x),r=$o(L.floating,f.y);return c?{...e,transform:"translate("+t+"px, "+r+"px)",...Yo(L.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:t,top:r}},[n,c,L.floating,f.x,f.y]);return s.useMemo(()=>({...f,update:R,refs:P,elements:L,floatingStyles:B}),[f,R,P,L,B])}({strategy:"fixed",placement:O,whileElementsMounted:(...e)=>_o(...e,{animationFrame:"always"===g}),elements:{reference:b.anchor},middleware:[Qo({mainAxis:o+M,alignmentAxis:c}),h&&Zo({mainAxis:!0,crossAxis:!1,limiter:"partial"===p?es():void 0,...D}),h&&ts({...D}),ns({...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&&is({element:S,padding:u}),Cs({arrowWidth:A,arrowHeight:M}),m&&rs({strategy:"referenceHidden",...D})]}),[j,F]=Es(B),W=tn(v);Vt(()=>{I&&W?.()},[I,W]);const H=_.arrow?.x,z=_.arrow?.y,V=0!==_.arrow?.centerOffset,[q,U]=s.useState();return Vt(()=>{w&&U(window.getComputedStyle(w).zIndex)},[w]),t.jsx("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:e.dir,children:t.jsx(vs,{scope:r,placedSide:j,onArrowChange:C,arrowX:H,arrowY:z,shouldHideArrow:V,children:t.jsx(Zt.div,{"data-side":j,"data-align":F,...y,ref:x,style:{...y.style,animation:I?void 0:"none"}})})})});bs.displayName=gs;var ws="PopperArrow",ks={top:"bottom",right:"left",bottom:"top",left:"right"},xs=s.forwardRef(function(e,n){const{__scopePopper:r,...i}=e,o=ys(ws,r),s=ks[o.placedSide];return t.jsx("span",{ref:o.onArrowChange,style:{position:"absolute",left:o.arrowX,top:o.arrowY,[s]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[o.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[o.placedSide],visibility:o.shouldHideArrow?"hidden":void 0},children:t.jsx(ss,{...i,ref:n,style:{...i.style,display:"block"}})})});function Ss(e){return null!==e}xs.displayName=ws;var Cs=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]=Es(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 Es(e){const[t,n="center"]=e.split("-");return[t,n]}var As=ds,Ms=ms,Os=bs,Ns=xs,Ts=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"}),Rs=s.forwardRef((e,n)=>t.jsx(Zt.span,{...e,ref:n,style:{...Ts,...e.style}}));Rs.displayName="VisuallyHidden";var Ds=Rs,[Ps,Ls]=Ht("Tooltip",[us]),Bs=us(),Is="TooltipProvider",_s=700,js="tooltip.open",[Fs,Ws]=Ps(Is),Hs=e=>{const{__scopeTooltip:n,delayDuration:r=_s,skipDelayDuration:i=300,disableHoverableContent:o=!1,children:a}=e,l=s.useRef(!0),c=s.useRef(!1),u=s.useRef(0);return s.useEffect(()=>{const e=u.current;return()=>window.clearTimeout(e)},[]),t.jsx(Fs,{scope:n,isOpenDelayedRef:l,delayDuration:r,onOpen:s.useCallback(()=>{window.clearTimeout(u.current),l.current=!1},[]),onClose:s.useCallback(()=>{window.clearTimeout(u.current),u.current=window.setTimeout(()=>l.current=!0,i)},[i]),isPointerInTransitRef:c,onPointerInTransitChange:s.useCallback(e=>{c.current=e},[]),disableHoverableContent:o,children:a})};Hs.displayName=Is;var zs="Tooltip",[Vs,qs]=Ps(zs),Us=e=>{const{__scopeTooltip:n,children:r,open:i,defaultOpen:o,onOpenChange:a,disableHoverableContent:l,delayDuration:c}=e,u=Ws(zs,e.__scopeTooltip),h=Bs(n),[f,d]=s.useState(null),p=Kt(),m=s.useRef(0),g=l??u.disableHoverableContent,v=c??u.delayDuration,y=s.useRef(!1),[b,w]=Yt({prop:i,defaultProp:o??!1,onChange:e=>{e?(u.onOpen(),document.dispatchEvent(new CustomEvent(js))):u.onClose(),a?.(e)},caller:zs}),k=s.useMemo(()=>b?y.current?"delayed-open":"instant-open":"closed",[b]),x=s.useCallback(()=>{window.clearTimeout(m.current),m.current=0,y.current=!1,w(!0)},[w]),S=s.useCallback(()=>{window.clearTimeout(m.current),m.current=0,w(!1)},[w]),C=s.useCallback(()=>{window.clearTimeout(m.current),m.current=window.setTimeout(()=>{y.current=!0,w(!0),m.current=0},v)},[v,w]);return s.useEffect(()=>()=>{m.current&&(window.clearTimeout(m.current),m.current=0)},[]),t.jsx(As,{...h,children:t.jsx(Vs,{scope:n,contentId:p,open:b,stateAttribute:k,trigger:f,onTriggerChange:d,onTriggerEnter:s.useCallback(()=>{u.isOpenDelayedRef.current?C():x()},[u.isOpenDelayedRef,C,x]),onTriggerLeave:s.useCallback(()=>{g?S():(window.clearTimeout(m.current),m.current=0)},[S,g]),onOpen:x,onClose:S,disableHoverableContent:g,children:r})})};Us.displayName=zs;var Ks="TooltipTrigger",Gs=s.forwardRef((e,n)=>{const{__scopeTooltip:r,...i}=e,o=qs(Ks,r),a=Ws(Ks,r),l=Bs(r),c=bt(n,s.useRef(null),o.onTriggerChange),u=s.useRef(!1),h=s.useRef(!1),f=s.useCallback(()=>u.current=!1,[]);return s.useEffect(()=>()=>document.removeEventListener("pointerup",f),[f]),t.jsx(Ms,{asChild:!0,...l,children:t.jsx(Zt.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...i,ref:c,onPointerMove:Wt(e.onPointerMove,e=>{"touch"!==e.pointerType&&(h.current||a.isPointerInTransitRef.current||(o.onTriggerEnter(),h.current=!0))}),onPointerLeave:Wt(e.onPointerLeave,()=>{o.onTriggerLeave(),h.current=!1}),onPointerDown:Wt(e.onPointerDown,()=>{o.open&&o.onClose(),u.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:Wt(e.onFocus,()=>{u.current||o.onOpen()}),onBlur:Wt(e.onBlur,o.onClose),onClick:Wt(e.onClick,o.onClose)})})});Gs.displayName=Ks;var[Ys,$s]=Ps("TooltipPortal",{forceMount:void 0}),Xs="TooltipContent",Js=s.forwardRef((e,n)=>{const r=$s(Xs,e.__scopeTooltip),{forceMount:i=r.forceMount,side:o="top",...s}=e,a=qs(Xs,e.__scopeTooltip);return t.jsx(xn,{present:i||a.open,children:a.disableHoverableContent?t.jsx(na,{side:o,...s,ref:n}):t.jsx(Qs,{side:o,...s,ref:n})})}),Qs=s.forwardRef((e,n)=>{const r=qs(Xs,e.__scopeTooltip),i=Ws(Xs,e.__scopeTooltip),o=s.useRef(null),a=bt(n,o),[l,c]=s.useState(null),{trigger:u,onClose:h}=r,f=o.current,{onPointerInTransitChange:d}=i,p=s.useCallback(()=>{c(null),d(!1)},[d]),m=s.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]);c(a),d(!0)},[d]);return s.useEffect(()=>()=>p(),[p]),s.useEffect(()=>{if(u&&f){const e=e=>m(e,f),t=e=>m(e,u);return u.addEventListener("pointerleave",e),f.addEventListener("pointerleave",t),()=>{u.removeEventListener("pointerleave",e),f.removeEventListener("pointerleave",t)}}},[u,f,m,p]),s.useEffect(()=>{if(l){const e=e=>{const t=e.target,n={x:e.clientX,y:e.clientY},r=u?.contains(t)||f?.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,l);r?p():i&&(p(),h())};return document.addEventListener("pointermove",e),()=>document.removeEventListener("pointermove",e)}},[u,f,l,h,p]),t.jsx(na,{...e,ref:a})}),[Zs,ea]=Ps(zs,{isInside:!1}),ta=function(e){const n=({children:e})=>t.jsx(t.Fragment,{children:e});return n.displayName=`${e}.Slottable`,n.__radixId=Jt,n}("TooltipContent"),na=s.forwardRef((e,n)=>{const{__scopeTooltip:r,children:i,"aria-label":o,onEscapeKeyDown:a,onPointerDownOutside:l,...c}=e,u=qs(Xs,r),h=Bs(r),{onClose:f}=u;return s.useEffect(()=>(document.addEventListener(js,f),()=>document.removeEventListener(js,f)),[f]),s.useEffect(()=>{if(u.trigger){const e=e=>{const t=e.target;t?.contains(u.trigger)&&f()};return window.addEventListener("scroll",e,{capture:!0}),()=>window.removeEventListener("scroll",e,{capture:!0})}},[u.trigger,f]),t.jsx(ln,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:e=>e.preventDefault(),onDismiss:f,children:t.jsxs(Os,{"data-state":u.stateAttribute,...h,...c,ref:n,style:{...c.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:[t.jsx(ta,{children:i}),t.jsx(Zs,{scope:r,isInside:!0,children:t.jsx(Ds,{id:u.contentId,role:"tooltip",children:o||i})})]})})});Js.displayName=Xs;var ra="TooltipArrow";s.forwardRef((e,n)=>{const{__scopeTooltip:r,...i}=e,o=Bs(r);return ea(ra,r).isInside?null:t.jsx(Ns,{...o,...i,ref:n})}).displayName=ra;var ia=Js,oa=Hs,sa=Us,aa=Gs,la=s.forwardRef(function(e,t){var n=e.className,r=e.sideOffset,i=void 0===r?4:r,o=H(e,["className","sideOffset"]);return s.createElement(ia,Object.assign({ref:t,sideOffset:i,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]",n)},o))});la.displayName=ia.displayName;var ca=s.createContext(null);function ua(){var e=s.useContext(ca);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}function ha(e){var t=e.defaultOpen,n=void 0===t||t,r=e.open,i=e.onOpenChange,o=e.className,a=e.style,l=e.children,c=H(e,["defaultOpen","open","onOpenChange","className","style","children"]),u=function(){var e=D(s.useState(void 0),2),t=e[0],n=e[1];return s.useEffect(function(){var e=window.matchMedia("(max-width: ".concat(767,"px)")),t=function(){n(window.innerWidth<768)};return e.addEventListener("change",t),n(window.innerWidth<768),function(){return e.removeEventListener("change",t)}},[]),!!t}(),h=D(s.useState(!1),2),f=h[0],d=h[1],p=D(s.useState(n),2),m=p[0],g=p[1],v=null!=r?r:m,y=s.useCallback(function(e){var t="function"==typeof e?e(v):e;i?i(t):g(t),document.cookie="".concat("sidebar_state","=").concat(t,"; path=/; max-age=").concat(604800)},[i,v]),b=s.useCallback(function(){return u?d(function(e){return!e}):y(function(e){return!e})},[u,y,d]);s.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=s.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 s.createElement(ca.Provider,{value:k},s.createElement(oa,{delayDuration:0},s.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",o)},c),l)))}function fa(e){var t=e.side,n=void 0===t?"left":t,r=e.variant,i=void 0===r?"sidebar":r,o=e.collapsible,a=void 0===o?"offcanvas":o,l=e.className,c=e.children,u=H(e,["side","variant","collapsible","className","children"]),h=ua(),f=h.isMobile,d=h.state,p=h.openMobile,m=h.setOpenMobile;return"none"===a?s.createElement("div",Object.assign({className:mt("bg-sidebar text-sidebar-foreground flex h-full w-[var(--sidebar-width)] flex-col",l)},u),c):f?s.createElement(ai,Object.assign({open:p,onOpenChange:m},u),s.createElement(hi,{className:"bg-sidebar text-sidebar-foreground w-[var(--sidebar-width)] p-0 [&>button]:hidden",style:{"--sidebar-width":"18rem"},side:n},s.createElement(fi,{className:"sr-only"},s.createElement(di,null,"Sidebar"),s.createElement(pi,null,"Displays the mobile sidebar.")),s.createElement("div",{className:"flex h-full w-full flex-col"},c))):s.createElement("div",{className:"group peer text-sidebar-foreground hidden md:block","data-state":d,"data-collapsible":"collapsed"===d?a:"","data-variant":i,"data-side":n},s.createElement("div",{className:mt("relative w-[var(--sidebar-width)] bg-transparent transition-[width] duration-200 ease-linear","group-data-[collapsible=offcanvas]:w-0","floating"===i||"inset"===i?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+1rem)]":"group-data-[collapsible=icon]:w-[var(--sidebar-width-icon)]")}),s.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"===n?"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"===i||"inset"===i?"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),s.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 da(e){var t=e.className,n=e.onClick,r=H(e,["className","onClick"]),i=ua().toggleSidebar;return s.createElement(Dt,Object.assign({variant:"ghost",size:"icon",className:mt("h-7 w-7",t),onClick:function(e){null==n||n(e),i()}},r),s.createElement(he,null),s.createElement("span",{className:"sr-only"},"Toggle Sidebar"))}function pa(e){var t=e.className,n=H(e,["className"]);return s.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",t)},n))}function ma(e){var t=e.className,n=H(e,["className"]);return s.createElement("div",Object.assign({className:mt("flex flex-col gap-2 p-2",t)},n))}function ga(e){var t=e.className,n=H(e,["className"]);return s.createElement("div",Object.assign({className:mt("flex flex-col gap-2 p-2",t)},n))}function va(e){var t=e.className,n=H(e,["className"]);return s.createElement("div",Object.assign({className:mt("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",t)},n))}function ya(e){var t=e.className,n=H(e,["className"]);return s.createElement("div",Object.assign({className:mt("relative flex w-full min-w-0 flex-col p-2",t)},n))}function ba(e){var t=e.className,n=e.asChild,r=void 0!==n&&n,i=H(e,["className","asChild"]),o=r?Ct:"div";return s.createElement(o,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",t)},i))}function wa(e){var t=e.className,n=H(e,["className"]);return s.createElement("div",Object.assign({className:mt("w-full text-sm",t)},n))}function ka(e){var t=e.className,n=H(e,["className"]);return s.createElement("ul",Object.assign({className:mt("flex w-full min-w-0 flex-col gap-1",t)},n))}function xa(e){var t=e.className,n=H(e,["className"]);return s.createElement("li",Object.assign({className:mt("group/menu-item relative",t)},n))}var Sa=Tt("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 Ca(e){var t=e.asChild,n=void 0!==t&&t,r=e.isActive,i=void 0!==r&&r,o=e.variant,a=void 0===o?"default":o,l=e.size,c=void 0===l?"default":l,u=e.tooltip,h=e.className,f=H(e,["asChild","isActive","variant","size","tooltip","className"]),d=n?Ct:"button",p=ua(),m=p.isMobile,g=p.state,v=s.createElement(d,Object.assign({"data-size":c,"data-active":i,className:mt(Sa({variant:a,size:c}),h)},f));return u?("string"==typeof u&&(u={children:u}),s.createElement(sa,null,s.createElement(aa,{asChild:!0},v),s.createElement(la,Object.assign({side:"right",align:"center",hidden:"collapsed"!==g||m},u)))):v}function Ea(n){const r=n+"CollectionProvider",[i,o]=Ht(r),[s,a]=i(r,{collectionRef:{current:null},itemMap:new Map}),l=n=>{const{scope:r,children:i}=n,o=e.useRef(null),a=e.useRef(new Map).current;return t.jsx(s,{scope:r,itemMap:a,collectionRef:o,children:i})};l.displayName=r;const c=n+"CollectionSlot",u=$t(c),h=e.forwardRef((e,n)=>{const{scope:r,children:i}=e,o=bt(n,a(c,r).collectionRef);return t.jsx(u,{ref:o,children:i})});h.displayName=c;const f=n+"CollectionItemSlot",d="data-radix-collection-item",p=$t(f),m=e.forwardRef((n,r)=>{const{scope:i,children:o,...s}=n,l=e.useRef(null),c=bt(r,l),u=a(f,i);return e.useEffect(()=>(u.itemMap.set(l,{ref:l,...s}),()=>{u.itemMap.delete(l)})),t.jsx(p,{[d]:"",ref:c,children:o})});return m.displayName=f,[{Provider:l,Slot:h,ItemSlot:m},function(t){const r=a(n+"CollectionConsumer",t);return e.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])},o]}var Aa=s.createContext(void 0);function Ma(e){const t=s.useContext(Aa);return e||t||"ltr"}var Oa="rovingFocusGroup.onEntryFocus",Na={bubbles:!1,cancelable:!0},Ta="RovingFocusGroup",[Ra,Da,Pa]=Ea(Ta),[La,Ba]=Ht(Ta,[Pa]),[Ia,_a]=La(Ta),ja=s.forwardRef((e,n)=>t.jsx(Ra.Provider,{scope:e.__scopeRovingFocusGroup,children:t.jsx(Ra.Slot,{scope:e.__scopeRovingFocusGroup,children:t.jsx(Fa,{...e,ref:n})})}));ja.displayName=Ta;var Fa=s.forwardRef((e,n)=>{const{__scopeRovingFocusGroup:r,orientation:i,loop:o=!1,dir:a,currentTabStopId:l,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:u,onEntryFocus:h,preventScrollOnEntryFocus:f=!1,...d}=e,p=s.useRef(null),m=bt(n,p),g=Ma(a),[v,y]=Yt({prop:l,defaultProp:c??null,onChange:u,caller:Ta}),[b,w]=s.useState(!1),k=tn(h),x=Da(r),S=s.useRef(!1),[C,E]=s.useState(0);return s.useEffect(()=>{const e=p.current;if(e)return e.addEventListener(Oa,k),()=>e.removeEventListener(Oa,k)},[k]),t.jsx(Ia,{scope:r,orientation:i,dir:g,loop:o,currentTabStopId:v,onItemFocus:s.useCallback(e=>y(e),[y]),onItemShiftTab:s.useCallback(()=>w(!0),[]),onFocusableItemAdd:s.useCallback(()=>E(e=>e+1),[]),onFocusableItemRemove:s.useCallback(()=>E(e=>e-1),[]),children:t.jsx(Zt.div,{tabIndex:b||0===C?-1:0,"data-orientation":i,...d,ref:m,style:{outline:"none",...e.style},onMouseDown:Wt(e.onMouseDown,()=>{S.current=!0}),onFocus:Wt(e.onFocus,e=>{const t=!S.current;if(e.target===e.currentTarget&&t&&!b){const t=new CustomEvent(Oa,Na);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){const e=x().filter(e=>e.focusable);Va([e.find(e=>e.active),e.find(e=>e.id===v),...e].filter(Boolean).map(e=>e.ref.current),f)}}S.current=!1}),onBlur:Wt(e.onBlur,()=>w(!1))})})}),Wa="RovingFocusGroupItem",Ha=s.forwardRef((e,n)=>{const{__scopeRovingFocusGroup:r,focusable:i=!0,active:o=!1,tabStopId:a,children:l,...c}=e,u=Kt(),h=a||u,f=_a(Wa,r),d=f.currentTabStopId===h,p=Da(r),{onFocusableItemAdd:m,onFocusableItemRemove:g,currentTabStopId:v}=f;return s.useEffect(()=>{if(i)return m(),()=>g()},[i,m,g]),t.jsx(Ra.ItemSlot,{scope:r,id:h,focusable:i,active:o,children:t.jsx(Zt.span,{tabIndex:d?0:-1,"data-orientation":f.orientation,...c,ref:n,onMouseDown:Wt(e.onMouseDown,e=>{i?f.onItemFocus(h):e.preventDefault()}),onFocus:Wt(e.onFocus,()=>f.onItemFocus(h)),onKeyDown:Wt(e.onKeyDown,e=>{if("Tab"===e.key&&e.shiftKey)return void f.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:za[r]}(e,f.orientation,f.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=f.loop?(r=o+1,(n=i).map((e,t)=>n[(r+t)%n.length])):i.slice(o+1)}setTimeout(()=>Va(i))}var n,r}),children:"function"==typeof l?l({isCurrentTabStop:d,hasTabStop:null!=v}):l})})});Ha.displayName=Wa;var za={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Va(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 qa=ja,Ua=Ha,Ka=["Enter"," "],Ga=["ArrowUp","PageDown","End"],Ya=["ArrowDown","PageUp","Home",...Ga],$a={ltr:[...Ka,"ArrowRight"],rtl:[...Ka,"ArrowLeft"]},Xa={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Ja="Menu",[Qa,Za,el]=Ea(Ja),[tl,nl]=Ht(Ja,[el,us,Ba]),rl=us(),il=Ba(),[ol,sl]=tl(Ja),[al,ll]=tl(Ja),cl=e=>{const{__scopeMenu:n,open:r=!1,children:i,dir:o,onOpenChange:a,modal:l=!0}=e,c=rl(n),[u,h]=s.useState(null),f=s.useRef(!1),d=tn(a),p=Ma(o);return s.useEffect(()=>{const e=()=>{f.current=!0,document.addEventListener("pointerdown",t,{capture:!0,once:!0}),document.addEventListener("pointermove",t,{capture:!0,once:!0})},t=()=>f.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})}},[]),t.jsx(As,{...c,children:t.jsx(ol,{scope:n,open:r,onOpenChange:d,content:u,onContentChange:h,children:t.jsx(al,{scope:n,onClose:s.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:f,dir:p,modal:l,children:i})})})};cl.displayName=Ja;var ul=s.forwardRef((e,n)=>{const{__scopeMenu:r,...i}=e,o=rl(r);return t.jsx(Ms,{...o,...i,ref:n})});ul.displayName="MenuAnchor";var hl="MenuPortal",[fl,dl]=tl(hl,{forceMount:void 0}),pl=e=>{const{__scopeMenu:n,forceMount:r,children:i,container:o}=e,s=sl(hl,n);return t.jsx(fl,{scope:n,forceMount:r,children:t.jsx(xn,{present:r||s.open,children:t.jsx(kn,{asChild:!0,container:o,children:i})})})};pl.displayName=hl;var ml="MenuContent",[gl,vl]=tl(ml),yl=s.forwardRef((e,n)=>{const r=dl(ml,e.__scopeMenu),{forceMount:i=r.forceMount,...o}=e,s=sl(ml,e.__scopeMenu),a=ll(ml,e.__scopeMenu);return t.jsx(Qa.Provider,{scope:e.__scopeMenu,children:t.jsx(xn,{present:i||s.open,children:t.jsx(Qa.Slot,{scope:e.__scopeMenu,children:a.modal?t.jsx(bl,{...o,ref:n}):t.jsx(wl,{...o,ref:n})})})})}),bl=s.forwardRef((e,n)=>{const r=sl(ml,e.__scopeMenu),i=s.useRef(null),o=bt(n,i);return s.useEffect(()=>{const e=i.current;if(e)return br(e)},[]),t.jsx(xl,{...e,ref:o,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:Wt(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})}),wl=s.forwardRef((e,n)=>{const r=sl(ml,e.__scopeMenu);return t.jsx(xl,{...e,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})}),kl=$t("MenuContent.ScrollLock"),xl=s.forwardRef((e,n)=>{const{__scopeMenu:r,loop:i=!1,trapFocus:o,onOpenAutoFocus:a,onCloseAutoFocus:l,disableOutsidePointerEvents:c,onEntryFocus:u,onEscapeKeyDown:h,onPointerDownOutside:f,onFocusOutside:d,onInteractOutside:p,onDismiss:m,disableOutsideScroll:g,...v}=e,y=sl(ml,r),b=ll(ml,r),w=rl(r),k=il(r),x=Za(r),[S,C]=s.useState(null),E=s.useRef(null),A=bt(n,E,y.onContentChange),M=s.useRef(0),O=s.useRef(""),N=s.useRef(0),T=s.useRef(null),R=s.useRef("right"),D=s.useRef(0),P=g?fr:s.Fragment,L=g?{as:kl,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())};s.useEffect(()=>()=>window.clearTimeout(M.current),[]),En();const I=s.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 t.jsx(gl,{scope:r,searchRef:O,onItemEnter:s.useCallback(e=>{I(e)&&e.preventDefault()},[I]),onItemLeave:s.useCallback(e=>{I(e)||(E.current?.focus(),C(null))},[I]),onTriggerLeave:s.useCallback(e=>{I(e)&&e.preventDefault()},[I]),pointerGraceTimerRef:N,onPointerGraceIntentChange:s.useCallback(e=>{T.current=e},[]),children:t.jsx(P,{...L,children:t.jsx(pn,{asChild:!0,trapped:o,onMountAutoFocus:Wt(a,e=>{e.preventDefault(),E.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:l,children:t.jsx(ln,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:h,onPointerDownOutside:f,onFocusOutside:d,onInteractOutside:p,onDismiss:m,children:t.jsx(qa,{asChild:!0,...k,dir:b.dir,orientation:"vertical",loop:i,currentTabStopId:S,onCurrentTabStopIdChange:C,onEntryFocus:Wt(u,e=>{b.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:t.jsx(Os,{role:"menu","aria-orientation":"vertical","data-state":Yl(y.open),"data-radix-menu-content":"",dir:b.dir,...w,...v,ref:A,style:{outline:"none",...v.style},onKeyDown:Wt(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(!Ya.includes(e.key))return;e.preventDefault();const o=x().filter(e=>!e.disabled).map(e=>e.ref.current);Ga.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:Wt(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(M.current),O.current="")}),onPointerMove:Wt(e.onPointerMove,Jl(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}}))})})})})})})});yl.displayName=ml;var Sl=s.forwardRef((e,n)=>{const{__scopeMenu:r,...i}=e;return t.jsx(Zt.div,{role:"group",...i,ref:n})});Sl.displayName="MenuGroup";var Cl=s.forwardRef((e,n)=>{const{__scopeMenu:r,...i}=e;return t.jsx(Zt.div,{...i,ref:n})});Cl.displayName="MenuLabel";var El="MenuItem",Al="menu.itemSelect",Ml=s.forwardRef((e,n)=>{const{disabled:r=!1,onSelect:i,...o}=e,a=s.useRef(null),l=ll(El,e.__scopeMenu),c=vl(El,e.__scopeMenu),u=bt(n,a),h=s.useRef(!1);return t.jsx(Ol,{...o,ref:u,disabled:r,onClick:Wt(e.onClick,()=>{const e=a.current;if(!r&&e){const t=new CustomEvent(Al,{bubbles:!0,cancelable:!0});e.addEventListener(Al,e=>i?.(e),{once:!0}),en(e,t),t.defaultPrevented?h.current=!1:l.onClose()}}),onPointerDown:t=>{e.onPointerDown?.(t),h.current=!0},onPointerUp:Wt(e.onPointerUp,e=>{h.current||e.currentTarget?.click()}),onKeyDown:Wt(e.onKeyDown,e=>{const t=""!==c.searchRef.current;r||t&&" "===e.key||Ka.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});Ml.displayName=El;var Ol=s.forwardRef((e,n)=>{const{__scopeMenu:r,disabled:i=!1,textValue:o,...a}=e,l=vl(El,r),c=il(r),u=s.useRef(null),h=bt(n,u),[f,d]=s.useState(!1),[p,m]=s.useState("");return s.useEffect(()=>{const e=u.current;e&&m((e.textContent??"").trim())},[a.children]),t.jsx(Qa.ItemSlot,{scope:r,disabled:i,textValue:o??p,children:t.jsx(Ua,{asChild:!0,...c,focusable:!i,children:t.jsx(Zt.div,{role:"menuitem","data-highlighted":f?"":void 0,"aria-disabled":i||void 0,"data-disabled":i?"":void 0,...a,ref:h,onPointerMove:Wt(e.onPointerMove,Jl(e=>{if(i)l.onItemLeave(e);else if(l.onItemEnter(e),!e.defaultPrevented){e.currentTarget.focus({preventScroll:!0})}})),onPointerLeave:Wt(e.onPointerLeave,Jl(e=>l.onItemLeave(e))),onFocus:Wt(e.onFocus,()=>d(!0)),onBlur:Wt(e.onBlur,()=>d(!1))})})})}),Nl=s.forwardRef((e,n)=>{const{checked:r=!1,onCheckedChange:i,...o}=e;return t.jsx(_l,{scope:e.__scopeMenu,checked:r,children:t.jsx(Ml,{role:"menuitemcheckbox","aria-checked":$l(r)?"mixed":r,...o,ref:n,"data-state":Xl(r),onSelect:Wt(o.onSelect,()=>i?.(!!$l(r)||!r),{checkForDefaultPrevented:!1})})})});Nl.displayName="MenuCheckboxItem";var Tl="MenuRadioGroup",[Rl,Dl]=tl(Tl,{value:void 0,onValueChange:()=>{}}),Pl=s.forwardRef((e,n)=>{const{value:r,onValueChange:i,...o}=e,s=tn(i);return t.jsx(Rl,{scope:e.__scopeMenu,value:r,onValueChange:s,children:t.jsx(Sl,{...o,ref:n})})});Pl.displayName=Tl;var Ll="MenuRadioItem",Bl=s.forwardRef((e,n)=>{const{value:r,...i}=e,o=Dl(Ll,e.__scopeMenu),s=r===o.value;return t.jsx(_l,{scope:e.__scopeMenu,checked:s,children:t.jsx(Ml,{role:"menuitemradio","aria-checked":s,...i,ref:n,"data-state":Xl(s),onSelect:Wt(i.onSelect,()=>o.onValueChange?.(r),{checkForDefaultPrevented:!1})})})});Bl.displayName=Ll;var Il="MenuItemIndicator",[_l,jl]=tl(Il,{checked:!1}),Fl=s.forwardRef((e,n)=>{const{__scopeMenu:r,forceMount:i,...o}=e,s=jl(Il,r);return t.jsx(xn,{present:i||$l(s.checked)||!0===s.checked,children:t.jsx(Zt.span,{...o,ref:n,"data-state":Xl(s.checked)})})});Fl.displayName=Il;var Wl=s.forwardRef((e,n)=>{const{__scopeMenu:r,...i}=e;return t.jsx(Zt.div,{role:"separator","aria-orientation":"horizontal",...i,ref:n})});Wl.displayName="MenuSeparator";var Hl=s.forwardRef((e,n)=>{const{__scopeMenu:r,...i}=e,o=rl(r);return t.jsx(Ns,{...o,...i,ref:n})});Hl.displayName="MenuArrow";var[zl,Vl]=tl("MenuSub"),ql="MenuSubTrigger",Ul=s.forwardRef((e,n)=>{const r=sl(ql,e.__scopeMenu),i=ll(ql,e.__scopeMenu),o=Vl(ql,e.__scopeMenu),a=vl(ql,e.__scopeMenu),l=s.useRef(null),{pointerGraceTimerRef:c,onPointerGraceIntentChange:u}=a,h={__scopeMenu:e.__scopeMenu},f=s.useCallback(()=>{l.current&&window.clearTimeout(l.current),l.current=null},[]);return s.useEffect(()=>f,[f]),s.useEffect(()=>{const e=c.current;return()=>{window.clearTimeout(e),u(null)}},[c,u]),t.jsx(ul,{asChild:!0,...h,children:t.jsx(Ol,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":r.open,"aria-controls":o.contentId,"data-state":Yl(r.open),...e,ref:yt(n,o.onTriggerChange),onClick:t=>{e.onClick?.(t),e.disabled||t.defaultPrevented||(t.currentTarget.focus(),r.open||r.onOpenChange(!0))},onPointerMove:Wt(e.onPointerMove,Jl(t=>{a.onItemEnter(t),t.defaultPrevented||e.disabled||r.open||l.current||(a.onPointerGraceIntentChange(null),l.current=window.setTimeout(()=>{r.onOpenChange(!0),f()},100))})),onPointerLeave:Wt(e.onPointerLeave,Jl(e=>{f();const t=r.content?.getBoundingClientRect();if(t){const n=r.content?.dataset.side,i="right"===n,o=i?-5:5,s=t[i?"left":"right"],l=t[i?"right":"left"];a.onPointerGraceIntentChange({area:[{x:e.clientX+o,y:e.clientY},{x:s,y:t.top},{x:l,y:t.top},{x:l,y:t.bottom},{x:s,y:t.bottom}],side:n}),window.clearTimeout(c.current),c.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(e),e.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:Wt(e.onKeyDown,t=>{const n=""!==a.searchRef.current;e.disabled||n&&" "===t.key||$a[i.dir].includes(t.key)&&(r.onOpenChange(!0),r.content?.focus(),t.preventDefault())})})})});Ul.displayName=ql;var Kl="MenuSubContent",Gl=s.forwardRef((e,n)=>{const r=dl(ml,e.__scopeMenu),{forceMount:i=r.forceMount,...o}=e,a=sl(ml,e.__scopeMenu),l=ll(ml,e.__scopeMenu),c=Vl(Kl,e.__scopeMenu),u=s.useRef(null),h=bt(n,u);return t.jsx(Qa.Provider,{scope:e.__scopeMenu,children:t.jsx(xn,{present:i||a.open,children:t.jsx(Qa.Slot,{scope:e.__scopeMenu,children:t.jsx(xl,{id:c.contentId,"aria-labelledby":c.triggerId,...o,ref:h,align:"start",side:"rtl"===l.dir?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{l.isUsingKeyboardRef.current&&u.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:Wt(e.onFocusOutside,e=>{e.target!==c.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:Wt(e.onEscapeKeyDown,e=>{l.onClose(),e.preventDefault()}),onKeyDown:Wt(e.onKeyDown,e=>{const t=e.currentTarget.contains(e.target),n=Xa[l.dir].includes(e.key);t&&n&&(a.onOpenChange(!1),c.trigger?.focus(),e.preventDefault())})})})})})});function Yl(e){return e?"open":"closed"}function $l(e){return"indeterminate"===e}function Xl(e){return $l(e)?"indeterminate":e?"checked":"unchecked"}function Jl(e){return t=>"mouse"===t.pointerType?e(t):void 0}Gl.displayName=Kl;var Ql=cl,Zl=ul,ec=pl,tc=yl,nc=Sl,rc=Cl,ic=Ml,oc=Nl,sc=Pl,ac=Bl,lc=Fl,cc=Wl,uc=Hl,hc=Ul,fc=Gl,dc="DropdownMenu",[pc,mc]=Ht(dc,[nl]),gc=nl(),[vc,yc]=pc(dc),bc=e=>{const{__scopeDropdownMenu:n,children:r,dir:i,open:o,defaultOpen:a,onOpenChange:l,modal:c=!0}=e,u=gc(n),h=s.useRef(null),[f,d]=Yt({prop:o,defaultProp:a??!1,onChange:l,caller:dc});return t.jsx(vc,{scope:n,triggerId:Kt(),triggerRef:h,contentId:Kt(),open:f,onOpenChange:d,onOpenToggle:s.useCallback(()=>d(e=>!e),[d]),modal:c,children:t.jsx(Ql,{...u,open:f,onOpenChange:d,dir:i,modal:c,children:r})})};bc.displayName=dc;var wc="DropdownMenuTrigger",kc=s.forwardRef((e,n)=>{const{__scopeDropdownMenu:r,disabled:i=!1,...o}=e,s=yc(wc,r),a=gc(r);return t.jsx(Zl,{asChild:!0,...a,children:t.jsx(Zt.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":i?"":void 0,disabled:i,...o,ref:yt(n,s.triggerRef),onPointerDown:Wt(e.onPointerDown,e=>{i||0!==e.button||!1!==e.ctrlKey||(s.onOpenToggle(),s.open||e.preventDefault())}),onKeyDown:Wt(e.onKeyDown,e=>{i||(["Enter"," "].includes(e.key)&&s.onOpenToggle(),"ArrowDown"===e.key&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(e.key)&&e.preventDefault())})})})});kc.displayName=wc;var xc=e=>{const{__scopeDropdownMenu:n,...r}=e,i=gc(n);return t.jsx(ec,{...i,...r})};xc.displayName="DropdownMenuPortal";var Sc="DropdownMenuContent",Cc=s.forwardRef((e,n)=>{const{__scopeDropdownMenu:r,...i}=e,o=yc(Sc,r),a=gc(r),l=s.useRef(!1);return t.jsx(tc,{id:o.contentId,"aria-labelledby":o.triggerId,...a,...i,ref:n,onCloseAutoFocus:Wt(e.onCloseAutoFocus,e=>{l.current||o.triggerRef.current?.focus(),l.current=!1,e.preventDefault()}),onInteractOutside:Wt(e.onInteractOutside,e=>{const t=e.detail.originalEvent,n=0===t.button&&!0===t.ctrlKey,r=2===t.button||n;o.modal&&!r||(l.current=!0)}),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)"}})});Cc.displayName=Sc;s.forwardRef((e,n)=>{const{__scopeDropdownMenu:r,...i}=e,o=gc(r);return t.jsx(nc,{...o,...i,ref:n})}).displayName="DropdownMenuGroup";var Ec=s.forwardRef((e,n)=>{const{__scopeDropdownMenu:r,...i}=e,o=gc(r);return t.jsx(rc,{...o,...i,ref:n})});Ec.displayName="DropdownMenuLabel";var Ac=s.forwardRef((e,n)=>{const{__scopeDropdownMenu:r,...i}=e,o=gc(r);return t.jsx(ic,{...o,...i,ref:n})});Ac.displayName="DropdownMenuItem";var Mc=s.forwardRef((e,n)=>{const{__scopeDropdownMenu:r,...i}=e,o=gc(r);return t.jsx(oc,{...o,...i,ref:n})});Mc.displayName="DropdownMenuCheckboxItem";s.forwardRef((e,n)=>{const{__scopeDropdownMenu:r,...i}=e,o=gc(r);return t.jsx(sc,{...o,...i,ref:n})}).displayName="DropdownMenuRadioGroup";var Oc=s.forwardRef((e,n)=>{const{__scopeDropdownMenu:r,...i}=e,o=gc(r);return t.jsx(ac,{...o,...i,ref:n})});Oc.displayName="DropdownMenuRadioItem";var Nc=s.forwardRef((e,n)=>{const{__scopeDropdownMenu:r,...i}=e,o=gc(r);return t.jsx(lc,{...o,...i,ref:n})});Nc.displayName="DropdownMenuItemIndicator";var Tc=s.forwardRef((e,n)=>{const{__scopeDropdownMenu:r,...i}=e,o=gc(r);return t.jsx(cc,{...o,...i,ref:n})});Tc.displayName="DropdownMenuSeparator";s.forwardRef((e,n)=>{const{__scopeDropdownMenu:r,...i}=e,o=gc(r);return t.jsx(uc,{...o,...i,ref:n})}).displayName="DropdownMenuArrow";var Rc=s.forwardRef((e,n)=>{const{__scopeDropdownMenu:r,...i}=e,o=gc(r);return t.jsx(hc,{...o,...i,ref:n})});Rc.displayName="DropdownMenuSubTrigger";var Dc=s.forwardRef((e,n)=>{const{__scopeDropdownMenu:r,...i}=e,o=gc(r);return t.jsx(fc,{...o,...i,ref:n,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)"}})});Dc.displayName="DropdownMenuSubContent";var Pc=xc,Lc=Cc,Bc=Ec,Ic=Ac,_c=Mc,jc=Oc,Fc=Nc,Wc=Tc,Hc=Rc,zc=Dc,Vc=bc,qc=kc,Uc=s.forwardRef(function(e,t){var n=e.className,r=e.inset,i=e.children,o=H(e,["className","inset","children"]);return s.createElement(Hc,Object.assign({ref:t,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",r&&"pl-8",n)},o),i,s.createElement(J,{className:"ml-auto"}))});Uc.displayName=Hc.displayName;var Kc=s.forwardRef(function(e,t){var n=e.className,r=H(e,["className"]);return s.createElement(zc,Object.assign({ref:t,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]",n)},r))});Kc.displayName=zc.displayName;var Gc=s.forwardRef(function(e,t){var n=e.className,r=e.sideOffset,i=void 0===r?4:r,o=H(e,["className","sideOffset"]);return s.createElement(Pc,null,s.createElement(Lc,Object.assign({ref:t,sideOffset:i,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]",n)},o)))});Gc.displayName=Lc.displayName;var Yc=s.forwardRef(function(e,t){var n=e.className,r=e.inset,i=H(e,["className","inset"]);return s.createElement(Ic,Object.assign({ref:t,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",r&&"pl-8",n)},i))});Yc.displayName=Ic.displayName;var $c=s.forwardRef(function(e,t){var n=e.className,r=e.children,i=e.checked,o=H(e,["className","children","checked"]);return s.createElement(_c,Object.assign({ref:t,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",n),checked:i},o),s.createElement("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center"},s.createElement(Fc,null,s.createElement(Y,{className:"h-4 w-4"}))),r)});$c.displayName=_c.displayName;var Xc=s.forwardRef(function(e,t){var n=e.className,r=e.children,i=H(e,["className","children"]);return s.createElement(jc,Object.assign({ref:t,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",n)},i),s.createElement("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center"},s.createElement(Fc,null,s.createElement(Z,{className:"h-2 w-2 fill-current"}))),r)});Xc.displayName=jc.displayName;var Jc=s.forwardRef(function(e,t){var n=e.className,r=e.inset,i=H(e,["className","inset"]);return s.createElement(Bc,Object.assign({ref:t,className:mt("px-2 py-1.5 text-sm font-semibold",r&&"pl-8",n)},i))});Jc.displayName=Bc.displayName;var Qc=s.forwardRef(function(e,t){var n=e.className,r=H(e,["className"]);return s.createElement(Wc,Object.assign({ref:t,className:mt("-mx-1 my-1 h-px bg-muted",n)},r))});Qc.displayName=Wc.displayName;var Zc=s.forwardRef((e,n)=>t.jsx(Lt.label,{...e,ref:n,onMouseDown:t=>{t.target.closest("button, input, select, textarea")||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));Zc.displayName="Label";var eu=Zc,tu=Tt("text-sm font-bold leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 text-foreground"),nu=s.forwardRef(function(e,t){var n=e.className,r=H(e,["className"]);return s.createElement(eu,Object.assign({ref:t,className:mt(tu(),n)},r))});nu.displayName=eu.displayName;var ru=s.forwardRef(function(e,t){var n=e.className,r=H(e,["className"]);return s.createElement("div",Object.assign({ref:t,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",n)},r))});ru.displayName="Card";var iu=s.forwardRef(function(e,t){var n=e.className,r=H(e,["className"]);return s.createElement("div",Object.assign({ref:t,className:mt("flex flex-col space-y-1.5 p-6",n)},r))});iu.displayName="CardHeader";var ou=s.forwardRef(function(e,t){var n=e.className,r=H(e,["className"]);return s.createElement("div",Object.assign({ref:t,className:mt("text-2xl font-bold leading-none tracking-tight",n)},r))});ou.displayName="CardTitle";var su=s.forwardRef(function(e,t){var n=e.className,r=H(e,["className"]);return s.createElement("div",Object.assign({ref:t,className:mt("text-sm text-muted-foreground",n)},r))});su.displayName="CardDescription";var au=s.forwardRef(function(e,t){var n=e.className,r=H(e,["className"]);return s.createElement("div",Object.assign({ref:t,className:mt("p-6 pt-0",n)},r))});au.displayName="CardContent";var lu=s.forwardRef(function(e,t){var n=e.className,r=H(e,["className"]);return s.createElement("div",Object.assign({ref:t,className:mt("flex items-center p-6 pt-0",n)},r))});lu.displayName="CardFooter";var cu={items:[],config:Object.assign({},{top:24,duration:3,maxCount:5})},uu=new Set;function hu(){uu.forEach(function(e){return e(cu.items.slice())})}function fu(t){switch(t){case"success":return e.createElement(G,null);case"error":return e.createElement(be,null);case"warning":return e.createElement(K,null);case"loading":return e.createElement(ae,{className:"animate-spin"});default:return e.createElement(oe,null)}}function du(e){var t,n,r;vu();var i=Date.now(),o=null!==(t=e.key)&&void 0!==t?t:"msg_".concat(i,"_").concat(Math.random().toString(36).slice(2)),s=cu.items.findIndex(function(e){return e.key===o}),a={key:o,content:e.content,duration:null!==(n=e.duration)&&void 0!==n?n:cu.config.duration,type:e.type,onClose:e.onClose,icon:null!==(r=e.icon)&&void 0!==r?r:fu(e.type),className:e.className,createdAt:i};return s>=0?cu.items[s]=Object.assign({},cu.items[s],a):(cu.items.length>=cu.config.maxCount&&cu.items.shift(),cu.items.push(a)),hu(),a.duration>0&&"loading"!==a.type&&window.setTimeout(function(){pu(o)},1e3*a.duration),{close:function(){return pu(o)}}}function pu(e){var t;if(void 0===e)return cu.items.forEach(function(e){var t;return null===(t=e.onClose)||void 0===t?void 0:t.call(e)}),cu.items=[],void hu();var n=cu.items.findIndex(function(t){return t.key===e});if(n>=0){var r=D(cu.items.splice(n,1),1)[0];null===(t=null==r?void 0:r.onClose)||void 0===t||t.call(r),hu()}}var mu=null,gu=null;function vu(){"undefined"!=typeof window&&(gu||((gu=document.createElement("div")).setAttribute("data-custom-message-holder",""),document.body.appendChild(gu)),mu||(mu=r.createRoot(gu)).render(e.createElement(yu,null)))}function yu(){var t=function(){var t=D(e.useState(cu.items),2),n=t[0],r=t[1];return e.useEffect(function(){var e=r;return uu.add(e),function(){uu.delete(e)}},[]),n}(),n=cu.config.top;return e.createElement("div",{className:"fixed left-1/2 -translate-x-1/2 z-[1000] w-80 pointer-events-none",style:{top:n}},e.createElement("div",{className:"mx-auto flex w-full max-w-xl flex-col items-center gap-2 px-4"},t.map(function(t){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"}}}(t.type);return e.createElement("div",{key:t.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=t.className)&&void 0!==n?n:"")},e.createElement("span",{className:"text-[18px] leading-none ".concat(i.icon)},null!==(r=t.icon)&&void 0!==r?r:fu(t.type)),e.createElement("div",{className:"min-w-0 flex-1 text-[14px] leading-normal ".concat(i.text)},"string"==typeof t.content?e.createElement("span",{className:"break-words align-middle"},t.content):t.content))})))}function bu(t,n,r,i){if(e.isValidElement(n)||"string"==typeof n||"number"==typeof n)return{type:t,content:n,duration:r,onClose:i};var o=n;return Object.assign({},o,{type:t})}var wu,ku,xu=(ku={open:function(e){var t;return du(Object.assign({},e,{type:null!==(t=e.type)&&void 0!==t?t:"info"}))},info:function(e,t,n){return du(bu("info",e,t,n))},success:function(e,t,n){return du(bu("success",e,t,n))},error:function(e,t,n){return du(bu("error",e,t,n))},warning:function(e,t,n){return du(bu("warning",e,t,n))},loading:function(e,t,n){return du(bu("loading",e,null!=t?t:0,n))},destroy:function(e){return pu(e)},config:function(e){return t=e,cu.config=Object.assign({},cu.config,t),void hu();var t},useMessage:function(){var t=e.useMemo(function(){return"undefined"!=typeof window&&vu(),e.createElement(e.Fragment,null)},[]);return[wu.current,t]}},(wu={}).current=ku,ku);function Su(e,t){return function(){return e.apply(t,arguments)}}var Cu,Eu=Object.prototype.toString,Au=Object.getPrototypeOf,Mu=Symbol.iterator,Ou=Symbol.toStringTag,Nu=(Cu=Object.create(null),function(e){var t=Eu.call(e);return Cu[t]||(Cu[t]=t.slice(8,-1).toLowerCase())}),Tu=function(e){return e=e.toLowerCase(),function(t){return Nu(t)===e}},Ru=function(e){return function(t){return I(t)===e}},Du=Array.isArray,Pu=Ru("undefined");function Lu(e){return null!==e&&!Pu(e)&&null!==e.constructor&&!Pu(e.constructor)&&_u(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var Bu=Tu("ArrayBuffer");var Iu=Ru("string"),_u=Ru("function"),ju=Ru("number"),Fu=function(e){return null!==e&&"object"===I(e)},Wu=function(e){if("object"!==Nu(e))return!1;var t=Au(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Ou in e||Mu in e)},Hu=Tu("Date"),zu=Tu("File"),Vu=Tu("Blob"),qu=Tu("FileList"),Uu=Tu("URLSearchParams"),Ku=D(["ReadableStream","Request","Response","Headers"].map(Tu),4),Gu=Ku[0],Yu=Ku[1],$u=Ku[2],Xu=Ku[3];function Ju(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"!==I(e)&&(e=[e]),Du(e))for(n=0,r=e.length;n<r;n++)t.call(null,e[n],n,e);else{if(Lu(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 Qu(e,t){if(Lu(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 Zu="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,eh=function(e){return!Pu(e)&&e!==Zu};var th,nh=(th="undefined"!=typeof Uint8Array&&Au(Uint8Array),function(e){return th&&e instanceof th}),rh=Tu("HTMLFormElement"),ih=function(){var e=Object.prototype.hasOwnProperty;return function(t,n){return e.call(t,n)}}(),oh=Tu("RegExp"),sh=function(e,t){var n=Object.getOwnPropertyDescriptors(e),r={};Ju(n,function(n,i){var o;!1!==(o=t(n,i,e))&&(r[i]=o||n)}),Object.defineProperties(e,r)};var ah,lh,ch,uh,hh=Tu("AsyncFunction"),fh=(ah="function"==typeof setImmediate,lh=_u(Zu.postMessage),ah?setImmediate:lh?(ch="axios@".concat(Math.random()),uh=[],Zu.addEventListener("message",function(e){var t=e.source,n=e.data;t===Zu&&n===ch&&uh.length&&uh.shift()()},!1),function(e){uh.push(e),Zu.postMessage(ch,"*")}):function(e){return setTimeout(e)}),dh="undefined"!=typeof queueMicrotask?queueMicrotask.bind(Zu):"undefined"!=typeof process&&process.nextTick||fh,ph={isArray:Du,isArrayBuffer:Bu,isBuffer:Lu,isFormData:function(e){var t;return e&&("function"==typeof FormData&&e instanceof FormData||_u(e.append)&&("formdata"===(t=Nu(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&&Bu(e.buffer)},isString:Iu,isNumber:ju,isBoolean:function(e){return!0===e||!1===e},isObject:Fu,isPlainObject:Wu,isEmptyObject:function(e){if(!Fu(e)||Lu(e))return!1;try{return 0===Object.keys(e).length&&Object.getPrototypeOf(e)===Object.prototype}catch(e){return!1}},isReadableStream:Gu,isRequest:Yu,isResponse:$u,isHeaders:Xu,isUndefined:Pu,isDate:Hu,isFile:zu,isBlob:Vu,isRegExp:oh,isFunction:_u,isStream:function(e){return Fu(e)&&_u(e.pipe)},isURLSearchParams:Uu,isTypedArray:nh,isFileList:qu,forEach:Ju,merge:function e(){for(var t=eh(this)&&this||{},n=t.caseless,r=t.skipUndefined,i={},o=function(t,o){var s=n&&Qu(i,o)||o;Wu(i[s])&&Wu(t)?i[s]=e(i[s],t):Wu(t)?i[s]=e({},t):Du(t)?i[s]=t.slice():r&&Pu(t)||(i[s]=t)},s=0,a=arguments.length;s<a;s++)arguments[s]&&Ju(arguments[s],o);return i},extend:function(e,t,n){return Ju(t,function(t,r){n&&_u(t)?e[r]=Su(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&&Au(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kindOf:Nu,kindOfTest:Tu,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(Du(e))return e;var t=e.length;if(!ju(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[Mu]).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:rh,hasOwnProperty:ih,hasOwnProp:ih,reduceDescriptors:sh,freezeMethods:function(e){sh(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 Du(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:Qu,global:Zu,isContextDefined:eh,isSpecCompliantForm:function(e){return!!(e&&_u(e.append)&&"FormData"===e[Ou]&&e[Mu])},toJSONObject:function(e){var t=new Array(10),n=function(e,r){if(Fu(e)){if(t.indexOf(e)>=0)return;if(Lu(e))return e;if(!("toJSON"in e)){t[r]=e;var i=Du(e)?[]:{};return Ju(e,function(e,t){var o=n(e,r+1);!Pu(o)&&(i[t]=o)}),t[r]=void 0,i}}return e};return n(e,0)},isAsyncFn:hh,isThenable:function(e){return e&&(Fu(e)||_u(e))&&_u(e.then)&&_u(e.catch)},setImmediate:fh,asap:dh,isIterable:function(e){return null!=e&&_u(e[Mu])}};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)}ph.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:ph.toJSONObject(this.config),code:this.code,status:this.status}}});var gh=mh.prototype,vh={};["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){vh[e]={value:e}}),Object.defineProperties(mh,vh),Object.defineProperty(gh,"isAxiosError",{value:!0}),mh.from=function(e,t,n,r,i,o){var s=Object.create(gh);ph.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 yh(e){return ph.isPlainObject(e)||ph.isArray(e)}function bh(e){return ph.endsWith(e,"[]")?e.slice(0,-2):e}function wh(e,t,n){return e?e.concat(t).map(function(e,t){return e=bh(e),!n&&t?"["+e+"]":e}).join(n?".":""):t}var kh=ph.toFlatObject(ph,{},null,function(e){return/^is[A-Z]/.test(e)});function xh(e,t,n){if(!ph.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;var r=(n=ph.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(e,t){return!ph.isUndefined(t[e])})).metaTokens,i=n.visitor||c,o=n.dots,s=n.indexes,a=(n.Blob||"undefined"!=typeof Blob&&Blob)&&ph.isSpecCompliantForm(t);if(!ph.isFunction(i))throw new TypeError("visitor must be a function");function l(e){if(null===e)return"";if(ph.isDate(e))return e.toISOString();if(ph.isBoolean(e))return e.toString();if(!a&&ph.isBlob(e))throw new mh("Blob is not supported. Use a Buffer instead.");return ph.isArrayBuffer(e)||ph.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"===I(e))if(ph.endsWith(n,"{}"))n=r?n:n.slice(0,-2),e=JSON.stringify(e);else if(ph.isArray(e)&&function(e){return ph.isArray(e)&&!e.some(yh)}(e)||(ph.isFileList(e)||ph.endsWith(n,"[]"))&&(a=ph.toArray(e)))return n=bh(n),a.forEach(function(e,r){!ph.isUndefined(e)&&null!==e&&t.append(!0===s?wh([n],r,o):null===s?n:n+"[]",l(e))}),!1;return!!yh(e)||(t.append(wh(i,n,o),l(e)),!1)}var u=[],h=Object.assign(kh,{defaultVisitor:c,convertValue:l,isVisitable:yh});if(!ph.isObject(e))throw new TypeError("data must be an object");return function e(n,r){if(!ph.isUndefined(n)){if(-1!==u.indexOf(n))throw Error("Circular reference detected in "+r.join("."));u.push(n),ph.forEach(n,function(n,o){!0===(!(ph.isUndefined(n)||null===n)&&i.call(t,n,ph.isString(o)?o.trim():o,r,h))&&e(n,r?r.concat(o):[o])}),u.pop()}}(e),t}function Sh(e){var t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(e){return t[e]})}function Ch(e,t){this._pairs=[],e&&xh(e,this,t)}var Eh=Ch.prototype;function Ah(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Mh(e,t,n){if(!t)return e;var r=n&&n.encode||Ah;ph.isFunction(n)&&(n={serialize:n});var i,o=n&&n.serialize;if(i=o?o(t,n):ph.isURLSearchParams(t)?t.toString():new Ch(t,n).toString(r)){var s=e.indexOf("#");-1!==s&&(e=e.slice(0,s)),e+=(-1===e.indexOf("?")?"?":"&")+i}return e}Eh.append=function(e,t){this._pairs.push([e,t])},Eh.toString=function(e){var t=e?function(t){return e.call(this,t,Sh)}:Sh;return this._pairs.map(function(e){return t(e[0])+"="+t(e[1])},"").join("&")};var Oh=function(){return b(function e(){v(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){ph.forEach(this.handlers,function(t){null!==t&&e(t)})}}])}(),Nh=Oh,Th={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Rh={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:Ch,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]},Dh="undefined"!=typeof window&&"undefined"!=typeof document,Ph="object"===("undefined"==typeof navigator?"undefined":I(navigator))&&navigator||void 0,Lh=Dh&&(!Ph||["ReactNative","NativeScript","NS"].indexOf(Ph.product)<0),Bh="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,Ih=Dh&&window.location.href||"http://localhost",_h=M(M({},Object.freeze({__proto__:null,hasBrowserEnv:Dh,hasStandardBrowserEnv:Lh,hasStandardBrowserWebWorkerEnv:Bh,navigator:Ph,origin:Ih})),Rh);function jh(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&&ph.isArray(r)?r.length:o,a?(ph.hasOwnProp(r,o)?r[o]=[r[o],n]:r[o]=n,!s):(r[o]&&ph.isObject(r[o])||(r[o]=[]),t(e,n,r[o],i)&&ph.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(ph.isFormData(e)&&ph.isFunction(e.entries)){var n={};return ph.forEachEntry(e,function(e,r){t(function(e){return ph.matchAll(/\w+|\[(\w*)]/g,e).map(function(e){return"[]"===e[0]?"":e[1]||e[0]})}(e),r,n,0)}),n}return null}var Fh={transitional:Th,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){var n,r=t.getContentType()||"",i=r.indexOf("application/json")>-1,o=ph.isObject(e);if(o&&ph.isHTMLForm(e)&&(e=new FormData(e)),ph.isFormData(e))return i?JSON.stringify(jh(e)):e;if(ph.isArrayBuffer(e)||ph.isBuffer(e)||ph.isStream(e)||ph.isFile(e)||ph.isBlob(e)||ph.isReadableStream(e))return e;if(ph.isArrayBufferView(e))return e.buffer;if(ph.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 xh(e,new _h.classes.URLSearchParams,M({visitor:function(e,t,n,r){return _h.isNode&&ph.isBuffer(e)?(this.append(t,e.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)}},t))}(e,this.formSerializer).toString();if((n=ph.isFileList(e))||r.indexOf("multipart/form-data")>-1){var s=this.env&&this.env.FormData;return xh(n?{"files[]":e}:e,s&&new s,this.formSerializer)}}return o||i?(t.setContentType("application/json",!1),function(e,t,n){if(ph.isString(e))try{return(t||JSON.parse)(e),ph.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(n||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){var t=this.transitional||Fh.transitional,n=t&&t.forcedJSONParsing,r="json"===this.responseType;if(ph.isResponse(e)||ph.isReadableStream(e))return e;if(e&&ph.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}}};ph.forEach(["delete","get","head","post","put","patch"],function(e){Fh.headers[e]={}});var Wh=Fh,Hh=ph.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"]),zh=Symbol("internals");function Vh(e){return e&&String(e).trim().toLowerCase()}function qh(e){return!1===e||null==e?e:ph.isArray(e)?e.map(qh):String(e)}function Uh(e,t,n,r,i){return ph.isFunction(r)?r.call(this,t,n):(i&&(t=n),ph.isString(t)?ph.isString(r)?-1!==t.indexOf(r):ph.isRegExp(r)?r.test(t):void 0:void 0)}var Kh=function(){return b(function e(t){v(this,e),t&&this.set(t)},[{key:"set",value:function(e,t,n){var r=this;function i(e,t,n){var i=Vh(t);if(!i)throw new Error("header name must be a non-empty string");var o=ph.findKey(r,i);(!o||void 0===r[o]||!0===n||void 0===n&&!1!==r[o])&&(r[o||t]=qh(e))}var o=function(e,t){return ph.forEach(e,function(e,n){return i(e,n,t)})};if(ph.isPlainObject(e)||e instanceof this.constructor)o(e,t);else if(ph.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]&&Hh[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(ph.isObject(e)&&ph.isIterable(e)){var s,a,l,c={},u=w(e);try{for(u.s();!(l=u.n()).done;){var h=l.value;if(!ph.isArray(h))throw TypeError("Object iterator must return a key-value pair");c[a=h[0]]=(s=c[a])?ph.isArray(s)?[].concat(L(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=Vh(e)){var n=ph.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(ph.isFunction(t))return t.call(this,r,n);if(ph.isRegExp(t))return t.exec(r);throw new TypeError("parser must be boolean|regexp|function")}}}},{key:"has",value:function(e,t){if(e=Vh(e)){var n=ph.findKey(this,e);return!(!n||void 0===this[n]||t&&!Uh(0,this[n],n,t))}return!1}},{key:"delete",value:function(e,t){var n=this,r=!1;function i(e){if(e=Vh(e)){var i=ph.findKey(n,e);!i||t&&!Uh(0,n[i],i,t)||(delete n[i],r=!0)}}return ph.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&&!Uh(0,this[i],i,e,!0)||(delete this[i],r=!0)}return r}},{key:"normalize",value:function(e){var t=this,n={};return ph.forEach(this,function(r,i){var o=ph.findKey(n,i);if(o)return t[o]=qh(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]=qh(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 ph.forEach(this,function(n,r){null!=n&&!1!==n&&(t[r]=e&&ph.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=D(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[zh]=this[zh]={accessors:{}}).accessors,n=this.prototype;function r(e){var r=Vh(e);t[r]||(!function(e,t){var n=ph.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 ph.isArray(e)?e.forEach(r):r(e),this}}])}();Kh.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),ph.reduceDescriptors(Kh.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}}}),ph.freezeMethods(Kh);var Gh=Kh;function Yh(e,t){var n=this||Wh,r=t||n,i=Gh.from(r.headers),o=r.data;return ph.forEach(e,function(e){o=e.call(n,o,i.normalize(),t?t.status:void 0)}),i.normalize(),o}function $h(e){return!(!e||!e.__CANCEL__)}function Xh(e,t,n){mh.call(this,null==e?"canceled":e,mh.ERR_CANCELED,t,n),this.name="CanceledError"}function Jh(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)}ph.inherits(Xh,mh,{__CANCEL__:!0});var Qh=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,L(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=k({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)},Zh=function(e,t){var n=null!=e;return[function(r){return t[0]({lengthComputable:n,total:e,loaded:r})},t[1]]},ef=function(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return ph.asap(function(){return e.apply(void 0,n)})}},tf=_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},nf=_h.hasStandardBrowserEnv?{write:function(e,t,n,r,i,o,s){if("undefined"!=typeof document){var a=["".concat(e,"=").concat(encodeURIComponent(t))];ph.isNumber(n)&&a.push("expires=".concat(new Date(n).toUTCString())),ph.isString(r)&&a.push("path=".concat(r)),ph.isString(i)&&a.push("domain=".concat(i)),!0===o&&a.push("secure"),ph.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 rf(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 of=function(e){return e instanceof Gh?M({},e):e};function sf(e,t){t=t||{};var n={};function r(e,t,n,r){return ph.isPlainObject(e)&&ph.isPlainObject(t)?ph.merge.call({caseless:r},e,t):ph.isPlainObject(t)?ph.merge({},t):ph.isArray(t)?t.slice():t}function i(e,t,n,i){return ph.isUndefined(t)?ph.isUndefined(e)?void 0:r(void 0,e,0,i):r(e,t,0,i)}function o(e,t){if(!ph.isUndefined(t))return r(void 0,t)}function s(e,t){return ph.isUndefined(t)?ph.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(of(e),of(t),0,!0)}};return ph.forEach(Object.keys(M(M({},e),t)),function(r){var o=l[r]||i,s=o(e[r],t[r],r);ph.isUndefined(s)&&o!==a||(n[r]=s)}),n}var af,lf=function(e){var t=sf({},e),n=t.data,r=t.withXSRFToken,i=t.xsrfHeaderName,o=t.xsrfCookieName,s=t.headers,a=t.auth;if(t.headers=s=Gh.from(s),t.url=Mh(rf(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&s.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),ph.isFormData(n))if(_h.hasStandardBrowserEnv||_h.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if(ph.isFunction(n.getHeaders)){var l=n.getHeaders(),c=["content-type","content-length"];Object.entries(l).forEach(function(e){var t=D(e,2),n=t[0],r=t[1];c.includes(n.toLowerCase())&&s.set(n,r)})}if(_h.hasStandardBrowserEnv&&(r&&ph.isFunction(r)&&(r=r(t)),r||!1!==r&&tf(t.url))){var u=i&&o&&nf.read(o);u&&s.set(i,u)}return t},cf="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise(function(t,n){var r,i,o,s,a,l=lf(e),c=l.data,u=Gh.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=Gh.from("getAllResponseHeaders"in m&&m.getAllResponseHeaders());Jh(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||Th;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&&ph.forEach(u.toJSON(),function(e,t){m.setRequestHeader(t,e)}),ph.isUndefined(l.withCredentials)||(m.withCredentials=!!l.withCredentials),h&&"json"!==h&&(m.responseType=l.responseType),d){var v=D(Qh(d,!0),2);o=v[0],a=v[1],m.addEventListener("progress",o)}if(f&&m.upload){var y=D(Qh(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 Xh(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)})},uf=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 Xh(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 ph.asap(a)},l}},hf=O().m(function e(t,n){var r,i,o;return O().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)}),ff=function(){var e=j(O().m(function e(t,n){var r,i,o,s,a,l,c;return O().w(function(e){for(;;)switch(e.p=e.n){case 0:r=!1,i=!1,e.p=1,s=h(df(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(T(u(h(hf(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)}}(),df=function(){var e=j(O().m(function e(t){var n,r,i,o;return O().w(function(e){for(;;)switch(e.p=e.n){case 0:if(!t[Symbol.asyncIterator]){e.n=2;break}return e.d(T(u(h(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)}}(),pf=function(e,t,n,r){var i,o=ff(e,t),s=0,a=function(e){i||(i=!0,r&&r(e))};return new ReadableStream({pull:function(e){return p(O().m(function t(){var r,i,l,c,u,h;return O().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=ph.isFunction,gf={Request:(af=ph.global).Request,Response:af.Response},vf=ph.global,yf=vf.ReadableStream,bf=vf.TextEncoder,wf=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}},kf=function(e){var t=e=ph.merge.call({skipUndefined:!0},gf,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(yf),u=o&&("function"==typeof bf?(l=new bf,function(e){return l.encode(e)}):function(){var e=p(O().m(function e(t){var n,i;return O().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&&wf(function(){var e=!1,t=new r(_h.origin,{body:new yf,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),f=a&&c&&wf(function(){return ph.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 m=function(){var e=p(O().m(function e(t){var n;return O().w(function(e){for(;;)switch(e.n){case 0:if(null!=t){e.n=1;break}return e.a(2,0);case 1:if(!ph.isBlob(t)){e.n=2;break}return e.a(2,t.size);case 2:if(!ph.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(!ph.isArrayBufferView(t)&&!ph.isArrayBuffer(t)){e.n=5;break}return e.a(2,t.byteLength);case 5:if(ph.isURLSearchParams(t)&&(t+=""),!ph.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)}}(),g=function(){var e=p(O().m(function e(t,n){var r;return O().w(function(e){for(;;)if(0===e.n)return r=ph.toFiniteNumber(t.getContentLength()),e.a(2,null==r?m(n):r)},e)}));return function(t,n){return e.apply(this,arguments)}}();return function(){var e=p(O().m(function e(t){var o,a,l,c,u,p,m,v,y,b,w,k,x,S,C,E,A,N,T,R,P,L,B,I,_,j,F,W,H,z,V,q,U,K,G,Y,$,X,J;return O().w(function(e){for(;;)switch(e.p=e.n){case 0:if(o=lf(t),a=o.url,l=o.method,c=o.data,u=o.signal,p=o.cancelToken,m=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=uf([u,p&&p.toAbortSignal()],m),A=null,N=E&&E.unsubscribe&&function(){E.unsubscribe()},e.p=1,!($=y&&h&&"get"!==l&&"head"!==l)){e.n=3;break}return e.n=2,g(w,c);case 2:X=T=e.v,$=0!==X;case 3:if(!$){e.n=4;break}R=new r(a,{method:"POST",body:c,duplex:"half"}),ph.isFormData(c)&&(P=R.headers.get("content-type"))&&w.setContentType(P),R.body&&(L=Zh(T,Qh(ef(y))),B=D(L,2),I=B[0],_=B[1],c=pf(R.body,65536,I,_));case 4:return ph.isString(x)||(x=x?"include":"omit"),j=s&&"credentials"in r.prototype,F=M(M({},S),{},{signal:E,method:l.toUpperCase(),headers:w.normalize().toJSON(),body:c,duplex:"half",credentials:j?x:void 0}),A=s&&new r(a,F),e.n=5,s?C(A,S):C(a,F);case 5:return W=e.v,H=f&&("stream"===b||"response"===b),f&&(v||H&&N)&&(z={},["status","statusText","headers"].forEach(function(e){z[e]=W[e]}),V=ph.toFiniteNumber(W.headers.get("content-length")),q=v&&Zh(V,Qh(ef(v),!0))||[],U=D(q,2),K=U[0],G=U[1],W=new i(pf(W.body,65536,K,function(){G&&G(),N&&N()}),z)),b=b||"text",e.n=6,d[ph.findKey(d,b)||"text"](W,t);case 6:return Y=e.v,!H&&N&&N(),e.n=7,new Promise(function(e,n){Jh(e,n,{data:Y,headers:Gh.from(W.headers),status:W.status,statusText:W.statusText,config:t,request:A})});case 7:return e.a(2,e.v);case 8:if(e.p=8,J=e.v,N&&N(),!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)}}()},xf=new Map,Sf=function(e){for(var t,n,r=e&&e.env||{},i=r.fetch,o=[r.Request,r.Response,i],s=o.length,a=xf;s--;)t=o[s],void 0===(n=a.get(t))&&a.set(t,n=s?new Map:kf(r)),a=n;return n};Sf();var Cf={http:null,xhr:cf,fetch:{get:Sf}};ph.forEach(Cf,function(e,t){if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}});var Ef=function(e){return"- ".concat(e)},Af=function(e){return ph.isFunction(e)||null===e||!1===e};var Mf={getAdapter:function(e,t){for(var n,r,i=(e=ph.isArray(e)?e:[e]).length,o={},s=0;s<i;s++){var a=void 0;if(r=n=e[s],!Af(n)&&void 0===(r=Cf[(a=String(n)).toLowerCase()]))throw new mh("Unknown adapter '".concat(a,"'"));if(r&&(ph.isFunction(r)||(r=r.get(t))))break;o[a||"#"+s]=r}if(!r){var l=Object.entries(o).map(function(e){var t=D(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(Ef).join("\n"):" "+Ef(l[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return r},adapters:Cf};function Of(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Xh(null,e)}function Nf(e){return Of(e),e.headers=Gh.from(e.headers),e.data=Yh.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Mf.getAdapter(e.adapter||Wh.adapter,e)(e).then(function(t){return Of(e),t.data=Yh.call(e,e.transformResponse,t),t.headers=Gh.from(t.headers),t},function(t){return $h(t)||(Of(e),t&&t.response&&(t.response.data=Yh.call(e,e.transformResponse,t.response),t.response.headers=Gh.from(t.response.headers))),Promise.reject(t)})}var Tf="1.13.2",Rf={};["object","boolean","number","function","string","symbol"].forEach(function(e,t){Rf[e]=function(n){return I(n)===e||"a"+(t<1?"n ":" ")+e}});var Df={};Rf.transitional=function(e,t,n){return function(r,i,o){if(!1===e)throw new mh(function(e,t){return"[Axios v"+Tf+"] Transitional option '"+e+"'"+t+(n?". "+n:"")}(i," has been removed"+(t?" in "+t:"")),mh.ERR_DEPRECATED);return t&&!Df[i]&&(Df[i]=!0),!e||e(r,i,o)}},Rf.spelling=function(e){return function(e,t){return!0}};var Pf={assertOptions:function(e,t,n){if("object"!==I(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:Rf},Lf=Pf.validators,Bf=function(){return b(function e(t){v(this,e),this.defaults=t||{},this.interceptors={request:new Nh,response:new Nh}},[{key:"request",value:(e=p(O().m(function e(t,n){var r,i,o;return O().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=sf(this.defaults,t),r=n.transitional,i=n.paramsSerializer,o=n.headers;void 0!==r&&Pf.assertOptions(r,{silentJSONParsing:Lf.transitional(Lf.boolean),forcedJSONParsing:Lf.transitional(Lf.boolean),clarifyTimeoutError:Lf.transitional(Lf.boolean)},!1),null!=i&&(ph.isFunction(i)?t.paramsSerializer={serialize:i}:Pf.assertOptions(i,{encode:Lf.function,serialize:Lf.function},!0)),void 0!==t.allowAbsoluteUrls||(void 0!==this.defaults.allowAbsoluteUrls?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),Pf.assertOptions(t,{baseUrl:Lf.spelling("baseURL"),withXsrfToken:Lf.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();var s=o&&ph.merge(o.common,o[t.method]);o&&ph.forEach(["delete","get","head","post","put","patch","common"],function(e){delete o[e]}),t.headers=Gh.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=[Nf.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=Nf.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 Mh(rf((e=sf(this.defaults,e)).baseURL,e.url,e.allowAbsoluteUrls),e.params,e.paramsSerializer)}}]);var e}();ph.forEach(["delete","get","head","options"],function(e){Bf.prototype[e]=function(t,n){return this.request(sf(n||{},{method:e,url:t,data:(n||{}).data}))}}),ph.forEach(["post","put","patch"],function(e){function t(t){return function(n,r,i){return this.request(sf(i||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:n,data:r}))}}Bf.prototype[e]=t(),Bf.prototype[e+"Form"]=t(!0)});var If=Bf,_f=function(){function e(t){if(v(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 Xh(e,t,i),n(r.reason))})}return b(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}}}])}(),jf=_f;var Ff={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(Ff).forEach(function(e){var t=D(e,2),n=t[0],r=t[1];Ff[r]=n});var Wf=Ff;var Hf=function e(t){var n=new If(t),r=Su(If.prototype.request,n);return ph.extend(r,If.prototype,n,{allOwnKeys:!0}),ph.extend(r,n,null,{allOwnKeys:!0}),r.create=function(n){return e(sf(t,n))},r}(Wh);Hf.Axios=If,Hf.CanceledError=Xh,Hf.CancelToken=jf,Hf.isCancel=$h,Hf.VERSION=Tf,Hf.toFormData=xh,Hf.AxiosError=mh,Hf.Cancel=Hf.CanceledError,Hf.all=function(e){return Promise.all(e)},Hf.spread=function(e){return function(t){return e.apply(null,t)}},Hf.isAxiosError=function(e){return ph.isObject(e)&&!0===e.isAxiosError},Hf.mergeConfig=sf,Hf.AxiosHeaders=Gh,Hf.formToJSON=function(e){return jh(ph.isHTMLForm(e)?new FormData(e):e)},Hf.getAdapter=Mf.getAdapter,Hf.HttpStatusCode=Wf,Hf.default=Hf;var zf=Hf;zf.Axios,zf.AxiosError,zf.CanceledError,zf.isCancel,zf.CancelToken,zf.VERSION,zf.all,zf.Cancel,zf.isAxiosError,zf.spread,zf.toFormData,zf.AxiosHeaders,zf.HttpStatusCode,zf.formToJSON,zf.getAdapter,zf.mergeConfig;var Vf=zf.create({baseURL:"/api/cms",timeout:1e4,headers:{"Content-Type":"application/json"}}),qf=new Map;Vf.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)}),Vf.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&&(xu.error(t),setTimeout(function(){window.location.reload()},1e3))):xu.error(t),Promise.reject(e)});var Uf,Kf=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=qf.get(o);if(s)return s;var a=Vf.get(r,n).then(function(e){return e.data}).finally(function(){qf.delete(o)});return qf.set(o,a),a},Gf=function(e,t,n){return Vf.post(e,t,n).then(function(e){return e.data})},Yf=function(e,t,n){return Vf.put(e,t,n).then(function(e){return e.data})},$f=function(e,t){return Vf.delete(e,t).then(function(e){return e.data})};try{var Xf=localStorage.getItem("cms_session_id")||void 0;Uf=Xf}catch(NC){}var Jf=function(){return Kf("/models")},Qf=function(){return Kf("/auth/signup/status/".concat(Uf?Uf+"_":"","cms_users"))},Zf=function(e){return Gf("/auth/signup/".concat(Uf?Uf+"_":"","cms_users"),e)},ed=function(e){return Gf("/auth/login/".concat(Uf?Uf+"_":"","cms_users"),e)},td=function(){return Gf("/auth/verify/".concat(Uf?Uf+"_":"","cms_users"))},nd=function(){return Kf("/auth/user/".concat(Uf?Uf+"_":"","cms_users"))},rd=function(){localStorage.removeItem("cms_token"),localStorage.removeItem("cms_user")},id=function(){return localStorage.getItem("cms_token")},od=function(){var e=localStorage.getItem("cms_user");return e?JSON.parse(e):null},sd=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)),Kf("/data/".concat(Uf?Uf+"_":"").concat(e),n)},ad=function(e,t){return Kf("/relation/".concat(Uf?Uf+"_":"").concat(e,"/options"),t)},ld=function(e,t){return Gf("/data/".concat(Uf?Uf+"_":"").concat(e),t)},cd=function(e,t){return Yf("/data/".concat(Uf?Uf+"_":"").concat(e),t)},ud=function(e,t){return $f("/data/".concat(Uf?Uf+"_":"").concat(e,"?id=").concat(t))},hd={"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"}}},fd=e.createContext(void 0);function dd(t){var n=t.children,r=t.defaultLocale,i=D(e.useState(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),o=i[0],s=i[1],a={locale:o,setLocale:function(e){s(e),function(e){try{localStorage.setItem("cms_locale",e)}catch(e){}}(e)},t:function(e){var t,n=e.split("."),r=hd[o],i=w(n);try{for(i.s();!(t=i.n()).done;){var s=t.value;if(!r||"object"!==I(r)||!(s in r))return e;r=r[s]}}catch(e){i.e(e)}finally{i.f()}return"string"==typeof r?r:e},messages:hd[o]};return e.createElement(fd.Provider,{value:a},n)}function pd(){var t=e.useContext(fd);if(!t)throw new Error("useTranslation must be used within I18nProvider");return t}function md(){return pd().t}function gd(){var e=pd();return{locale:e.locale,setLocale:e.setLocale}}function vd(t){var n=t.onLoginSuccess,r=md(),i=D(e.useState(""),2),o=i[0],s=i[1],a=D(e.useState(""),2),l=a[0],c=a[1],u=D(e.useState(!1),2),h=u[0],f=u[1],d=D(e.useState("login"),2),m=d[0],g=d[1];e.useEffect(function(){var e=id();if(e){var t=function(){var t=p(O().m(function t(){var r;return O().w(function(t){for(;;)switch(t.p=t.n){case 0:return f(!0),t.p=1,t.n=2,td();case 2:if(t.v.success){t.n=3;break}throw new Error("token验证失败");case 3:return t.n=4,nd();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,rd();case 8:return t.p=8,f(!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]),e.useEffect(function(){if(!id()){var e=function(){var e=p(O().m(function e(){var t,n;return O().w(function(e){for(;;)switch(e.p=e.n){case 0:return f(!0),e.p=1,e.n=2,Qf();case 2:(n=e.v).success&&(null===(t=n.data)||void 0===t?void 0:t.allowSignup)?g("signup"):g("login"),e.n=4;break;case 3:e.p=3,e.v,g("login");case 4:return e.p=4,f(!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 v=function(){var e=p(O().m(function e(t){var i,s,a,c,u;return O().w(function(e){for(;;)switch(e.p=e.n){case 0:if(t.preventDefault(),o&&l){e.n=1;break}return xu.error(r("validation.required")),e.a(2);case 1:if(f(!0),e.p=2,"signup"!==m){e.n=4;break}return e.n=3,Zf({username:o,password:l});case 3:c=e.v,e.n=6;break;case 4:return e.n=5,ed({username:o,password:l});case 5:c=e.v;case 6:if((a=c).success&&(null===(i=a.data)||void 0===i?void 0:i.token)){e.n=7;break}return xu.error(a.message||r("auth.loginFailed")),"signup"===m&&(null===(s=a.message)||void 0===s?void 0:s.includes("已存在管理员"))&&g("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,u=e.v,xu.error("".concat(r("auth.loginFailed"),", ").concat(u.message||r("common.error")));case 9:return e.p=9,f(!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 e.createElement("div",{className:"we0-cms-root"},e.createElement("div",{className:"min-h-screen flex relative overflow-hidden bg-white"},e.createElement("div",{className:"pointer-events-none absolute inset-0"},e.createElement("div",{className:"absolute inset-0 bg-[linear-gradient(110deg,#ffffff_0%,#f7fbff_40%,#edf6ff_70%,#eaf3ff_100%)]"}),e.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)]"}),e.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%)]"})),e.createElement("div",{className:"flex-1 relative flex items-center justify-center"},e.createElement("div",{className:"relative z-10 max-w-4xl w-full px-16 text-left"},e.createElement("div",{className:"mb-12"},e.createElement("div",{className:"inline-flex items-center rounded-2xl px-4 py-2 bg-white/70 backdrop-blur border border-white/60"},e.createElement("span",{className:"text-2xl font-semibold tracking-tight text-gray-900"},r("data.dataManagement"))),e.createElement("h1",{className:"mt-8 text-5xl md:text-6xl font-extrabold leading-tight text-gray-900"},"WE0-CMS"),e.createElement("p",{className:"mt-6 text-2xl text-gray-600"},r("auth.welcome"))))),e.createElement("div",{className:"w-[480px] min-w-[380px] flex items-center justify-center p-8 mt-30"},e.createElement("div",{className:"w-full max-w-sm"},h?e.createElement(ru,{className:"bg-white/30 backdrop-blur-xl border border-white/50 shadow-none rounded-3xl overflow-hidden"},e.createElement(au,{className:"p-8"},e.createElement("div",{className:"space-y-4"},e.createElement(gt,{className:"h-12 w-48"}),e.createElement(gt,{className:"h-4 w-64"}),e.createElement(gt,{className:"h-10 w-full"}),e.createElement(gt,{className:"h-10 w-full"})))):e.createElement(ru,{className:"bg-white/30 backdrop-blur-xl border border-white/50 shadow-none rounded-3xl overflow-hidden"},e.createElement(iu,{className:"p-8 pb-6"},e.createElement(ou,{className:"text-center text-2xl mb-2 text-gray-800"},r("signup"===m?"auth.createAdminAccount":"auth.welcome")),e.createElement(su,{className:"text-center text-gray-500"},r("signup"===m?"auth.firstTimeSetup":"auth.pleaseLogin"))),e.createElement(au,{className:"p-8 pt-0"},e.createElement("form",{onSubmit:v,className:"space-y-6"},e.createElement("div",{className:"space-y-2"},e.createElement(nu,{htmlFor:"username"},r("auth.username"),"/",r("auth.email")),e.createElement("div",{className:"relative"},e.createElement(ye,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400"}),e.createElement(Pt,{id:"username",type:"text",placeholder:r("auth.email"),value:o,onChange:function(e){return s(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}))),e.createElement("div",{className:"space-y-2"},e.createElement(nu,{htmlFor:"password"},r("auth.password")),e.createElement("div",{className:"relative"},e.createElement(le,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400"}),e.createElement(Pt,{id:"password",type:"password",placeholder:r("auth.password"),value:l,onChange:function(e){return c(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}))),e.createElement(Dt,{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:h},e.createElement(ce,{className:"h-4 w-4 mr-2"}),r(h?"common.loading":"signup"===m?"auth.signup":"auth.login")))))))))}function yd(e,[t,n]){return Math.min(n,Math.max(t,e))}function bd(e){const t=s.useRef({value:e,previous:e});return s.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var wd=[" ","Enter","ArrowUp","ArrowDown"],kd=[" ","Enter"],xd="Select",[Sd,Cd,Ed]=Ea(xd),[Ad,Md]=Ht(xd,[Ed,us]),Od=us(),[Nd,Td]=Ad(xd),[Rd,Dd]=Ad(xd),Pd=e=>{const{__scopeSelect:n,children:r,open:i,defaultOpen:o,onOpenChange:a,value:l,defaultValue:c,onValueChange:u,dir:h,name:f,autoComplete:d,disabled:p,required:m,form:g}=e,v=Od(n),[y,b]=s.useState(null),[w,k]=s.useState(null),[x,S]=s.useState(!1),C=Ma(h),[E,A]=Yt({prop:i,defaultProp:o??!1,onChange:a,caller:xd}),[M,O]=Yt({prop:l,defaultProp:c,onChange:u,caller:xd}),N=s.useRef(null),T=!y||(g||!!y.closest("form")),[R,D]=s.useState(new Set),P=Array.from(R).map(e=>e.props.value).join(";");return t.jsx(As,{...v,children:t.jsxs(Nd,{required:m,scope:n,trigger:y,onTriggerChange:b,valueNode:w,onValueNodeChange:k,valueNodeHasChildren:x,onValueNodeHasChildrenChange:S,contentId:Kt(),value:M,onValueChange:O,open:E,onOpenChange:A,dir:C,triggerPointerDownPosRef:N,disabled:p,children:[t.jsx(Sd.Provider,{scope:n,children:t.jsx(Rd,{scope:e.__scopeSelect,onNativeOptionAdd:s.useCallback(e=>{D(t=>new Set(t).add(e))},[]),onNativeOptionRemove:s.useCallback(e=>{D(t=>{const n=new Set(t);return n.delete(e),n})},[]),children:r})}),T?t.jsxs(bp,{"aria-hidden":!0,required:m,tabIndex:-1,name:f,autoComplete:d,value:M,onChange:e=>O(e.target.value),disabled:p,form:g,children:[void 0===M?t.jsx("option",{value:""}):null,Array.from(R)]},P):null]})})};Pd.displayName=xd;var Ld="SelectTrigger",Bd=s.forwardRef((e,n)=>{const{__scopeSelect:r,disabled:i=!1,...o}=e,a=Od(r),l=Td(Ld,r),c=l.disabled||i,u=bt(n,l.onTriggerChange),h=Cd(r),f=s.useRef("touch"),[d,p,m]=kp(e=>{const t=h().filter(e=>!e.disabled),n=t.find(e=>e.value===l.value),r=xp(t,e,n);void 0!==r&&l.onValueChange(r.value)}),g=e=>{c||(l.onOpenChange(!0),m()),e&&(l.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return t.jsx(Ms,{asChild:!0,...a,children:t.jsx(Zt.button,{type:"button",role:"combobox","aria-controls":l.contentId,"aria-expanded":l.open,"aria-required":l.required,"aria-autocomplete":"none",dir:l.dir,"data-state":l.open?"open":"closed",disabled:c,"data-disabled":c?"":void 0,"data-placeholder":wp(l.value)?"":void 0,...o,ref:u,onClick:Wt(o.onClick,e=>{e.currentTarget.focus(),"mouse"!==f.current&&g(e)}),onPointerDown:Wt(o.onPointerDown,e=>{f.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:Wt(o.onKeyDown,e=>{const t=""!==d.current;e.ctrlKey||e.altKey||e.metaKey||1!==e.key.length||p(e.key),t&&" "===e.key||wd.includes(e.key)&&(g(),e.preventDefault())})})})});Bd.displayName=Ld;var Id="SelectValue",_d=s.forwardRef((e,n)=>{const{__scopeSelect:r,className:i,style:o,children:s,placeholder:a="",...l}=e,c=Td(Id,r),{onValueNodeHasChildrenChange:u}=c,h=void 0!==s,f=bt(n,c.onValueNodeChange);return Vt(()=>{u(h)},[u,h]),t.jsx(Zt.span,{...l,ref:f,style:{pointerEvents:"none"},children:wp(c.value)?t.jsx(t.Fragment,{children:a}):s})});_d.displayName=Id;var jd=s.forwardRef((e,n)=>{const{__scopeSelect:r,children:i,...o}=e;return t.jsx(Zt.span,{"aria-hidden":!0,...o,ref:n,children:i||"▼"})});jd.displayName="SelectIcon";var Fd=e=>t.jsx(kn,{asChild:!0,...e});Fd.displayName="SelectPortal";var Wd="SelectContent",Hd=s.forwardRef((e,n)=>{const r=Td(Wd,e.__scopeSelect),[i,o]=s.useState();if(Vt(()=>{o(new DocumentFragment)},[]),!r.open){const n=i;return n?a.createPortal(t.jsx(Vd,{scope:e.__scopeSelect,children:t.jsx(Sd.Slot,{scope:e.__scopeSelect,children:t.jsx("div",{children:e.children})})}),n):null}return t.jsx(Kd,{...e,ref:n})});Hd.displayName=Wd;var zd=10,[Vd,qd]=Ad(Wd),Ud=$t("SelectContent.RemoveScroll"),Kd=s.forwardRef((e,n)=>{const{__scopeSelect:r,position:i="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:a,onPointerDownOutside:l,side:c,sideOffset:u,align:h,alignOffset:f,arrowPadding:d,collisionBoundary:p,collisionPadding:m,sticky:g,hideWhenDetached:v,avoidCollisions:y,...b}=e,w=Td(Wd,r),[k,x]=s.useState(null),[S,C]=s.useState(null),E=bt(n,e=>x(e)),[A,M]=s.useState(null),[O,N]=s.useState(null),T=Cd(r),[R,D]=s.useState(!1),P=s.useRef(!1);s.useEffect(()=>{if(k)return br(k)},[k]),En();const L=s.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=s.useCallback(()=>L([A,k]),[L,A,k]);s.useEffect(()=>{R&&B()},[R,B]);const{onOpenChange:I,triggerPointerDownPosRef:_}=w;s.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,_]),s.useEffect(()=>{const e=()=>I(!1);return window.addEventListener("blur",e),window.addEventListener("resize",e),()=>{window.removeEventListener("blur",e),window.removeEventListener("resize",e)}},[I]);const[j,F]=kp(e=>{const t=T().filter(e=>!e.disabled),n=t.find(e=>e.ref.current===document.activeElement),r=xp(t,e,n);r&&setTimeout(()=>r.ref.current.focus())}),W=s.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=s.useCallback(()=>k?.focus(),[k]),z=s.useCallback((e,t,n)=>{const r=!P.current&&!n;(void 0!==w.value&&w.value===t||r)&&N(e)},[w.value]),V="popper"===i?Yd:Gd,q=V===Yd?{side:c,sideOffset:u,align:h,alignOffset:f,arrowPadding:d,collisionBoundary:p,collisionPadding:m,sticky:g,hideWhenDetached:v,avoidCollisions:y}:{};return t.jsx(Vd,{scope:r,content:k,viewport:S,onViewportChange:C,itemRefCallback:W,selectedItem:A,onItemLeave:H,itemTextRefCallback:z,focusSelectedItem:B,selectedItemText:O,position:i,isPositioned:R,searchRef:j,children:t.jsx(fr,{as:Ud,allowPinchZoom:!0,children:t.jsx(pn,{asChild:!0,trapped:w.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:Wt(o,e=>{w.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:t.jsx(ln,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:t.jsx(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:Wt(b.onKeyDown,e=>{const t=e.ctrlKey||e.altKey||e.metaKey;if("Tab"===e.key&&e.preventDefault(),t||1!==e.key.length||F(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()}})})})})})})});Kd.displayName="SelectContentImpl";var Gd=s.forwardRef((e,n)=>{const{__scopeSelect:r,onPlaced:i,...o}=e,a=Td(Wd,r),l=qd(Wd,r),[c,u]=s.useState(null),[h,f]=s.useState(null),d=bt(n,e=>f(e)),p=Cd(r),m=s.useRef(!1),g=s.useRef(!0),{viewport:v,selectedItem:y,selectedItemText:b,focusSelectedItem:w}=l,k=s.useCallback(()=>{if(a.trigger&&a.valueNode&&c&&h&&v&&y&&b){const e=a.trigger.getBoundingClientRect(),t=h.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),r=b.getBoundingClientRect();if("rtl"!==a.dir){const i=r.left-t.left,o=n.left-i,s=e.left-o,a=e.width+s,l=Math.max(a,t.width),u=window.innerWidth-zd,h=yd(o,[zd,Math.max(zd,u-l)]);c.style.minWidth=a+"px",c.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,l=Math.max(a,t.width),u=window.innerWidth-zd,h=yd(o,[zd,Math.max(zd,u-l)]);c.style.minWidth=a+"px",c.style.right=h+"px"}const o=p(),s=window.innerHeight-2*zd,l=v.scrollHeight,u=window.getComputedStyle(h),f=parseInt(u.borderTopWidth,10),d=parseInt(u.paddingTop,10),g=parseInt(u.borderBottomWidth,10),w=f+d+l+parseInt(u.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-zd,A=s-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;c.style.bottom="0px";const t=h.clientHeight-v.offsetTop-v.offsetHeight,n=O+Math.max(A,M+(e?C:0)+t+g);c.style.height=n+"px"}else{const e=o.length>0&&y===o[0].ref.current;c.style.top="0px";const t=Math.max(E,f+v.offsetTop+(e?S:0)+M)+N;c.style.height=t+"px",v.scrollTop=O-E+v.offsetTop}c.style.margin=`${zd}px 0`,c.style.minHeight=k+"px",c.style.maxHeight=s+"px",i?.(),requestAnimationFrame(()=>m.current=!0)}},[p,a.trigger,a.valueNode,c,h,v,y,b,a.dir,i]);Vt(()=>k(),[k]);const[x,S]=s.useState();Vt(()=>{h&&S(window.getComputedStyle(h).zIndex)},[h]);const C=s.useCallback(e=>{e&&!0===g.current&&(k(),w?.(),g.current=!1)},[k,w]);return t.jsx($d,{scope:r,contentWrapper:c,shouldExpandOnScrollRef:m,onScrollButtonChange:C,children:t.jsx("div",{ref:u,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:x},children:t.jsx(Zt.div,{...o,ref:d,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Gd.displayName="SelectItemAlignedPosition";var Yd=s.forwardRef((e,n)=>{const{__scopeSelect:r,align:i="start",collisionPadding:o=zd,...s}=e,a=Od(r);return t.jsx(Os,{...a,...s,ref:n,align:i,collisionPadding:o,style:{boxSizing:"border-box",...s.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)"}})});Yd.displayName="SelectPopperPosition";var[$d,Xd]=Ad(Wd,{}),Jd="SelectViewport",Qd=s.forwardRef((e,n)=>{const{__scopeSelect:r,nonce:i,...o}=e,a=qd(Jd,r),l=Xd(Jd,r),c=bt(n,a.onViewportChange),u=s.useRef(0);return t.jsxs(t.Fragment,{children:[t.jsx("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}),t.jsx(Sd.Slot,{scope:r,children:t.jsx(Zt.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:c,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:Wt(o.onScroll,e=>{const t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=l;if(r?.current&&n){const e=Math.abs(u.current-t.scrollTop);if(e>0){const r=window.innerHeight-2*zd,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")}}}u.current=t.scrollTop})})})]})});Qd.displayName=Jd;var Zd="SelectGroup",[ep,tp]=Ad(Zd);s.forwardRef((e,n)=>{const{__scopeSelect:r,...i}=e,o=Kt();return t.jsx(ep,{scope:r,id:o,children:t.jsx(Zt.div,{role:"group","aria-labelledby":o,...i,ref:n})})}).displayName=Zd;var np="SelectLabel",rp=s.forwardRef((e,n)=>{const{__scopeSelect:r,...i}=e,o=tp(np,r);return t.jsx(Zt.div,{id:o.id,...i,ref:n})});rp.displayName=np;var ip="SelectItem",[op,sp]=Ad(ip),ap=s.forwardRef((e,n)=>{const{__scopeSelect:r,value:i,disabled:o=!1,textValue:a,...l}=e,c=Td(ip,r),u=qd(ip,r),h=c.value===i,[f,d]=s.useState(a??""),[p,m]=s.useState(!1),g=bt(n,e=>u.itemRefCallback?.(e,i,o)),v=Kt(),y=s.useRef("touch"),b=()=>{o||(c.onValueChange(i),c.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 t.jsx(op,{scope:r,value:i,disabled:o,textId:v,isSelected:h,onItemTextChange:s.useCallback(e=>{d(t=>t||(e?.textContent??"").trim())},[]),children:t.jsx(Sd.ItemSlot,{scope:r,value:i,disabled:o,textValue:f,children:t.jsx(Zt.div,{role:"option","aria-labelledby":v,"data-highlighted":p?"":void 0,"aria-selected":h&&p,"data-state":h?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...l,ref:g,onFocus:Wt(l.onFocus,()=>m(!0)),onBlur:Wt(l.onBlur,()=>m(!1)),onClick:Wt(l.onClick,()=>{"mouse"!==y.current&&b()}),onPointerUp:Wt(l.onPointerUp,()=>{"mouse"===y.current&&b()}),onPointerDown:Wt(l.onPointerDown,e=>{y.current=e.pointerType}),onPointerMove:Wt(l.onPointerMove,e=>{y.current=e.pointerType,o?u.onItemLeave?.():"mouse"===y.current&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Wt(l.onPointerLeave,e=>{e.currentTarget===document.activeElement&&u.onItemLeave?.()}),onKeyDown:Wt(l.onKeyDown,e=>{""!==u.searchRef?.current&&" "===e.key||(kd.includes(e.key)&&b()," "===e.key&&e.preventDefault())})})})})});ap.displayName=ip;var lp="SelectItemText",cp=s.forwardRef((e,n)=>{const{__scopeSelect:r,className:i,style:o,...l}=e,c=Td(lp,r),u=qd(lp,r),h=sp(lp,r),f=Dd(lp,r),[d,p]=s.useState(null),m=bt(n,e=>p(e),h.onItemTextChange,e=>u.itemTextRefCallback?.(e,h.value,h.disabled)),g=d?.textContent,v=s.useMemo(()=>t.jsx("option",{value:h.value,disabled:h.disabled,children:g},h.value),[h.disabled,h.value,g]),{onNativeOptionAdd:y,onNativeOptionRemove:b}=f;return Vt(()=>(y(v),()=>b(v)),[y,b,v]),t.jsxs(t.Fragment,{children:[t.jsx(Zt.span,{id:h.textId,...l,ref:m}),h.isSelected&&c.valueNode&&!c.valueNodeHasChildren?a.createPortal(l.children,c.valueNode):null]})});cp.displayName=lp;var up="SelectItemIndicator",hp=s.forwardRef((e,n)=>{const{__scopeSelect:r,...i}=e;return sp(up,r).isSelected?t.jsx(Zt.span,{"aria-hidden":!0,...i,ref:n}):null});hp.displayName=up;var fp="SelectScrollUpButton",dp=s.forwardRef((e,n)=>{const r=qd(fp,e.__scopeSelect),i=Xd(fp,e.__scopeSelect),[o,a]=s.useState(!1),l=bt(n,i.onScrollButtonChange);return Vt(()=>{if(r.viewport&&r.isPositioned){let e=function(){const e=t.scrollTop>0;a(e)};const t=r.viewport;return e(),t.addEventListener("scroll",e),()=>t.removeEventListener("scroll",e)}},[r.viewport,r.isPositioned]),o?t.jsx(gp,{...e,ref:l,onAutoScroll:()=>{const{viewport:e,selectedItem:t}=r;e&&t&&(e.scrollTop=e.scrollTop-t.offsetHeight)}}):null});dp.displayName=fp;var pp="SelectScrollDownButton",mp=s.forwardRef((e,n)=>{const r=qd(pp,e.__scopeSelect),i=Xd(pp,e.__scopeSelect),[o,a]=s.useState(!1),l=bt(n,i.onScrollButtonChange);return Vt(()=>{if(r.viewport&&r.isPositioned){let e=function(){const e=t.scrollHeight-t.clientHeight,n=Math.ceil(t.scrollTop)<e;a(n)};const t=r.viewport;return e(),t.addEventListener("scroll",e),()=>t.removeEventListener("scroll",e)}},[r.viewport,r.isPositioned]),o?t.jsx(gp,{...e,ref:l,onAutoScroll:()=>{const{viewport:e,selectedItem:t}=r;e&&t&&(e.scrollTop=e.scrollTop+t.offsetHeight)}}):null});mp.displayName=pp;var gp=s.forwardRef((e,n)=>{const{__scopeSelect:r,onAutoScroll:i,...o}=e,a=qd("SelectScrollButton",r),l=s.useRef(null),c=Cd(r),u=s.useCallback(()=>{null!==l.current&&(window.clearInterval(l.current),l.current=null)},[]);return s.useEffect(()=>()=>u(),[u]),Vt(()=>{const e=c().find(e=>e.ref.current===document.activeElement);e?.ref.current?.scrollIntoView({block:"nearest"})},[c]),t.jsx(Zt.div,{"aria-hidden":!0,...o,ref:n,style:{flexShrink:0,...o.style},onPointerDown:Wt(o.onPointerDown,()=>{null===l.current&&(l.current=window.setInterval(i,50))}),onPointerMove:Wt(o.onPointerMove,()=>{a.onItemLeave?.(),null===l.current&&(l.current=window.setInterval(i,50))}),onPointerLeave:Wt(o.onPointerLeave,()=>{u()})})}),vp=s.forwardRef((e,n)=>{const{__scopeSelect:r,...i}=e;return t.jsx(Zt.div,{"aria-hidden":!0,...i,ref:n})});vp.displayName="SelectSeparator";var yp="SelectArrow";s.forwardRef((e,n)=>{const{__scopeSelect:r,...i}=e,o=Od(r),s=Td(yp,r),a=qd(yp,r);return s.open&&"popper"===a.position?t.jsx(Ns,{...o,...i,ref:n}):null}).displayName=yp;var bp=s.forwardRef(({__scopeSelect:e,value:n,...r},i)=>{const o=s.useRef(null),a=bt(i,o),l=bd(n);return s.useEffect(()=>{const e=o.current;if(!e)return;const t=window.HTMLSelectElement.prototype,r=Object.getOwnPropertyDescriptor(t,"value").set;if(l!==n&&r){const t=new Event("change",{bubbles:!0});r.call(e,n),e.dispatchEvent(t)}},[l,n]),t.jsx(Zt.select,{...r,style:{...Ts,...r.style},ref:a,defaultValue:n})});function wp(e){return""===e||void 0===e}function kp(e){const t=tn(e),n=s.useRef(""),r=s.useRef(0),i=s.useCallback(e=>{const i=n.current+e;t(i),function e(t){n.current=t,window.clearTimeout(r.current),""!==t&&(r.current=window.setTimeout(()=>e(""),1e3))}(i)},[t]),o=s.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return s.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,o]}function xp(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}bp.displayName="SelectBubbleInput";var Sp=Bd,Cp=jd,Ep=Fd,Ap=Hd,Mp=Qd,Op=rp,Np=ap,Tp=cp,Rp=hp,Dp=dp,Pp=mp,Lp=vp,Bp=Pd,Ip=_d,_p=s.forwardRef(function(e,t){var n=e.className,r=e.children,i=H(e,["className","children"]);return s.createElement(Sp,Object.assign({ref:t,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",n)},i),r,s.createElement(Cp,{asChild:!0},s.createElement($,{className:"h-4 w-4 opacity-50"})))});_p.displayName=Sp.displayName;var jp=s.forwardRef(function(e,t){var n=e.className,r=H(e,["className"]);return s.createElement(Dp,Object.assign({ref:t,className:mt("flex cursor-default items-center justify-center py-1",n)},r),s.createElement(Q,{className:"h-4 w-4"}))});jp.displayName=Dp.displayName;var Fp=s.forwardRef(function(e,t){var n=e.className,r=H(e,["className"]);return s.createElement(Pp,Object.assign({ref:t,className:mt("flex cursor-default items-center justify-center py-1",n)},r),s.createElement($,{className:"h-4 w-4"}))});Fp.displayName=Pp.displayName;var Wp=s.forwardRef(function(e,t){var n=e.className,r=e.children,i=e.position,o=void 0===i?"popper":i,a=H(e,["className","children","position"]);return s.createElement(Ep,null,s.createElement(Ap,Object.assign({ref:t,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"===o&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",n),position:o},a),s.createElement(jp,null),s.createElement(Mp,{className:mt("p-1","popper"===o&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]")},r),s.createElement(Fp,null)))});Wp.displayName=Ap.displayName;var Hp=s.forwardRef(function(e,t){var n=e.className,r=H(e,["className"]);return s.createElement(Op,Object.assign({ref:t,className:mt("py-1.5 pl-8 pr-2 text-sm font-semibold",n)},r))});Hp.displayName=Op.displayName;var zp=s.forwardRef(function(e,t){var n=e.className,r=e.children,i=H(e,["className","children"]);return s.createElement(Np,Object.assign({ref:t,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",n)},i),s.createElement("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center"},s.createElement(Rp,null,s.createElement(Y,{className:"h-4 w-4"}))),s.createElement(Tp,null,r))});zp.displayName=Np.displayName;var Vp=s.forwardRef(function(e,t){var n=e.className,r=H(e,["className"]);return s.createElement(Lp,Object.assign({ref:t,className:mt("-mx-1 my-1 h-px bg-muted",n)},r))});Vp.displayName=Lp.displayName;var qp="Switch",[Up,Kp]=Ht(qp),[Gp,Yp]=Up(qp),$p=s.forwardRef((e,n)=>{const{__scopeSwitch:r,name:i,checked:o,defaultChecked:a,required:l,disabled:c,value:u="on",onCheckedChange:h,form:f,...d}=e,[p,m]=s.useState(null),g=bt(n,e=>m(e)),v=s.useRef(!1),y=!p||(f||!!p.closest("form")),[b,w]=Yt({prop:o,defaultProp:a??!1,onChange:h,caller:qp});return t.jsxs(Gp,{scope:r,checked:b,disabled:c,children:[t.jsx(Zt.button,{type:"button",role:"switch","aria-checked":b,"aria-required":l,"data-state":Zp(b),"data-disabled":c?"":void 0,disabled:c,value:u,...d,ref:g,onClick:Wt(e.onClick,e=>{w(e=>!e),y&&(v.current=e.isPropagationStopped(),v.current||e.stopPropagation())})}),y&&t.jsx(Qp,{control:p,bubbles:!v.current,name:i,value:u,checked:b,required:l,disabled:c,form:f,style:{transform:"translateX(-100%)"}})]})});$p.displayName=qp;var Xp="SwitchThumb",Jp=s.forwardRef((e,n)=>{const{__scopeSwitch:r,...i}=e,o=Yp(Xp,r);return t.jsx(Zt.span,{"data-state":Zp(o.checked),"data-disabled":o.disabled?"":void 0,...i,ref:n})});Jp.displayName=Xp;var Qp=s.forwardRef(({__scopeSwitch:e,control:n,checked:r,bubbles:i=!0,...o},a)=>{const l=s.useRef(null),c=bt(l,a),u=bd(r),h=as(n);return s.useEffect(()=>{const e=l.current;if(!e)return;const t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,"checked").set;if(u!==r&&n){const t=new Event("click",{bubbles:i});n.call(e,r),e.dispatchEvent(t)}},[u,r,i]),t.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:r,...o,tabIndex:-1,ref:c,style:{...o.style,...h,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});function Zp(e){return e?"checked":"unchecked"}Qp.displayName="SwitchBubbleInput";var em=$p,tm=Jp,nm=s.forwardRef(function(e,t){var n=e.className,r=H(e,["className"]);return s.createElement(em,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",n)},r,{ref:t}),s.createElement(tm,{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")}))});nm.displayName=em.displayName;var rm=s.forwardRef(function(e,t){var n=e.className,r=H(e,["className"]);return s.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",n),ref:t},r))});rm.displayName="Textarea";var im=Zr,om=ei,sm=ti,am=s.forwardRef(function(e,t){var n=e.className,r=H(e,["className"]);return s.createElement(ni,Object.assign({ref:t,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",n)},r))});am.displayName=ni.displayName;var lm=s.forwardRef(function(e,t){var n=e.className,r=e.children,i=H(e,["className","children"]);return s.createElement(sm,null,s.createElement(am,null),s.createElement(ri,Object.assign({ref:t,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]",n)},i),r,s.createElement(si,{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"},s.createElement(we,{className:"h-4 w-4"}),s.createElement("span",{className:"sr-only"},"Close"))))});lm.displayName=ri.displayName;var cm=function(e){var t=e.className,n=H(e,["className"]);return s.createElement("div",Object.assign({className:mt("flex flex-col space-y-1.5 text-center sm:text-left",t)},n))};cm.displayName="DialogHeader";var um=function(e){var t=e.className,n=H(e,["className"]);return s.createElement("div",Object.assign({className:mt("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t)},n))};um.displayName="DialogFooter";var hm=s.forwardRef(function(e,t){var n=e.className,r=H(e,["className"]);return s.createElement(ii,Object.assign({ref:t,className:mt("text-lg font-semibold leading-none tracking-tight",n)},r))});hm.displayName=ii.displayName;var fm,dm=s.forwardRef(function(e,t){var n=e.className,r=H(e,["className"]);return s.createElement(oi,Object.assign({ref:t,className:mt("text-sm text-muted-foreground",n)},r))});function pm(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(mm(t)){do{r++,i+=String.fromCharCode(t),t=e.charCodeAt(r)}while(mm(t));return s=15}if(gm(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(gm(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&&!gm(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++,gm(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||!vm(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&&vm(e.charCodeAt(r));)r++;if(r<e.length&&46===e.charCodeAt(r)){if(!(++r<e.length&&vm(e.charCodeAt(r))))return h=3,e.substring(t,r);for(r++;r<e.length&&vm(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&&vm(e.charCodeAt(r))){for(r++;r<e.length&&vm(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(mm(e)||gm(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 mm(e){return 32===e||9===e}function gm(e){return 10===e||13===e}function vm(e){return e>=48&&e<=57}dm.displayName=oi.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"}(fm||(fm={}));var ym,bm,wm,km=new Array(20).fill(0).map(function(e,t){return" ".repeat(t)}),xm=200,Sm={" ":{"\n":new Array(xm).fill(0).map(function(e,t){return"\n"+" ".repeat(t)}),"\r":new Array(xm).fill(0).map(function(e,t){return"\r"+" ".repeat(t)}),"\r\n":new Array(xm).fill(0).map(function(e,t){return"\r\n"+" ".repeat(t)})},"\t":{"\n":new Array(xm).fill(0).map(function(e,t){return"\n"+"\t".repeat(t)}),"\r":new Array(xm).fill(0).map(function(e,t){return"\r"+"\t".repeat(t)}),"\r\n":new Array(xm).fill(0).map(function(e,t){return"\r\n"+"\t".repeat(t)})}},Cm=["\n","\r","\r\n"];function Em(e,t,n){var r,i,o,s,a;if(t){for(s=t.offset,a=s+t.length,o=s;o>0&&!Mm(e,o-1);)o--;for(var l=a;l<e.length&&!Mm(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===km[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=Cm.includes(h),d=0,p=0;n.insertSpaces?c=null!==(u=km[n.tabSize||4])&&void 0!==u?u:Am(km[1],n.tabSize||4):c="\t";var m="\t"===c?"\t":" ",g=pm(i,!1),v=!1;function y(){if(d>1)return Am(h,d)+Am(c,r+p);var e=c.length*(r+p);return!f||e>Sm[m][h].length?h+Am(c,r+p):e<=0?h:Sm[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(Am(h,d),0,0),17!==x){var S=g.getTokenOffset()+o;k(c.length*r<20&&n.insertSpaces?km[c.length*r]:Am(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(km[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=km[1]);else if(4===E)3!==x&&p--,n.keepLines&&d>0||!n.keepLines&&3!==x?A=y():n.keepLines&&(A=km[1]);else{switch(x){case 3:case 1:p++,A=n.keepLines&&d>0||!n.keepLines?y():km[1];break;case 5:A=n.keepLines&&d>0||!n.keepLines?y():km[1];break;case 12:A=y();break;case 13:d>0?A=y():M||(A=km[1]);break;case 6:n.keepLines&&d>0?A=y():M||(A=km[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=km[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 Am(e,t){for(var n="",r=0;r<t;r++)n+=e;return n}function Mm(e,t){return-1!=="\r\n".indexOf(e.charAt(t))}!function(e){e.DEFAULT={allowTrailingComma:!1}}(ym||(ym={})),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"}(bm||(bm={})),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"}(wm||(wm={}));var Om,Nm=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:ym.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]:ym.DEFAULT,r=pm(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 Tm(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 Rm(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=Nm(t,n,{allowTrailingComma:!0,disallowComments:!1});return n.length?{ok:!1,message:Tm(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 Dm(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,n=(e||"").toString(),r=[];if(Nm(n,r,{allowTrailingComma:!0,disallowComments:!1}),r.length)return{ok:!1,message:Tm(n,r)};for(var i=function(e,t,n){return Em(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 Pm(){return Pm=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},Pm.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"}(Om||(Om={}));var Lm=[],Bm=[];function Im(e){if(e<768)return!1;for(var t=0,n=Lm.length;;){var r=t+n>>1;if(e<Lm[r])n=r;else{if(!(e>=Bm[r]))return!0;t=r+1}if(t==n)return!1}}function _m(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?Bm:Lm).push(n+=e[t])}();function jm(e,t){return(!(arguments.length>2&&void 0!==arguments[2])||arguments[2]?Fm:Wm)(e,t,!(arguments.length>3&&void 0!==arguments[3])||arguments[3])}function Fm(e,t,n){if(t==e.length)return t;t&&zm(e.charCodeAt(t))&&Vm(e.charCodeAt(t-1))&&t--;var r=Hm(e,t);for(t+=qm(r);t<e.length;){var i=Hm(e,t);if(8205==r||8205==i||n&&Im(i))t+=qm(i),r=i;else{if(!_m(i))break;for(var o=0,s=t-2;s>=0&&_m(Hm(e,s));)o++,s-=2;if(o%2==0)break;t+=2}}return t}function Wm(e,t,n){for(;t>0;){var r=Fm(e,t-2,n);if(r<t)return r;t--}return 0}function Hm(e,t){var n=e.charCodeAt(t);if(!Vm(n)||t+1==e.length)return n;var r=e.charCodeAt(t+1);return zm(r)?r-56320+(n-55296<<10)+65536:n}function zm(e){return e>=56320&&e<57344}function Vm(e){return e>=55296&&e<56320}function qm(e){return e<65536?1:2}var Um=function(){function e(){v(this,e)}return b(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=D(eg(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),Gm.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=D(eg(this,e,t),2);e=n[0],t=n[1];var r=[];return this.decompose(e,t,r,0),Gm.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 Xm(this),i=new Xm(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 Xm(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 Jm(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 Qm(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 Km(t):Gm.from(Km.split(t,[])):e.empty}}])}(),Km=function(){function e(t){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(e){var t,n=-1,r=w(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 v(this,e),(n=g(this,e)).text=t,n.length=r,n}return C(e,Um),b(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 Zm(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($m(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(1&i){var s=r.pop(),a=Ym(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 P(e,"replace",this,3)([t,n,r]);var i=D(eg(this,t,n),2);t=i[0],n=i[1];var o=Ym(this.text,Ym(r.text,$m(this.text,0,t)),n),s=this.length+r.length-(n-t);return o.length<=32?new e(o,s):Gm.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=D(eg(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=w(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=w(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}}])}(),Gm=function(){function e(t,n){var r;v(this,e),(r=g(this,e)).children=t,r.length=n,r.lines=0;var i,o=w(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 C(e,Um),b(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=D(eg(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 P(e,"replace",this,3)([s,l,c])}s=l+1}return P(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=D(eg(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=w(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=D(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=w(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=w(t);try{for(l.s();!(s=l.n()).done;){s.value.flatten(a)}}catch(e){l.e(e)}finally{l.f()}return new Km(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=w(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 Km&&d&&(n=m[m.length-1])instanceof Km&&t.lines+n.lines<=32?(d+=t.lines,p+=t.length+1,m[m.length-1]=new Km(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=w(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 Ym(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 $m(e,t,n){return Ym(e,[""],t,n)}Um.empty=new Km([""],0);var Xm=function(){return b(function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;v(this,e),this.dir=n,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[t],this.offsets=[n>0?1:(t instanceof Km?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 Km?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 Km){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 Km?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)}}])}(),Jm=function(){return b(function e(t,n,r){v(this,e),this.value="",this.done=!1,this.cursor=new Xm(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}}])}(),Qm=function(){return b(function e(t){v(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&&(Um.prototype[Symbol.iterator]=function(){return this.iter()},Xm.prototype[Symbol.iterator]=Jm.prototype[Symbol.iterator]=Qm.prototype[Symbol.iterator]=function(){return this});var Zm=function(){return b(function e(t,n,r,i){v(this,e),this.from=t,this.to=n,this.number=r,this.text=i},[{key:"length",get:function(){return this.to-this.from}}])}();function eg(e,t,n){return[t=Math.max(0,Math.min(e.length,t)),Math.max(t,Math.min(e.length,n))]}function tg(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 ng(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 rg(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode(55296+(e>>10),56320+(1023&e)))}function ig(e){return e<65536?1:2}var og=/\r\n?|\n/,sg=function(e){return e[e.Simple=0]="Simple",e[e.TrackDel=1]="TrackDel",e[e.TrackBefore=2]="TrackBefore",e[e.TrackAfter=3]="TrackAfter",e}(sg||(sg={})),ag=function(){function e(t){v(this,e),this.sections=t}return b(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){hg(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:dg(this,e)}},{key:"mapDesc",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return e.empty?this:fg(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]:sg.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!=sg.Simple&&l>=e&&(n==sg.TrackDel&&r<e&&l>e||n==sg.TrackBefore&&r<e||n==sg.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)}}])}(),lg=function(){function e(t,n){var r;return v(this,e),(r=g(this,e,[t])).inserted=n,r}return C(e,ag),b(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 hg(this,function(t,n,r,i,o){return e=e.replace(r,r+(n-t),o)},!1),e}},{key:"mapDesc",value:function(e){return fg(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(Um.empty);r.push(s?t.slice(o,o+s):Um.empty)}o+=s}return new e(n,r)}},{key:"compose",value:function(e){return this.empty?e:e.empty?this:dg(this,e,!0)}},{key:"map",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return e.empty?this:fg(this,e,t,!0)}},{key:"iterChanges",value:function(e){hg(this,e,arguments.length>1&&void 0!==arguments[1]&&arguments[1])}},{key:"desc",get:function(){return ag.create(this.sections)}},{key:"filter",value:function(t){var n=[],r=[],i=[],o=new pg(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);cg(i,c,-1);var u=-1==o.ins?-1:0==o.off?o.ins:0;cg(n,c,u),u>0&&ug(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);cg(n,f,-1),cg(i,f,-1==o.ins?-1:0==o.off?o.ins:0),o.forward(f),a+=f}}return{changes:new e(n,r),filtered:ag.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&&cg(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=w(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?Um.of(m.split(r||og)):m:Um.empty,v=g.length;if(f==p&&0==v)return;f<s&&l(),f>s&&cg(i,f-s,-1),cg(i,p-f,v),ug(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(Um.empty);r[i]=Um.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 cg(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 ug(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(Um.empty);e.push(n)}}}function hg(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=Um.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 fg(e,t,n){for(var r=[],i=arguments.length>3&&void 0!==arguments[3]&&arguments[3]?[]:null,o=new pg(e),s=new pg(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);cg(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(cg(r,s.ins,-1);c;){var u=Math.min(o.len,c);o.ins>=0&&a<o.i&&o.len<=u&&(cg(r,0,o.ins),i&&ug(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?lg.createSet(r,i):ag.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()}cg(r,h,a<o.i?o.ins:0),i&&a<o.i&&ug(i,r,o.text),a=o.i,o.forward(o.len-f)}}}function dg(e,t){for(var n=[],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2]?[]:null,i=new pg(e),o=new pg(t),s=!1;;){if(i.done&&o.done)return r?lg.createSet(n,r):ag.create(n);if(0==i.ins)cg(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;cg(n,a,c,s),r&&c&&ug(r,n,o.text)}else-1==o.ins?(cg(n,i.off?0:i.len,a,s),r&&ug(r,n,i.textBit(a))):(cg(n,i.off?0:i.len,o.off?0:o.ins,s),r&&!o.off&&ug(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 cg(n,0,o.ins,s),r&&ug(r,n,o.text),o.next()}}var pg=function(){return b(function e(t){v(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?Um.empty:e[t]}},{key:"textBit",value:function(e){var t=this.set.inserted,n=this.i-2>>1;return n>=t.length&&!e?Um.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)}}])}(),mg=function(){function e(t,n,r){v(this,e),this.from=t,this.to=n,this.flags=r}return b(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 gg.range(e,t);var n=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return gg.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 gg.range(e.anchor,e.head)}},{key:"create",value:function(t,n,r){return new e(t,n,r)}}])}(),gg=function(){function e(t,n){v(this,e),this.ranges=t,this.mainIndex=n}return b(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 mg.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 mg.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?mg.create(t,e,48|i):mg.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 vg(e,t){var n,r=w(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 yg=0,bg=function(){function e(t,n,r,i,o){v(this,e),this.combine=t,this.compareInput=n,this.compare=r,this.isStatic=i,this.id=yg++,this.default=t([]),this.extensions="function"==typeof o?o(this):o}return b(e,[{key:"reader",get:function(){return this}},{key:"of",value:function(e){return new kg([],this,0,e)}},{key:"compute",value:function(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new kg(e,this,1,t)}},{key:"computeN",value:function(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new kg(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}:wg),!!t.static,t.enables)}}])}();function wg(e,t){return e==t||e.length==t.length&&e.every(function(e,n){return e===t[n]})}var kg=function(){return b(function e(t,n,r,i){v(this,e),this.dependencies=t,this.facet=n,this.type=r,this.value=i,this.id=yg++},[{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=w(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)||Sg(e,h)){var n=i(e);if(l?!xg(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=_g(t,c);if(r.dependencies.every(function(n){return n instanceof bg?t.facet(n)===e.facet(n):!(n instanceof Eg)||t.field(n,!1)==e.field(n,!1)})||(l?xg(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 xg(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 Sg(e,t){var n,r=!1,i=w(t);try{for(i.s();!(n=i.n()).done;){1&Ig(e,n.value)&&(r=!0)}}catch(e){i.e(e)}finally{i.f()}return r}var Cg=bg.define({static:!0}),Eg=function(){function e(t,n,r,i,o){v(this,e),this.id=t,this.createF=n,this.updateF=r,this.compareF=i,this.spec=o,this.provides=void 0}return b(e,[{key:"create",value:function(e){var t=this,n=e.facet(Cg).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(Cg),s=r.facet(Cg);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,Cg.of({field:this,create:e})]}},{key:"extension",get:function(){return this}}],[{key:"define",value:function(t){var n=new e(yg++,t.create,t.update,t.compare||function(e,t){return e===t},t);return t.provide&&(n.provides=t.provide(n)),n}}])}(),Ag=4,Mg=3,Og=2,Ng=1;function Tg(e){return function(t){return new Dg(t,e)}}var Rg={highest:Tg(0),high:Tg(Ng),default:Tg(Og),low:Tg(Mg),lowest:Tg(Ag)},Dg=b(function e(t,n){v(this,e),this.inner=t,this.prec=n}),Pg=function(){function e(){v(this,e)}return b(e,[{key:"of",value:function(e){return new Lg(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)}}])}(),Lg=b(function e(t,n){v(this,e),this.compartment=t,this.inner=n}),Bg=function(){function e(t,n,r,i,o,s){for(v(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 b(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=w(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 Lg&&n.delete(e.compartment)}if(i.set(e,s),Array.isArray(e)){var c,u=w(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 Lg){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 Dg)o(e.inner,e.prec);else if(e instanceof Eg)r[s].push(e),e.provides&&o(e.provides,s);else if(e instanceof kg)r[s].push(e),e.facet.extensions&&o(e.facet.extensions,Og);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,Og),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 Eg?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,wg(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=w(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=_g(e,r[o]);if(2==i[o]){var a,l=w(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=w(r);try{for(n.s();!(t=n.n()).done;)Ig(e,t.value)}catch(e){n.e(e)}finally{n.f()}return e.values[s]=a(e),1},update:function(e,n){if(!Sg(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=Sg(e,r),l=i.config.facets[t.id],c=i.facet(t);if(l&&!o&&wg(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 Ig(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 _g(e,t){return 1&t?e.config.staticValues[t>>1]:e.values[t>>1]}var jg=bg.define(),Fg=bg.define({combine:function(e){return e.some(function(e){return e})},static:!0}),Wg=bg.define({combine:function(e){return e.length?e[0]:void 0},static:!0}),Hg=bg.define(),zg=bg.define(),Vg=bg.define(),qg=bg.define({combine:function(e){return!!e.length&&e[0]}}),Ug=function(){return b(function e(t,n){v(this,e),this.type=t,this.value=n},null,[{key:"define",value:function(){return new Kg}}])}(),Kg=function(){return b(function e(){v(this,e)},[{key:"of",value:function(e){return new Ug(this,e)}}])}(),Gg=function(){return b(function e(t){v(this,e),this.map=t},[{key:"of",value:function(e){return new Yg(this,e)}}])}(),Yg=function(){function e(t,n){v(this,e),this.type=t,this.value=n}return b(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 Gg((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=w(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}}])}();Yg.reconfigure=Yg.define(),Yg.appendConfig=Yg.define();var $g=function(){function e(t,n,r,i,o,s){v(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&&vg(r,n.newLength),o.some(function(t){return t.type==e.time})||(this.annotations=o.concat(e.time.of(Date.now())))}return b(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=w(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 Xg(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 Jg(e,t,n){var r,i,o,s;return n?(i=t.changes,o=lg.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:Yg.mapEffects(e.effects,i).concat(Yg.mapEffects(t.effects,o)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function Qg(e,t,n){var r=t.selection,i=tv(t.annotations);return t.userEvent&&(i=i.concat($g.userEvent.of(t.userEvent))),{changes:t.changes instanceof lg?t.changes:lg.of(t.changes||[],n,e.facet(Wg)),selection:r&&(r instanceof gg?r:gg.single(r.anchor,r.head)),effects:tv(t.effects),annotations:i,scrollIntoView:!!t.scrollIntoView}}function Zg(e,t,n){var r=Qg(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=Jg(r,Qg(e,t[i],o?r.changes.newLength:e.doc.length),o)}var s=$g.create(e,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return function(e){for(var t=e.startState,n=t.facet(Vg),r=e,i=n.length-1;i>=0;i--){var o=n[i](e);o&&Object.keys(o).length&&(r=Jg(r,Qg(t,o,e.changes.newLength),!0))}return r==e?e:$g.create(t,e.changes,e.selection,r.effects,r.annotations,r.scrollIntoView)}(n?function(e){var t,n=e.startState,r=!0,i=w(n.facet(Hg));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:Xg(r,o))}}catch(e){i.e(e)}finally{i.f()}if(!0!==r){var s,a;if(!1===r)a=e.changes.invertedDesc,s=lg.empty(n.doc.length);else{var l=e.changes.filter(r);s=l.changes,a=l.filtered.mapDesc(l.changes).invertedDesc}e=$g.create(n,s,e.selection&&e.selection.map(a),Yg.mapEffects(e.effects,a),e.annotations,e.scrollIntoView)}for(var c=n.facet(zg),u=c.length-1;u>=0;u--){var h=c[u](e);e=h instanceof $g?h:Array.isArray(h)&&1==h.length&&h[0]instanceof $g?h[0]:Zg(n,tv(h),!1)}return e}(s):s)}$g.time=Ug.define(),$g.userEvent=Ug.define(),$g.addToHistory=Ug.define(),$g.remote=Ug.define();var ev=[];function tv(e){return null==e?ev:Array.isArray(e)?e:[e]}var nv,rv=function(e){return e[e.Word=0]="Word",e[e.Space=1]="Space",e[e.Other=2]="Other",e}(rv||(rv={})),iv=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;try{nv=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(e){}function ov(e){return function(t){if(!/\S/.test(t))return rv.Space;if(function(e){if(nv)return nv.test(e);for(var t=0;t<e.length;t++){var n=e[t];if(/\w/.test(n)||n>"€"&&(n.toUpperCase()!=n.toLowerCase()||iv.test(n)))return!0}return!1}(t))return rv.Word;for(var n=0;n<e.length;n++)if(t.indexOf(e[n])>-1)return rv.Word;return rv.Other}}var sv=function(){function e(t,n,r,i,o,s){v(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++)Ig(this,a<<1);this.computeSlot=null}return b(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 Ig(this,n),_g(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 Zg(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=w(t.effects);try{for(c.s();!(n=c.n()).done;){var u=n.value;u.is(Pg.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(Yg.reconfigure)?(o=null,a=u.value):u.is(Yg.appendConfig)&&(o=null,a=tv(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=Bg.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(Fg)?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:gg.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=tv(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=Yg.mapEffects(o,c).concat(Yg.mapEffects(tv(a.effects),h))}return{changes:r,selection:gg.create(i,t.mainIndex),effects:o}}},{key:"changes",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return t instanceof lg?t:lg.of(t,this.doc.length,this.facet(e.lineSeparator))}},{key:"toText",value:function(t){return Um.of(t.split(this.facet(e.lineSeparator)||og))}},{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:(Ig(this,t),_g(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 Eg&&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(qg)}},{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=w(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=w(this.facet(jg));try{for(o.s();!(n=o.n()).done;){var s,a=w((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 ov(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=tg(n,s,!1);if(o(n.slice(l,s))!=rv.Word)break;s=l}for(;a<i;){var c=tg(n,a);if(o(n.slice(a,c))!=rv.Word)break;a=c}return s==a?null:gg.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:gg.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=Bg.resolve(t.extensions||[],new Map),r=t.doc instanceof Um?t.doc:Um.of((t.doc||"").split(n.staticFacet(e.lineSeparator)||og)),i=t.selection?t.selection instanceof gg?t.selection:gg.single(t.selection.anchor,t.selection.head):gg.single(0);return vg(i,r.length),n.staticFacet(Fg)||(i=i.asSingle()),new e(n,r,i,n.dynamicSlots.map(function(){return null}),function(e,t){return t.create(e)},null)}}])}();function av(e,t){var n,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i={},o=w(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}sv.allowMultipleSelections=Fg,sv.tabSize=bg.define({combine:function(e){return e.length?e[0]:4}}),sv.lineSeparator=Wg,sv.readOnly=qg,sv.phrases=bg.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]})}}),sv.languageData=jg,sv.changeFilter=Hg,sv.transactionFilter=zg,sv.transactionExtender=Vg,Pg.reconfigure=Yg.define();var lv=function(){return b(function e(){v(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 uv.create(e,t,this)}}])}();function cv(e,t){return e==t||e.constructor==t.constructor&&e.eq(t)}lv.prototype.startSide=lv.prototype.endSide=0,lv.prototype.point=!1,lv.prototype.mapMode=sg.TrackDel;var uv=function(){function e(t,n,r){v(this,e),this.from=t,this.to=n,this.value=r}return b(e,null,[{key:"create",value:function(t,n,r){return new e(t,n,r)}}])}();function hv(e,t){return e.from-t.from||e.value.startSide-t.value.startSide}var fv=function(){function e(t,n,r,i){v(this,e),this.from=t,this.to=n,this.value=r,this.maxPoint=i}return b(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}}}])}(),dv=function(){function e(t,n,r,i){v(this,e),this.chunkPos=t,this.chunk=n,this.nextLayer=r,this.maxPoint=i}return b(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=w(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(hv)),this.isEmpty)return r.length?e.of(r):this;for(var h=new gv(this,null,-1).goto(0),f=0,d=[],p=new pv;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(uv.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 vv.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 vv.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=mv(o,s,n),l=new bv(o,a,i),c=new bv(s,a,i);n.iterGaps(function(e,t,n){return wv(l,e,c,t,n,r)}),n.empty&&0==n.length&&wv(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=mv(i,o),a=new bv(i,s,0).goto(n),l=new bv(o,s,0).goto(n);;){if(a.to!=l.to||!kv(a.active,l.active)||a.point&&(!l.point||!cv(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 bv(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 pv,i=w(e instanceof uv?[e]:n?function(e){if(e.length>1)for(var t=e[0],n=1;n<e.length;n++){var r=e[n];if(hv(t,r)>0)return e.slice().sort(hv);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}}])}();dv.empty=new dv([],[],null,-1),dv.empty.nextLayer=dv.empty;var pv=function(){function e(){v(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 b(e,[{key:"finishChunk",value:function(e){this.chunks.push(new fv(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(dv.empty)}},{key:"finishInner",value:function(e){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return e;var t=dv.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}])}();function mv(e,t,n){var r,i=new Map,o=w(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=w(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 gv=function(){return b(function e(t,n,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;v(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}}])}(),vv=function(){function e(t){v(this,e),this.heap=t}return b(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=w(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--)yv(this.heap,i);return this.next(),this}},{key:"forward",value:function(e,t){var n,r=w(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--)yv(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(),yv(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 gv(s,n,r,o));return 1==i.length?i[0]:new e(i)}}])}();function yv(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 bv=function(){return b(function e(t,n,r){v(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=vv.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){xv(this.active,e),xv(this.activeTo,e),xv(this.activeRank,e),this.minActive=Cv(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++;Sv(this.active,t,r),Sv(this.activeTo,t,i),Sv(this.activeRank,t,o),e&&Sv(e,t,this.cursor.from),this.minActive=Cv(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&&xv(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 wv(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&&cv(e.point,n.point)&&kv(e.activeForPoint(e.to),n.activeForPoint(n.to))||o.comparePoint(a,p,e.point,n.point),u=!1):(u&&o.boundChange(a),p>a&&!kv(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 kv(e,t){if(e.length!=t.length)return!1;for(var n=0;n<e.length;n++)if(e[n]!=t[n]&&!cv(e[n],t[n]))return!1;return!0}function xv(e,t){for(var n=t,r=e.length-1;n<r;n++)e[n]=e[n+1];e.pop()}function Sv(e,t,n){for(var r=e.length-1;r>=t;r--)e[r+1]=e[r];e[t]=n}function Cv(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 Ev(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=tg(e,i));return r}function Av(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=tg(e,i)}return!0===r?-1:e.length}for(var Mv="undefined"==typeof Symbol?"__ͼ":Symbol.for("ͼ"),Ov="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),Nv="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{},Tv=function(){return b(function e(t,n){v(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"==I(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=Nv[Mv]||1;return Nv[Mv]=e+1,"ͼ"+e.toString(36)}},{key:"mount",value:function(e,t,n){var r=e[Ov],i=n&&n.nonce;r?i&&r.setNonce(i):r=new Dv(e,i),r.mount(Array.isArray(t)?t:[t],e)}}])}(),Rv=new Map,Dv=function(){return b(function e(t,n){v(this,e);var r=t.ownerDocument||t,i=r.defaultView;if(!t.head&&t.adoptedStyleSheets&&i.CSSStyleSheet){var o=Rv.get(r);if(o)return t[Ov]=o;this.sheet=new i.CSSStyleSheet,Rv.set(r,this)}else this.styleTag=r.createElement("style"),n&&this.styleTag.setAttribute("nonce",n);this.modules=[],t[Ov]=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(L(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)}}])}(),Pv={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:"'"},Lv={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Bv="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),Iv="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),_v=0;_v<10;_v++)Pv[48+_v]=Pv[96+_v]=String(_v);for(_v=1;_v<=24;_v++)Pv[_v+111]="F"+_v;for(_v=65;_v<=90;_v++)Pv[_v]=String.fromCharCode(_v+32),Lv[_v]=String.fromCharCode(_v);for(var jv in Pv)Lv.hasOwnProperty(jv)||(Lv[jv]=Pv[jv]);function Fv(){var e=arguments[0];"string"==typeof e&&(e=document.createElement(e));var t=1,n=arguments[1];if(n&&"object"==I(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++)Wv(e,arguments[t]);return e}function Wv(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++)Wv(e,t[n])}}var Hv="undefined"!=typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},zv="undefined"!=typeof document?document:{documentElement:{style:{}}},Vv=/Edge\/(\d+)/.exec(Hv.userAgent),qv=/MSIE \d/.test(Hv.userAgent),Uv=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Hv.userAgent),Kv=!!(qv||Uv||Vv),Gv=!Kv&&/gecko\/(\d+)/i.test(Hv.userAgent),Yv=!Kv&&/Chrome\/(\d+)/.exec(Hv.userAgent),$v="webkitFontSmoothing"in zv.documentElement.style,Xv=!Kv&&/Apple Computer/.test(Hv.vendor),Jv=Xv&&(/Mobile\/\w+/.test(Hv.userAgent)||Hv.maxTouchPoints>2),Qv={mac:Jv||/Mac/.test(Hv.platform),windows:/Win/.test(Hv.platform),linux:/Linux|X11/.test(Hv.platform),ie:Kv,ie_version:qv?zv.documentMode||6:Uv?+Uv[1]:Vv?+Vv[1]:0,gecko:Gv,gecko_version:Gv?+(/Firefox\/(\d+)/.exec(Hv.userAgent)||[0,0])[1]:0,chrome:!!Yv,chrome_version:Yv?+Yv[1]:0,ios:Jv,android:/Android\b/.test(Hv.userAgent),webkit:$v,webkit_version:$v?+(/\bAppleWebKit\/(\d+)/.exec(Hv.userAgent)||[0,0])[1]:0,safari:Xv,safari_version:Xv?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Hv.userAgent)||[0,0])[1]:0,tabSize:null!=zv.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};function Zv(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 ey=Object.create(null);function ty(e,t,n){if(e==t)return!0;e||(e=ey),t||(t=ey);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 ny(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 ry(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 iy=function(){return b(function e(){v(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){}}])}(),oy=function(e){return e[e.Text=0]="Text",e[e.WidgetBefore=1]="WidgetBefore",e[e.WidgetAfter=2]="WidgetAfter",e[e.WidgetRange=3]="WidgetRange",e}(oy||(oy={})),sy=function(){function e(t,n,r,i){var o;return v(this,e),(o=g(this,e)).startSide=t,o.endSide=n,o.widget=r,o.spec=i,o}return C(e,lv),b(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 ay(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 cy(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=uy(e,r);t=(i.start?r?-3e8:-1:5e8)-1,n=1+(i.end?r?2e8:1:-6e8)}return new cy(e,t,n,r,e.widget||null,!0)}},{key:"line",value:function(e){return new ly(e)}},{key:"set",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return dv.of(e,t)}}])}();sy.none=dv.empty;var ay=function(){function e(t){var n;v(this,e);var r=uy(t);return(n=g(this,e,[r.start?-1:5e8,r.end?1:-6e8,null,t])).tagName=t.tagName||"span",n.attrs=t.class&&t.attributes?Zv(t.attributes,{class:t.class}):t.class?{class:t.class}:t.attributes||ey,n}return C(e,sy),b(e,[{key:"eq",value:function(t){return this==t||t instanceof e&&this.tagName==t.tagName&&ty(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 P(e,"range",this,3)([t,n])}}])}();ay.prototype.point=!1;var ly=function(){function e(t){return v(this,e),g(this,e,[-2e8,-2e8,null,t])}return C(e,sy),b(e,[{key:"eq",value:function(t){return t instanceof e&&this.spec.class==t.spec.class&&ty(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 P(e,"range",this,3)([t,n])}}])}();ly.prototype.mapMode=sg.TrackBefore,ly.prototype.point=!0;var cy=function(){function e(t,n,r,i,o,s){var a;return v(this,e),(a=g(this,e,[n,r,o,t])).block=i,a.isReplace=s,a.mapMode=i?n<=0?sg.TrackBefore:sg.TrackAfter:sg.TrackDel,a}return C(e,sy),b(e,[{key:"type",get:function(){return this.startSide!=this.endSide?oy.WidgetRange:this.startSide<=0?oy.WidgetBefore:oy.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 P(e,"range",this,3)([t,n])}}])}();function uy(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 hy(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)}cy.prototype.point=!0;var fy=function(){function e(t,n){var r;return v(this,e),(r=g(this,e)).tagName=t,r.attributes=n,r}return C(e,lv),b(e,[{key:"eq",value:function(t){return t==this||t instanceof e&&this.tagName==t.tagName&&ty(this.attributes,t.attributes)}}],[{key:"create",value:function(t){return new e(t.tagName,t.attributes||ey)}},{key:"set",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return dv.of(e,t)}}])}();function dy(e){return(11==e.nodeType?e.getSelection?e:e.ownerDocument:e).getSelection()}function py(e,t){return!!t&&(e==t||e.contains(1!=t.nodeType?t.parentNode:t))}function my(e,t){if(!t.anchorNode)return!1;try{return py(e,t.anchorNode)}catch(e){return!1}}function gy(e){return 3==e.nodeType?Ny(e,0,e.nodeValue.length).getClientRects():1==e.nodeType?e.getClientRects():[]}function vy(e,t,n,r){return!!n&&(wy(e,t,n,r,-1)||wy(e,t,n,r,1))}function yy(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t}function by(e){return 1==e.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(e.nodeName)}function wy(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:ky(e))){if("DIV"==e.nodeName)return!1;var o=e.parentNode;if(!o||1!=o.nodeType)return!1;t=yy(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?ky(e):0}}}function ky(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function xy(e,t){var n=t?e.left:e.right;return{left:n,right:n,top:e.top,bottom:e.bottom}}function Sy(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 Cy(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}}fy.prototype.startSide=fy.prototype.endSide=-1;var Ey,Ay=function(){return b(function e(){v(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?ky(t):0),n,Math.min(e.focusOffset,n?ky(n):0))}},{key:"set",value:function(e,t,n,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=r}}])}(),My=null;function Oy(e){if(e.setActive)return e.setActive();if(My)return e.focus(My);for(var t=[],n=e;n&&(t.push(n,n.scrollTop,n.scrollLeft),n!=n.ownerDocument);n=n.parentNode);if(e.focus(null==My?{get preventScroll(){return My={preventScroll:!0},!0}}:void 0),!My){My=!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 Ny(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t,r=Ey||(Ey=document.createRange());return r.setEnd(e,n),r.setStart(e,t),r}function Ty(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 Ry(e){return e.scrollTop>Math.max(1,e.scrollHeight-e.clientHeight-4)}function Dy(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=ky(n=n.childNodes[r-1])}else{if(!n.parentNode||by(n))return null;r=yy(n),n=n.parentNode}}}function Py(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||by(n))return null;r=yy(n)+1,n=n.parentNode}}}Qv.safari&&Qv.safari_version>=26&&(My=!1);var Ly=function(){function e(t,n){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];v(this,e),this.node=t,this.offset=n,this.precise=r}return b(e,null,[{key:"before",value:function(t,n){return new e(t.parentNode,yy(t),n)}},{key:"after",value:function(t,n){return new e(t.parentNode,yy(t)+1,n)}}])}(),By=function(e){return e[e.LTR=0]="LTR",e[e.RTL=1]="RTL",e}(By||(By={})),Iy=By.LTR,_y=By.RTL;function jy(e){for(var t=[],n=0;n<e.length;n++)t.push(1<<+e[n]);return t}for(var Fy=jy("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),Wy=jy("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),Hy=Object.create(null),zy=[],Vy=0,qy=["()","[]","{}"];Vy<qy.length;Vy++){var Uy=qy[Vy],Ky=Uy.charCodeAt(0),Gy=Uy.charCodeAt(1);Hy[Ky]=Gy,Hy[Gy]=-Ky}function Yy(e){return e<=247?Fy[e]:1424<=e&&e<=1524?2:1536<=e&&e<=1785?Wy[e-1536]:1774<=e&&e<=2220?4:8192<=e&&e<=8204?256:64336<=e&&e<=65023?4:1}var $y=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/,Xy=function(){return b(function e(t,n,r){v(this,e),this.from=t,this.to=n,this.level=r},[{key:"dir",get:function(){return this.level%2?_y:Iy}},{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 Jy(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||!Jy(r.inner,i.inner))return!1}return!0}var Qy=[];function Zy(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=Qy[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(Qy[v]==a)break e;break}v=o[y++].to}if(c++,d)d.push(g);else g.from>l&&s.push(new Xy(l,g.from,p)),eb(e,g.direction==Iy!=!(p%2)?r+1:r,i,g.inner,g.from,g.to,s),l=g.to;m=g.to}else{if(m==n||(u?Qy[m]!=a:Qy[m]==a))break;m++}d?Zy(e,l,m,r+1,i,d,s):l<m&&s.push(new Xy(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=Qy[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(Qy[O-1]==a)break e;break}O=o[--N].from}if(C)C.push(M);else M.to<b&&s.push(new Xy(M.to,b,E)),eb(e,M.direction==Iy!=!(E%2)?r+1:r,i,M.inner,M.from,M.to,s),b=M.from;A=M.from}else{if(A==t||(k?Qy[A-1]!=a:Qy[A-1]==a))break;A--}C?Zy(e,A,b,r+1,i,C,s):A<b&&s.push(new Xy(A,b,E)),b=A}}function eb(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=Yy(e.charCodeAt(c));512==f?f=u:8==f&&4==h&&(f=16),Qy[c]=4==f?2:f,7&f&&(h=f),u=f}for(var d=s,p=l,m=l;d<a;d++){var g=Qy[d];if(128==g)d<a-1&&p==Qy[d+1]&&24&p?g=Qy[d]=p:Qy[d]=256;else if(64==g){for(var v=d+1;v<a&&64==Qy[v];)v++;for(var y=d&&8==p||v<n&&8==Qy[v]?1==m?1:8:256,b=d;b<v;b++)Qy[b]=y;d=v-1}else 8==g&&1==m&&(Qy[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=Hy[c=e.charCodeAt(p)])if(u<0){for(var m=a-3;m>=0;m-=3)if(zy[m+1]==-u){var g=zy[m+2],v=2&g?i:4&g?1&g?o:i:0;v&&(Qy[p]=Qy[zy[m]]=v),a=m;break}}else{if(189==zy.length)break;zy[a++]=p,zy[a++]=c,zy[a++]=l}else if(2==(h=Qy[p])||1==h){var y=h==i;l=y?0:1;for(var b=a-3;b>=0;b-=3){var w=zy[b+2];if(2&w)break;if(y)zy[b+2]|=2;else{if(4&w)break;zy[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=Qy[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!=Qy[u])break;u++}for(var h=1==o,f=h==(1==(u<t?Qy[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),Qy[--d]=f;l=u}else o=c,l++}}(i,o,r,a),Zy(e,i,o,t,n,r,s)}function tb(e){return[new Xy(0,e,0)]}var nb="";function rb(e,t,n,r,i){var o,s=r.head-e.from,a=Xy.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=tg(e.text,s,l.forward(i,n));(h<l.from||h>l.to)&&(h=c),nb=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?gg.cursor(f.side(!i,n)+e.from,f.forward(i,n)?1:-1,f.level):gg.cursor(h+e.from,l.forward(i,n)?-1:1,l.level)}function ib(e,t,n){for(var r=t;r<n;r++){var i=Yy(e.charCodeAt(r));if(1==i)return Iy;if(2==i||4==i)return _y}return Iy}var ob=bg.define(),sb=bg.define(),ab=bg.define(),lb=bg.define(),cb=bg.define(),ub=bg.define(),hb=bg.define(),fb=bg.define(),db=bg.define(),pb=bg.define({combine:function(e){return e.some(function(e){return e})}}),mb=bg.define({combine:function(e){return e.some(function(e){return e})}}),gb=bg.define(),vb=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];v(this,e),this.range=t,this.y=n,this.x=r,this.yMargin=i,this.xMargin=o,this.isSnapshot=s}return b(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(gg.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}])}(),yb=Yg.define({map:function(e,t){return e.map(t)}}),bb=Yg.define();function wb(e,t,n){var r=e.facet(lb);r.length?r[0](t):window.onerror&&window.onerror(String(t),n,void 0,void 0,t)}var kb=bg.define({combine:function(e){return!e.length||e[0]}}),xb=0,Sb=bg.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})}}),Cb=function(){function e(t,n,r,i,o){v(this,e),this.id=t,this.create=n,this.domEventHandlers=r,this.domEventObservers=i,this.baseExtensions=o(this),this.extension=this.baseExtensions.concat(Sb.of({plugin:this,arg:void 0}))}return b(e,[{key:"of",value:function(e){return this.baseExtensions.concat(Sb.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(xb++,t,i,o,function(e){var t=[];return a&&t.push(Ob.of(function(t){var n=t.plugin(e);return n?a(n):sy.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)}}])}(),Eb=function(){return b(function e(t){v(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(wb(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){wb(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){wb(e.state,t,"CodeMirror plugin crashed")}}},{key:"deactivate",value:function(){this.spec=this.value=null}}])}(),Ab=bg.define(),Mb=bg.define(),Ob=bg.define(),Nb=bg.define(),Tb=bg.define(),Rb=bg.define(),Db=bg.define();function Pb(e,t){var n=e.state.facet(Db);if(!n.length)return n;var r=n.map(function(t){return t instanceof Function?t(e):t}),i=[];return dv.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=ib(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 Lb=bg.define();function Bb(e){var t,n=0,r=0,i=0,o=0,s=w(e.state.facet(Lb));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 Ib=bg.define(),_b=function(){function e(t,n,r,i){v(this,e),this.fromA=t,this.toA=n,this.fromB=r,this.toB=i}return b(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){v(this,e),this.view=t,this.state=n,this.transactions=r,this.flags=0,this.startState=t.state,this.changes=lg.empty(this.startState.doc.length);var i,o=w(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 _b(e,t,n,r))}),this.changedRanges=a}return b(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)}}])}(),Fb=[],Wb=function(){return b(function e(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;v(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 Fb}},{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=w(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=yy(this.dom),r=this.length?e>0:t>0;return new Ly(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 Vb)return e;return null}}],[{key:"get",value:function(e){return e.cmTile}}])}(),Hb=function(){function e(t){var n;return v(this,e),(n=g(this,e,[t,0]))._children=[],n}return C(e,Wb),b(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)){P(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=w(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=zb(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=zb(n);this.length=a}}}])}();function zb(e){var t=e.nextSibling;return e.parentNode.removeChild(e),t}var Vb=function(){function e(t,n){var r;return v(this,e),(r=g(this,e,[n])).view=t,r}return C(e,Hb),b(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=Wb.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 qb)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}}}])}(),qb=function(){function e(t,n){var r;return v(this,e),(r=g(this,e,[t])).wrapper=n,r}return C(e,Hb),b(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}}])}(),Ub=function(){function e(t,n){var r;return v(this,e),(r=g(this,e,[t])).attrs=n,r}return C(e,Hb),b(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&&Kb(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=gy(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 Ly(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=w(n.tile.parent.children);try{for(a.s();!(o=a.n()).done;){var l=o.value;if(s)return new Ly(l.dom,0);l==n.tile&&(s=!0)}}catch(e){a.e(e)}finally{a.f()}}return new Ly(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 Kb(e,t){var n=e.coordsIn(0,1),r=t.coordsIn(0,1);return n&&r&&r.top<n.bottom}for(var Gb=function(){function e(t,n){var r;return v(this,e),(r=g(this,e,[t])).mark=n,r}return C(e,Hb),b(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}}])}(),Yb=function(){function e(t,n){var r;return v(this,e),(r=g(this,e,[t,n.length])).text=n,r}return C(e,Wb),b(e,[{key:"sync",value:function(t){2&this.flags||(P(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?Qv.chrome||Qv.gecko||(e?(r--,o=1):i<n&&(i++,o=-1)):t<0?r--:i<n&&i++;var s=Ny(this.dom,r,i).getClientRects();if(!s.length)return null;var a=s[(o?o<0:t>=0)?0:s.length-1];return Qv.safari&&!o&&0==a.width&&(a=Array.prototype.find.call(s,function(e){return e.width})||a),o?xy(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}}])}(),$b=function(){function e(t,n,r,i){var o;return v(this,e),(o=g(this,e,[t,n,i])).widget=r,o}return C(e,Wb),b(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 xy(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 xy(o,!s)}},{key:"overrideDOMText",get:function(){if(!this.length)return Um.empty;var e=this.root;if(!e)return Um.empty;var t=this.posAtStart;return e.view.state.doc.slice(t,t+this.length)}},{key:"destroy",value:function(){P(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)}}])}(),Xb=function(){function e(t){v(this,e);var n=document.createElement("img");return n.className="cm-widgetBuffer",n.setAttribute("aria-hidden","true"),g(this,e,[n,0,t])}return C(e,Wb),b(e,[{key:"isHidden",get:function(){return!0}},{key:"overrideDOMText",get:function(){return Um.empty}},{key:"coordsIn",value:function(e){return this.dom.getBoundingClientRect()}}])}(),Jb=function(){return b(function e(t){v(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}}])}(),Qb=b(function e(t,n,r,i){v(this,e),this.from=t,this.to=n,this.wrapper=r,this.rank=i}),Zb=function(){return b(function e(t,n,r){v(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 Yb(s.dom,s.text+e)).parent=o):o.append(r||Yb.of(e,null===(i=this.cache.find(Yb))||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)?aw(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 Gb&&s.mark.eq(o.mark))s.dom!=o.dom&&s.setDOM(aw(o.dom)),r=s;else{if(this.cache.reused.get(o)){var a=Wb.get(o.dom);a&&a.setDOM(aw(o.dom))}var l=Gb.of(o.mark,o.dom);r.append(l),r=l}this.cache.reused.set(o,2)}var c=Wb.get(e.text);c&&this.cache.reused.set(c,2);var u=new Yb(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=sw);var r=Ub.start(e,t||(null===(n=this.cache.find(Ub))||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 Gb&&o.mark.eq(a))i=o,t--;else{var l=Gb.of(a,null===(n=r.cache.find(Gb,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&&ow(this.curLine,!1)&&("BR"==e.dom.nodeName||!e.isWidget()||Qv.ios&&ow(this.curLine,!0))||this.curLine.append(this.cache.findWidget(cw,0,32)||new $b(cw.toDOM(),0,cw,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 Qb(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=w(this.wrappers);try{var o=function(){var i=n.value,o=r.lastChild;if(i.from<t.pos&&o instanceof qb&&o.wrapper.eq(i.wrapper))r=o;else{var s=qb.of(i.wrapper,null===(e=t.cache.find(qb,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(Xb,void 0,1);return n&&(n.flags=t),n||new Xb(t)}},{key:"flushBuffer",value:function(){!this.afterWidget||32&this.afterWidget.flags||(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}])}(),ew=function(){return b(function e(t){v(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}}])}(),tw=[$b,Ub,Yb,Gb,Xb,qb,Vb],nw=0;nw<tw.length;nw++)tw[nw].bucket=nw;var rw=function(){return b(function e(t){v(this,e),this.view=t,this.buckets=tw.map(function(){return[]}),this.index=tw.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 $b(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}}])}(),iw=function(){return b(function e(t,n,r,i,o){var s=this;v(this,e),this.view=t,this.decorations=i,this.disallowBlockEffectsFor=o,this.openWidget=!1,this.openMarks=0,this.cache=new rw(t),this.text=new ew(t.state.doc),this.builder=new Zb(this.cache,new Vb(t,t.contentDOM),dv.iter(r)),this.cache.reused.set(n,2),this.old=new Jb(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 Gb&&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?$b.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 Xb)r.cache.add(e);else{if(!(e instanceof Gb))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 Gb&&i.unshift(e.mark)),r.openWidget=!1},leave:function(e){e.isLine()?i.length&&(i.length=o=0):e instanceof Gb&&(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=dv.spans(this.decorations,e,t,{point:function(e,t,s,a,l,c){if(s instanceof cy){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?lw.block:lw.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)||$b.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&&Zv(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=Wb.get(r);if(r==this.view.contentDOM)break;i instanceof Gb?t.push(i):(null==i?void 0:i.isLine())?n=i:i instanceof qb||("DIV"!=r.nodeName||n||r==this.view.contentDOM?n||t.push(Gb.of(new ay({tagName:r.nodeName.toLowerCase(),attributes:ry(r)}),r)):n=new Ub(r,sw))}return{line:n,marks:t}}}])}();function ow(e,t){var n=function(e){var r,i=w(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 sw={class:"cm-line"};function aw(e){var t=Wb.get(e);return t&&t.setDOM(e.cloneNode()),e}var lw=function(){function e(t){var n;return v(this,e),(n=g(this,e)).tag=t,n}return C(e,iy),b(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}}])}();lw.inline=new lw("span"),lw.block=new lw("div");var cw=new(function(){function e(){return v(this,e),g(this,e,arguments)}return C(e,iy),b(e,[{key:"toDOM",value:function(){return document.createElement("br")}},{key:"isHidden",get:function(){return!0}},{key:"editable",get:function(){return!0}}])}()),uw=function(){return b(function e(t){v(this,e),this.view=t,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=sy.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 Vb(t,t.contentDOM),this.updateInner([new _b(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=fw(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 _b(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 _b(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,(Qv.ie||Qv.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 dw,dv.compare(h,f,d,p),p.changes);m.length&&(r=_b.extendWithRanges(r,m));var g=function(e,t,n){var r=new pw;return dv.compare(e,t,n,r),r.changes}(u,this.blockWrappers,e.changes);return g.length&&(r=_b.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 iw(n.view,i,n.blockWrappers,n.decorations,n.dynamicDecorationMap);n.tile=o.run(e,t),hw(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=Qv.chrome||Qv.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=w(this.tile.children);try{for(s.s();!(o=s.n()).done;){var a=o.value;a.isWidget()&&a.widget instanceof mw&&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=w(e.transactions);try{for(n.s();!(t=n.n()).done;){var r,i=w(t.value.effects);try{for(i.s();!(r=i.n()).done;){var o=r.value;o.is(bb)&&(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(kb)||n.tabIndex>-1)&&my(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)),Qv.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 Ly(h,0),s=!0}var f=this.view.observer.selectionRange;!s&&f.focusNode&&(vy(a.node,a.offset,f.anchorNode,f.anchorOffset)&&vy(l.node,l.offset,f.focusNode,f.focusOffset)||this.suppressWidgetCursorChange(f,u))||(this.view.observer.ignore(function(){Qv.android&&Qv.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=dy(e.view.root);if(t)if(u.empty){if(Qv.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?Dy:Py)(a.node,a.offset);s&&(a=new Ly(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 Ly(f.anchorNode,f.anchorOffset),this.impreciseHead=l.precise?null:new Ly(f.focusNode,f.focusOffset)}}},{key:"suppressWidgetCursorChange",value:function(e,t){return this.hasComposition&&t.empty&&vy(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=dy(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==ky(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&&!Wb.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 mw?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=w(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=tg(t.text,n);if(a==n)return null;for(var l=Ny(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==By.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 qb)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?gy(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?By.RTL:By.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=w(e.children);try{for(i.s();!(n=i.n()).done;){var o=n.value;if(!o.isText()||/[^ -~]/.test(o.text))return;var s=gy(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=gy(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(sy.replace({widget:new mw(s),block:!0,inclusive:!0,isBlockGap:!0}).range(n,o))}if(!i)break;n=i.to+1}return sy.set(e)}},{key:"updateDeco",value:function(){var e=this,t=1,n=this.view.state.facet(Ob).map(function(n){return(e.dynamicDecorationMap[t++]="function"==typeof n)?n(e.view):n}),r=!1,i=this.view.state.facet(Tb).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(dv.join(i))),this.decorations=[this.editContextFormatting].concat(L(n),[this.computeBlockGapDeco(),this.view.viewState.lineGapDeco]);t<this.decorations.length;)this.dynamicDecorationMap[t++]=!1;this.blockWrappers=this.view.state.facet(Nb).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=w(this.view.state.facet(gb));try{for(r.s();!(n=r.n()).done;){var i=n.value;try{if(i(this.view,e.range,e))return!0}catch(e){wb(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=Bb(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=Sy(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=Cy(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==By.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(){hw(this.tile)}}])}();function hw(e,t){var n=null==t?void 0:t.get(e);if(1!=n){null==n&&e.destroy();var r,i=w(e.children);try{for(i.s();!(r=i.n()).done;){hw(r.value,t)}}catch(e){i.e(e)}finally{i.f()}}}function fw(e,t){var n=e.observer.selectionRange;if(!n.focusNode)return null;var r=Dy(n.focusNode,n.focusOffset),i=Py(n.focusNode,n.focusOffset),o=r||i;if(i&&r&&i.node!=r.node){var s=Wb.get(i.node);if(!s||s.isText()&&s.text!=i.node.nodeValue)o=i;else if(e.docView.lastCompositionAfterCursor){var a=Wb.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 dw=function(){return b(function e(){v(this,e),this.changes=[]},[{key:"compareRange",value:function(e,t){hy(e,t,this.changes)}},{key:"comparePoint",value:function(e,t){hy(e,t,this.changes)}},{key:"boundChange",value:function(e){hy(e,e,this.changes)}}])}();var pw=function(){return b(function e(){v(this,e),this.changes=[]},[{key:"compareRange",value:function(e,t){hy(e,t,this.changes)}},{key:"comparePoint",value:function(){}},{key:"boundChange",value:function(e){hy(e,e,this.changes)}}])}();var mw=function(){function e(t){var n;return v(this,e),(n=g(this,e)).height=t,n}return C(e,iy),b(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 gw(e,t,n){var r=e.lineBlockAt(t);if(Array.isArray(r.type)){var i,o,s=w(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!=oy.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 vw(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=rb(i,o,s,a,n),u=nb;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 yw(e,t,n){for(var r,i=function(){var r,i=0,o=w(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 bw(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=yw(e,i.from,0);s!=i.from&&(o=gg.cursor(s,-1))}else{var a=yw(e,i.from,-1),l=yw(e,i.to,1);a==i.from&&l==i.to||(o=gg.range(i.from==i.anchor?a:l,i.from==i.head?a:l))}o&&(n||(n=t.ranges.slice()),n[r]=o)}return n?gg.create(n,t.mainIndex):t}function ww(e,t,n){var r=yw(e.state.facet(Rb).map(function(t){return t(e)}),n.from,t.head>n.from?-1:1);return r==n.from?n:gg.cursor(r,r<n.from?1:-1)}var kw=b(function e(t,n){v(this,e),this.pos=t,this.assoc=n});function xw(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 kw(0,1);if(c>e.viewState.docHeight)return new kw(e.state.doc.length,-1);if(i=e.elementAtHeight(c),null==r)break;if(i.type==oy.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==oy.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+Av(a,o,e.state.tabSize)}(e,o,i,a,l);return new kw(f,f==i.from?1:-1)}}if(i.type!=oy.Text)return c<(i.top+i.bottom)/2?new kw(i.from,1):new kw(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 Sw(e,a,l,e.textDirectionAt(i.from)).scanTile(d,i.from)}var Sw=function(){return b(function e(t,n,r,i){v(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[Xy.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[Xy.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==By.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)==By.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=tg(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 Ny(e.dom,i,o).getClientRects()});return i.after?new kw(n[i.i+1],-1):new kw(n[i.i],1)}},{key:"scanTile",value:function(e,t){if(!e.length)return new kw(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:Ny(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 kw(r[s.i+1],-1):new kw(l,1)}}])}(),Cw="￿",Ew=function(){return b(function e(t,n){v(this,e),this.points=t,this.view=n,this.text="",this.lineSeparator=n.state.facet(sv.lineSeparator)},[{key:"append",value:function(e){this.text+=e}},{key:"lineBreak",value:function(){this.text+=Cw}},{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=Wb.get(r),s=r.nextSibling;if(s==t){(null==o?void 0:o.breakAfter)&&!s&&n!=this.view.contentDOM&&this.lineBreak();break}var a=Wb.get(s);(o&&a?o.breakAfter:(o?o.breakAfter:by(r))||by(s)&&("BR"!=r.nodeName||(null==o?void 0:o.isWidget()))&&this.text.length>i)&&!Mw(s,t)&&this.lineBreak(),r=s}return this.findPointBefore(n,t),this}},{key:"readTextNode",value:function(e){var t,n=e.nodeValue,r=w(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=w(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=Wb.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=w(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=w(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+(Aw(e,i.node,i.offset)?t:0))}}catch(e){r.e(e)}finally{r.f()}}}])}();function Aw(e,t,n){for(;;){if(!t||n<ky(t))return!1;if(t==e)return!0;n=yy(t)+1,t=t.parentNode}}function Mw(e,t){for(var n;e!=t&&e;e=e.nextSibling){var r=Wb.get(e);if(!(null==r?void 0:r.isWidget()))return!1;r&&(n||(n=[])).push(r)}if(n){var i,o=w(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 Ow=b(function e(t,n){v(this,e),this.node=t,this.offset=n,this.pos=-1}),Nw=b(function e(t,n,r,i){v(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=Tw(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 Ow(r,i)),o==r&&s==i||t.push(new Ow(o,s)));return t}(t),c=new Ew(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?gg.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||!py(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||!py(t.contentDOM,u.anchorNode)?t.state.selection.main.anchor:t.docView.posFromDOM(u.anchorNode,u.anchorOffset),d=t.viewport;if((Qv.ios||Qv.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,y=d.to-m;0!=g&&1!=g&&0!=p||0!=y&&-1!=y&&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(gg.range(f,h)):this.newSel=gg.single(f,h)}});function Tw(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 Tw(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 Rw(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||Qv.android&&t.text.length<l-a)&&(c=i.to,u="end");var h=Pw(e.state.doc.sliceString(a,l,Cw),t.text,c-a,u);h&&(Qv.chrome&&13==o&&h.toB==h.from+2&&t.text.slice(h.from,h.toB)==Cw+Cw&&h.toB--,n={from:a+h.from,to:a+h.toA,insert:Um.of(t.text.slice(h.from,h.toB).split(Cw))})}else r&&(!e.hasFocus&&e.state.facet(kb)||Lw(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)}:(Qv.mac||Qv.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=gg.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:Um.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)}:Qv.chrome&&n&&n.from==n.to&&n.from==i.head&&"\n "==n.insert.toString()&&e.lineWrapping&&(r&&(r=gg.single(r.main.anchor-1,r.main.head-1)),n={from:i.from,to:i.to,insert:Um.of([" "])}),n)return Dw(e,n,r,o);if(r&&!Lw(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=bw(e.state.facet(Rb).map(function(t){return t(e)}),r))),e.dispatch({selection:r,scrollIntoView:f,userEvent:d}),!0}return!1}function Dw(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:-1;if(Qv.ios&&e.inputState.flushIOSKey(t))return!0;var i=e.state.selection.main;if(Qv.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&&Ty(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)&&Ty(e.contentDOM,"Backspace",8)||t.from==i.from&&t.to==i.to+1&&0==t.insert.length&&Ty(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=yw(i.facet(Rb).map(function(t){return t(e)}),l,a);t.from==c&&(s=c)}if(s>-1)r={changes:t,selection:gg.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&&fw(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?gg.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(ub).some(function(n){return n(e,t.from,t.to,s,a)})||e.dispatch(a()),!0}function Pw(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 Lw(e,t){return t.head==e.main.head&&t.anchor==e.main.anchor}var Bw=function(){return b(function e(t){v(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,Qv.safari&&t.contentDOM.addEventListener("input",function(){return null}),Qv.gecko&&function(e){ik.has(e)||(ik.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=Wb.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=w(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=w(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=w(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(Iw(o.value,u))}if(l)for(var h in l){var f=l[h];f&&n(h).observers.push(Iw(o.value,f))}}}catch(e){i.e(e)}finally{i.f()}for(var d in zw)n(d).handlers.push(zw[d]);for(var p in Vw)n(p).observers.push(Vw[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&&Fw.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),!Qv.android||!Qv.chrome||e.synthetic||13!=e.keyCode&&8!=e.keyCode?!Qv.ios||e.synthetic||e.altKey||e.metaKey||!((t=_w.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,Ty(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||!!(Qv.safari&&!Qv.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 Iw(e,t){return function(n,r){try{return t.call(e,r,n)}catch(e){wb(n.state,e)}}}var _w=[{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",Fw=[16,17,18,20,91,92,224,225];function Ww(e){return.7*Math.max(0,e)+8}var Hw=function(){return b(function e(t,n,r,i){v(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(Rb).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(sv.allowMultipleSelections)&&function(e,t){var n=e.state.facet(ob);return n.length?n[0](t):Qv.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=dy(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!=Qw(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=Bb(this.view);e.clientX-h.left<=o+6?r=-Ww(o-e.clientX):e.clientX+h.right>=a-6&&(r=Ww(e.clientX-a)),e.clientY-h.top<=s+6?i=-Ww(s-e.clientY):e.clientY+h.bottom>=l-6&&(i=Ww(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=bw(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 zw=Object.create(null),Vw=Object.create(null),qw=Qv.ie&&Qv.ie_version<15||Qv.ios&&Qv.webkit_version<604;function Uw(e,t,n){var r,i=w(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 Kw(e,t){t=Uw(e.state,fb,t);var n,r=e.state,i=1,o=r.toText(t),s=o.lines==r.selection.ranges.length,a=null!=ek&&r.selection.ranges.every(function(e){return e.empty})&&ek==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:gg.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:gg.cursor(e.from+t.length)}}):r.replaceSelection(o);e.dispatch(n,{userEvent:"input.paste",scrollIntoView:!0})}function Gw(e,t,n,r){if(1==r)return gg.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 gg.cursor(t);0==o?n=1:o==i.length&&(n=-1);var s=o,a=o;n<0?s=tg(i.text,o,!1):a=tg(i.text,o);for(var l=r(i.text.slice(s,a));s>0;){var c=tg(i.text,s,!1);if(r(i.text.slice(c,s))!=l)break;s=c}for(;a<i.length;){var u=tg(i.text,a);if(r(i.text.slice(a,u))!=l)break;a=u}return gg.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++,gg.range(s,a)}Vw.scroll=function(e){e.inputState.lastScrollTop=e.scrollDOM.scrollTop,e.inputState.lastScrollLeft=e.scrollDOM.scrollLeft},zw.keydown=function(e,t){return e.inputState.setSelectionOrigin("select"),27==t.keyCode&&0!=e.inputState.tabFocusMode&&(e.inputState.tabFocusMode=Date.now()+2e3),!1},Vw.touchstart=function(e,t){e.inputState.lastTouchTime=Date.now(),e.inputState.setSelectionOrigin("select.pointer")},Vw.touchmove=function(e){e.inputState.setSelectionOrigin("select.pointer")},zw.mousedown=function(e,t){if(e.observer.flush(),e.inputState.lastTouchTime>Date.now()-2e3)return!1;var n,r=null,i=w(e.state.facet(ab));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=Qw(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=Gw(e,l.pos,l.assoc,r);if(n.pos!=l.pos&&!o){var u=Gw(e,n.pos,n.assoc,r),h=Math.min(u.from,c.from),f=Math.max(u.to,c.to);c=h<c.from?gg.range(h,f):gg.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 gg.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):gg.create([c])}}}(e,t)),r){var o=!e.hasFocus;e.inputState.startMouseSelection(new Hw(e,t,r,o)),o&&e.observer.ignore(function(){Oy(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 Yw=Qv.ie&&Qv.ie_version<=11,$w=null,Xw=0,Jw=0;function Qw(e){if(!Yw)return e.detail;var t=$w,n=Jw;return $w=e,Jw=Date.now(),Xw=!t||n>Date.now()-400&&Math.abs(t.clientX-e.clientX)<2&&Math.abs(t.clientY-e.clientY)<2?(Xw+1)%3:1}function Zw(e,t,n,r){if(n=Uw(e.state,fb,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(sb);return n.length?n[0](t):Qv.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}}zw.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=gg.range(i,o))}}var s=e.inputState;return s.mouseSelection&&(s.mouseSelection.dragging=!0),s.draggedContent=n,t.dataTransfer&&(t.dataTransfer.setData("Text",Uw(e.state,db,e.state.sliceDoc(n.from,n.to))),t.dataTransfer.effectAllowed="copyMove"),!1},zw.dragend=function(e){return e.inputState.draggedContent=null,!1},zw.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&&Zw(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&&(Zw(e,t,l,!0),!0)},zw.paste=function(e,t){if(e.state.readOnly)return!0;e.observer.flush();var n=qw?null:t.clipboardData;return n?(Kw(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(),Kw(e,n.value)},50)}}(e),!1)};var ek=null;zw.copy=zw.cut=function(e,t){if(!my(e.contentDOM,e.observer.selectionRange))return!1;var n=function(e){var t,n=[],r=[],i=!1,o=w(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=w(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:Uw(e,db,n.join(e.lineBreak)),ranges:r,linewise:i}}(e.state),r=n.text,i=n.ranges,o=n.linewise;if(!r&&!o)return!1;ek=o?r:null,"cut"!=t.type||e.state.readOnly||e.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});var s=qw?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 tk=Ug.define();function nk(e,t){var n,r=[],i=w(e.facet(hb));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:tk.of(!0)}):null}function rk(e){setTimeout(function(){var t=e.hasFocus;if(t!=e.inputState.notifiedFocused){var n=nk(e.state,t);n?e.dispatch(n):e.update([])}},10)}Vw.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),rk(e)},Vw.blur=function(e){e.observer.clearSelectionRange(),rk(e)},Vw.compositionstart=Vw.compositionupdate=function(e){e.observer.editContext||(null==e.inputState.compositionFirstChange&&(e.inputState.compositionFirstChange=!0),e.inputState.composing<0&&(e.inputState.composing=0))},Vw.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,Qv.chrome&&Qv.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))},Vw.contextmenu=function(e){e.inputState.lastContextMenu=Date.now()},zw.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 Dw(e,{from:l,to:c,insert:e.state.toText(o)},null),!0}}if(Qv.chrome&&Qv.android&&(i=_w.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 Qv.ios&&"deleteContentForward"==t.inputType&&e.observer.flushSoon(),Qv.safari&&"insertText"==t.inputType&&e.inputState.composing>=0&&setTimeout(function(){return Vw.compositionend(e,t)},20),!1};var ik=new Set;var ok=["pre-wrap","normal","pre-line","break-spaces"],sk=!1;function ak(){sk=!1}var lk=function(){return b(function e(t){v(this,e),this.lineWrapping=t,this.doc=Um.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 ok.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=ok.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}}])}(),ck=function(){return b(function e(t,n){v(this,e),this.from=t,this.heights=n,this.index=0},[{key:"more",get:function(){return this.index<this.heights.length}}])}(),uk=function(){function e(t,n,r,i,o){v(this,e),this.from=t,this.length=n,this.top=r,this.height=i,this._content=o}return b(e,[{key:"type",get:function(){return"number"==typeof this._content?oy.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 cy?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)}}])}(),hk=function(e){return e[e.ByPos=0]="ByPos",e[e.ByHeight=1]="ByHeight",e[e.ByPosNoHeight=2]="ByPosNoHeight",e}(hk||(hk={})),fk=.001,dk=function(){function e(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2;v(this,e),this.length=t,this.height=n,this.flags=r}return b(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)>fk&&(sk=!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,hk.ByPosNoHeight,n.setDoc(t),0,0),d=f.to>=c?f:i.lineAt(c,hk.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,hk.ByPosNoHeight,n,0,0));u+=f.from-l,l=f.from;var p=kk.build(n.setDoc(o),e,u,h);i=pk(i,i.replace(l,c,p))}return i.updateHeight(n,0)}}],[{key:"empty",value:function(){return new vk(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 bk(e.of(t.slice(0,n)),u,e.of(t.slice(r)))}}])}();function pk(e,t){return e==t?e:(e.constructor!=t.constructor&&(sk=!0),t)}dk.prototype.size=1;var mk=sy.replace({}),gk=function(){function e(t,n,r){var i;return v(this,e),(i=g(this,e,[t,n])).deco=r,i.spaceAbove=0,i}return C(e,dk),b(e,[{key:"mainBlock",value:function(e,t){return new uk(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 uk(r,0,n,this.spaceAbove,mk):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,hk.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,")")}}])}(),vk=function(){function e(t,n,r){var i;return v(this,e),(i=g(this,e,[t,n,null])).collapsed=0,i.widgetHeight=0,i.breaks=0,i.spaceAbove=r,i}return C(e,gk),b(e,[{key:"mainBlock",value:function(e,t){return new uk(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 yk&&4&i.flags)&&Math.abs(this.length-i.length)<10?(i instanceof yk?i=new e(i.length,this.height,this.spaceAbove):i.height=this.height,this.outdated||(i.outdated=!1),i):dk.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:"",")")}}])}(),yk=function(){function e(t){return v(this,e),g(this,e,[t,0])}return C(e,dk),b(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 uk(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 uk(m,g,n+a*d,a,0)}},{key:"lineAt",value:function(e,t,n,r,i){if(t==hk.ByHeight)return this.blockAt(e,n,r,i);if(t==hk.ByPosNoHeight){var o=n.doc.lineAt(e),s=o.from,a=o.to;return new uk(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 uk(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 uk(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 dk.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)>=fk&&(l=-2);var f=new vk(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=dk.of(s);return(l<0||Math.abs(d.height-this.height)>=fk||Math.abs(l-this.heightMetrics(t,n).perLine)>=fk)&&(sk=!0),pk(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,")")}}])}(),bk=function(){function e(t,n,r){var i;return v(this,e),(i=g(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 C(e,dk),b(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==hk.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==hk.ByPosNoHeight?hk.ByPosNoHeight:hk.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,hk.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=w(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&&wk(i,s-1),t<this.length){var c=i.length;this.decomposeRight(t,i),wk(i,c)}return dk.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?dk.of(this.break?[e,null,t]:[e,t]):(this.left=pk(this.left,e),this.right=pk(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 wk(e,t){var n,r;null==e[t]&&(n=e[t-1])instanceof yk&&(r=e[t+1])instanceof yk&&e.splice(t-1,3,new yk(n.length+1+r.length))}var kk=function(){function e(t,n){v(this,e),this.pos=t,this.oracle=n,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=t}return b(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 vk?r.length+=n-this.pos:(n>this.pos||!this.isCovered)&&this.nodes.push(new vk(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 gk(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 vk(this.pos-t,-1,0)),this.writtenTo=this.pos}}},{key:"blankContent",value:function(e,t){var n=new yk(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 vk)return e;var t=new vk(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 vk||this.isCovered?(this.writtenTo<this.pos||null==t)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new vk(0,-1,0));var n,r=e,i=w(this.nodes);try{for(i.s();!(n=i.n()).done;){var o=n.value;o instanceof vk&&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 dv.spans(n,r,i,o,0),o.finish(r)}}])}();var xk=function(){return b(function e(){v(this,e),this.changes=[]},[{key:"compareRange",value:function(){}},{key:"comparePoint",value:function(e,t,n,r){(e<t||n&&n.heightRelevant||r&&r.heightRelevant)&&hy(e,t,this.changes,5)}}])}();function Sk(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 Ck(e,t){var n=e.getBoundingClientRect();return{left:0,right:n.right-n.left,top:t,bottom:n.bottom-(n.top+t)}}var Ek=function(){return b(function e(t,n,r,i){v(this,e),this.from=t,this.to=n,this.size=r,this.displaySize=i},[{key:"draw",value:function(e,t){return sy.replace({widget:new Ak(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}}])}(),Ak=function(){function e(t,n){var r;return v(this,e),(r=g(this,e)).size=t,r.vertical=n,r}return C(e,iy),b(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}}])}(),Mk=function(){return b(function e(t){var n=this;v(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=Rk,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=By.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;var r=t.facet(Mb).some(function(e){return"function"!=typeof e&&"cm-lineWrapping"==e.class});this.heightOracle=new lk(r),this.stateDeco=Dk(t),this.heightMap=dk.empty().applyChanges(this.stateDeco,Um.empty,this.heightOracle.setDoc(t.doc),[new _b(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=sy.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 Ok(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?Rk:new Pk(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(Lk(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=Dk(this.state);var r,i,o,s,a=e.changedRanges,l=_b.extendWithRanges(a,(r=n,i=this.stateDeco,o=e?e.changes:lg.empty(this.state.doc.length),s=new xk,dv.compare(r,i,o,s,0),s.changes)),c=this.heightMap.height,u=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);ak(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),l),(this.heightMap.height!=c||sk)&&(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(mb)&&(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?By.RTL:By.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=Cy(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=Ry(e.scrollDOM);var g=(this.printing?Ck:Sk)(t,this.paddingTop),v=g.top-this.pixelViewport.top,y=g.bottom-this.pixelViewport.bottom;this.pixelViewport=g;var b,k,x,S=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(S!=this.inView&&(this.inView=S,S&&(a=!0)),!(this.inView||this.scrollTarget||(b=e.dom,k=b.getBoundingClientRect(),x=b.ownerDocument.defaultView||window,k.left<x.innerWidth&&k.right>0&&k.top<x.innerHeight&&k.bottom>0)))return 0;var C=s.width;if(this.contentDOMWidth==C&&this.editorHeight==e.scrollDOM.clientHeight||(this.contentDOMWidth=s.width,this.editorHeight=e.scrollDOM.clientHeight,l|=16),a){var E=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(E)&&(o=!0),o||r.lineWrapping&&Math.abs(C-this.contentDOMWidth)>r.charWidth){var A=e.docView.measureTextSize(),M=A.lineHeight,O=A.charWidth,N=A.textHeight;(o=M>0&&r.refresh(i,M,O,N,Math.max(5,C/O),E))&&(e.docView.minWidth=0,l|=16)}v>0&&y>0?c=Math.max(v,y):v<0&&y<0&&(c=Math.min(v,y)),ak();var T,R=w(this.viewports);try{for(R.s();!(T=R.n()).done;){var D=T.value,P=D.from==this.viewport.from?E:e.docView.measureVisibleLineHeights(D);this.heightMap=(o?dk.empty().applyChanges(this.stateDeco,Um.empty,this.heightOracle,[new _b(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,o,new ck(D.from,P))}}catch(e){R.e(e)}finally{R.f()}sk&&(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 Ok(r.lineAt(o-1e3*n,hk.ByHeight,i,0,0).from,r.lineAt(s+1e3*(1-n),hk.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,hk.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 Ok(r.lineAt(c-500,hk.ByHeight,i,0,0).from,r.lineAt(c+u+500,hk.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 Ok(this.heightMap.lineAt(n,hk.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(r,hk.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,hk.ByPos,this.heightOracle,0,0).top,o=this.heightMap.lineAt(n,hk.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=w(e);try{for(i.s();!(n=i.n()).done;){var o=n.value;t.touchesRange(o.from,o.to)||r.push(new Ek(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!=By.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=w(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(gg.cursor(s),!1,!0).head;v>i&&(s=v)}var y=n.gapSize(a,i,s,u);g=new Ek(i,s,y,r||y<2e6?y:2e6)}l.push(g)}},u=function(t){if(!(t.length<s||t.type!=oy.Text)){var o=function(e,t,n){var r=[],i=e,o=0;dv.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=Tk(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=Nk(o,h),l=Nk(o,f)}else{var g=o.total*n.heightOracle.charWidth,v=i*n.heightOracle.charWidth,y=0;if(g>2e6){var b,k=w(e);try{for(k.s();!(b=k.n()).done;){var x=b.value;x.from>=t.from&&x.from<t.to&&x.size!=x.displaySize&&x.from*n.heightOracle.charWidth+y<n.pixelViewport.left&&(y=x.size-x.displaySize)}}catch(e){k.e(e)}finally{k.f()}}var S,C,E=n.pixelViewport.left+y,A=n.pixelViewport.right+y;if(null!=u){var M=Tk(o,u),O=((A-E)/2+v)/g;S=M-O,C=M+O}else S=(E-v)/g,C=(A+v)/g;a=Nk(o,S),l=Nk(o,C)}a>t.from&&c(t.from,a,t,o),l<t.to&&c(l,t.to,t,o)}}},h=w(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=Tk(r,n)-Tk(r,t);return this.heightOracle.lineWrapping?e.height*i:r.total*this.heightOracle.charWidth*i}},{key:"updateLineGaps",value:function(e){var t=this;Ek.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=sy.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=[];dv.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})||Lk(this.heightMap.lineAt(e,hk.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})||Lk(this.heightMap.lineAt(this.scaler.fromDOM(e),hk.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 Lk(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}}])}(),Ok=b(function e(t,n){v(this,e),this.from=t,this.to=n});function Nk(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 Tk(e,t){var n,r=0,i=w(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 Rk={toDOM:function(e){return e},fromDOM:function(e){return e},scale:1,eq:function(e){return e==this}};function Dk(e){var t=e.facet(Ob).filter(function(e){return"function"!=typeof e}),n=e.facet(Tb).filter(function(e){return"function"!=typeof e});return n.length&&t.push(dv.join(n)),t}var Pk=function(){function e(t,n,r){v(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,hk.ByPos,t,0,0).top,a=n.lineAt(o,hk.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=w(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 b(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 Lk(e,t){if(1==t.scale)return e;var n=t.toDOM(e.top),r=t.toDOM(e.bottom);return new uk(e.from,e.length,n,r-n,Array.isArray(e._content)?e._content.map(function(e){return Lk(e,t)}):e._content)}var Bk=bg.define({combine:function(e){return e.join(" ")}}),Ik=bg.define({combine:function(e){return e.indexOf(!0)>-1}}),_k=Tv.newName(),jk=Tv.newName(),Fk=Tv.newName(),Wk={"&light":"."+jk,"&dark":"."+Fk};function Hk(e,t,n){return new Tv(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 zk=Hk("."+_k,{"&":{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"}},Wk),Vk={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},qk=Qv.ie&&Qv.ie_version<=11,Uk=function(){return b(function e(t){var n=this;v(this,e),this.view=t,this.active=!1,this.editContext=null,this.selectionRange=new Ay,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=w(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()}(Qv.ie&&Qv.ie_version<=11||Qv.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||!Qv.android||!1===t.constructor.EDIT_CONTEXT||Qv.chrome&&Qv.chrome_version<126||(this.editContext=new Yk(t),t.state.facet(kb)&&(t.contentDOM.editContext=this.editContext.editContext)),qk&&(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=w(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(kb)?n.root.activeElement==this.dom:my(this.dom,r)){var i=r.anchorNode&&n.docView.tile.nearest(r.anchorNode);i&&i.isWidget()&&i.widget.ignoreEvent(e)?t||(this.selectionChanged=!1):(Qv.ie&&Qv.ie_version<=11||Qv.android&&Qv.chrome)&&!n.state.selection.main.empty&&r.focusNode&&vy(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}}}},{key:"readSelectionRange",value:function(){var e=this.view,t=dy(e.root);if(!t)return!1;var n=Qv.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 Gk(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?Gk(e,r):null}(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;var r=my(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,ky(n));;)if(r){if(1!=n.nodeType)return!1;var i=n.childNodes[r-1];"false"==i.contentEditable?r--:r=ky(n=i)}else{if(n==e)return!0;r=yy(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=w(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=w(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,Vk),qk&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}},{key:"stop",value:function(){this.active&&(this.active=!1,this.observer.disconnect(),qk&&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&&Ty(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=w(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=w(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&&my(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 Nw(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=Rw(this.view,t);return this.view.state==n&&(t.domChanged||t.newSel&&!Lw(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=Kk(t,e.previousSibling||e.target.previousSibling,-1),r=Kk(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(kb)!=e.state.facet(kb)&&(e.view.contentDOM.editContext=e.state.facet(kb)?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=w(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 Kk(e,t,n){for(;t;){var r=Wb.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 Gk(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(vy(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 Yk=function(){return b(function e(t){var n=this;v(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=Pw(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:Um.of(e.text.slice(u.from,u.toB).split("\n"))};if((Qv.mac||Qv.android)&&h.from==s-1&&/^\. ?$/.test(e.text)&&"off"==t.contentDOM.getAttribute("autocorrect")&&(h={from:a,to:l,insert:Um.of([e.text.replace("."," ")])}),n.pendingContextChange=h,!t.state.readOnly){var f=n.to-n.from+(h.to-h.from+h.insert.length);Dw(t,h,gg.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=gg.single(n.toEditorPos(e.selectionStart),n.toEditorPos(e.selectionEnd));Lw(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=w(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(sy.mark({attributes:{style:h}}).range(c,u))}}}}catch(e){o.e(e)}finally{o.f()}t.dispatch({effects:bb.of(sy.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=dy(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])}}])}(),$k=function(){function e(){var t,n=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};v(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 Mk(r.state||sv.create(r)),r.scrollTo&&r.scrollTo.is(yb)&&(this.viewState.scrollTarget=r.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Sb).map(function(e){return new Eb(e)});var o,s=w(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 Uk(this),this.inputState=new Bw(this),this.inputState.ensureHandlers(this.plugins),this.docView=new uw(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 b(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 $g?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=w(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(tk)})?(this.inputState.notifiedFocused=c,u=1):c!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=c,(h=nk(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(sv.phrases)!=this.state.facet(sv.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=w(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 vb(y.empty?y:gg.cursor(y.head,y.head>y.anchor?-1:1))}var b,k=w(v.effects);try{for(k.s();!(b=k.n()).done;){var x=b.value;x.is(yb)&&(p=x.value.clip(this.state))}}catch(e){k.e(e)}finally{k.f()}}}catch(e){g.e(e)}finally{g.f()}this.viewState.update(n,p),this.bidiCache=Qk.update(this.bidiCache,n.changes),n.empty||(this.updatePlugins(n),this.inputState.update(n)),i=this.docView.update(n),this.state.facet(Ib)!=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(Bk)!=n.state.facet(Bk)&&(this.viewState.mustMeasureContent=!0),(i||o||p||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),i&&this.docViewUpdate(),!n.empty){var S,C=w(this.state.facet(cb));try{for(C.s();!(S=C.n()).done;){var E=S.value;try{E(n)}catch(x){wb(this.state,x,"update listener")}}}catch(e){C.e(e)}finally{C.f()}}(h||d)&&Promise.resolve().then(function(){h&&t.state==h.startState&&t.dispatch(h),d&&!Rw(t,d)&&f.force&&Ty(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=w(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 Mk(e),this.plugins=e.facet(Sb).map(function(e){return new Eb(e)}),this.pluginMap.clear();var i,o=w(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 uw(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(Sb),n=e.state.facet(Sb);if(t!=n){var r,i=[],o=w(n);try{for(o.s();!(r=o.n()).done;){var s=r.value,a=t.indexOf(s);if(a<0)i.push(new Eb(s));else{var l=this.plugins[a];l.mustUpdate=e,i.push(l)}}}catch(e){o.e(e)}finally{o.f()}var c,u=w(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=w(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=w(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){wb(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(Ry(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 wb(e.state,t),Jk}}),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]!=Jk)try{var v=h[g];v.write&&v.write(d[g],this)}catch(e){wb(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,k=w(this.state.facet(cb));try{for(k.s();!(b=k.n()).done;){(0,b.value)(n)}}catch(e){k.e(e)}finally{k.f()}}}}},{key:"themeClasses",get:function(){return _k+" "+(this.state.facet(Ik)?Fk:jk)+" "+this.state.facet(Bk)}},{key:"updateAttrs",value:function(){var e=this,t=Zk(this,Ab,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(kb)?"true":"false",class:"cm-content",style:"".concat(Qv.tabSize,": ").concat(this.state.tabSize),role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),Zk(this,Mb,n);var r=this.observer.ignore(function(){var r=ny(e.contentDOM,e.contentAttrs,n),i=ny(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=w(t);try{for(i.s();!(n=i.n()).done;){var o,s=w(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(Ib);var t=this.state.facet(e.cspNonce);Tv.mount(this.root,this.styleModules.concat(zk).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 ww(this,e,vw(this,e,t,n))}},{key:"moveByGroup",value:function(e,t){var n=this;return ww(this,e,vw(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==rv.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 gg.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=gw(e,t.head,t.assoc||-1),o=r&&i.type==oy.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==By.LTR)?s.right-1:s.left+1,y:(o.top+o.bottom)/2});if(null!=l)return gg.cursor(l,n?-1:1)}return gg.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 ww(this,e,function(e,t,n,r){var i=t.head,o=n?1:-1;if(i==(n?e.state.doc.length:0))return gg.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=xw(e,{x:l.left+a,y:s+(null!=r?r:e.viewState.heightOracle.textHeight>>1)*o},!1,o);return gg.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=xw(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(),xw(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 xy(n,i[Xy.find(i,e-r.from,-1,t)].dir==By.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(pb)||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>Xk)return tb(e.length);var t,n,r=this.textDirectionAt(e.from),i=w(this.bidiCache);try{for(i.s();!(n=i.n()).done;){var o=n.value;if(o.from==e.from&&o.dir==r&&(o.fresh||Jy(o.isolates,t=Pb(this,e))))return o.order}}catch(e){i.e(e)}finally{i.f()}t||(t=Pb(this,e));var s=function(e,t,n){if(!e)return[new Xy(0,0,t==_y?1:0)];if(t==Iy&&!n.length&&!$y.test(e))return tb(e.length);if(n.length)for(;e.length>Qy.length;)Qy[Qy.length]=256;var r=[],i=t==Iy?0:1;return eb(e,i,i,n,0,e.length,r),r}(e.text,r,t);return this.bidiCache.push(new Qk(e.from,e.to,r,t,!0,s)),s}},{key:"hasFocus",get:function(){var e;return(this.dom.ownerDocument.hasFocus()||Qv.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(){Oy(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=w(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 yb.of(new vb(gg.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 yb.of(new vb("number"==typeof e?gg.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}},{key:"domEventHandlers",value:function(e){return Cb.define(function(){return{}},{eventHandlers:e})}},{key:"domEventObservers",value:function(e){return Cb.define(function(){return{}},{eventObservers:e})}},{key:"theme",value:function(e,t){var n=Tv.newName(),r=[Bk.of(n),Ib.of(Hk(".".concat(n),e))];return t&&t.dark&&r.push(Ik.of(!0)),r}},{key:"baseTheme",value:function(e){return Rg.lowest(Ib.of(Hk("."+_k,e,Wk)))}},{key:"findFromDOM",value:function(e){var t,n=e.querySelector(".cm-content"),r=n&&Wb.get(n)||Wb.get(e);return(null===(t=null==r?void 0:r.root)||void 0===t?void 0:t.view)||null}}])}();$k.styleModule=Ib,$k.inputHandler=ub,$k.clipboardInputFilter=fb,$k.clipboardOutputFilter=db,$k.scrollHandler=gb,$k.focusChangeEffect=hb,$k.perLineTextDirection=pb,$k.exceptionSink=lb,$k.updateListener=cb,$k.editable=kb,$k.mouseSelectionStyle=ab,$k.dragMovesSelection=sb,$k.clickAddsSelectionRange=ob,$k.decorations=Ob,$k.blockWrappers=Nb,$k.outerDecorations=Tb,$k.atomicRanges=Rb,$k.bidiIsolatedRanges=Db,$k.scrollMargins=Lb,$k.darkTheme=Ik,$k.cspNonce=bg.define({combine:function(e){return e.length?e[0]:""}}),$k.contentAttributes=Mb,$k.editorAttributes=Ab,$k.lineWrapping=$k.contentAttributes.of({class:"cm-lineWrapping"}),$k.announce=Yg.define();var Xk=4096,Jk={},Qk=function(){function e(t,n,r,i,o,s){v(this,e),this.from=t,this.to=n,this.dir=r,this.isolates=i,this.fresh=o,this.order=s}return b(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:By.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 Zk(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&&Zv(s,n)}return n}var ex=Qv.mac?"mac":Qv.windows?"win":Qv.linux?"linux":"key";function tx(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 nx=Rg.default($k.domEventHandlers({keydown:function(e,t){return cx(ox(t.state),e,t,"editor")}})),rx=bg.define({enables:nx}),ix=new WeakMap;function ox(e){var t=e.facet(rx),n=ix.get(t);return n||ix.set(t,n=function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ex,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=sx={view:n,prefix:t,scope:e};return setTimeout(function(){sx==r&&(sx=null)},ax),!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=w(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=w(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,lx)})};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=w(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 sx=null,ax=4e3;var lx=null;function cx(e,t,n,r){lx=t;var i=function(e){var t=!(Bv&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||Iv&&e.shiftKey&&e.key&&1==e.key.length||"Unidentified"==e.key)&&e.key||(e.shiftKey?Lv:Pv)[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=ig(ng(i,0))==i.length&&" "!=i,s="",a=!1,l=!1,c=!1;sx&&sx.view==n&&sx.scope==r&&(s=sx.prefix+" ",Fw.indexOf(t.keyCode)<0&&(l=!0,sx=null));var u,h,f=new Set,d=function(e){if(e){var t,r=w(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+tx(i,t,!o)])?a=!0:!o||!(t.altKey||t.metaKey||t.ctrlKey)||Qv.windows&&t.ctrlKey&&t.altKey||Qv.mac&&t.altKey&&!t.ctrlKey&&!t.metaKey||!(u=Pv[t.keyCode])||u==i?o&&t.shiftKey&&d(p[s+tx(i,t,!0)])&&(a=!0):(d(p[s+tx(u,t,!0)])||t.shiftKey&&(h=Lv[t.keyCode])!=i&&h!=u&&d(p[s+tx(h,t,!1)]))&&(a=!0),!a&&d(p._any)&&(a=!0)),l&&(a=!0),a&&c&&t.stopPropagation(),lx=null,a}var ux=function(){function e(t,n,r,i,o){v(this,e),this.className=t,this.left=n,this.top=r,this.width=i,this.height=o}return b(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=hx(t);return[new e(n,i.left-o.left,i.top-o.top,null,i.bottom-i.top)]}return dx(t,n,r)}}])}();function hx(e){var t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==By.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function fx(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 dx(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==By.LTR,s=e.contentDOM,a=s.getBoundingClientRect(),l=hx(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=gw(e,r,1),p=gw(e,i,-1),m=d.type==oy.Text?d:null,g=p.type==oy.Text?p:null;if(m&&(e.lineWrapping||d.widgetLineBreaks)&&(m=fx(e,r,1,m)),g&&(e.lineWrapping||p.widgetLineBreaks)&&(g=fx(e,i,-1,g)),m&&g&&m.from==g.from&&m.to==g.to)return x(S(n.from,n.to,m));var v=m?S(n.from,null,m):C(d,!1),y=g?S(null,n.to,g):C(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(k(h,v.bottom,f,y.top)):v.bottom<y.top&&e.elementAtHeight((v.bottom+y.top)/2).type==oy.Text&&(v.bottom=y.top=(v.bottom+y.top)/2),x(v).concat(b).concat(x(y));function k(e,n,r,i){return new ux(t,e-l.left,n-l.top,Math.max(0,r-e),i-n)}function x(e){for(var t=e.top,n=e.bottom,r=e.horizontal,i=[],o=0;o<r.length;o+=2)i.push(k(r[o],t,r[o+1],n));return i}function S(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==By.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=w(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),k=w(e.bidiSpans(b));try{for(k.s();!(y=k.n()).done;){var x=y.value,S=x.from+b.from,C=x.to+b.from;if(S>=v)break;C>g&&l(Math.max(S,g),null==t&&S<=u,Math.min(C,v),null==n&&C>=d,x.dir)}}catch(e){k.e(e)}finally{k.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 C(e,t){var n=a.top+(t?e.top:e.bottom);return{top:n,bottom:n,horizontal:[]}}}var px=function(){return b(function e(t,n){v(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(mx)!=e.state.facet(mx)&&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(mx);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=w(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,Qv.safari&&Qv.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()}}])}(),mx=bg.define();function gx(e){return[Cb.define(function(t){return new px(t,e)}),mx.of(e)]}var vx=bg.define({combine:function(e){return av(e,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:function(e,t){return Math.min(e,t)},drawRangeCursor:function(e,t){return e||t}})}});function yx(e){return e.startState.facet(vx)!=e.state.facet(vx)}var bx=gx({above:!0,markers:function(e){var t,n=e.state,r=n.facet(vx),i=[],o=w(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:gg.cursor(s.head,s.head>s.anchor?-1:1),h=w(ux.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=yx(e);return n&&wx(e.state,t),e.docChanged||e.selectionSet||n},mount:function(e,t){wx(t.state,e)},class:"cm-cursorLayer"});function wx(e,t){t.style.animationDuration=e.facet(vx).cursorBlinkRate+"ms"}var kx=gx({above:!1,markers:function(e){return e.state.selection.ranges.map(function(t){return t.empty?[]:ux.forRange(e,"cm-selectionBackground",t)}).reduce(function(e,t){return e.concat(t)})},update:function(e,t){return e.docChanged||e.selectionSet||e.viewportChanged||yx(e)},class:"cm-selectionLayer"}),xx=Rg.highest($k.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"}}}})),Sx=Yg.define({map:function(e,t){return null==e?null:t.mapPos(e)}}),Cx=Eg.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(Sx)?t.value:e},e)}}),Ex=Cb.fromClass(function(){return b(function e(t){v(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(Cx);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(Cx)!=n||e.docChanged||e.geometryChanged)&&this.view.requestMeasure(this.measureReq))}},{key:"readPos",value:function(){var e=this.view,t=e.state.field(Cx),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(Cx)!=e&&this.view.dispatch({effects:Sx.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 Ax(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 Mx=function(){return b(function e(t){v(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 pv,i=r.add.bind(r),o=w(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=w(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;Ax(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=w(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 Ax(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}}])}(),Ox=null!=/x/.unicode?"gu":"g",Nx=new RegExp("[\0-\b\n--Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\ufeff-]",Ox),Tx={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"},Rx=null;var Dx=bg.define({combine:function(e){var t=av(e,{render:null,specialChars:Nx,addSpecialChars:null});return(t.replaceTabs=!function(){var e;if(null==Rx&&"undefined"!=typeof document&&document.body){var t=document.body.style;Rx=null!=(null!==(e=t.tabSize)&&void 0!==e?e:t.MozTabSize)}return Rx||!1}())&&(t.specialChars=new RegExp("\t|"+t.specialChars.source,Ox)),t.addSpecialChars&&(t.specialChars=new RegExp(t.specialChars.source+"|"+t.addSpecialChars.source,Ox)),t}});var Px=null;var Lx=function(){function e(t,n){var r;return v(this,e),(r=g(this,e)).options=t,r.code=n,r}return C(e,iy),b(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")+" "+(Tx[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}}])}(),Bx=function(){function e(t){var n;return v(this,e),(n=g(this,e)).width=t,n}return C(e,iy),b(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 Ix=sy.line({class:"cm-activeLine"}),_x=Cb.fromClass(function(){return b(function e(t){v(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=w(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(Ix.range(s.from)),n=s.from)}}catch(e){i.e(e)}finally{i.f()}return sy.set(r)}}])}(),{decorations:function(e){return e.decorations}}),jx=function(){function e(t){var n;return v(this,e),(n=g(this,e)).content=t,n}return C(e,iy),b(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?gy(e.firstChild):[];if(!t.length)return null;var n=window.getComputedStyle(e.parentNode),r=xy(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 Fx=2e3;function Wx(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>Fx?-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):Ev(r.text,e.state.tabSize,n-r.from);return{line:r.number,col:o,off:i}}function Hx(e,t){var n=Wx(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=Wx(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>Fx||n.off>Fx||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(gg.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=Av(d.text,u,e.tabSize,!0);if(p<0)o.push(gg.cursor(d.to));else{var m=Av(d.text,h,e.tabSize);o.push(gg.range(d.from+p,d.from+m))}}return o}(e.state,n,s);return a.length?o?gg.create(a.concat(r.ranges)):gg.create(a):r}}:null}var zx={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}]},Vx={style:"cursor: crosshair"};var qx="-10000px",Ux=function(){return b(function e(t,n,r,i){v(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=w(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=w(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 Kx(e){var t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}var Gx=bg.define({combine:function(e){var t,n,r;return{position:Qv.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)||Kx}}}),Yx=new WeakMap,$x=Cb.fromClass(function(){return b(function e(t){var n=this;v(this,e),this.view=t,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;var r=t.state.facet(Gx);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 Ux(t,Zx,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=w(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(Gx);if(r.position!=this.position&&!this.madeAbsolute){this.position=r.position;var i,o=w(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=w(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=qx,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=w(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(Qv.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=Bb(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(Gx).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=w(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=qx;else{var m=u.arrow?h.dom.querySelector(".cm-tooltip-arrow"):null,g=m?7:0,v=p.right-p.left,y=null!==(t=Yx.get(h))&&void 0!==t?t:p.bottom-p.top,b=h.offset||Qx,k=this.view.textDirection==By.LTR,x=p.width>o.right-o.left?k?o.left:o.right-p.width:k?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),S=this.above[c];!u.strictSide&&(S?d.top-y-g-b.y<o.top:d.bottom+y+g+b.y>o.bottom)&&S==o.bottom-d.bottom>d.top-o.top&&(S=this.above[c]=!S);var C=(S?d.top-o.top:o.bottom-d.bottom)-g;if(C<y&&!1!==h.resize){if(C<this.view.defaultLineHeight){f.style.top=qx;continue}Yx.set(h,y),f.style.height=(y=C)/a+"px"}else f.style.height&&(f.style.height="");var E=S?d.top-y-g-b.y:d.bottom+g+b.y,A=x+v;if(!0!==h.overlap){var M,O=w(l);try{for(O.s();!(M=O.n()).done;){var N=M.value;N.left<A&&N.right>x&&N.top<E+y&&N.bottom>E&&(E=S?N.top-y-2-g:N.bottom+g+2)}}catch(e){O.e(e)}finally{O.f()}}if("absolute"==this.position?(f.style.top=(E-e.parent.top)/a+"px",Xx(f,(x-e.parent.left)/s)):(f.style.top=E/a+"px",Xx(f,x/s)),m){var T=d.left+(k?b.x:-b.x)-(x+14-7);m.style.left=T/s+"px"}!0!==h.overlap&&l.push({left:x,top:E,right:A,bottom:E+y}),f.classList.toggle("cm-tooltip-above",S),f.classList.toggle("cm-tooltip-below",!S),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=w(this.manager.tooltipViews);try{for(t.s();!(e=t.n()).done;){e.value.dom.style.top=qx}}catch(e){t.e(e)}finally{t.f()}}}}])}(),{eventObservers:{scroll:function(){this.maybeMeasure()}}});function Xx(e,t){var n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+"px")}var Jx=$k.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"}}}),Qx={x:0,y:0},Zx=bg.define({enables:[$x,Jx]}),eS=bg.define({combine:function(e){return e.reduce(function(e,t){return e.concat(t)},[])}}),tS=function(){function e(t){var n=this;v(this,e),this.view=t,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new Ux(t,eS,function(e,t){return n.createHostedView(e,t)},function(e){return e.dom.remove()})}return b(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=w(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=w(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=w(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=w(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)}}])}(),nS=Zx.compute([eS],function(e){var t=e.facet(eS);return 0===t.length?null:{pos:Math.min.apply(Math,L(t.map(function(e){return e.pos}))),end:Math.max.apply(Math,L(t.map(function(e){var t;return null!==(t=e.end)&&void 0!==t?t:e.pos}))),create:tS.create,above:t[0].above,arrow:t.some(function(e){return e.arrow})}}),rS=function(){return b(function e(t,n,r,i,o){v(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==By.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 wb(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($x),t=e?e.manager.tooltips.findIndex(function(e){return e.create==tS.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-iS&&t.clientX<=o+iS&&t.clientY>=s-iS&&t.clientY<=a+iS}(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)}}])}(),iS=4;function oS(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=Yg.define(),r=Eg.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=w(e);try{for(s.s();!(i=s.n()).done;){var a=i.value,l=r.changes.mapPos(a.pos,-1,sg.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=w(r.effects);try{for(h.s();!(u=h.n()).done;){var f=u.value;f.is(n)&&(e=f.value),f.is(aS)&&(e=[])}}catch(e){h.e(e)}finally{h.f()}return e},provide:function(e){return eS.from(e)}});return{active:r,extension:[r,Cb.define(function(i){return new rS(i,e,r,n,t.hoverTime||300)}),nS]}}function sS(e,t){var n=e.plugin($x);if(!n)return null;var r=n.manager.tooltips.indexOf(t);return r<0?null:n.manager.tooltipViews[r]}var aS=Yg.define(),lS=bg.define({combine:function(e){var t,n,r,i=w(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 cS(e,t){var n=e.plugin(uS),r=n?n.specs.indexOf(t):-1;return r>-1?n.panels[r]:null}var uS=Cb.fromClass(function(){return b(function e(t){v(this,e),this.input=t.state.facet(dS),this.specs=this.input.filter(function(e){return e}),this.panels=this.specs.map(function(e){return e(t)});var n=t.state.facet(lS);this.top=new hS(t,!0,n.topContainer),this.bottom=new hS(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=w(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(lS);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new hS(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new hS(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();var n=e.state.facet(dS);if(n!=this.input){var r,i=n.filter(function(e){return e}),o=[],s=[],a=[],l=[],c=w(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=w(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 $k.scrollMargins.of(function(t){var n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})}}),hS=function(){return b(function e(t,n,r){v(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=w(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=w(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=fS(n);n=n.nextSibling}else this.dom.insertBefore(i.dom,n)}}catch(e){r.e(e)}finally{r.f()}for(;n;)n=fS(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=w(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=w((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 fS(e){var t=e.nextSibling;return e.remove(),t}var dS=bg.define({enables:uS});function pS(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=Fv("form"),t.input){var i=Fv("input",t.input);/^(text|password|number|email|tel|url)$/.test(i.type)&&i.classList.add("cm-textfield"),i.name||(i.name="input"),r.appendChild(Fv("label",(t.label||"")+": ",i))}else r.appendChild(document.createTextNode(t.label||""));r.appendChild(document.createTextNode(" ")),r.appendChild(Fv("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=Fv("div",r,Fv("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(mS,!1)?e.dispatch({effects:gS.of(i)}):e.dispatch({effects:Yg.appendConfig.of(mS.init(function(){return[i]}))});var o=vS.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(mS).indexOf(i)>-1&&e.dispatch({effects:o})}),t})}}var mS=Eg.define({create:function(){return[]},update:function(e,t){var n,r=w(t.effects);try{var i=function(){var t=n.value;t.is(gS)?e=[t.value].concat(e):t.is(vS)&&(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 dS.computeN([e],function(t){return t.field(e)})}}),gS=Yg.define(),vS=Yg.define();var yS=function(){function e(){return v(this,e),g(this,e,arguments)}return C(e,lv),b(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){}}])}();yS.prototype.elementClass="",yS.prototype.toDOM=void 0,yS.prototype.mapMode=sg.TrackBefore,yS.prototype.startSide=yS.prototype.endSide=-1,yS.prototype.point=!0;var bS=bg.define(),wS=bg.define(),kS={class:"",renderEmptyElements:!1,elementStyle:"",markers:function(){return dv.empty},lineMarker:function(){return null},widgetMarker:function(){return null},lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},xS=bg.define();function SS(e){return[ES(),xS.of(M(M({},kS),e))]}var CS=bg.define({combine:function(e){return e.some(function(e){return e})}});function ES(e){var t=[AS];return e&&!1===e.fixed&&t.push(CS.of(!0)),t}var AS=Cb.fromClass(function(){return b(function e(t){v(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(xS).map(function(e){return new TS(t,e)}),this.fixed=!t.state.facet(CS);var n,r=w(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(CS)!=!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=dv.iter(this.view.state.facet(bS),this.view.viewport.from),o=[],s=this.gutters.map(function(e){return new NS(e,t.view.viewport,-t.view.documentPadding.top)}),a=w(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=w(l.type);try{for(h.s();!(c=h.n()).done;){var f=c.value;if(f.type==oy.Text&&u){OS(i,o,f.from);var d,p=w(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=w(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==oy.Text){OS(i,o,l.from);var v,y=w(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,k=w(s);try{for(k.s();!(b=k.n()).done;){b.value.widget(this.view,l)}}catch(e){k.e(e)}finally{k.f()}}}}catch(e){a.e(e)}finally{a.f()}var x,S=w(s);try{for(S.s();!(x=S.n()).done;){x.value.finish()}}catch(e){S.e(e)}finally{S.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(xS),n=e.state.facet(xS),r=e.docChanged||e.heightChanged||e.viewportChanged||!dv.eq(e.startState.facet(bS),e.state.facet(bS),e.view.viewport.from,e.view.viewport.to);if(t==n){var i,o=w(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=w(n);try{for(l.s();!(s=l.n()).done;){var c=s.value,u=t.indexOf(c);u<0?a.push(new TS(this.view,c)):(this.gutters[u].update(e),a.push(this.gutters[u]))}}catch(e){l.e(e)}finally{l.f()}var h,f=w(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=w(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 $k.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==By.LTR?{left:r,right:i}:{right:r,left:i}})}});function MS(e){return Array.isArray(e)?e:[e]}function OS(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}var NS=function(){return b(function e(t,n,r){v(this,e),this.gutter=t,this.height=r,this.i=0,this.cursor=dv.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 RS(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=[];OS(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=w(e.state.facet(wS));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()}}}])}(),TS=function(){return b(function e(t,n){var r=this;v(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=MS(n.markers(t)),n.initialSpacer&&(this.spacer=new RS(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=MS(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!dv.eq(this.markers,t,r.from,r.to)||!!this.config.lineMarkerChange&&this.config.lineMarkerChange(e)}},{key:"destroy",value:function(){var e,t=w(this.elements);try{for(t.s();!(e=t.n()).done;){e.value.destroy()}}catch(e){t.e(e)}finally{t.f()}}}])}(),RS=function(){return b(function e(t,n,r,i){v(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 DS=bg.define(),PS=bg.define(),LS=bg.define({combine:function(e){return av(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}})}}),BS=function(){function e(t){var n;return v(this,e),(n=g(this,e)).number=t,n}return C(e,yS),b(e,[{key:"eq",value:function(e){return this.number==e.number}},{key:"toDOM",value:function(){return document.createTextNode(this.number)}}])}();function IS(e,t){return e.state.facet(LS).formatNumber(t,e.state)}var _S=xS.compute([LS],function(e){return{class:"cm-lineNumbers",renderEmptyElements:!1,markers:function(e){return e.state.facet(DS)},lineMarker:function(e,t,n){return n.some(function(e){return e.toDOM})?null:new BS(IS(e,e.state.doc.lineAt(t.from).number))},widgetMarker:function(e,t,n){var r,i=w(e.state.facet(PS));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(LS)!=e.state.facet(LS)},initialSpacer:function(e){return new BS(IS(e,jS(e.state.doc.lines)))},updateSpacer:function(e,t){var n=IS(t.view,jS(t.view.state.doc.lines));return n==e.number?e:new BS(n)},domEventHandlers:e.facet(LS).domEventHandlers,side:"before"}});function jS(e){for(var t=9;t<e;)t=10*t+9;return t}var FS=new(function(){function e(){var t;return v(this,e),(t=g(this,e,arguments)).elementClass="cm-activeLineGutter",t}return C(e,yS),b(e)}()),WS=bS.compute(["selection"],function(e){var t,n=[],r=-1,i=w(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(FS.range(s)))}}catch(e){i.e(e)}finally{i.f()}return dv.of(n)});var HS=0,zS=b(function e(t,n){v(this,e),this.from=t,this.to=n}),VS=function(){return b(function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};v(this,e),this.id=HS++,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=KS.match(e)),function(n){var r=e(n);return void 0===r?null:[t,r]}}}])}();VS.closedBy=new VS({deserialize:function(e){return e.split(" ")}}),VS.openedBy=new VS({deserialize:function(e){return e.split(" ")}}),VS.group=new VS({deserialize:function(e){return e.split(" ")}}),VS.isolate=new VS({deserialize:function(e){if(e&&"rtl"!=e&&"ltr"!=e&&"auto"!=e)throw new RangeError("Invalid value for isolate: "+e);return e||"auto"}}),VS.contextHash=new VS({perNode:!0}),VS.lookAhead=new VS({perNode:!0}),VS.mounted=new VS({perNode:!0});var qS=function(){return b(function e(t,n,r){var i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];v(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[VS.mounted.id]}}])}(),US=Object.create(null),KS=function(){function e(t,n,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;v(this,e),this.name=t,this.props=n,this.id=r,this.flags=i}return b(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(VS.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):US,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=w(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=w(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(VS.group),r=-1;r<(n?n.length:0);r++){var i=t[r<0?e.name:n[r]];if(i)return i}}}}])}();KS.none=new KS("",Object.create(null),0,8);var GS,YS=function(){function e(t){v(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 b(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=w(this.types);try{for(s.s();!(o=s.n()).done;){var a,l=o.value,c=null,u=w(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 KS(l.name,c,l.id,l.flags):l)}}catch(e){s.e(e)}finally{s.f()}return new e(t)}}])}(),$S=new WeakMap,XS=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"}(GS||(GS={}));var JS=function(){function e(t,n,r,i,o){if(v(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=w(o);try{for(a.s();!(s=a.n()).done;){var l=D(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 b(e,[{key:"toString",value:function(){var e=qS.get(this);if(e&&!e.overlay)return e.tree.toString();var t,n="",r=w(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 uC(this.topNode,e)}},{key:"cursorAt",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=$S.get(this)||this.topNode,r=new uC(n);return r.moveTo(e,t),$S.set(this,r._tree),r}},{key:"topNode",get:function(){return new rC(this,0,0,null)}},{key:"resolve",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=tC($S.get(this)||this.topNode,e,t,!1);return $S.set(this,n),n}},{key:"resolveInner",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=tC(XS.get(this)||this.topNode,e,t,!0);return XS.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 rC?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=qS.get(o.tree);if(a&&a.overlay&&a.overlay[0].from<=t&&a.overlay[a.overlay.length-1].to>=t){var l=new rC(a.tree,a.overlay[0].from+o.from,-1,o);(i||(i=[r])).push(tC(l,t,n,!1))}}return i?lC(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&GS.IncludeAnonymous)>0,c=this.cursor(a|GS.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:mC(KS.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(KS.none,t,n,r)})}}],[{key:"build",value:function(e){return fC(e)}}])}();JS.empty=new JS(KS.none,[],[],0);var QS=function(){function e(t,n){v(this,e),this.buffer=t,this.index=n}return b(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)}}])}(),ZS=function(){function e(t,n,r){v(this,e),this.buffer=t,this.length=n,this.set=r}return b(e,[{key:"type",get:function(){return KS.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&&!(eC(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 eC(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 tC(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 rC&&e.index<0?null:e.parent;if(!o)return e;e=o}var s=r?0:GS.IgnoreOverlays;if(r)for(var a=e,l=a.parent;l;l=(a=l).parent)a instanceof rC&&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 nC=function(){return b(function e(){v(this,e)},[{key:"cursor",value:function(){return new uC(this,arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}},{key:"getChild",value:function(e){var t=iC(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 iC(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 tC(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,!1)}},{key:"resolveInner",value:function(e){return tC(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,!0)}},{key:"matchContext",value:function(e){return oC(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}}])}(),rC=function(){function e(t,n,r,i){var o;return v(this,e),(o=g(this,e))._tree=t,o.from=n,o.index=r,o._parent=i,o}return C(e,nC),b(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&GS.EnterBracketed&&h instanceof JS&&(d=qS.get(h))&&!d.overlay&&d.bracketed&&r>=f&&r<=f+h.length||eC(i,r,f,f+h.length))if(h instanceof ZS){if(o&GS.ExcludeBuffers)continue;var p=h.findChild(0,h.buffer.length,n,r-f,i);if(p>-1)return new aC(new sC(s,h,t,f),null,p)}else if(o&GS.IncludeAnonymous||!h.type.isAnonymous||hC(h)){var m=void 0;if(!(o&GS.IgnoreMounts)&&(m=qS.get(h))&&!m.overlay)return new e(m.tree,f,t,s);var g=new e(h,f,t,s);return o&GS.IncludeAnonymous||!g.type.isAnonymous?g:g.nextChild(n<0?h.children.length-1:0,n,r,i,o)}}if(o&GS.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&GS.IgnoreOverlays)&&(r=qS.get(this._tree))&&r.overlay){var o,s=t-this.from,a=i&GS.EnterBracketed&&r.bracketed,l=w(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 iC(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 oC(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 sC=b(function e(t,n,r,i){v(this,e),this.parent=t,this.buffer=n,this.index=r,this.start=i}),aC=function(){function e(t,n,r){var i;return v(this,e),(i=g(this,e)).context=t,i._parent=n,i.index=r,i.type=t.buffer.set.types[t.buffer.buffer[r]],i}return C(e,nC),b(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)&GS.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 JS(this.type,e,t,this.to-this.from)}},{key:"toString",value:function(){return this.context.buffer.childString(this.index)}}])}();function lC(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 rC&&n.index<0?null:n.parent,s=e.slice();return o?s[t]=o:s.splice(t,1),new cC(s,n)}var cC=function(){return b(function e(t,n){v(this,e),this.heads=t,this.node=n},[{key:"next",get:function(){return lC(this.heads)}}])}();var uC=function(){return b(function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(v(this,e),this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=n&~GS.EnterBracketed,t instanceof rC)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 rC?(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&GS.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&GS.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());var e=this.mode&GS.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&GS.IncludeAnonymous||c instanceof ZS||!c.type.isAnonymous||hC(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 aC(this.buffer,t,this.stack[s]);return this.bufferNode=new aC(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 oC(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 oC(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 hC(e){return e.children.some(function(e){return e instanceof ZS||!e.type.isAnonymous||hC(e)})}function fC(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 QS(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 ZS(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,j=k;u.pos>P;)I>=0&&u.id==I&&u.size>=0?(u.end<=j-o&&(g(L,B,w,_,u.end,j,I,S,C),_=L.length,j=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,j,I,S,C),L.reverse(),B.reverse(),I>-1&&_>0){var F=function(e,t){return function(n,r,i){var o,s,a=0,l=n.length-1;if(l>=0&&(o=n[l])instanceof JS){if(!l&&o.type==e&&o.length==i)return o;(s=o.prop(VS.lookAhead))&&(a=r[l]+o.length+s)}return v(e,n,r,i,a,t)}}(O,C);A=mC(O,L,B,0,L.length,0,k-w,F,F)}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 ZS(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=[VS.contextHash,o];s=s?[a].concat(s):[a]}if(i>25){var l=[VS.lookAhead,i];s=s?[l].concat(s):[l]}return new JS(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 JS(h[e.topID],b.reverse(),w.reverse(),k)}var dC=new WeakMap;function pC(e,t){if(!e.isAnonymous||t instanceof ZS||t.type!=e)return 1;var n=dC.get(t);if(null==n){n=1;var r,i=w(t.children);try{for(i.s();!(r=i.n()).done;){var o=r.value;if(o.type!=e||!(o instanceof JS)){n=1;break}n+=pC(e,o)}}catch(e){i.e(e)}finally{i.f()}dC.set(t,n)}return n}function mC(e,t,n,r,i,o,s,a,l){for(var c=0,u=r;u<i;u++)c+=pC(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=pC(e,n[c]);for(c++;c<s;c++){var g=pC(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(mC(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 gC=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];v(this,e),this.from=t,this.to=n,this.tree=r,this.offset=i,this.open=(o?1:0)|(s?2:0)}return b(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=w(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}}])}(),vC=function(){return b(function e(){v(this,e)},[{key:"startParse",value:function(e,t,n){return"string"==typeof e&&(e=new yC(e)),n=n?n.length?n.map(function(e){return new zS(e.from,e.to)}):[new zS(0,0)]:[new zS(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}}}])}(),yC=function(){return b(function e(t){v(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 VS({perNode:!0});var bC=0,wC=function(){function e(t,n,r,i){v(this,e),this.name=t,this.set=n,this.base=r,this.modified=i,this.id=bC++}return b(e,[{key:"toString",value:function(){var e,t=this.name,n=w(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=w(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 xC(e);return function(e){return e.modified.indexOf(t)>-1?e:xC.get(e.base||e,e.modified.concat(t).sort(function(e,t){return e.id-t.id}))}}}])}(),kC=0,xC=function(){function e(t){v(this,e),this.name=t,this.instances=[],this.id=kC++}return b(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 wC(t.name,o,t,n),a=w(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=w(t.set);try{for(u.s();!(l=u.n()).done;){var h=l.value;if(!h.modified.length){var f,d=w(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 SC(e){var t=Object.create(null);for(var n in e){var r=e[n];Array.isArray(r)||(r=[r]);var i,o=w(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 EC(r,l,d>0?a.slice(0,d):null);t[p]=m.sort(t[p])}}}catch(e){o.e(e)}finally{o.f()}}return CC.add(t)}var CC=new VS({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 EC(i.tags,i.mode,i.context);n?n.next=o:r=o,n=o}return r}}),EC=function(){return b(function e(t,n,r,i){v(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 AC(e,t){var n,r=Object.create(null),i=w(e);try{for(i.s();!(n=i.n()).done;){var o=n.value;if(Array.isArray(o.tag)){var s,a=w(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=w(e);try{for(i.s();!(t=i.n()).done;){var o,s=w(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 MC(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 OC(r,Array.isArray(t)?t:[t],n);o.highlightRange(e.cursor(),r,i,"",o.highlighters),o.flush(i)}EC.empty=new EC([],2,null);var OC=function(){return b(function e(t,n,r){v(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(CC);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}(e)||EC.empty,u=function(e,t){var n,r=null,i=w(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(VS.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),k=Math.min(n,y);if(b<k&&p)for(;e.from<k&&(this.highlightRange(e,b,k,r,i),this.startSpan(Math.min(k,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 NC,TC=wC.define,RC=TC(),DC=TC(),PC=TC(DC),LC=TC(DC),BC=TC(),IC=TC(BC),_C=TC(BC),jC=TC(),FC=TC(jC),WC=TC(),HC=TC(),zC=TC(),VC=TC(zC),qC=TC(),UC={comment:RC,lineComment:TC(RC),blockComment:TC(RC),docComment:TC(RC),name:DC,variableName:TC(DC),typeName:PC,tagName:TC(PC),propertyName:LC,attributeName:TC(LC),className:TC(DC),labelName:TC(DC),namespace:TC(DC),macroName:TC(DC),literal:BC,string:IC,docString:TC(IC),character:TC(IC),attributeValue:TC(IC),number:_C,integer:TC(_C),float:TC(_C),bool:TC(BC),regexp:TC(BC),escape:TC(BC),color:TC(BC),url:TC(BC),keyword:WC,self:TC(WC),null:TC(WC),atom:TC(WC),unit:TC(WC),modifier:TC(WC),operatorKeyword:TC(WC),controlKeyword:TC(WC),definitionKeyword:TC(WC),moduleKeyword:TC(WC),operator:HC,derefOperator:TC(HC),arithmeticOperator:TC(HC),logicOperator:TC(HC),bitwiseOperator:TC(HC),compareOperator:TC(HC),updateOperator:TC(HC),definitionOperator:TC(HC),typeOperator:TC(HC),controlOperator:TC(HC),punctuation:zC,separator:TC(zC),bracket:VC,angleBracket:TC(VC),squareBracket:TC(VC),paren:TC(VC),brace:TC(VC),content:jC,heading:FC,heading1:TC(FC),heading2:TC(FC),heading3:TC(FC),heading4:TC(FC),heading5:TC(FC),heading6:TC(FC),contentSeparator:TC(jC),list:TC(jC),quote:TC(jC),emphasis:TC(jC),strong:TC(jC),link:TC(jC),monospace:TC(jC),strikethrough:TC(jC),inserted:TC(),deleted:TC(),changed:TC(),invalid:TC(),meta:qC,documentMeta:TC(qC),annotation:TC(qC),processingInstruction:TC(qC),definition:wC.defineModifier("definition"),constant:wC.defineModifier("constant"),function:wC.defineModifier("function"),standard:wC.defineModifier("standard"),local:wC.defineModifier("local"),special:wC.defineModifier("special")};for(var KC in UC){var GC=UC[KC];GC instanceof wC&&(GC.name=KC)}AC([{tag:UC.link,class:"tok-link"},{tag:UC.heading,class:"tok-heading"},{tag:UC.emphasis,class:"tok-emphasis"},{tag:UC.strong,class:"tok-strong"},{tag:UC.keyword,class:"tok-keyword"},{tag:UC.atom,class:"tok-atom"},{tag:UC.bool,class:"tok-bool"},{tag:UC.url,class:"tok-url"},{tag:UC.labelName,class:"tok-labelName"},{tag:UC.inserted,class:"tok-inserted"},{tag:UC.deleted,class:"tok-deleted"},{tag:UC.literal,class:"tok-literal"},{tag:UC.string,class:"tok-string"},{tag:UC.number,class:"tok-number"},{tag:[UC.regexp,UC.escape,UC.special(UC.string)],class:"tok-string2"},{tag:UC.variableName,class:"tok-variableName"},{tag:UC.local(UC.variableName),class:"tok-variableName tok-local"},{tag:UC.definition(UC.variableName),class:"tok-variableName tok-definition"},{tag:UC.special(UC.variableName),class:"tok-variableName2"},{tag:UC.definition(UC.propertyName),class:"tok-propertyName tok-definition"},{tag:UC.typeName,class:"tok-typeName"},{tag:UC.namespace,class:"tok-namespace"},{tag:UC.className,class:"tok-className"},{tag:UC.macroName,class:"tok-macroName"},{tag:UC.propertyName,class:"tok-propertyName"},{tag:UC.operator,class:"tok-operator"},{tag:UC.comment,class:"tok-comment"},{tag:UC.meta,class:"tok-meta"},{tag:UC.invalid,class:"tok-invalid"},{tag:UC.punctuation,class:"tok-punctuation"}]);var YC=new VS;var $C=new VS,XC=function(){return b(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]:"";v(this,e),this.data=t,this.name=i,sv.prototype.hasOwnProperty("tree")||Object.defineProperty(sv.prototype,"tree",{get:function(){return ZC(this)}}),this.parser=n,this.extension=[lE.of(this),sv.languageData.of(function(e,t,n){var r=JC(e,t,n),i=r.type.prop(YC);if(!i)return[];var o=e.facet(i),s=r.type.prop($C);if(s){var a,l=r.resolve(t-r.from,n),c=w(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 JC(e,t,arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1).type.prop(YC)==this.data}},{key:"findRegions",value:function(e){var t=this,n=e.facet(lE);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(YC)!=t.data){var o=e.prop(VS.mounted);if(o){if(o.tree.prop(YC)==t.data){if(o.overlay){var s,a=w(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 JS&&i(h,e.positions[u]+n)}}else r.push({from:n,to:n+e.length})};return i(ZC(e),0),r}},{key:"allowsNesting",get:function(){return!0}}])}();function JC(e,t,n){var r=e.facet(lE),i=ZC(e).topNode;if(!r||r.allowsNesting)for(var o=i;o;o=o.enter(t,n,GS.ExcludeBuffers|GS.EnterBracketed))o.type.isTop&&(i=o);return i}XC.setState=Yg.define();var QC=function(){function e(t,n,r){var i;return v(this,e),(i=g(this,e,[t,n,[],r])).parser=n,i}return C(e,XC),b(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,bg.define({combine:n?function(e){return e.concat(n)}:void 0}));return new e(r,t.parser.configure({props:[YC.add(function(e){return e.isTop?r:void 0})]}),t.name)}}])}();function ZC(e){var t=e.field(XC.state,!1);return t?t.tree:JS.empty}var eE=function(){return b(function e(t){v(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)}}])}(),tE=null,nE=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;v(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 b(e,[{key:"startParse",value:function(){return this.parser.startParse(new eE(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!=JS.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(gC.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(gC.addTree(this.tree,this.fragments,!0)),this.parse=null)}},{key:"withContext",value:function(e){var t=tE;tE=this;try{return e()}finally{tE=t}}},{key:"withoutTempSkipped",value:function(e){for(var t;t=this.tempSkipped.pop();)e=rE(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=gC.applyChanges(r,l),i=JS.empty,o=0,s={from:t.mapPos(s.from,-1),to:t.mapPos(s.to,1)},this.skipped.length){a=[];var c,u=w(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=rE(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,[],JS.empty,0,r,[],null)}},{key:"getSkippingParser",value:function(e){return new(function(){function t(){return v(this,t),g(this,t,arguments)}return C(t,vC),b(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=tE;if(t){var n,s=w(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 JS(KS.none,[],[],o-i)},stoppedAt:null,stopAt:function(){}};return s}}])}())}},{key:"get",value:function(){return tE}}])}();function rE(e,t,n){return gC.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}var iE=function(){function e(t){v(this,e),this.context=t,this.tree=t.tree}return b(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=nE.create(t.facet(lE).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new e(r)}}])}();XC.state=Eg.define({create:iE.init,update:function(e,t){var n,r=w(t.effects);try{for(r.s();!(n=r.n()).done;){var i=n.value;if(i.is(XC.setState))return i.value}}catch(e){r.e(e)}finally{r.f()}return t.startState.facet(lE)!=t.state.facet(lE)?iE.init(t.state):e.apply(t)}});var oE=function(e){var t=setTimeout(function(){return e()},500);return function(){return clearTimeout(t)}};"undefined"!=typeof requestIdleCallback&&(oE=function(e){var t=-1,n=setTimeout(function(){t=requestIdleCallback(e,{timeout:400})},100);return function(){return t<0?clearTimeout(n):cancelIdleCallback(t)}});var sE="undefined"!=typeof navigator&&(null===(NC=navigator.scheduling)||void 0===NC?void 0:NC.isInputPending)?function(){return navigator.scheduling.isInputPending()}:null,aE=Cb.fromClass(function(){return b(function e(t){v(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(XC.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(XC.state);t.tree==t.context.tree&&t.context.isDone(e.doc.length)||(this.working=oE(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(XC.state);if(o.tree!=o.context.tree||!o.context.isDone(i+1e5)){var s=Date.now()+Math.min(this.chunkBudget,100,e&&!sE?Math.max(25,e.timeRemaining()-5):1e9),a=o.context.treeLen<i&&r.doc.length>i+1e3,l=o.context.work(function(){return sE&&sE()||Date.now()>s},i+(a?0:1e5));this.chunkBudget-=Date.now()-t,(l||this.chunkBudget<=0)&&(o.context.takeTree(),this.view.dispatch({effects:XC.setState.of(new iE(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 wb(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()}}}),lE=bg.define({combine:function(e){return e.length?e[0]:null},enables:function(e){return[XC.state,aE,$k.contentAttributes.compute([e],function(t){var n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]}}),cE=b(function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];v(this,e),this.language=t,this.support=n,this.extension=[t,n]}),uE=bg.define(),hE=bg.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 fE(e){var t=e.facet(hE);return 9==t.charCodeAt(0)?e.tabSize*t.length:t.length}function dE(e,t){var n="",r=e.tabSize,i=e.facet(hE)[0];if("\t"==i){for(;t>=r;)n+="\t",t-=r;i=" "}for(var o=0;o<t;o++)n+=i;return n}function pE(e,t){e instanceof sv&&(e=new mE(e));var n,r=w(e.state.facet(uE));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=ZC(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 vE(r,e,n)}(e,o,t):null}var mE=function(){return b(function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};v(this,e),this.state=t,this.options=n,this.unit=fE(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 Ev(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}}])}(),gE=new VS;function vE(e,t,n){for(var r=e;r;r=r.next){var i=yE(r.node);if(i)return i(wE.create(t,n,r))}return 0}function yE(e){var t=e.type.prop(gE);if(t)return t;var n,r=e.firstChild;if(r&&(n=r.type.prop(VS.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?bE:null}function bE(){return 0}var wE=function(){function e(t,n,r){var i;return v(this,e),(i=g(this,e,[t.state,t.options])).base=t,i.pos=n,i.context=r,i}return C(e,mE),b(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(kE(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}},{key:"continue",value:function(){return vE(this.context.next,this.base,this.pos)}}],[{key:"create",value:function(t,n,r){return new e(t,n,r)}}])}();function kE(e,t){for(var n=t;n;n=n.parent)if(e==n)return!0;return!1}function xE(){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 SE=bg.define(),CE=new VS;function EE(e){var t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function AE(e,t,n){var r,i=w(e.facet(SE));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=ZC(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(CE);if(a&&(s.to<r.length-50||r.length==e.doc.length||!EE(s))){var l=a(s,e);l&&l.from<=n&&l.from>=t&&l.to>n&&(i=l)}}}return i}(e,t,n)}function ME(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 OE=Yg.define({map:ME}),NE=Yg.define({map:ME});function TE(e){var t,n=[],r=w(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 RE=Eg.define({create:function(){return sy.none},update:function(e,t){t.isUserEvent("delete")&&t.changes.iterChangedRanges(function(t,n){return e=DE(e,t,n)}),e=e.map(t.changes);var n,r=w(t.effects);try{var i=function(){var r=n.value;if(r.is(OE)&&!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?sy.replace({widget:new zE(i(t.state,r.value))}):HE;e=e.update({add:[o.range(r.value.from,r.value.to)]})}else r.is(NE)&&(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=DE(e,t.selection.main.head)),e},provide:function(e){return $k.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(HE.range(r,i))}return sy.set(t,!0)}});function DE(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 PE(e,t,n){var r,i=null;return null===(r=e.field(RE,!1))||void 0===r||r.between(t,n,function(e,t){(!i||i.from>e)&&(i={from:e,to:t})}),i}function LE(e,t){return e.field(RE,!1)?t:t.concat(Yg.appendConfig.of(FE()))}function BE(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 $k.announce.of("".concat(e.state.phrase(n?"Folded lines":"Unfolded lines")," ").concat(r," ").concat(e.state.phrase("to")," ").concat(i,"."))}var IE=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:function(e){var t,n=w(TE(e));try{for(n.s();!(t=n.n()).done;){var r=t.value,i=AE(e.state,r.from,r.to);if(i)return e.dispatch({effects:LE(e.state,[OE.of(i),BE(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(RE,!1))return!1;var t,n=[],r=w(TE(e));try{for(r.s();!(t=r.n()).done;){var i=t.value,o=PE(e.state,i.from,i.to);o&&n.push(NE.of(o),BE(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=AE(t,i.from,i.to);o&&n.push(OE.of(o)),r=(o?e.lineBlockAt(o.to):i).to+1}return n.length&&e.dispatch({effects:LE(e.state,n)}),!!n.length}},{key:"Ctrl-Alt-]",run:function(e){var t=e.state.field(RE,!1);if(!t||!t.size)return!1;var n=[];return t.between(0,e.state.doc.length,function(e,t){n.push(NE.of({from:e,to:t}))}),e.dispatch({effects:n}),!0}}],_E={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},jE=bg.define({combine:function(e){return av(e,_E)}});function FE(e){var t=[RE,UE];return e&&t.push(jE.of(e)),t}function WE(e,t){var n=e.state,r=n.facet(jE),i=function(t){var n=e.lineBlockAt(e.posAtDOM(t.target)),r=PE(e.state,n.from,n.to);r&&e.dispatch({effects:NE.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 HE=sy.replace({widget:new(function(){function e(){return v(this,e),g(this,e,arguments)}return C(e,iy),b(e,[{key:"toDOM",value:function(e){return WE(e,null)}}])}())}),zE=function(){function e(t){var n;return v(this,e),(n=g(this,e)).value=t,n}return C(e,iy),b(e,[{key:"eq",value:function(e){return this.value==e.value}},{key:"toDOM",value:function(e){return WE(e,this.value)}}])}(),VE={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:function(){return!1}},qE=function(){function e(t,n){var r;return v(this,e),(r=g(this,e)).config=t,r.open=n,r}return C(e,yS),b(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 UE=$k.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"}}),KE=function(){function e(t,n){var r;function i(e){var t=Tv.newName();return(r||(r=Object.create(null)))["."+t]=e,t}v(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 XC?function(e){return e.prop(YC)==s.data}:s?function(e){return e==s}:void 0,this.style=AC(t.map(function(e){return{tag:e.tag,class:e.class||i(Object.assign({},e,{tag:null}))}}),{all:o}).style,this.module=r?new Tv(r):null,this.themeType=n.themeType}return b(e,null,[{key:"define",value:function(t,n){return new e(t,n||{})}}])}(),GE=bg.define(),YE=bg.define({combine:function(e){return e.length?[e[0]]:null}});function $E(e){var t=e.facet(GE);return t.length?t:e.facet(YE)}function XE(e,t){var n,r=[QE];return e instanceof KE&&(e.module&&r.push($k.styleModule.of(e.module)),n=e.themeType),(null==t?void 0:t.fallback)?r.push(YE.of(e)):n?r.push(GE.computeN([$k.darkTheme],function(t){return t.facet($k.darkTheme)==("dark"==n)?[e]:[]})):r.push(GE.of(e)),r}var JE=function(){return b(function e(t){v(this,e),this.markCache=Object.create(null),this.tree=ZC(t.state),this.decorations=this.buildDeco(t,$E(t.state)),this.decoratedTo=t.viewport.to},[{key:"update",value:function(e){var t=ZC(e.state),n=$E(e.state),r=n!=$E(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 sy.none;var r,i=new pv,o=w(e.visibleRanges);try{for(o.s();!(r=o.n()).done;){var s=r.value,a=s.from,l=s.to;MC(this.tree,t,function(e,t,r){i.add(e,t,n.markCache[r]||(n.markCache[r]=sy.mark({class:r})))},a,l)}}catch(e){o.e(e)}finally{o.f()}return i.finish()}}])}(),QE=Rg.high(Cb.fromClass(JE,{decorations:function(e){return e.decorations}})),ZE=KE.define([{tag:UC.meta,color:"#404740"},{tag:UC.link,textDecoration:"underline"},{tag:UC.heading,textDecoration:"underline",fontWeight:"bold"},{tag:UC.emphasis,fontStyle:"italic"},{tag:UC.strong,fontWeight:"bold"},{tag:UC.strikethrough,textDecoration:"line-through"},{tag:UC.keyword,color:"#708"},{tag:[UC.atom,UC.bool,UC.url,UC.contentSeparator,UC.labelName],color:"#219"},{tag:[UC.literal,UC.inserted],color:"#164"},{tag:[UC.string,UC.deleted],color:"#a11"},{tag:[UC.regexp,UC.escape,UC.special(UC.string)],color:"#e40"},{tag:UC.definition(UC.variableName),color:"#00f"},{tag:UC.local(UC.variableName),color:"#30a"},{tag:[UC.typeName,UC.namespace],color:"#085"},{tag:UC.className,color:"#167"},{tag:[UC.special(UC.variableName),UC.macroName],color:"#256"},{tag:UC.definition(UC.propertyName),color:"#00c"},{tag:UC.comment,color:"#940"},{tag:UC.invalid,color:"#f00"}]),eA=$k.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),tA="()[]{}",nA=bg.define({combine:function(e){return av(e,{afterCursor:!0,brackets:tA,maxScanDistance:1e4,renderMatch:oA})}}),rA=sy.mark({class:"cm-matchingBracket"}),iA=sy.mark({class:"cm-nonmatchingBracket"});function oA(e){var t=[],n=e.matched?rA:iA;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 sA(e){var t,n=[],r=e.facet(nA),i=w(e.selection.ranges);try{for(i.s();!(t=i.n()).done;){var o=t.value;if(o.empty){var s=hA(e,o.head,-1,r)||o.head>0&&hA(e,o.head-1,1,r)||r.afterCursor&&(hA(e,o.head,1,r)||o.head<e.doc.length&&hA(e,o.head+1,-1,r));s&&(n=n.concat(r.renderMatch(s,e)))}}}catch(e){i.e(e)}finally{i.f()}return sy.set(n,!0)}var aA=[Cb.fromClass(function(){return b(function e(t){v(this,e),this.paused=!1,this.decorations=sA(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=sA(e.state),this.paused=!1))}}])}(),{decorations:function(e){return e.decorations}}),eA];var lA=new VS;function cA(e,t,n){var r=e.prop(t<0?VS.openedBy:VS.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 uA(e){var t=e.type.prop(lA);return t?t(e.node):e}function hA(e,t,n){for(var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=r.maxScanDistance||1e4,o=r.brackets||tA,s=ZC(e),a=s.resolveInner(t,n),l=a;l;l=l.parent){var c=cA(l.type,n,o);if(c&&l.from<l.to){var u=uA(l);if(u&&(n>0?t>=u.from&&t<u.to:t>u.from&&t<=u.to))return fA(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 fA(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=uA(u);return{start:l,end:h?{from:h.from,to:h.to}:void 0,matched:!0}}if(cA(u.type,n,s))c++;else if(cA(u.type,-n,s)){if(0==c){var f=uA(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 dA=Object.create(null),pA=[KS.none],mA=[],gA=Object.create(null),vA=Object.create(null),yA=0,bA=[["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"]];yA<bA.length;yA++){var wA=D(bA[yA],2),kA=wA[0],xA=wA[1];vA[kA]=CA(dA,xA)}function SA(e,t){mA.indexOf(e)>-1||mA.push(e)}function CA(e,t){var n,r=[],i=w(t.split(" "));try{for(i.s();!(n=i.n()).done;){var o,s=n.value,a=[],l=w(s.split("."));try{for(l.s();!(o=l.n()).done;){var c=o.value,u=e[c]||UC[c];u?"function"==typeof u?a.length?a=a.map(u):SA(c,"Modifier ".concat(c," used at start of tag")):a.length?SA(c,"Tag ".concat(c," used as modifier")):a=Array.isArray(u)?u:[u]:SA(c,"Unknown highlighting tag ".concat(c))}}catch(e){l.e(e)}finally{l.f()}var h,f=w(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=gA[m];if(g)return g.id;var v=gA[m]=KS.define({id:pA.length,name:p,props:[SC(k({},p,r))]});return pA.push(v),v.id}By.RTL,By.LTR;function EA(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 AA=EA(DA,0),MA=EA(RA,0),OA=EA(function(e,t){return RA(e,t,function(e){var t,n=[],r=w(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 NA(e,t){var n=e.languageDataAt("commentTokens",t,1);return n.length?n[0]:{}}var TA=50;function RA(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t.selection.ranges,r=n.map(function(e){return NA(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-TA,n),c=e.sliceDoc(r,r+TA),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*TA?i=o=e.sliceDoc(n,r):(i=e.sliceDoc(n,n+TA),o=e.sliceDoc(r-TA,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 DA(e,t){var n,r=[],i=-1,o=w(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=NA(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=[],k=w(r);try{for(k.s();!(y=k.n()).done;){var x=y.value,S=x.line,C=x.token,E=x.indent,A=x.empty;!x.single&&A||b.push({from:S.from+E,insert:C+" "})}}catch(e){k.e(e)}finally{k.f()}var M=t.changes(b);return{changes:M,selection:t.selection.map(M,1)}}if(1!=e&&r.some(function(e){return e.comment>=0})){var O,N=[],T=w(r);try{for(T.s();!(O=T.n()).done;){var R=O.value,D=R.line,P=R.comment,L=R.token;if(P>=0){var B=D.from+P,I=B+L.length;" "==D.text[I-D.from]&&I++,N.push({from:B,to:I})}}}catch(e){T.e(e)}finally{T.f()}return{changes:N}}return null}var PA=Ug.define(),LA=Ug.define(),BA=bg.define(),IA=bg.define({combine:function(e){return av(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)}}})}}),_A=Eg.define({create:function(){return ZA.empty},update:function(e,t){var n=t.state.facet(IA),r=t.annotation(PA);if(r){var i=VA.fromTransaction(t,r.selection),o=r.side,s=0==o?e.undone:e.done;return s=i?qA(s,s.length,n.minDepth,i):YA(s,t.startState.selection),new ZA(0==o?r.rest:s,0==o?s:r.rest)}var a=t.annotation(LA);if("full"!=a&&"before"!=a||(e=e.isolate()),!1===t.annotation($g.addToHistory))return t.changes.empty?e:e.addMapping(t.changes.desc);var l=VA.fromTransaction(t),c=t.annotation($g.time),u=t.annotation($g.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 ZA(e.done.map(VA.fromJSON),e.undone.map(VA.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(_A,!1);if(!o)return!1;var s=o.pop(e,r,t);return!!s&&(i(s),!0)}}var FA=jA(0,!1),WA=jA(1,!1),HA=jA(0,!0),zA=jA(1,!0),VA=function(){function e(t,n,r,i,o){v(this,e),this.changes=t,this.effects=n,this.mapped=r,this.startSelection=i,this.selectionsAfter=o}return b(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&&lg.fromJSON(t.changes),[],t.mapped&&ag.fromJSON(t.mapped),t.startSelection&&gg.fromJSON(t.startSelection),t.selectionsAfter.map(gg.fromJSON))}},{key:"fromTransaction",value:function(t,n){var r,i=KA,o=w(t.startState.facet(BA));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,KA)}},{key:"selection",value:function(t){return new e(void 0,KA,void 0,void 0,t)}}])}();function qA(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 UA(e,t){return e.length?t.length?e.concat(t):e:t}var KA=[],GA=200;function YA(e,t){if(e.length){var n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-GA));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),qA(e,e.length-1,1e9,n.setSelAfter(r)))}return[VA.selection([t])]}function $A(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 XA(e,t){if(!e.length)return e;for(var n=e.length,r=KA;n;){var i=JA(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?[VA.selection(r)]:KA}function JA(e,t,n){var r=UA(e.selectionsAfter.length?e.selectionsAfter.map(function(e){return e.map(t)}):KA,n);if(!e.changes)return VA.selection(r);var i=e.changes.map(t),o=t.mapDesc(e.changes,!0),s=e.mapped?e.mapped.composeDesc(o):o;return new VA(i,Yg.mapEffects(e.effects,t),s,e.startSelection.map(o),r)}var QA=/^(input\.type|delete)($|\.)/,ZA=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;v(this,e),this.done=t,this.undone=n,this.prevTime=r,this.prevUserEvent=i}return b(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||QA.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)?qA(s,s.length-1,i.minDepth,new VA(t.changes.compose(a.changes),UA(Yg.mapEffects(t.effects,a.changes),a.effects),a.mapped,a.startSelection,KA)):qA(s,s.length,i.minDepth,t),new e(s,KA,n,r)}},{key:"addSelection",value:function(t,n,r,i){var o,s,a=this.done.length?this.done[this.done.length-1].selectionsAfter:KA;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(YA(this.done,t),this.undone,n,r)}},{key:"addMapping",value:function(t){return new e(XA(this.done,t),XA(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:PA.of({side:e,rest:$A(r),selection:o}),userEvent:0==e?"select.undo":"select.redo",scrollIntoView:!0});if(i.changes){var s=1==r.length?KA:r.slice(0,r.length-1);return i.mapped&&(s=XA(s,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:PA.of({side:e,rest:s,selection:o}),filter:!1,userEvent:0==e?"undo":"redo",scrollIntoView:!0})}return null}}])}();ZA.empty=new ZA(KA,KA);var eM=[{key:"Mod-z",run:FA,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:WA,preventDefault:!0},{linux:"Ctrl-Shift-z",run:WA,preventDefault:!0},{key:"Mod-u",run:HA,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:zA,preventDefault:!0}];function tM(e,t){return gg.create(e.ranges.map(t),e.mainIndex)}function nM(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function rM(e,t){var n=e.state,r=e.dispatch,i=tM(n.selection,t);return!i.eq(n.selection,!0)&&(r(nM(n,i)),!0)}function iM(e,t){return gg.cursor(t?e.to:e.from)}function oM(e,t){return rM(e,function(n){return n.empty?e.moveByChar(n,t):iM(n,t)})}function sM(e){return e.textDirectionAt(e.state.selection.main.head)==By.LTR}var aM=function(e){return oM(e,!sM(e))},lM=function(e){return oM(e,sM(e))};function cM(e,t){return rM(e,function(n){return n.empty?e.moveByGroup(n,t):iM(n,t)})}function uM(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 hM(e,t,n){for(var r=ZC(e).resolveInner(t.head),i=n?VS.closedBy:VS.openedBy,o=t.head;;){var s=n?r.childAfter(o):r.childBefore(o);if(!s)break;uM(e,s,i)?r=s:o=n?s.to:s.from}var a,l;return l=r.type.prop(i)&&(a=n?hA(e,r.from,1):hA(e,r.to,-1))&&a.matched?n?a.end.to:a.end.from:n?r.to:r.from,gg.cursor(l,n?-1:1)}function fM(e,t){return rM(e,function(n){if(!n.empty)return iM(n,t);var r=e.moveVertically(n,t);return r.head!=n.head?r:e.moveToLineBoundary(n,t)})}var dM=function(e){return fM(e,!1)},pM=function(e){return fM(e,!0)};function mM(e){var t,n=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,r=0,i=0;if(n){var o,s=w(e.state.facet($k.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 gM(e,t){var n,r=mM(e),i=e.state,o=tM(i.selection,function(n){return n.empty?e.moveVertically(n,t,r.height):iM(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=$k.scrollIntoView(o.main.head,{y:"start",yMargin:s.top-l}))}return e.dispatch(nM(i,o),{effects:n}),!0}var vM=function(e){return gM(e,!1)},yM=function(e){return gM(e,!0)};function bM(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=gg.cursor(r.from+o))}return i}function wM(e,t){var n=tM(e.state.selection,function(e){var n=t(e);return gg.range(e.anchor,n.head,n.goalColumn,n.bidiLevel||void 0)});return!n.eq(e.state.selection)&&(e.dispatch(nM(e.state,n)),!0)}function kM(e,t){return wM(e,function(n){return e.moveByChar(n,t)})}var xM=function(e){return kM(e,!sM(e))},SM=function(e){return kM(e,sM(e))};function CM(e,t){return wM(e,function(n){return e.moveByGroup(n,t)})}function EM(e,t){return wM(e,function(n){return e.moveVertically(n,t)})}var AM=function(e){return EM(e,!1)},MM=function(e){return EM(e,!0)};function OM(e,t){return wM(e,function(n){return e.moveVertically(n,t,mM(e).height)})}var NM=function(e){return OM(e,!1)},TM=function(e){return OM(e,!0)},RM=function(e){var t=e.state;return(0,e.dispatch)(nM(t,{anchor:0})),!0},DM=function(e){var t=e.state;return(0,e.dispatch)(nM(t,{anchor:t.doc.length})),!0},PM=function(e){var t=e.state;return(0,e.dispatch)(nM(t,{anchor:t.selection.main.anchor,head:0})),!0},LM=function(e){var t=e.state;return(0,e.dispatch)(nM(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0};function BM(e,t){var n,r=e.state,i=r.selection,o=r.selection.ranges.slice(),s=w(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(nM(r,gg.create(o,o.length-1))),!0)}function IM(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=_M(e,s,!1)):s>i&&(n="delete.forward",s=_M(e,s,!0)),i=Math.min(i,s),o=Math.max(o,s)}else i=_M(e,i,!1),o=_M(e,o,!0);return i==o?{range:r}:{changes:{from:i,to:o},range:gg.cursor(i,i<r.head?-1:1)}});return!i.changes.empty&&(e.dispatch(r.update(i,{scrollIntoView:!0,userEvent:n,effects:"delete.selection"==n?$k.announce.of(r.phrase("Selection deleted")):void 0})),!0)}function _M(e,t,n){if(e instanceof $k){var r,i=w(e.state.facet($k.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 IM(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=Ev(i,a.tabSize)%fE(a)||fE(a),u=0;u<c&&" "==i[i.length-1-u];u++)s--;o=s}else(o=tg(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=tg(l.text,o-l.from,!1,!1)+l.from);return o})},FM=function(e){return jM(e,!1,!0)},WM=function(e){return jM(e,!0,!1)},HM=function(e,t){return IM(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=tg(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})},zM=function(e){return HM(e,!1)};function VM(e){var t,n=[],r=-1,i=w(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 qM(e,t,n){if(e.readOnly)return!1;var r,i=[],o=[],s=w(VM(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=w(a.ranges);try{for(h.s();!(u=h.n()).done;){var f=u.value;o.push(gg.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=w(a.ranges);try{for(p.s();!(d=p.n()).done;){var m=d.value;o.push(gg.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:gg.create(o,e.selection.mainIndex),userEvent:"move.line"})),!0)}function UM(e,t,n){if(e.readOnly)return!1;var r,i=[],o=w(VM(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 KM=YM(!1),GM=YM(!0);function YM(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=ZC(e).resolveInner(t),i=r.childBefore(t),o=r.childAfter(t);return i&&o&&i.to<=t&&o.from>=t&&(n=i.type.prop(VS.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 mE(n,{simulateBreak:r,simulateDoubleBreak:!!s}),l=pE(a,r);for(null==l&&(l=Ev(/^\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=["",dE(n,l)];return s&&c.push(dE(n,a.lineIndent(o.from,-1))),{changes:{from:r,to:i,insert:Um.of(c)},range:gg.cursor(r+1+c[1].length)}});return r(n.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function $M(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:gg.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}var XM=function(e){var t=e.state,n=e.dispatch;return!t.readOnly&&(n(t.update($M(t,function(e,n){n.push({from:e.from,insert:t.facet(hE)})}),{userEvent:"input.indent"})),!0)},JM=function(e){var t=e.state,n=e.dispatch;return!t.readOnly&&(n(t.update($M(t,function(e,n){var r=/^\s*/.exec(e.text)[0];if(r){for(var i=Ev(r,t.tabSize),o=0,s=dE(t,Math.max(0,i-fE(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)},QM=[{key:"Ctrl-b",run:aM,shift:xM,preventDefault:!0},{key:"Ctrl-f",run:lM,shift:SM},{key:"Ctrl-p",run:dM,shift:AM},{key:"Ctrl-n",run:pM,shift:MM},{key:"Ctrl-a",run:function(e){return rM(e,function(t){return gg.cursor(e.lineBlockAt(t.head).from,1)})},shift:function(e){return wM(e,function(t){return gg.cursor(e.lineBlockAt(t.head).from)})}},{key:"Ctrl-e",run:function(e){return rM(e,function(t){return gg.cursor(e.lineBlockAt(t.head).to,-1)})},shift:function(e){return wM(e,function(t){return gg.cursor(e.lineBlockAt(t.head).to)})}},{key:"Ctrl-d",run:WM},{key:"Ctrl-h",run:FM},{key:"Ctrl-k",run:function(e){return IM(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:zM},{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:Um.of(["",""])},range:gg.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:tg(r.text,n-r.from,!1)+r.from,o=n==r.to?n+1:tg(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:gg.cursor(o)}});return!r.changes.empty&&(n(t.update(r,{scrollIntoView:!0,userEvent:"move.character"})),!0)}},{key:"Ctrl-v",run:yM}],ZM=[{key:"ArrowLeft",run:aM,shift:xM,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:function(e){return cM(e,!sM(e))},shift:function(e){return CM(e,!sM(e))},preventDefault:!0},{mac:"Cmd-ArrowLeft",run:function(e){return rM(e,function(t){return bM(e,t,!sM(e))})},shift:function(e){return wM(e,function(t){return bM(e,t,!sM(e))})},preventDefault:!0},{key:"ArrowRight",run:lM,shift:SM,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:function(e){return cM(e,sM(e))},shift:function(e){return CM(e,sM(e))},preventDefault:!0},{mac:"Cmd-ArrowRight",run:function(e){return rM(e,function(t){return bM(e,t,sM(e))})},shift:function(e){return wM(e,function(t){return bM(e,t,sM(e))})},preventDefault:!0},{key:"ArrowUp",run:dM,shift:AM,preventDefault:!0},{mac:"Cmd-ArrowUp",run:RM,shift:PM},{mac:"Ctrl-ArrowUp",run:vM,shift:NM},{key:"ArrowDown",run:pM,shift:MM,preventDefault:!0},{mac:"Cmd-ArrowDown",run:DM,shift:LM},{mac:"Ctrl-ArrowDown",run:yM,shift:TM},{key:"PageUp",run:vM,shift:NM},{key:"PageDown",run:yM,shift:TM},{key:"Home",run:function(e){return rM(e,function(t){return bM(e,t,!1)})},shift:function(e){return wM(e,function(t){return bM(e,t,!1)})},preventDefault:!0},{key:"Mod-Home",run:RM,shift:PM},{key:"End",run:function(e){return rM(e,function(t){return bM(e,t,!0)})},shift:function(e){return wM(e,function(t){return bM(e,t,!0)})},preventDefault:!0},{key:"Mod-End",run:DM,shift:LM},{key:"Enter",run:KM,shift:KM},{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:FM,shift:FM,preventDefault:!0},{key:"Delete",run:WM,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:zM,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:function(e){return HM(e,!0)},preventDefault:!0},{mac:"Mod-Backspace",run:function(e){return IM(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 IM(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(QM.map(function(e){return{mac:e.key,run:e.run,shift:e.shift}})),eO=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:function(e){return rM(e,function(t){return hM(e.state,t,!sM(e))})},shift:function(e){return wM(e,function(t){return hM(e.state,t,!sM(e))})}},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:function(e){return rM(e,function(t){return hM(e.state,t,sM(e))})},shift:function(e){return wM(e,function(t){return hM(e.state,t,sM(e))})}},{key:"Alt-ArrowUp",run:function(e){return qM(e.state,e.dispatch,!1)}},{key:"Shift-Alt-ArrowUp",run:function(e){return UM(e.state,e.dispatch,!1)}},{key:"Alt-ArrowDown",run:function(e){return qM(e.state,e.dispatch,!0)}},{key:"Shift-Alt-ArrowDown",run:function(e){return UM(e.state,e.dispatch,!0)}},{key:"Mod-Alt-ArrowUp",run:function(e){return BM(e,!1)}},{key:"Mod-Alt-ArrowDown",run:function(e){return BM(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=gg.create([r.main]):r.main.empty||(i=gg.create([gg.cursor(r.main.head)])),!!i&&(n(nM(t,i)),!0)}},{key:"Mod-Enter",run:GM},{key:"Alt-l",mac:"Ctrl-l",run:function(e){var t=e.state,n=e.dispatch,r=VM(t).map(function(e){var n=e.from,r=e.to;return gg.range(n,Math.min(r+1,t.doc.length))});return n(t.update({selection:gg.create(r),userEvent:"select"})),!0}},{key:"Mod-i",run:function(e){var t=e.state,n=e.dispatch,r=tM(t.selection,function(e){var n=ZC(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 gg.range(s.to,s.from)}return e});return!r.eq(t.selection)&&(n(nM(t,r)),!0)},preventDefault:!0},{key:"Mod-[",run:JM},{key:"Mod-]",run:XM},{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 mE(t,{overrideIndentation:function(e){var t=r[e];return null==t?-1:t}}),o=$M(t,function(e,n,o){var s=pE(i,e.from);if(null!=s){/\S/.test(e.text)||(s=0);var a=/^\s*/.exec(e.text)[0],l=dE(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(VM(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=tM(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=tM(e.selection,function(t){var i=hA(e,t.head,-1)||hA(e,t.head,1)||t.head>0&&hA(e,t.head-1,1)||t.head<e.doc.length&&hA(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?gg.range(t.anchor,o):gg.cursor(o)});return!!r&&(t(nM(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=NA(e.state,n.from);return r.line?AA(e):!!r.block&&OA(e)}},{key:"Alt-A",run:MA},{key:"Ctrl-m",mac:"Shift-Alt-m",run:function(e){return e.setTabFocusMode(),!0}}].concat(ZM),tO={key:"Tab",run:XM,shift:JM},nO="function"==typeof String.prototype.normalize?function(e){return e.normalize("NFKD")}:function(e){return e},rO=function(){return b(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;v(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(nO(e))}:nO,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 ng(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=rg(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=ig(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&&(rO.prototype[Symbol.iterator]=function(){return this});var iO={from:-1,to:-1,match:/.*/.exec("")},oO="gm"+(null==/x/.unicode?"":"u"),sO=function(){return b(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(v(this,e),this.text=t,this.to=o,this.curLine="",this.done=!1,this.value=iO,/\\[sWDnr]|\n|\r|\[\^/.test(n))return new cO(t,n,r,i,o);this.re=new RegExp(n,oO+((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=uO(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=uO(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}}}}])}(),aO=new WeakMap,lO=function(){function e(t,n){v(this,e),this.from=t,this.text=n}return b(e,[{key:"to",get:function(){return this.from+this.text.length}}],[{key:"get",value:function(t,n,r){var i=aO.get(t);if(!i||i.from>=r||i.to<=n){var o=new e(n,t.sliceString(n,r));return aO.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)),aO.set(t,new e(a,s)),new e(n,s.slice(n-a,r-a))}}])}(),cO=function(){return b(function e(t,n,r,i,o){v(this,e),this.text=t,this.to=o,this.done=!1,this.value=iO,this.matchPos=uO(t,i),this.re=new RegExp(n,oO+((null==r?void 0:r.ignoreCase)?"i":"")),this.test=null==r?void 0:r.test,this.flat=lO.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=uO(this.text,r+(n==r?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=lO.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+2*this.flat.text.length))}}}])}();function uO(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&&(sO.prototype[Symbol.iterator]=cO.prototype[Symbol.iterator]=function(){return this});var hO={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},fO=bg.define({combine:function(e){return av(e,hO,{highlightWordAroundCursor:function(e,t){return e||t},minSelectionLength:Math.min,maxMatches:Math.min})}});var dO=sy.mark({class:"cm-selectionMatch"}),pO=sy.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function mO(e,t,n,r){return!(0!=n&&e(t.sliceDoc(n-1,n))==rv.Word||r!=t.doc.length&&e(t.sliceDoc(r,r+1))==rv.Word)}var gO=Cb.fromClass(function(){return b(function e(t){v(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(fO),n=e.state,r=n.selection;if(r.ranges.length>1)return sy.none;var i,o=r.main,s=null;if(o.empty){if(!t.highlightWordAroundCursor)return sy.none;var a=n.wordAt(o.head);if(!a)return sy.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 sy.none;if(t.wholeWords){if(i=n.sliceDoc(o.from,o.to),!mO(s=n.charCategorizer(o.head),n,o.from,o.to)||!function(e,t,n,r){return e(t.sliceDoc(n,n+1))==rv.Word&&e(t.sliceDoc(r-1,r))==rv.Word}(s,n,o.from,o.to))return sy.none}else if(!(i=n.sliceDoc(o.from,o.to)))return sy.none}var c,u=[],h=w(e.visibleRanges);try{for(h.s();!(c=h.n()).done;)for(var f=c.value,d=new rO(n.doc,i,f.from,f.to);!d.next().done;){var p=d.value,m=p.from,g=p.to;if((!s||mO(s,n,m,g))&&(o.empty&&m<=o.from&&g>=o.to?u.push(pO.range(m,g)):(m>=o.to||g<=o.from)&&u.push(dO.range(m,g)),u.length>t.maxMatches))return sy.none}}catch(e){h.e(e)}finally{h.f()}return sy.set(u)}}])}(),{decorations:function(e){return e.decorations}}),vO=$k.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}});var yO=bg.define({combine:function(e){return av(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:function(e){return new GO(e)},scrollToMatch:function(e){return $k.scrollIntoView(e)}})}}),bO=function(){return b(function e(t){v(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,oO),!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 AO(this):new xO(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:sv.create({doc:e});return null==n&&(n=r.doc.length),this.regexp?SO(this,r,t,n):kO(this,r,t,n)}}])}(),wO=b(function e(t){v(this,e),this.spec=t});function kO(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(CO(i,n-o))==rv.Word&&t(EO(i,n-o))==rv.Word||t(EO(i,r-o))==rv.Word&&t(CO(i,r-o))==rv.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 rO(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:function(e){return e.toLowerCase()},i)}var xO=function(){function e(t){return v(this,e),g(this,e,[t])}return C(e,wO),b(e,[{key:"nextMatch",value:function(e,t,n){var r=kO(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){var i=Math.min(e.doc.length,t+this.spec.unquoted.length);r=kO(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=kO(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=kO(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=kO(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 SO(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(CO(n.input,n.index))!=rv.Word||o(EO(n.input,n.index))!=rv.Word)&&(o(EO(n.input,n.index+n[0].length))!=rv.Word||o(CO(n.input,n.index+n[0].length))!=rv.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 sO(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function CO(e,t){return e.slice(tg(e,t,!1),t)}function EO(e,t){return e.slice(t,tg(e,t))}var AO=function(){function e(){return v(this,e),g(this,e,arguments)}return C(e,wO),b(e,[{key:"nextMatch",value:function(e,t,n){var r=SO(this.spec,e,n,e.doc.length).next();return r.done&&(r=SO(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=SO(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=SO(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=SO(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)}}])}(),MO=Yg.define(),OO=Yg.define(),NO=Eg.define({create:function(e){return new TO(HO(e).create(),null)},update:function(e,t){var n,r=w(t.effects);try{for(r.s();!(n=r.n()).done;){var i=n.value;i.is(MO)?e=new TO(i.value.create(),e.panel):i.is(OO)&&(e=new TO(e.query,i.value?WO:null))}}catch(e){r.e(e)}finally{r.f()}return e},provide:function(e){return dS.from(e,function(e){return e.panel})}}),TO=b(function e(t,n){v(this,e),this.query=t,this.panel=n}),RO=sy.mark({class:"cm-searchMatch"}),DO=sy.mark({class:"cm-searchMatch cm-searchMatch-selected"}),PO=Cb.fromClass(function(){return b(function e(t){v(this,e),this.view=t,this.decorations=this.highlight(t.state.field(NO))},[{key:"update",value:function(e){var t=e.state.field(NO);(t!=e.startState.field(NO)||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 sy.none;for(var n=this.view,r=new pv,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?DO:RO)})}return r.finish()}}])}(),{decorations:function(e){return e.decorations}});function LO(e){return function(t){var n=t.state.field(NO,!1);return n&&n.query.spec.valid?e(t,n):qO(t)}}var BO=LO(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=gg.single(i.from,i.to),s=e.state.facet(yO);return e.dispatch({selection:o,effects:[JO(e,i),s.scrollToMatch(o.main,e)],userEvent:"select.search"}),VO(e),!0}),IO=LO(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=gg.single(o.from,o.to),a=e.state.facet(yO);return e.dispatch({selection:s,effects:[JO(e,o),a.scrollToMatch(s.main,e)],userEvent:"select.search"}),VO(e),!0}),_O=LO(function(e,t){var n=t.query.matchAll(e.state,1e3);return!(!n||!n.length)&&(e.dispatch({selection:gg.create(n.map(function(e){return gg.range(e.from,e.to)})),userEvent:"select.search.matches"}),!0)}),jO=LO(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($k.announce.of(r.phrase("replaced match on line $",r.doc.lineAt(o).number)+".")));var d=e.state.changes(h);return u&&(l=gg.single(u.from,u.to).map(d),f.push(JO(e,u)),f.push(r.facet(yO).scrollToMatch(l.main,e))),e.dispatch({changes:d,selection:l,effects:f,userEvent:"input.replace"}),!0}),FO=LO(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:$k.announce.of(i),userEvent:"input.replace.all"}),!0});function WO(e){return e.state.facet(yO).createPanel(e)}function HO(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(yO);return new bO({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 zO(e){var t=cS(e,WO);return t&&t.dom.querySelector("[main-field]")}function VO(e){var t=zO(e);t&&t==e.root.activeElement&&t.select()}var qO=function(e){var t=e.state.field(NO,!1);if(t&&t.panel){var n=zO(e);if(n&&n!=e.root.activeElement){var r=HO(e.state,t.query.spec);r.valid&&e.dispatch({effects:MO.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[OO.of(!0),t?MO.of(HO(e.state,t.query.spec)):Yg.appendConfig.of(ZO)]});return!0},UO=function(e){var t=e.state.field(NO,!1);if(!t||!t.panel)return!1;var n=cS(e,WO);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:OO.of(!1)}),!0},KO=[{key:"Mod-f",run:qO,scope:"editor search-panel"},{key:"F3",run:BO,shift:IO,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:BO,shift:IO,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:UO,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 rO(t.doc,t.sliceDoc(o,s));!c.next().done;){if(a.length>1e3)return!1;c.value.from==o&&(l=a.length),a.push(gg.range(c.value.from,c.value.to))}return n(t.update({selection:gg.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=pS(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=D(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=gg.cursor(p.from+Math.max(0,Math.min(h,p.length)));e.dispatch({effects:[i,$k.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=gg.create(r.ranges.map(function(e){return t.wordAt(e.head)||gg.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 rO(e.doc,t,0,Math.max(0,o[o.length-1].from-1)),c=n=!0,u=r},c=!1,u=new rO(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(gg.range(o.from,o.to),!1),effects:$k.scrollIntoView(o.to)})),!0)},preventDefault:!0}],GO=function(){return b(function e(t){var n=this;v(this,e),this.view=t;var r=this.query=t.state.field(NO).query.spec;function i(e,t,n){return Fv("button",{class:"cm-button",name:e,onclick:t,type:"button"},n)}this.commit=this.commit.bind(this),this.searchField=Fv("input",{value:r.search,placeholder:YO(t,"Find"),"aria-label":YO(t,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=Fv("input",{value:r.replace,placeholder:YO(t,"Replace"),"aria-label":YO(t,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=Fv("input",{type:"checkbox",name:"case",form:"",checked:r.caseSensitive,onchange:this.commit}),this.reField=Fv("input",{type:"checkbox",name:"re",form:"",checked:r.regexp,onchange:this.commit}),this.wordField=Fv("input",{type:"checkbox",name:"word",form:"",checked:r.wholeWord,onchange:this.commit}),this.dom=Fv("div",{onkeydown:function(e){return n.keydown(e)},class:"cm-search"},[this.searchField,i("next",function(){return BO(t)},[YO(t,"next")]),i("prev",function(){return IO(t)},[YO(t,"previous")]),i("select",function(){return _O(t)},[YO(t,"all")]),Fv("label",null,[this.caseField,YO(t,"match case")]),Fv("label",null,[this.reField,YO(t,"regexp")]),Fv("label",null,[this.wordField,YO(t,"by word")])].concat(L(t.state.readOnly?[]:[Fv("br"),this.replaceField,i("replace",function(){return jO(t)},[YO(t,"replace")]),i("replaceAll",function(){return FO(t)},[YO(t,"replace all")])]),[Fv("button",{name:"close",onclick:function(){return UO(t)},"aria-label":YO(t,"close"),type:"button"},["×"])]))},[{key:"commit",value:function(){var e=new bO({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:MO.of(e)}))}},{key:"keydown",value:function(e){var t,n,r;t=this.view,n=e,r="search-panel",cx(ox(t.state),n,t,r)?e.preventDefault():13==e.keyCode&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?IO:BO)(this.view)):13==e.keyCode&&e.target==this.replaceField&&(e.preventDefault(),jO(this.view))}},{key:"update",value:function(e){var t,n=w(e.transactions);try{for(n.s();!(t=n.n()).done;){var r,i=w(t.value.effects);try{for(i.s();!(r=i.n()).done;){var o=r.value;o.is(MO)&&!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(yO).top}}])}();function YO(e,t){return e.state.phrase(t)}var $O=30,XO=/[\s\.,:;?!]/;function JO(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-$O),a=Math.min(o,r+$O),l=e.state.sliceDoc(s,a);if(s!=i.from)for(var c=0;c<$O;c++)if(!XO.test(l[c+1])&&XO.test(l[c])){l=l.slice(c);break}if(a!=o)for(var u=l.length-1;u>l.length-$O;u--)if(!XO.test(l[u-1])&&XO.test(l[u])){l=l.slice(0,u);break}return $k.announce.of("".concat(e.state.phrase("current match"),". ").concat(l," ").concat(e.state.phrase("on line")," ").concat(i.number,"."))}var QO=$k.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"}}),ZO=[NO,Rg.low(PO),QO],eN=function(){return b(function e(t,n,r,i){v(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=ZC(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(oN(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 tN(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 nN(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=w(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=tN(n)+tN(r)+"*$";return[new RegExp("^"+a),new RegExp(a)]}(t),r=D(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 rN=b(function e(t,n,r,i){v(this,e),this.completion=t,this.source=n,this.match=r,this.score=i});function iN(e){return e.selection.main.from}function oN(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 sN=Ug.define();var aN=new WeakMap;function lN(e){if(!Array.isArray(e))return e;var t=aN.get(e);return t||aN.set(e,t=nN(e)),t}var cN=Yg.define(),uN=Yg.define(),hN=function(){return b(function e(t){v(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=ng(t,n),i=ig(r);this.chars.push(r);var o=t.slice(n,n+i),s=o.toUpperCase();this.folded.push(ng(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=ng(e,0),a=ig(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=ng(e,f);p!=t[h]&&p!=n[h]||(r[h++]=f),f+=ig(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=ng(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=rg(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+=ig(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=w(t);try{for(s.s();!(r=s.n()).done;){var a=r.value,l=a+(this.astral?ig(ng(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)}}])}(),fN=function(){return b(function e(t){v(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)}}])}(),dN=bg.define({combine:function(e){return av(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:mN,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 pN(e(n),t(n))}},optionClass:function(e,t){return function(n){return pN(e(n),t(n))}},addToOptions:function(e,t){return e.concat(t)},filterStrict:function(e,t){return e||t}})}});function pN(e,t){return e?t?e+" "+t:e:t}function mN(e,t,n,r,i,o){var s,a,l=e.textDirection==By.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 gN(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 vN=function(){return b(function e(t,n,r){var i=this;v(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(dN);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,L(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=gN(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(dN).closeOnBlur&&e.relatedTarget!=t.contentDOM&&t.dispatch({effects:uN.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=gN(o.length,s,e.state.facet(dN).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=w(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=w(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=gN(n.options.length,n.selected,this.view.state.facet(dN).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 wb(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(dN).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=w(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 yN(e,t){return function(n){return new vN(n,e,t)}}function bN(e){return 100*(e.boost||0)+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}var wN=function(){function e(t,n,r,i,o,s){v(this,e),this.options=t,this.attrs=n,this.tooltip=r,this.timestamp=i,this.selected=o,this.disabled=s}return b(e,[{key:"setSelected",value:function(t,n){return t==this.selected||t>=this.options.length?this:new e(this.options,CN(n,t),this.tooltip,this.timestamp,t,this.disabled)}},{key:"map",value:function(t){return new e(this.options,this.attrs,M(M({},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(dN),l=w(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=w(c.result.options);try{for(f.s();!(h=f.n()).done;){var d=h.value;s(new rN(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 fN(m):new hN(m),y=w(c.result.options);try{for(y.s();!(p=y.n()).done;){var b=p.value;if(g=v.match(b.label)){var k=b.displayLabel?u?u(b,g.matched):[]:g.matched,x=g.score+(b.boost||0);if(s(new rN(b,c.source,k,x)),"object"==I(b.section)&&"dynamic"===b.section.rank){var S=b.section.name;o||(o=Object.create(null)),o[S]=Math.max(x,o[S]||-1e9)}}}}catch(e){y.e(e)}finally{y.f()}}}}}catch(e){l.e(e)}finally{l.f()}if(i){var C,E=Object.create(null),A=0,M=w(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(M.s();!(C=M.n()).done;){var O=C.value;A-=1e5,E[O.name]=A}}catch(e){M.e(e)}finally{M.f()}var N,T=w(r);try{for(T.s();!(N=T.n()).done;){var R=N.value,D=R.completion.section;D&&(R.score+=E["string"==typeof D?D:D.name])}}catch(e){T.e(e)}finally{T.f()}}var P,L=[],B=null,_=a.compareCompletions,j=w(r.sort(function(e,t){return t.score-e.score||_(e.completion,t.completion)}));try{for(j.s();!(P=j.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):bN(F.completion)>bN(B)&&(L[L.length-1]=F),B=F.completion}}catch(e){j.e(e)}finally{j.f()}return L}(t,n);if(!a.length)return i&&t.some(function(e){return e.isPending})?i.setDisabled():null;var l=n.facet(dN).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,CN(r,l),{pos:t.reduce(function(e,t){return t.hasResult()?Math.min(e,t.from):e},1e8),create:PN,above:o.aboveCursor},i?i.timestamp:Date.now(),l,!1)}}])}(),kN=function(){function e(t,n,r){v(this,e),this.active=t,this.id=n,this.open=r}return b(e,[{key:"update",value:function(t){var n=this,r=t.state,i=r.facet(dN),o=(i.override||r.languageDataAt("autocomplete",iN(r)).map(lN)).map(function(e){return(n.active.find(function(t){return t.source==e})||new MN(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(NN)});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=wN.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 MN(e.source,0):e}));var l,c=w(t.effects);try{for(c.s();!(l=c.n()).done;){var u=l.value;u.is(TN)&&(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?xN:SN}}],[{key:"start",value:function(){return new e(EN,"cm-ac-"+Math.floor(2e6*Math.random()).toString(36),null)}}])}();var xN={"aria-autocomplete":"list"},SN={};function CN(e,t){var n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(n["aria-activedescendant"]=e+"-"+t),n}var EN=[];function AN(e,t){if(e.isUserEvent("input.complete")){var n=e.annotation(sN);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 MN=function(){function e(t,n){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];v(this,e),this.source=t,this.state=n,this.explicit=r}return b(e,[{key:"hasResult",value:function(){return!1}},{key:"isPending",get:function(){return 1==this.state}},{key:"update",value:function(t,n){var r=AN(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=w(t.effects);try{for(s.s();!(o=s.n()).done;){var a=o.value;if(a.is(cN))i=new e(i.source,1,a.value);else if(a.is(uN))i=new e(i.source,0);else if(a.is(NN)){var l,c=w(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(iN(e.state))}}])}(),ON=function(){function e(t,n,r,i,o,s){var a;return v(this,e),(a=g(this,e,[t,3,n])).limit=r,a.result=i,a.from=o,a.to=s,a}return C(e,MN),b(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=iN(t.state);if(a>s||!i||2&n&&(iN(t.startState)==this.from||a<this.limit))return new MN(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):oN(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 eN(t.state,a,!1)))?new e(this.source,this.explicit,l,i,i.from,null!==(r=i.to)&&void 0!==r?r:iN(t.state)):new MN(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 MN(this.source,0)}},{key:"touches",value:function(e){return e.changes.touchesRange(this.from,this.to)}}])}();var NN=Yg.define({map:function(e,t){return e.map(function(e){return e.map(t)})}}),TN=Yg.define(),RN=Eg.define({create:function(){return kN.start()},update:function(e,t){return e.update(t)},provide:function(e){return[Zx.from(e,function(e){return e.tooltip}),$k.contentAttributes.from(e,function(e){return e.attrs})]}});function DN(e,t){var n=t.completion.apply||t.completion.label,r=e.state.field(RN).active.find(function(e){return e.source==t.source});return r instanceof ON&&("string"==typeof n?e.dispatch(M(M({},function(e,t,n,r){var i=e.selection.main,o=n-i.from,s=r-i.from;return M(M({},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:gg.cursor(a.from+o+l.length)}})),{},{scrollIntoView:!0,userEvent:"input.complete"})}(e.state,n,r.from,r.to)),{},{annotations:sN.of(t.completion)})):n(e,t.completion,r.from,r.to),!0)}var PN=yN(RN,DN);function LN(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"option";return function(n){var r=n.state.field(RN,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(dN).interactionDelay)return!1;var i,o=1;"page"==t&&(i=sS(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:TN.of(a)}),!0}}var BN=function(e){return!!e.state.field(RN,!1)&&(e.dispatch({effects:cN.of(!0)}),!0)},IN=b(function e(t,n){v(this,e),this.active=t,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}),_N=Cb.fromClass(function(){return b(function e(t){v(this,e),this.view=t,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;var n,r=w(t.state.field(RN).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(RN),r=e.state.facet(dN);if(e.selectionSet||e.docChanged||e.startState.field(RN)!=n){for(var i=e.transactions.some(function(e){var t=AN(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=w(s.context.abortListeners);try{for(l.s();!(a=l.n()).done;){var c=a.value;try{c()}catch(e){wb(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,L(e.transactions))}}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(function(e){return e.effects.some(function(e){return e.is(cN)})})&&(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=w(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(RN),r=w(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(dN).updateSyncTime))}},{key:"startQuery",value:function(e){var t=this,n=this.view.state,r=iN(n),i=new eN(n,r,e.explicit,this.view),o=new IN(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:uN.of(null)}),wb(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(dN).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(dN),i=this.view.state.field(RN),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=iN(a.updates.length?a.updates[0].startState:t.view.state),u=Math.min(c,a.done.from+(a.active.explicit?0:1)),h=new ON(a.active.source,a.active.explicit,u,a.done,a.done.from,null!==(e=a.done.to)&&void 0!==e?e:c),f=w(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 MN(a.active.source,0),v=w(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:NN.of(n)})}}])}(),{eventHandlers:{blur:function(e){var t=this,n=this.view.state.field(RN,!1);if(n&&n.tooltip&&this.view.state.facet(dN).closeOnBlur){var r=n.open&&sS(this.view,n.open.tooltip);r&&r.dom.contains(e.relatedTarget)||setTimeout(function(){return t.view.dispatch({effects:uN.of(null)})},10)}},compositionstart:function(){this.composing=1},compositionend:function(){var e=this;3==this.composing&&setTimeout(function(){return e.view.dispatch({effects:cN.of(!1)})},20),this.composing=0}}}),jN="object"==("undefined"==typeof navigator?"undefined":I(navigator))&&/Win/.test(navigator.platform),FN=Rg.highest($k.domEventHandlers({keydown:function(e,t){var n=t.state.field(RN,!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&&DN(t,r),!1}})),WN=$k.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"}}}),HN={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},zN=Yg.define({map:function(e,t){var n=t.mapPos(e,-1,sg.TrackAfter);return null==n?void 0:n}}),VN=new(function(){function e(){return v(this,e),g(this,e,arguments)}return C(e,lv),b(e)}());VN.startSide=1,VN.endSide=-1;var qN=Eg.define({create:function(){return dv.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=w(t.effects);try{for(i.s();!(r=i.n()).done;){var o=r.value;o.is(zN)&&(e=e.update({add:[VN.range(o.value,o.value+1)]}))}}catch(e){i.e(e)}finally{i.f()}return e}});var UN="()[]{}<>«»»«[]{}";function KN(e){for(var t=0;t<16;t+=2)if(UN.charCodeAt(t)==e)return UN.charAt(t+1);return rg(e<128?e:e+1)}function GN(e,t){return e.languageDataAt("closeBrackets",t)[0]||HN}var YN="object"==("undefined"==typeof navigator?"undefined":I(navigator))&&/Android\b/.test(navigator.userAgent),$N=$k.inputHandler.of(function(e,t,n,r){if((YN?e.composing:e.compositionStarted)||e.state.readOnly)return!1;var i=e.state.selection.main;if(r.length>2||2==r.length&&1==ig(ng(r,0))||t!=i.from||n!=i.to)return!1;var o=function(e,t){var n,r=GN(e,e.selection.main.head),i=r.brackets||HN.brackets,o=w(i);try{for(o.s();!(n=o.n()).done;){var s=n.value,a=KN(ng(s,0));if(t==s)return a==s?tT(e,s,i.indexOf(s+s+s)>-1,r):ZN(e,s,a,r.before||HN.before);if(t==a&&JN(e,e.selection.main.from))return eT(e,s,a)}}catch(e){o.e(e)}finally{o.f()}return null}(e.state,r);return!!o&&(e.dispatch(o),!0)}),XN=[{key:"Backspace",run:function(e){var t=e.state,n=e.dispatch;if(t.readOnly)return!1;var r=GN(t,t.selection.main.head).brackets||HN.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 ig(ng(n,0))==n.length?n:n.slice(1)}(t.doc,e.head),s=w(r);try{for(s.s();!(n=s.n()).done;){var a=n.value;if(a==o&&QN(t.doc,e.head)==KN(ng(a,0)))return{changes:{from:e.head-a.length,to:e.head+a.length},range:gg.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 JN(e,t){var n=!1;return e.field(qN).between(0,e.doc.length,function(e){e==t&&(n=!0)}),n}function QN(e,t){var n=e.sliceString(t,t+2);return n.slice(0,ig(ng(n,0)))}function ZN(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:zN.of(o.to+t.length),range:gg.range(o.anchor+t.length,o.head+t.length)};var s=QN(e.doc,o.head);return!s||/\s/.test(s)||r.indexOf(s)>-1?{changes:{insert:t+n,from:o.head},effects:zN.of(o.head+t.length),range:gg.cursor(o.head+t.length)}:{range:i=o}});return i?null:e.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function eT(e,t,n){var r=null,i=e.changeByRange(function(t){return t.empty&&QN(e.doc,t.head)==n?{changes:{from:t.head,to:t.head+n.length,insert:n},range:gg.cursor(t.head+n.length)}:r={range:t}});return r?null:e.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function tT(e,t,n,r){var i=r.stringPrefixes||HN.stringPrefixes,o=null,s=e.changeByRange(function(r){if(!r.empty)return{changes:[{insert:t,from:r.from},{insert:t,from:r.to}],effects:zN.of(r.to+t.length),range:gg.range(r.anchor+t.length,r.head+t.length)};var s,a=r.head,l=QN(e.doc,a);if(l==t){if(nT(e,a))return{changes:{insert:t+t,from:a},effects:zN.of(a+t.length),range:gg.cursor(a+t.length)};if(JN(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:gg.cursor(a+c.length)}}}else{if(n&&e.sliceDoc(a-2*t.length,a)==t+t&&(s=rT(e,a-2*t.length,i))>-1&&nT(e,s))return{changes:{insert:t+t+t+t,from:a},effects:zN.of(a+t.length),range:gg.cursor(a+t.length)};if(e.charCategorizer(a)(l)!=rv.Word&&rT(e,a,i)>-1&&!function(e,t,n,r){for(var i=ZC(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:zN.of(a+t.length),range:gg.cursor(a+t.length)}}return{range:o=r}});return o?null:e.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function nT(e,t){var n=ZC(e).resolveInner(t+1);return n.parent&&n.from==t}function rT(e,t,n){var r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=rv.Word)return t;var i,o=w(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))!=rv.Word)return a}}catch(e){o.e(e)}finally{o.f()}return-1}var iT=[{key:"Ctrl-Space",run:BN},{mac:"Alt-`",run:BN},{mac:"Alt-i",run:BN},{key:"Escape",run:function(e){var t=e.state.field(RN,!1);return!(!t||!t.active.some(function(e){return 0!=e.state}))&&(e.dispatch({effects:uN.of(null)}),!0)}},{key:"ArrowDown",run:LN(!0)},{key:"ArrowUp",run:LN(!1)},{key:"PageDown",run:LN(!0,"page")},{key:"PageUp",run:LN(!1,"page")},{key:"Enter",run:function(e){var t=e.state.field(RN,!1);return!(e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(dN).interactionDelay)&&DN(e,t.open.options[t.open.selected])}}],oT=Rg.highest(rx.computeN([dN],function(e){return e.facet(dN).defaultKeymap?[iT]:[]})),sT=b(function e(t,n,r){v(this,e),this.from=t,this.to=n,this.diagnostic=r}),aT=function(){function e(t,n,r){v(this,e),this.diagnostics=t,this.panel=n,this.selected=r}return b(e,null,[{key:"init",value:function(t,n,r){var i=r.facet(bT).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 pv,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=w(e);try{for(i.s();!(t=i.n()).done;){var o=t.value,s=OT(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,sy.widget({widget:new ST(g),diagnostics:a.slice()}));else{var v=a.reduce(function(e,t){return t.markClass?e+" "+t.markClass:e},"");s.add(t,n,sy.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,lT(p))}}])}();function lT(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 sT(r.from,n,r.diagnostic)}else r=new sT(e,n,t||o.diagnostics[0])}),r}function cT(e,t){return e.field(dT,!1)?t:t.concat(Yg.appendConfig.of(NT))}var uT=Yg.define(),hT=Yg.define(),fT=Yg.define(),dT=Eg.define({create:function(){return new aT(sy.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=lT(n,e.selected.diagnostic,o)||lT(n,null,o)}!n.size&&i&&t.state.facet(bT).autoPanel&&(i=null),e=new aT(n,i,r)}var s,a=w(t.effects);try{for(a.s();!(s=a.n()).done;){var l=s.value;if(l.is(uT)){var c=t.state.facet(bT).autoPanel?l.value.length?ET.open:null:e.panel;e=aT.init(l.value,c,t.state)}else l.is(hT)?e=new aT(e.diagnostics,l.value?ET.open:null,e.selected):l.is(fT)&&(e=new aT(e.diagnostics,e.panel,l.value))}}catch(e){a.e(e)}finally{a.f()}return e},provide:function(e){return[dS.from(e,function(e){return e.panel}),$k.decorations.from(e,function(e){return e.diagnostics})]}}),pT=sy.mark({class:"cm-lintRange cm-lintRange-active"});function mT(e,t,n){var r,i=e.state.field(dT).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(bT).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:gT(e,r)}}}:null}function gT(e,t){return Fv("ul",{class:"cm-tooltip-lint"},t.map(function(t){return xT(e,t,!1)}))}var vT=function(e){var t=e.state.field(dT,!1);return!(!t||!t.panel)&&(e.dispatch({effects:hT.of(!1)}),!0)},yT=[{key:"Mod-Shift-m",run:function(e){var t=e.state.field(dT,!1);t&&t.panel||e.dispatch({effects:cT(e.state,[hT.of(!0)])});var n=cS(e,ET.open);return n&&n.dom.querySelector(".cm-panel-lint ul").focus(),!0},preventDefault:!0},{key:"F8",run:function(e){var t=e.state.field(dT,!1);if(!t)return!1;var n=e.state.selection.main,r=lT(t.diagnostics,null,n.to+1);return!(!r&&(!(r=lT(t.diagnostics,null,0))||r.from==n.from&&r.to==n.to))&&(e.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),!0)}}],bT=bg.define({combine:function(e){return M({sources:e.map(function(e){return e.source}).filter(function(e){return null!=e})},av(e.map(function(e){return e.config}),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:function(){return null}},{delay:Math.max,markerFilter:wT,tooltipFilter:wT,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 wT(e,t){return e?t?function(n,r){return t(e(n,r),r)}:e:t}function kT(e){var t=[];if(e){var n,r=w(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 xT(e,t,n){var r,i=n?kT(t.actions):[];return Fv("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},Fv("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=lT(e.state.field(dT).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),Fv("u",a.slice(l,l+1)),a.slice(l+1)];return Fv("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&&Fv("div",{class:"cm-diagnosticSource"},t.source))}var ST=function(){function e(t){var n;return v(this,e),(n=g(this,e)).sev=t,n}return C(e,iy),b(e,[{key:"eq",value:function(e){return e.sev==this.sev}},{key:"toDOM",value:function(){return Fv("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}])}(),CT=b(function e(t,n){v(this,e),this.diagnostic=n,this.id="item_"+Math.floor(4294967295*Math.random()).toString(16),this.dom=xT(t,n,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}),ET=function(){function e(t){var n=this;v(this,e),this.view=t,this.items=[];this.list=Fv("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)vT(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=kT(r.actions),o=0;o<i.length;o++)if(i[o].toUpperCase().charCodeAt(0)==e.keyCode){var s=lT(n.view.state.field(dT).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=Fv("div",{class:"cm-panel-lint"},this.list,Fv("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:function(){return vT(n.view)}},"×")),this.update()}return b(e,[{key:"selectedIndex",get:function(){var e=this.view.state.field(dT).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(dT),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=w(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 CT(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 CT(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=w(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=lT(this.view.state.field(dT).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:fT.of(t)})}}}],[{key:"open",value:function(t){return new e(t)}}])}();function AT(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 MT=$k.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:AT("#d11")},".cm-lintRange-warning":{backgroundImage:AT("orange")},".cm-lintRange-info":{backgroundImage:AT("#999")},".cm-lintRange-hint":{backgroundImage:AT("#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 OT(e){return"error"==e?4:"warning"==e?3:"info"==e?2:1}var NT=[dT,$k.decorations.compute([dT],function(e){var t=e.field(dT),n=t.selected,r=t.panel;return n&&r&&n.from!=n.to?sy.set([pT.range(n.from,n.to)]):sy.none}),oS(mT,{hideOn:function(e,t){var n=t.pos,r=t.end||n,i=e.state.facet(bT).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(uT)})&&!e.changes.touchesRange(o.from,Math.max(o.to,r)))}}),MT],TT=function(e){void 0===e&&(e={});var t=e.crosshairCursor,n=void 0!==t&&t,r=[];!1!==e.closeBracketsKeymap&&(r=r.concat(XN)),!1!==e.defaultKeymap&&(r=r.concat(eO)),!1!==e.searchKeymap&&(r=r.concat(KO)),!1!==e.historyKeymap&&(r=r.concat(eM)),!1!==e.foldKeymap&&(r=r.concat(IE)),!1!==e.completionKeymap&&(r=r.concat(iT)),!1!==e.lintKeymap&&(r=r.concat(yT));var i=[];return!1!==e.lineNumbers&&i.push(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return[LS.of(e),ES(),_S]}()),!1!==e.highlightActiveLineGutter&&i.push(WS),!1!==e.highlightSpecialChars&&i.push(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return[Dx.of(e),Px||(Px=Cb.fromClass(function(){return b(function e(t){v(this,e),this.view=t,this.decorations=sy.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(t.state.facet(Dx)),this.decorations=this.decorator.createDeco(t)},[{key:"makeDecorator",value:function(e){var t=this;return new Mx({regexp:e.specialChars,decoration:function(n,r,i){var o=r.state.doc,s=ng(n[0],0);if(9==s){var a=o.lineAt(i),l=r.state.tabSize,c=Ev(a.text,l,i-a.from);return sy.replace({widget:new Bx((l-c%l)*t.view.defaultCharacterWidth/t.view.scaleX)})}return t.decorationCache[s]||(t.decorationCache[s]=sy.replace({widget:new Lx(e,s)}))},boundary:e.replaceTabs?void 0:/[^]/})}},{key:"update",value:function(e){var t=e.state.facet(Dx);e.startState.facet(Dx)!=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[_A,IA.of(e),$k.domEventHandlers({beforeinput:function(e,t){var n="historyUndo"==e.inputType?FA:"historyRedo"==e.inputType?WA: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=M(M({},VE),e),n=new qE(t,!0),r=new qE(t,!1),i=Cb.fromClass(function(){return b(function e(t){v(this,e),this.from=t.viewport.from,this.markers=this.buildMarkers(t)},[{key:"update",value:function(e){(e.docChanged||e.viewportChanged||e.startState.facet(lE)!=e.state.facet(lE)||e.startState.field(RE,!1)!=e.state.field(RE,!1)||ZC(e.startState)!=ZC(e.state)||t.foldingChanged(e))&&(this.markers=this.buildMarkers(e.view))}},{key:"buildMarkers",value:function(e){var t,i=new pv,o=w(e.viewportLineBlocks);try{for(o.s();!(t=o.n()).done;){var s=t.value,a=PE(e.state,s.from,s.to)?r:AE(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,SS({class:"cm-foldGutter",markers:function(e){var t;return(null===(t=e.plugin(i))||void 0===t?void 0:t.markers)||dv.empty},initialSpacer:function(){return new qE(t,!1)},domEventHandlers:M(M({},o),{},{click:function(e,t,n){if(o.click&&o.click(e,t,n))return!0;var r=PE(e.state,t.from,t.to);if(r)return e.dispatch({effects:NE.of(r)}),!0;var i=AE(e.state,t.from,t.to);return!!i&&(e.dispatch({effects:OE.of(i)}),!0)}})}),FE()]}()),!1!==e.drawSelection&&i.push(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return[vx.of(e),bx,kx,xx,mb.of(!0)]}()),!1!==e.dropCursor&&i.push([Cx,Ex]),!1!==e.allowMultipleSelections&&i.push(sv.allowMultipleSelections.of(!0)),!1!==e.indentOnInput&&i.push(sv.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=w(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=pE(a,f.from);if(null!=d){var p=/^\s*/.exec(f.text)[0],m=dE(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(XE(ZE,{fallback:!0})),!1!==e.bracketMatching&&i.push(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return[nA.of(e),aA]}()),!1!==e.closeBrackets&&i.push([$N,qN]),!1!==e.autocompletion&&i.push(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return[FN,RN,dN.of(e),_N,oT,WN]}()),!1!==e.rectangularSelection&&i.push(function(e){var t=(null==e?void 0:e.eventFilter)||function(e){return e.altKey&&0==e.button};return $k.mouseSelectionStyle.of(function(e,n){return t(n)?Hx(e,n):null})}()),!1!==n&&i.push(function(){var e=D(zx[(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).key||"Alt"],2),t=e[0],n=e[1],r=Cb.fromClass(function(){return b(function e(t){v(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,$k.contentAttributes.of(function(e){var t;return(null===(t=e.plugin(r))||void 0===t?void 0:t.isDown)?Vx:null})]}()),!1!==e.highlightActiveLine&&i.push(_x),!1!==e.highlightSelectionMatches&&i.push(function(e){var t=[vO,gO];return e&&t.push(fO.of(e)),t}()),e.tabSize&&"number"==typeof e.tabSize&&i.push(hE.of(" ".repeat(e.tabSize))),i.concat([rx.of(r.flat())]).filter(Boolean)},RT="#e06c75",DT="#abb2bf",PT="#7d8799",LT="#d19a66",BT="#2c313a",IT="#282c34",_T="#353a42",jT="#528bff",FT=[$k.theme({"&":{color:DT,backgroundColor:IT},".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:DT},".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:IT,color:PT,border:"none"},".cm-activeLineGutter":{backgroundColor:BT},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:_T},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:_T,borderBottomColor:_T},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:BT,color:DT}}},{dark:!0}),XE(KE.define([{tag:UC.keyword,color:"#c678dd"},{tag:[UC.name,UC.deleted,UC.character,UC.propertyName,UC.macroName],color:RT},{tag:[UC.function(UC.variableName),UC.labelName],color:"#61afef"},{tag:[UC.color,UC.constant(UC.name),UC.standard(UC.name)],color:LT},{tag:[UC.definition(UC.name),UC.separator],color:DT},{tag:[UC.typeName,UC.className,UC.number,UC.changed,UC.annotation,UC.modifier,UC.self,UC.namespace],color:"#e5c07b"},{tag:[UC.operator,UC.operatorKeyword,UC.url,UC.escape,UC.regexp,UC.link,UC.special(UC.string)],color:"#56b6c2"},{tag:[UC.meta,UC.comment],color:PT},{tag:UC.strong,fontWeight:"bold"},{tag:UC.emphasis,fontStyle:"italic"},{tag:UC.strikethrough,textDecoration:"line-through"},{tag:UC.link,color:PT,textDecoration:"underline"},{tag:UC.heading,fontWeight:"bold",color:RT},{tag:[UC.atom,UC.bool,UC.special(UC.variableName)],color:LT},{tag:[UC.processingInstruction,UC.string,UC.inserted],color:"#98c379"},{tag:UC.invalid,color:"#ffffff"}]))],WT=$k.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),HT=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(rx.of([tO])),d&&("boolean"==typeof d?p.unshift(TT()):p.unshift(TT(d))),h&&p.unshift(function(e){var t=Cb.fromClass(function(){return b(function t(n){v(this,t),this.view=n,this.placeholder=e?sy.set([sy.widget({widget:new jx(e),side:1}).range(0)]):sy.none},[{key:"decorations",get:function(){return this.view.state.doc.length?sy.none:this.placeholder}}])}(),{decorations:function(e){return e.decorations}});return"string"==typeof e?[t,$k.contentAttributes.of({"aria-placeholder":e})]:t}(h)),c){case"light":p.push(WT);break;case"dark":p.push(FT);break;case"none":break;default:p.push(c)}return!1===o&&p.push($k.editable.of(!1)),a&&p.push(sv.readOnly.of(!0)),[].concat(p)},zT=function(){return b(function e(t,n){v(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}}])}(),VT=function(){return b(function e(){v(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)}}])}(),qT=null,UT=Ug.define(),KT=[];function GT(t){var n=t.value,r=t.selection,i=t.onChange,o=t.onStatistics,s=t.onCreateEditor,a=t.onUpdate,l=t.extensions,c=void 0===l?KT:l,u=t.autoFocus,h=t.theme,f=void 0===h?"light":h,d=t.height,p=void 0===d?null:d,m=t.minHeight,g=void 0===m?null:m,v=t.maxHeight,y=void 0===v?null:v,b=t.width,w=void 0===b?null:b,k=t.minWidth,x=void 0===k?null:k,S=t.maxWidth,C=void 0===S?null:S,E=t.placeholder,A=void 0===E?"":E,M=t.editable,O=void 0===M||M,N=t.readOnly,T=void 0!==N&&N,R=t.indentWithTab,P=void 0===R||R,B=t.basicSetup,I=void 0===B||B,_=t.root,j=t.initialState,F=D(e.useState(),2),W=F[0],H=F[1],z=D(e.useState(),2),V=z[0],q=z[1],U=D(e.useState(),2),K=U[0],G=U[1],Y=e.useState(function(){return{current:null}})[0],$=e.useState(function(){return{current:null}})[0],X=$k.theme({"&":{height:p,minHeight:g,maxHeight:y,width:w,minWidth:x,maxWidth:C},"& .cm-scroller":{height:"100% !important"}}),J=$k.updateListener.of(function(e){if(e.docChanged&&"function"==typeof i&&!e.transactions.some(function(e){return e.annotation(UT)})){Y.current?Y.current.reset():(Y.current=new zT(function(){if($.current){var e=$.current;$.current=null,e()}Y.current=null},200),("undefined"==typeof window?new VT:(qT||(qT=new VT),qT)).add(Y.current));var t=e.state.doc.toString();i(t,e)}o&&o(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))}),Q=HT({theme:f,editable:O,readOnly:T,placeholder:A,indentWithTab:P,basicSetup:I}),Z=[J,X].concat(L(Q));return a&&"function"==typeof a&&Z.push($k.updateListener.of(a)),Z=Z.concat(c),e.useLayoutEffect(function(){if(W&&!K){var e={doc:n,selection:r,extensions:Z},t=j?sv.fromJSON(j.json,e,j.fields):sv.create(e);if(G(t),!V){var i=new $k({state:t,parent:W,root:_});q(i),s&&s(i,t)}}return function(){V&&(G(void 0),q(void 0))}},[W,K]),e.useEffect(function(){t.container&&H(t.container)},[t.container]),e.useEffect(function(){return function(){V&&(V.destroy(),q(void 0)),Y.current&&(Y.current.cancel(),Y.current=null)}},[V]),e.useEffect(function(){u&&V&&V.focus()},[u,V]),e.useEffect(function(){V&&V.dispatch({effects:Yg.reconfigure.of(Z)})},[f,c,p,g,y,w,x,C,A,O,T,P,I,i,a]),e.useEffect(function(){if(void 0!==n){var e=V?V.state.doc.toString():"";if(V&&n!==e){var t=function(){V&&n!==V.state.doc.toString()&&V.dispatch({changes:{from:0,to:V.state.doc.toString().length,insert:n||""},annotations:[UT.of(!0)]})};Y.current&&!Y.current.isDone?$.current=t:t()}}},[n,V]),{state:K,setState:G,view:V,setView:q,container:W,setContainer:H}}var YT=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],$T=e.forwardRef(function(n,r){var i=n.className,o=n.value,s=void 0===o?"":o,a=n.selection,l=n.extensions,c=void 0===l?[]:l,u=n.onChange,h=n.onStatistics,f=n.onCreateEditor,d=n.onUpdate,p=n.autoFocus,m=n.theme,g=void 0===m?"light":m,v=n.height,y=n.minHeight,b=n.maxHeight,w=n.width,k=n.minWidth,x=n.maxWidth,S=n.basicSetup,C=n.placeholder,E=n.indentWithTab,A=n.editable,M=n.readOnly,O=n.root,N=n.initialState,T=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}(n,YT),R=e.useRef(null),D=GT({root:O,value:s,autoFocus:p,theme:g,height:v,minHeight:y,maxHeight:b,width:w,minWidth:k,maxWidth:x,basicSetup:S,placeholder:C,indentWithTab:E,editable:A,readOnly:M,selection:a,onChange:u,onStatistics:h,onCreateEditor:f,onUpdate:d,extensions:c,initialState:N}),P=D.state,L=D.view,B=D.container,_=D.setContainer;e.useImperativeHandle(r,function(){return{editor:R.current,state:P,view:L}},[R,B,P,L]);var j=e.useCallback(function(e){R.current=e,_(e)},[_]);if("string"!=typeof s)throw new Error("value must be typeof string but got "+I(s));var F="string"==typeof g?"cm-theme-"+g:"cm-theme";return t.jsx("div",Pm({ref:j,className:F+(i?" "+i:"")},T))});$T.displayName="CodeMirror";var XT=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;v(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 b(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 QT(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 JT(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 JT(i,i.start):null,0,null)}}])}(),JT=b(function e(t,n){v(this,e),this.tracker=t,this.context=n,this.hash=t.strict?t.hash(n):0}),QT=function(){return b(function e(t){v(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}}])}(),ZT=function(){function e(t,n,r){v(this,e),this.stack=t,this.pos=n,this.index=r,this.buffer=t.buffer,0==this.index&&this.maybeNext()}return b(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 eR(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 tR=b(function e(){v(this,e),this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}),nR=new tR,rR=function(){return b(function e(t,n){v(this,e),this.input=t,this.ranges=n,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=nR,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=w(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=nR,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=w(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}}])}(),iR=function(){return b(function e(t,n){v(this,e),this.data=t,this.id=n},[{key:"token",value:function(e,t){var n=t.p.parser;oR(this.data,e,t,this.id,n.data,n.tokenPrecTable)}}])}();function oR(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||aR(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 sR(e,t,n){for(var r,i=t;65535!=(r=e[i]);i++)if(r==n)return i-t;return-1}function aR(e,t,n,r){var i=sR(n,r,t);return i<0||sR(n,r,e)<i}iR.prototype.contextual=iR.prototype.fallback=iR.prototype.extend=!1,function(){return b(function e(t,n,r){v(this,e),this.precTable=n,this.elseToken=r,this.data="string"==typeof t?eR(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(oR(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=iR.prototype.fallback=iR.prototype.extend=!1;var lR="undefined"!=typeof process&&process.env&&/\bparse\b/.test(process.env.LOG),cR=null;function uR(e,t,n){var r=e.cursor(GS.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 hR=function(){return b(function e(t,n){v(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?uR(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?uR(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 JS){if(o==e){if(o<this.safeFrom)return null;var s=o+i.length;if(s<=this.safeTo){var a=i.prop(VS.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()}}}])}(),fR=function(){return b(function e(t,n){v(this,e),this.stream=n,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=t.tokenizers.map(function(e){return new tR})},[{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 tR).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 tR,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(vR(s,l+2),t,n,r));break}l=vR(s,l+2)}s[l]==t&&(r=this.putAction(vR(s,l+1),t,n,r))}return r}}])}(),dR=function(){return b(function e(t,n,r,i){v(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 rR(n,i),this.tokens=new fR(t,this.stream),this.topTerm=t.top[1];var o=i[0].from;this.stacks=[XT.start(this,t.top[0],o)],this.fragments=r.length&&this.stream.end-o>4*t.bufferLength?new hR(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=D(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=w(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;lR&&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(VS.contextHash)||0)==s))return e.useNode(a,l),!0;if(!(a instanceof JS)||0==a.children.length||a.positions[0]>0)break;var c=a.children[0];if(!(c instanceof JS&&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 pR(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)];lR&&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;lR&&this.stackID(c)+" -> "}var h,f=w(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),pR(s,n)):(!r||r.score<c.score)&&(r=c)}return r}},{key:"stackToTree",value:function(e){return e.close(),JS.build({buffer:ZT.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=(cR||(cR=new WeakMap)).get(e);return t||cR.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}}])}();function pR(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 mR=function(){return b(function e(t,n,r){v(this,e),this.source=t,this.flags=n,this.disabled=r},[{key:"allows",value:function(e){return!this.disabled||0==this.disabled[e]}}])}(),gR=function(){function e(t){var n,r;if(v(this,e),(r=g(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=w(t.nodeProps);try{for(h.s();!(u=h.n()).done;){var f=u.value,d=f[0];"string"==typeof d&&(d=VS[d]);for(var p=1;p<f.length;){var m=f[p++];if(m>=0)c(m,d,f[p++]);else{for(var y=f[p+-m],b=-m;b>0;b--)c(f[p++],d,y);p++}}}}catch(e){h.e(e)}finally{h.f()}}r.nodeSet=new YS(i.map(function(e,n){return KS.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,L(t.propSources))),r.strict=!1,r.bufferLength=1024;var k=eR(t.tokenData);r.context=t.context,r.specializerSpecs=t.specialized||[],r.specialized=new Uint16Array(r.specializerSpecs.length);for(var x=0;x<r.specializerSpecs.length;x++)r.specialized[x]=r.specializerSpecs[x].term;return r.specializers=r.specializerSpecs.map(yR),r.states=eR(t.states,Uint32Array),r.data=eR(t.stateData),r.goto=eR(t.goto),r.maxTerm=t.maxTerm,r.tokenizers=t.tokenizers.map(function(e){return"number"==typeof e?new iR(k,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 C(e,vC),b(e,[{key:"createParse",value:function(e,t,n){var r,i=new dR(this,e,t,n),o=w(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 vR(n,o+2);break}i=n[o=vR(n,o+2)]}if(i==t||0==i)return vR(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=vR(this.data,i+2)}r=t(vR(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=vR(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,L(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]=yR(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=w(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 mR(e,n,a)}}],[{key:"deserialize",value:function(t){return new e(t)}}])}();function vR(e,t){return e[t]|e[t+1]<<16}function yR(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 bR=SC({String:UC.string,Number:UC.number,"True False":UC.bool,PropertyName:UC.propertyName,Null:UC.null,", :":UC.separator,"[ ]":UC.squareBracket,"{ }":UC.brace}),wR=gR.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:[bR],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}),kR=QC.define({name:"json",parser:wR.configure({props:[gE.add({Object:xE({except:/^\s*\}/}),Array:xE({except:/^\s*\]/})}),CE.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 xR=[],SR=[];function CR(e){if(e<768)return!1;for(let t=0,n=xR.length;;){let r=t+n>>1;if(e<xR[r])n=r;else{if(!(e>=SR[r]))return!0;t=r+1}if(t==n)return!1}}function ER(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?SR:xR).push(n+=e[t])})();function AR(e,t,n=!0,r=!0){return(n?MR:OR)(e,t,r)}function MR(e,t,n){if(t==e.length)return t;t&&TR(e.charCodeAt(t))&&RR(e.charCodeAt(t-1))&&t--;let r=NR(e,t);for(t+=DR(r);t<e.length;){let i=NR(e,t);if(8205==r||8205==i||n&&CR(i))t+=DR(i),r=i;else{if(!ER(i))break;{let n=0,r=t-2;for(;r>=0&&ER(NR(e,r));)n++,r-=2;if(n%2==0)break;t+=2}}}return t}function OR(e,t,n){for(;t>0;){let r=MR(e,t-2,n);if(r<t)return r;t--}return 0}function NR(e,t){let n=e.charCodeAt(t);if(!RR(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return TR(r)?r-56320+(n-55296<<10)+65536:n}function TR(e){return e>=56320&&e<57344}function RR(e){return e>=55296&&e<56320}function DR(e){return e<65536?1:2}class PR{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]=zR(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),BR.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]=zR(this,e,t);let n=[];return this.decompose(e,t,n,0),BR.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 FR(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 WR(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 LR(e):BR.from(LR.split(e,[])):PR.empty}}class LR extends PR{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 HR(r,s,n,o);r=s+1,n++}}decompose(e,t,n,r){let i=e<=0&&t>=this.length?this:new LR(_R(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(1&r){let e=n.pop(),t=IR(i.text,e.text.slice(),0,i.length);if(t.length<=32)n.push(new LR(t,e.length+i.length));else{let e=t.length>>1;n.push(new LR(t.slice(0,e)),new LR(t.slice(e)))}}else n.push(i)}replace(e,t,n){if(!(n instanceof LR))return super.replace(e,t,n);[e,t]=zR(this,e,t);let r=IR(this.text,IR(n.text,_R(this.text,0,e)),t),i=this.length+n.length-(t-e);return r.length<=32?new LR(r,i):BR.from(LR.split(r,[]),i)}sliceString(e,t=this.length,n="\n"){[e,t]=zR(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 LR(n,r)),n=[],r=-1);return r>-1&&t.push(new LR(n,r)),t}}class BR extends PR{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]=zR(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 BR(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]=zR(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 BR))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 LR(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 BR)for(let t of e.children)u(t);else e.lines>o&&(a>o||!a)?(h(),s.push(e)):e instanceof LR&&a&&(t=c[c.length-1])instanceof LR&&e.lines+t.lines<=32?(a+=e.lines,l+=e.length+1,c[c.length-1]=new LR(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]:BR.from(c,l)),l=-1,a=c.length=0)}for(let t of e)u(t);return h(),1==s.length?s[0]:new BR(s,t)}}function IR(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 _R(e,t,n){return IR(e,[""],t,n)}PR.empty=new LR([""],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 LR?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 LR?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 LR){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 LR?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 FR{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 WR{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&&(PR.prototype[Symbol.iterator]=function(){return this.iter()},jR.prototype[Symbol.iterator]=FR.prototype[Symbol.iterator]=WR.prototype[Symbol.iterator]=function(){return this});class HR{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 zR(e,t,n){return[t=Math.max(0,Math.min(e.length,t)),Math.max(t,Math.min(e.length,n))]}function VR(e,t,n=!0,r=!0){return AR(e,t,n,r)}const qR=/\r\n?|\n/;var UR=function(e){return e[e.Simple=0]="Simple",e[e.TrackDel=1]="TrackDel",e[e.TrackBefore=2]="TrackBefore",e[e.TrackAfter=3]="TrackAfter",e}(UR||(UR={}));class KR{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){XR(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 KR(e)}composeDesc(e){return this.empty?e:e.empty?this:QR(this,e)}mapDesc(e,t=!1){return e.empty?this:JR(this,e,t)}mapPos(e,t=-1,n=UR.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!=UR.Simple&&l>=e&&(n==UR.TrackDel&&r<e&&l>e||n==UR.TrackBefore&&r<e||n==UR.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 KR(e)}static create(e){return new KR(e)}}class GR extends KR{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 XR(this,(t,n,r,i,o)=>e=e.replace(r,r+(n-t),o),!1),e}mapDesc(e,t=!1){return JR(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(PR.empty);n.push(o?e.slice(i,i+o):PR.empty)}i+=o}return new GR(t,n)}compose(e){return this.empty?e:e.empty?this:QR(this,e,!0)}map(e,t=!1){return e.empty?this:JR(this,e,t,!0)}iterChanges(e,t=!1){XR(this,e,t)}get desc(){return KR.create(this.sections)}filter(e){let t=[],n=[],r=[],i=new ZR(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);YR(r,e,-1);let o=-1==i.ins?-1:0==i.off?i.ins:0;YR(t,e,o),o>0&&$R(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);YR(t,e,-1),YR(r,e,-1==i.ins?-1:0==i.off?i.ins:0),i.forward(e),s+=e}}return{changes:new GR(t,n),filtered:KR.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&&YR(r,t-o,-1);let n=new GR(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 GR){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?PR.of(c.split(n||qR)):c:PR.empty,h=u.length;if(e==s&&0==h)return;e<o&&a(),e>o&&YR(r,e-o,-1),YR(r,s-e,h),$R(i,r,u),o=s}}(e),a(!s),s}static empty(e){return new GR(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(PR.empty);n[r]=PR.of(i.slice(1)),t.push(i[0],n[r].length)}}}return new GR(t,n)}static createSet(e,t){return new GR(e,t)}}function YR(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 $R(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(PR.empty);e.push(n)}}function XR(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=PR.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 JR(e,t,n,r=!1){let i=[],o=r?[]:null,s=new ZR(e),a=new ZR(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);YR(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(YR(i,a.ins,-1);t;){let n=Math.min(s.len,t);s.ins>=0&&e<s.i&&s.len<=n&&(YR(i,0,s.ins),o&&$R(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?GR.createSet(i,o):KR.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()}YR(i,t,e<s.i?s.ins:0),o&&e<s.i&&$R(o,i,s.text),e=s.i,s.forward(s.len-n)}}}}function QR(e,t,n=!1){let r=[],i=n?[]:null,o=new ZR(e),s=new ZR(t);for(let e=!1;;){if(o.done&&s.done)return i?GR.createSet(r,i):KR.create(r);if(0==o.ins)YR(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;YR(r,t,n,e),i&&n&&$R(i,r,s.text)}else-1==s.ins?(YR(r,o.off?0:o.len,t,e),i&&$R(i,r,o.textBit(t))):(YR(r,o.off?0:o.len,s.off?0:s.ins,e),i&&!s.off&&$R(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 YR(r,0,s.ins,e),i&&$R(i,r,s.text),s.next()}}class ZR{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?PR.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?PR.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 eD{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 eD(n,r,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return tD.range(e,t);let n=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return tD.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 tD.range(e.anchor,e.head)}static create(e,t,n){return new eD(e,t,n)}}class tD{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:tD.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 tD([this.main],0)}addRange(e,t=!0){return tD.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let n=this.ranges.slice();return n[t]=e,tD.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 tD(e.ranges.map(e=>eD.fromJSON(e)),e.main)}static single(e,t=e){return new tD([tD.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 tD.normalized(e.slice(),t);n=i.to}return new tD(e,t)}static cursor(e,t=0,n,r){return eD.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?eD.create(t,e,48|i):eD.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?tD.range(s,o):tD.range(o,s))}}return new tD(e,t)}}function nD(e,t){for(let n of e.ranges)if(n.to>t)throw new RangeError("Selection points outside of document")}let rD=0;class iD{constructor(e,t,n,r,i){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=r,this.id=rD++,this.default=e([]),this.extensions="function"==typeof i?i(this):i}get reader(){return this}static define(e={}){return new iD(e.combine||(e=>e),e.compareInput||((e,t)=>e===t),e.compare||(e.combine?(e,t)=>e===t:oD),!!e.static,e.enables)}of(e){return new sD([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new sD(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new sD(e,this,2,t)}from(e,t){return t||(t=e=>e),this.compute([e],n=>t(n.field(e)))}}function oD(e,t){return e==t||e.length==t.length&&e.every((e,n)=>e===t[n])}class sD{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=rD++}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)||lD(e,c)){let t=n(e);if(s?!aD(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=SD(t,l);if(this.dependencies.every(n=>n instanceof iD?t.facet(n)===e.facet(n):!(n instanceof hD)||t.field(n,!1)==e.field(n,!1))||(s?aD(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 aD(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 lD(e,t){let n=!1;for(let r of t)1&xD(e,r)&&(n=!0);return n}function cD(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=SD(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)xD(e,t);return e.values[s]=a(e),1},update(e,n){if(!lD(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=lD(e,r),l=i.config.facets[t.id],c=i.facet(t);if(l&&!o&&oD(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 uD=iD.define({static:!0});class hD{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 hD(rD++,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(uD).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(uD),o=n.facet(uD);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,uD.of({field:this,create:e})]}get extension(){return this}}const fD=4,dD=3,pD=2,mD=1;function gD(e){return t=>new yD(t,e)}const vD={highest:gD(0),high:gD(mD),default:gD(pD),low:gD(dD),lowest:gD(fD)};class yD{constructor(e,t){this.inner=e,this.prec=t}}class bD{of(e){return new wD(this,e)}reconfigure(e){return bD.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class wD{constructor(e,t){this.compartment=e,this.inner=t}}class kD{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 wD&&n.delete(e.compartment)}if(i.set(e,s),Array.isArray(e))for(let t of e)o(t,s);else if(e instanceof wD){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 yD)o(e.inner,e.prec);else if(e instanceof hD)r[s].push(e),e.provides&&o(e.provides,s);else if(e instanceof sD)r[s].push(e),e.facet.extensions&&o(e.facet.extensions,pD);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,pD),r.reduce((e,t)=>e.concat(t))}(e,t,o))n instanceof hD?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,oD(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=>cD(e,r,t))}}let u=l.map(e=>e(s));return new kD(e,o,u,s,a,i)}}function xD(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 SD(e,t){return 1&t?e.config.staticValues[t>>1]:e.values[t>>1]}const CD=iD.define(),ED=iD.define({combine:e=>e.some(e=>e),static:!0}),AD=iD.define({combine:e=>e.length?e[0]:void 0,static:!0}),MD=iD.define(),OD=iD.define(),ND=iD.define(),TD=iD.define({combine:e=>!!e.length&&e[0]});class RD{constructor(e,t){this.type=e,this.value=t}static define(){return new DD}}class DD{of(e){return new RD(this,e)}}class PD{constructor(e){this.map=e}of(e){return new LD(this,e)}}class LD{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 LD(this.type,t)}is(e){return this.type==e}static define(e={}){return new PD(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}}LD.reconfigure=LD.define(),LD.appendConfig=LD.define();class BD{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&&nD(n,t.newLength),i.some(e=>e.type==BD.time)||(this.annotations=i.concat(BD.time.of(Date.now())))}static create(e,t,n,r,i,o){return new BD(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(BD.userEvent);return!(!t||!(t==e||t.length>e.length&&t.slice(0,e.length)==e&&"."==t[e.length]))}}function ID(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 _D(e,t,n){var r;let i,o,s;return n?(i=t.changes,o=GR.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:LD.mapEffects(e.effects,i).concat(LD.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=HD(t.annotations);return t.userEvent&&(i=i.concat(BD.userEvent.of(t.userEvent))),{changes:t.changes instanceof GR?t.changes:GR.of(t.changes||[],n,e.facet(AD)),selection:r&&(r instanceof tD?r:tD.single(r.anchor,r.head)),effects:HD(t.effects),annotations:i,scrollIntoView:!!t.scrollIntoView}}function FD(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=_D(r,jD(e,t[i],o?r.changes.newLength:e.doc.length),o)}let i=BD.create(e,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return function(e){let t=e.startState,n=t.facet(ND),r=e;for(let i=n.length-1;i>=0;i--){let o=n[i](e);o&&Object.keys(o).length&&(r=_D(r,jD(t,o,e.changes.newLength),!0))}return r==e?e:BD.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(MD)){let t=r(e);if(!1===t){n=!1;break}Array.isArray(t)&&(n=!0===n?t:ID(n,t))}if(!0!==n){let r,i;if(!1===n)i=e.changes.invertedDesc,r=GR.empty(t.doc.length);else{let t=e.changes.filter(n);r=t.changes,i=t.filtered.mapDesc(t.changes).invertedDesc}e=BD.create(t,r,e.selection&&e.selection.map(i),LD.mapEffects(e.effects,i),e.annotations,e.scrollIntoView)}let r=t.facet(OD);for(let n=r.length-1;n>=0;n--){let i=r[n](e);e=i instanceof BD?i:Array.isArray(i)&&1==i.length&&i[0]instanceof BD?i[0]:FD(t,HD(i),!1)}return e}(i):i)}BD.time=RD.define(),BD.userEvent=RD.define(),BD.addToHistory=RD.define(),BD.remote=RD.define();const WD=[];function HD(e){return null==e?WD:Array.isArray(e)?e:[e]}var zD=function(e){return e[e.Word=0]="Word",e[e.Space=1]="Space",e[e.Other=2]="Other",e}(zD||(zD={}));const VD=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let qD;try{qD=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(e){}function UD(e){return t=>{if(!/\S/.test(t))return zD.Space;if(function(e){if(qD)return qD.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>"€"&&(n.toUpperCase()!=n.toLowerCase()||VD.test(n)))return!0}return!1}(t))return zD.Word;for(let n=0;n<e.length;n++)if(t.indexOf(e[n])>-1)return zD.Word;return zD.Other}}class KD{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++)xD(this,e<<1);this.computeSlot=null}field(e,t=!0){let n=this.config.address[e.id];if(null!=n)return xD(this,n),SD(this,n);if(t)throw new RangeError("Field is not present in this state")}update(...e){return FD(this,e,!0)}applyTransaction(e){let t,n=this.config,{base:r,compartments:i}=n;for(let t of e.effects)t.is(bD.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(LD.reconfigure)?(n=null,r=t.value):t.is(LD.appendConfig)&&(n=null,r=HD(r).concat(t.value));if(n)t=e.startState.values.slice();else{n=kD.resolve(r,i,this);let e=new KD(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(e,t)=>t.reconfigure(e,this),null);t=e.values}let o=e.startState.facet(ED)?e.newSelection:e.newSelection.asSingle();new KD(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:tD.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=HD(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=LD.mapEffects(o,l).concat(LD.mapEffects(HD(s.effects),c))}return{changes:r,selection:tD.create(i,t.mainIndex),effects:o}}changes(e=[]){return e instanceof GR?e:GR.of(e,this.doc.length,this.facet(KD.lineSeparator))}toText(e){return PR.of(e.split(this.facet(KD.lineSeparator)||qR))}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:(xD(this,t),SD(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 hD&&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 KD.create({doc:e.doc,selection:tD.fromJSON(e.selection),extensions:t.extensions?r.concat([t.extensions]):r})}static create(e={}){let t=kD.resolve(e.extensions||[],new Map),n=e.doc instanceof PR?e.doc:PR.of((e.doc||"").split(t.staticFacet(KD.lineSeparator)||qR)),r=e.selection?e.selection instanceof tD?e.selection:tD.single(e.selection.anchor,e.selection.head):tD.single(0);return nD(r,n.length),t.staticFacet(ED)||(r=r.asSingle()),new KD(t,n,r,t.dynamicSlots.map(()=>null),(e,t)=>t.create(e),null)}get tabSize(){return this.facet(KD.tabSize)}get lineBreak(){return this.facet(KD.lineSeparator)||"\n"}get readOnly(){return this.facet(TD)}phrase(e,...t){for(let t of this.facet(KD.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(CD))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 UD(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=VR(t,o,!1);if(i(t.slice(e,o))!=zD.Word)break;o=e}for(;s<r;){let e=VR(t,s);if(i(t.slice(s,e))!=zD.Word)break;s=e}return o==s?null:tD.range(o+n,s+n)}}KD.allowMultipleSelections=ED,KD.tabSize=iD.define({combine:e=>e.length?e[0]:4}),KD.lineSeparator=AD,KD.readOnly=TD,KD.phrases=iD.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])}}),KD.languageData=CD,KD.changeFilter=MD,KD.transactionFilter=OD,KD.transactionExtender=ND,bD.reconfigure=LD.define();class GD{eq(e){return this==e}range(e,t=e){return $D.create(e,t,this)}}function YD(e,t){return e==t||e.constructor==t.constructor&&e.eq(t)}GD.prototype.startSide=GD.prototype.endSide=0,GD.prototype.point=!1,GD.prototype.mapMode=UR.TrackDel;class $D{constructor(e,t,n){this.from=e,this.to=t,this.value=n}static create(e,t,n){return new $D(e,t,n)}}function XD(e,t){return e.from-t.from||e.value.startSide-t.value.startSide}class JD{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 JD(r,i,n,s):null,pos:o}}}class QD{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 QD(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(XD)),this.isEmpty)return t.length?QD.of(t):this;let s=new tP(this,null,-1).goto(0),a=0,l=[],c=new ZD;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($D.create(s.from,s.to,s.value))),s.next());return c.finishInner(this.nextLayer.isEmpty&&!l.length?QD.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 QD(n,t,i||QD.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 nP.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return nP.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=eP(o,s,n),l=new iP(o,a,i),c=new iP(s,a,i);n.iterGaps((e,t,n)=>oP(l,e,c,t,n,r)),n.empty&&0==n.length&&oP(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=eP(i,o),a=new iP(i,s,0).goto(n),l=new iP(o,s,0).goto(n);for(;;){if(a.to!=l.to||!sP(a.active,l.active)||a.point&&(!l.point||!YD(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 iP(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 ZD;for(let r of e instanceof $D?[e]:t?function(e){if(e.length>1)for(let t=e[0],n=1;n<e.length;n++){let r=e[n];if(XD(t,r)>0)return e.slice().sort(XD);t=r}return e}(e):e)n.add(r.from,r.to,r.value);return n.finish()}static join(e){if(!e.length)return QD.empty;let t=e[e.length-1];for(let n=e.length-2;n>=0;n--)for(let r=e[n];r!=QD.empty;r=r.nextLayer)t=new QD(r.chunkPos,r.chunk,t,Math.max(r.maxPoint,t.maxPoint));return t}}QD.empty=new QD([],[],null,-1),QD.empty.nextLayer=QD.empty;class ZD{finishChunk(e){this.chunks.push(new JD(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 ZD)).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(QD.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return e;let t=QD.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function eP(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 tP{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 nP{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 tP(o,t,n,i));return 1==r.length?r[0]:new nP(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--)rP(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--)rP(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(),rP(this.heap,0)}}}function rP(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 iP{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=nP.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){aP(this.active,e),aP(this.activeTo,e),aP(this.activeRank,e),this.minActive=cP(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++;lP(this.active,t,n),lP(this.activeTo,t,r),lP(this.activeRank,t,i),e&&lP(e,t,this.cursor.from),this.minActive=cP(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&&aP(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 oP(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&&YD(e.point,n.point)&&sP(e.activeForPoint(e.to),n.activeForPoint(n.to))||o.comparePoint(a,h,e.point,n.point),t=!1):(t&&o.boundChange(a),h>a&&!sP(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 sP(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n]&&!YD(e[n],t[n]))return!1;return!0}function aP(e,t){for(let n=t,r=e.length-1;n<r;n++)e[n]=e[n+1];e.pop()}function lP(e,t,n){for(let n=e.length-1;n>=t;n--)e[n+1]=e[n];e[t]=n}function cP(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 uP="undefined"==typeof Symbol?"__ͼ":Symbol.for("ͼ"),hP="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),fP="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class dP{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=fP[uP]||1;return fP[uP]=e+1,"ͼ"+e.toString(36)}static mount(e,t,n){let r=e[hP],i=n&&n.nonce;r?i&&r.setNonce(i):r=new mP(e,i),r.mount(Array.isArray(t)?t:[t],e)}}let pP=new Map;class mP{constructor(e,t){let n=e.ownerDocument||e,r=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let t=pP.get(n);if(t)return e[hP]=t;this.sheet=new r.CSSStyleSheet,pP.set(n,this)}else this.styleTag=n.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[hP]=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 gP={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:"'"},vP={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},yP=0;yP<10;yP++)gP[48+yP]=gP[96+yP]=String(yP);for(yP=1;yP<=24;yP++)gP[yP+111]="F"+yP;for(yP=65;yP<=90;yP++)gP[yP]=String.fromCharCode(yP+32),vP[yP]=String.fromCharCode(yP);for(var bP in gP)vP.hasOwnProperty(bP)||(vP[bP]=gP[bP]);let wP="undefined"!=typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},kP="undefined"!=typeof document?document:{documentElement:{style:{}}};const xP=/Edge\/(\d+)/.exec(wP.userAgent),SP=/MSIE \d/.test(wP.userAgent),CP=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(wP.userAgent),EP=!!(SP||CP||xP),AP=!EP&&/gecko\/(\d+)/i.test(wP.userAgent),MP=!EP&&/Chrome\/(\d+)/.exec(wP.userAgent),OP="webkitFontSmoothing"in kP.documentElement.style,NP=!EP&&/Apple Computer/.test(wP.vendor),TP=NP&&(/Mobile\/\w+/.test(wP.userAgent)||wP.maxTouchPoints>2);var RP={mac:TP||/Mac/.test(wP.platform),windows:/Win/.test(wP.platform),linux:/Linux|X11/.test(wP.platform),ie:EP,ie_version:SP?kP.documentMode||6:CP?+CP[1]:xP?+xP[1]:0,gecko:AP,gecko_version:AP?+(/Firefox\/(\d+)/.exec(wP.userAgent)||[0,0])[1]:0,chrome:!!MP,chrome_version:MP?+MP[1]:0,ios:TP,android:/Android\b/.test(wP.userAgent),webkit:OP,webkit_version:OP?+(/\bAppleWebKit\/(\d+)/.exec(wP.userAgent)||[0,0])[1]:0,safari:NP,safari_version:NP?+(/\bVersion\/(\d+(\.\d+)?)/.exec(wP.userAgent)||[0,0])[1]:0,tabSize:null!=kP.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};function DP(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 PP=Object.create(null);function LP(e,t,n){if(e==t)return!0;e||(e=PP),t||(t=PP);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 BP(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 IP(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 _P{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 FP extends GD{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 WP(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 zP(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}=VP(e,r);t=(i?r?-3e8:-1:5e8)-1,n=1+(o?r?2e8:1:-6e8)}return new zP(e,t,n,r,e.widget||null,!0)}static line(e){return new HP(e)}static set(e,t=!1){return QD.of(e,t)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}FP.none=QD.empty;class WP extends FP{constructor(e){let{start:t,end:n}=VP(e);super(t?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?DP(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||PP}eq(e){return this==e||e instanceof WP&&this.tagName==e.tagName&&LP(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)}}WP.prototype.point=!1;class HP extends FP{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof HP&&this.spec.class==e.spec.class&&LP(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)}}HP.prototype.mapMode=UR.TrackBefore,HP.prototype.point=!0;class zP extends FP{constructor(e,t,n,r,i,o){super(t,n,i,e),this.block=r,this.isReplace=o,this.mapMode=r?t<=0?UR.TrackBefore:UR.TrackAfter:UR.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 zP&&(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 VP(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 qP(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)}zP.prototype.point=!0;class UP extends GD{constructor(e,t){super(),this.tagName=e,this.attributes=t}eq(e){return e==this||e instanceof UP&&this.tagName==e.tagName&&LP(this.attributes,e.attributes)}static create(e){return new UP(e.tagName,e.attributes||PP)}static set(e,t=!1){return QD.of(e,t)}}function KP(e){let t;return t=11==e.nodeType?e.getSelection?e:e.ownerDocument:e,t.getSelection()}function GP(e,t){return!!t&&(e==t||e.contains(1!=t.nodeType?t.parentNode:t))}function YP(e,t){if(!t.anchorNode)return!1;try{return GP(e,t.anchorNode)}catch(e){return!1}}function $P(e){return 3==e.nodeType?lL(e,0,e.nodeValue.length).getClientRects():1==e.nodeType?e.getClientRects():[]}function XP(e,t,n,r){return!!n&&(ZP(e,t,n,r,-1)||ZP(e,t,n,r,1))}function JP(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t}function QP(e){return 1==e.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(e.nodeName)}function ZP(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:eL(e))){if("DIV"==e.nodeName)return!1;let n=e.parentNode;if(!n||1!=n.nodeType)return!1;t=JP(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?eL(e):0}}}function eL(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function tL(e,t){let n=t?e.left:e.right;return{left:n,right:n,top:e.top,bottom:e.bottom}}function nL(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 rL(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}}UP.prototype.startSide=UP.prototype.endSide=-1;class iL{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?eL(t):0),n,Math.min(e.focusOffset,n?eL(n):0))}set(e,t,n,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=r}}let oL,sL=null;function aL(e){if(e.setActive)return e.setActive();if(sL)return e.focus(sL);let t=[];for(let n=e;n&&(t.push(n,n.scrollTop,n.scrollLeft),n!=n.ownerDocument);n=n.parentNode);if(e.focus(null==sL?{get preventScroll(){return sL={preventScroll:!0},!0}}:void 0),!sL){sL=!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 lL(e,t,n=t){let r=oL||(oL=document.createRange());return r.setEnd(e,n),r.setStart(e,t),r}function cL(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 uL(e){return e.scrollTop>Math.max(1,e.scrollHeight-e.clientHeight-4)}function hL(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=eL(n)}else{if(!n.parentNode||QP(n))return null;r=JP(n),n=n.parentNode}}}function fL(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||QP(n))return null;r=JP(n)+1,n=n.parentNode}}}RP.safari&&RP.safari_version>=26&&(sL=!1);class dL{constructor(e,t,n=!0){this.node=e,this.offset=t,this.precise=n}static before(e,t){return new dL(e.parentNode,JP(e),t)}static after(e,t){return new dL(e.parentNode,JP(e)+1,t)}}var pL=function(e){return e[e.LTR=0]="LTR",e[e.RTL=1]="RTL",e}(pL||(pL={}));const mL=pL.LTR,gL=pL.RTL;function vL(e){let t=[];for(let n=0;n<e.length;n++)t.push(1<<+e[n]);return t}const yL=vL("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),bL=vL("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),wL=Object.create(null),kL=[];for(let e of["()","[]","{}"]){let t=e.charCodeAt(0),n=e.charCodeAt(1);wL[t]=n,wL[n]=-t}function xL(e){return e<=247?yL[e]:1424<=e&&e<=1524?2:1536<=e&&e<=1785?bL[e-1536]:1774<=e&&e<=2220?4:8192<=e&&e<=8204?256:64336<=e&&e<=65023?4:1}const SL=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class CL{get dir(){return this.level%2?gL:mL}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 EL(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||!EL(r.inner,i.inner))return!1}return!0}const AL=[];function ML(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=AL[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(AL[e]==a)break e;break}e=o[t++].to}if(c++,h)h.push(p);else{p.from>l&&s.push(new CL(l,p.from,f)),OL(e,p.direction==mL!=!(f%2)?r+1:r,i,p.inner,p.from,p.to,s),l=p.to}d=p.to}else{if(d==n||(t?AL[d]!=a:AL[d]==a))break;d++}h?ML(e,l,d,r+1,i,h,s):l<d&&s.push(new CL(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=AL[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(AL[e-1]==a)break e;break}e=o[--n].from}if(h)h.push(p);else{p.to<l&&s.push(new CL(p.to,l,f)),OL(e,p.direction==mL!=!(f%2)?r+1:r,i,p.inner,p.from,p.to,s),l=p.from}d=p.from}else{if(d==t||(n?AL[d-1]!=a:AL[d-1]==a))break;d--}h?ML(e,d,l,r+1,i,h,s):d<l&&s.push(new CL(d,l,f)),l=d}}function OL(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=xL(e.charCodeAt(t));512==i?i=n:8==i&&4==r&&(i=16),AL[t]=4==i?2:i,7&i&&(r=i),n=i}for(let e=s,t=l,r=l;e<a;e++){let i=AL[e];if(128==i)e<a-1&&t==AL[e+1]&&24&t?i=AL[e]=t:AL[e]=256;else if(64==i){let i=e+1;for(;i<a&&64==AL[i];)i++;let o=e&&8==t||i<n&&8==AL[i]?1==r?1:8:256;for(let t=e;t<i;t++)AL[t]=o;e=i-1}else 8==i&&1==r&&(AL[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=wL[t=e.charCodeAt(s)])if(n<0){for(let e=a-3;e>=0;e-=3)if(kL[e+1]==-n){let t=kL[e+2],n=2&t?i:4&t?1&t?o:i:0;n&&(AL[s]=AL[kL[e]]=n),a=e;break}}else{if(189==kL.length)break;kL[a++]=s,kL[a++]=t,kL[a++]=l}else if(2==(r=AL[s])||1==r){let e=r==i;l=e?0:1;for(let t=a-3;t>=0;t-=3){let n=kL[t+2];if(2&n)break;if(e)kL[t+2]|=2;else{if(4&n)break;kL[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=AL[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!=AL[s])break;s++}let c=1==o,u=c==(1==(s<t?AL[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),AL[--t]=u;l=s}else o=s,l++}}}(i,o,r,a),ML(e,i,o,t,n,r,s)}function NL(e){return[new CL(0,e,0)]}let TL="";function RL(e,t,n,r,i){var o;let s=r.head-e.from,a=CL.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=VR(e.text,s,l.forward(i,n));(u<l.from||u>l.to)&&(u=c),TL=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?tD.cursor(h.side(!i,n)+e.from,h.forward(i,n)?1:-1,h.level):tD.cursor(u+e.from,l.forward(i,n)?-1:1,l.level)}function DL(e,t,n){for(let r=t;r<n;r++){let t=xL(e.charCodeAt(r));if(1==t)return mL;if(2==t||4==t)return gL}return mL}const PL=iD.define(),LL=iD.define(),BL=iD.define(),IL=iD.define(),_L=iD.define(),jL=iD.define(),FL=iD.define(),WL=iD.define(),HL=iD.define(),zL=iD.define({combine:e=>e.some(e=>e)}),VL=iD.define({combine:e=>e.some(e=>e)}),qL=iD.define();class UL{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 UL(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 UL(tD.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const KL=LD.define({map:(e,t)=>e.map(t)}),GL=LD.define();function YL(e,t,n){let r=e.facet(IL);r.length?r[0](t):window.onerror&&window.onerror(String(t),n,void 0,void 0,t)}const $L=iD.define({combine:e=>!e.length||e[0]});let XL=0;const JL=iD.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 QL{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(JL.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(JL.of({plugin:this,arg:e}))}static define(e,t){const{eventHandlers:n,eventObservers:r,provide:i,decorations:o}=t||{};return new QL(XL++,e,n,r,e=>{let t=[];return o&&t.push(nB.of(t=>{let n=t.plugin(e);return n?o(n):FP.none})),i&&t.push(i(e)),t})}static fromClass(e,t){return QL.define((t,n)=>new e(t,n),t)}}class ZL{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(YL(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){YL(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){YL(e.state,t,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const eB=iD.define(),tB=iD.define(),nB=iD.define(),rB=iD.define(),iB=iD.define(),oB=iD.define(),sB=iD.define();function aB(e,t){let n=e.state.facet(sB);if(!n.length)return n;let r=n.map(t=>t instanceof Function?t(e):t),i=[];return QD.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=DL(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 lB=iD.define();function cB(e){let t=0,n=0,r=0,i=0;for(let o of e.state.facet(lB)){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 uB=iD.define();class hB{constructor(e,t,n,r){this.fromA=e,this.toA=t,this.fromB=n,this.toB=r}join(e){return new hB(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 hB(c,h,l,u))}return n}}class fB{constructor(e,t,n){this.view=e,this.state=t,this.transactions=n,this.flags=0,this.startState=e.state,this.changes=GR.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 hB(e,t,n,i))),this.changedRanges=r}static create(e,t,n){return new fB(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 dB=[];class pB{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 dB}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=JP(this.dom),r=this.length?e>0:t>0;return new dL(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 vB)return e;return null}static get(e){return e.cmTile}}class mB extends pB{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=gB(t);else n.insertBefore(s.dom,t);r=s.dom}for(t=r?r.nextSibling:n.firstChild,i&&t&&(i.written=!0);t;)t=gB(t);this.length=o}}function gB(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}class vB extends mB{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=pB.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 yB)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 yB extends mB{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 yB(t||document.createElement(e.tagName),e);return t||(n.flags|=4),n}}class bB extends mB{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(e,t,n){let r=new bB(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&&wB(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=$P(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 dL(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 dL(e.dom,0);e==n.tile&&(o=!0)}}return new dL(this.dom,0)}}function wB(e,t){let n=e.coordsIn(0,1),r=t.coordsIn(0,1);return n&&r&&r.top<n.bottom}class kB extends mB{constructor(e,t){super(e),this.mark=t}get domAttrs(){return this.mark.attrs}static of(e,t){let n=new kB(t||document.createElement(e.tagName),e);return t||(n.flags|=4),n}}class xB extends pB{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?RP.chrome||RP.gecko||(e?(r--,o=1):i<n&&(i++,o=-1)):t<0?r--:i<n&&i++;let s=lL(this.dom,r,i).getClientRects();if(!s.length)return null;let a=s[(o?o<0:t>=0)?0:s.length-1];return RP.safari&&!o&&0==a.width&&(a=Array.prototype.find.call(s,e=>e.width)||a),o?tL(a,o<0):a||null}static of(e,t){let n=new xB(t||document.createTextNode(e),e);return t||(n.flags|=2),n}}class SB extends pB{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 tL(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 tL(n,!r)}}get overrideDOMText(){if(!this.length)return PR.empty;let{root:e}=this;if(!e)return PR.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 SB(i,n,e,r)}}class CB extends pB{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 PR.empty}coordsIn(e){return this.dom.getBoundingClientRect()}}class EB{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 AB{constructor(e,t,n,r){this.from=e,this.to=t,this.wrapper=n,this.rank=r}}class MB{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||xB.of(e,null===(i=this.cache.find(xB))||void 0===i?void 0:i.dom));else{this.cache.reused.set(s,2),(o.children[o.children.length-1]=new xB(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)?LB(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 kB&&i.mark.eq(n.mark))i.dom!=n.dom&&i.setDOM(LB(n.dom)),r=i;else{if(this.cache.reused.get(n)){let e=pB.get(n.dom);e&&e.setDOM(LB(n.dom))}let e=kB.of(n.mark,n.dom);r.append(e),r=e}this.cache.reused.set(n,2)}let i=pB.get(e.text);i&&this.cache.reused.set(i,2);let o=new xB(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=PB);let r=bB.start(e,t||(null===(n=this.cache.find(bB))||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 kB&&o.mark.eq(s))r=o,t--;else{let e=kB.of(s,null===(n=this.cache.find(kB,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&&DB(this.curLine,!1)&&("BR"==e.dom.nodeName||!e.isWidget()||RP.ios&&DB(this.curLine,!0))||this.curLine.append(this.cache.findWidget(IB,0,32)||new SB(IB.toDOM(),0,IB,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 AB(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 yB&&r.wrapper.eq(n.wrapper))t=r;else{let r=yB.of(n.wrapper,null===(e=this.cache.find(yB,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(CB,void 0,1);return n&&(n.flags=t),n||new CB(t)}flushBuffer(){!this.afterWidget||32&this.afterWidget.flags||(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class OB{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 NB=[SB,bB,xB,kB,CB,yB,vB];for(let e=0;e<NB.length;e++)NB[e].bucket=e;class TB{constructor(e){this.view=e,this.buckets=NB.map(()=>[]),this.index=NB.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 SB(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 RB{constructor(e,t,n,r,i){this.view=e,this.decorations=r,this.disallowBlockEffectsFor=i,this.openWidget=!1,this.openMarks=0,this.cache=new TB(e),this.text=new OB(e.state.doc),this.builder=new MB(this.cache,new vB(e,e.contentDOM),QD.iter(n)),this.cache.reused.set(t,2),this.old=new EB(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 kB&&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?SB.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 CB)this.cache.add(e);else{if(!(e instanceof kB))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 kB&&r.unshift(e.mark)),this.openWidget=!1},leave:e=>{e.isLine()?r.length&&(r.length=i=0):e instanceof kB&&(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=QD.spans(this.decorations,e,t,{point:(e,t,o,s,a,l)=>{if(o instanceof zP){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?BB.block:BB.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)||SB.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&&DP(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=pB.get(r);if(r==this.view.contentDOM)break;e instanceof kB?t.push(e):(null==e?void 0:e.isLine())?n=e:"DIV"!=r.nodeName||n||r==this.view.contentDOM?t.push(kB.of(new WP({tagName:r.nodeName.toLowerCase(),attributes:IP(r)}),r)):n=new bB(r,PB)}return{line:n,marks:t}}}function DB(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 PB={class:"cm-line"};function LB(e){let t=pB.get(e);return t&&t.setDOM(e.cloneNode()),e}class BB extends _P{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}}BB.inline=new BB("span"),BB.block=new BB("div");const IB=new class extends _P{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class _B{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=FP.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 vB(e,e.contentDOM),this.updateInner([new hB(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=FB(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 hB(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 hB(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,(RP.ie||RP.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 WB;return QD.compare(e,t,n,r),r.changes}(o,this.decorations,e.changes);a.length&&(n=hB.extendWithRanges(n,a));let l=function(e,t,n){let r=new HB;return QD.compare(e,t,n,r),r.changes}(s,this.blockWrappers,e.changes);return l.length&&(n=hB.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 RB(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=RP.chrome||RP.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 zB&&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(GL)&&(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($L)||n.tabIndex>-1)&&YP(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)),RP.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 dL(e,0),s=!0}var u;let h=this.view.observer.selectionRange;!s&&h.focusNode&&(XP(a.node,a.offset,h.anchorNode,h.anchorOffset)&&XP(l.node,l.offset,h.focusNode,h.focusOffset)||this.suppressWidgetCursorChange(h,c))||(this.view.observer.ignore(()=>{RP.android&&RP.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=KP(this.view.root);if(e)if(c.empty){if(RP.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?hL:fL)(a.node,a.offset);t&&(a=new dL(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 dL(h.anchorNode,h.anchorOffset),this.impreciseHead=l.precise?null:new dL(h.focusNode,h.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&XP(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=KP(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==eL(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&&!pB.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 zB?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=VR(t.text,n);if(e==n)return null;let r=lL(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==pL.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 yB)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?$P(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?pL.RTL:pL.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=$P(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=$P(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(FP.replace({widget:new zB(r),block:!0,inclusive:!0,isBlockGap:!0}).range(n,o))}if(!i)break;n=i.to+1}return FP.set(e)}updateDeco(){let e=1,t=this.view.state.facet(nB).map(t=>(this.dynamicDecorationMap[e++]="function"==typeof t)?t(this.view):t),n=!1,r=this.view.state.facet(iB).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(QD.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(rB).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(qL))try{if(t(this.view,e.range,e))return!0}catch(e){YL(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=cB(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=nL(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}=rL(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==pL.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 FB(e,t){let n=e.observer.selectionRange;if(!n.focusNode)return null;let r=hL(n.focusNode,n.focusOffset),i=fL(n.focusNode,n.focusOffset),o=r||i;if(i&&r&&i.node!=r.node){let t=pB.get(i.node);if(!t||t.isText()&&t.text!=i.node.nodeValue)o=i;else if(e.docView.lastCompositionAfterCursor){let e=pB.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 WB=class{constructor(){this.changes=[]}compareRange(e,t){qP(e,t,this.changes)}comparePoint(e,t){qP(e,t,this.changes)}boundChange(e){qP(e,e,this.changes)}};class HB{constructor(){this.changes=[]}compareRange(e,t){qP(e,t,this.changes)}comparePoint(){}boundChange(e){qP(e,e,this.changes)}}class zB extends _P{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 VB(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=VR(e,r)}return!0===r?-1:e.length}(s,o,e.state.tabSize)}function qB(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==pL.LTR)?t.right-1:t.left+1,y:(o.top+o.bottom)/2});if(null!=s)return tD.cursor(s,n?-1:1)}return tD.cursor(n?i.to:i.from,n?-1:1)}function UB(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=RL(i,o,s,a,n),c=TL;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 KB(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 GB(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=KB(e,i.from,0);t!=i.from&&(o=tD.cursor(t,-1))}else{let t=KB(e,i.from,-1),n=KB(e,i.to,1);t==i.from&&n==i.to||(o=tD.range(i.from==i.anchor?t:n,i.from==i.head?t:n))}o&&(n||(n=t.ranges.slice()),n[r]=o)}return n?tD.create(n,t.mainIndex):t}function YB(e,t,n){let r=KB(e.state.facet(oB).map(t=>t(e)),n.from,t.head>n.from?-1:1);return r==n.from?n:tD.cursor(r,r<n.from?1:-1)}class $B{constructor(e,t){this.pos=e,this.assoc=t}}function XB(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 $B(0,1);if(c>e.viewState.docHeight)return new $B(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=VB(e,o,i,a,l);return new $B(t,t==i.from?1:-1)}}if(i.type!=jP.Text)return c<(i.top+i.bottom)/2?new $B(i.from,1):new $B(i.to,-1);let u=e.docView.lineAt(i.from,2);return u&&u.length==i.length||(u=e.docView.lineAt(i.from,-2)),JB(e,u,i.from,a,l)}function JB(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=VR(t.text,e);if(h(lL(t.dom,e,n).getClientRects(),e),!a&&!l)break;e=n}return r>(s.left+s.right)/2==(QB(e,o+n)==pL.LTR)?new $B(n+VR(t.text,o),-1):new $B(n+o,1)}{if(!t.length)return new $B(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:lL(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()?JB(e,c,u,Math.max(s.left,Math.min(s.right,r)),i):r>(s.left+s.right)/2==(QB(e,o+n)==pL.LTR)?new $B(u+c.length,-1):new $B(u,1)}}function QB(e,t){let n=e.state.doc.lineAt(t);return e.bidiSpans(n)[CL.find(e.bidiSpans(n),t-n.from,-1,1)].dir}const ZB="￿";class eI{constructor(e,t){this.points=e,this.view=t,this.text="",this.lineSeparator=t.state.facet(KD.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=ZB}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=pB.get(r),o=r.nextSibling;if(o==t){(null==i?void 0:i.breakAfter)&&!o&&n!=this.view.contentDOM&&this.lineBreak();break}let s=pB.get(o);(i&&s?i.breakAfter:(i?i.breakAfter:QP(r))||QP(o)&&("BR"!=r.nodeName||(null==i?void 0:i.isWidget()))&&this.text.length>e)&&!nI(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=pB.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+(tI(e,n.node,n.offset)?t:0))}}function tI(e,t,n){for(;;){if(!t||n<eL(t))return!1;if(t==e)return!0;n=JP(t)+1,t=t.parentNode}}function nI(e,t){let n;for(;e!=t&&e;e=e.nextSibling){let t=pB.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 rI{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}}class iI{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=oI(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 rI(n,r)),i==n&&o==r||t.push(new rI(i,o)));return t}(e),n=new eI(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?tD.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||!GP(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||!GP(e.contentDOM,t.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(t.anchorNode,t.anchorOffset),s=e.viewport;if((RP.ios||RP.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(tD.range(r,n)):this.newSel=tD.single(r,n)}}}function oI(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 oI(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 sI(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||RP.android&&t.text.length<s-r)&&(a=i.to,l="end");let c=lI(e.state.doc.sliceString(r,s,ZB),t.text,a-r,l);c&&(RP.chrome&&13==o&&c.toB==c.from+2&&t.text.slice(c.from,c.toB)==ZB+ZB&&c.toB--,n={from:r+c.from,to:r+c.toA,insert:PR.of(t.text.slice(c.from,c.toB).split(ZB))})}else r&&(!e.hasFocus&&e.state.facet($L)||cI(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)}:(RP.mac||RP.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=tD.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:PR.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)}:RP.chrome&&n&&n.from==n.to&&n.from==i.head&&"\n "==n.insert.toString()&&e.lineWrapping&&(r&&(r=tD.single(r.main.anchor-1,r.main.head-1)),n={from:i.from,to:i.to,insert:PR.of([" "])}),n)return aI(e,n,r,o);if(r&&!cI(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=GB(e.state.facet(oB).map(t=>t(e)),r))),e.dispatch({selection:r,scrollIntoView:t,userEvent:n}),!0}return!1}function aI(e,t,n,r=-1){if(RP.ios&&e.inputState.flushIOSKey(t))return!0;let i=e.state.selection.main;if(RP.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&&cL(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)&&cL(e.contentDOM,"Backspace",8)||t.from==i.from&&t.to==i.to+1&&0==t.insert.length&&cL(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=KB(i.facet(oB).map(t=>t(e)),r,n);t.from==a&&(s=a)}if(s>-1)r={changes:t,selection:tD.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&&FB(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?tD.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 lI(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 cI(e,t){return t.head==e.main.head&&t.anchor==e.main.anchor}class uI{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,RP.safari&&e.contentDOM.addEventListener("input",()=>null),RP.gecko&&function(e){LI.has(e)||(LI.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=pB.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=fI(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&&mI.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),RP.android&&RP.chrome&&!e.synthetic&&(13==e.keyCode||8==e.keyCode))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return!RP.ios||e.synthetic||e.altKey||e.metaKey||!((t=dI.find(t=>t.keyCode==e.keyCode))&&!e.ctrlKey||pI.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,cL(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||!!(RP.safari&&!RP.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 hI(e,t){return(n,r)=>{try{return t.call(e,r,n)}catch(e){YL(n.state,e)}}}function fI(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(hI(t.value,i))}if(i)for(let e in i){let r=i[e];r&&n(e).observers.push(hI(t.value,r))}}for(let e in yI)n(e).handlers.push(yI[e]);for(let e in bI)n(e).observers.push(bI[e]);return t}const dI=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],pI="dthko",mI=[16,17,18,20,91,92,224,225];function gI(e){return.7*Math.max(0,e)+8}class vI{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(oB).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(KD.allowMultipleSelections)&&function(e,t){let n=e.state.facet(PL);return n.length?n[0](t):RP.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=KP(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!=OI(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=cB(this.view);e.clientX-c.left<=o+6?r=-gI(o-e.clientX):e.clientX+c.right>=a-6&&(r=gI(e.clientX-a)),e.clientY-c.top<=s+6?i=-gI(s-e.clientY):e.clientY+c.bottom>=l-6&&(i=gI(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=GB(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 yI=Object.create(null),bI=Object.create(null),wI=RP.ie&&RP.ie_version<15||RP.ios&&RP.webkit_version<604;function kI(e,t,n){for(let r of e.facet(t))n=r(n,e);return n}function xI(e,t){t=kI(e.state,WL,t);let n,{state:r}=e,i=1,o=r.toText(t),s=o.lines==r.selection.ranges.length,a=null!=TI&&r.selection.ranges.every(e=>e.empty)&&TI==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:tD.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:tD.cursor(e.from+t.length)}}):r.replaceSelection(o);e.dispatch(n,{userEvent:"input.paste",scrollIntoView:!0})}function SI(e,t,n,r){if(1==r)return tD.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 tD.cursor(t);0==o?n=1:o==i.length&&(n=-1);let s=o,a=o;n<0?s=VR(i.text,o,!1):a=VR(i.text,o);let l=r(i.text.slice(s,a));for(;s>0;){let e=VR(i.text,s,!1);if(r(i.text.slice(e,s))!=l)break;s=e}for(;a<i.length;){let e=VR(i.text,a);if(r(i.text.slice(a,e))!=l)break;a=e}return tD.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++,tD.range(o,s)}}bI.scroll=e=>{e.inputState.lastScrollTop=e.scrollDOM.scrollTop,e.inputState.lastScrollLeft=e.scrollDOM.scrollLeft},yI.keydown=(e,t)=>(e.inputState.setSelectionOrigin("select"),27==t.keyCode&&0!=e.inputState.tabFocusMode&&(e.inputState.tabFocusMode=Date.now()+2e3),!1),bI.touchstart=(e,t)=>{e.inputState.lastTouchTime=Date.now(),e.inputState.setSelectionOrigin("select.pointer")},bI.touchmove=e=>{e.inputState.setSelectionOrigin("select.pointer")},yI.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(BL))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=OI(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=SI(e,l.pos,l.assoc,r);if(n.pos!=l.pos&&!o){let t=SI(e,n.pos,n.assoc,r),i=Math.min(t.from,c.from),o=Math.max(t.to,c.to);c=i<c.from?tD.range(i,o):tD.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 tD.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):tD.create([c])}}}(e,t)),n){let r=!e.hasFocus;e.inputState.startMouseSelection(new vI(e,t,n,r)),r&&e.observer.ignore(()=>{aL(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 CI=RP.ie&&RP.ie_version<=11;let EI=null,AI=0,MI=0;function OI(e){if(!CI)return e.detail;let t=EI,n=MI;return EI=e,MI=Date.now(),AI=!t||n>Date.now()-400&&Math.abs(t.clientX-e.clientX)<2&&Math.abs(t.clientY-e.clientY)<2?(AI+1)%3:1}function NI(e,t,n,r){if(!(n=kI(e.state,WL,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(LL);return n.length?n[0](t):RP.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}yI.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=tD.range(e,t))}}let{inputState:r}=e;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,t.dataTransfer&&(t.dataTransfer.setData("Text",kI(e.state,HL,e.state.sliceDoc(n.from,n.to))),t.dataTransfer.effectAllowed="copyMove"),!1},yI.dragend=e=>(e.inputState.draggedContent=null,!1),yI.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&&NI(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 NI(e,t,n,!0),!0}return!1},yI.paste=(e,t)=>{if(e.state.readOnly)return!0;e.observer.flush();let n=wI?null:t.clipboardData;return n?(xI(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(),xI(e,n.value)},50)}(e),!1)};let TI=null;yI.copy=yI.cut=(e,t)=>{let n=KP(e.root);if(n&&!YP(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:kI(e,HL,t.join(e.lineBreak)),ranges:n,linewise:r}}(e.state);if(!r&&!o)return!1;TI=o?r:null,"cut"!=t.type||e.state.readOnly||e.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let s=wI?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 RI=RD.define();function DI(e,t){let n=[];for(let r of e.facet(FL)){let i=r(e,t);i&&n.push(i)}return n.length?e.update({effects:n,annotations:RI.of(!0)}):null}function PI(e){setTimeout(()=>{let t=e.hasFocus;if(t!=e.inputState.notifiedFocused){let n=DI(e.state,t);n?e.dispatch(n):e.update([])}},10)}bI.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),PI(e)},bI.blur=e=>{e.observer.clearSelectionRange(),PI(e)},bI.compositionstart=bI.compositionupdate=e=>{e.observer.editContext||(null==e.inputState.compositionFirstChange&&(e.inputState.compositionFirstChange=!0),e.inputState.composing<0&&(e.inputState.composing=0))},bI.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,RP.chrome&&RP.android?e.observer.flushSoon():e.inputState.compositionPendingChange?Promise.resolve().then(()=>e.observer.flush()):setTimeout(()=>{e.inputState.composing<0&&e.docView.hasComposition&&e.update([])},50))},bI.contextmenu=e=>{e.inputState.lastContextMenu=Date.now()},yI.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 aI(e,{from:n,to:o,insert:e.state.toText(r)},null),!0}}let i;if(RP.chrome&&RP.android&&(i=dI.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 RP.ios&&"deleteContentForward"==t.inputType&&e.observer.flushSoon(),RP.safari&&"insertText"==t.inputType&&e.inputState.composing>=0&&setTimeout(()=>bI.compositionend(e,t),20),!1};const LI=new Set;const BI=["pre-wrap","normal","pre-line","break-spaces"];let II=!1;function _I(){II=!1}class jI{constructor(e){this.lineWrapping=e,this.doc=PR.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 BI.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=BI.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 FI{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}}class WI{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 zP?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 WI(this.from,this.length+e.length,this.top,this.height+e.height,t)}}var HI=function(e){return e[e.ByPos=0]="ByPos",e[e.ByHeight=1]="ByHeight",e[e.ByPosNoHeight=2]="ByPosNoHeight",e}(HI||(HI={}));const zI=.001;class VI{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)>zI&&(II=!0),this.height=e)}replace(e,t,n){return VI.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,HI.ByPosNoHeight,n.setDoc(t),0,0),f=h.to>=l?h:i.lineAt(l,HI.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,HI.ByPosNoHeight,n,0,0));c+=h.from-a,a=h.from;let d=JI.build(n.setDoc(o),e,c,u);i=qI(i,i.replace(a,l,d))}return i.updateHeight(n,0)}static empty(){return new GI(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 $I(VI.of(e.slice(0,t)),o,VI.of(e.slice(n)))}}function qI(e,t){return e==t?e:(e.constructor!=t.constructor&&(II=!0),t)}VI.prototype.size=1;const UI=FP.replace({});class KI extends VI{constructor(e,t,n){super(e,t),this.deco=n,this.spaceAbove=0}mainBlock(e,t){return new WI(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 WI(r,0,n,this.spaceAbove,UI):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,HI.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 GI extends KI{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 WI(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 GI||r instanceof YI&&4&r.flags)&&Math.abs(this.length-r.length)<10?(r instanceof YI?r=new GI(r.length,this.height,this.spaceAbove):r.height=this.height,this.outdated||(r.outdated=!1),r):VI.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 YI extends VI{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 WI(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 WI(a,l,n+s*r,s,0)}}lineAt(e,t,n,r,i){if(t==HI.ByHeight)return this.blockAt(e,n,r,i);if(t==HI.ByPosNoHeight){let{from:t,to:r}=n.doc.lineAt(e);return new WI(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 WI(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 WI(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 YI?n[n.length-1]=new YI(e.length+r):n.push(null,new YI(r-1))}if(e>0){let t=n[0];t instanceof YI?n[0]=new YI(e+t.length):n.unshift(new YI(e-1),null)}return VI.of(n)}decomposeLeft(e,t){t.push(new YI(e-1),null)}decomposeRight(e,t){t.push(null,new YI(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 YI(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)>=zI&&(s=-2);let l=new GI(t,i,a);l.outdated=!1,n.push(l),o+=t+1}o<=i&&n.push(null,new YI(i-o).updateHeight(e,o));let a=VI.of(n);return(s<0||Math.abs(a.height-this.height)>=zI||Math.abs(s-this.heightMetrics(e,t).perLine)>=zI)&&(II=!0),qI(this,a)}return(n||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class $I extends VI{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==HI.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==HI.ByPosNoHeight?HI.ByPosNoHeight:HI.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,HI.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&&XI(i,o-1),t<this.length){let e=i.length;this.decomposeRight(t,i),XI(i,e)}return VI.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?VI.of(this.break?[e,null,t]:[e,t]):(this.left=qI(this.left,e),this.right=qI(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 XI(e,t){let n,r;null==e[t]&&(n=e[t-1])instanceof YI&&(r=e[t+1])instanceof YI&&e.splice(t-1,3,new YI(n.length+1+r.length))}class JI{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 GI?n.length+=e-this.pos:(e>this.pos||!this.isCovered)&&this.nodes.push(new GI(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 KI(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 GI(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let n=new YI(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 GI)return e;let t=new GI(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 GI||this.isCovered?(this.writtenTo<this.pos||null==t)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new GI(0,-1,0));let n=e;for(let e of this.nodes)e instanceof GI&&e.updateHeight(this.oracle,n),n+=e?e.length:1;return this.nodes}static build(e,t,n,r){let i=new JI(n,e);return QD.spans(t,n,r,i,0),i.finish(n)}}class QI{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,n,r){(e<t||n&&n.heightRelevant||r&&r.heightRelevant)&&qP(e,t,this.changes,5)}}function ZI(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 e_(e,t){let n=e.getBoundingClientRect();return{left:0,right:n.right-n.left,top:t,bottom:n.bottom-(n.top+t)}}class t_{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 FP.replace({widget:new n_(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}}class n_ extends _P{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 r_{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=a_,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=pL.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let t=e.facet(tB).some(e=>"function"!=typeof e&&"cm-lineWrapping"==e.class);this.heightOracle=new jI(t),this.stateDeco=l_(e),this.heightMap=VI.empty().applyChanges(this.stateDeco,PR.empty,this.heightOracle.setDoc(e.doc),[new hB(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=FP.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 i_(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?a_:new c_(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(u_(e,this.scaler))})}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=l_(this.state);let r=e.changedRanges,i=hB.extendWithRanges(r,function(e,t,n){let r=new QI;return QD.compare(e,t,n,r,0),r.changes}(n,this.stateDeco,e?e.changes:GR.empty(this.state.doc.length))),o=this.heightMap.height,s=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);_I(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),i),(this.heightMap.height!=o||II)&&(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(VL)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,n=window.getComputedStyle(t),r=this.heightOracle,i=n.whiteSpace;this.defaultTextDirection="rtl"==n.direction?pL.RTL:pL.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}=rL(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=uL(e.scrollDOM);let d=(this.printing?e_:ZI)(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)),_I();for(let n of this.viewports){let i=n.from==this.viewport.from?t:e.docView.measureVisibleLineHeights(n);this.heightMap=(o?VI.empty().applyChanges(this.stateDeco,PR.empty,this.heightOracle,[new hB(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,o,new FI(n.from,i))}II&&(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 i_(r.lineAt(o-1e3*n,HI.ByHeight,i,0,0).from,r.lineAt(s+1e3*(1-n),HI.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,HI.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 i_(r.lineAt(n-500,HI.ByHeight,i,0,0).from,r.lineAt(n+o+500,HI.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 i_(this.heightMap.lineAt(n,HI.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(r,HI.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,HI.ByPos,this.heightOracle,0,0),{bottom:i}=this.heightMap.lineAt(t,HI.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 t_(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!=pL.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(tD.cursor(o),!1,!0).head;e>r&&(o=e)}let e=this.gapSize(l,r,o,c);f=new t_(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;QD.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=s_(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=o_(i,e),l=o_(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=s_(i,c),t=((d-f)/2+o)/n;u=e-t,h=e+t}else u=(f-o)/n,h=(d+o)/n;s=o_(i,u),l=o_(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=s_(r,n)-s_(r,t);return this.heightOracle.lineWrapping?e.height*i:r.total*this.heightOracle.charWidth*i}updateLineGaps(e){t_.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=FP.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=[];QD.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)||u_(this.heightMap.lineAt(e,HI.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)||u_(this.heightMap.lineAt(this.scaler.fromDOM(e),HI.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 u_(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 i_{constructor(e,t){this.from=e,this.to=t}}function o_({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 s_(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 a_={toDOM:e=>e,fromDOM:e=>e,scale:1,eq(e){return e==this}};function l_(e){let t=e.facet(nB).filter(e=>"function"!=typeof e),n=e.facet(iB).filter(e=>"function"!=typeof e);return n.length&&t.push(QD.join(n)),t}class c_{constructor(e,t,n){let r=0,i=0,o=0;this.viewports=n.map(({from:n,to:i})=>{let o=t.lineAt(n,HI.ByPos,e,0,0).top,s=t.lineAt(i,HI.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 c_&&(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 u_(e,t){if(1==t.scale)return e;let n=t.toDOM(e.top),r=t.toDOM(e.bottom);return new WI(e.from,e.length,n,r-n,Array.isArray(e._content)?e._content.map(e=>u_(e,t)):e._content)}const h_=iD.define({combine:e=>e.join(" ")}),f_=iD.define({combine:e=>e.indexOf(!0)>-1}),d_=dP.newName(),p_=dP.newName(),m_=dP.newName(),g_={"&light":"."+p_,"&dark":"."+m_};function v_(e,t,n){return new dP(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 y_=v_("."+d_,{"&":{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"}},g_),b_={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},w_=RP.ie&&RP.ie_version<=11;class k_{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new iL,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);(RP.ie&&RP.ie_version<=11||RP.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||!RP.android||!1===e.constructor.EDIT_CONTEXT||RP.chrome&&RP.chrome_version<126||(this.editContext=new C_(e),e.state.facet($L)&&(e.contentDOM.editContext=this.editContext.editContext)),w_&&(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($L)?n.root.activeElement!=this.dom:!YP(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):(RP.ie&&RP.ie_version<=11||RP.android&&RP.chrome)&&!n.state.selection.main.empty&&r.focusNode&&XP(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=KP(e.root);if(!t)return!1;let n=RP.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 S_(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?S_(e,n):null}(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;let r=YP(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,eL(n));;)if(r){if(1!=n.nodeType)return!1;let e=n.childNodes[r-1];"false"==e.contentEditable?r--:(n=e,r=eL(n))}else{if(n==e)return!0;r=JP(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,b_),w_&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),w_&&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&&cL(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&&YP(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 iI(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=sI(this.view,t);return this.view.state==n&&(t.domChanged||t.newSel&&!cI(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=x_(t,e.previousSibling||e.target.previousSibling,-1),r=x_(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($L)!=e.state.facet($L)&&(e.view.contentDOM.editContext=e.state.facet($L)?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 x_(e,t,n){for(;t;){let r=pB.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 S_(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 XP(s.node,s.offset,i,o)&&([n,r,i,o]=[i,o,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:o}}class C_{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=lI(e.state.sliceDoc(s,a),n.text,(l?r.from:r.to)-s,l?"end":null);if(!c){let t=tD.single(this.toEditorPos(n.selectionStart),this.toEditorPos(n.selectionEnd));return void(cI(t,r)||e.dispatch({selection:t,userEvent:"select"}))}let u={from:c.from+s,to:c.toA+s,insert:PR.of(n.text.slice(c.from,c.toB).split("\n"))};if((RP.mac||RP.android)&&u.from==o-1&&/^\. ?$/.test(n.text)&&"off"==e.contentDOM.getAttribute("autocorrect")&&(u={from:s,to:a,insert:PR.of([n.text.replace("."," ")])}),this.pendingContextChange=u,!e.state.readOnly){let t=this.to-this.from+(u.to-u.from+u.insert.length);aI(e,u,tD.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(FP.mark({attributes:{style:e}}).range(i,o))}}}e.dispatch({effects:GL.of(FP.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=KP(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 E_{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 r_(e.state||KD.create(e)),e.scrollTo&&e.scrollTo.is(KL)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(JL).map(e=>new ZL(e));for(let e of this.plugins)e.update(this);this.observer=new k_(this),this.inputState=new uI(this),this.inputState.ensureHandlers(this.plugins),this.docView=new _B(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 BD?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(RI))?(this.inputState.notifiedFocused=o,s=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=DI(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(KD.phrases)!=this.state.facet(KD.phrases))return this.setState(i);t=fB.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 UL(e.empty?e:tD.cursor(e.head,e.head>e.anchor?-1:1))}for(let e of t.effects)e.is(KL)&&(u=e.value.clip(this.state))}this.viewState.update(t,u),this.bidiCache=O_.update(this.bidiCache,t.changes),t.empty||(this.updatePlugins(t),this.inputState.update(t)),n=this.docView.update(t),this.state.facet(uB)!=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(h_)!=t.state.facet(h_)&&(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(_L))try{e(t)}catch(e){YL(this.state,e,"update listener")}(a||c)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!sI(this,c)&&l.force&&cL(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 r_(e),this.plugins=e.facet(JL).map(e=>new ZL(e)),this.pluginMap.clear();for(let e of this.plugins)e.update(this);this.docView.destroy(),this.docView=new _B(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(JL),n=e.state.facet(JL);if(t!=n){let r=[];for(let i of n){let n=t.indexOf(i);if(n<0)r.push(new ZL(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){YL(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(uL(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 YL(this.state,e),M_}}),c=fB.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]!=M_)try{let t=a[e];t.write&&t.write(l[e],this)}catch(e){YL(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(_L))e(t)}get themeClasses(){return d_+" "+(this.state.facet(f_)?m_:p_)+" "+this.state.facet(h_)}updateAttrs(){let e=N_(this,eB,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet($L)?"true":"false",class:"cm-content",style:`${RP.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),N_(this,tB,t);let n=this.observer.ignore(()=>{let n=BP(this.contentDOM,this.contentAttrs,t),r=BP(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(E_.announce)){t&&(this.announceDOM.textContent=""),t=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=e.value}}mountStyles(){this.styleModules=this.state.facet(uB);let e=this.state.facet(E_.cspNonce);dP.mount(this.root,this.styleModules.concat(y_).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 YB(this,e,UB(this,e,t,n))}moveByGroup(e,t){return YB(this,e,UB(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==zD.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 tD.cursor(i.side(t,r)+e.from,i.forward(!t,r)?1:-1)}moveToLineBoundary(e,t,n=!0){return qB(this,e,t,n)}moveVertically(e,t,n){return YB(this,e,function(e,t,n,r){let i=t.head,o=n?1:-1;if(i==(n?e.state.doc.length:0))return tD.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=XB(e,{x:l.left+a,y:s+(null!=r?r:e.viewState.heightOracle.textHeight>>1)*o},!1,o);return tD.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=XB(this,e,t);return n&&n.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),XB(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 tL(n,i[CL.find(i,e-r.from,-1,t)].dir==pL.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(zL)||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>A_)return NL(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||EL(r.isolates,t=aB(this,e))))return r.order;t||(t=aB(this,e));let r=function(e,t,n){if(!e)return[new CL(0,0,t==gL?1:0)];if(t==mL&&!n.length&&!SL.test(e))return NL(e.length);if(n.length)for(;e.length>AL.length;)AL[AL.length]=256;let r=[],i=t==mL?0:1;return OL(e,i,i,n,0,e.length,r),r}(e.text,n,t);return this.bidiCache.push(new O_(e.from,e.to,n,t,!0,r)),r}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||RP.safari&&(null===(e=this.inputState)||void 0===e?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{aL(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 KL.of(new UL("number"==typeof e?tD.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 KL.of(new UL(tD.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 QL.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return QL.define(()=>({}),{eventObservers:e})}static theme(e,t){let n=dP.newName(),r=[h_.of(n),uB.of(v_(`.${n}`,e))];return t&&t.dark&&r.push(f_.of(!0)),r}static baseTheme(e){return vD.lowest(uB.of(v_("."+d_,e,g_)))}static findFromDOM(e){var t;let n=e.querySelector(".cm-content"),r=n&&pB.get(n)||pB.get(e);return(null===(t=null==r?void 0:r.root)||void 0===t?void 0:t.view)||null}}E_.styleModule=uB,E_.inputHandler=jL,E_.clipboardInputFilter=WL,E_.clipboardOutputFilter=HL,E_.scrollHandler=qL,E_.focusChangeEffect=FL,E_.perLineTextDirection=zL,E_.exceptionSink=IL,E_.updateListener=_L,E_.editable=$L,E_.mouseSelectionStyle=BL,E_.dragMovesSelection=LL,E_.clickAddsSelectionRange=PL,E_.decorations=nB,E_.blockWrappers=rB,E_.outerDecorations=iB,E_.atomicRanges=oB,E_.bidiIsolatedRanges=sB,E_.scrollMargins=lB,E_.darkTheme=f_,E_.cspNonce=iD.define({combine:e=>e.length?e[0]:""}),E_.contentAttributes=tB,E_.editorAttributes=eB,E_.lineWrapping=E_.contentAttributes.of({class:"cm-lineWrapping"}),E_.announce=LD.define();const A_=4096,M_={};class O_{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:pL.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 O_(t.mapPos(o.from,1),t.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return n}}function N_(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&&DP(o,n)}return n}class T_ extends GD{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}function R_(e){return D_.apply(this,arguments)}function D_(){return D_=p(O().m(function e(t){var n,r;return O().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)})),D_.apply(this,arguments)}function P_(e){var t=e.value,n=e.title;if(null==t||""===t)return s.createElement("span",null,"-");var r,i=Rm(t),o=i.ok,a=i.pretty,l=i.compact,c=l.length>80?l.slice(0,80)+"…":l;return s.createElement(im,null,s.createElement(om,{asChild:!0},s.createElement("button",{type:"button",className:"max-w-xs truncate text-left font-mono text-xs text-muted-foreground hover:underline",title:"点击查看 JSON"},c)),s.createElement(lm,{className:"max-w-3xl"},s.createElement(cm,null,s.createElement(hm,null,n||"JSON")),s.createElement("div",{className:"flex items-center justify-end gap-2"},s.createElement(Dt,{variant:"outline",size:"sm",onClick:(r=p(O().m(function e(){return O().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,R_(a);case 1:xu.success("已复制 JSON"),e.n=3;break;case 2:e.p=2,e.v,xu.error("复制失败");case 3:return e.a(2)}},e,null,[[0,2]])})),function(){return r.apply(this,arguments)})},"复制")),s.createElement("pre",{className:"max-h-[60vh] overflow-auto rounded-md bg-muted p-3 text-xs font-mono whitespace-pre-wrap break-all"},a),!o&&s.createElement("div",{className:"text-xs text-destructive"},i.ok?"":i.message)))}function L_(e){e.id;var t=e.value;e.required;var n,r=e.disabled,i=e.onChange,o=D(s.useState(null),2),a=o[0],l=o[1];return s.createElement("div",{className:"space-y-2"},s.createElement("div",{className:"flex items-center justify-end gap-2"},s.createElement(Dt,{type:"button",variant:"outline",size:"sm",disabled:!!r,onClick:function(){if(!r){var e=(t||"").trim();if(e){var n=Dm(e,2);n.ok?(i(n.formatted),l(null)):l(n.message)}}}},"格式化"),s.createElement(Dt,{type:"button",variant:"outline",size:"sm",onClick:(n=p(O().m(function e(){return O().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,R_(t||"");case 1:xu.success("已复制"),e.n=3;break;case 2:e.p=2,e.v,xu.error("复制失败");case 3:return e.a(2)}},e,null,[[0,2]])})),function(){return n.apply(this,arguments)})},"复制")),s.createElement("div",{className:"w-full max-w-full overflow-hidden rounded-md border bg-background"},s.createElement($T,{className:"w-full max-w-full",editable:!r,value:t||"",height:"220px",basicSetup:{lineNumbers:!0,foldGutter:!0,highlightActiveLine:!0},extensions:[new cE(kR),E_.lineWrapping],onChange:function(e){r||(i(e),function(e){var t=(e||"").trim();if(!t)return l(null),!0;var n=Rm(t);n.ok?l(null):l(n.message)}(e))}})),a&&s.createElement("div",{className:"text-xs text-destructive"},a))}T_.prototype.elementClass="",T_.prototype.toDOM=void 0,T_.prototype.mapMode=UR.TrackBefore,T_.prototype.startSide=T_.prototype.endSide=-1,T_.prototype.point=!0;var B_=s.forwardRef(function(e,t){var n=e.className,r=H(e,["className"]);return s.createElement("div",{className:"relative w-full overflow-x-auto"},s.createElement("table",Object.assign({ref:t,className:mt("w-full min-w-max caption-bottom text-sm",n)},r)))});B_.displayName="Table";var I_=s.forwardRef(function(e,t){var n=e.className,r=H(e,["className"]);return s.createElement("thead",Object.assign({ref:t,className:mt("[&_tr]:border-b",n)},r))});I_.displayName="TableHeader";var __=s.forwardRef(function(e,t){var n=e.className,r=H(e,["className"]);return s.createElement("tbody",Object.assign({ref:t,className:mt("[&_tr:last-child]:border-0",n)},r))});__.displayName="TableBody";var j_=s.forwardRef(function(e,t){var n=e.className,r=H(e,["className"]);return s.createElement("tfoot",Object.assign({ref:t,className:mt("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",n)},r))});j_.displayName="TableFooter";var F_=s.forwardRef(function(e,t){var n=e.className,r=H(e,["className"]);return s.createElement("tr",Object.assign({ref:t,className:mt("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",n)},r))});F_.displayName="TableRow";var W_=s.forwardRef(function(e,t){var n=e.className,r=H(e,["className"]);return s.createElement("th",Object.assign({ref:t,className:mt("h-12 px-4 text-left align-middle font-medium text-muted-foreground whitespace-nowrap [&:has([role=checkbox])]:pr-0",n)},r))});W_.displayName="TableHead";var H_=s.forwardRef(function(e,t){var n=e.className,r=H(e,["className"]);return s.createElement("td",Object.assign({ref:t,className:mt("p-4 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0",n)},r))});H_.displayName="TableCell";var z_=s.forwardRef(function(e,t){var n=e.className,r=H(e,["className"]);return s.createElement("caption",Object.assign({ref:t,className:mt("mt-4 text-sm text-muted-foreground",n)},r))});z_.displayName="TableCaption";var V_=Tt("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 q_(e){var t=e.className,n=e.variant,r=H(e,["className","variant"]);return s.createElement("div",Object.assign({className:mt(V_({variant:n}),t)},r))}function U_(){return"".concat(Date.now(),"_").concat(Math.random().toString(16).slice(2))}function K_(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 G_(t){var n,r,i=e.useMemo(function(){var e=[];e.push.apply(e,L([{column:"id",label:"ID",type:"id"},{column:"created_at",label:"创建时间",type:"datetime"},{column:"updated_at",label:"更新时间",type:"datetime"}]));var n,r=w(t.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");e.push({column:o,label:"".concat(i.comment||i.name,"(关联)"),type:"relation"})}else e.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 e.filter(function(e){return!s.has(e.column)&&(s.add(e.column),!0)})},[t.fields]),o=e.useMemo(function(){return new Map(i.map(function(e){return[e.column,e]}))},[i]),s=e.useMemo(function(){return new Map(i.map(function(e){return[e.column,e.type]}))},[i]),a=D(e.useState([]),2),l=a[0],c=a[1];e.useEffect(function(){c(function(e,t){return(e||[]).map(function(e){if(t.get(e.column),"is"===e.operator&&(null===e.value||"null"===e.value))return{id:U_(),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:U_(),column:e.column,operator:"contains",value:n.slice(1,-1)};if(n.endsWith("%"))return{id:U_(),column:e.column,operator:"startsWith",value:n.slice(0,-1)};if(n.startsWith("%"))return{id:U_(),column:e.column,operator:"endsWith",value:n.slice(1)}}if("in"===e.operator){var r=Array.isArray(e.value)?e.value:[];return{id:U_(),column:e.column,operator:"in",value:r.join(",")}}return{id:U_(),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)}})}(t.value||[],s))},[JSON.stringify(t.value),i.length]);var u=function(e,t){c(function(n){return n.map(function(n){var r,i;if(n.id!==e)return n;var s=Object.assign(Object.assign({},n),t);if(t.column&&t.column!==n.column){var a=K_((null===(r=o.get(t.column))||void 0===r?void 0:r.type)||"string");s.operator=(null===(i=a[0])||void 0===i?void 0:i.value)||"eq",s.value=""}return t.operator&&"isNull"===t.operator&&(s.value=""),s})})};return e.createElement("div",{className:"space-y-3"},e.createElement("div",{className:"flex items-center justify-between gap-3"},e.createElement(nu,{className:"text-base font-medium flex items-center gap-2"},e.createElement(re,{className:"h-4 w-4"}),"动态筛选"),e.createElement("div",{className:"flex items-center gap-2"},(null===(n=t.value)||void 0===n?void 0:n.length)>0&&e.createElement(q_,{variant:"secondary"},"已应用 ",t.value.length," 条"),e.createElement(Dt,{type:"button",variant:"outline",size:"sm",onClick:function(){var e=i[0];if(e){var t=K_(e.type);c(function(n){var r;return[].concat(L(n),[{id:U_(),column:e.column,operator:(null===(r=t[0])||void 0===r?void 0:r.value)||"eq",value:""}])})}}},e.createElement(fe,{className:"h-4 w-4 mr-1"}),"添加条件"))),0===l.length?e.createElement("div",{className:"text-sm text-muted-foreground border rounded-lg p-3 bg-muted/20"},"暂无筛选条件(可添加条件后点击“应用”)"):e.createElement("div",{className:"space-y-2"},l.map(function(t){var n=o.get(t.column),r=(null==n?void 0:n.type)||"string",s=K_(r),a="isNull"!==t.operator;return e.createElement("div",{key:t.id,className:"grid grid-cols-12 gap-2 items-center"},e.createElement("div",{className:"col-span-5"},e.createElement(Bp,{value:t.column,onValueChange:function(e){return u(t.id,{column:e})}},e.createElement(_p,{className:"h-10"},e.createElement(Ip,{placeholder:"字段"})),e.createElement(Wp,null,i.map(function(t){return e.createElement(zp,{key:t.column,value:t.column},t.label," (",t.column,")")})))),e.createElement("div",{className:"col-span-3"},e.createElement(Bp,{value:t.operator,onValueChange:function(e){return u(t.id,{operator:e})}},e.createElement(_p,{className:"h-10"},e.createElement(Ip,{placeholder:"操作符"})),e.createElement(Wp,null,s.map(function(t){return e.createElement(zp,{key:t.value,value:t.value},t.label)})))),e.createElement("div",{className:"col-span-3"},a?"boolean"===r?e.createElement(Bp,{value:t.value,onValueChange:function(e){return u(t.id,{value:e})}},e.createElement(_p,{className:"h-10"},e.createElement(Ip,{placeholder:"值"})),e.createElement(Wp,null,e.createElement(zp,{value:"true"},"true"),e.createElement(zp,{value:"false"},"false"))):e.createElement(Pt,{className:"h-10",placeholder:"in"===t.operator?"多个值用逗号分隔":"值",type:"integer"===r||"float"===r?"number":"date"===r?"date":"datetime"===r?"datetime-local":"text",value:t.value,onChange:function(e){return u(t.id,{value:e.target.value})}}):e.createElement("div",{className:"h-10 flex items-center text-sm text-muted-foreground"},"无需填写")),e.createElement("div",{className:"col-span-1 flex justify-end"},e.createElement(Dt,{type:"button",variant:"ghost",size:"sm",className:"h-9 w-9 p-0",onClick:function(){return e=t.id,void c(function(t){return t.filter(function(t){return t.id!==e})});var e}},e.createElement(we,{className:"h-4 w-4"}))))})),e.createElement("div",{className:"flex items-center justify-end gap-2"},e.createElement(Dt,{type:"button",variant:"outline",onClick:function(){c([]),t.onChange([])},disabled:0===l.length&&0===((null===(r=t.value)||void 0===r?void 0:r.length)||0)},"清空"),e.createElement(Dt,{type:"button",onClick:function(){var e=function(e,t){var n,r,i=[],o=w(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}(l,o);t.onChange(e)},disabled:0===l.length},"应用")))}function Y_(){var t,n=D(e.useState([]),2),r=n[0],o=n[1],s=D(e.useState(null),2),a=s[0],l=s[1],c=D(e.useState([]),2),u=c[0],h=c[1],f=D(e.useState(!1),2),d=f[0],m=f[1],g=D(e.useState(!1),2),v=g[0],y=g[1],b=D(e.useState(null),2),w=b[0],x=b[1],S=D(e.useState({}),2),C=S[0],E=S[1],A=D(e.useState(1),2),M=A[0],N=A[1],T=D(e.useState(10),2),R=T[0];T[1];var P=D(e.useState(0),2),L=P[0],B=P[1],I=D(e.useState(""),2),_=I[0],j=I[1],F=D(e.useState(!1),2),W=F[0],H=F[1],z=D(e.useState(null),2),V=z[0],q=z[1],U=D(e.useState(!0),2),K=U[0],G=U[1],Y=D(e.useState([]),2),$=Y[0],Q=Y[1],Z=D(e.useState(!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:[]},ie=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}},oe=function(e){return!e||!e.readOnly&&!1!==e.editable};e.useEffect(function(){se()},[]),e.useEffect(function(){a&&le()},[a,M,R,_,$]);var se=function(){var e=p(O().m(function e(){var t;return O().w(function(e){for(;;)switch(e.p=e.n){case 0:return G(!0),e.p=1,e.n=2,Jf();case 2:t=e.v,o(ne(t.data)),e.n=4;break;case 3:e.p=3,e.v,xu.error("加载模型列表失败");case 4:return e.p=4,G(!1),e.f(4);case 5:return e.a(2)}},e,null,[[1,3,4,5]])}));return function(){return e.apply(this,arguments)}}(),le=function(){var e=p(O().m(function e(){var t,n,r;return O().w(function(e){for(;;)switch(e.p=e.n){case 0:if(a){e.n=1;break}return e.a(2);case 1:return m(!0),e.p=2,t={page:M,limit:R},_&&(t.search=_),$.length>0&&(t.filters=$),e.n=3,sd(a.table_name,t);case 3:if((n=e.v).success){e.n=4;break}return xu.error(n.message||"加载数据失败"),h([]),B(0),e.a(2);case 4:r=ie(n.data),h(r.rows),B(r.total),e.n=6;break;case 5:e.p=5,e.v,xu.error("加载数据失败"),h([]),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)}}(),ce=function(){var e=p(O().m(function e(t){var n;return O().w(function(e){for(;;)switch(e.p=e.n){case 0:if(confirm("确定要删除这条数据吗?此操作不可撤销。")){e.n=1;break}return e.a(2);case 1:return q(t.id),e.p=2,e.n=3,ud(null==a?void 0:a.table_name,t.id);case 3:(n=e.v).success?(xu.success("删除成功"),le()):xu.error(n.message||"删除失败"),e.n=5;break;case 4:e.p=4,e.v,xu.error("删除失败");case 5:return e.p=5,q(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=p(O().m(function e(){var t,n,r,i,o;return O().w(function(e){for(;;)switch(e.p=e.n){case 0:if(a){e.n=1;break}return e.a(2);case 1:if(H(!0),e.p=2,t={},a.json_schema.fields.forEach(function(e){if("id"!==e.name&&oe(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=Rm(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}}),!w){e.n=4;break}return e.n=3,cd(a.table_name,Object.assign(Object.assign({},t),{id:w.id}));case 3:(n=e.v).success?(xu.success("更新成功"),y(!1),le()):xu.error(n.message||"更新失败"),e.n=6;break;case 4:return e.n=5,ld(a.table_name,t);case 5:(r=e.v).success?(xu.success("创建成功"),y(!1),le()):xu.error(r.message||"创建失败");case 6:e.n=8;break;case 7:e.p=7,o=e.v,i=o instanceof Error?o.message:"操作失败",xu.error(i);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)}}();return e.createElement("div",{className:"min-h-[calc(100vh-4rem)] bg-gradient-to-br from-background via-background to-muted/20"},e.createElement("div",{className:"container mx-auto px-6 py-8 space-y-6"},e.createElement("div",{className:"space-y-2"},e.createElement("h1",{className:"text-3xl font-bold tracking-tight"},"数据列表"),e.createElement("p",{className:"text-muted-foreground"},"选择模型查看和管理数据")),e.createElement(ru,{className:"border-2 shadow-lg"},e.createElement(iu,{className:"bg-muted/30"},e.createElement("div",{className:"flex flex-col md:flex-row md:items-center md:justify-between gap-4"},e.createElement("div",null,e.createElement(ou,null,"数据管理"),e.createElement(su,null,"选择数据模型进行查看和管理")),a&&e.createElement(Dt,{onClick:function(){x(null),E({}),y(!0)},className:"w-full md:w-auto"},e.createElement(fe,{className:"h-4 w-4 mr-2"}),"新建数据"))),e.createElement(au,{className:"space-y-6 pt-6"},e.createElement("div",{className:"flex flex-col md:flex-row gap-4"},e.createElement("div",{className:"flex-1 space-y-2"},e.createElement(nu,{htmlFor:"model",className:"text-base font-medium flex items-center gap-2"},e.createElement(re,{className:"h-4 w-4"}),"选择数据模型"),e.createElement(Bp,{value:(null===(t=null==a?void 0:a.id)||void 0===t?void 0:t.toString())||"",onValueChange:function(e){var t=r.find(function(t){return t.id.toString()===e});l(t||null),N(1),j(""),Q([])},disabled:K},e.createElement(_p,{className:"h-11"},K?e.createElement("div",{className:"flex items-center gap-2"},e.createElement(ae,{className:"h-4 w-4 animate-spin"}),e.createElement("span",null,"加载中...")):e.createElement(Ip,{placeholder:"请选择模型"})),e.createElement(Wp,null,r.map(function(t){return e.createElement(zp,{key:t.id,value:t.id.toString()},t.name," (",t.table_name,")")})))),a&&e.createElement("div",{className:"flex-1 space-y-2"},e.createElement(nu,{htmlFor:"search",className:"text-base font-medium flex items-center gap-2"},e.createElement(de,{className:"h-4 w-4"}),"搜索"),e.createElement("div",{className:"relative"},e.createElement(de,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.createElement(Pt,{id:"search",placeholder:"搜索数据...",value:_,onChange:function(e){return j(e.target.value)},className:"pl-10 h-11"})))),a&&e.createElement(e.Fragment,null,e.createElement("div",{className:"flex items-center justify-end"},e.createElement(Dt,{type:"button",variant:"outline",className:"h-10",onClick:function(){return te(!0)}},e.createElement(re,{className:"h-4 w-4 mr-2"}),"筛选",$.length>0?"(".concat($.length,")"):"")),e.createElement("div",{className:"flex items-center justify-between p-4 rounded-lg bg-muted/50 border"},e.createElement("div",{className:"text-sm text-muted-foreground"},"共 ",e.createElement("span",{className:"font-semibold text-foreground"},L)," 条数据"),e.createElement(q_,{variant:"outline"},a.name)),e.createElement("div",{className:"rounded-lg border overflow-hidden"},e.createElement("div",{className:"overflow-x-auto"},e.createElement(B_,null,e.createElement(I_,null,e.createElement(F_,{className:"bg-muted/50"},e.createElement(W_,{className:"font-semibold w-20"},"ID"),a.json_schema.fields.map(function(t){return e.createElement(W_,{key:t.name,className:"font-semibold"},t.comment||t.name)}),e.createElement(W_,{className:"font-semibold"},"创建时间"),e.createElement(W_,{className:"font-semibold"},"更新时间"),e.createElement(W_,{className:"font-semibold w-32 text-center"},"操作"))),e.createElement(__,null,d?Array.from({length:3}).map(function(t,n){return e.createElement(F_,{key:n},e.createElement(H_,{colSpan:a.json_schema.fields.length+4},e.createElement("div",{className:"flex items-center gap-2 py-4"},e.createElement(ae,{className:"h-4 w-4 animate-spin text-muted-foreground"}),e.createElement("span",{className:"text-sm text-muted-foreground"},"加载中..."))))}):0===u.length?e.createElement(F_,null,e.createElement(H_,{colSpan:a.json_schema.fields.length+4,className:"text-center py-12"},e.createElement("div",{className:"flex flex-col items-center gap-2 text-muted-foreground"},e.createElement(de,{className:"h-8 w-8"}),e.createElement("p",null,"暂无数据")))):u.map(function(t,n){return e.createElement(F_,{key:t.id,className:n%2==0?"bg-muted/20":""},e.createElement(H_,{className:"font-mono font-medium"},t.id),a.json_schema.fields.map(function(n){return e.createElement(H_,{key:n.name},function(t,n){return"boolean"===t.type?e.createElement(q_,{variant:n?"default":"secondary"},n?"是":"否"):"date"===t.type||"datetime"===t.type?n?i(n).format("YYYY-MM-DD HH:mm:ss"):"-":"text"===t.type&&n&&n.length>50?e.createElement("span",{className:"max-w-xs truncate block",title:n},n.substring(0,50),"..."):"json"===t.type||"jsonb"===t.type?e.createElement(P_,{value:n,title:t.comment||t.name}):n||"-"}(n,t[n.name]))}),e.createElement(H_,{className:"text-sm text-muted-foreground"},i(t.created_at).format("YYYY-MM-DD HH:mm")),e.createElement(H_,{className:"text-sm text-muted-foreground"},i(t.updated_at).format("YYYY-MM-DD HH:mm")),e.createElement(H_,null,e.createElement("div",{className:"flex items-center justify-center gap-2"},e.createElement(Dt,{variant:"ghost",size:"sm",onClick:function(){return function(e){x(e);var t={};null==a||a.json_schema.fields.forEach(function(n){if("id"!==n.name){var r=e[n.name];"date"!==n.type&&"datetime"!==n.type||(r=r?i(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)}(t)},className:"h-8 w-8 p-0"},e.createElement(me,{className:"h-4 w-4"})),e.createElement(Dt,{variant:"ghost",size:"sm",onClick:function(){return ce(t)},disabled:V===t.id,className:"h-8 w-8 p-0 text-destructive hover:text-destructive"},V===t.id?e.createElement(ae,{className:"h-4 w-4 animate-spin"}):e.createElement(ve,{className:"h-4 w-4"})))))}))))),L>R&&e.createElement("div",{className:"flex items-center justify-between p-4 rounded-lg bg-muted/50 border"},e.createElement("div",{className:"text-sm text-muted-foreground"},"第 ",e.createElement("span",{className:"font-semibold text-foreground"},M)," 页, 共 ",e.createElement("span",{className:"font-semibold text-foreground"},Math.ceil(L/R))," 页"),e.createElement("div",{className:"flex gap-2"},e.createElement(Dt,{variant:"outline",size:"sm",onClick:function(){return N(Math.max(1,M-1))},disabled:1===M||d},e.createElement(X,{className:"h-4 w-4 mr-1"}),"上一页"),e.createElement(Dt,{variant:"outline",size:"sm",onClick:function(){return N(Math.min(Math.ceil(L/R),M+1))},disabled:M>=Math.ceil(L/R)||d},"下一页",e.createElement(J,{className:"h-4 w-4 ml-1"}))))))),a&&e.createElement(im,{open:ee,onOpenChange:te},e.createElement(lm,{className:"max-w-3xl"},e.createElement(cm,null,e.createElement(hm,{className:"text-xl"},"筛选"),e.createElement(dm,{className:"text-sm"},a.name," - ",a.table_name)),e.createElement("div",{className:"py-2"},e.createElement(G_,{fields:a.json_schema.fields,value:$,onChange:function(e){Q(e),N(1)}})),e.createElement(um,{className:"gap-2"},e.createElement(Dt,{variant:"outline",onClick:function(){return te(!1)}},"关闭")))),e.createElement(im,{open:v,onOpenChange:y},e.createElement(lm,{className:"max-w-3xl max-h-[85vh] overflow-y-auto"},e.createElement(cm,null,e.createElement(hm,{className:"text-2xl"},w?"编辑数据":"新建数据"),e.createElement(dm,{className:"text-base"},null==a?void 0:a.name," - ",null==a?void 0:a.table_name)),e.createElement("div",{className:"space-y-4 py-4"},null==a?void 0:a.json_schema.fields.map(function(t){return function(t){if("id"===t.name)return null;var n=oe(t);switch(t.type){case"boolean":return e.createElement("div",{key:t.name,className:"flex items-center space-x-3 p-4 rounded-lg border bg-card"},e.createElement(nm,{id:t.name,checked:C[t.name]||!1,disabled:!n,onCheckedChange:function(e){return E(Object.assign(Object.assign({},C),k({},t.name,e)))}}),e.createElement(nu,{htmlFor:t.name,className:"text-base font-medium cursor-pointer"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")));case"date":return e.createElement("div",{key:t.name,className:"space-y-2"},e.createElement(nu,{htmlFor:t.name,className:"text-base font-medium"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")),e.createElement(Pt,{id:t.name,type:"date",value:C[t.name]||"",disabled:!n,onChange:function(e){return E(Object.assign(Object.assign({},C),k({},t.name,e.target.value)))},required:t.required,className:"h-11"}));case"datetime":return e.createElement("div",{key:t.name,className:"space-y-2"},e.createElement(nu,{htmlFor:t.name,className:"text-base font-medium"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")),e.createElement(Pt,{id:t.name,type:"datetime-local",value:C[t.name]||"",disabled:!n,onChange:function(e){return E(Object.assign(Object.assign({},C),k({},t.name,e.target.value)))},required:t.required,className:"h-11"}));case"text":return e.createElement("div",{key:t.name,className:"space-y-2"},e.createElement(nu,{htmlFor:t.name,className:"text-base font-medium"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")),e.createElement(rm,{id:t.name,rows:4,value:C[t.name]||"",disabled:!n,onChange:function(e){return E(Object.assign(Object.assign({},C),k({},t.name,e.target.value)))},required:t.required,className:"resize-none"}));case"json":case"jsonb":return e.createElement("div",{key:t.name,className:"space-y-2"},e.createElement(nu,{htmlFor:t.name,className:"text-base font-medium"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")),e.createElement(L_,{id:t.name,value:C[t.name]||"",required:t.required,disabled:!n,onChange:function(e){return E(Object.assign(Object.assign({},C),k({},t.name,e)))}}));case"integer":case"float":return e.createElement("div",{key:t.name,className:"space-y-2"},e.createElement(nu,{htmlFor:t.name,className:"text-base font-medium"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")),e.createElement(Pt,{id:t.name,type:"number",value:C[t.name]||"",disabled:!n,onChange:function(e){return E(Object.assign(Object.assign({},C),k({},t.name,e.target.value)))},required:t.required,className:"h-11"}));default:return e.createElement("div",{key:t.name,className:"space-y-2"},e.createElement(nu,{htmlFor:t.name,className:"text-base font-medium"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")),e.createElement(Pt,{id:t.name,type:"email"===t.type?"email":"text",maxLength:t.maxLength,value:C[t.name]||"",disabled:!n,onChange:function(e){return E(Object.assign(Object.assign({},C),k({},t.name,e.target.value)))},required:t.required,className:"h-11"}))}}(t)})),e.createElement(um,{className:"gap-2"},e.createElement(Dt,{variant:"outline",onClick:function(){return y(!1)},disabled:W},"取消"),e.createElement(Dt,{onClick:ue,disabled:W},W?e.createElement(e.Fragment,null,e.createElement(ae,{className:"h-4 w-4 mr-2 animate-spin"}),w?"更新中...":"创建中..."):w?"更新":"创建"))))))}function $_(e){return/^https?:\/\//i.test(e)}function X_(t){var n=t.url;return e.createElement("div",{className:"flex items-center gap-2 max-w-[360px]"},e.createElement(sa,null,e.createElement(aa,{asChild:!0},e.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:"点击打开原图"},e.createElement("img",{src:n,alt:"",className:"h-full w-full object-cover",onError:function(e){e.currentTarget.style.display="none"}}))),e.createElement(la,{side:"right",className:"p-2"},e.createElement("img",{src:n,alt:"",className:"max-h-64 max-w-64 rounded object-contain",onError:function(e){e.currentTarget.style.display="none"}}))),e.createElement("a",{href:n,target:"_blank",rel:"noreferrer",className:"truncate text-primary underline-offset-2 hover:underline",title:n},n))}function J_(t){var n=t.model,r=D(e.useState([]),2),o=r[0],s=r[1],a=D(e.useState(!1),2),l=a[0],c=a[1],u=D(e.useState(!1),2),h=u[0],f=u[1],d=D(e.useState(!1),2),m=d[0],g=d[1],v=D(e.useState(null),2),y=v[0],b=v[1],w=D(e.useState({}),2),x=w[0],S=w[1],C=D(e.useState(1),2),E=C[0],A=C[1],M=D(e.useState(10),2),N=M[0];M[1];var T=D(e.useState(0),2),R=T[0],P=T[1],L=D(e.useState(""),2),B=L[0],I=L[1],_=D(e.useState(!1),2),j=_[0],F=_[1],W=D(e.useState(null),2),H=W[0],z=W[1],V=D(e.useState({}),2),q=V[0],U=V[1],K=D(e.useState([]),2),G=K[0],Y=K[1],$=e.useMemo(function(){return G.length?JSON.stringify(G):""},[G]),Q=function(e){return!e.readOnly&&!1!==e.editable};e.useEffect(function(){n&&ee()},[null==n?void 0:n.table_name,E,N,B,$]);var Z=function(){var e=p(O().m(function e(t){var n,r,i,o,s;return O().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,ad(r,{displayField:i||"name",limit:200});case 3:(s=e.v).success&&s.data&&U(function(e){return Object.assign(Object.assign({},e),k({},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)}}();e.useEffect(function(){h&&n&&n.json_schema.fields.filter(function(e){return"relation"===e.type&&e.relation}).forEach(function(e){return Z(e)})},[h,n]);var ee=function(){var e=p(O().m(function e(){var t,r,i,o;return O().w(function(e){for(;;)switch(e.p=e.n){case 0:if(n){e.n=1;break}return e.a(2);case 1:return c(!0),e.p=2,i={page:E,limit:N},B&&(i.search=B),G.length>0&&(i.filters=G),e.n=3,sd(n.table_name,i);case 3:if((o=e.v).success){e.n=4;break}return xu.error(o.message||"加载数据失败"),s([]),P(0),e.a(2);case 4:s((null===(t=o.data)||void 0===t?void 0:t.data)||[]),P((null===(r=o.data)||void 0===r?void 0:r.total)||0),e.n=6;break;case 5:e.p=5,e.v,xu.error("加载数据失败"),s([]),P(0);case 6:return e.p=6,c(!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=p(O().m(function e(t){var r;return O().w(function(e){for(;;)switch(e.p=e.n){case 0:if(confirm("确定要删除这条数据吗?此操作不可撤销。")){e.n=1;break}return e.a(2);case 1:return z(t.id),e.p=2,e.n=3,ud(null==n?void 0:n.table_name,t.id);case 3:(r=e.v).success?(xu.success("删除成功"),ee()):xu.error(r.message||"删除失败"),e.n=5;break;case 4:e.p=4,e.v,xu.error("删除失败");case 5:return e.p=5,z(null),e.f(5);case 6:return e.a(2)}},e,null,[[2,4,5,6]])}));return function(t){return e.apply(this,arguments)}}(),ie=function(){var e=p(O().m(function e(){var t,r,i,o,s,a;return O().w(function(e){for(;;)switch(e.p=e.n){case 0:if(n){e.n=1;break}return e.a(2);case 1:if(F(!0),e.p=2,t={},n.json_schema.fields.forEach(function(e){if("id"!==e.name&&Q(e))if("relation"===e.type&&e.relation){var n=e.relation.foreignKey||"".concat(e.relation.target,"_id");t[n]=x[n]}else{var r=x[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=Rm(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}}),!y){e.n=4;break}return r=Object.assign(Object.assign({},t),{id:y.id}),e.n=3,cd(n.table_name,r);case 3:(i=e.v).success?(xu.success("更新成功"),f(!1),ee()):xu.error(i.message||"更新失败"),e.n=6;break;case 4:return e.n=5,ld(n.table_name,t);case 5:(o=e.v).success?(xu.success("创建成功"),f(!1),ee()):xu.error(o.message||"创建失败");case 6:e.n=8;break;case 7:e.p=7,a=e.v,s=a instanceof Error?a.message:"操作失败",xu.error(s);case 8:return e.p=8,F(!1),e.f(8);case 9:return e.a(2)}},e,null,[[2,7,8,9]])}));return function(){return e.apply(this,arguments)}}(),oe=function(t,n,r){if("string"==typeof n){var o=n.trim();if(o&&function(e){var t,n=e.trim();if(!n)return!1;if(n.startsWith("data:image/"))return!0;if(!$_(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)}(o))return e.createElement(X_,{url:o});if(o&&$_(o))return e.createElement("a",{href:o,target:"_blank",rel:"noreferrer",className:"max-w-[360px] truncate text-primary underline-offset-2 hover:underline block",title:o},o)}if("boolean"===t.type)return e.createElement(q_,{variant:n?"default":"secondary"},n?"是":"否");if("date"===t.type||"datetime"===t.type)return n?i(n).format("YYYY-MM-DD HH:mm:ss"):"-";if("text"===t.type&&n&&n.length>50)return e.createElement("span",{className:"max-w-xs truncate block",title:n},n.substring(0,50),"...");if("json"===t.type||"jsonb"===t.type)return e.createElement(P_,{value:n,title:t.comment||t.name});if("relation"===t.type&&t.relation&&r){var s=t.relation.displayField,a=void 0===s?"name":s,l=r["".concat(t.name,"_data")];if(l)return e.createElement(q_,{variant:"outline"},l[a]||"ID: ".concat(l.id));var c=r[t.relation.foreignKey||"".concat(t.relation.target,"_id")];return c?"ID: ".concat(c):"-"}return n||"-"};return n?e.createElement("div",{className:"min-h-[calc(100vh-4rem)] bg-gradient-to-br from-background via-background to-muted/20"},e.createElement("div",{className:"w-full py-4 space-y-4"},e.createElement("div",{className:"space-y-1"},e.createElement("div",{className:"flex items-center gap-3"},e.createElement("div",{className:"inline-flex items-center justify-center w-9 h-9 rounded-lg bg-primary/10 text-primary"},e.createElement(te,{className:"h-4 w-4"})),e.createElement("div",null,e.createElement("h1",{className:"text-2xl font-bold tracking-tight leading-tight"},n.name),e.createElement("p",{className:"text-sm text-muted-foreground"},"表名: ",n.table_name)))),e.createElement(ru,{className:"border-2 shadow-lg"},e.createElement(iu,{className:"bg-muted/30"},e.createElement("div",{className:"flex flex-col md:flex-row md:items-center md:justify-between gap-4"},e.createElement("div",null,e.createElement(ou,null,"数据管理"),e.createElement(su,null,"查看和管理 ",n.name," 的数据")),e.createElement(Dt,{onClick:function(){b(null),S({}),f(!0)},className:"w-full md:w-auto"},e.createElement(fe,{className:"h-4 w-4 mr-2"}),"新建数据"))),e.createElement(au,{className:"space-y-4 pt-4"},e.createElement("div",{className:"flex flex-col md:flex-row md:items-center gap-3"},e.createElement("div",{className:"flex-1"},e.createElement(nu,{htmlFor:"search",className:"sr-only"},"搜索"),e.createElement("div",{className:"relative"},e.createElement(de,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.createElement(Pt,{id:"search",placeholder:"搜索数据...",value:B,onChange:function(e){return I(e.target.value)},className:"pl-10 h-10"}))),e.createElement(Dt,{type:"button",variant:"outline",className:"h-10",onClick:function(){return g(!0)}},e.createElement(re,{className:"h-4 w-4 mr-2"}),"筛选",G.length>0?"(".concat(G.length,")"):"")),e.createElement("div",{className:"flex items-center justify-between p-4 rounded-lg bg-muted/50 border"},e.createElement("div",{className:"text-sm text-muted-foreground"},"共 ",e.createElement("span",{className:"font-semibold text-foreground"},R)," 条数据"),e.createElement(q_,{variant:"outline"},n.name)),e.createElement("div",{className:"rounded-lg border overflow-hidden"},e.createElement(B_,null,e.createElement(I_,null,e.createElement(F_,{className:"bg-muted/50"},e.createElement(W_,{className:"font-semibold w-20"},"ID"),n.json_schema.fields.map(function(t){return e.createElement(W_,{key:t.name,className:"font-semibold"},t.comment||t.name)}),e.createElement(W_,{className:"font-semibold"},"创建时间"),e.createElement(W_,{className:"font-semibold"},"更新时间"),e.createElement(W_,{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)]")},"操作"))),e.createElement(__,null,l?Array.from({length:3}).map(function(t,r){return e.createElement(F_,{key:r},e.createElement(H_,{colSpan:n.json_schema.fields.length+4},e.createElement("div",{className:"flex items-center gap-2 py-4"},e.createElement(ae,{className:"h-4 w-4 animate-spin text-muted-foreground"}),e.createElement("span",{className:"text-sm text-muted-foreground"},"加载中..."))))}):0===o.length?e.createElement(F_,null,e.createElement(H_,{colSpan:n.json_schema.fields.length+4,className:"text-center py-12"},e.createElement("div",{className:"flex flex-col items-center gap-2 text-muted-foreground"},e.createElement(de,{className:"h-8 w-8"}),e.createElement("p",null,"暂无数据")))):o.map(function(t,r){return e.createElement(F_,{key:t.id,className:mt("group hover:bg-muted",r%2==0?"bg-muted/20":"")},e.createElement(H_,{className:"font-mono font-medium max-w-[220px] truncate",title:String(t.id)},t.id),n.json_schema.fields.map(function(n){return e.createElement(H_,{key:n.name},oe(n,t[n.name],t))}),e.createElement(H_,{className:"text-sm text-muted-foreground"},i(t.created_at).format("YYYY-MM-DD HH:mm")),e.createElement(H_,{className:"text-sm text-muted-foreground"},i(t.updated_at).format("YYYY-MM-DD HH:mm")),e.createElement(H_,{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")},e.createElement("div",{className:"flex items-center justify-center gap-2"},e.createElement(Dt,{variant:"ghost",size:"sm",onClick:function(){return function(e){b(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 o=e[n.name];"date"!==n.type&&"datetime"!==n.type||(o=o?i(o).format("YYYY-MM-DDTHH:mm"):""),"json"!==n.type&&"jsonb"!==n.type||(o=null==o||""===o?"":"string"==typeof o?o:JSON.stringify(o,null,2)),t[n.name]=o}}),S(t),f(!0)}(t)},className:"h-8 w-8 p-0"},e.createElement(me,{className:"h-4 w-4"})),e.createElement(Dt,{variant:"ghost",size:"sm",onClick:function(){return ne(t)},disabled:H===t.id,className:"h-8 w-8 p-0 text-destructive hover:text-destructive"},H===t.id?e.createElement(ae,{className:"h-4 w-4 animate-spin"}):e.createElement(ve,{className:"h-4 w-4"})))))})))),R>N&&e.createElement("div",{className:"flex items-center justify-between p-4 rounded-lg bg-muted/50 border"},e.createElement("div",{className:"text-sm text-muted-foreground"},"第 ",e.createElement("span",{className:"font-semibold text-foreground"},E)," 页, 共 ",e.createElement("span",{className:"font-semibold text-foreground"},Math.ceil(R/N))," 页"),e.createElement("div",{className:"flex gap-2"},e.createElement(Dt,{variant:"outline",size:"sm",onClick:function(){return A(Math.max(1,E-1))},disabled:1===E||l},e.createElement(X,{className:"h-4 w-4 mr-1"}),"上一页"),e.createElement(Dt,{variant:"outline",size:"sm",onClick:function(){return A(Math.min(Math.ceil(R/N),E+1))},disabled:E>=Math.ceil(R/N)||l},"下一页",e.createElement(J,{className:"h-4 w-4 ml-1"})))))),e.createElement(im,{open:m,onOpenChange:g},e.createElement(lm,{className:"max-w-3xl"},e.createElement(cm,null,e.createElement(hm,{className:"text-xl"},"筛选"),e.createElement(dm,{className:"text-sm"},n.name," - ",n.table_name)),e.createElement("div",{className:"py-2"},e.createElement(G_,{fields:n.json_schema.fields,value:G,onChange:function(e){Y(e),A(1)}})),e.createElement(um,{className:"gap-2"},e.createElement(Dt,{variant:"outline",onClick:function(){return g(!1)}},"关闭")))),e.createElement(im,{open:h,onOpenChange:f},e.createElement(lm,{className:"max-w-3xl max-h-[85vh] overflow-y-auto"},e.createElement(cm,null,e.createElement(hm,{className:"text-2xl"},y?"编辑数据":"新建数据"),e.createElement(dm,{className:"text-base"},n.name," - ",n.table_name)),e.createElement("div",{className:"space-y-6 py-4"},n.json_schema.fields.map(function(t){return function(t){if("id"===t.name)return null;var n=Q(t);switch(t.type){case"boolean":return e.createElement("div",{key:t.name,className:"flex items-center space-x-3 p-4 rounded-lg border bg-card"},e.createElement(nm,{id:t.name,checked:x[t.name]||!1,disabled:!n,onCheckedChange:function(e){return S(Object.assign(Object.assign({},x),k({},t.name,e)))}}),e.createElement(nu,{htmlFor:t.name,className:"text-sm font-semibold cursor-pointer"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")));case"date":return e.createElement("div",{key:t.name,className:"space-y-2.5"},e.createElement(nu,{htmlFor:t.name,className:"text-sm font-semibold"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")),e.createElement(Pt,{id:t.name,type:"date",value:x[t.name]||"",disabled:!n,onChange:function(e){return S(Object.assign(Object.assign({},x),k({},t.name,e.target.value)))},required:t.required,className:"h-11"}));case"datetime":return e.createElement("div",{key:t.name,className:"space-y-2.5"},e.createElement(nu,{htmlFor:t.name,className:"text-sm font-semibold"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")),e.createElement(Pt,{id:t.name,type:"datetime-local",value:x[t.name]||"",disabled:!n,onChange:function(e){return S(Object.assign(Object.assign({},x),k({},t.name,e.target.value)))},required:t.required,className:"h-11"}));case"text":return e.createElement("div",{key:t.name,className:"space-y-2.5"},e.createElement(nu,{htmlFor:t.name,className:"text-sm font-semibold"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")),e.createElement(rm,{id:t.name,rows:4,value:x[t.name]||"",disabled:!n,onChange:function(e){return S(Object.assign(Object.assign({},x),k({},t.name,e.target.value)))},required:t.required,className:"resize-none"}));case"json":case"jsonb":return e.createElement("div",{key:t.name,className:"space-y-2.5"},e.createElement(nu,{htmlFor:t.name,className:"text-sm font-semibold"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")),e.createElement(L_,{id:t.name,value:x[t.name]||"",required:t.required,disabled:!n,onChange:function(e){return S(Object.assign(Object.assign({},x),k({},t.name,e)))}}));case"integer":case"float":return e.createElement("div",{key:t.name,className:"space-y-2.5"},e.createElement(nu,{htmlFor:t.name,className:"text-sm font-semibold"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")),e.createElement(Pt,{id:t.name,type:"number",value:x[t.name]||"",disabled:!n,onChange:function(e){return S(Object.assign(Object.assign({},x),k({},t.name,e.target.value)))},required:t.required,className:"h-11"}));case"relation":if(!t.relation)return null;var r=t.relation,i=r.target,o=r.displayField,s=void 0===o?"name":o,a="".concat(i,"_").concat(s),l=q[a]||[],c=t.relation.foreignKey||"".concat(i,"_id"),u=void 0!==x[c]&&null!==x[c]?String(x[c]):"",h=l.find(function(e){return String(e.id)===u});return e.createElement("div",{key:t.name,className:"space-y-2.5"},e.createElement(nu,{htmlFor:t.name,className:"text-sm font-semibold"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")),e.createElement(Bp,{value:u,disabled:!n,onValueChange:function(e){var t=parseInt(e,10),n=!isNaN(t)&&String(t)===e;S(Object.assign(Object.assign({},x),k({},c,n?t:e)))}},e.createElement(_p,{className:"h-11"},e.createElement(Ip,{placeholder:"请选择".concat(t.comment||t.name)},h?h.label:u?"ID: ".concat(u):"请选择".concat(t.comment||t.name))),e.createElement(Wp,null,0===l.length?e.createElement(zp,{value:"_loading",disabled:!0},"加载中..."):l.map(function(t){return e.createElement(zp,{key:t.id,value:String(t.id)},t.label)}))));default:return e.createElement("div",{key:t.name,className:"space-y-2.5"},e.createElement(nu,{htmlFor:t.name,className:"text-sm font-semibold"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")),e.createElement(Pt,{id:t.name,type:"email"===t.type?"email":"text",maxLength:t.maxLength,value:x[t.name]||"",disabled:!n,onChange:function(e){return S(Object.assign(Object.assign({},x),k({},t.name,e.target.value)))},required:t.required,className:"h-11"}))}}(t)})),e.createElement(um,{className:"gap-2"},e.createElement(Dt,{variant:"outline",onClick:function(){return f(!1)},disabled:j},"取消"),e.createElement(Dt,{onClick:ie,disabled:j},j?e.createElement(e.Fragment,null,e.createElement(ae,{className:"h-4 w-4 mr-2 animate-spin"}),y?"更新中...":"创建中..."):y?"更新":"创建")))))):e.createElement("div",{className:"min-h-[calc(100vh-4rem)] bg-gradient-to-br from-background via-background to-muted/20"},e.createElement("div",{className:"w-full py-4"},e.createElement(ru,{className:"border-2"},e.createElement(au,{className:"py-16 text-center"},e.createElement(te,{className:"h-12 w-12 mx-auto mb-4 text-muted-foreground"}),e.createElement("p",{className:"text-lg text-muted-foreground"},"请选择数据模型")))))}function Q_(t){var n=t.model;return e.createElement(J_,{key:n.id,model:n})}function Z_(t){return t.models.map(function(t){return{path:"/data/list-".concat(t.id),name:t.name,icon:e.createElement(ge),component:function(){return e.createElement(Q_,{model:t})}}})}var ej=function(t){return[{path:"/login",name:"登录",icon:e.createElement(ce),component:vd},{name:"数据管理",icon:e.createElement(ee),path:"/data",component:Y_,routes:L(Z_(t))}]},tj=pe,nj=ye,rj=ue,ij=se;function oj(t){var n=t.inputModels,r=t.skipAuth,i=void 0!==r&&r,o=t.brandName,s=void 0===o?"WE0-CMS":o,a=md(),l=gd(),c=l.locale,u=l.setLocale,h=D(e.useState("/data"),2),f=h[0],d=h[1],m=D(e.useState([]),2);m[0],m[1];var g=D(e.useState(!1),2),v=g[0],y=g[1],b=D(e.useState(null),2),k=b[0],x=b[1],S=D(e.useState(!0),2),C=S[0],E=S[1],A=e.useMemo(function(){return ej({models:n.models})},[n.models]);e.useEffect(function(){if(i)return y(!0),x(null),E(!1),void("/login"===f&&d("/data"));var e=function(){var e=p(O().m(function e(){var t,n;return O().w(function(e){for(;;)switch(e.p=e.n){case 0:if(e.p=0,id()){e.n=1;break}return y(!1),d("/login"),E(!1),e.a(2);case 1:return e.p=1,e.n=2,td();case 2:if(e.v.success){e.n=3;break}throw new Error("token验证失败");case 3:if(!(t=od())){e.n=4;break}x(t),e.n=6;break;case 4:return e.n=5,nd();case 5:(n=e.v).success&&n.data&&(x(n.data),localStorage.setItem("cms_user",JSON.stringify(n.data)));case 6:y(!0),"/login"===f&&d("/data"),e.n=8;break;case 7:e.p=7,e.v,rd(),y(!1),x(null),d("/login");case 8:e.n=10;break;case 9:e.p=9,e.v,y(!1),x(null),d("/login");case 10:return e.p=10,E(!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()},[i]);var M=function(e,t){x(t),y(!0),d("/data"),xu.success("".concat(a("auth.welcome"),", ").concat(t.username,"!"))},N=function(e,t){var n,r=w(e);try{for(r.s();!(n=r.n()).done;){var i=n.value;if(i.path===t)return i;if(i.routes){var o=N(i.routes,t);if(o)return o}}}catch(e){r.e(e)}finally{r.f()}return null};if(C)return e.createElement("div",{className:"flex min-h-screen items-center justify-center bg-background"},e.createElement("div",{className:"space-y-4"},e.createElement(gt,{className:"h-12 w-48"}),e.createElement(gt,{className:"h-4 w-64"})));if(!v)return e.createElement(vd,{onLoginSuccess:M});var T=A.filter(function(e){return"/login"!==e.path}),R=function(t){if(!t)return te;if(e.isValidElement(t)){var n=t.type;if(n&&"function"==typeof n){var r=n.name||"";if(r.includes("Home"))return ie;if(r.includes("Table"))return ge;if(r.includes("Database"))return te;if(r.includes("File"))return ne}}return te},P=T.flatMap(function(e){return e.routes&&e.routes.length>0?e.routes.map(function(e){return{title:e.name,icon:R(e.icon),path:e.path}}):[{title:e.name,icon:R(e.icon),path:e.path}]});return e.createElement("div",{className:"we0-cms-root"},e.createElement(ha,null,e.createElement(fa,{variant:"inset"},e.createElement(ma,{className:"border-b border-sidebar-border p-4"},e.createElement("div",{className:"flex items-center gap-3"},e.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"},e.createElement(tj,{className:"w-5 h-5 text-primary-foreground"})),e.createElement("span",{className:"font-bold text-xl text-foreground"},s))),e.createElement(va,null,e.createElement(ya,null,e.createElement(ba,null,"Navigation"),e.createElement(wa,null,e.createElement(ka,null,P.map(function(t){return e.createElement(xa,{key:t.path},e.createElement(Ca,{onClick:function(){return d(t.path)},isActive:(n=t.path,f===n||f.startsWith(n+"/")),tooltip:t.title},e.createElement(t.icon,{className:"w-4 h-4"}),e.createElement("span",null,t.title)));var n}))))),e.createElement(ga,{className:"border-t border-sidebar-border"},e.createElement(ka,null,e.createElement(xa,null,e.createElement(Vc,null,e.createElement(qc,{asChild:!0},e.createElement(Ca,{tooltip:a("settings.language")},e.createElement(ij,{className:"w-4 h-4"}),e.createElement("span",null,"zh-CN"===c?"中文":"English"))),e.createElement(Gc,{align:"end",className:"w-48"},e.createElement(Yc,{onClick:function(){return u("zh-CN")},className:"zh-CN"===c?"bg-accent":""},"简体中文"),e.createElement(Yc,{onClick:function(){return u("en-US")},className:"en-US"===c?"bg-accent":""},"English")))),!i&&k&&e.createElement(e.Fragment,null,e.createElement(xa,null,e.createElement(Ca,{tooltip:k.username||"User"},e.createElement(nj,{className:"w-4 h-4"}),e.createElement("span",{className:"truncate"},k.username))),e.createElement(xa,null,e.createElement(Ca,{onClick:function(){window.confirm(a("auth.logoutConfirm"))&&(rd(),localStorage.removeItem("cms_token"),localStorage.removeItem("cms_user"),y(!1),x(null),d("/login"),xu.success(a("auth.logoutSuccess")))},tooltip:a("auth.logout")},e.createElement(rj,{className:"w-4 h-4"}),e.createElement("span",null,a("auth.logout")))))))),e.createElement(pa,null,e.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"},e.createElement(da,null),e.createElement("h1",{className:"text-xl font-bold text-foreground"},function(){if("/login"===f)return a("auth.login");var e=N(A,f);return(null==e?void 0:e.name)||a("data.dataManagement")}())),e.createElement("main",{className:"flex-1 min-w-0 p-8 bg-gradient-to-br from-background via-background to-muted/20"},function(){if(!i&&"/login"===f)return e.createElement(vd,{onLoginSuccess:M});if(i&&"/login"===f)return e.createElement(Y_,null);var t=N(A,f);if(t){var n=t.component;return e.createElement(n,null)}return e.createElement(Y_,null)}()))))}function sj(t){var n=t.defaultLocale,r=H(t,["defaultLocale"]);return e.createElement(dd,{defaultLocale:n},e.createElement(oj,Object.assign({},r)))}exports.CmsLayoutShadcn=sj,exports.I18nProvider=dd,exports.cmsRoutes=ej,exports.default=sj,exports.setSessionId=function(e){Uf=e;try{localStorage.setItem("cms_session_id",e)}catch(e){}},exports.useLocale=gd,exports.useT=md,exports.useTranslation=pd;
17
11
  //# sourceMappingURL=index.js.map