@apollo-annotation/jbrowse-plugin-apollo 1.1.0 → 1.1.2
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/FeatureDetailsWidget/Translation.d.ts.map +1 -1
- package/dist/components/CreateApolloAnnotation.d.ts.map +1 -1
- package/dist/index.esm.js +11 -3
- package/dist/index.esm.js.map +1 -1
- package/dist/jbrowse-plugin-apollo.cjs.development.js +11 -3
- package/dist/jbrowse-plugin-apollo.cjs.development.js.map +1 -1
- package/dist/jbrowse-plugin-apollo.cjs.production.min.js +1 -1
- package/dist/jbrowse-plugin-apollo.cjs.production.min.js.map +1 -1
- package/dist/jbrowse-plugin-apollo.umd.development.js +16 -3
- package/dist/jbrowse-plugin-apollo.umd.development.js.map +1 -1
- package/dist/jbrowse-plugin-apollo.umd.production.min.js +1 -1
- package/dist/jbrowse-plugin-apollo.umd.production.min.js.map +1 -1
- package/package.json +4 -4
- package/src/FeatureDetailsWidget/Translation.tsx +9 -1
- package/src/components/CreateApolloAnnotation.tsx +4 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@jbrowse/core/Plugin"),require("@jbrowse/core/configuration"),require("@jbrowse/core/pluggableElementTypes"),require("@jbrowse/core/util"),require("react/jsx-runtime"),require("@mui/material/utils"),require("@mui/material"),require("@jbrowse/mobx-state-tree"),require("mobx"),require("react"),require("@jbrowse/core/util/types/mst"),require("@jbrowse/core/util/io"),require("@jbrowse/core/ui"),require("mobx-react"),require("@mui/material/styles"),require("@mui/x-data-grid"),require("@jbrowse/core/pluggableElementTypes/AdapterType"),require("@jbrowse/core/data_adapters/BaseAdapter"),require("@jbrowse/core/util/rxjs"),require("@jbrowse/core/util/tracks")):"function"==typeof define&&define.amd?define(["exports","@jbrowse/core/Plugin","@jbrowse/core/configuration","@jbrowse/core/pluggableElementTypes","@jbrowse/core/util","react/jsx-runtime","@mui/material/utils","@mui/material","@jbrowse/mobx-state-tree","mobx","react","@jbrowse/core/util/types/mst","@jbrowse/core/util/io","@jbrowse/core/ui","mobx-react","@mui/material/styles","@mui/x-data-grid","@jbrowse/core/pluggableElementTypes/AdapterType","@jbrowse/core/data_adapters/BaseAdapter","@jbrowse/core/util/rxjs","@jbrowse/core/util/tracks"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).JBrowsePluginApollo={},e.JBrowseExports["@jbrowse/core/Plugin"],e.JBrowseExports["@jbrowse/core/configuration"],e.JBrowseExports["@jbrowse/core/pluggableElementTypes"],e.JBrowseExports["@jbrowse/core/util"],e.JBrowseExports["react/jsx-runtime"],e.JBrowseExports["@mui/material/utils"],e.JBrowseExports["@mui/material"],e.JBrowseExports["@jbrowse/mobx-state-tree"],e.JBrowseExports.mobx,e.JBrowseExports.react,e.JBrowseExports["@jbrowse/core/util/types/mst"],e.JBrowseExports["@jbrowse/core/util/io"],e.JBrowseExports["@jbrowse/core/ui"],e.JBrowseExports["mobx-react"],e.JBrowseExports["@mui/material/styles"],e.JBrowseExports["@mui/x-data-grid"],e.JBrowseExports["@jbrowse/core/pluggableElementTypes/AdapterType"],e.JBrowseExports["@jbrowse/core/data_adapters/BaseAdapter"],e.JBrowseExports["@jbrowse/core/util/rxjs"],e.JBrowseExports["@jbrowse/core/util/tracks"])}(this,(function(e,t,n,r,o,i,a,s,l,c,u,d,f,h,p,g,m,y,_,v,b){"use strict";function x(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,t}var w=x(u);function S(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 A(e,t,n,r,o,i,a){try{var s=e[i](a),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,o)}function k(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function a(e){A(i,r,o,a,s,"next",e)}function s(e){A(i,r,o,a,s,"throw",e)}a(void 0)}))}}function N(e){return new S(e,0)}function T(e,t,n){return t=F(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,L()?Reflect.construct(t,n||[],F(e).constructor):t.apply(e,n))}function R(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function E(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,J(r.key),r)}}function I(e,t,n){return t&&E(e.prototype,t),n&&E(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function j(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=Y(e))||t){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}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 i,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}function D(e,t,n){return(t=J(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function O(){return O="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=F(e)););return e}(e,t);if(r){var o=Object.getOwnPropertyDescriptor(r,t);return o.get?o.get.call(arguments.length<3?e:n):o.value}},O.apply(null,arguments)}function F(e){return F=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},F(e)}function M(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&&H(e,t)}function L(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(L=function(){return!!e})()}function P(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 B(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?P(Object(n),!0).forEach((function(t){D(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):P(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function q(e,t){if(null==e)return{};var n,r,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}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)-1===t.indexOf(n=i[r])&&{}.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function U(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function i(n,r,o,i){var l=Object.create((r&&r.prototype instanceof s?r:s).prototype);return z(l,"_invoke",function(n,r,o){var i,s,l,c=0,u=o||[],d=!1,f={p:0,n:0,v:e,a:h,f:h.bind(e,4),d:function(t,n){return i=t,s=0,l=e,f.n=n,a}};function h(n,r){for(s=n,l=r,t=0;!d&&c&&!o&&t<u.length;t++){var o,i=u[t],h=f.p,p=i[2];n>3?(o=p===r)&&(l=i[(s=i[4])?5:(s=3,3)],i[4]=i[5]=e):i[0]<=h&&((o=n<2&&h<i[1])?(s=0,f.v=r,f.n=i[1]):h<p&&(o=n<3||i[0]>r||r>p)&&(i[4]=n,i[5]=r,f.n=p,s=0))}if(o||n>1)return a;throw d=!0,r}return function(o,u,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===u&&h(u,p),s=u,l=p;(t=s<2?e:l)||!d;){i||(s?s<3?(s>1&&(f.n=-1),h(s,l)):f.n=l:f.v=l);try{if(c=2,i){if(s||(o="next"),t=i[o]){if(!(t=t.call(i,l)))throw TypeError("iterator result is not an object");if(!t.done)return t;l=t.value,s<2&&(s=0)}else 1===s&&(t=i.return)&&t.call(i),s<2&&(l=TypeError("The iterator does not provide a '"+o+"' method"),s=1);i=e}else if((t=(d=f.n<0)?l:n.call(r,f))!==a)break}catch(t){i=e,s=1,l=t}finally{c=1}}return{value:t,done:d}}}(n,o,i),!0),l}var a={};function s(){}function l(){}function c(){}t=Object.getPrototypeOf;var u=[][r]?t(t([][r]())):(z(t={},r,(function(){return this})),t),d=c.prototype=s.prototype=Object.create(u);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,z(e,o,"GeneratorFunction")),e.prototype=Object.create(d),e}return l.prototype=c,z(d,"constructor",c),z(c,"constructor",l),l.displayName="GeneratorFunction",z(c,o,"GeneratorFunction"),z(d),z(d,o,"Generator"),z(d,r,(function(){return this})),z(d,"toString",(function(){return"[object Generator]"})),(U=function(){return{w:i,m:f}})()}function z(e,t,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}z=function(e,t,n,r){function i(t,n){z(e,t,(function(e){return this._invoke(t,n,e)}))}t?o?o(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(i("next",0),i("throw",1),i("return",2))},z(e,t,n,r)}function $(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 H(e,t){return H=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},H(e,t)}function G(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,o,i,a,s=[],l=!0,c=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=i.call(n)).done)&&(s.push(r.value),s.length!==t);l=!0);}catch(e){c=!0,o=e}finally{try{if(!l&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(e,t)||Y(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 V(e,t,n,r){var o=O(F(1&r?e.prototype:e),t,n);return 2&r&&"function"==typeof o?function(e){return o.apply(n,e)}:o}function W(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)||Y(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 J(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,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}function K(e){return K="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},K(e)}function Y(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 X(e){var t,n;function r(t,n){try{var i=e[t](n),a=i.value,s=a instanceof S;Promise.resolve(s?a.v:a).then((function(n){if(s){var l="return"===t?"return":"next";if(!a.k||n.done)return r(l,n);n=e[l](n).value}o(i.done?"return":"normal",n)}),(function(e){r("throw",e)}))}catch(e){o("throw",e)}}function o(e,o){switch(e){case"return":t.resolve({value:o,done:!0});break;case"throw":t.reject(o);break;default:t.resolve({value:o,done:!1})}(t=t.next)?r(t.key,t.arg):n=null}this._invoke=function(e,o){return new Promise((function(i,a){var s={key:e,arg:o,resolve:i,reject:a,next:null};n?n=n.next=s:(t=n=s,r(e,o))}))},"function"!=typeof e.return&&(this.return=void 0)}function Z(e){var t="function"==typeof Map?new Map:void 0;return Z=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return function(e,t,n){if(L())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,t);var o=new(e.bind.apply(e,r));return n&&H(o,n.prototype),o}(e,arguments,F(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),H(n,e)},Z(e)}X.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},X.prototype.next=function(e){return this._invoke("next",e)},X.prototype.throw=function(e){return this._invoke("throw",e)},X.prototype.return=function(e){return this._invoke("return",e)};var Q=new(function(){return I((function e(){R(this,e),D(this,"changes",new Map)}),[{key:"registerChange",value:function(e,t){if(this.changes.has(e))throw new Error('change type "'.concat(e,'" has already been registered'));this.changes.set(e,t)}},{key:"getChangeType",value:function(e){var t=this.changes.get(e);if(!t)throw new Error('No change constructor registered for "'.concat(e,'"'));return t}}])}()),ee=function(){return I((function e(t,n){var r;R(this,e),D(this,"logger",void 0),this.logger=null!==(r=null==n?void 0:n.logger)&&void 0!==r?r:console}),[{key:"notification",get:function(){return""}}],[{key:"fromJSON",value:function(e,t){return new(Q.getChangeType(e.typeName))(e,(null==t?void 0:t.logger)&&{logger:t.logger})}}])}();function te(e){return function(e){return void 0!==e.getInverse}(e)&&void 0!==e.assembly}var ne=new(function(){return I((function e(){R(this,e),D(this,"checks",new Map)}),[{key:"registerCheck",value:function(e,t){if(this.checks.has(e))throw new Error('check "'.concat(e,'" has already been registered'));this.checks.set(e,t)}},{key:"getCheck",value:function(e){var t=this.checks.get(e);if(!t)throw new Error('No check constructor registered for "'.concat(e,'"'));return t}},{key:"getChecks",value:function(){return this.checks}}])}()),re="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function oe(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ie="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},ae={env:{}},se=[],le=[],ce="undefined"!=typeof Uint8Array?Uint8Array:Array,ue=!1;function de(){ue=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)se[t]=e[t],le[e.charCodeAt(t)]=t;le["-".charCodeAt(0)]=62,le["_".charCodeAt(0)]=63}function fe(e,t,n){for(var r,o=[],i=t;i<n;i+=3)o.push(se[(r=(e[i]<<16)+(e[i+1]<<8)+e[i+2])>>18&63]+se[r>>12&63]+se[r>>6&63]+se[63&r]);return o.join("")}function he(e,t,n,r,o){var i,a,s=8*o-r-1,l=(1<<s)-1,c=l>>1,u=-7,d=n?o-1:0,f=n?-1:1,h=e[t+d];for(d+=f,i=h&(1<<-u)-1,h>>=-u,u+=s;u>0;i=256*i+e[t+d],d+=f,u-=8);for(a=i&(1<<-u)-1,i>>=-u,u+=r;u>0;a=256*a+e[t+d],d+=f,u-=8);if(0===i)i=1-c;else{if(i===l)return a?NaN:Infinity*(h?-1:1);a+=Math.pow(2,r),i-=c}return(h?-1:1)*a*Math.pow(2,i-r)}function pe(e,t,n,r,o,i){var a,s,l,c=8*i-o-1,u=(1<<c)-1,d=u>>1,f=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,h=r?0:i-1,p=r?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||Infinity===t?(s=isNaN(t)?1:0,a=u):(a=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-a))<1&&(a--,l*=2),(t+=a+d>=1?f/l:f*Math.pow(2,1-d))*l>=2&&(a++,l/=2),a+d>=u?(s=0,a=u):a+d>=1?(s=(t*l-1)*Math.pow(2,o),a+=d):(s=t*Math.pow(2,d-1)*Math.pow(2,o),a=0));o>=8;e[n+h]=255&s,h+=p,s/=256,o-=8);for(a=a<<o|s,c+=o;c>0;e[n+h]=255&a,h+=p,a/=256,c-=8);e[n+h-p]|=128*g}var ge={}.toString,me=Array.isArray||function(e){return"[object Array]"==ge.call(e)};function ye(){return ve.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function _e(e,t){if(ye()<t)throw new RangeError("Invalid typed array length");return ve.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=ve.prototype:(null===e&&(e=new ve(t)),e.length=t),e}function ve(e,t,n){if(!(ve.TYPED_ARRAY_SUPPORT||this instanceof ve))return new ve(e,t,n);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return we(this,e)}return be(this,e,t,n)}function be(e,t,n,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,n,r){if(n<0||t.byteLength<n)throw new RangeError("'offset' is out of bounds");if(t.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");return t=void 0===n&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,n):new Uint8Array(t,n,r),ve.TYPED_ARRAY_SUPPORT?(e=t).__proto__=ve.prototype:e=Se(e,t),e}(e,t,n,r):"string"==typeof t?function(e,t,n){if("string"==typeof n&&""!==n||(n="utf8"),!ve.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|ke(t,n),o=(e=_e(e,r)).write(t,n);return o!==r&&(e=e.slice(0,o)),e}(e,t,n):function(e,t){if(Ae(t)){var n=0|Ce(t.length);return 0===(e=_e(e,n)).length||t.copy(e,0,0,n),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(r=t.length)!=r?_e(e,0):Se(e,t);if("Buffer"===t.type&&me(t.data))return Se(e,t.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function xe(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function we(e,t){if(xe(t),e=_e(e,t<0?0:0|Ce(t)),!ve.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function Se(e,t){var n=t.length<0?0:0|Ce(t.length);e=_e(e,n);for(var r=0;r<n;r+=1)e[r]=255&t[r];return e}function Ce(e){if(e>=ye())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+ye().toString(16)+" bytes");return 0|e}function Ae(e){return!(null==e||!e._isBuffer)}function ke(e,t){if(Ae(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return tt(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return nt(e).length;default:if(r)return tt(e).length;t=(""+t).toLowerCase(),r=!0}}function Ne(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return ze(this,t,n);case"utf8":case"utf-8":return Pe(this,t,n);case"ascii":return qe(this,t,n);case"latin1":case"binary":return Ue(this,t,n);case"base64":return Le(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return $e(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function Te(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function Re(e,t,n,r,o){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=o?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(o)return-1;n=e.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof t&&(t=ve.from(t,r)),Ae(t))return 0===t.length?-1:Ee(e,t,n,r,o);if("number"==typeof t)return t&=255,ve.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):Ee(e,[t],n,r,o);throw new TypeError("val must be string, number or Buffer")}function Ee(e,t,n,r,o){var i,a=1,s=e.length,l=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;a=2,s/=2,l/=2,n/=2}function c(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(o){var u=-1;for(i=n;i<s;i++)if(c(e,i)===c(t,-1===u?0:i-u)){if(-1===u&&(u=i),i-u+1===l)return u*a}else-1!==u&&(i-=i-u),u=-1}else for(n+l>s&&(n=s-l),i=n;i>=0;i--){for(var d=!0,f=0;f<l;f++)if(c(e,i+f)!==c(t,f)){d=!1;break}if(d)return i}return-1}function Ie(e,t,n,r){n=Number(n)||0;var o=e.length-n;r?(r=Number(r))>o&&(r=o):r=o;var i=t.length;if(i%2!=0)throw new TypeError("Invalid hex string");r>i/2&&(r=i/2);for(var a=0;a<r;++a){var s=parseInt(t.substr(2*a,2),16);if(isNaN(s))return a;e[n+a]=s}return a}function je(e,t,n,r){return rt(tt(t,e.length-n),e,n,r)}function De(e,t,n,r){return rt(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function Oe(e,t,n,r){return De(e,t,n,r)}function Fe(e,t,n,r){return rt(nt(t),e,n,r)}function Me(e,t,n,r){return rt(function(e,t){for(var n,r,o=[],i=0;i<e.length&&!((t-=2)<0);++i)r=(n=e.charCodeAt(i))>>8,o.push(n%256),o.push(r);return o}(t,e.length-n),e,n,r)}function Le(e,t,n){return function(e){var t;ue||de();for(var n=e.length,r=n%3,o="",i=[],a=16383,s=0,l=n-r;s<l;s+=a)i.push(fe(e,s,s+a>l?l:s+a));return 1===r?(o+=se[(t=e[n-1])>>2],o+=se[t<<4&63],o+="=="):2===r&&(o+=se[(t=(e[n-2]<<8)+e[n-1])>>10],o+=se[t>>4&63],o+=se[t<<2&63],o+="="),i.push(o),i.join("")}(0===t&&n===e.length?e:e.slice(t,n))}function Pe(e,t,n){n=Math.min(e.length,n);for(var r=[],o=t;o<n;){var i,a,s,l,c=e[o],u=null,d=c>239?4:c>223?3:c>191?2:1;if(o+d<=n)switch(d){case 1:c<128&&(u=c);break;case 2:128==(192&(i=e[o+1]))&&(l=(31&c)<<6|63&i)>127&&(u=l);break;case 3:a=e[o+2],128==(192&(i=e[o+1]))&&128==(192&a)&&(l=(15&c)<<12|(63&i)<<6|63&a)>2047&&(l<55296||l>57343)&&(u=l);break;case 4:a=e[o+2],s=e[o+3],128==(192&(i=e[o+1]))&&128==(192&a)&&128==(192&s)&&(l=(15&c)<<18|(63&i)<<12|(63&a)<<6|63&s)>65535&&l<1114112&&(u=l)}null===u?(u=65533,d=1):u>65535&&(r.push((u-=65536)>>>10&1023|55296),u=56320|1023&u),r.push(u),o+=d}return function(e){var t=e.length;if(t<=Be)return String.fromCharCode.apply(String,e);for(var n="",r=0;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=Be));return n}(r)}ve.TYPED_ARRAY_SUPPORT=void 0===ie.TYPED_ARRAY_SUPPORT||ie.TYPED_ARRAY_SUPPORT,ve.poolSize=8192,ve._augment=function(e){return e.__proto__=ve.prototype,e},ve.from=function(e,t,n){return be(null,e,t,n)},ve.TYPED_ARRAY_SUPPORT&&(ve.prototype.__proto__=Uint8Array.prototype,ve.__proto__=Uint8Array),ve.alloc=function(e,t,n){return function(e,t,n,r){return xe(t),t<=0?_e(e,t):void 0!==n?"string"==typeof r?_e(e,t).fill(n,r):_e(e,t).fill(n):_e(e,t)}(null,e,t,n)},ve.allocUnsafe=function(e){return we(null,e)},ve.allocUnsafeSlow=function(e){return we(null,e)},ve.isBuffer=function(e){return null!=e&&(!!e._isBuffer||ot(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&ot(e.slice(0,0))}(e))},ve.compare=function(e,t){if(!Ae(e)||!Ae(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,o=0,i=Math.min(n,r);o<i;++o)if(e[o]!==t[o]){n=e[o],r=t[o];break}return n<r?-1:r<n?1:0},ve.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},ve.concat=function(e,t){if(!me(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return ve.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=ve.allocUnsafe(t),o=0;for(n=0;n<e.length;++n){var i=e[n];if(!Ae(i))throw new TypeError('"list" argument must be an Array of Buffers');i.copy(r,o),o+=i.length}return r},ve.byteLength=ke,ve.prototype._isBuffer=!0,ve.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)Te(this,t,t+1);return this},ve.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)Te(this,t,t+3),Te(this,t+1,t+2);return this},ve.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)Te(this,t,t+7),Te(this,t+1,t+6),Te(this,t+2,t+5),Te(this,t+3,t+4);return this},ve.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?Pe(this,0,e):Ne.apply(this,arguments)},ve.prototype.equals=function(e){if(!Ae(e))throw new TypeError("Argument must be a Buffer");return this===e||0===ve.compare(this,e)},ve.prototype.inspect=function(){var e="";return this.length>0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),"<Buffer "+e+">"},ve.prototype.compare=function(e,t,n,r,o){if(!Ae(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),t<0||n>e.length||r<0||o>this.length)throw new RangeError("out of range index");if(r>=o&&t>=n)return 0;if(r>=o)return-1;if(t>=n)return 1;if(this===e)return 0;for(var i=(o>>>=0)-(r>>>=0),a=(n>>>=0)-(t>>>=0),s=Math.min(i,a),l=this.slice(r,o),c=e.slice(t,n),u=0;u<s;++u)if(l[u]!==c[u]){i=l[u],a=c[u];break}return i<a?-1:a<i?1:0},ve.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},ve.prototype.indexOf=function(e,t,n){return Re(this,e,t,n,!0)},ve.prototype.lastIndexOf=function(e,t,n){return Re(this,e,t,n,!1)},ve.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var o=this.length-t;if((void 0===n||n>o)&&(n=o),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var i=!1;;)switch(r){case"hex":return Ie(this,e,t,n);case"utf8":case"utf-8":return je(this,e,t,n);case"ascii":return De(this,e,t,n);case"latin1":case"binary":return Oe(this,e,t,n);case"base64":return Fe(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Me(this,e,t,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0}},ve.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Be=4096;function qe(e,t,n){var r="";n=Math.min(e.length,n);for(var o=t;o<n;++o)r+=String.fromCharCode(127&e[o]);return r}function Ue(e,t,n){var r="";n=Math.min(e.length,n);for(var o=t;o<n;++o)r+=String.fromCharCode(e[o]);return r}function ze(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var o="",i=t;i<n;++i)o+=et(e[i]);return o}function $e(e,t,n){for(var r=e.slice(t,n),o="",i=0;i<r.length;i+=2)o+=String.fromCharCode(r[i]+256*r[i+1]);return o}function He(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function Ge(e,t,n,r,o,i){if(!Ae(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||t<i)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError("Index out of range")}function Ve(e,t,n,r){t<0&&(t=65535+t+1);for(var o=0,i=Math.min(e.length-n,2);o<i;++o)e[n+o]=(t&255<<8*(r?o:1-o))>>>8*(r?o:1-o)}function We(e,t,n,r){t<0&&(t=4294967295+t+1);for(var o=0,i=Math.min(e.length-n,4);o<i;++o)e[n+o]=t>>>8*(r?o:3-o)&255}function Je(e,t,n,r,o,i){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function Ke(e,t,n,r,o){return o||Je(e,0,n,4),pe(e,t,n,r,23,4),n+4}function Ye(e,t,n,r,o){return o||Je(e,0,n,8),pe(e,t,n,r,52,8),n+8}ve.prototype.slice=function(e,t){var n,r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e),ve.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=ve.prototype;else{var o=t-e;n=new ve(o,void 0);for(var i=0;i<o;++i)n[i]=this[i+e]}return n},ve.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||He(e,t,this.length);for(var r=this[e],o=1,i=0;++i<t&&(o*=256);)r+=this[e+i]*o;return r},ve.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||He(e,t,this.length);for(var r=this[e+--t],o=1;t>0&&(o*=256);)r+=this[e+--t]*o;return r},ve.prototype.readUInt8=function(e,t){return t||He(e,1,this.length),this[e]},ve.prototype.readUInt16LE=function(e,t){return t||He(e,2,this.length),this[e]|this[e+1]<<8},ve.prototype.readUInt16BE=function(e,t){return t||He(e,2,this.length),this[e]<<8|this[e+1]},ve.prototype.readUInt32LE=function(e,t){return t||He(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},ve.prototype.readUInt32BE=function(e,t){return t||He(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},ve.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||He(e,t,this.length);for(var r=this[e],o=1,i=0;++i<t&&(o*=256);)r+=this[e+i]*o;return r>=(o*=128)&&(r-=Math.pow(2,8*t)),r},ve.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||He(e,t,this.length);for(var r=t,o=1,i=this[e+--r];r>0&&(o*=256);)i+=this[e+--r]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*t)),i},ve.prototype.readInt8=function(e,t){return t||He(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},ve.prototype.readInt16LE=function(e,t){t||He(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},ve.prototype.readInt16BE=function(e,t){t||He(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},ve.prototype.readInt32LE=function(e,t){return t||He(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},ve.prototype.readInt32BE=function(e,t){return t||He(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},ve.prototype.readFloatLE=function(e,t){return t||He(e,4,this.length),he(this,e,!0,23,4)},ve.prototype.readFloatBE=function(e,t){return t||He(e,4,this.length),he(this,e,!1,23,4)},ve.prototype.readDoubleLE=function(e,t){return t||He(e,8,this.length),he(this,e,!0,52,8)},ve.prototype.readDoubleBE=function(e,t){return t||He(e,8,this.length),he(this,e,!1,52,8)},ve.prototype.writeUIntLE=function(e,t,n,r){e=+e,t|=0,n|=0,r||Ge(this,e,t,n,Math.pow(2,8*n)-1,0);var o=1,i=0;for(this[t]=255&e;++i<n&&(o*=256);)this[t+i]=e/o&255;return t+n},ve.prototype.writeUIntBE=function(e,t,n,r){e=+e,t|=0,n|=0,r||Ge(this,e,t,n,Math.pow(2,8*n)-1,0);var o=n-1,i=1;for(this[t+o]=255&e;--o>=0&&(i*=256);)this[t+o]=e/i&255;return t+n},ve.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||Ge(this,e,t,1,255,0),ve.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},ve.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||Ge(this,e,t,2,65535,0),ve.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Ve(this,e,t,!0),t+2},ve.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||Ge(this,e,t,2,65535,0),ve.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Ve(this,e,t,!1),t+2},ve.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||Ge(this,e,t,4,4294967295,0),ve.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):We(this,e,t,!0),t+4},ve.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||Ge(this,e,t,4,4294967295,0),ve.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):We(this,e,t,!1),t+4},ve.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var o=Math.pow(2,8*n-1);Ge(this,e,t,n,o-1,-o)}var i=0,a=1,s=0;for(this[t]=255&e;++i<n&&(a*=256);)e<0&&0===s&&0!==this[t+i-1]&&(s=1),this[t+i]=(e/a>>0)-s&255;return t+n},ve.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var o=Math.pow(2,8*n-1);Ge(this,e,t,n,o-1,-o)}var i=n-1,a=1,s=0;for(this[t+i]=255&e;--i>=0&&(a*=256);)e<0&&0===s&&0!==this[t+i+1]&&(s=1),this[t+i]=(e/a>>0)-s&255;return t+n},ve.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||Ge(this,e,t,1,127,-128),ve.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},ve.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||Ge(this,e,t,2,32767,-32768),ve.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Ve(this,e,t,!0),t+2},ve.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||Ge(this,e,t,2,32767,-32768),ve.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Ve(this,e,t,!1),t+2},ve.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||Ge(this,e,t,4,2147483647,-2147483648),ve.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):We(this,e,t,!0),t+4},ve.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||Ge(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),ve.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):We(this,e,t,!1),t+4},ve.prototype.writeFloatLE=function(e,t,n){return Ke(this,e,t,!0,n)},ve.prototype.writeFloatBE=function(e,t,n){return Ke(this,e,t,!1,n)},ve.prototype.writeDoubleLE=function(e,t,n){return Ye(this,e,t,!0,n)},ve.prototype.writeDoubleBE=function(e,t,n){return Ye(this,e,t,!1,n)},ve.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var o,i=r-n;if(this===e&&n<t&&t<r)for(o=i-1;o>=0;--o)e[o+t]=this[o+n];else if(i<1e3||!ve.TYPED_ARRAY_SUPPORT)for(o=0;o<i;++o)e[o+t]=this[o+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+i),t);return i},ve.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===e.length){var o=e.charCodeAt(0);o<256&&(e=o)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!ve.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;var i;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(i=t;i<n;++i)this[i]=e;else{var a=Ae(e)?e:tt(new ve(e,r).toString()),s=a.length;for(i=0;i<n-t;++i)this[i+t]=a[i%s]}return this};var Xe,Ze,Qe=/[^+\/0-9A-Za-z-_]/g;function et(e){return e<16?"0"+e.toString(16):e.toString(16)}function tt(e,t){var n;t=t||Infinity;for(var r=e.length,o=null,i=[],a=0;a<r;++a){if((n=e.charCodeAt(a))>55295&&n<57344){if(!o){if(n>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(a+1===r){(t-=3)>-1&&i.push(239,191,189);continue}o=n;continue}if(n<56320){(t-=3)>-1&&i.push(239,191,189),o=n;continue}n=65536+(o-55296<<10|n-56320)}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,n<128){if((t-=1)<0)break;i.push(n)}else if(n<2048){if((t-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function nt(e){return function(e){var t,n,r,o,i,a;ue||de();var s=e.length;if(s%4>0)throw new Error("Invalid string. Length must be a multiple of 4");a=new ce(3*s/4-(i="="===e[s-2]?2:"="===e[s-1]?1:0)),r=i>0?s-4:s;var l=0;for(t=0,n=0;t<r;t+=4,n+=3)o=le[e.charCodeAt(t)]<<18|le[e.charCodeAt(t+1)]<<12|le[e.charCodeAt(t+2)]<<6|le[e.charCodeAt(t+3)],a[l++]=o>>16&255,a[l++]=o>>8&255,a[l++]=255&o;return 2===i?(o=le[e.charCodeAt(t)]<<2|le[e.charCodeAt(t+1)]>>4,a[l++]=255&o):1===i&&(o=le[e.charCodeAt(t)]<<10|le[e.charCodeAt(t+1)]<<4|le[e.charCodeAt(t+2)]>>2,a[l++]=o>>8&255,a[l++]=255&o),a}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Qe,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function rt(e,t,n,r){for(var o=0;o<r&&!(o+n>=t.length||o>=e.length);++o)t[o+n]=e[o];return o}function ot(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}var it=function(){if(Ze)return Xe;Ze=1;for(var e=Math.floor(16777215*Math.random()),t=c.index=parseInt(16777215*Math.random(),10),n=(void 0===ae||"number"!=typeof ae.pid?Math.floor(1e5*Math.random()):ae.pid)%65535,r=function(){try{return _Buffer}catch(e){try{return ve}catch(e){return null}}}(),o=function(e){return!(null==e||!e.constructor||"function"!=typeof e.constructor.isBuffer||!e.constructor.isBuffer(e))},i=[],a=0;a<256;a++)i[a]=(a<=15?"0":"")+a.toString(16);var s=new RegExp("^[0-9a-fA-F]{24}$"),l=[];for(a=0;a<10;)l[48+a]=a++;for(;a<16;)l[55+a]=l[87+a]=a++;function c(e){if(!(this instanceof c))return new c(e);if(e&&(e instanceof c||"ObjectID"===e._bsontype))return e;if(this._bsontype="ObjectID",null!=e&&"number"!=typeof e){var t=c.isValid(e);if(!t&&null!=e)throw new Error("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters");if(t&&"string"==typeof e&&24===e.length)return c.createFromHexString(e);if(null==e||12!==e.length){if(null!=e&&"function"==typeof e.toHexString)return e;throw new Error("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters")}this.id=e}else this.id=this.generate(e)}Xe=c,c.default=c,c.createFromTime=function(e){return new c(function(e,t){return 8===(t=t.toString(16)).length?t:"00000000".substring(t.length,8)+t}(0,e=parseInt(e,10)%4294967295)+"0000000000000000")},c.createFromHexString=function(e){if(void 0===e||null!=e&&24!==e.length)throw new Error("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters");for(var t="",n=0;n<24;)t+=String.fromCharCode(l[e.charCodeAt(n++)]<<4|l[e.charCodeAt(n++)]);return new c(t)},c.isValid=function(e){return null!=e&&("number"==typeof e||("string"==typeof e?12===e.length||24===e.length&&s.test(e):e instanceof c||(o(e)?c.isValid(e.toString("hex")):!("function"!=typeof e.toHexString||!r||!(e.id instanceof r||"string"==typeof e.id))&&(12===e.id.length||24===e.id.length&&s.test(e.id)))))},c.prototype={constructor:c,toHexString:function(){if(!this.id||!this.id.length)throw new Error("invalid ObjectId, ObjectId.id must be either a string or a Buffer, but is ["+JSON.stringify(this.id)+"]");if(24===this.id.length)return this.id;if(o(this.id))return this.id.toString("hex");for(var e="",t=0;t<this.id.length;t++)e+=i[this.id.charCodeAt(t)];return e},equals:function(e){return e instanceof c?this.toString()===e.toString():"string"==typeof e&&c.isValid(e)&&12===e.length&&o(this.id)?e===this.id.toString("binary"):"string"==typeof e&&c.isValid(e)&&24===e.length?e.toLowerCase()===this.toHexString():"string"==typeof e&&c.isValid(e)&&12===e.length?e===this.id:!(null==e||!(e instanceof c||e.toHexString))&&e.toHexString()===this.toHexString()},getTimestamp:function(){var e,t=new Date;return e=o(this.id)?this.id[3]|this.id[2]<<8|this.id[1]<<16|this.id[0]<<24:this.id.charCodeAt(3)|this.id.charCodeAt(2)<<8|this.id.charCodeAt(1)<<16|this.id.charCodeAt(0)<<24,t.setTime(1e3*Math.floor(e)),t},generate:function(r){"number"!=typeof r&&(r=~~(Date.now()/1e3)),r=parseInt(r,10)%4294967295;var o=t=(t+1)%16777215;return String.fromCharCode(r>>24&255,r>>16&255,r>>8&255,255&r,e>>16&255,e>>8&255,255&e,n>>8&255,255&n,o>>16&255,o>>8&255,255&o)}};var u=Symbol&&Symbol.for&&Symbol.for("nodejs.util.inspect.custom")||"inspect";return c.prototype[u]=function(){return"ObjectID("+this+")"},c.prototype.toJSON=c.prototype.toHexString,c.prototype.toString=c.prototype.toHexString,Xe}(),at=oe(it);function st(e){return te(e)&&void 0!==e.changedIds}var lt=new(function(){return I((function e(){R(this,e),D(this,"changes",new Map)}),[{key:"registerChange",value:function(e,t){if(this.changes.has(e))throw new Error('change type "'.concat(e,'" has already been registered'));this.changes.set(e,t)}},{key:"getChangeType",value:function(e){var t=this.changes.get(e);if(!t)throw new Error('No change constructor registered for "'.concat(e,'"'));return t}}])}()),ct=function(){return I((function e(t,n){var r;R(this,e),D(this,"logger",void 0),this.logger=null!==(r=null==n?void 0:n.logger)&&void 0!==r?r:console}),[{key:"notification",get:function(){return""}}],[{key:"fromJSON",value:function(e,t){return new(lt.getChangeType(e.typeName))(e,(null==t?void 0:t.logger)&&{logger:t.logger})}}])}(),ut=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"assembly",void 0),r.assembly=e.assembly,r}return M(t,e),I(t,[{key:"getIndexedIds",value:function(e,t){var n,r=[],o=j(null!=t?t:[]);try{for(o.s();!(n=o.n()).done;){var i=n.value,a=e.attributes,s=a instanceof Map?a.get(i):null==a?void 0:a[i];null!=s&&s[0]&&r.push(s[0])}}catch(e){o.e(e)}finally{o.f()}if(e.children){var l,c=j(e.children instanceof Map?e.children.values():Object.values(e.children));try{for(c.s();!(l=c.n()).done;){var u=this.getIndexedIds(l.value,t);r.push.apply(r,W(u))}}catch(e){c.e(e)}finally{c.f()}}return r}}])}(ct),dt=I((function e(){R(this,e)})),ft=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"changedIds",void 0),r.changedIds=e.changedIds,r}return M(t,e),I(t,[{key:"getFeatureFromId",value:function(e,t){var n,r,o,i,a=this.logger;if(null===(n=a.verbose)||void 0===n||n.call(a,"Entry=".concat(JSON.stringify(e))),e._id.equals(t))return null===(i=a.debug)||void 0===i||i.call(a,"Top level featureId matches in the object ".concat(JSON.stringify(e))),e;null===(r=a.debug)||void 0===r||r.call(a,"FeatureId was not found on top level so lets make recursive call...");var s,l=j(null!==(o=e.children)&&void 0!==o?o:new Map);try{for(l.s();!(s=l.n()).done;){var c=G(s.value,2),u=this.getFeatureFromId(c[1],t);if(u)return u}}catch(e){l.e(e)}finally{l.f()}return null}},{key:"getChildFeatureIds",value:function(e){if(!e.children)return[];var t,n=[],r=j((e.children instanceof Map?e.children:new Map(Object.entries(e.children)))||new Map);try{for(r.s();!(t=r.n()).done;){var o=G(t.value,2);n.push.apply(n,[o[0]].concat(W(this.getChildFeatureIds(o[1]))))}}catch(e){r.e(e)}finally{r.f()}return n}},{key:"generateNewIds",value:function(e,t){var n=(new at).toHexString();t.push(n);var r={};if(e.children)for(var o=0,i=Object.values(e.children);o<i.length;o++){var a=this.generateNewIds(i[o],t);r[a._id]=a}var s="string"==typeof e.refSeq?e.refSeq:e.refSeq.toHexString();return B(B({},e),{},{refSeq:s,children:e.children&&r,_id:n})}},{key:"addChild",value:function(e,t){var n,r;if(null===(n=e.attributes)||void 0===n||!n._id){var o=e.attributes,i=void 0===o?{}:o;i=B({_id:[e._id.toString()]},JSON.parse(JSON.stringify(i))),e.attributes=i}var a=t._id;null!==(r=e.children)&&void 0!==r||(e.children=new Map),e.children.set(a,B(B({allIds:[]},t),{},{_id:a})),e.children=new Map(W(e.children.entries()).sort((function(e,t){return e[1].min-t[1].min})))}},{key:"findAndDeleteChildFeature",value:function(e,t){if(!e.children)throw new Error("Feature ".concat(e._id.toHexString()," has no children"));var n=e._id,r=e.children,o=r.get(t);if(o){var i=this.getChildFeatureIds(o);return r.delete(t),i}var a,s=j(r);try{for(s.s();!(a=s.n()).done;){var l=G(a.value,2)[1];try{return this.findAndDeleteChildFeature(l,t)}catch(e){}}}catch(e){s.e(e)}finally{s.f()}throw new Error('Feature "'.concat(t,'" not found in ').concat(n.toHexString()))}}])}(ut),ht=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","AddFeatureChange"),D(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return M(t,e),I(t,[{key:"notification",get:function(){return"Feature added successfully"}},{key:"toJSON",value:function(){var e=this.assembly,t=this.changedIds,n=this.changes,r=this.typeName;if(1===n.length){var o=G(n,1)[0];return{typeName:r,changedIds:t,assembly:e,addedFeature:o.addedFeature,parentFeatureId:o.parentFeatureId,copyFeature:o.copyFeature,allIds:o.allIds}}return{typeName:r,changedIds:t,assembly:e,changes:n}}},{key:"getInverse",value:function(){var e=this.assembly,t=this.changes,n=this.logger,r=W(this.changedIds).reverse(),o=W(t).reverse().map((function(e){return{deletedFeature:e.addedFeature,parentFeatureId:e.parentFeatureId}}));return new pt({changedIds:r,typeName:"DeleteFeatureChange",changes:o,assembly:e},{logger:n})}}])}(ft),pt=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","DeleteFeatureChange"),D(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return M(t,e),I(t,[{key:"notification",get:function(){return"Feature deleted successfully"}},{key:"toJSON",value:function(){var e=this.assembly,t=this.changedIds,n=this.changes,r=this.typeName;if(1===n.length){var o=G(n,1)[0];return{typeName:r,changedIds:t,assembly:e,deletedFeature:o.deletedFeature,parentFeatureId:o.parentFeatureId}}return{typeName:r,changedIds:t,assembly:e,changes:n}}},{key:"getInverse",value:function(){var e,t=this.assembly,n=this.changes,r=this.logger,o=W(this.changedIds).reverse(),i=W(n).reverse().map((function(e){return{addedFeature:e.deletedFeature,parentFeatureId:e.parentFeatureId}}));return null===(e=r.debug)||void 0===e||e.call(r,"INVERSE CHANGE '".concat(JSON.stringify(i),"'")),new ht({changedIds:o,typeName:"AddFeatureChange",changes:i,assembly:t},{logger:r})}}])}(ft),gt=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","AddAssemblyAliasesChange"),D(r,"aliases",void 0),r.aliases=e.aliases,r}return M(t,e),I(t,[{key:"getInverse",value:function(){throw new Error("Method not implemented.")}},{key:"toJSON",value:function(){return{assembly:this.assembly,typeName:this.typeName,aliases:this.aliases}}},{key:"notification",get:function(){return"Assembly aliases have been added."}}])}(ut),mt=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","AddAssemblyAndFeaturesFromFileChange"),D(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return M(t,e),I(t,[{key:"notification",get:function(){return'Assembly "'.concat(this.changes[0].assemblyName,'" added successfully. To use it, please refresh the page.')}},{key:"toJSON",value:function(){var e=this.assembly,t=this.changes,n=this.typeName;if(1===t.length){var r=G(t,1)[0];return{typeName:n,assembly:e,assemblyName:r.assemblyName,fileIds:r.fileIds}}return{typeName:n,assembly:e,changes:t}}},{key:"getInverse",value:function(){return new t({typeName:this.typeName,changes:this.changes,assembly:this.assembly},{logger:this.logger})}}])}(ut),yt=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","AddAssemblyFromExternalChange"),D(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return M(t,e),I(t,[{key:"notification",get:function(){return'Assembly "'.concat(this.changes[0].assemblyName,'" added successfully. To use it, please refresh the page.')}},{key:"toJSON",value:function(){var e=this.assembly,t=this.changes,n=this.typeName;if(1===t.length){var r=G(t,1)[0];return{typeName:n,assembly:e,assemblyName:r.assemblyName,externalLocation:r.externalLocation}}return{typeName:n,assembly:e,changes:t}}},{key:"getInverse",value:function(){return new t({typeName:this.typeName,changes:this.changes,assembly:this.assembly},{logger:this.logger})}}])}(ut),_t=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","AddAssemblyFromFileChange"),D(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return M(t,e),I(t,[{key:"notification",get:function(){return'Assembly "'.concat(this.changes[0].assemblyName,'" added successfully. To use it, please refresh the page.')}},{key:"toJSON",value:function(){var e=this.assembly,t=this.changes,n=this.typeName;if(1===t.length){var r=G(t,1)[0];return{typeName:n,assembly:e,assemblyName:r.assemblyName,fileIds:r.fileIds}}return{typeName:n,assembly:e,changes:t}}},{key:"getInverse",value:function(){return new t({typeName:this.typeName,changes:this.changes,assembly:this.assembly},{logger:this.logger})}}])}(ut),vt=function(e){function t(e,n){var r,o;return R(this,t),D(o=T(this,t,[e,n]),"typeName","AddFeaturesFromFileChange"),D(o,"changes",void 0),D(o,"deleteExistingFeatures",!1),o.deleteExistingFeatures=null!==(r=e.deleteExistingFeatures)&&void 0!==r&&r,o.changes="changes"in e?e.changes:[e],o}return M(t,e),I(t,[{key:"notification",get:function(){return"Features have been added. To see them, please refresh the page."}},{key:"toJSON",value:function(){var e=this.assembly,t=this.changes,n=this.deleteExistingFeatures,r=this.typeName;return 1===t.length?{typeName:r,assembly:e,fileId:G(t,1)[0].fileId,deleteExistingFeatures:n}:{typeName:r,assembly:e,changes:t,deleteExistingFeatures:n}}},{key:"getInverse",value:function(){return new t({typeName:this.typeName,changes:this.changes,assembly:this.assembly},{logger:this.logger})}}])}(ut),bt=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","AddRefSeqAliasesChange"),D(r,"refSeqAliases",void 0),r.refSeqAliases=e.refSeqAliases,r}return M(t,e),I(t,[{key:"getInverse",value:function(){throw new Error("Method not implemented.")}},{key:"toJSON",value:function(){return{assembly:this.assembly,typeName:this.typeName,refSeqAliases:this.refSeqAliases}}},{key:"notification",get:function(){return"RefSeq aliases have been added."}}])}(ut),xt=function(e){function t(){var e;R(this,t);for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return D(e=T(this,t,[].concat(r)),"typeName","DeleteAssemblyChange"),e}return M(t,e),I(t,[{key:"notification",get:function(){return'Assembly "'.concat(this.assembly,'" deleted successfully.')}},{key:"toJSON",value:function(){return{typeName:this.typeName,assembly:this.assembly}}},{key:"getInverse",value:function(){return new t({typeName:"DeleteAssemblyChange",assembly:this.assembly},{logger:this.logger})}}])}(ut),wt=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","DeleteUserChange"),D(r,"changes",void 0),D(r,"userId",void 0),r.changes="changes"in e?e.changes:[e],r.userId=e.userId,r}return M(t,e),I(t,[{key:"toJSON",value:function(){return{typeName:this.typeName,userId:this.userId}}},{key:"getInverse",value:function(){return new t({typeName:this.typeName,userId:this.userId},{logger:this.logger})}}])}(ct),St=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","FeatureAttributeChange"),D(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return M(t,e),I(t,[{key:"toJSON",value:function(){var e=this.assembly,t=this.changedIds,n=this.changes,r=this.typeName;if(1===n.length){var o=G(n,1)[0];return{typeName:r,changedIds:t,assembly:e,featureId:o.featureId,oldAttributes:o.oldAttributes,newAttributes:o.newAttributes}}return{typeName:r,changedIds:t,assembly:e,changes:n}}},{key:"getInverse",value:function(){var e=this.assembly,n=this.changes,r=this.logger;return new t({changedIds:W(this.changedIds).reverse(),typeName:"FeatureAttributeChange",changes:W(n).reverse().map((function(e){return{featureId:e.featureId,oldAttributes:e.newAttributes,newAttributes:e.oldAttributes}})),assembly:e},{logger:r})}}])}(ft),Ct=["__v","_id","assemblies","configuration","internetAccounts","plugins","tracks"],At=["hasRole"];function kt(e){var t,n=e.assemblies,r=e.configuration,o=e.internetAccounts,i=e.plugins,a=e.tracks,s=q(e,Ct);if(n&&(s.assemblies=n.filter((function(e){return"ApolloSequenceAdapter"!==e.sequence.adapter.type}))),null!=r&&null!==(t=r.ApolloPlugin)&&void 0!==t&&t.hasRole){var l=q(r.ApolloPlugin,At);s.configuration=B(B({},r),{},{ApolloPlugin:l})}return o&&(s.internetAccounts=o.filter((function(e){return"ApolloInternetAccount"!==e.type}))),i&&(s.plugins=i.filter((function(e){return"Apollo"!==e.name}))),a&&(s.tracks=a.filter((function(e){return"ApolloTrack"!==e.type}))),s}var Nt=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","ImportJBrowseConfigChange"),D(r,"oldJBrowseConfig",void 0),D(r,"newJBrowseConfig",void 0),r.oldJBrowseConfig=e.oldJBrowseConfig,r.newJBrowseConfig=e.newJBrowseConfig,r}return M(t,e),I(t,[{key:"toJSON",value:function(){return{typeName:this.typeName,oldJBrowseConfig:this.oldJBrowseConfig,newJBrowseConfig:this.newJBrowseConfig}}},{key:"getInverse",value:function(){return new t({typeName:"ImportJBrowseConfigChange",oldJBrowseConfig:this.newJBrowseConfig,newJBrowseConfig:this.oldJBrowseConfig},{logger:this.logger})}}])}(ct),Tt=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","LocationEndChange"),D(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return M(t,e),I(t,[{key:"toJSON",value:function(){var e=this.assembly,t=this.changedIds,n=this.changes,r=this.typeName;if(1===n.length){var o=G(n,1)[0];return{typeName:r,changedIds:t,assembly:e,featureId:o.featureId,oldEnd:o.oldEnd,newEnd:o.newEnd}}return{typeName:r,changedIds:t,assembly:e,changes:n}}},{key:"getInverse",value:function(){var e=this.assembly,n=this.changes,r=this.logger,o=this.typeName;return new t({changedIds:W(this.changedIds).reverse(),typeName:o,changes:W(n).reverse().map((function(e){return{featureId:e.featureId,oldEnd:e.newEnd,newEnd:e.oldEnd}})),assembly:e},{logger:r})}}])}(ft);function Rt(e){return"LocationEndChange"===e.typeName}var Et=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","LocationStartChange"),D(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return M(t,e),I(t,[{key:"toJSON",value:function(){var e=this.assembly,t=this.changedIds,n=this.changes,r=this.typeName;if(1===n.length){var o=G(n,1)[0];return{typeName:r,changedIds:t,assembly:e,featureId:o.featureId,oldStart:o.oldStart,newStart:o.newStart}}return{typeName:r,changedIds:t,assembly:e,changes:n}}},{key:"getInverse",value:function(){var e=this.assembly,n=this.changes,r=this.logger,o=this.typeName;return new t({changedIds:W(this.changedIds).reverse(),typeName:o,changes:W(n).reverse().map((function(e){return{featureId:e.featureId,oldStart:e.newStart,newStart:e.oldStart}})),assembly:e},{logger:r})}}])}(ft);function It(e){return"LocationStartChange"===e.typeName}var jt=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","MergeExonsChange"),D(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return M(t,e),I(t,[{key:"notification",get:function(){return"Exons successfully merged"}},{key:"toJSON",value:function(){var e=this.assembly,t=this.changedIds,n=this.changes,r=this.typeName;if(1===n.length){var o=G(n,1)[0];return{typeName:r,changedIds:t,assembly:e,firstExon:o.firstExon,secondExon:o.secondExon,parentFeatureId:o.parentFeatureId}}return{typeName:r,changedIds:t,assembly:e,changes:n}}},{key:"getInverse",value:function(){var e,t=this.assembly,n=this.changes,r=this.logger,o=W(this.changedIds).reverse(),i=W(n).reverse().map((function(e){return{exonsToRestore:[e.firstExon,e.secondExon],parentFeatureId:e.parentFeatureId}}));return null===(e=r.debug)||void 0===e||e.call(r,"INVERSE CHANGE '".concat(JSON.stringify(i),"'")),new Dt({changedIds:o,typeName:"UndoMergeExonsChange",changes:i,assembly:t},{logger:r})}}])}(ft),Dt=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","UndoMergeExonsChange"),D(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return M(t,e),I(t,[{key:"toJSON",value:function(){var e=this.assembly,t=this.changedIds,n=this.changes,r=this.typeName;if(1===n.length){var o=G(n,1)[0];return{typeName:r,changedIds:t,assembly:e,exonsToRestore:o.exonsToRestore,parentFeatureId:o.parentFeatureId}}return{typeName:r,changedIds:t,assembly:e,changes:n}}},{key:"getInverse",value:function(){var e=this.assembly,t=this.changes,n=this.logger,r=W(this.changedIds).reverse(),o=W(t).reverse().map((function(e){return{firstExon:e.exonsToRestore[0],secondExon:e.exonsToRestore[1],parentFeatureId:e.parentFeatureId}}));return new jt({changedIds:r,typeName:"MergeExonsChange",changes:o,assembly:e},{logger:n})}}])}(ft);function Ot(e,t){for(var n=[],r=0;r<e.length;r+=t){var o=e.slice(r,r+t);n.push(o)}return n}function Ft(e){var t,n,r=e,o=null===(t=r.attributes.get("gff_id"))||void 0===t?void 0:t.join(",");if(o)return"ID=".concat(o," (_id: ").concat(e._id.toString(),")");var i=null===(n=r.attributes.get("gff_name"))||void 0===n?void 0:n.join(",");return i?"Name=".concat(i," (_id: ").concat(e._id.toString(),")"):"_id: ".concat(e._id.toString())}function Mt(e){var t={};if(!e)return t;for(var n=0,r=Object.entries(e);n<r.length;n++){var o=G(r[n],2),i=o[1];t[o[0]]=null==i?void 0:i.slice()}return t}function Lt(e){if(!e)return"";for(var t=[],n=0,r=Object.entries(e);n<r.length;n++){var o=G(r[n],2),i=o[1],a=o[0];a.startsWith("gff_")&&(a=(a=a.slice(4)).charAt(0).toUpperCase()+a.slice(1)),t.push(i?"".concat(a,"=").concat(i.join(",")):a)}return encodeURIComponent(t.join(";"))}var Pt=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","MergeTranscriptsChange"),D(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return M(t,e),I(t,[{key:"notification",get:function(){return"Transcripts successfully merged"}},{key:"toJSON",value:function(){var e=this.assembly,t=this.changedIds,n=this.changes,r=this.typeName;if(1===n.length){var o=G(n,1)[0];return{typeName:r,changedIds:t,assembly:e,firstTranscript:o.firstTranscript,secondTranscript:o.secondTranscript,parentFeatureId:o.parentFeatureId}}return{typeName:r,changedIds:t,assembly:e,changes:n}}},{key:"mergeTranscriptsOnServer",value:function(e,t){e.min=Math.min(e.min,t.min),e.max=Math.max(e.max,t.max);var n=e.attributes?JSON.parse(JSON.stringify(e.attributes)):{};if(t.attributes&&(Object.keys(n).includes("merged_with")||(n.merged_with=[]),n.merged_with.push(Lt(Mt(t.attributes)))),e.attributes=n,t.children)for(var r=0,o=Object.entries(t.children);r<o.length;r++){var i=G(o[r],2);this.mergeFeatureIntoTranscriptOnServer(i[1],e)}}},{key:"mergeFeatureIntoTranscriptOnServer",value:function(e,t){var n,r=this;null!==(n=t.children)&&void 0!==n||(t.children=new Map);var i,a,s,l=!1,c=j(t.children);try{for(c.s();!(s=c.n()).done;){var u=G(s.value,2)[1];if(l&&i?a=!0:(a=!1,i=u),i.type===e.type&&i.type===u.type&&o.doesIntersect2(e.min,e.max,i.min,i.max)&&o.doesIntersect2(u.min,u.max,i.min,i.max)){var d,f;i.min=Math.min(e.min,i.min,u.min),i.max=Math.max(e.max,i.max,u.max),null!==(f=(d=i).attributes)&&void 0!==f||(d.attributes={});var h=JSON.parse(JSON.stringify(i.attributes));Object.keys(h).includes("merged_with")||(h.merged_with=[]);var p=h.merged_with;if(p.push(Lt(Mt(e.attributes))),a){var g=u.attributes?JSON.parse(JSON.stringify(u.attributes)):void 0;p.push(Lt(g)),t.children.delete(u._id.toString())}h.merged_with=W(new Set(p)),i.attributes=h,l=!0}}}catch(e){c.e(e)}finally{c.f()}l&&i&&e.children&&Object.entries(e.children).map((function(e){var t=G(e,2);r.addChild(i,t[1])})),this.addChild(t,l&&i?i:e)}},{key:"mergeTranscriptsOnClient",value:function(e,t){var n,r;e.setMin(Math.min(e.min,t.min)),e.setMax(Math.max(e.max,t.max));var o=null!==(n=null===(r=e.attributes.get("merged_with"))||void 0===r?void 0:r.slice())&&void 0!==n?n:[],i=Lt(Mt(t.attributes));if(o.includes(i)||o.push(i),e.setAttribute("merged_with",o),t.children)for(var a=0,s=Object.entries(t.children);a<s.length;a++){var l=G(s[a],2);this.mergeFeatureIntoTranscriptOnClient(l[1],e)}}},{key:"mergeFeatureIntoTranscriptOnClient",value:function(e,t){var n;null!==(n=t.children)&&void 0!==n||(t.children=new Map);var r,i,a,s=!1,c=j(t.children);try{for(c.s();!(a=c.n()).done;){var u=G(a.value,2)[1];if(s&&r?i=!0:(i=!1,r=u),r.type===e.type&&r.type===u.type&&o.doesIntersect2(e.min,e.max,r.min,r.max)&&o.doesIntersect2(u.min,u.max,r.min,r.max)){var d,f;r.setMin(Math.min(e.min,r.min,u.min)),r.setMax(Math.max(e.max,r.max,u.max));var h=null!==(d=null===(f=r.attributes.get("merged_with"))||void 0===f?void 0:f.slice())&&void 0!==d?d:[];h.push(Lt(Mt(e.attributes))),i&&(h.push(Lt(l.getSnapshot(u).attributes)),t.deleteChild(u._id)),r.setAttribute("merged_with",W(new Set(h))),s=!0}}}catch(e){c.e(e)}finally{c.f()}s&&r&&e.children&&Object.entries(e.children).map((function(e){var t=G(e,2);r.addChild(t[1])})),t.addChild(s&&r?l.getSnapshot(r):e)}},{key:"getInverse",value:function(){var e,t=this.assembly,n=this.changes,r=this.logger,o=W(this.changedIds).reverse(),i=W(n).reverse().map((function(e){return{transcriptsToRestore:[e.firstTranscript,e.secondTranscript],parentFeatureId:e.parentFeatureId}}));return null===(e=r.debug)||void 0===e||e.call(r,"INVERSE CHANGE '".concat(JSON.stringify(i),"'")),new Bt({changedIds:o,typeName:"UndoMergeTranscriptsChange",changes:i,assembly:t},{logger:r})}}])}(ft),Bt=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","UndoMergeTranscriptsChange"),D(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return M(t,e),I(t,[{key:"toJSON",value:function(){var e=this.assembly,t=this.changedIds,n=this.changes,r=this.typeName;if(1===n.length){var o=G(n,1)[0];return{typeName:r,changedIds:t,assembly:e,transcriptsToRestore:o.transcriptsToRestore,parentFeatureId:o.parentFeatureId}}return{typeName:r,changedIds:t,assembly:e,changes:n}}},{key:"getInverse",value:function(){var e=this.assembly,t=this.changes,n=this.logger,r=W(this.changedIds).reverse(),o=W(t).reverse().map((function(e){return{firstTranscript:e.transcriptsToRestore[0],secondTranscript:e.transcriptsToRestore[1],parentFeatureId:e.parentFeatureId}}));return new Pt({changedIds:r,typeName:"MergeTranscriptsChange",changes:o,assembly:e},{logger:n})}}])}(ft),qt=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","SplitExonChange"),D(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return M(t,e),I(t,[{key:"notification",get:function(){return"Exon successfully split"}},{key:"toJSON",value:function(){var e=this.assembly,t=this.changedIds,n=this.changes,r=this.typeName;if(1===n.length){var o=G(n,1)[0];return{typeName:r,changedIds:t,assembly:e,exonToBeSplit:o.exonToBeSplit,parentFeatureId:o.parentFeatureId,upstreamCut:o.upstreamCut,downstreamCut:o.downstreamCut,leftExonId:o.leftExonId,rightExonId:o.rightExonId}}return{typeName:r,changedIds:t,assembly:e,changes:n}}},{key:"getInverse",value:function(){var e,t=this.assembly,n=this.changes,r=this.logger,o=W(this.changedIds).reverse(),i=W(n).reverse().map((function(e){return{exonToRestore:e.exonToBeSplit,parentFeatureId:e.parentFeatureId,idsToDelete:[e.leftExonId,e.rightExonId],upstreamCut:e.upstreamCut,downstreamCut:e.downstreamCut,leftExonId:e.leftExonId,rightExonId:e.rightExonId}}));return null===(e=r.debug)||void 0===e||e.call(r,"INVERSE CHANGE '".concat(JSON.stringify(i),"'")),new Ut({changedIds:o,typeName:"UndoSplitExonChange",changes:i,assembly:t},{logger:r})}},{key:"makeSplitExons",value:function(e,t,n,r,o){var i=JSON.parse(JSON.stringify(e));delete i.attributes._id,delete i.attributes.gff_id;var a=structuredClone(i);a._id=r,a.max=t;var s=structuredClone(i);return s.min=n,s._id=o,[a,s]}}])}(ft),Ut=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","UndoSplitExonChange"),D(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return M(t,e),I(t,[{key:"toJSON",value:function(){var e=this.assembly,t=this.changedIds,n=this.changes,r=this.typeName;if(1===n.length){var o=G(n,1)[0];return{typeName:r,changedIds:t,assembly:e,exonToRestore:o.exonToRestore,parentFeatureId:o.parentFeatureId,idsToDelete:o.idsToDelete,upstreamCut:o.upstreamCut,downstreamCut:o.downstreamCut,leftExonId:o.leftExonId,rightExonId:o.rightExonId}}return{typeName:r,changedIds:t,assembly:e,changes:n}}},{key:"getInverse",value:function(){var e=this.assembly,t=this.changes,n=this.logger,r=W(this.changedIds).reverse(),o=W(t).reverse().map((function(e){return{parentFeatureId:e.parentFeatureId,exonToBeSplit:e.exonToRestore,upstreamCut:e.upstreamCut,downstreamCut:e.downstreamCut,leftExonId:e.leftExonId,rightExonId:e.rightExonId}}));return new qt({changedIds:r,typeName:"SplitExonChange",changes:o,assembly:e},{logger:n})}}])}(ft),zt=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","StrandChange"),D(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return M(t,e),I(t,[{key:"toJSON",value:function(){var e=this.assembly,t=this.changedIds,n=this.changes,r=this.typeName;if(1===n.length){var o=G(n,1)[0];return{typeName:r,changedIds:t,assembly:e,featureId:o.featureId,oldStrand:o.oldStrand,newStrand:o.newStrand}}return{typeName:r,changedIds:t,assembly:e,changes:n}}},{key:"getInverse",value:function(){var e=this.assembly,n=this.changes,r=this.logger,o=this.typeName;return new t({changedIds:W(this.changedIds).reverse(),typeName:o,changes:W(n).reverse().map((function(e){return{featureId:e.featureId,oldStrand:e.newStrand,newStrand:e.oldStrand}})),assembly:e},{logger:r})}}])}(ft),$t=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","TypeChange"),D(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return M(t,e),I(t,[{key:"toJSON",value:function(){var e=this.assembly,t=this.changedIds,n=this.changes,r=this.typeName;if(1===n.length){var o=G(n,1)[0];return{typeName:r,changedIds:t,assembly:e,featureId:o.featureId,oldType:o.oldType,newType:o.newType}}return{typeName:r,changedIds:t,assembly:e,changes:n}}},{key:"getInverse",value:function(){var e=this.assembly,n=this.changes,r=this.logger,o=this.typeName;return new t({changedIds:W(this.changedIds).reverse(),typeName:o,changes:W(n).reverse().map((function(e){return{featureId:e.featureId,oldType:e.newType,newType:e.oldType}})),assembly:e},{logger:r})}}])}(ft),Ht=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","UserChange"),D(r,"changes",void 0),D(r,"userId",void 0),r.changes="changes"in e?e.changes:[e],r.userId=e.userId,r}return M(t,e),I(t,[{key:"toJSON",value:function(){var e=this.changes,t=this.typeName,n=this.userId;return 1===e.length?{typeName:t,userId:n,role:G(e,1)[0].role}:{typeName:t,userId:n,changes:e}}},{key:"getInverse",value:function(){return new t({typeName:this.typeName,changes:this.changes,userId:this.userId},{logger:this.logger})}}])}(ct),Gt=B(B({},{AddFeatureChange:ht,DeleteFeatureChange:pt,FeatureAttributeChange:St,LocationEndChange:Tt,LocationStartChange:Et,MergeExonsChange:jt,SplitExonChange:qt,MergeTranscriptsChange:Pt,UndoMergeExonsChange:Dt,UndoSplitExonChange:Ut,UndoMergeTranscriptsChange:Bt,StrandChange:zt,TypeChange:$t}),{},{AddAssemblyAndFeaturesFromFileChange:mt,AddAssemblyFromFileChange:_t,AddAssemblyFromExternalChange:yt,AddFeaturesFromFileChange:vt,DeleteAssemblyChange:xt,DeleteUserChange:wt,ImportJBrowseConfigChange:Nt,UserChange:Ht,AddRefSeqAliasesChange:bt,AddAssemblyAliasesChange:gt}),Vt=function(){return I((function e(){R(this,e)}),[{key:"frontendPreValidate",value:(o=k(U().m((function e(t){return U().w((function(e){for(;;)if(0===e.n)return e.a(2,{validationName:this.name})}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"frontendPostValidate",value:(r=k(U().m((function e(t){return U().w((function(e){for(;;)if(0===e.n)return e.a(2,{validationName:this.name})}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"backendPreValidate",value:(n=k(U().m((function e(t){return U().w((function(e){for(;;)if(0===e.n)return e.a(2,{validationName:this.name})}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"backendPostValidate",value:(t=k(U().m((function e(t,n){return U().w((function(e){for(;;)if(0===e.n)return e.a(2,{validationName:this.name})}),e,this)}))),function(e,n){return t.apply(this,arguments)})},{key:"possibleValues",value:(e=k(U().m((function e(t){return U().w((function(e){for(;;)if(0===e.n)return e.a(2,void 0)}),e)}))),function(t){return e.apply(this,arguments)})}]);var e,t,n,r,o}(),Wt=function(){return I((function e(){R(this,e),D(this,"results",[]),D(this,"ok",!0)}),[{key:"resultsMessages",get:function(){return this.results.map((function(e){var t;return null===(t=e.error)||void 0===t?void 0:t.message})).filter(Boolean).join(", ")}},{key:"add",value:function(e){this.results.push(e),e.error&&(this.ok=!1)}}])}(),Jt=function(){return I((function e(){R(this,e),D(this,"validations",new Set)}),[{key:"registerValidation",value:function(e){this.validations.add(e)}},{key:"frontendPreValidate",value:(o=k(U().m((function e(t){var n,r,o,i,a;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:n=new Wt,r=j(this.validations),e.p=1,r.s();case 2:if((o=r.n()).done){e.n=5;break}return i=o.value,e.n=3,i.frontendPreValidate(t);case 3:if(n.add(a=e.v),!a.error){e.n=4;break}return e.a(3,5);case 4:e.n=2;break;case 5:e.n=7;break;case 6:e.p=6,r.e(e.v);case 7:return e.p=7,r.f(),e.f(7);case 8:return e.a(2,n)}}),e,this,[[1,6,7,8]])}))),function(e){return o.apply(this,arguments)})},{key:"frontendPostValidate",value:(r=k(U().m((function e(t){var n,r,o,i,a;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:n=new Wt,r=j(this.validations),e.p=1,r.s();case 2:if((o=r.n()).done){e.n=5;break}return i=o.value,e.n=3,i.frontendPostValidate(t);case 3:if(n.add(a=e.v),!a.error){e.n=4;break}return e.a(3,5);case 4:e.n=2;break;case 5:e.n=7;break;case 6:e.p=6,r.e(e.v);case 7:return e.p=7,r.f(),e.f(7);case 8:return e.a(2,n)}}),e,this,[[1,6,7,8]])}))),function(e){return r.apply(this,arguments)})},{key:"backendPreValidate",value:(n=k(U().m((function e(t){var n,r,o,i,a;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:n=new Wt,r=j(this.validations),e.p=1,r.s();case 2:if((o=r.n()).done){e.n=5;break}return i=o.value,e.n=3,i.backendPreValidate(t);case 3:if(n.add(a=e.v),!a.error){e.n=4;break}return e.a(3,5);case 4:e.n=2;break;case 5:e.n=7;break;case 6:e.p=6,r.e(e.v);case 7:return e.p=7,r.f(),e.f(7);case 8:return e.a(2,n)}}),e,this,[[1,6,7,8]])}))),function(e){return n.apply(this,arguments)})},{key:"backendPostValidate",value:(t=k(U().m((function e(t,n){var r,o,i,a,s,l,c;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:r=n.featureModel,o=n.session,i=new Wt,a=j(this.validations),e.p=1,a.s();case 2:if((s=a.n()).done){e.n=5;break}return l=s.value,e.n=3,l.backendPostValidate(t,{featureModel:r,session:o});case 3:if(i.add(c=e.v),!c.error){e.n=4;break}return e.a(3,5);case 4:e.n=2;break;case 5:e.n=7;break;case 6:e.p=6,a.e(e.v);case 7:return e.p=7,a.f(),e.f(7);case 8:return e.a(2,i)}}),e,this,[[1,6,7,8]])}))),function(e,n){return t.apply(this,arguments)})},{key:"possibleValues",value:(e=k(U().m((function e(t){var n,r,o,i;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:n=j(this.validations),e.p=1,n.s();case 2:if((r=n.n()).done){e.n=5;break}return o=r.value,e.n=3,o.possibleValues(t);case 3:if(!(i=e.v)){e.n=4;break}return e.a(2,i);case 4:e.n=2;break;case 5:e.n=7;break;case 6:e.p=6,n.e(e.v);case 7:return e.p=7,n.f(),e.f(7);case 8:return e.a(2)}}),e,this,[[1,6,7,8]])}))),function(t){return e.apply(this,arguments)})}]);var e,t,n,r,o}(),Kt=new Jt,Yt=["2A_self_cleaving_peptide_region","4_methylcytosine","5S_SINE_retrotransposon","5_carboxylcytosine","5_formylcytosine","5_hydroxymethylcytosine","5_methylcytosine","7SL_SINE_retrotransposon","8_oxoadenine","8_oxoguanine","AACCCT_box","AFLP_fragment","AP_1_binding_site","ARIA","ARRET","ARS","ARS_consensus_sequence","ASPE_primer","AUG_initiated_uORF","AU_rich_element","A_box","A_box_type_1","A_box_type_2","A_minor_RNA_motif","A_to_C_transversion","A_to_G_transition","A_to_T_transversion","Ace2_UAS","Alu_deletion","Alu_insertion","BAC","BAC_cloned_genomic_insert","BAC_end","BAC_read_contig","BREd_motif","BREu_motif","B_box","Bel_Pao_LTR_retrotransposon","Bruno_response_element","C-D_H_ACA_box_scaRNA","C-D_H_ACA_box_scaRNA_gene","CAAT_signal","CAAX_box","CACTA_TIR_transposon","CAGE_cluster","CAGE_tag","CArG_box","CCAAT_motif","CCA_tail","CDRE_motif","CDS","CDS_extension","CDS_five_prime_extension","CDS_fragment","CDS_independently_known","CDS_predicted","CDS_region","CDS_supported_by_EST_or_cDNA_data","CDS_supported_by_domain_match_data","CDS_supported_by_peptide_spectrum_match","CDS_supported_by_sequence_similarity_data","CDS_three_prime_extension","CRE","CRISPR","CSL_response_element","CTCF_binding_site","CTG_start_codon","C_D_box_scaRNA","C_D_box_scaRNA_gene","C_D_box_snoRNA","C_D_box_snoRNA_gene","C_D_box_snoRNA_primary_transcript","C_box","C_cluster","C_gene_segment","C_region","C_to_A_transversion","C_to_G_transversion","C_to_T_transition","C_to_T_transition_at_pCpG_site","ChIP_seq_region","Copia_LTR_retrotransposon","CpG_island","Crick_strand","Crypton_YR_transposon","CsrB_RsmB_RNA","CuRE","DArT_marker","DCE","DCE_SI","DCE_SII","DCE_SIII","DDB_box","DHU_loop","DIRS_YR_retrotransposon","DJ_C_cluster","DJ_J_C_cluster","DJ_J_cluster","DJ_gene_segment","DMv1_motif","DMv2_motif","DMv3_motif","DMv4_motif","DMv5_motif","DNA_aptamer","DNA_binding_site","DNA_chromosome","DNA_constraint_sequence","DNA_loop","DNA_loop_anchor","DNA_motif","DNA_sequence_secondary_structure","DNA_transposon","DNAzyme","DNaseI_hypersensitive_site","DPE1_motif","DPE_motif","DRE","DRE_motif","DSR_motif","D_DJ_C_cluster","D_DJ_J_C_cluster","D_DJ_J_cluster","D_DJ_cluster","D_J_C_cluster","D_J_cluster","D_cluster","D_gene_recombination_feature","D_gene_segment","D_loop","DsrA_RNA","ER_retention_signal","EST","EST_match","E_box_motif","Endogenous_Retrovirus_LTR_retrotransposon","FLEX_element","FRE","FRT_site","GAGA_motif","GATA_box","GC_rich_promoter_region","GNA_oligo","GTT_trinucleotide_repeat","GT_dinucleotide_repeat","G_box","G_quartet","G_to_A_transition","G_to_C_transversion","G_to_T_transversion","GcvB_RNA","Gypsy_LTR_retrotransposon","H2AK5_acetylation_site","H2AK9_acetylation_site","H2AZK11_acetylation_site","H2AZK13_acetylation_site","H2AZK15_acetylation_site","H2AZK4_acetylation_site","H2AZK7_acetylation_site","H2BK120_acetylation_site","H2BK12_acetylation_site","H2BK15_acetylation_site","H2BK20_acetylation_site","H2BK5_acetylation_site","H2BK5_monomethylation_site","H2B_ubiquitination_site","H3K14_acetylation_site","H3K18_acetylation_site","H3K20_trimethylation_site","H3K23_acetylation_site","H3K23_dimethylation_site","H3K27_acetylation_site","H3K27_dimethylation_site","H3K27_methylation_site","H3K27_monomethylation_site","H3K27_trimethylation_site","H3K36_acetylation_site","H3K36_dimethylation_site","H3K36_methylation_site","H3K36_monomethylation_site","H3K36_trimethylation_site","H3K4_acetylation_site","H3K4_dimethylation_site","H3K4_methylation_site","H3K4_monomethylation_site","H3K4_trimethylation","H3K56_acetylation_site","H3K79_dimethylation_site","H3K79_methylation_site","H3K79_monomethylation_site","H3K79_trimethylation_site","H3K9_acetylation_site","H3K9_dimethylation_site","H3K9_methylation_site","H3K9_monomethylation_site","H3K9_trimethylation_site","H3R2_dimethylation_site","H3R2_monomethylation_site","H4K12_acetylation_site","H4K16_acetylation_site","H4K20_monomethylation_site","H4K4_trimethylation_site","H4K5_acetylation_site","H4K8_acetylation_site","H4K91_acetylation_site","H4K_acylation_region","H4R3_dimethylation_site","HERV_deletion","HERV_insertion","HSE","H_ACA_box_scaRNA","H_ACA_box_scaRNA_gene","H_ACA_box_snoRNA","H_ACA_box_snoRNA_gene","H_ACA_box_snoRNA_primary_transcript","H_pseudoknot","Hoogsteen_base_pair","I-box","IG_C_gene","IG_C_pseudogene","IG_D_gene","IG_J_gene","IG_J_pseudogene","IG_V_gene","IG_V_pseudogene","INR1_motif","INR_motif","IRLinv_site","IRRinv_site","ISRE","I_LINE_retrotransposon","J_C_cluster","J_cluster","J_gene_recombination_feature","J_gene_segment","J_heptamer","J_nonamer","J_spacer","Jockey_LINE_retrotransposon","KEN_box","K_turn_RNA_motif","L1_LINE_retrotransposon","LARD","LINE1_deletion","LINE1_insertion","LINE_element","LNA_oligo","LOZ1_response_element","LTR_component","LTR_retrotransposon","L_box","MCB","MITE","MNP","MNV","MNV_artifact","MTE","Mat2P","Mat3M","Merlin_TIR_transposon","MicF_RNA","Mutator_TIR_transposon","N2_2_prime_O_dimethylguanosine","N2_7_2prirme_O_trimethylguanosine","N2_7_dimethylguanosine","N2_N2_2_prime_O_trimethylguanosine","N2_N2_7_trimethylguanosine","N2_N2_dimethylguanosine","N2_methylguanosine","N4_2_prime_O_dimethylcytidine","N4_N4_2_prime_O_trimethylcytidine","N4_acetyl_2_prime_O_methylcytidine","N4_acetylcytidine","N4_methylcytidine","N6_2_prime_O_dimethyladenosine","N6_N6_2_prime_O_trimethyladenosine","N6_N6_dimethyladenosine","N6_acetyladenosine","N6_cis_hydroxyisopentenyl_adenosine","N6_glycinylcarbamoyladenosine","N6_hydroxynorvalylcarbamoyladenosine","N6_isopentenyladenosine","N6_methyl_N6_threonylcarbamoyladenosine","N6_methyladenine","N6_methyladenosine","N6_threonylcarbamoyladenosine","NDM2_motif","NDM3_motif","NMD_polymorphic_pseudogene_transcript","NMD_transcript","NSD_transcript","N_region","Ngaro_YR_retrotransposon","ORF","Okazaki_fragment","OxyS_RNA","PAC","PAC_end","PCB","PCR_product","PIF_Harbinger_TIR_transposon","PIP_box","PNA_oligo","PSE_motif","P_TIR_transposon","Penelope_retrotransposon","Phage_RNA_Polymerase_Promoter","Pho7_binding_site","QTL","R2_LINE_retrotransposon","RAPD","RFLP_fragment","RH_map","RNA_6S","RNA_7SK","RNA_7SK_gene","RNA_aptamer","RNA_chromosome","RNA_hook_turn","RNA_internal_loop","RNA_junction_loop","RNA_motif","RNA_polymerase_III_TATA_box","RNA_polymerase_II_TATA_box","RNA_sequence_secondary_structure","RNA_stability_element","RNA_thermometer","RNAi_reagent","RNApol_III_promoter","RNApol_III_promoter_type_1","RNApol_III_promoter_type_2","RNApol_III_promoter_type_3","RNApol_II_core_promoter","RNApol_II_promoter","RNApol_I_promoter","RNase_MRP_RNA","RNase_MRP_RNA_gene","RNase_P_RNA","RNase_P_RNA_gene","RRE_RNA","RR_tract","RST","RST_match","RTE_LINE_retrotransposon","R_GNA_oligo","R_LTR_region","R_five_prime_LTR_region","R_three_prime_LTR_region","Retrovirus_LTR_retrotransposon","Robertsonian_fusion","RprA_RNA","SAGE_tag","SECIS_element","SHP_box","SINE_element","SL10_acceptor_site","SL11_acceptor_site","SL12_acceptor_site","SL1_acceptor_site","SL2_acceptor_site","SL3_acceptor_site","SL4_acceptor_site","SL5_acceptor_site","SL6_acceptor_site","SL7_acceptor_site","SL8_acceptor_site","SL9_acceptor_site","SNP","SNV","SNV_artifact","SP6_RNA_Polymerase_Promoter","SRP_RNA","SRP_RNA_gene","SRP_RNA_primary_transcript","STREP_motif","STS","STS_map","SUMO_interaction_motif","SVA_deletion","SVA_insertion","S_GNA_oligo","S_region","Sap1_recognition_motif","Shine_Dalgarno_sequence","T3_RNA_Polymerase_Promoter","T7_RNA_Polymerase_Promoter","TATA_box","TCS_element","TCT_motif","TERRA","TFRS_collection","TFRS_module","TF_binding_site","TNA_oligo","TRIM","TR_C_Gene","TR_D_Gene","TR_J_Gene","TR_J_pseudogene","TR_V_Gene","TR_V_pseudogene","TR_box","TSS","T_cell_receptor_gene","T_cell_receptor_pseudogene","T_loop","T_to_A_transversion","T_to_C_transition","T_to_G_transversion","Tc1_Mariner_TIR_transposon","Transib_TIR_transposon","U11_snRNA","U12_intron","U12_snRNA","U14_snoRNA","U14_snoRNA_gene","U14_snoRNA_primary_transcript","U1_snRNA","U2_intron","U2_snRNA","U3_LTR_region","U3_five_prime_LTR_region","U3_snoRNA","U3_snoRNA_gene","U3_three_prime_LTR_region","U4_snRNA","U4atac_snRNA","U5_LTR_region","U5_five_prime_LTR_region","U5_snRNA","U5_three_prime_LTR_region","U6_snRNA","U6atac_snRNA","U7_snRNA","UAA_stop_codon_signal","UAG_stop_codon_signal","UGA_stop_codon_signal","UNAAAC_motif","UPD","UST","UST_match","UTR","UTR_intron","UTR_region","U_box","VDJ_C_cluster","VDJ_J_C_cluster","VDJ_J_cluster","VDJ_gene_segment","VD_gene_segment","VJ_C_cluster","VJ_J_C_cluster","VJ_J_cluster","VJ_gene_segment","V_DJ_C_cluster","V_DJ_J_C_cluster","V_DJ_J_cluster","V_DJ_cluster","V_D_DJ_C_cluster","V_D_DJ_J_C_cluster","V_D_DJ_J_cluster","V_D_DJ_cluster","V_D_J_C_cluster","V_D_J_cluster","V_J_C_cluster","V_J_cluster","V_VDJ_C_cluster","V_VDJ_J_C_cluster","V_VDJ_J_cluster","V_VDJ_cluster","V_VJ_C_cluster","V_VJ_J_C_cluster","V_VJ_J_cluster","V_VJ_cluster","V_cluster","V_gene_recombination_feature","V_gene_segment","V_heptamer","V_nonamer","V_region","V_spacer","Viper_YR_retrotransposon","WC_base_pair","W_region","Watson_strand","X_element","X_element_combinatorial_repeat","X_region","YAC","YAC_end","YR_retrotransposon","Y_RNA","Y_RNA_gene","Y_RNA_primary_transcript","Y_prime_element","Y_region","Z1_region","Z2_region","Zas1_recognition_motif","aberrant_processed_transcript","accessible_DNA_region","active_peptide","adaptive_island","alanine","alanine_tRNA_primary_transcript","alanyl_tRNA","allelic_pseudogene","allelic_pseudogenic_rRNA","allelic_pseudogenic_tRNA","allelically_excluded_gene","alpha_beta_motif","alpha_helix","alternate_sequence_site","alternatively_spliced_transcript","amber_stop_codon","ambisense_ssRNA_viral_sequence","amino_acid","amplification_origin","anchor_binding_site","anchor_region","androgen_response_element","anti_ARRET","anticodon","anticodon_loop","antiparallel_beta_strand","antisense_RNA","antisense_lncRNA","antisense_lncRNA_gene","antisense_primary_transcript","apicoplast_chromosome","apicoplast_gene","aptamer","archaeal_intron","archaeosine","arginine","arginine_tRNA_primary_transcript","arginyl_tRNA","asparagine","asparagine_tRNA_primary_transcript","asparaginyl_tRNA","aspartic_acid","aspartic_acid_tRNA_primary_transcript","aspartyl_tRNA","assembly","assembly_component","assembly_error_correction","asx_motif","asx_turn","asx_turn_left_handed_type_one","asx_turn_left_handed_type_two","asx_turn_right_handed_type_one","asx_turn_right_handed_type_two","asymmetric_RNA_internal_loop","attB_site","attC_site","attCtn_site","attI_site","attL_site","attP_site","attR_site","attenuator","autocatalytically_spliced_intron","bacterial_RNApol_promoter","bacterial_RNApol_promoter_sigma54_element","bacterial_RNApol_promoter_sigma_70_element","bacterial_RNApol_promoter_sigma_ecf_element","bacterial_terminator","base","base_call_error_correction","base_pair","beta_bulge","beta_bulge_loop","beta_bulge_loop_five","beta_bulge_loop_six","beta_strand","beta_turn","beta_turn_left_handed_type_one","beta_turn_left_handed_type_two","beta_turn_right_handed_type_one","beta_turn_right_handed_type_two","beta_turn_type_eight","beta_turn_type_six","beta_turn_type_six_a","beta_turn_type_six_a_one","beta_turn_type_six_a_two","beta_turn_type_six_b","bidirectional_promoter","bidirectional_promoter_lncRNA","binding_site","biochemical_region_of_peptide","biological_region","biomaterial_region","biosynthetic_gene_cluster","blocked_reading_frame","blunt_end_restriction_enzyme_cleavage_junction","blunt_end_restriction_enzyme_cleavage_site","boundary_element","branch_site","cDNA_clone","cDNA_match","c_terminal_region","candidate_gene","canonical_five_prime_splice_site","canonical_three_prime_splice_site","cap","capped_mRNA","capped_primary_transcript","cassette_pseudogene","catalytic_residue","catmat_left_handed_four","catmat_left_handed_three","catmat_right_handed_four","catmat_right_handed_three","central_hydrophobic_region_of_signal_peptide","centromere","centromere_DNA_Element_I","centromere_DNA_Element_II","centromere_DNA_Element_III","centromeric_repeat","chimeric_cDNA_clone","chloroplast_DNA_read","chloroplast_chromosome","chromatin_regulatory_region","chromoplast_chromosome","chromoplast_gene","chromosomal_regulatory_element","chromosomal_structural_element","chromosomal_translocation","chromosome","chromosome_arm","chromosome_band","chromosome_breakage_sequence","chromosome_breakpoint","chromosome_part","circular_double_stranded_DNA_chromosome","circular_double_stranded_RNA_chromosome","circular_mRNA","circular_ncRNA","circular_plasmid","circular_single_stranded_DNA_chromosome","circular_single_stranded_RNA_chromosome","cis_acting_homologous_chromosome_pairing_region","cis_regulatory_frameshift_element","cis_regulatory_module","cis_splice_site","class_II_RNA","class_I_RNA","cleaved_for_gpi_anchor_region","cleaved_initiator_methionine","cleaved_peptide_region","clip","clone","clone_end","clone_insert","clone_insert_end","clone_insert_start","cloned_cDNA_insert","cloned_genomic_insert","cloned_region","coding_conserved_region","coding_end","coding_exon","coding_region_of_exon","coding_start","coding_transcript_with_retained_intron","codon","coiled_coil","cointegrated_plasmid","common_fragile_site","complex_chromosomal_rearrangement","complex_operon","complex_regulon","complex_structural_alteration","complex_substitution","compositionally_biased_region_of_peptide","conformational_switch","conjugative_transposon","consensus_AFLP_fragment","consensus_gDNA","consensus_mRNA","consensus_region","conserved_region","constitutive_promoter","contig","contig_collection","contig_read","copy_number_gain","copy_number_loss","copy_number_variation","core_eukaryotic_promoter_element","core_prokaryotic_promoter_element","core_promoter_element","core_viral_promoter_element","cosmid","cross_genome_match","cryptic_gene","cryptic_promoter","cryptic_prophage","cryptic_splice_site","cryptogene","ct_gene","cyanelle_chromosome","cyanelle_gene","cyclic_translocation","cysteine","cysteine_tRNA_primary_transcript","cysteinyl_tRNA","cytoplasmic_polypeptide_region","cytosolic_16S_rRNA","cytosolic_18S_rRNA","cytosolic_23S_rRNA","cytosolic_25S_rRNA","cytosolic_28S_rRNA","cytosolic_2S_rRNA","cytosolic_5S_rRNA","cytosolic_5_8S_rRNA","cytosolic_LSU_rRNA","cytosolic_LSU_rRNA_gene","cytosolic_SSU_rRNA","cytosolic_SSU_rRNA_gene","cytosolic_rRNA","cytosolic_rRNA_16S_gene","cytosolic_rRNA_18S_gene","cytosolic_rRNA_23S_gene","cytosolic_rRNA_25S_gene","cytosolic_rRNA_28S_gene","cytosolic_rRNA_2S_gene","cytosolic_rRNA_5S_gene","cytosolic_rRNA_5_8S_gene","cytosolic_rRNA_gene","dCAPS_primer","databank_entry","decayed_exon","defective_conjugative_transposon","deficient_translocation","deletion","deletion_artifact","deletion_breakpoint","deletion_junction","delins","destruction_box","dg_repeat","dh_repeat","dicistronic_mRNA","dicistronic_primary_transcript","dicistronic_transcript","dif_site","dihydrouridine","dinucleotide_repeat_microsatellite_feature","direct_repeat","direct_tandem_duplication","disabled_reading_frame","dispersed_repeat","distal_duplication","distal_promoter_element","distant_three_prime_recoding_signal","double_stranded_DNA_chromosome","double_stranded_RNA_chromosome","ds_DNA_viral_sequence","ds_RNA_viral_sequence","ds_oligo","duplicated_pseudogene","duplication","duplication_artifact","dye_terminator_read","early_origin_of_replication","edited_CDS","edited_mRNA","edited_transcript","edited_transcript_by_A_to_I_substitution","edited_transcript_feature","editing_block","editing_domain","endogenous_retroviral_gene","endonuclease_spliced_intron","endosomal_localization_signal","engineered_episome","engineered_foreign_gene","engineered_foreign_region","engineered_foreign_repetitive_element","engineered_foreign_transposable_element","engineered_foreign_transposable_element_gene","engineered_fusion_gene","engineered_gene","engineered_insert","engineered_plasmid","engineered_region","engineered_rescue_region","engineered_tag","engineered_transposable_element","enhancer","enhancerRNA","enhancer_binding_site","enhancer_blocking_element","enhancer_bound_by_factor","enhancer_trap_construct","enzymatic_RNA","enzymatic_RNA_gene","epigenetically_modified_gene","epigenetically_modified_region","epigenomically_modified_region","episome","epitope","epoxyqueuosine","eukaryotic_promoter","eukaryotic_terminator","exemplar_mRNA","exon","exon_junction","exon_of_single_exon_gene","exon_region","exonic_splice_enhancer","exonic_splicing_silencer","experimental_feature","experimental_result_region","experimentally_defined_binding_region","expressed_sequence_assembly","expressed_sequence_match","extended_cis_splice_site","extended_intronic_splice_region","external_transcribed_spacer_region","extrachromosomal_mobile_genetic_element","extramembrane_polypeptide_region","fingerprint_map","five_aminomethyl_two_thiouridine","five_carbamoylmethyl_two_prime_O_methyluridine","five_carbamoylmethyluridine","five_carboxyhydroxymethyl_uridine","five_carboxyhydroxymethyl_uridine_methyl_ester","five_carboxymethylaminomethyl_two_prime_O_methyluridine","five_carboxymethylaminomethyl_two_thiouridine","five_carboxymethylaminomethyluridine","five_carboxymethyluridine","five_formyl_two_prime_O_methylcytidine","five_formylcytidine","five_hydroxymethylcytidine","five_hydroxyuridine","five_isopentenylaminomethyl_two_prime_O_methyluridine","five_isopentenylaminomethyl_two_thiouridine","five_isopentenylaminomethyl_uridine","five_methoxycarbonylmethyl_two_prime_O_methyluridine","five_methoxycarbonylmethyl_two_thiouridine","five_methoxycarbonylmethyluridine","five_methoxyuridine","five_methyl_2_thiouridine","five_methylaminomethyl_two_selenouridine","five_methylaminomethyl_two_thiouridine","five_methylaminomethyluridine","five_methylcytidine","five_methyldihydrouridine","five_methyluridine","five_prime_D_heptamer","five_prime_D_nonamer","five_prime_D_recombination_signal_sequence","five_prime_D_spacer","five_prime_EST","five_prime_LTR","five_prime_LTR_component","five_prime_RST","five_prime_UST","five_prime_UTR","five_prime_UTR_intron","five_prime_cis_splice_site","five_prime_clip","five_prime_coding_exon","five_prime_coding_exon_coding_region","five_prime_coding_exon_noncoding_region","five_prime_flanking_region","five_prime_intron","five_prime_noncoding_exon","five_prime_open_reading_frame","five_prime_recoding_site","five_prime_restriction_enzyme_junction","five_prime_sticky_end_restriction_enzyme_cleavage_site","five_prime_terminal_inverted_repeat","five_taurinomethyl_two_thiouridine","five_taurinomethyluridine","five_two_prime_O_dimethylcytidine","five_two_prime_O_dimethyluridine","flanking_region","flanking_repeat","flanking_three_prime_quadruplet_recoding_signal","floxed_gene","foldback_element","foreign_gene","foreign_transposable_element","forkhead_motif","forward_primer","fosmid","four_bp_start_codon","four_demethylwyosine","four_thiouridine","fragile_site","fragment_assembly","functional_candidate_gene","functional_gene_region","fusion_gene","gRNA_gene","galactosyl_queuosine","gamma_turn","gamma_turn_classic","gamma_turn_inverse","gap","gene","gene_array","gene_cassette","gene_cassette_array","gene_component_region","gene_fragment","gene_group","gene_member_region","gene_rearranged_at_DNA_level","gene_segment","gene_silenced_by_DNA_methylation","gene_silenced_by_DNA_modification","gene_silenced_by_RNA_interference","gene_silenced_by_histone_deacetylation","gene_silenced_by_histone_methylation","gene_silenced_by_histone_modification","gene_subarray","gene_trap_construct","gene_with_dicistronic_mRNA","gene_with_dicistronic_primary_transcript","gene_with_dicistronic_transcript","gene_with_edited_transcript","gene_with_mRNA_recoded_by_translational_bypass","gene_with_mRNA_with_frameshift","gene_with_non_canonical_start_codon","gene_with_polyadenylated_mRNA","gene_with_polycistronic_transcript","gene_with_recoded_mRNA","gene_with_start_codon_CUG","gene_with_stop_codon_read_through","gene_with_stop_codon_redefined_as_pyrrolysine","gene_with_stop_codon_redefined_as_selenocysteine","gene_with_trans_spliced_transcript","gene_with_transcript_with_translational_frameshift","genetic_marker","genomic_DNA_contig","genomic_DNA_read","genomic_clone","genomic_island","genomically_contaminated_cDNA_clone","glutamic_acid","glutamic_acid_tRNA_primary_transcript","glutamine","glutamine_tRNA_primary_transcript","glutaminyl_tRNA","glutamyl_tRNA","glycine","glycine_tRNA_primary_transcript","glycyl_tRNA","golden_path","golden_path_fragment","group_1_intron_homing_endonuclease_target_region","group_IIA_intron","group_IIB_intron","group_IIC_intron","group_III_intron","group_II_intron","group_I_intron","guide_RNA","guide_RNA_region","hAT_TIR_transposon","hammerhead_ribozyme","haplotype_block","helitron","helix_turn_helix","heptamer_of_recombination_feature_of_vertebrate_immune_system_gene","heritable_phenotypic_marker","high_identity_region","histidine","histidine_tRNA_primary_transcript","histidyl_tRNA","histone_2AZ_acetylation_site","histone_2A_acetylation_site","histone_2B_acetylation_site","histone_3_acetylation_site","histone_4_acetylation_site","histone_acetylation_site","histone_acylation_region","histone_binding_site","histone_methylation_site","histone_modification","histone_ubiqitination_site","homing_endonuclease_binding_site","homol_D_box","homol_E_box","homologous_chromosome_recognition_and_pairing_locus","homologous_region","hpRNA","hpRNA_gene","hydrophobic_region_of_peptide","hydroxywybutosine","iDNA","i_motif","immature_peptide_region","immunoglobulin_gene","immunoglobulin_pseudogene","immunoglobulin_region","imprinting_control_region","indel_artifact","inducible_promoter","inert_DNA_spacer","inosine","insertion","insertion_artifact","insertion_breakpoint","insertion_sequence","insertion_site","insulator","insulator_binding_site","integrated_mobile_genetic_element","integrated_plasmid","integration_excision_site","integron","intein","intein_encoding_region","interband","interchromosomal_breakpoint","interchromosomal_translocation","intergenic_region","interior_coding_exon","interior_exon","interior_intron","intermediate_element","internal_Shine_Dalgarno_sequence","internal_UTR","internal_eliminated_sequence","internal_guide_sequence","internal_ribosome_entry_site","internal_transcribed_spacer_region","intrachromosomal_breakpoint","intrachromosomal_translocation","intramembrane_polypeptide_region","intrinsically_unstructured_polypeptide_region","introgressed_chromosome_region","intron","intron_base_5","intron_domain","intronic_regulatory_region","intronic_splice_enhancer","intronic_splicing_silencer","invalidated_cDNA_clone","inversion","inversion_breakpoint","inversion_cum_translocation","inversion_site","inversion_site_part","inverted_intrachromosomal_transposition","inverted_repeat","inverted_tandem_duplication","iron_repressed_GATA_element","iron_responsive_element","isoleucine","isoleucine_tRNA_primary_transcript","isoleucyl_tRNA","isomiR","isowyosine","junction","kinetoplast_gene","knob","kozak_sequence","lambda_vector","lariat_intron","late_origin_of_replication","left_handed_peptide_helix","leucine","leucine_tRNA_primary_transcript","leucoplast_chromosome","leucoplast_gene","leucyl_tRNA","ligand_binding_site","ligation_based_read","lincRNA","lincRNA_gene","linear_double_stranded_DNA_chromosome","linear_double_stranded_RNA_chromosome","linear_plasmid","linear_single_stranded_DNA_chromosome","linear_single_stranded_RNA_chromosome","linkage_group","lipoprotein_signal_peptide","lncRNA","lncRNA_gene","lncRNA_primary_transcript","lncRNA_with_retained_intron","loR","locus_control_region","long_terminal_repeat","long_terminal_repeat_transcript","loop","low_complexity_region","loxP_site","lysidine","lysine","lysine_tRNA_primary_transcript","lysosomal_localization_signal","lysyl_tRNA","mRNA","mRNA_contig","mRNA_read","mRNA_recoded_by_codon_redefinition","mRNA_recoded_by_translational_bypass","mRNA_region","mRNA_with_frameshift","mRNA_with_minus_1_frameshift","mRNA_with_minus_2_frameshift","mRNA_with_plus_1_frameshift","mRNA_with_plus_2_frameshift","macronuclear_chromosome","macronucleus_destined_segment","major_TSS","mannosyl_queuosine","match","match_part","maternal_uniparental_disomy","maternally_imprinted_gene","mathematically_defined_repeat","mating_type_M_box","mating_type_region","mating_type_region_motif","mating_type_region_replication_fork_barrier","matrix_attachment_site","mature_protein_region","mature_protein_region_of_CDS","mature_transcript","mature_transcript_region","maxicircle","maxicircle_gene","meiotic_recombination_region","membrane_peptide_loop","membrane_structure","metabolic_island","metal_binding_site","methionine","methionine_tRNA_primary_transcript","methionyl_tRNA","methylated_DNA_base_feature","methylated_adenine","methylated_cytosine","methylation_guide_snoRNA","methylation_guide_snoRNA_gene","methylation_guide_snoRNA_primary_transcript","methylinosine","methylwyosine","miRNA","miRNA_antiguide","miRNA_gene","miRNA_loop","miRNA_primary_transcript","miRNA_primary_transcript_region","miRNA_stem","miRNA_target_site","miR_encoding_Y_RNA_primary_transcript","miR_encoding_lncRNA_primary_transcript","miR_encoding_shRNA_primary_transcript","miR_encoding_snoRNA_primary_transcript","miR_encoding_tRNA_primary_transcript","miR_encoding_vaultRNA_primary_transcript","miRtron","microarray_oligo","micronuclear_chromosome","microsatellite","mini_exon_donor_RNA","mini_gene","minicircle","minicircle_gene","minisatellite","minor_TSS","minus_10_signal","minus_12_signal","minus_1_translational_frameshift","minus_24_signal","minus_2_translational_frameshift","minus_35_signal","mitochondrial_DNA_read","mitochondrial_D_loop","mitochondrial_chromosome","mitochondrial_contig","mitochondrial_control_region","mitochondrial_supercontig","mitochondrial_targeting_signal","mitotic_recombination_region","moR","mobile_element_deletion","mobile_element_insertion","mobile_genetic_element","mobile_intron","modified_DNA_base","modified_L_alanine","modified_L_arginine","modified_L_asparagine","modified_L_aspartic_acid","modified_L_cysteine","modified_L_glutamic_acid","modified_L_glutamine","modified_L_histidine","modified_L_isoleucine","modified_L_leucine","modified_L_lysine","modified_L_methionine","modified_L_phenylalanine","modified_L_proline","modified_L_selenocysteine","modified_L_serine","modified_L_threonine","modified_L_tryptophan","modified_L_tyrosine","modified_L_valine","modified_RNA_base_feature","modified_adenine","modified_adenosine","modified_amino_acid_feature","modified_cytidine","modified_cytosine","modified_glycine","modified_guanine","modified_guanosine","modified_inosine","modified_uridine","molecular_contact_region","monocistronic_mRNA","monocistronic_primary_transcript","monocistronic_transcript","monomeric_repeat","morpholino_oligo","mt_LSU_rRNA","mt_LSU_rRNA_gene","mt_SSU_rRNA","mt_SSU_rRNA_gene","mt_gene","mt_rRNA","mt_rRNA_gene","mt_tRNA","multiplexing_sequence_identifier","mutated_variant_site","mutational_hotspot","n_terminal_region","natural_plasmid","natural_transposable_element","natural_variant_site","ncRNA","ncRNA_gene","nc_conserved_region","nc_primary_transcript","negative_sense_ssRNA_viral_sequence","negatively_autoregulated_gene","nested_repeat","nested_tandem_repeat","nested_transposon","no_output","no_sequence_alteration","non_AUG_initiated_uORF","non_LTR_retrotransposon","non_LTR_retrotransposon_polymeric_tract","non_adjacent_residues","non_allelic_homologous_recombination_region","non_canonical_five_prime_splice_site","non_canonical_start_codon","non_canonical_three_prime_splice_site","non_complimentary_stem","non_cytoplasmic_polypeptide_region","non_processed_pseudogene","non_terminal_residue","non_transcribed_region","nonamer_of_recombination_feature_of_vertebrate_immune_system_gene","noncoding_exon","noncoding_region_of_exon","novel_sequence_insertion","nuclear_chromosome","nuclear_export_signal","nuclear_gene","nuclear_localization_signal","nuclear_mt_pseudogene","nuclear_rim_localization_signal","nuclease_binding_site","nuclease_hypersensitive_site","nuclease_sensitive_site","nucleomorph_gene","nucleomorphic_chromosome","nucleotide_binding_site","nucleotide_cleavage_site","nucleotide_match","nucleotide_motif","nucleotide_to_protein_binding_site","ochre_stop_codon","octamer_motif","oligo","oligo_U_tail","one_methyl_three_three_amino_three_carboxypropyl_pseudouridine","one_methyladenosine","one_methylguanosine","one_methylinosine","one_methylpseudouridine","one_two_prime_O_dimethyladenosine","one_two_prime_O_dimethylguanosine","one_two_prime_O_dimethylinosine","opal_stop_codon","open_chromatin_region","operator","operon","oriC","oriT","oriV","origin_of_replication","orphan_CDS","orthologous_region","outron","overlapping_EST_set","overlapping_feature_set","paired_end_fragment","parallel_beta_strand","paralogous_region","partial_genomic_sequence_assembly","partially_processed_cDNA_clone","paternal_uniparental_disomy","paternally_imprinted_gene","pathogenic_island","peptide_coil","peptide_helix","peptide_localization_signal","peroxywybutosine","phage_sequence","phagemid","phenylalanine","phenylalanine_tRNA_primary_transcript","phenylalanyl_tRNA","pheromone_response_element","phosphorylation_site","piRNA","piRNA_gene","pi_helix","piggyBac_TIR_transposon","plasmid","plasmid_gene","plasmid_vector","plastid_LSU_rRNA","plastid_LSU_rRNA_gene","plastid_SSU_rRNA","plastid_SSU_rRNA_gene","plastid_gene","plastid_rRNA","plastid_rRNA_gene","plus_1_translational_frameshift","plus_2_translational_frameshift","point_centromere","point_mutation","polinton","polyA_primed_cDNA_clone","polyA_sequence","polyA_signal_sequence","polyA_site","polyA_site_cluster","polyadenylated_mRNA","polycistronic_mRNA","polycistronic_primary_transcript","polycistronic_transcript","polymerase_synthesis_read","polymorphic_pseudogene","polymorphic_pseudogene_processed_transcript","polymorphic_pseudogene_with_retained_intron","polypeptide","polypeptide_DNA_contact","polypeptide_binding_motif","polypeptide_calcium_ion_contact_site","polypeptide_catalytic_motif","polypeptide_cobalt_ion_contact_site","polypeptide_conserved_motif","polypeptide_conserved_region","polypeptide_copper_ion_contact_site","polypeptide_domain","polypeptide_iron_ion_contact_site","polypeptide_ligand_contact","polypeptide_magnesium_ion_contact_site","polypeptide_manganese_ion_contact_site","polypeptide_metal_contact","polypeptide_molybdenum_ion_contact_site","polypeptide_motif","polypeptide_nest_left_right_motif","polypeptide_nest_motif","polypeptide_nest_right_left_motif","polypeptide_nickel_ion_contact_site","polypeptide_region","polypeptide_repeat","polypeptide_secondary_structure","polypeptide_sequencing_information","polypeptide_structural_motif","polypeptide_structural_region","polypeptide_tungsten_ion_contact_site","polypeptide_turn_motif","polypeptide_variation_site","polypeptide_zinc_ion_contact_site","polypyrimidine_tract","positional_candidate_gene","positive_sense_ssRNA_viral_sequence","positively_autoregulated_gene","possible_assembly_error","possible_base_call_error","post_translationally_modified_region","post_translationally_regulated_gene","pre_edited_mRNA","pre_edited_region","pre_miRNA","predicted_gene","predicted_transcript","presence_absence_variation","priRNA","primary_transcript","primary_transcript_region","primer","primer_binding_site","primer_match","probe","processed_pseudogene","processed_pseudogenic_rRNA","processed_pseudogenic_tRNA","processed_transcript","prokaryotic_promoter","proline","proline_tRNA_primary_transcript","prolyl_tRNA","promoter","promoter_element","promoter_flanking_region","promoter_targeting_sequence","promoter_trap_construct","propeptide","propeptide_cleavage_site","propeptide_region_of_CDS","prophage","proplastid_gene","protease_site","protein_binding_site","protein_coding_gene","protein_coding_primary_transcript","protein_hmm_match","protein_match","protein_protein_contact","protein_stability_element","proviral_gene","proviral_region","proximal_promoter_element","pseudogene","pseudogene_by_unequal_crossing_over","pseudogene_processed_transcript","pseudogenic_CDS","pseudogenic_exon","pseudogenic_gene_segment","pseudogenic_rRNA","pseudogenic_region","pseudogenic_tRNA","pseudogenic_transcript","pseudogenic_transcript_with_retained_intron","pseudoknot","pseudouridine","pseudouridylation_guide_snoRNA","pseudouridylation_guide_snoRNA_gene","pumilio_response_element","purine_to_pyrimidine_transversion","purine_transition","pyrimidine_to_purine_transversion","pyrimidine_transition","pyrosequenced_read","pyrrolysine","pyrrolysine_tRNA_primary_transcript","pyrrolysyl_tRNA","queuosine","rDNA_intergenic_spacer_element","rDNA_replication_fork_barrier","rRNA","rRNA_21S_gene","rRNA_cleavage_RNA","rRNA_cleavage_snoRNA_primary_transcript","rRNA_gene","rRNA_large_subunit_primary_transcript","rRNA_primary_transcript","rRNA_primary_transcript_region","rRNA_small_subunit_primary_transcript","rare_fragile_site","rasiRNA","read","read_pair","reading_frame","reagent","rearrangement_region","reciprocal_chromosomal_translocation","recoded_codon","recoded_mRNA","recoding_pseudoknot","recoding_stimulatory_region","recombination_enhancer","recombination_feature","recombination_feature_of_rearranged_gene","recombination_hotspot","recombination_regulatory_region","recombination_signal_sequence","recombinationally_inverted_gene","recombinationally_rearranged_gene","recombinationally_rearranged_vertebrate_immune_system_gene","recursive_splice_site","ref_miRNA","region","regional_centromere","regional_centromere_central_core","regional_centromere_inner_repeat_region","regional_centromere_outer_repeat_region","regional_centromere_outer_repeat_transcript","regulatory_promoter_element","regulatory_region","regulon","remark","repeat_component","repeat_fragment","repeat_instability_region","repeat_region","repeat_unit","replication_regulatory_region","replication_start_site","replicon","rescue_gene","rescue_mini_gene","rescue_region","resolution_site","response_element","restriction_enzyme_assembly_scar","restriction_enzyme_binding_site","restriction_enzyme_cleavage_junction","restriction_enzyme_five_prime_single_strand_overhang","restriction_enzyme_recognition_site","restriction_enzyme_region","restriction_enzyme_single_strand_overhang","restriction_enzyme_three_prime_single_strand_overhang","restriction_fragment","retinoic_acid_responsive_element","retrogene","retron","retrotransposon","reverse_Hoogsteen_base_pair","reverse_primer","rho_dependent_bacterial_terminator","rho_independent_bacterial_terminator","ribonuclease_site","ribosome_entry_site","riboswitch","ribothymidine","ribozyme","ribozyme_gene","right_handed_peptide_helix","sORF","sarcin_like_RNA_motif","satellite_DNA","sbRNA","sbRNA_gene","scRNA","scRNA_gene","scRNA_primary_transcript","scaRNA","scaRNA_gene","schellmann_loop","schellmann_loop_seven","schellmann_loop_six","selection_marker","selenocysteine","selenocysteine_tRNA_primary_transcript","selenocysteinyl_tRNA","self_cleaving_ribozyme","sense_intronic_ncRNA","sense_intronic_ncRNA_gene","sense_overlap_ncRNA","sense_overlap_ncRNA_gene","sequence_alteration","sequence_alteration_artifact","sequence_assembly","sequence_comparison","sequence_conflict","sequence_difference","sequence_feature","sequence_length_alteration","sequence_motif","sequence_rearrangement_feature","sequence_secondary_structure","sequence_uncertainty","sequencing_primer","serine","serine_tRNA_primary_transcript","serine_threonine_motif","serine_threonine_staple_motif","serine_threonine_turn","seryl_tRNA","seven_aminomethyl_seven_deazaguanosine","seven_cyano_seven_deazaguanosine","seven_deazaguanosine","seven_methylguanine","seven_methylguanosine","sgRNA","shRNA","shRNA_primary_transcript","shadow_enhancer","short_tandem_repeat_variation","siRNA","signal_anchor","signal_peptide","signal_peptide_region_of_CDS","signature","silenced_gene","silencer","silent_mating_type_cassette_array","simple_operon","simple_regulon","simple_sequence_length_variation","single_strand_restriction_enzyme_cleavage_site","single_stranded_DNA_chromosome","single_stranded_RNA_chromosome","sisRNA","site_specific_recombination_target_region","smFISH_probe","small_regulatory_ncRNA","snRNA","snRNA_gene","snRNA_primary_transcript","sncRNA","sncRNA_gene","snoRNA","snoRNA_gene","snoRNA_primary_transcript","solo_LTR","sonicate_fragment","specific_recombination_site","splice_enhancer","splice_junction","splice_region","splice_site","spliced_leader_RNA","spliceosomal_intron","spliceosomal_intron_region","splicing_regulatory_region","spot_42_RNA","spurious_protein","ss_RNA_viral_sequence","ss_oligo","st_turn_left_handed_type_one","st_turn_left_handed_type_two","st_turn_right_handed_type_one","st_turn_right_handed_type_two","start_codon","stem","stem_loop","stem_loop_region","sterol_regulatory_element","sticky_end_restriction_enzyme_cleavage_site","stop_codon","stop_codon_read_through","stop_codon_redefined_as_pyrrolysine","stop_codon_redefined_as_selenocysteine","stop_codon_signal","structural_alteration","substitution","substitution_artifact","subtelomere","sugar_edge_base_pair","supercontig","symbiosis_island","symmetric_RNA_internal_loop","syntenic_region","synthetic_oligo","tRNA","tRNA_SINE_retrotransposon","tRNA_gene","tRNA_intron","tRNA_primary_transcript","tRNA_region","tag","tandem_duplication","tandem_repeat","target_site_duplication","targeting_vector","tasiRNA","tasiRNA_primary_transcript","teb1_recognition_motif","telomerase_RNA","telomerase_RNA_gene","telomere","telomeric_D_loop","telomeric_repeat","telomeric_transcript","template_region","terminal_inverted_repeat","terminal_inverted_repeat_element","terminal_repeat","terminator","terminator_of_type_2_RNApol_III_promoter","tetraloop","tetranucleotide_repeat_microsatellite_feature","three_methylcytidine","three_methylpseudouridine","three_methyluridine","three_prime_D_heptamer","three_prime_D_nonamer","three_prime_D_recombination_signal_sequence","three_prime_D_spacer","three_prime_EST","three_prime_LTR","three_prime_LTR_component","three_prime_RACE_clone","three_prime_RST","three_prime_UST","three_prime_UTR","three_prime_UTR_intron","three_prime_cis_splice_site","three_prime_clip","three_prime_coding_exon","three_prime_coding_exon_coding_region","three_prime_coding_exon_noncoding_region","three_prime_flanking_region","three_prime_intron","three_prime_noncoding_exon","three_prime_overlapping_ncrna","three_prime_recoding_site","three_prime_repeat_recoding_signal","three_prime_restriction_enzyme_junction","three_prime_stem_loop_structure","three_prime_sticky_end_restriction_enzyme_cleavage_site","three_prime_terminal_inverted_repeat","three_ten_helix","three_three_amino_three_carboxypropyl_uridine","three_two_prime_O_dimethyluridine","threonine","threonine_tRNA_primary_transcript","threonyl_tRNA","tiling_path","tiling_path_clone","tiling_path_fragment","tmRNA","tmRNA_acceptor_piece","tmRNA_coding_piece","tmRNA_gene","tmRNA_primary_transcript","tmRNA_region","tnaORF","topologically_associated_domain","topologically_associated_domain_boundary","topologically_defined_region","trans_splice_acceptor_site","trans_splice_donor_site","trans_splice_junction","trans_splice_site","trans_spliced_mRNA","trans_spliced_transcript","transcribed_cluster","transcribed_fragment","transcribed_processed_pseudogene","transcribed_spacer_region","transcribed_unitary_pseudogene","transcribed_unprocessed_pseudogene","transcript","transcript_bound_by_nucleic_acid","transcript_bound_by_protein","transcript_region","transcript_with_translational_frameshift","transcription_end_site","transcription_factor_regulatory_site","transcription_pause_site","transcription_start_cluster","transcription_termination_signal","transcription_unit","transcriptional_cis_regulatory_region","transgene","transgenic_insertion","transgenic_transposable_element","transit_peptide","transit_peptide_region_of_CDS","transition","translated_nucleotide_match","translated_processed_pseudogene","translated_unprocessed_pseudogene","translation_regulatory_region","translational_frameshift","translationally_regulated_gene","translocation","translocation_breakpoint","translocation_element","transmembrane_helix","transmembrane_polypeptide_region","transposable_element","transposable_element_CDS","transposable_element_flanking_region","transposable_element_gene","transposable_element_insertion_site","transposable_element_pseudogene","transposon_fragment","transversion","trinucleotide_repeat_microsatellite_feature","tryptophan","tryptophan_tRNA_primary_transcript","tryptophanyl_tRNA","twintron","two_methyladenosine","two_methylthio_N6_cis_hydroxyisopentenyl_adenosine","two_methylthio_N6_hydroxynorvalyl_carbamoyladenosine","two_methylthio_N6_isopentenyladenosine","two_methylthio_N6_methyladenosine","two_methylthio_N6_threonyl_carbamoyladenosine","two_prime_O_methyladenosine","two_prime_O_methylcytidine","two_prime_O_methylguanosine","two_prime_O_methylinosine","two_prime_O_methylpseudouridine","two_prime_O_methyluridine","two_prime_O_ribosyladenosine_phosphate","two_prime_O_ribosylguanosine_phosphate","two_thio_two_prime_O_methyluridine","two_thiocytidine","two_thiouridine","tyrosine","tyrosine_tRNA_primary_transcript","tyrosyl_tRNA","uORF","ultracontig","unassigned_supercontig","unconfirmed_transcript","undermodified_hydroxywybutosine","unedited_region","unigene_cluster","unit_of_gene_expression","unitary_pseudogene","unitary_pseudogenic_rRNA","unitary_pseudogenic_tRNA","unprocessed_pseudogenic_rRNA","unprocessed_pseudogenic_tRNA","unspecified_indel","untranslated_region_polycistronic_mRNA","upstream_AUG_codon","uridine_five_oxyacetic_acid","uridine_five_oxyacetic_acid_methyl_ester","vacuolar_sorting_signal","validated_cDNA_clone","valine","valine_tRNA_primary_transcript","valyl_tRNA","vaultRNA_primary_transcript","vault_RNA","vault_RNA_gene","vector_replicon","vertebrate_immune_system_gene","vertebrate_immune_system_gene_recombination_feature","vertebrate_immune_system_gene_recombination_signal_feature","vertebrate_immune_system_gene_recombination_spacer","vertebrate_immune_system_pseudogene","vertebrate_immunoglobulin_T_cell_receptor_gene_cluster","vertebrate_immunoglobulin_T_cell_receptor_rearranged_gene_cluster","vertebrate_immunoglobulin_T_cell_receptor_rearranged_segment","vertebrate_immunoglobulin_T_cell_receptor_segment","viral_promoter","viral_sequence","virtual_sequence","wild_type_rescue_gene","wobble_base_pair","wybutosine","wyosine","zinc_finger_binding_site","zinc_repressed_element"],Xt=function(e){function t(){var e;R(this,t);for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return D(e=T(this,t,[].concat(r)),"name","Core"),e}return M(t,e),I(t,[{key:"frontendPreValidate",value:(r=k(U().m((function e(t){var n,r,o;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:if(!("oldType"in(i=t))||!("newType"in i)){e.n=7;break}n=j(t.changes),e.p=1,n.s();case 2:if((r=n.n()).done){e.n=4;break}if(Yt.includes((o=r.value).newType)){e.n=3;break}return e.a(2,{validationName:this.name,error:{message:'"'.concat(o.newType,'" is not a valid SO sequence_feature term')}});case 3:e.n=2;break;case 4:e.n=6;break;case 5:e.p=5,n.e(e.v);case 6:return e.p=6,n.f(),e.f(6);case 7:return e.a(2,{validationName:this.name})}var i}),e,this,[[1,5,6,7]])}))),function(e){return r.apply(this,arguments)})},{key:"possibleValues",value:(n=k(U().m((function e(t){return U().w((function(e){for(;;)switch(e.n){case 0:if("type"!==t){e.n=1;break}return e.a(2,Yt);case 1:return e.a(2)}}),e)}))),function(e){return n.apply(this,arguments)})}]);var n,r}(Vt),Zt=function(e){function t(){var e;R(this,t);for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return D(e=T(this,t,[].concat(r)),"name","ParentChildValidation"),e}return M(t,e),I(t,[{key:"backendPostValidate",value:(r=k(U().m((function e(t,n){var r,o;return U().w((function(e){for(;;)switch(e.n){case 0:if(r=n.featureModel,o=n.session,!Rt(t)&&!It(t)){e.n=1;break}return e.a(2,this.validateParentChildRelationships(t,{session:o,featureModel:r}));case 1:return e.a(2,{validationName:this.name})}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"validateParentChildRelationships",value:(n=k(U().m((function e(t,n){var r,o,i,a,s,l,c,u,d;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:r=n.featureModel,o=n.session,i=[],a=j(t.changes),e.p=1,l=U().m((function e(){var t,n,a;return U().w((function(e){for(;;)switch(e.n){case 0:return t=s.value.featureId,e.n=1,r.findOne({allIds:t}).session(o).exec();case 1:if(n=e.v){e.n=2;break}throw a="ERROR: The following featureId was not found in database ='".concat(t,"'"),new Error(a);case 2:i.some((function(e){return e._id===n._id}))||i.push(n);case 3:return e.a(2)}}),e)})),a.s();case 2:if((s=a.n()).done){e.n=4;break}return e.d($(l()),3);case 3:e.n=2;break;case 4:e.n=6;break;case 5:e.p=5,a.e(e.v);case 6:return e.p=6,a.f(),e.f(6);case 7:c=0,u=i;case 8:if(!(c<u.length)){e.n=12;break}d=u[c],e.p=9,this.checkChildFeatureBoundaries(d),e.n=11;break;case 10:return e.p=10,e.a(2,{validationName:this.name,error:{message:String(e.v)}});case 11:c++,e.n=8;break;case 12:return e.a(2,{validationName:this.name})}}),e,this,[[9,10],[1,5,6,7]])}))),function(e,t){return n.apply(this,arguments)})},{key:"checkChildFeatureBoundaries",value:function(e){if(e.children){var t,n=j(e.children||new Map);try{for(n.s();!(t=n.n()).done;){var r=G(t.value,2)[1];if(null!==e.min&&null!==e.max&&null!==r.min&&null!==r.max&&(r.max>e.max||r.min<e.min))throw new Error("Feature ".concat(Ft(r)," exceeds the bounds of its parent, ").concat(Ft(e)));this.checkChildFeatureBoundaries(r)}}catch(e){n.e(e)}finally{n.f()}}}}]);var n,r}(Vt);function Qt(e){this.message=e}(Qt.prototype=new Error).name="InvalidCharacterError";var en,tn,nn="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new Qt("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,r,o=0,i=0,a="";r=t.charAt(i++);~r&&(n=o%4?64*n+r:r,o++%4)?a+=String.fromCharCode(255&n>>(-2*o&6)):0)r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(r);return a};function rn(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(nn(e).replace(/(.)/g,(function(e,t){var n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(t)}catch(e){return nn(t)}}function on(e){this.message=e}function an(e,t){if("string"!=typeof e)throw new on("Invalid token specified");var n=!0===(t=t||{}).header?0:1;try{return JSON.parse(rn(e.split(".")[n]))}catch(e){throw new on("Invalid token specified: "+e.message)}}function sn(e){var t="string"==typeof e?an(e):e;return"".concat(t.id,"-").concat(t.iat)}function ln(e){return an(e)}function cn(e){var t,n,r=null===(t=e.attributes)||void 0===t||null===(t=t.gff_id)||void 0===t?void 0:t.join(", ");if(r)return"".concat(r," (_id: ").concat(e._id,")");var o=null===(n=e.attributes)||void 0===n||null===(n=n.gff_name)||void 0===n?void 0:n.join(", ");return o?"".concat(o," (_id: ").concat(e._id,")"):"_id: ".concat(e._id)}(on.prototype=new Error).name="InvalidTokenError",function(e){e[e.TAG=0]="TAG",e[e.TAA=1]="TAA",e[e.TGA=2]="TGA"}(en||(en={})),function(e){e[e.ATG=0]="ATG"}(tn||(tn={}));var un,dn="CDSCheck";!function(e){e[e.InternalStopCodon=0]="InternalStopCodon",e[e.MissingStartCodon=1]="MissingStartCodon",e[e.MissingStopCodon=2]="MissingStopCodon"}(un||(un={}));var fn={G:"C",A:"T",T:"A",C:"G",R:"Y",Y:"R",M:"K",K:"M",S:"S",W:"W",H:"D",B:"V",V:"B",D:"H",N:"N"};function hn(e){var t,n=[],r=j(e);try{for(r.s();!(t=r.n()).done;){var o=t.value,i=fn[o.toUpperCase()];if(void 0===i)throw new TypeError('Cannot complement nucleotide: "'.concat(o,'"'));o===o.toLowerCase()?n.push(i.toLowerCase()):n.push(i)}}catch(e){r.e(e)}finally{r.f()}return n.reverse().join("")}function pn(e,t,n){return gn.apply(this,arguments)}function gn(){return(gn=k(U().m((function e(t,n,r){var o;return U().w((function(e){for(;;)switch(e.n){case 0:return e.n=1,Promise.all(t.map((function(e){return r(e.min,e.max)})));case 1:return o=e.v.join(""),-1===n&&(o=hn(o)),e.a(2,o)}}),e)})))).apply(this,arguments)}function mn(e){for(var t=[],n=0;n<=e.length-3;n+=3)t.push(e.slice(n,n+3));return t}function yn(e,t,n){return-1===n?e>t:e<t}function _n(e,t,n){for(var r,o,i=e.toSorted(-1===t?function(e,t){return e.min<t.min?1:-1}:function(e,t){return e.min<t.min?-1:1}),a=0,s=0;s<i.length;s++)for(var l=i[s],c=l.phase,u=-1===t?l.min:l.max,d=-1===t?l.max-c:l.min+c;yn(d,u,t);d=-1===t?d-3:d+3){if(r=d,o=-1===t?r-3:r+3,-1===t&&o<l.min?o=i[s+1].max-i[s+1].phase:o>l.max&&(o=i[s+1].min+i[s+1].phase),a===n)return[r,o].sort((function(e,t){return e-t}));a++}}function vn(e,t){return bn.apply(this,arguments)}function bn(){return(bn=k(U().m((function e(t,n){var r,o,i,a,s,l,c,u,d,f,h,p,g,m,y,_,v,b,x,w,S,C,A,k,N,T,R,E,I,D,O,F,M,L;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:if(r=[],o=t._id,i=t.max,a=t.min,s=t.refSeq,l=t.strand,c=xn(t)){e.n=1;break}return e.a(2,r);case 1:u=[o],d=j(c),e.p=2,d.s();case 3:if((f=d.n()).done){e.n=13;break}return y=f.value,e.n=4,pn(y,l,n);case 4:v=mn(_=e.v),b=-1===l?null!==(h=null===(p=y.at(0))||void 0===p?void 0:p.min)&&void 0!==h?h:a:null!==(g=null===(m=y.at(-1))||void 0===m?void 0:m.max)&&void 0!==g?g:i,_.length%3==0?((x=v.at(0))&&!(x.toUpperCase()in tn)&&(k=-1===l?null!==(w=null===(S=y.at(-1))||void 0===S?void 0:S.max)&&void 0!==w?w:i:null!==(C=null===(A=y.at(0))||void 0===A?void 0:A.min)&&void 0!==C?C:a,k=-1===l?k-3:k,r.push({_id:(new at).toHexString(),name:dn,cause:un[un.MissingStartCodon],ids:u,refSeq:s,start:k,end:k,message:'Unexpected start codon "'.concat(x,'" in feature "').concat(cn(t),'": ')})),(N=v.at(-1))&&!(N.toUpperCase()in en)&&r.push({_id:(new at).toHexString(),name:dn,cause:un[un.MissingStopCodon],ids:u,refSeq:s,start:b,end:b,message:'Missing stop codon in feature "'.concat(cn(t),'"')})):r.push({_id:(new at).toHexString(),name:dn,cause:un[un.MissingStopCodon],ids:u,refSeq:s,start:b,end:b,message:'Missing stop codon in feature "'.concat(cn(t),'"')}),T=j(v.entries()),e.p=5,T.s();case 6:if((R=T.n()).done){e.n=9;break}if(E=G(R.value,2),D=E[1],(I=E[0])!==v.length-1){e.n=7;break}return e.a(3,9);case 7:(O=_n(y,l,I))&&D.toUpperCase()in en&&(F=G(O,2),M=F[0],L=F[1],r.push({_id:(new at).toHexString(),name:dn,cause:un[un.InternalStopCodon],ids:u,refSeq:s,start:M,end:L,message:'Internal stop codon in feature "'.concat(cn(t),'"')}));case 8:e.n=6;break;case 9:e.n=11;break;case 10:e.p=10,T.e(e.v);case 11:return e.p=11,T.f(),e.f(11);case 12:e.n=3;break;case 13:e.n=15;break;case 14:e.p=14,d.e(e.v);case 15:return e.p=15,d.f(),e.f(15);case 16:return e.a(2,r)}}),e,null,[[5,10,11,12],[2,14,15,16]])})))).apply(this,arguments)}function xn(e){if("mRNA"===e.type){var t=e.children,n=e.strand;if(t){var r=Object.values(t).filter((function(e){return"CDS"===e.type}));if(0!==r.length){var i,a=[],s=j(r);try{var l=function(){for(var e=i.value,r=e.max,s=e.min,l=[],c=0,u=Object.values(t);c<u.length;c++){var d=u[c];if("exon"===d.type){var f=G(o.intersection2(s,r,d.min,d.max),2),h=f[0],p=f[1];void 0!==h&&void 0!==p&&l.push({min:h,max:p})}}l.sort((function(e,t){return e.min-t.min})),-1===n&&l.reverse();var g=0,m=l.map((function(e){var t=g;return g=(3-(e.max-e.min-t+3)%3)%3,B(B({},e),{},{phase:t})}));m.sort((function(e,t){return e.min<t.min?-1:1})),a.push(m)};for(s.s();!(i=s.n()).done;)l()}catch(e){s.e(e)}finally{s.f()}return a.length>1&&a.sort((function(e,t){return e[0].min<t[0].min?-1:1})),a}}}}var wn,Sn=function(e){function t(){var e;R(this,t);for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return D(e=T(this,t,[].concat(r)),"name",dn),D(e,"causes",Object.values(un).filter((function(e){return Number.isNaN(Number(e))}))),D(e,"version",1),D(e,"isDefault",!0),e}return M(t,e),I(t,[{key:"checkFeature",value:(n=k(U().m((function e(t,n){var r,o,i,a,s,l,c;return U().w((function(e){for(;;)switch(e.n){case 0:if("mRNA"!==t.type){e.n=1;break}return e.a(2,vn(t,n));case 1:if(t.children){e.n=2;break}return e.a(2,[]);case 2:r=[],o=0,i=Object.values(t.children);case 3:if(!(o<i.length)){e.n=6;break}return a=i[o],s=r.push,l=r,c=W,e.n=4,this.checkFeature(a,n);case 4:s.apply.call(s,l,c(e.v));case 5:o++,e.n=3;break;case 6:return e.a(2,r)}}),e,this)}))),function(e,t){return n.apply(this,arguments)})}]);var n}(dt);!function(e){e[e.NonCanonicalSpliceSiteAtFivePrime=0]="NonCanonicalSpliceSiteAtFivePrime",e[e.NonCanonicalSpliceSiteAtThreePrime=1]="NonCanonicalSpliceSiteAtThreePrime"}(wn||(wn={}));var Cn="TranscriptCheck";function An(e,t){return kn.apply(this,arguments)}function kn(){return kn=k(U().m((function e(t,n){var r,i,a,s,l,c,u,d,f,h,p,g;return U().w((function(e){for(;;)switch(e.n){case 0:if(t.children){e.n=1;break}return e.a(2,[]);case 1:for(r=[],i=0,a=Object.entries(t.children);i<a.length;i++)s=G(a[i],2),"exon"===(l=s[1]).type&&r.push(l);if(!(r.length<2)){e.n=2;break}return e.a(2,[]);case 2:r.sort((function(e,t){return e.min<t.min?-1:1})),c=[],u=0;case 3:if(!(u<r.length-1)){e.n=7;break}return d=r[u].max,f=r[u+1].min,-1===t.strand?(f=(h=[d,f])[0],d=h[1],d-=2):f-=2,e.n=4,n(d,d+2);case 4:return p=e.v,e.n=5,n(f,f+2);case 5:g=e.v,-1===t.strand&&(g=o.revcom(g),p=o.revcom(p)),c.push({fivePrimeSeq:p,fivePrimeMin:d,threePrimeSeq:g,threePrimeMin:f});case 6:u++,e.n=3;break;case 7:return e.a(2,c)}}),e)}))),kn.apply(this,arguments)}function Nn(e,t){return Tn.apply(this,arguments)}function Tn(){return(Tn=k(U().m((function e(t,n){var r,o,i,a,s,l;return U().w((function(e){for(;;)switch(e.n){case 0:return r=[],o=new Set(["GT"]),i=new Set(["AG"]),e.n=1,An(t,n);case 1:a=j(e.v);try{for(a.s();!(s=a.n()).done;)o.has((l=s.value).fivePrimeSeq.toUpperCase())||r.push({_id:(new at).toHexString(),name:Cn,cause:wn[wn.NonCanonicalSpliceSiteAtFivePrime],ids:[t._id],refSeq:t.refSeq,start:l.fivePrimeMin,end:l.fivePrimeMin+2,message:'Unexpected 5′ splice site in "'.concat(cn(t),'". Expected: ').concat(W(o).join("|"),", got: ").concat(l.fivePrimeSeq)}),i.has(l.threePrimeSeq.toUpperCase())||r.push({_id:(new at).toHexString(),name:Cn,cause:wn[wn.NonCanonicalSpliceSiteAtThreePrime],ids:[t._id],refSeq:t.refSeq,start:l.threePrimeMin,end:l.threePrimeMin+2,message:'Unexpected 3′ splice site in "'.concat(cn(t),'". Expected: ').concat(W(i).join("|"),", got: ").concat(l.threePrimeSeq)})}catch(e){a.e(e)}finally{a.f()}return e.a(2,r)}}),e)})))).apply(this,arguments)}var Rn=function(e){function t(){var e;R(this,t);for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return D(e=T(this,t,[].concat(r)),"name","TranscriptCheck"),D(e,"causes",Object.values(wn).filter((function(e){return Number.isNaN(Number(e))}))),D(e,"version",1),D(e,"isDefault",!0),e}return M(t,e),I(t,[{key:"checkFeature",value:(n=k(U().m((function e(t,n){var r,o,i,a,s,l,c;return U().w((function(e){for(;;)switch(e.n){case 0:if("mRNA"!==t.type&&"transcript"!==t.type&&"pseudogenic_transcript"!==t.type){e.n=1;break}return e.a(2,Nn(t,n));case 1:if(t.children){e.n=2;break}return e.a(2,[]);case 2:r=[],o=0,i=Object.values(t.children);case 3:if(!(o<i.length)){e.n=6;break}return a=i[o],s=r.push,l=r,c=W,e.n=4,this.checkFeature(a,n);case 4:s.apply.call(s,l,c(e.v));case 5:o++,e.n=3;break;case 6:return e.a(2,r)}}),e,this)}))),function(e,t){return n.apply(this,arguments)})}]);var n}(dt);function En(e,t,n){var r;return("apollo_feature_container"===e.type?Object.values(null!==(r=e.children)&&void 0!==r?r:{}):[e]).map((function(e){var n,r,o,i,a,s=JSON.parse(JSON.stringify(null!==(n=e.attributes)&&void 0!==n?n:{})),l=[],c=null!==(r=null===(o=e.attributes)||void 0===o||null===(o=o.gff_source)||void 0===o?void 0:o[0])&&void 0!==r?r:null;delete s.gff_source,t&&(s.Parent=[t]),s.gff_id?(s.ID=s.gff_id,delete s.gff_id):e.children&&(s.ID=[e._id]),s.gff_name&&(s.Name=s.gff_name,delete s.gff_name),s.gff_alias&&(s.Alias=s.gff_alias,delete s.gff_alias),s.gff_target&&(s.Target=s.gff_target,delete s.gff_target),s.gff_gap&&(s.Gap=s.gff_gap,delete s.gff_gap),s.gff_derives_from&&(s.Derives_from=s.gff_derives_from,delete s.gff_derives_from),s.gff_note&&(s.Note=s.gff_note,delete s.gff_note),s.gff_dbxref&&(s.Dbxref=s.gff_dbxref,delete s.gff_dbxref),s.gff_is_circular&&(s.Is_circular=s.gff_is_circular,delete s.gff_is_circular),s.gff_ontology_term&&(l.push.apply(l,W(s.gff_ontology_term)),delete s.gff_ontology_term),s["Gene Ontology"]&&(l.push.apply(l,W(s["Gene Ontology"])),delete s["Gene Ontology"]),s["Sequence Ontology"]&&(l.push.apply(l,W(s["Sequence Ontology"])),delete s["Sequence Ontology"]),l.length>0&&(s.Ontology_term=l);var u=null===(i=e.attributes)||void 0===i?void 0:i.gff_score,d=null;return u&&u.length>0&&(u[0]&&(d=Number(u[0]),Number.isNaN(d)&&(d=null)),delete s.gff_score),{start:e.min+1,end:e.max,seq_id:e.refSeq,source:c,type:e.type,score:d,strand:e.strand?1===e.strand?"+":"-":null,phase:null,attributes:Object.keys(s).length>0?s:null,derived_features:[],child_features:In(e,null===(a=s.ID)||void 0===a?void 0:a[0])}}))}function In(e,t,n){if(!e.children)return[];if("mRNA"===e.type){for(var r=[],i=function(e){var t;try{t=function(e){if("mRNA"!==e.type)throw new Error('Only features of type "mRNA" or equivalent can calculate CDS locations');if(!e.children)throw new Error("no CDS or exons in mRNA");var t=Object.values(e.children),n=t.filter((function(e){return"CDS"===e.type}));if(0===n.length)throw new Error("no CDS in mRNA");var r,i=[],a=j(n);try{var s=function(){for(var n=r.value,a=n.max,s=n.min,l=[],c=!1,u=[],d=0,f=t;d<f.length;d++){var h=f[d];"exon"===h.type&&u.push({min:h.min,max:h.max})}u.sort((function(e,t){return e.min-t.min}));for(var p=0,g=u;p<g.length;p++){var m=g[p],y=l.at(-1);y&&l.push({min:y.max,max:m.min,type:"intron"});var _,v=G(o.intersection2(s,a,m.min,m.max),2),b=v[0],x=v[1];_=c?1===e.strand?"threePrimeUTR":"fivePrimeUTR":1===e.strand?"fivePrimeUTR":"threePrimeUTR",void 0!==b&&void 0!==x?(c=!0,b===m.min&&x===m.max?l.push({min:b,max:x,phase:0,type:"CDS"}):b===m.min?l.push({min:b,max:x,phase:0,type:"CDS"},{min:x,max:m.max,type:_}):x===m.max?l.push({min:m.min,max:b,type:_},{min:b,max:x,phase:0,type:"CDS"}):l.push({min:m.min,max:b,type:_},{min:b,max:x,phase:0,type:"CDS"},{min:x,max:m.max,type:"fivePrimeUTR"===_?"threePrimeUTR":"fivePrimeUTR"})):l.push({min:m.min,max:m.max,type:_})}l.sort((function(e,t){return e.min-t.min})),-1===e.strand&&l.reverse();var w=0,S=l.map((function(e){if("CDS"!==e.type)return e;var t=w;return w=(3-(e.max-e.min-t+3)%3)%3,B(B({},e),{},{phase:t})}));i.push(S)};for(a.s();!(r=a.n()).done;)s()}catch(e){a.e(e)}finally{a.f()}return i}(e)}catch(e){return[]}return t.map((function(e){return e.filter((function(e){return"CDS"===e.type}))}))}(e),a=0,s=0,l=Object.values(e.children);s<l.length;s++){var c=l[s],u=En(c,t);if("CDS"===c.type){var d,f=j(i[a]);try{for(f.s();!(d=f.n()).done;){var h=d.value,p=JSON.parse(JSON.stringify(u));if(1!=p.length)throw new Error("Unexpected CDS: ".concat(JSON.stringify(p,null,2)));p[0].start=h.min+1,p[0].end=h.max,p[0].phase=h.phase.toString(),p[0].type=h.type,r.push(p)}}catch(e){f.e(e)}finally{f.f()}a++}else r.push(u)}return r}return Object.values(e.children).map((function(e){return En(e,t)}))}var jn={ID:"gff_id",Name:"gff_name",Alias:"gff_alias",Parent:"gff_parent",Target:"gff_target",Gap:"gff_gap",Derives_from:"gff_derives_from",Note:"gff_note",Dbxref:"gff_dbxref",Ontology_term:"gff_ontology_term",Is_circular:"gff_is_circular"},Dn={gff_id:"ID",gff_name:"Name",gff_alias:"Alias",gff_parent:"Parent",gff_target:"Target",gff_gap:"Gap",gff_derives_from:"Derives_from",gff_note:"Note",gff_dbxref:"Dbxref",gff_ontology_term:"Ontology_term",gff_is_circular:"Is_circular"},On={gff_score:"score",gff_source:"source"};function Fn(e,t){var n=G(e,1)[0],r=n.end,i=n.seq_id,a=n.start,s=n.strand;if(!i)throw new Error("feature does not have seq_id: ".concat(JSON.stringify(n)));if(null===a)throw new Error("feature does not have start: ".concat(JSON.stringify(n)));if(null===r)throw new Error("feature does not have end: ".concat(JSON.stringify(n)));var l=function(e){var t=e.map((function(e){return e.start})).filter((function(e){return null!==e})),n=e.map((function(e){return e.end})).filter((function(e){return null!==e}));return[Math.min.apply(Math,W(t))-1,Math.max.apply(Math,W(n))]}(e),c=G(l,2),u=c[0],d=c[1],f=function(e,t,n){var r={},i=e.filter((function(e){return e.child_features.length>0}));if(i.length>1)throw new Error("Features with multiple locations may not have children");if(e.length>1&&"CDS"!==e[0].type){var a,s=j(e);try{for(s.s();!(a=s.n()).done;){var l=Fn([a.value],t);r[l._id]=l}}catch(e){s.e(e)}finally{s.f()}return r}if(0!==i.length){var c,u=[],d=[],f=[],h=j(G(i,1)[0].child_features);try{for(h.s();!(c=h.n()).done;){var p=c.value,g=G(p,1)[0];if("exon"===g.type&&d.push(p),"three_prime_UTR"!==g.type&&"five_prime_UTR"!==g.type||f.push(p),"three_prime_UTR"!==g.type&&"five_prime_UTR"!==g.type&&"intron"!==g.type&&"start_codon"!==g.type&&"stop_codon"!==g.type)if("CDS"===g.type)u.push(p);else{var m=Fn(p,t);r[m._id]=m}}}catch(e){h.e(e)}finally{h.f()}if(u.length>0){var y,_=function(e,t){var n=e.map((function(e){return e.length}));if(n.some((function(e){return e>1})))return e.map((function(e){return Fn(e,t)}));var r=e.map((function(e){return e[0]})).filter((function(e){return null!==e.start&&null!==e.end})).sort((function(e,t){return e.start-t.start}));if(!r.some((function(e,t){var n=r.at(t+1);return!!n&&o.doesIntersect2(e.start,e.end,n.start,n.end)})))return[Fn(r,t)];var i,a=e.map((function(e){return e[0]})),s=[],l=j(a);try{var c=function(){var e=i.value,t=s.at(-1);if(!t)return s.push([e]),1;t.some((function(t){return o.doesIntersect2(t.start,t.end,e.start,e.end)}))?s.push([e]):t.push(e)};for(l.s();!(i=l.n()).done;)c()}catch(e){l.e(e)}finally{l.f()}return s.map((function(e){return Fn(e,t)}))}(u,t),v=j(_);try{for(v.s();!(y=v.n()).done;){var b=y.value;r[b._id]=b}}catch(e){v.e(e)}finally{v.f()}var x,w=function(e,t,n,r,o){var i,a=[],s=j(n);try{for(s.s();!(i=s.n()).done;){var l,c=j(i.value);try{for(c.s();!(l=c.n()).done;){var u=l.value;if(!u.start||!u.end)throw new Error("UTR has undefined start and/or end\n: ".concat(JSON.stringify(u,null,2)));var d=void 0;"+"===u.strand?d=1:"-"===u.strand&&(d=-1),a.push({_id:(new at).toHexString(),refSeq:r,type:"exon",min:u.start-1,max:u.end,strand:d})}}catch(e){c.e(e)}finally{c.f()}}}catch(e){s.e(e)}finally{s.f()}a.sort((function(e,t){return e.min-t.min}));var f,h=[],p=j(e);try{for(p.s();!(f=p.n()).done;){var g=f.value;g.sort((function(e,t){if(!e.start||!t.start)throw new Error("CDS has undefined start");return e.start-t.start}));for(var m=0;m<g.length;m++){var y,_=g[m],v=!1,b=j(t);try{for(b.s();!(y=b.n()).done;){var x=y.value;if(1!=x.length)throw new Error("Unexpected number of exons");var w=G(x,1)[0];if(w.start&&w.end&&_.start&&_.end&&w.start<=_.start&&w.end>=_.end){v=!0;break}}}catch(e){b.e(e)}finally{b.f()}if(!v){if(!_.start||!_.end)throw new Error("CDS has undefined start and/or end: ".concat(JSON.stringify(_,null,2)));var S=void 0;"+"===_.strand?S=1:"-"===_.strand&&(S=-1);var C={_id:(new at).toHexString(),refSeq:r,type:"exon",min:_.start-1,max:_.end,strand:S};if(0===m){var A,k=j(a);try{for(k.s();!(A=k.n()).done;){var N=A.value;if(N.max>C.min)break;N.max===C.min?C.min=N.min:h.push(N)}}catch(e){k.e(e)}finally{k.f()}}if(m===g.length-1){var T,R=j(a);try{for(R.s();!(T=R.n()).done;){var E=T.value;E.min<C.max||(E.min===C.max?C.max=E.max:h.push(E))}}catch(e){R.e(e)}finally{R.f()}}h.push(C)}}}}catch(e){p.e(e)}finally{p.f()}var I=function(e){if(0===e.length)return[];e.sort((function(e,t){return e.min-t.min}));var t=[];t.push(e[0]);for(var n=1;n<e.length;n++){var r=t.at(-1),o=e[n];r&&o.min<=r.max?r.max=Math.max(r.max,o.max):t.push(o)}return t}(h);return I}(u,d,f,_[0].refSeq),S=j(w);try{for(S.s();!(x=S.n()).done;){var C=x.value;r[C._id]=C}}catch(e){S.e(e)}finally{S.f()}}return Object.keys(r).length>0?r:void 0}}(e,t),h=function(e){var t={},n=e.map((function(e){return e.score})).filter((function(e){return null!==e})),r=e.map((function(e){return e.source})).filter((function(e){return null!==e})),o=e.map((function(e){return e.attributes})).filter((function(e){return null!==e}));if(n.length>0){var i=G(n,1)[0];n.length>1&&(i=n.reduce((function(e,t){return e+t}),0)/n.length),t.gff_score=[String(i)]}if(r.length>0){var a=G(r,1)[0];r.length>1&&(a=W(new Set(r)).join(",")),t.gff_source=[a]}if(o.length>0){var s,l=j(o);try{for(l.s();!(s=l.n()).done;)for(var c=0,u=Object.entries(s.value);c<u.length;c++){var d=G(u[c],2),f=d[0],h=d[1];if("Parent"!==f){var p=f in jn?jn[f]:f,g=t[p];if(g){var m=new Set([].concat(W(g),W(h)));t[p]=W(m)}else t[p]=h}}}catch(e){l.e(e)}finally{l.f()}}if(Object.keys(t).length>0)return t}(e),p={_id:(new at).toHexString(),refSeq:i,type:Mn(e),min:u,max:d};if(s)if("+"===s)p.strand=1;else{if("-"!==s)throw new Error('Unknown strand: "'.concat(s,'"'));p.strand=-1}return f&&(p.children=f),h&&(p.attributes=h),p}function Mn(e){var t=G(e,1)[0];if(1===e.length||"CDS"===t.type){var n=t.type;if(!n)throw new Error("feature does not have type: ".concat(JSON.stringify(t)));return n}return"apollo_feature_container"}var Ln=a.createSvgIcon(i.jsx("path",{d:"M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6z"}),"Add");const Pn=n.ConfigurationSchema("ApolloInternetAccount",{baseURL:{description:"Location of Apollo server",type:"string",defaultValue:""},tokenType:{description:"A custom name for a token to include in the header",type:"string",defaultValue:"Bearer"}},{baseConfiguration:r.BaseInternetAccountConfig,explicitlyTyped:!0});var Bn=Object.create(null);Bn.open="0",Bn.close="1",Bn.ping="2",Bn.pong="3",Bn.message="4",Bn.upgrade="5",Bn.noop="6";var qn=Object.create(null);Object.keys(Bn).forEach((function(e){qn[Bn[e]]=e}));var Un,zn={type:"error",data:"parser error"},$n="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Object.prototype.toString.call(Blob),Hn="function"==typeof ArrayBuffer,Gn=function(e){return"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer},Vn=function(e,t,n){var r=e.type,o=e.data;return $n&&o instanceof Blob?t?n(o):Wn(o,n):Hn&&(o instanceof ArrayBuffer||Gn(o))?t?n(o):Wn(new Blob([o]),n):n(Bn[r]+(o||""))},Wn=function(e,t){var n=new FileReader;return n.onload=function(){var e=n.result.split(",")[1];t("b"+(e||""))},n.readAsDataURL(e)};function Jn(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}for(var Kn="undefined"==typeof Uint8Array?[]:new Uint8Array(256),Yn=0;Yn<64;Yn++)Kn["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charCodeAt(Yn)]=Yn;var Xn,Zn="function"==typeof ArrayBuffer,Qn=function(e,t){if("string"!=typeof e)return{type:"message",data:tr(e,t)};var n=e.charAt(0);return"b"===n?{type:"message",data:er(e.substring(1),t)}:qn[n]?e.length>1?{type:qn[n],data:e.substring(1)}:{type:qn[n]}:zn},er=function(e,t){if(Zn){var n=function(e){var t,n,r,o,i,a=.75*e.length,s=e.length,l=0;"="===e[e.length-1]&&(a--,"="===e[e.length-2]&&a--);var c=new ArrayBuffer(a),u=new Uint8Array(c);for(t=0;t<s;t+=4)n=Kn[e.charCodeAt(t)],r=Kn[e.charCodeAt(t+1)],o=Kn[e.charCodeAt(t+2)],i=Kn[e.charCodeAt(t+3)],u[l++]=n<<2|r>>4,u[l++]=(15&r)<<4|o>>2,u[l++]=(3&o)<<6|63&i;return c}(e);return tr(n,t)}return{base64:!0,data:e}},tr=function(e,t){return"blob"===t?e instanceof Blob?e:new Blob([e]):e instanceof ArrayBuffer?e:e.buffer},nr=String.fromCharCode(30);function rr(e){return e.reduce((function(e,t){return e+t.length}),0)}function or(e,t){if(e[0].length===t)return e.shift();for(var n=new Uint8Array(t),r=0,o=0;o<t;o++)n[o]=e[0][r++],r===e[0].length&&(e.shift(),r=0);return e.length&&r<e[0].length&&(e[0]=e[0].slice(r)),n}function ir(e){if(e)return function(e){for(var t in ir.prototype)e[t]=ir.prototype[t];return e}(e)}ir.prototype.on=ir.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},ir.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},ir.prototype.off=ir.prototype.removeListener=ir.prototype.removeAllListeners=ir.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var o=0;o<r.length;o++)if((n=r[o])===t||n.fn===t){r.splice(o,1);break}return 0===r.length&&delete this._callbacks["$"+e],this},ir.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),n=this._callbacks["$"+e],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(n){r=0;for(var o=(n=n.slice(0)).length;r<o;++r)n[r].apply(this,t)}return this},ir.prototype.emitReserved=ir.prototype.emit,ir.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},ir.prototype.hasListeners=function(e){return!!this.listeners(e).length};var ar=function(){return"undefined"!=typeof self?self:"undefined"!=typeof window?window:Function("return this")()}();function sr(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return n.reduce((function(t,n){return e.hasOwnProperty(n)&&(t[n]=e[n]),t}),{})}var lr=ar.setTimeout,cr=ar.clearTimeout;function ur(e,t){t.useNativeTimers?(e.setTimeoutFn=lr.bind(ar),e.clearTimeoutFn=cr.bind(ar)):(e.setTimeoutFn=ar.setTimeout.bind(ar),e.clearTimeoutFn=ar.clearTimeout.bind(ar))}var dr,fr=function(e){function t(e,n,r){var o;return R(this,t),(o=T(this,t,[e])).description=n,o.context=r,o.type="TransportError",o}return M(t,e),I(t)}(Z(Error)),hr=function(e){function t(e){var n;return R(this,t),(n=T(this,t)).writable=!1,ur(n,e),n.opts=e,n.query=e.query,n.socket=e.socket,n}return M(t,e),I(t,[{key:"onError",value:function(e,n,r){return V(t,"emitReserved",this,3)(["error",new fr(e,n,r)]),this}},{key:"open",value:function(){return this.readyState="opening",this.doOpen(),this}},{key:"close",value:function(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this}},{key:"send",value:function(e){"open"===this.readyState&&this.write(e)}},{key:"onOpen",value:function(){this.readyState="open",this.writable=!0,V(t,"emitReserved",this,3)(["open"])}},{key:"onData",value:function(e){var t=Qn(e,this.socket.binaryType);this.onPacket(t)}},{key:"onPacket",value:function(e){V(t,"emitReserved",this,3)(["packet",e])}},{key:"onClose",value:function(e){this.readyState="closed",V(t,"emitReserved",this,3)(["close",e])}},{key:"pause",value:function(e){}},{key:"createUri",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}},{key:"_hostname",value:function(){var e=this.opts.hostname;return-1===e.indexOf(":")?e:"["+e+"]"}},{key:"_port",value:function(){return this.opts.port&&(this.opts.secure&&Number(443!==this.opts.port)||!this.opts.secure&&80!==Number(this.opts.port))?":"+this.opts.port:""}},{key:"_query",value:function(e){var t=function(e){var t="";for(var n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t}(e);return t.length?"?"+t:""}}])}(ir),pr="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),gr=64,mr=0;function yr(e){var t="";do{t=pr[e%gr]+t,e=Math.floor(e/gr)}while(e>0);return t}function _r(){var e=yr(+new Date);return e!==dr?(mr=0,dr=e):e+"."+yr(mr++)}var vr=!1;try{vr="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(e){}var br=vr;function xr(e){var t=e.xdomain;try{if("undefined"!=typeof XMLHttpRequest&&(!t||br))return new XMLHttpRequest}catch(e){}if(!t)try{return new(ar[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(e){}}function wr(){}var Sr=function(){return null!=new xr({xdomain:!1}).responseType}(),Cr=function(e){function t(e){var n;if(R(this,t),(n=T(this,t,[e])).polling=!1,"undefined"!=typeof location){var r="https:"===location.protocol,o=location.port;o||(o=r?"443":"80"),n.xd="undefined"!=typeof location&&e.hostname!==location.hostname||o!==e.port}return n.supportsBinary=Sr&&!(e&&e.forceBase64),n.opts.withCredentials&&(n.cookieJar=void 0),n}return M(t,e),I(t,[{key:"name",get:function(){return"polling"}},{key:"doOpen",value:function(){this.poll()}},{key:"pause",value:function(e){var t=this;this.readyState="pausing";var n=function(){t.readyState="paused",e()};if(this.polling||!this.writable){var r=0;this.polling&&(r++,this.once("pollComplete",(function(){--r||n()}))),this.writable||(r++,this.once("drain",(function(){--r||n()})))}else n()}},{key:"poll",value:function(){this.polling=!0,this.doPoll(),this.emitReserved("poll")}},{key:"onData",value:function(e){var t=this;(function(e,t){for(var n=e.split(nr),r=[],o=0;o<n.length;o++){var i=Qn(n[o],t);if(r.push(i),"error"===i.type)break}return r})(e,this.socket.binaryType).forEach((function(e){if("opening"===t.readyState&&"open"===e.type&&t.onOpen(),"close"===e.type)return t.onClose({description:"transport closed by the server"}),!1;t.onPacket(e)})),"closed"!==this.readyState&&(this.polling=!1,this.emitReserved("pollComplete"),"open"===this.readyState&&this.poll())}},{key:"doClose",value:function(){var e=this,t=function(){e.write([{type:"close"}])};"open"===this.readyState?t():this.once("open",t)}},{key:"write",value:function(e){var t=this;this.writable=!1,function(e,n){var r=e.length,o=new Array(r),i=0;e.forEach((function(e,n){Vn(e,!1,(function(e){var a;o[n]=e,++i===r&&(a=o.join(nr),t.doWrite(a,(function(){t.writable=!0,t.emitReserved("drain")})))}))}))}(e)}},{key:"uri",value:function(){var e=this.opts.secure?"https":"http",t=this.query||{};return!1!==this.opts.timestampRequests&&(t[this.opts.timestampParam]=_r()),this.supportsBinary||t.sid||(t.b64=1),this.createUri(e,t)}},{key:"request",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return Object.assign(e,{xd:this.xd,cookieJar:this.cookieJar},this.opts),new Ar(this.uri(),e)}},{key:"doWrite",value:function(e,t){var n=this,r=this.request({method:"POST",data:e});r.on("success",t),r.on("error",(function(e,t){n.onError("xhr post error",e,t)}))}},{key:"doPoll",value:function(){var e=this,t=this.request();t.on("data",this.onData.bind(this)),t.on("error",(function(t,n){e.onError("xhr poll error",t,n)})),this.pollXhr=t}}])}(hr),Ar=function(e){function t(e,n){var r;return R(this,t),ur(r=T(this,t),n),r.opts=n,r.method=n.method||"GET",r.uri=e,r.data=void 0!==n.data?n.data:null,r.create(),r}return M(t,e),I(t,[{key:"create",value:function(){var e,n=this,r=sr(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");r.xdomain=!!this.opts.xd;var o=this.xhr=new xr(r);try{o.open(this.method,this.uri,!0);try{if(this.opts.extraHeaders)for(var i in o.setDisableHeaderCheck&&o.setDisableHeaderCheck(!0),this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(i)&&o.setRequestHeader(i,this.opts.extraHeaders[i])}catch(e){}if("POST"===this.method)try{o.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(e){}try{o.setRequestHeader("Accept","*/*")}catch(e){}null===(e=this.opts.cookieJar)||void 0===e||e.addCookies(o),"withCredentials"in o&&(o.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(o.timeout=this.opts.requestTimeout),o.onreadystatechange=function(){var e;3===o.readyState&&(null===(e=n.opts.cookieJar)||void 0===e||e.parseCookies(o)),4===o.readyState&&(200===o.status||1223===o.status?n.onLoad():n.setTimeoutFn((function(){n.onError("number"==typeof o.status?o.status:0)}),0))},o.send(this.data)}catch(e){return void this.setTimeoutFn((function(){n.onError(e)}),0)}"undefined"!=typeof document&&(this.index=t.requestsCount++,t.requests[this.index]=this)}},{key:"onError",value:function(e){this.emitReserved("error",e,this.xhr),this.cleanup(!0)}},{key:"cleanup",value:function(e){if(null!=this.xhr){if(this.xhr.onreadystatechange=wr,e)try{this.xhr.abort()}catch(e){}"undefined"!=typeof document&&delete t.requests[this.index],this.xhr=null}}},{key:"onLoad",value:function(){var e=this.xhr.responseText;null!==e&&(this.emitReserved("data",e),this.emitReserved("success"),this.cleanup())}},{key:"abort",value:function(){this.cleanup()}}])}(ir);function kr(){for(var e in Ar.requests)Ar.requests.hasOwnProperty(e)&&Ar.requests[e].abort()}Ar.requestsCount=0,Ar.requests={},"undefined"!=typeof document&&("function"==typeof attachEvent?attachEvent("onunload",kr):"function"==typeof addEventListener&&addEventListener("onpagehide"in ar?"pagehide":"unload",kr,!1));var Nr=function(){return"function"==typeof Promise&&"function"==typeof Promise.resolve?function(e){return Promise.resolve().then(e)}:function(e,t){return t(e,0)}}(),Tr=ar.WebSocket||ar.MozWebSocket,Rr="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase(),Er=function(e){function t(e){var n;return R(this,t),(n=T(this,t,[e])).supportsBinary=!e.forceBase64,n}return M(t,e),I(t,[{key:"name",get:function(){return"websocket"}},{key:"doOpen",value:function(){if(this.check()){var e=this.uri(),t=this.opts.protocols,n=Rr?{}:sr(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=Rr?new Tr(e,t,n):t?new Tr(e,t):new Tr(e)}catch(e){return this.emitReserved("error",e)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}}},{key:"addEventListeners",value:function(){var e=this;this.ws.onopen=function(){e.opts.autoUnref&&e.ws._socket.unref(),e.onOpen()},this.ws.onclose=function(t){return e.onClose({description:"websocket connection closed",context:t})},this.ws.onmessage=function(t){return e.onData(t.data)},this.ws.onerror=function(t){return e.onError("websocket error",t)}}},{key:"write",value:function(e){var t=this;this.writable=!1;for(var n=function(){var n=r===e.length-1;Vn(e[r],t.supportsBinary,(function(e){try{t.ws.send(e)}catch(e){}n&&Nr((function(){t.writable=!0,t.emitReserved("drain")}),t.setTimeoutFn)}))},r=0;r<e.length;r++)n()}},{key:"doClose",value:function(){void 0!==this.ws&&(this.ws.close(),this.ws=null)}},{key:"uri",value:function(){var e=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=_r()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}},{key:"check",value:function(){return!!Tr}}])}(hr),Ir=function(e){function t(){return R(this,t),T(this,t,arguments)}return M(t,e),I(t,[{key:"name",get:function(){return"webtransport"}},{key:"doOpen",value:function(){var e=this;"function"==typeof WebTransport&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then((function(){e.onClose()})).catch((function(t){e.onError("webtransport error",t)})),this.transport.ready.then((function(){e.transport.createBidirectionalStream().then((function(t){var n=function(e,t){Xn||(Xn=new TextDecoder);var n=[],r=0,o=-1,i=!1;return new TransformStream({transform:function(a,s){for(n.push(a);;){if(0===r){if(rr(n)<1)break;var l=or(n,1);i=128==(128&l[0]),r=(o=127&l[0])<126?3:126===o?1:2}else if(1===r){if(rr(n)<2)break;var c=or(n,2);o=new DataView(c.buffer,c.byteOffset,c.length).getUint16(0),r=3}else if(2===r){if(rr(n)<8)break;var u=or(n,8),d=new DataView(u.buffer,u.byteOffset,u.length),f=d.getUint32(0);if(f>Math.pow(2,21)-1){s.enqueue(zn);break}o=f*Math.pow(2,32)+d.getUint32(4),r=3}else{if(rr(n)<o)break;var h=or(n,o);s.enqueue(Qn(i?h:Xn.decode(h),t)),r=0}if(0===o||o>e){s.enqueue(zn);break}}}})}(Number.MAX_SAFE_INTEGER,e.socket.binaryType),r=t.readable.pipeThrough(n).getReader(),o=new TransformStream({transform:function(e,t){!function(e,t){$n&&e.data instanceof Blob?e.data.arrayBuffer().then(Jn).then(t):Hn&&(e.data instanceof ArrayBuffer||Gn(e.data))?t(Jn(e.data)):Vn(e,!1,(function(e){Un||(Un=new TextEncoder),t(Un.encode(e))}))}(e,(function(n){var r,o=n.length;if(o<126)r=new Uint8Array(1),new DataView(r.buffer).setUint8(0,o);else if(o<65536){r=new Uint8Array(3);var i=new DataView(r.buffer);i.setUint8(0,126),i.setUint16(1,o)}else{r=new Uint8Array(9);var a=new DataView(r.buffer);a.setUint8(0,127),a.setBigUint64(1,BigInt(o))}e.data&&"string"!=typeof e.data&&(r[0]|=128),t.enqueue(r),t.enqueue(n)}))}});o.readable.pipeTo(t.writable),e.writer=o.writable.getWriter();var i=function(){r.read().then((function(t){t.done||(e.onPacket(t.value),i())})).catch((function(e){}))};i();var a={type:"open"};e.query.sid&&(a.data='{"sid":"'.concat(e.query.sid,'"}')),e.writer.write(a).then((function(){return e.onOpen()}))}))})))}},{key:"write",value:function(e){var t=this;this.writable=!1;for(var n=function(){var n=r===e.length-1;t.writer.write(e[r]).then((function(){n&&Nr((function(){t.writable=!0,t.emitReserved("drain")}),t.setTimeoutFn)}))},r=0;r<e.length;r++)n()}},{key:"doClose",value:function(){var e;null===(e=this.transport)||void 0===e||e.close()}}])}(hr),jr={websocket:Er,webtransport:Ir,polling:Cr},Dr=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Or=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Fr(e){var t,n,r=e,o=e.indexOf("["),i=e.indexOf("]");-1!=o&&-1!=i&&(e=e.substring(0,o)+e.substring(o,i).replace(/:/g,";")+e.substring(i,e.length));for(var a,s=Dr.exec(e||""),l={},c=14;c--;)l[Or[c]]=s[c]||"";return-1!=o&&-1!=i&&(l.source=r,l.host=l.host.substring(1,l.host.length-1).replace(/;/g,":"),l.authority=l.authority.replace("[","").replace("]","").replace(/;/g,":"),l.ipv6uri=!0),l.pathNames=(n=(t=l.path).replace(/\/{2,9}/g,"/").split("/"),"/"!=t.slice(0,1)&&0!==t.length||n.splice(0,1),"/"==t.slice(-1)&&n.splice(n.length-1,1),n),l.queryKey=(a={},l.query.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,(function(e,t,n){t&&(a[t]=n)})),a),l}var Mr=function(e){function t(e){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return R(this,t),(n=T(this,t)).binaryType="arraybuffer",n.writeBuffer=[],e&&"object"===K(e)&&(r=e,e=null),e?(e=Fr(e),r.hostname=e.host,r.secure="https"===e.protocol||"wss"===e.protocol,r.port=e.port,e.query&&(r.query=e.query)):r.host&&(r.hostname=Fr(r.host).host),ur(n,r),n.secure=null!=r.secure?r.secure:"undefined"!=typeof location&&"https:"===location.protocol,r.hostname&&!r.port&&(r.port=n.secure?"443":"80"),n.hostname=r.hostname||("undefined"!=typeof location?location.hostname:"localhost"),n.port=r.port||("undefined"!=typeof location&&location.port?location.port:n.secure?"443":"80"),n.transports=r.transports||["polling","websocket","webtransport"],n.writeBuffer=[],n.prevBufferLen=0,n.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},r),n.opts.path=n.opts.path.replace(/\/$/,"")+(n.opts.addTrailingSlash?"/":""),"string"==typeof n.opts.query&&(n.opts.query=function(e){for(var t={},n=e.split("&"),r=0,o=n.length;r<o;r++){var i=n[r].split("=");t[decodeURIComponent(i[0])]=decodeURIComponent(i[1])}return t}(n.opts.query)),n.id=null,n.upgrades=null,n.pingInterval=null,n.pingTimeout=null,n.pingTimeoutTimer=null,"function"==typeof addEventListener&&(n.opts.closeOnBeforeunload&&(n.beforeunloadEventListener=function(){n.transport&&(n.transport.removeAllListeners(),n.transport.close())},addEventListener("beforeunload",n.beforeunloadEventListener,!1)),"localhost"!==n.hostname&&(n.offlineEventListener=function(){n.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",n.offlineEventListener,!1))),n.open(),n}return M(t,e),I(t,[{key:"createTransport",value:function(e){var t=Object.assign({},this.opts.query);t.EIO=4,t.transport=e,this.id&&(t.sid=this.id);var n=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new jr[e](n)}},{key:"open",value:function(){var e,n=this;if(this.opts.rememberUpgrade&&t.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))e="websocket";else{if(0===this.transports.length)return void this.setTimeoutFn((function(){n.emitReserved("error","No transports available")}),0);e=this.transports[0]}this.readyState="opening";try{e=this.createTransport(e)}catch(e){return this.transports.shift(),void this.open()}e.open(),this.setTransport(e)}},{key:"setTransport",value:function(e){var t=this;this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",(function(e){return t.onClose("transport close",e)}))}},{key:"probe",value:function(e){var n=this,r=this.createTransport(e),o=!1;t.priorWebsocketSuccess=!1;var i=function(){o||(r.send([{type:"ping",data:"probe"}]),r.once("packet",(function(e){if(!o)if("pong"===e.type&&"probe"===e.data){if(n.upgrading=!0,n.emitReserved("upgrading",r),!r)return;t.priorWebsocketSuccess="websocket"===r.name,n.transport.pause((function(){o||"closed"!==n.readyState&&(d(),n.setTransport(r),r.send([{type:"upgrade"}]),n.emitReserved("upgrade",r),r=null,n.upgrading=!1,n.flush())}))}else{var i=new Error("probe error");i.transport=r.name,n.emitReserved("upgradeError",i)}})))};function a(){o||(o=!0,d(),r.close(),r=null)}var s=function(e){var t=new Error("probe error: "+e);t.transport=r.name,a(),n.emitReserved("upgradeError",t)};function l(){s("transport closed")}function c(){s("socket closed")}function u(e){r&&e.name!==r.name&&a()}var d=function(){r.removeListener("open",i),r.removeListener("error",s),r.removeListener("close",l),n.off("close",c),n.off("upgrading",u)};r.once("open",i),r.once("error",s),r.once("close",l),this.once("close",c),this.once("upgrading",u),-1!==this.upgrades.indexOf("webtransport")&&"webtransport"!==e?this.setTimeoutFn((function(){o||r.open()}),200):r.open()}},{key:"onOpen",value:function(){if(this.readyState="open",t.priorWebsocketSuccess="websocket"===this.transport.name,this.emitReserved("open"),this.flush(),"open"===this.readyState&&this.opts.upgrade)for(var e=0,n=this.upgrades.length;e<n;e++)this.probe(this.upgrades[e])}},{key:"onPacket",value:function(e){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),this.resetPingTimeout(),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this.sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong");break;case"error":var t=new Error("server error");t.code=e.data,this.onError(t);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data)}}},{key:"onHandshake",value:function(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this.upgrades=this.filterUpgrades(e.upgrades),this.pingInterval=e.pingInterval,this.pingTimeout=e.pingTimeout,this.maxPayload=e.maxPayload,this.onOpen(),"closed"!==this.readyState&&this.resetPingTimeout()}},{key:"resetPingTimeout",value:function(){var e=this;this.clearTimeoutFn(this.pingTimeoutTimer),this.pingTimeoutTimer=this.setTimeoutFn((function(){e.onClose("ping timeout")}),this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}},{key:"onDrain",value:function(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emitReserved("drain"):this.flush()}},{key:"flush",value:function(){if("closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){var e=this.getWritablePackets();this.transport.send(e),this.prevBufferLen=e.length,this.emitReserved("flush")}}},{key:"getWritablePackets",value:function(){if(!(this.maxPayload&&"polling"===this.transport.name&&this.writeBuffer.length>1))return this.writeBuffer;for(var e,t=1,n=0;n<this.writeBuffer.length;n++){var r=this.writeBuffer[n].data;if(r&&(t+="string"==typeof(e=r)?function(e){for(var t=0,n=0,r=0,o=e.length;r<o;r++)(t=e.charCodeAt(r))<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(r++,n+=4);return n}(e):Math.ceil(1.33*(e.byteLength||e.size))),n>0&&t>this.maxPayload)return this.writeBuffer.slice(0,n);t+=2}return this.writeBuffer}},{key:"write",value:function(e,t,n){return this.sendPacket("message",e,t,n),this}},{key:"send",value:function(e,t,n){return this.sendPacket("message",e,t,n),this}},{key:"sendPacket",value:function(e,t,n,r){if("function"==typeof t&&(r=t,t=void 0),"function"==typeof n&&(r=n,n=null),"closing"!==this.readyState&&"closed"!==this.readyState){(n=n||{}).compress=!1!==n.compress;var o={type:e,data:t,options:n};this.emitReserved("packetCreate",o),this.writeBuffer.push(o),r&&this.once("flush",r),this.flush()}}},{key:"close",value:function(){var e=this,t=function(){e.onClose("forced close"),e.transport.close()},n=function(){e.off("upgrade",n),e.off("upgradeError",n),t()},r=function(){e.once("upgrade",n),e.once("upgradeError",n)};return"opening"!==this.readyState&&"open"!==this.readyState||(this.readyState="closing",this.writeBuffer.length?this.once("drain",(function(){e.upgrading?r():t()})):this.upgrading?r():t()),this}},{key:"onError",value:function(e){t.priorWebsocketSuccess=!1,this.emitReserved("error",e),this.onClose("transport error",e)}},{key:"onClose",value:function(e,t){"opening"!==this.readyState&&"open"!==this.readyState&&"closing"!==this.readyState||(this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),"function"==typeof removeEventListener&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this.prevBufferLen=0)}},{key:"filterUpgrades",value:function(e){for(var t=[],n=0,r=e.length;n<r;n++)~this.transports.indexOf(e[n])&&t.push(e[n]);return t}}])}(ir);Mr.protocol=4;var Lr="function"==typeof ArrayBuffer,Pr=function(e){return"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer},Br=Object.prototype.toString,qr="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Br.call(Blob),Ur="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===Br.call(File);function zr(e){return Lr&&(e instanceof ArrayBuffer||Pr(e))||qr&&e instanceof Blob||Ur&&e instanceof File}function $r(e,t){if(!e||"object"!==K(e))return!1;if(Array.isArray(e)){for(var n=0,r=e.length;n<r;n++)if($r(e[n]))return!0;return!1}if(zr(e))return!0;if(e.toJSON&&"function"==typeof e.toJSON&&1===arguments.length)return $r(e.toJSON(),!0);for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)&&$r(e[o]))return!0;return!1}function Hr(e){var t=[],n=e;return n.data=Gr(e.data,t),n.attachments=t.length,{packet:n,buffers:t}}function Gr(e,t){if(!e)return e;if(zr(e)){var n={_placeholder:!0,num:t.length};return t.push(e),n}if(Array.isArray(e)){for(var r=new Array(e.length),o=0;o<e.length;o++)r[o]=Gr(e[o],t);return r}if("object"===K(e)&&!(e instanceof Date)){var i={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(i[a]=Gr(e[a],t));return i}return e}function Vr(e,t){return e.data=Wr(e.data,t),delete e.attachments,e}function Wr(e,t){if(!e)return e;if(e&&!0===e._placeholder){if("number"==typeof e.num&&e.num>=0&&e.num<t.length)return t[e.num];throw new Error("illegal attachments")}if(Array.isArray(e))for(var n=0;n<e.length;n++)e[n]=Wr(e[n],t);else if("object"===K(e))for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(e[r]=Wr(e[r],t));return e}var Jr,Kr=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];!function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"}(Jr||(Jr={}));var Yr=function(){return I((function e(t){R(this,e),this.replacer=t}),[{key:"encode",value:function(e){return e.type!==Jr.EVENT&&e.type!==Jr.ACK||!$r(e)?[this.encodeAsString(e)]:this.encodeAsBinary({type:e.type===Jr.EVENT?Jr.BINARY_EVENT:Jr.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id})}},{key:"encodeAsString",value:function(e){var t=""+e.type;return e.type!==Jr.BINARY_EVENT&&e.type!==Jr.BINARY_ACK||(t+=e.attachments+"-"),e.nsp&&"/"!==e.nsp&&(t+=e.nsp+","),null!=e.id&&(t+=e.id),null!=e.data&&(t+=JSON.stringify(e.data,this.replacer)),t}},{key:"encodeAsBinary",value:function(e){var t=Hr(e),n=this.encodeAsString(t.packet),r=t.buffers;return r.unshift(n),r}}])}();function Xr(e){return"[object Object]"===Object.prototype.toString.call(e)}var Zr=function(e){function t(e){var n;return R(this,t),(n=T(this,t)).reviver=e,n}return M(t,e),I(t,[{key:"add",value:function(e){var n;if("string"==typeof e){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");var r=(n=this.decodeString(e)).type===Jr.BINARY_EVENT;r||n.type===Jr.BINARY_ACK?(n.type=r?Jr.EVENT:Jr.ACK,this.reconstructor=new Qr(n),0===n.attachments&&V(t,"emitReserved",this,3)(["decoded",n])):V(t,"emitReserved",this,3)(["decoded",n])}else{if(!zr(e)&&!e.base64)throw new Error("Unknown type: "+e);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");(n=this.reconstructor.takeBinaryData(e))&&(this.reconstructor=null,V(t,"emitReserved",this,3)(["decoded",n]))}}},{key:"decodeString",value:function(e){var n=0,r={type:Number(e.charAt(0))};if(void 0===Jr[r.type])throw new Error("unknown packet type "+r.type);if(r.type===Jr.BINARY_EVENT||r.type===Jr.BINARY_ACK){for(var o=n+1;"-"!==e.charAt(++n)&&n!=e.length;);var i=e.substring(o,n);if(i!=Number(i)||"-"!==e.charAt(n))throw new Error("Illegal attachments");r.attachments=Number(i)}if("/"===e.charAt(n+1)){for(var a=n+1;++n&&","!==e.charAt(n)&&n!==e.length;);r.nsp=e.substring(a,n)}else r.nsp="/";var s=e.charAt(n+1);if(""!==s&&Number(s)==s){for(var l=n+1;++n;){var c=e.charAt(n);if(null==c||Number(c)!=c){--n;break}if(n===e.length)break}r.id=Number(e.substring(l,n+1))}if(e.charAt(++n)){var u=this.tryParse(e.substr(n));if(!t.isPayloadValid(r.type,u))throw new Error("invalid payload");r.data=u}return r}},{key:"tryParse",value:function(e){try{return JSON.parse(e,this.reviver)}catch(e){return!1}}},{key:"destroy",value:function(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}],[{key:"isPayloadValid",value:function(e,t){switch(e){case Jr.CONNECT:return Xr(t);case Jr.DISCONNECT:return void 0===t;case Jr.CONNECT_ERROR:return"string"==typeof t||Xr(t);case Jr.EVENT:case Jr.BINARY_EVENT:return Array.isArray(t)&&("number"==typeof t[0]||"string"==typeof t[0]&&-1===Kr.indexOf(t[0]));case Jr.ACK:case Jr.BINARY_ACK:return Array.isArray(t)}}}])}(ir),Qr=function(){return I((function e(t){R(this,e),this.packet=t,this.buffers=[],this.reconPack=t}),[{key:"takeBinaryData",value:function(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){var t=Vr(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}},{key:"finishedReconstruction",value:function(){this.reconPack=null,this.buffers=[]}}])}(),eo={__proto__:null,Decoder:Zr,Encoder:Yr,get PacketType(){return Jr}};function to(e,t,n){return e.on(t,n),function(){e.off(t,n)}}var no=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),ro=function(e){function t(e,n,r){var o;return R(this,t),(o=T(this,t)).connected=!1,o.recovered=!1,o.receiveBuffer=[],o.sendBuffer=[],o._queue=[],o._queueSeq=0,o.ids=0,o.acks={},o.flags={},o.io=e,o.nsp=n,r&&r.auth&&(o.auth=r.auth),o._opts=Object.assign({},r),o.io._autoConnect&&o.open(),o}return M(t,e),I(t,[{key:"disconnected",get:function(){return!this.connected}},{key:"subEvents",value:function(){if(!this.subs){var e=this.io;this.subs=[to(e,"open",this.onopen.bind(this)),to(e,"packet",this.onpacket.bind(this)),to(e,"error",this.onerror.bind(this)),to(e,"close",this.onclose.bind(this))]}}},{key:"active",get:function(){return!!this.subs}},{key:"connect",value:function(){return this.connected||(this.subEvents(),this.io._reconnecting||this.io.open(),"open"===this.io._readyState&&this.onopen()),this}},{key:"open",value:function(){return this.connect()}},{key:"send",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.unshift("message"),this.emit.apply(this,t),this}},{key:"emit",value:function(e){if(no.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];if(n.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(n),this;var o={type:Jr.EVENT,data:n,options:{}};if(o.options.compress=!1!==this.flags.compress,"function"==typeof n[n.length-1]){var i=this.ids++,a=n.pop();this._registerAckCallback(i,a),o.id=i}return this.flags.volatile&&(!(this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable)||!this.connected)||(this.connected?(this.notifyOutgoingListeners(o),this.packet(o)):this.sendBuffer.push(o)),this.flags={},this}},{key:"_registerAckCallback",value:function(e,t){var n,r=this,o=null!==(n=this.flags.timeout)&&void 0!==n?n:this._opts.ackTimeout;if(void 0!==o){var i=this.io.setTimeoutFn((function(){delete r.acks[e];for(var n=0;n<r.sendBuffer.length;n++)r.sendBuffer[n].id===e&&r.sendBuffer.splice(n,1);t.call(r,new Error("operation has timed out"))}),o);this.acks[e]=function(){r.io.clearTimeoutFn(i);for(var e=arguments.length,n=new Array(e),o=0;o<e;o++)n[o]=arguments[o];t.apply(r,[null].concat(n))}}else this.acks[e]=t}},{key:"emitWithAck",value:function(e){for(var t=this,n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];var i=void 0!==this.flags.timeout||void 0!==this._opts.ackTimeout;return new Promise((function(n,o){r.push((function(e,t){return i?e?o(e):n(t):n(e)})),t.emit.apply(t,[e].concat(r))}))}},{key:"_addToQueue",value:function(e){var t,n=this;"function"==typeof e[e.length-1]&&(t=e.pop());var r={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((function(e){if(r===n._queue[0]){if(null!==e)r.tryCount>n._opts.retries&&(n._queue.shift(),t&&t(e));else if(n._queue.shift(),t){for(var o=arguments.length,i=new Array(o>1?o-1:0),a=1;a<o;a++)i[a-1]=arguments[a];t.apply(void 0,[null].concat(i))}return r.pending=!1,n._drainQueue()}})),this._queue.push(r),this._drainQueue()}},{key:"_drainQueue",value:function(){if(this.connected&&0!==this._queue.length){var e=this._queue[0];e.pending&&!(arguments.length>0&&void 0!==arguments[0]&&arguments[0])||(e.pending=!0,e.tryCount++,this.flags=e.flags,this.emit.apply(this,e.args))}}},{key:"packet",value:function(e){e.nsp=this.nsp,this.io._packet(e)}},{key:"onopen",value:function(){var e=this;"function"==typeof this.auth?this.auth((function(t){e._sendConnectPacket(t)})):this._sendConnectPacket(this.auth)}},{key:"_sendConnectPacket",value:function(e){this.packet({type:Jr.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}},{key:"onerror",value:function(e){this.connected||this.emitReserved("connect_error",e)}},{key:"onclose",value:function(e,t){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t)}},{key:"onpacket",value:function(e){if(e.nsp===this.nsp)switch(e.type){case Jr.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case Jr.EVENT:case Jr.BINARY_EVENT:this.onevent(e);break;case Jr.ACK:case Jr.BINARY_ACK:this.onack(e);break;case Jr.DISCONNECT:this.ondisconnect();break;case Jr.CONNECT_ERROR:this.destroy();var t=new Error(e.data.message);t.data=e.data.data,this.emitReserved("connect_error",t)}}},{key:"onevent",value:function(e){var t=e.data||[];null!=e.id&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}},{key:"emitEvent",value:function(e){if(this._anyListeners&&this._anyListeners.length){var n,r=j(this._anyListeners.slice());try{for(r.s();!(n=r.n()).done;)n.value.apply(this,e)}catch(e){r.e(e)}finally{r.f()}}V(t,"emit",this,1).apply(this,e),this._pid&&e.length&&"string"==typeof e[e.length-1]&&(this._lastOffset=e[e.length-1])}},{key:"ack",value:function(e){var t=this,n=!1;return function(){if(!n){n=!0;for(var r=arguments.length,o=new Array(r),i=0;i<r;i++)o[i]=arguments[i];t.packet({type:Jr.ACK,id:e,data:o})}}}},{key:"onack",value:function(e){var t=this.acks[e.id];"function"==typeof t&&(t.apply(this,e.data),delete this.acks[e.id])}},{key:"onconnect",value:function(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}},{key:"emitBuffered",value:function(){var e=this;this.receiveBuffer.forEach((function(t){return e.emitEvent(t)})),this.receiveBuffer=[],this.sendBuffer.forEach((function(t){e.notifyOutgoingListeners(t),e.packet(t)})),this.sendBuffer=[]}},{key:"ondisconnect",value:function(){this.destroy(),this.onclose("io server disconnect")}},{key:"destroy",value:function(){this.subs&&(this.subs.forEach((function(e){return e()})),this.subs=void 0),this.io._destroy(this)}},{key:"disconnect",value:function(){return this.connected&&this.packet({type:Jr.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}},{key:"close",value:function(){return this.disconnect()}},{key:"compress",value:function(e){return this.flags.compress=e,this}},{key:"volatile",get:function(){return this.flags.volatile=!0,this}},{key:"timeout",value:function(e){return this.flags.timeout=e,this}},{key:"onAny",value:function(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}},{key:"prependAny",value:function(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}},{key:"offAny",value:function(e){if(!this._anyListeners)return this;if(e){for(var t=this._anyListeners,n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyListeners=[];return this}},{key:"listenersAny",value:function(){return this._anyListeners||[]}},{key:"onAnyOutgoing",value:function(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}},{key:"prependAnyOutgoing",value:function(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}},{key:"offAnyOutgoing",value:function(e){if(!this._anyOutgoingListeners)return this;if(e){for(var t=this._anyOutgoingListeners,n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyOutgoingListeners=[];return this}},{key:"listenersAnyOutgoing",value:function(){return this._anyOutgoingListeners||[]}},{key:"notifyOutgoingListeners",value:function(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){var t,n=j(this._anyOutgoingListeners.slice());try{for(n.s();!(t=n.n()).done;)t.value.apply(this,e.data)}catch(e){n.e(e)}finally{n.f()}}}}])}(ir);function oo(e){this.ms=(e=e||{}).min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}oo.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=0==(1&Math.floor(10*t))?e-n:e+n}return 0|Math.min(e,this.max)},oo.prototype.reset=function(){this.attempts=0},oo.prototype.setMin=function(e){this.ms=e},oo.prototype.setMax=function(e){this.max=e},oo.prototype.setJitter=function(e){this.jitter=e};var io=function(e){function t(e,n){var r,o;R(this,t),(r=T(this,t)).nsps={},r.subs=[],e&&"object"===K(e)&&(n=e,e=void 0),(n=n||{}).path=n.path||"/socket.io",r.opts=n,ur(r,n),r.reconnection(!1!==n.reconnection),r.reconnectionAttempts(n.reconnectionAttempts||Infinity),r.reconnectionDelay(n.reconnectionDelay||1e3),r.reconnectionDelayMax(n.reconnectionDelayMax||5e3),r.randomizationFactor(null!==(o=n.randomizationFactor)&&void 0!==o?o:.5),r.backoff=new oo({min:r.reconnectionDelay(),max:r.reconnectionDelayMax(),jitter:r.randomizationFactor()}),r.timeout(null==n.timeout?2e4:n.timeout),r._readyState="closed",r.uri=e;var i=n.parser||eo;return r.encoder=new i.Encoder,r.decoder=new i.Decoder,r._autoConnect=!1!==n.autoConnect,r._autoConnect&&r.open(),r}return M(t,e),I(t,[{key:"reconnection",value:function(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection}},{key:"reconnectionAttempts",value:function(e){return void 0===e?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}},{key:"reconnectionDelay",value:function(e){var t;return void 0===e?this._reconnectionDelay:(this._reconnectionDelay=e,null===(t=this.backoff)||void 0===t||t.setMin(e),this)}},{key:"randomizationFactor",value:function(e){var t;return void 0===e?this._randomizationFactor:(this._randomizationFactor=e,null===(t=this.backoff)||void 0===t||t.setJitter(e),this)}},{key:"reconnectionDelayMax",value:function(e){var t;return void 0===e?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,null===(t=this.backoff)||void 0===t||t.setMax(e),this)}},{key:"timeout",value:function(e){return arguments.length?(this._timeout=e,this):this._timeout}},{key:"maybeReconnectOnOpen",value:function(){!this._reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}},{key:"open",value:function(e){var t=this;if(~this._readyState.indexOf("open"))return this;this.engine=new Mr(this.uri,this.opts);var n=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;var o=to(n,"open",(function(){r.onopen(),e&&e()})),i=function(n){t.cleanup(),t._readyState="closed",t.emitReserved("error",n),e?e(n):t.maybeReconnectOnOpen()},a=to(n,"error",i);if(!1!==this._timeout){var s=this.setTimeoutFn((function(){o(),i(new Error("timeout")),n.close()}),this._timeout);this.opts.autoUnref&&s.unref(),this.subs.push((function(){t.clearTimeoutFn(s)}))}return this.subs.push(o),this.subs.push(a),this}},{key:"connect",value:function(e){return this.open(e)}},{key:"onopen",value:function(){this.cleanup(),this._readyState="open",this.emitReserved("open");var e=this.engine;this.subs.push(to(e,"ping",this.onping.bind(this)),to(e,"data",this.ondata.bind(this)),to(e,"error",this.onerror.bind(this)),to(e,"close",this.onclose.bind(this)),to(this.decoder,"decoded",this.ondecoded.bind(this)))}},{key:"onping",value:function(){this.emitReserved("ping")}},{key:"ondata",value:function(e){try{this.decoder.add(e)}catch(e){this.onclose("parse error",e)}}},{key:"ondecoded",value:function(e){var t=this;Nr((function(){t.emitReserved("packet",e)}),this.setTimeoutFn)}},{key:"onerror",value:function(e){this.emitReserved("error",e)}},{key:"socket",value:function(e,t){var n=this.nsps[e];return n?this._autoConnect&&!n.active&&n.connect():(n=new ro(this,e,t),this.nsps[e]=n),n}},{key:"_destroy",value:function(e){for(var t=0,n=Object.keys(this.nsps);t<n.length;t++)if(this.nsps[n[t]].active)return;this._close()}},{key:"_packet",value:function(e){for(var t=this.encoder.encode(e),n=0;n<t.length;n++)this.engine.write(t[n],e.options)}},{key:"cleanup",value:function(){this.subs.forEach((function(e){return e()})),this.subs.length=0,this.decoder.destroy()}},{key:"_close",value:function(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}},{key:"disconnect",value:function(){return this._close()}},{key:"onclose",value:function(e,t){this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}},{key:"reconnect",value:function(){var e=this;if(this._reconnecting||this.skipReconnect)return this;var t=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{var n=this.backoff.duration();this._reconnecting=!0;var r=this.setTimeoutFn((function(){t.skipReconnect||(e.emitReserved("reconnect_attempt",t.backoff.attempts),t.skipReconnect||t.open((function(n){n?(t._reconnecting=!1,t.reconnect(),e.emitReserved("reconnect_error",n)):t.onreconnect()})))}),n);this.opts.autoUnref&&r.unref(),this.subs.push((function(){e.clearTimeoutFn(r)}))}}},{key:"onreconnect",value:function(){var e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}])}(ir),ao={};function so(e,t){"object"===K(e)&&(t=e,e=void 0);var n,r=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2?arguments[2]:void 0,r=e;n=n||"undefined"!=typeof location&&location,null==e&&(e=n.protocol+"//"+n.host),"string"==typeof e&&("/"===e.charAt(0)&&(e="/"===e.charAt(1)?n.protocol+e:n.host+e),/^(https?|wss?):\/\//.test(e)||(e=void 0!==n?n.protocol+"//"+e:"https://"+e),r=Fr(e)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";var o=-1!==r.host.indexOf(":")?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+o+":"+r.port+t,r.href=r.protocol+"://"+o+(n&&n.port===r.port?"":":"+r.port),r}(e,(t=t||{}).path||"/socket.io"),o=r.source,i=r.id;return t.forceNew||t["force new connection"]||!1===t.multiplex||ao[i]&&r.path in ao[i].nsps?n=new io(o,t):(ao[i]||(ao[i]=new io(o,t)),n=ao[i]),r.query&&!t.query&&(t.query=r.queryKey),n.socket(r.path,t)}Object.assign(so,{Manager:io,Socket:ro,io:so,connect:so});var lo=a.createSvgIcon([i.jsx("path",{d:"M17 11c.34 0 .67.04 1 .09V6.27L10.5 3 3 6.27v4.91c0 4.54 3.2 8.79 7.5 9.82.55-.13 1.08-.32 1.6-.55-.69-.98-1.1-2.17-1.1-3.45 0-3.31 2.69-6 6-6"},"0"),i.jsx("path",{d:"M17 13c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4m0 1.38c.62 0 1.12.51 1.12 1.12s-.51 1.12-1.12 1.12-1.12-.51-1.12-1.12.5-1.12 1.12-1.12m0 5.37c-.93 0-1.74-.46-2.24-1.17.05-.72 1.51-1.08 2.24-1.08s2.19.36 2.24 1.08c-.5.71-1.31 1.17-2.24 1.17"},"1")],"AdminPanelSettings"),co=a.createSvgIcon(i.jsx("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6zM19 4h-3.5l-1-1h-5l-1 1H5v2h14z"}),"Delete"),uo=a.createSvgIcon(i.jsx("path",{d:"M21 3.01H3c-1.1 0-2 .9-2 2V9h2V4.99h18v14.03H3V15H1v4.01c0 1.1.9 1.98 2 1.98h18c1.1 0 2-.88 2-1.98v-14c0-1.11-.9-2-2-2M11 16l4-4-4-4v3H1v2h10z"}),"Input"),fo=a.createSvgIcon(i.jsx("path",{d:"M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4m0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4"}),"Person"),ho=a.createSvgIcon(i.jsx("path",{d:"M16.54 11 13 7.46l1.41-1.41 2.12 2.12 4.24-4.24 1.41 1.41zM11 7H2v2h9zm10 6.41L19.59 12 17 14.59 14.41 12 13 13.41 15.59 16 13 18.59 14.41 20 17 17.41 19.59 20 21 18.59 18.41 16zM11 15H2v2h9z"}),"Rule"),po=function(){function e(e){var t=this;this._insertTag=function(e){t.container.insertBefore(e,0===t.tags.length?t.insertionPoint?t.insertionPoint.nextSibling:t.prepend?t.container.firstChild:t.before:t.tags[t.tags.length-1].nextSibling),t.tags.push(e)},this.isSpeedy=void 0===e.speedy?"production"===ae.env.NODE_ENV:e.speedy,this.tags=[],this.ctr=0,this.nonce=e.nonce,this.key=e.key,this.container=e.container,this.prepend=e.prepend,this.insertionPoint=e.insertionPoint,this.before=null}var t=e.prototype;return t.hydrate=function(e){e.forEach(this._insertTag)},t.insert=function(e){this.ctr%(this.isSpeedy?65e3:1)==0&&this._insertTag(function(e){var t=document.createElement("style");return t.setAttribute("data-emotion",e.key),void 0!==e.nonce&&t.setAttribute("nonce",e.nonce),t.appendChild(document.createTextNode("")),t.setAttribute("data-s",""),t}(this));var t=this.tags[this.tags.length-1];if("production"!==ae.env.NODE_ENV){var n=64===e.charCodeAt(0)&&105===e.charCodeAt(1);n&&this._alreadyInsertedOrderInsensitiveRule&&console.error("You're attempting to insert the following rule:\n"+e+"\n\n`@import` rules must be before all other types of rules in a stylesheet but other rules have already been inserted. Please ensure that `@import` rules are before all other rules."),this._alreadyInsertedOrderInsensitiveRule=this._alreadyInsertedOrderInsensitiveRule||!n}if(this.isSpeedy){var r=function(e){if(e.sheet)return e.sheet;for(var t=0;t<document.styleSheets.length;t++)if(document.styleSheets[t].ownerNode===e)return document.styleSheets[t]}(t);try{r.insertRule(e,r.cssRules.length)}catch(t){"production"===ae.env.NODE_ENV||/:(-moz-placeholder|-moz-focus-inner|-moz-focusring|-ms-input-placeholder|-moz-read-write|-moz-read-only|-ms-clear|-ms-expand|-ms-reveal){/.test(e)||console.error('There was a problem inserting the following rule: "'+e+'"',t)}}else t.appendChild(document.createTextNode(e));this.ctr++},t.flush=function(){this.tags.forEach((function(e){return e.parentNode&&e.parentNode.removeChild(e)})),this.tags=[],this.ctr=0,"production"!==ae.env.NODE_ENV&&(this._alreadyInsertedOrderInsensitiveRule=!1)},e}(),go="-ms-",mo="-moz-",yo="-webkit-",_o="comm",vo="rule",bo="decl",xo="@keyframes",wo=Math.abs,So=String.fromCharCode,Co=Object.assign;function Ao(e){return e.trim()}function ko(e,t,n){return e.replace(t,n)}function No(e,t){return e.indexOf(t)}function To(e,t){return 0|e.charCodeAt(t)}function Ro(e,t,n){return e.slice(t,n)}function Eo(e){return e.length}function Io(e){return e.length}function jo(e,t){return t.push(e),e}var Do=1,Oo=1,Fo=0,Mo=0,Lo=0,Po="";function Bo(e,t,n,r,o,i,a){return{value:e,root:t,parent:n,type:r,props:o,children:i,line:Do,column:Oo,length:a,return:""}}function qo(e,t){return Co(Bo("",null,null,"",null,null,0),e,{length:-e.length},t)}function Uo(){return Lo=Mo>0?To(Po,--Mo):0,Oo--,10===Lo&&(Oo=1,Do--),Lo}function zo(){return Lo=Mo<Fo?To(Po,Mo++):0,Oo++,10===Lo&&(Oo=1,Do++),Lo}function $o(){return To(Po,Mo)}function Ho(){return Mo}function Go(e,t){return Ro(Po,e,t)}function Vo(e){switch(e){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function Wo(e){return Do=Oo=1,Fo=Eo(Po=e),Mo=0,[]}function Jo(e){return Po="",e}function Ko(e){return Ao(Go(Mo-1,Zo(91===e?e+2:40===e?e+1:e)))}function Yo(e){for(;(Lo=$o())&&Lo<33;)zo();return Vo(e)>2||Vo(Lo)>3?"":" "}function Xo(e,t){for(;--t&&zo()&&!(Lo<48||Lo>102||Lo>57&&Lo<65||Lo>70&&Lo<97););return Go(e,Ho()+(t<6&&32==$o()&&32==zo()))}function Zo(e){for(;zo();)switch(Lo){case e:return Mo;case 34:case 39:34!==e&&39!==e&&Zo(Lo);break;case 40:41===e&&Zo(e);break;case 92:zo()}return Mo}function Qo(e,t){for(;zo()&&e+Lo!==57&&(e+Lo!==84||47!==$o()););return"/*"+Go(t,Mo-1)+"*"+So(47===e?e:zo())}function ei(e){for(;!Vo($o());)zo();return Go(e,Mo)}function ti(e){return Jo(ni("",null,null,null,[""],e=Wo(e),0,[0],e))}function ni(e,t,n,r,o,i,a,s,l){for(var c=0,u=0,d=a,f=0,h=0,p=0,g=1,m=1,y=1,_=0,v="",b=o,x=i,w=r,S=v;m;)switch(p=_,_=zo()){case 40:if(108!=p&&58==To(S,d-1)){-1!=No(S+=ko(Ko(_),"&","&\f"),"&\f")&&(y=-1);break}case 34:case 39:case 91:S+=Ko(_);break;case 9:case 10:case 13:case 32:S+=Yo(p);break;case 92:S+=Xo(Ho()-1,7);continue;case 47:switch($o()){case 42:case 47:jo(oi(Qo(zo(),Ho()),t,n),l);break;default:S+="/"}break;case 123*g:s[c++]=Eo(S)*y;case 125*g:case 59:case 0:switch(_){case 0:case 125:m=0;case 59+u:-1==y&&(S=ko(S,/\f/g,"")),h>0&&Eo(S)-d&&jo(h>32?ii(S+";",r,n,d-1):ii(ko(S," ","")+";",r,n,d-2),l);break;case 59:S+=";";default:if(jo(w=ri(S,t,n,c,u,o,s,v,b=[],x=[],d),i),123===_)if(0===u)ni(S,t,w,w,b,i,d,s,x);else switch(99===f&&110===To(S,3)?100:f){case 100:case 108:case 109:case 115:ni(e,w,w,r&&jo(ri(e,w,w,0,0,o,s,v,o,b=[],d),x),o,x,d,s,r?b:x);break;default:ni(S,w,w,w,[""],x,0,s,x)}}c=u=h=0,g=y=1,v=S="",d=a;break;case 58:d=1+Eo(S),h=p;default:if(g<1)if(123==_)--g;else if(125==_&&0==g++&&125==Uo())continue;switch(S+=So(_),_*g){case 38:y=u>0?1:(S+="\f",-1);break;case 44:s[c++]=(Eo(S)-1)*y,y=1;break;case 64:45===$o()&&(S+=Ko(zo())),f=$o(),u=d=Eo(v=S+=ei(Ho())),_++;break;case 45:45===p&&2==Eo(S)&&(g=0)}}return i}function ri(e,t,n,r,o,i,a,s,l,c,u){for(var d=o-1,f=0===o?i:[""],h=Io(f),p=0,g=0,m=0;p<r;++p)for(var y=0,_=Ro(e,d+1,d=wo(g=a[p])),v=e;y<h;++y)(v=Ao(g>0?f[y]+" "+_:ko(_,/&\f/g,f[y])))&&(l[m++]=v);return Bo(e,t,n,0===o?vo:s,l,c,u)}function oi(e,t,n){return Bo(e,t,n,_o,So(Lo),Ro(e,2,-2),0)}function ii(e,t,n,r){return Bo(e,t,n,bo,Ro(e,0,r),Ro(e,r+1,-1),r)}function ai(e,t){for(var n="",r=Io(e),o=0;o<r;o++)n+=t(e[o],o,e,t)||"";return n}function si(e,t,n,r){switch(e.type){case"@layer":if(e.children.length)break;case"@import":case bo:return e.return=e.return||e.value;case _o:return"";case xo:return e.return=e.value+"{"+ai(e.children,r)+"}";case vo:e.value=e.props.join(",")}return Eo(n=ai(e.children,r))?e.return=e.value+"{"+n+"}":""}function li(e){var t=Object.create(null);return function(n){return void 0===t[n]&&(t[n]=e(n)),t[n]}}var ci=function(e,t,n){for(var r=0,o=0;r=o,o=$o(),38===r&&12===o&&(t[n]=1),!Vo(o);)zo();return Go(e,Mo)},ui=new WeakMap,di=function(e){if("rule"===e.type&&e.parent&&!(e.length<1)){for(var t=e.value,n=e.parent,r=e.column===n.column&&e.line===n.line;"rule"!==n.type;)if(!(n=n.parent))return;if((1!==e.props.length||58===t.charCodeAt(0)||ui.get(n))&&!r){ui.set(e,!0);for(var o=[],i=function(e,t){return Jo(function(e,t){var n=-1,r=44;do{switch(Vo(r)){case 0:38===r&&12===$o()&&(t[n]=1),e[n]+=ci(Mo-1,t,n);break;case 2:e[n]+=Ko(r);break;case 4:if(44===r){e[++n]=58===$o()?"&\f":"",t[n]=e[n].length;break}default:e[n]+=So(r)}}while(r=zo());return e}(Wo(e),t))}(t,o),a=n.props,s=0,l=0;s<i.length;s++)for(var c=0;c<a.length;c++,l++)e.props[l]=o[s]?i[s].replace(/&\f/g,a[c]):a[c]+" "+i[s]}}},fi=function(e){if("decl"===e.type){var t=e.value;108===t.charCodeAt(0)&&98===t.charCodeAt(2)&&(e.return="",e.value="")}},hi=function(e){return"comm"===e.type&&e.children.indexOf("emotion-disable-server-rendering-unsafe-selector-warning-please-do-not-use-this-the-warning-exists-for-a-reason")>-1},pi=function(e){return 105===e.type.charCodeAt(1)&&64===e.type.charCodeAt(0)},gi=function(e){e.type="",e.value="",e.return="",e.children="",e.props=""},mi=function(e,t,n){pi(e)&&(e.parent?(console.error("`@import` rules can't be nested inside other rules. Please move it to the top level and put it before regular rules. Keep in mind that they can only be used within global styles."),gi(e)):function(e,t){for(var n=e-1;n>=0;n--)if(!pi(t[n]))return!0;return!1}(t,n)&&(console.error("`@import` rules can't be after other rules. Please put your `@import` rules before your other rules."),gi(e)))};function yi(e,t){switch(function(e,t){return 45^To(e,0)?(((t<<2^To(e,0))<<2^To(e,1))<<2^To(e,2))<<2^To(e,3):0}(e,t)){case 5103:return yo+"print-"+e+e;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return yo+e+e;case 5349:case 4246:case 4810:case 6968:case 2756:return yo+e+mo+e+go+e+e;case 6828:case 4268:return yo+e+go+e+e;case 6165:return yo+e+go+"flex-"+e+e;case 5187:return yo+e+ko(e,/(\w+).+(:[^]+)/,yo+"box-$1$2"+go+"flex-$1$2")+e;case 5443:return yo+e+go+"flex-item-"+ko(e,/flex-|-self/,"")+e;case 4675:return yo+e+go+"flex-line-pack"+ko(e,/align-content|flex-|-self/,"")+e;case 5548:return yo+e+go+ko(e,"shrink","negative")+e;case 5292:return yo+e+go+ko(e,"basis","preferred-size")+e;case 6060:return yo+"box-"+ko(e,"-grow","")+yo+e+go+ko(e,"grow","positive")+e;case 4554:return yo+ko(e,/([^-])(transform)/g,"$1"+yo+"$2")+e;case 6187:return ko(ko(ko(e,/(zoom-|grab)/,yo+"$1"),/(image-set)/,yo+"$1"),e,"")+e;case 5495:case 3959:return ko(e,/(image-set\([^]*)/,yo+"$1$`$1");case 4968:return ko(ko(e,/(.+:)(flex-)?(.*)/,yo+"box-pack:$3"+go+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+yo+e+e;case 4095:case 3583:case 4068:case 2532:return ko(e,/(.+)-inline(.+)/,yo+"$1$2")+e;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(Eo(e)-1-t>6)switch(To(e,t+1)){case 109:if(45!==To(e,t+4))break;case 102:return ko(e,/(.+:)(.+)-([^]+)/,"$1"+yo+"$2-$3$1"+mo+(108==To(e,t+3)?"$3":"$2-$3"))+e;case 115:return~No(e,"stretch")?yi(ko(e,"stretch","fill-available"),t)+e:e}break;case 4949:if(115!==To(e,t+1))break;case 6444:switch(To(e,Eo(e)-3-(~No(e,"!important")&&10))){case 107:return ko(e,":",":"+yo)+e;case 101:return ko(e,/(.+:)([^;!]+)(;|!.+)?/,"$1"+yo+(45===To(e,14)?"inline-":"")+"box$3$1"+yo+"$2$3$1"+go+"$2box$3")+e}break;case 5936:switch(To(e,t+11)){case 114:return yo+e+go+ko(e,/[svh]\w+-[tblr]{2}/,"tb")+e;case 108:return yo+e+go+ko(e,/[svh]\w+-[tblr]{2}/,"tb-rl")+e;case 45:return yo+e+go+ko(e,/[svh]\w+-[tblr]{2}/,"lr")+e}return yo+e+go+e+e}return e}var _i=[function(e,t,n,r){if(e.length>-1&&!e.return)switch(e.type){case bo:e.return=yi(e.value,e.length);break;case xo:return ai([qo(e,{value:ko(e.value,"@","@"+yo)})],r);case vo:if(e.length)return function(e,t){return e.map(t).join("")}(e.props,(function(t){switch(function(e,t){return(e=/(::plac\w+|:read-\w+)/.exec(e))?e[0]:e}(t)){case":read-only":case":read-write":return ai([qo(e,{props:[ko(t,/:(read-\w+)/,":-moz-$1")]})],r);case"::placeholder":return ai([qo(e,{props:[ko(t,/:(plac\w+)/,":"+yo+"input-$1")]}),qo(e,{props:[ko(t,/:(plac\w+)/,":-moz-$1")]}),qo(e,{props:[ko(t,/:(plac\w+)/,go+"input-$1")]})],r)}return""}))}}],vi=function(e){var t=e.key;if("production"!==ae.env.NODE_ENV&&!t)throw new Error("You have to configure `key` for your cache. Please make sure it's unique (and not equal to 'css') as it's used for linking styles to your cache.\nIf multiple caches share the same key they might \"fight\" for each other's style elements.");if("css"===t){var n=document.querySelectorAll("style[data-emotion]:not([data-s])");Array.prototype.forEach.call(n,(function(e){-1!==e.getAttribute("data-emotion").indexOf(" ")&&(document.head.appendChild(e),e.setAttribute("data-s",""))}))}var r=e.stylisPlugins||_i;if("production"!==ae.env.NODE_ENV&&/[^a-z-]/.test(t))throw new Error('Emotion key must only contain lower case alphabetical characters and - but "'+t+'" was passed');var o,i,a={},s=[];o=e.container||document.head,Array.prototype.forEach.call(document.querySelectorAll('style[data-emotion^="'+t+' "]'),(function(e){for(var t=e.getAttribute("data-emotion").split(" "),n=1;n<t.length;n++)a[t[n]]=!0;s.push(e)}));var l=[di,fi];"production"!==ae.env.NODE_ENV&&l.push(function(e){return function(t,n,r){if("rule"===t.type&&!e.compat){var o=t.value.match(/(:first|:nth|:nth-last)-child/g);if(o){for(var i=t.parent?t.parent.children:r,a=i.length-1;a>=0;a--){var s=i[a];if(s.line<t.line)break;if(s.column<t.column){if(hi(s))return;break}}o.forEach((function(e){console.error('The pseudo class "'+e+'" is potentially unsafe when doing server-side rendering. Try changing it to "'+e.split("-child")[0]+'-of-type".')}))}}}}({get compat(){return h.compat}}),mi);var c,u,d=[si,"production"!==ae.env.NODE_ENV?function(e){e.root||(e.return?c.insert(e.return):e.value&&e.type!==_o&&c.insert(e.value+"{}"))}:(u=function(e){c.insert(e)},function(e){e.root||(e=e.return)&&u(e)})],f=function(e){var t=Io(e);return function(n,r,o,i){for(var a="",s=0;s<t;s++)a+=e[s](n,r,o,i)||"";return a}}(l.concat(r,d));i=function(e,t,n,r){c=n,"production"!==ae.env.NODE_ENV&&void 0!==t.map&&(c={insert:function(e){n.insert(e+t.map)}}),function(e){ai(ti(e),f)}(e?e+"{"+t.styles+"}":t.styles),r&&(h.inserted[t.name]=!0)};var h={key:t,sheet:new po({key:t,container:o,nonce:e.nonce,speedy:e.speedy,prepend:e.prepend,insertionPoint:e.insertionPoint}),nonce:e.nonce,inserted:a,registered:{},insert:i};return h.sheet.hydrate(s),h};function bi(){return bi=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},bi.apply(this,arguments)}function xi(e,t,n){var r="";return n.split(" ").forEach((function(n){void 0!==e[n]?t.push(e[n]+";"):r+=n+" "})),r}var wi=function(e,t,n){var r=e.key+"-"+t.name;!1===n&&void 0===e.registered[r]&&(e.registered[r]=t.styles)},Si=function(e,t,n){wi(e,t,n);var r=e.key+"-"+t.name;if(void 0===e.inserted[t.name]){var o=t;do{e.insert(t===o?"."+r:"",o,e.sheet,!0),o=o.next}while(void 0!==o)}},Ci={animationIterationCount:1,aspectRatio:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1},Ai="You have illegal escape sequence in your template literal, most likely inside content's property value.\nBecause you write your CSS inside a JavaScript string you actually have to do double escaping, so for example \"content: '\\00d7';\" should become \"content: '\\\\00d7';\".\nYou can read more about this here:\nhttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#ES2018_revision_of_illegal_escape_sequences",ki=/[A-Z]|^ms/g,Ni=/_EMO_([^_]+?)_([^]*?)_EMO_/g,Ti=function(e){return 45===e.charCodeAt(1)},Ri=function(e){return null!=e&&"boolean"!=typeof e},Ei=li((function(e){return Ti(e)?e:e.replace(ki,"-$&").toLowerCase()})),Ii=function(e,t){switch(e){case"animation":case"animationName":if("string"==typeof t)return t.replace(Ni,(function(e,t,n){return Ui={name:t,styles:n,next:Ui},t}))}return 1===Ci[e]||Ti(e)||"number"!=typeof t||0===t?t:t+"px"};if("production"!==ae.env.NODE_ENV){var ji=/(var|attr|counters?|url|element|(((repeating-)?(linear|radial))|conic)-gradient)\(|(no-)?(open|close)-quote/,Di=["normal","none","initial","inherit","unset"],Oi=Ii,Fi=/^-ms-/,Mi=/-(.)/g,Li={};Ii=function(e,t){if("content"===e&&("string"!=typeof t||-1===Di.indexOf(t)&&!ji.test(t)&&(t.charAt(0)!==t.charAt(t.length-1)||'"'!==t.charAt(0)&&"'"!==t.charAt(0))))throw new Error("You seem to be using a value for 'content' without quotes, try replacing it with `content: '\""+t+"\"'`");var n=Oi(e,t);return""===n||Ti(e)||-1===e.indexOf("-")||void 0!==Li[e]||(Li[e]=!0,console.error("Using kebab-case for css properties in objects is not supported. Did you mean "+e.replace(Fi,"ms-").replace(Mi,(function(e,t){return t.toUpperCase()}))+"?")),n}}var Pi="Component selectors can only be used in conjunction with @emotion/babel-plugin, the swc Emotion plugin, or another Emotion-aware compiler transform.";function Bi(e,t,n){if(null==n)return"";if(void 0!==n.__emotion_styles){if("production"!==ae.env.NODE_ENV&&"NO_COMPONENT_SELECTOR"===n.toString())throw new Error(Pi);return n}switch(K(n)){case"boolean":return"";case"object":if(1===n.anim)return Ui={name:n.name,styles:n.styles,next:Ui},n.name;if(void 0!==n.styles){var r=n.next;if(void 0!==r)for(;void 0!==r;)Ui={name:r.name,styles:r.styles,next:Ui},r=r.next;var o=n.styles+";";return"production"!==ae.env.NODE_ENV&&void 0!==n.map&&(o+=n.map),o}return function(e,t,n){var r="";if(Array.isArray(n))for(var o=0;o<n.length;o++)r+=Bi(e,t,n[o])+";";else for(var i in n){var a=n[i];if("object"!==K(a))null!=t&&void 0!==t[a]?r+=i+"{"+t[a]+"}":Ri(a)&&(r+=Ei(i)+":"+Ii(i,a)+";");else{if("NO_COMPONENT_SELECTOR"===i&&"production"!==ae.env.NODE_ENV)throw new Error(Pi);if(!Array.isArray(a)||"string"!=typeof a[0]||null!=t&&void 0!==t[a[0]]){var s=Bi(e,t,a);switch(i){case"animation":case"animationName":r+=Ei(i)+":"+s+";";break;default:"production"!==ae.env.NODE_ENV&&"undefined"===i&&console.error("You have passed in falsy value as style object's key (can happen when in example you pass unexported component as computed key)."),r+=i+"{"+s+"}"}}else for(var l=0;l<a.length;l++)Ri(a[l])&&(r+=Ei(i)+":"+Ii(i,a[l])+";")}}return r}(e,t,n);case"function":if(void 0!==e){var i=Ui,a=n(e);return Ui=i,Bi(e,t,a)}"production"!==ae.env.NODE_ENV&&console.error("Functions that are interpolated in css calls will be stringified.\nIf you want to have a css call based on props, create a function that returns a css call like this\nlet dynamicStyle = (props) => css`color: ${props.color}`\nIt can be called directly with props or interpolated in a styled call like this\nlet SomeComponent = styled('div')`${dynamicStyle}`");break;case"string":if("production"!==ae.env.NODE_ENV){var s=[],l=n.replace(Ni,(function(e,t,n){var r="animation"+s.length;return s.push("const "+r+" = keyframes`"+n.replace(/^@keyframes animation-\w+/,"")+"`"),"${"+r+"}"}));s.length&&console.error("`keyframes` output got interpolated into plain string, please wrap it with `css`.\n\nInstead of doing this:\n\n"+[].concat(s,["`"+l+"`"]).join("\n")+"\n\nYou should wrap it with `css` like this:\n\ncss`"+l+"`")}}if(null==t)return n;var c=t[n];return void 0!==c?c:n}var qi,Ui,zi=/label:\s*([^\s;\n{]+)\s*(;|$)/g;"production"!==ae.env.NODE_ENV&&(qi=/\/\*#\ssourceMappingURL=data:application\/json;\S+\s+\*\//g);var $i=function(e,t,n){if(1===e.length&&"object"===K(e[0])&&null!==e[0]&&void 0!==e[0].styles)return e[0];var r=!0,o="";Ui=void 0;var i,a=e[0];null==a||void 0===a.raw?(r=!1,o+=Bi(n,t,a)):("production"!==ae.env.NODE_ENV&&void 0===a[0]&&console.error(Ai),o+=a[0]);for(var s=1;s<e.length;s++)o+=Bi(n,t,e[s]),r&&("production"!==ae.env.NODE_ENV&&void 0===a[s]&&console.error(Ai),o+=a[s]);"production"!==ae.env.NODE_ENV&&(o=o.replace(qi,(function(e){return i=e,""}))),zi.lastIndex=0;for(var l,c="";null!==(l=zi.exec(o));)c+="-"+l[1];var u=function(e){for(var t,n=0,r=0,o=e.length;o>=4;++r,o-=4)t=1540483477*(65535&(t=255&e.charCodeAt(r)|(255&e.charCodeAt(++r))<<8|(255&e.charCodeAt(++r))<<16|(255&e.charCodeAt(++r))<<24))+(59797*(t>>>16)<<16),n=1540483477*(65535&(t^=t>>>24))+(59797*(t>>>16)<<16)^1540483477*(65535&n)+(59797*(n>>>16)<<16);switch(o){case 3:n^=(255&e.charCodeAt(r+2))<<16;case 2:n^=(255&e.charCodeAt(r+1))<<8;case 1:n=1540483477*(65535&(n^=255&e.charCodeAt(r)))+(59797*(n>>>16)<<16)}return(((n=1540483477*(65535&(n^=n>>>13))+(59797*(n>>>16)<<16))^n>>>15)>>>0).toString(36)}(o)+c;return"production"!==ae.env.NODE_ENV?{name:u,styles:o,map:i,next:Ui,toString:function(){return"You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."}}:{name:u,styles:o,next:Ui}},Hi=!!w.useInsertionEffect&&w.useInsertionEffect||function(e){return e()},Gi={}.hasOwnProperty,Vi=w.createContext("undefined"!=typeof HTMLElement?vi({key:"css"}):null);"production"!==ae.env.NODE_ENV&&(Vi.displayName="EmotionCacheContext");var Wi=function(e){return u.forwardRef((function(t,n){var r=u.useContext(Vi);return e(t,r,n)}))},Ji=w.createContext({});"production"!==ae.env.NODE_ENV&&(Ji.displayName="EmotionThemeContext");var Ki="__EMOTION_TYPE_PLEASE_DO_NOT_USE__",Yi="__EMOTION_LABEL_PLEASE_DO_NOT_USE__",Xi=function(e){var t=e.cache,n=e.serialized,r=e.isStringTag;return wi(t,n,r),Hi((function(){return Si(t,n,r)})),null},Zi=Wi((function(e,t,n){var r=e.css;"string"==typeof r&&void 0!==t.registered[r]&&(r=t.registered[r]);var o=e[Ki],i=[r],a="";"string"==typeof e.className?a=xi(t.registered,i,e.className):null!=e.className&&(a=e.className+" ");var s=$i(i,void 0,w.useContext(Ji));if("production"!==ae.env.NODE_ENV&&-1===s.name.indexOf("-")){var l=e[Yi];l&&(s=$i([s,"label:"+l+";"]))}a+=t.key+"-"+s.name;var c={};for(var u in e)!Gi.call(e,u)||"css"===u||u===Ki||"production"!==ae.env.NODE_ENV&&u===Yi||(c[u]=e[u]);return c.ref=n,c.className=a,w.createElement(w.Fragment,null,w.createElement(Xi,{cache:t,serialized:s,isStringTag:"string"==typeof o}),w.createElement(o,c))}));"production"!==ae.env.NODE_ENV&&(Zi.displayName="EmotionCssPropInternal");var Qi={animationIterationCount:1,aspectRatio:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,scale:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1};function ea(e){var t=Object.create(null);return function(n){return void 0===t[n]&&(t[n]=e(n)),t[n]}}var ta=/[A-Z]|^ms/g,na=/_EMO_([^_]+?)_([^]*?)_EMO_/g,ra=function(e){return 45===e.charCodeAt(1)},oa=function(e){return null!=e&&"boolean"!=typeof e},ia=ea((function(e){return ra(e)?e:e.replace(ta,"-$&").toLowerCase()})),aa=function(e,t){switch(e){case"animation":case"animationName":if("string"==typeof t)return t.replace(na,(function(e,t,n){return la={name:t,styles:n,next:la},t}))}return 1===Qi[e]||ra(e)||"number"!=typeof t||0===t?t:t+"px"};function sa(e,t,n){if(null==n)return"";if(void 0!==n.__emotion_styles)return n;switch(K(n)){case"boolean":return"";case"object":if(1===n.anim)return la={name:n.name,styles:n.styles,next:la},n.name;var r=n;if(void 0!==r.styles){var o=r.next;if(void 0!==o)for(;void 0!==o;)la={name:o.name,styles:o.styles,next:la},o=o.next;return r.styles+";"}return function(e,t,n){var r="";if(Array.isArray(n))for(var o=0;o<n.length;o++)r+=sa(e,t,n[o])+";";else for(var i in n){var a=n[i];if("object"!==K(a)){var s=a;null!=t&&void 0!==t[s]?r+=i+"{"+t[s]+"}":oa(s)&&(r+=ia(i)+":"+aa(i,s)+";")}else if(!Array.isArray(a)||"string"!=typeof a[0]||null!=t&&void 0!==t[a[0]]){var l=sa(e,t,a);switch(i){case"animation":case"animationName":r+=ia(i)+":"+l+";";break;default:r+=i+"{"+l+"}"}}else for(var c=0;c<a.length;c++)oa(a[c])&&(r+=ia(i)+":"+aa(i,a[c])+";")}return r}(e,t,n)}if(null==t)return n;var i=t[n];return void 0!==i?i:n}var la,ca=/label:\s*([^\s;{]+)\s*(;|$)/g,ua=function(e){for(var t=e.length,n=0,r="";n<t;n++){var o=e[n];if(null!=o){var i=void 0;switch(K(o)){case"boolean":break;case"object":if(Array.isArray(o))i=ua(o);else{var a=o;for(var s in i="",a)a[s]&&s&&(i&&(i+=" "),i+=s)}break;default:i=o}i&&(r&&(r+=" "),r+=i)}}return r},da=function(){return{createCssAndCx:function(e){var t=e.cache,n=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];var o=function(e,t,n){if(1===e.length&&"object"===K(e[0])&&null!==e[0]&&void 0!==e[0].styles)return e[0];var r=!0,o="";la=void 0;var i=e[0];null==i||void 0===i.raw?(r=!1,o+=sa(n,t,i)):o+=i[0];for(var a=1;a<e.length;a++)o+=sa(n,t,e[a]),r&&(o+=i[a]);ca.lastIndex=0;for(var s,l="";null!==(s=ca.exec(o));)l+="-"+s[1];var c=function(e){for(var t,n=0,r=0,o=e.length;o>=4;++r,o-=4)t=1540483477*(65535&(t=255&e.charCodeAt(r)|(255&e.charCodeAt(++r))<<8|(255&e.charCodeAt(++r))<<16|(255&e.charCodeAt(++r))<<24))+(59797*(t>>>16)<<16),n=1540483477*(65535&(t^=t>>>24))+(59797*(t>>>16)<<16)^1540483477*(65535&n)+(59797*(n>>>16)<<16);switch(o){case 3:n^=(255&e.charCodeAt(r+2))<<16;case 2:n^=(255&e.charCodeAt(r+1))<<8;case 1:n=1540483477*(65535&(n^=255&e.charCodeAt(r)))+(59797*(n>>>16)<<16)}return(((n=1540483477*(65535&(n^=n>>>13))+(59797*(n>>>16)<<16))^n>>>15)>>>0).toString(36)}(o)+l;return{name:c,styles:o,next:la}}(n,t.registered);!function(e,t,n){!function(e,t,n){var r=e.key+"-"+t.name;void 0===e.registered[r]&&(e.registered[r]=t.styles)}(e,t);var r=e.key+"-"+t.name;if(void 0===e.inserted[t.name]){var o=t;do{e.insert(t===o?"."+r:"",o,e.sheet,!0),o=o.next}while(void 0!==o)}}(t,o);var i="".concat(t.key,"-").concat(o.name),a=n[0];return function(e){return e instanceof Object&&!("styles"in e)&&!("length"in e)&&!("__emotion_styles"in e)}(a)&&ha.saveClassNameCSSObjectMapping(t,i,a),i};return{css:n,cx:function(){for(var e=arguments.length,r=new Array(e),o=0;o<e;o++)r[o]=arguments[o];var i=ua(r),a=ha.fixClassName(t,i,n);return function(e,t,n){var r=[],o=function(e,t,n){var r="";return n.split(" ").forEach((function(n){void 0!==e[n]?t.push(e[n]+";"):n&&(r+=n+" ")})),r}(e,r,n);return r.length<2?n:o+t(r)}(t.registered,n,a)}}}}}(),fa=da.createCssAndCx,ha=function(){var e=new WeakMap;return{saveClassNameCSSObjectMapping:function(t,n,r){var o=e.get(t);void 0===o&&(o=new Map,e.set(t,o)),o.set(n,r)},fixClassName:function(t,n,r){if(!n.includes(" "))return n;var o,i,a=e.get(t);return ua((o=n.split(" ").map((function(e){return[e,null==a?void 0:a.get(e)]})),i=!1,o.map((function(e){var t,n=G(e,2),r=n[0],o=n[1];if(void 0===o)return r;if(i)t={"&&":o};else for(var a in t=r,o)if(a.startsWith("@media")){i=!0;break}return t}))).map((function(e){return"string"==typeof e?e:r(e)})))}}}(),pa=function(){return u.useContext(Vi)};function ga(e){var t=e.useTheme,n=function(e){var t=e.useCache;return{useCssAndCx:function(){var e=t(),n=u.useMemo((function(){return fa({cache:e})}),[e]);return{css:n.css,cx:n.cx}}}}({useCache:pa}),r=n.useCssAndCx;return{makeStyles:function(){return function(e){var n="function"==typeof e?e:function(){return e};return function(e,o){var i=t(),a=r(),s=a.css,l=a.cx,c=u.useMemo((function(){for(var e=n(i),t={},r=0,o=Object.keys(e);r<o.length;r++){var a=o[r];t[a]=s(e[a])}return t}),[s,i]),d=null==o?void 0:o.props.classes,f=function(e){if(!(e instanceof Object)||"function"==typeof e)return e;var t=[];for(var n in e){var r=e[n],o=K(r);if("string"!==o&&("number"!==o||isNaN(r))&&"boolean"!==o&&null!=r)return e;t.push("".concat(n,":").concat(o,"_").concat(r))}return"xSqLiJdLMd9s".concat(t.join("|"))}(d),h=u.useMemo((function(){return d?function(e,t,n){if(!(t instanceof Object))return e;var r=Object.keys(t);if(0===r.length)return e;for(var o={},i=0,a=Object.keys(e);i<a.length;i++){var s=a[i];o[s]=n(e[s],t[s])}for(var l=0,c=r;l<c.length;l++){var u=c[l];if(!(u in e)){var d=t[u];"string"==typeof d&&(o[u]=d)}}return o}(c,d,l):c}),[c,f,l]);return{classes:h,theme:i,css:s,cx:l}}}}}}var ma=ga({useTheme:g.useTheme}).makeStyles,ya=a.createSvgIcon(i.jsx("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m1 15h-2v-6h2zm0-8h-2V7h2z"}),"Info"),_a=a.createSvgIcon(i.jsx("path",{d:"M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1M8 13h8v-2H8zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5"}),"Link"),va=a.createSvgIcon(i.jsx("path",{d:"M12 7c-2.76 0-5 2.24-5 5s2.24 5 5 5 5-2.24 5-5-2.24-5-5-5m0-5C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8"}),"RadioButtonChecked"),ba=a.createSvgIcon(i.jsx("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8"}),"RadioButtonUnchecked");function xa(e){const{attributes:t}=e,n=t.get("gff_name");return n?n[0]:""}function wa(e){const{attributes:t}=e,n=t.get("gff_id"),r=t.get("transcript_id"),o=t.get("exon_id"),i=t.get("protein_id");return n?n[0]:r?r[0]:o?o[0]:i?i[0]:""}function Sa(e){const t=xa(e),n=wa(e);return t?`: ${t}`:n?`: ${n}`:""}function Ca(e,t,n=!1){const r=[];r.push(e);for(const t of function(e){const t=[];let{parent:n}=e;for(;n;)t.push(n),({parent:n}=n);return t}(e))r.push(t);const o=function(e){const t=[];if(e.children)for(const[,n]of e.children)t.push(n);return t}(e);for(const e of o)e.min<t&&e.max>=t&&r.push(e);if(!n)return r;if(e.parent){const n=e.parent.children;if(n)for(const[,o]of n)o._id!=e._id&&o.min<t&&o.max>=t&&r.push(o)}return r}function Aa(e,t){if(e.attributes){const n={};for(const[r,o]of Object.entries(e.attributes))t.has(r)||(n[r]=o);e.attributes=0===Object.keys(n).length?void 0:n}if(e.children){const n={};for(const[r,o]of Object.entries(e.children)){const e={...o};Aa(e,t),n[r]=e}e.children=n}}var ka,Na,Ta=a.createSvgIcon(i.jsx("path",{d:"m7.58 16.89 5.77-4.07c.56-.4.56-1.24 0-1.63L7.58 7.11C6.91 6.65 6 7.12 6 7.93v8.14c0 .81.91 1.28 1.58.82M16 7v10c0 .55.45 1 1 1s1-.45 1-1V7c0-.55-.45-1-1-1s-1 .45-1 1"}),"SkipNextRounded"),Ra=a.createSvgIcon(i.jsx("path",{d:"M7 6c.55 0 1 .45 1 1v10c0 .55-.45 1-1 1s-1-.45-1-1V7c0-.55.45-1 1-1m3.66 6.82 5.77 4.07c.66.47 1.58-.01 1.58-.82V7.93c0-.81-.91-1.28-1.58-.82l-5.77 4.07c-.57.4-.57 1.24 0 1.64"}),"SkipPreviousRounded"),Ea=function(e,t){return t.some((function(t){return e instanceof t}))},Ia=new WeakMap,ja=new WeakMap,Da=new WeakMap,Oa=new WeakMap,Fa=new WeakMap,Ma={get:function(e,t,n){if(e instanceof IDBTransaction){if("done"===t)return ja.get(e);if("objectStoreNames"===t)return e.objectStoreNames||Da.get(e);if("store"===t)return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return Pa(e[t])},set:function(e,t,n){return e[t]=n,!0},has:function(e,t){return e instanceof IDBTransaction&&("done"===t||"store"===t)||t in e}};function La(e){Ma=e(Ma)}function Pa(e){if(e instanceof IDBRequest)return t=e,(n=new Promise((function(e,n){var r=function(){t.removeEventListener("success",o),t.removeEventListener("error",i)},o=function(){e(Pa(t.result)),r()},i=function(){n(t.error),r()};t.addEventListener("success",o),t.addEventListener("error",i)}))).then((function(e){e instanceof IDBCursor&&Ia.set(e,t)})).catch((function(){})),Fa.set(n,t),n;var t,n;if(Oa.has(e))return Oa.get(e);var r=function(e){return"function"==typeof e?(t=e)!==IDBDatabase.prototype.transaction||"objectStoreNames"in IDBTransaction.prototype?(Na||(Na=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(t)?function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return t.apply(Ba(this),n),Pa(Ia.get(this))}:function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return Pa(t.apply(Ba(this),n))}:function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];var i=t.call.apply(t,[Ba(this),e].concat(r));return Da.set(i,e.sort?e.sort():[e]),Pa(i)}:(e instanceof IDBTransaction&&function(e){if(!ja.has(e)){var t=new Promise((function(t,n){var r=function(){e.removeEventListener("complete",o),e.removeEventListener("error",i),e.removeEventListener("abort",i)},o=function(){t(),r()},i=function(){n(e.error||new DOMException("AbortError","AbortError")),r()};e.addEventListener("complete",o),e.addEventListener("error",i),e.addEventListener("abort",i)}));ja.set(e,t)}}(e),Ea(e,ka||(ka=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction]))?new Proxy(e,Ma):e);var t}(e);return r!==e&&(Oa.set(e,r),Fa.set(r,e)),r}var Ba=function(e){return Fa.get(e)};function qa(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.blocked,o=n.upgrade,i=n.blocking,a=n.terminated,s=indexedDB.open(e,t),l=Pa(s);return o&&s.addEventListener("upgradeneeded",(function(e){o(Pa(s.result),e.oldVersion,e.newVersion,Pa(s.transaction),e)})),r&&s.addEventListener("blocked",(function(e){return r(e.oldVersion,e.newVersion,e)})),l.then((function(e){a&&e.addEventListener("close",(function(){return a()})),i&&e.addEventListener("versionchange",(function(e){return i(e.oldVersion,e.newVersion,e)}))})).catch((function(){})),l}var Ua=["get","getKey","getAll","getAllKeys","count"],za=["put","add","delete","clear"],$a=new Map;function Ha(e,t){if(e instanceof IDBDatabase&&!(t in e)&&"string"==typeof t){if($a.get(t))return $a.get(t);var n=t.replace(/FromIndex$/,""),r=t!==n,o=za.includes(n);if(n in(r?IDBIndex:IDBObjectStore).prototype&&(o||Ua.includes(n))){var i=function(){var e=k(U().m((function e(t){var i,a,s,l,c,u,d=arguments;return U().w((function(e){for(;;)switch(e.n){case 0:for(a=this.transaction(t,o?"readwrite":"readonly"),s=a.store,l=d.length,c=new Array(l>1?l-1:0),u=1;u<l;u++)c[u-1]=d[u];return r&&(s=s.index(c.shift())),e.n=1,Promise.all([(i=s)[n].apply(i,c),o&&a.done]);case 1:return e.a(2,e.v[0])}}),e,this)})));return function(t){return e.apply(this,arguments)}}();return $a.set(t,i),i}}}La((function(e){return B(B({},e),{},{get:function(t,n,r){return Ha(t,n)||e.get(t,n,r)},has:function(t,n){return!!Ha(t,n)||e.has(t,n)}})}));var Ga=["continue","continuePrimaryKey","advance"],Va={},Wa=new WeakMap,Ja=new WeakMap,Ka={get:function(e,t){if(!Ga.includes(t))return e[t];var n=Va[t];return n||(n=Va[t]=function(){var e;Wa.set(this,(e=Ja.get(this))[t].apply(e,arguments))}),n}};function Ya(){return Xa.apply(this,arguments)}function Xa(){return Xa=function(e){return function(){return new X(e.apply(this,arguments))}}(U().m((function e(){var t,n,r,o=arguments;return U().w((function(e){for(;;)switch(e.n){case 0:if((t=this)instanceof IDBCursor){e.n=2;break}return e.n=1,N((n=t).openCursor.apply(n,o));case 1:t=e.v;case 2:if(t){e.n=3;break}return e.a(2);case 3:r=new Proxy(t,Ka),Ja.set(r,t),Fa.set(r,Ba(t));case 4:if(!t){e.n=7;break}return e.n=5,r;case 5:return e.n=6,N(Wa.get(r)||t.continue());case 6:t=e.v,Wa.delete(r),e.n=4;break;case 7:return e.a(2)}}),e,this)}))),Xa.apply(this,arguments)}function Za(e,t){return t===Symbol.asyncIterator&&Ea(e,[IDBIndex,IDBObjectStore,IDBCursor])||"iterate"===t&&Ea(e,[IDBIndex,IDBObjectStore])}La((function(e){return B(B({},e),{},{get:function(t,n,r){return Za(t,n)?Ya:e.get(t,n,r)},has:function(t,n){return Za(t,n)||e.has(t,n)}})}));var Qa=function(e){function t(){var e;R(this,t);for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return D(e=T(this,t,[].concat(r)),"code",void 0),e}return M(t,e),I(t)}(Z(Error));function es(e){if(e){if(!(e instanceof AbortSignal))throw new TypeError("must pass an AbortSignal");if(e.aborted)throw function(){if("undefined"!=typeof DOMException)return new DOMException("aborted","AbortError");var e=new Qa("aborted");return e.code="ERR_ABORTED",e}()}}function ts(e){return e instanceof Error&&("AbortError"===e.name||"ERR_ABORTED"===e.code||/\b(aborted|aborterror)\b/i.test(e.message))}function ns(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var rs,os={exports:{}},is=(rs||(rs=1,function(e,t){e.exports=function e(t,n,r){function o(a,s){if(!n[a]){if(!t[a]){if(!s&&ns)return ns(a);if(i)return i(a,!0);var l=new Error("Cannot find module '"+a+"'");throw l.code="MODULE_NOT_FOUND",l}var c=n[a]={exports:{}};t[a][0].call(c.exports,(function(e){return o(t[a][1][e]||e)}),c,c.exports,e,t,n,r)}return n[a].exports}for(var i=ns,a=0;a<r.length;a++)o(r[a]);return o}({"./aesprim":[function(e,t,n){var r;r=function(e){var t,n,r,o,i,a,s,l,c,u,d,f,h,p,g,m,y,_;function v(e,t){if(!e)throw new Error("ASSERT: "+t)}function b(e){return e>=48&&e<=57}function x(e){return"0123456789abcdefABCDEF".indexOf(e)>=0}function w(e){return"01234567".indexOf(e)>=0}function S(e){return 32===e||9===e||11===e||12===e||160===e||e>=5760&&[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279].indexOf(e)>=0}function C(e){return 10===e||13===e||8232===e||8233===e}function A(e){return 64==e||36===e||95===e||e>=65&&e<=90||e>=97&&e<=122||92===e||e>=128&&s.NonAsciiIdentifierStart.test(String.fromCharCode(e))}function k(e){return 36===e||95===e||e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||92===e||e>=128&&s.NonAsciiIdentifierPart.test(String.fromCharCode(e))}function N(e){switch(e){case"implements":case"interface":case"package":case"private":case"protected":case"public":case"static":case"yield":case"let":return!0;default:return!1}}function T(e){return"eval"===e||"arguments"===e}function R(e){if(u&&N(e))return!0;switch(e.length){case 2:return"if"===e||"in"===e||"do"===e;case 3:return"var"===e||"for"===e||"new"===e||"try"===e||"let"===e;case 4:return"this"===e||"else"===e||"case"===e||"void"===e||"with"===e||"enum"===e;case 5:return"while"===e||"break"===e||"catch"===e||"throw"===e||"const"===e||"yield"===e||"class"===e||"super"===e;case 6:return"return"===e||"typeof"===e||"delete"===e||"switch"===e||"export"===e||"import"===e;case 7:return"default"===e||"finally"===e||"extends"===e;case 8:return"function"===e||"continue"===e||"debugger"===e;case 10:return"instanceof"===e;default:return!1}}function E(e,t,n,r,o){var i;v("number"==typeof n,"Comment must have valid position"),y.lastCommentStart>=n||(y.lastCommentStart=n,i={type:e,value:t},_.range&&(i.range=[n,r]),_.loc&&(i.loc=o),_.comments.push(i),_.attachComment&&(_.leadingComments.push(i),_.trailingComments.push(i)))}function I(e){var t,n,r,o;for(t=d-e,n={start:{line:f,column:d-h-e}};d<p;)if(r=c.charCodeAt(d),++d,C(r))return _.comments&&(o=c.slice(t+e,d-1),n.end={line:f,column:d-h-1},E("Line",o,t,d-1,n)),13===r&&10===c.charCodeAt(d)&&++d,++f,void(h=d);_.comments&&(o=c.slice(t+e,d),n.end={line:f,column:d-h},E("Line",o,t,d,n))}function j(){var e,t,n,r;for(_.comments&&(e=d-2,t={start:{line:f,column:d-h-2}});d<p;)if(C(n=c.charCodeAt(d)))13===n&&10===c.charCodeAt(d+1)&&++d,++f,++d,h=d,d>=p&&J({},a.UnexpectedToken,"ILLEGAL");else if(42===n){if(47===c.charCodeAt(d+1))return++d,++d,void(_.comments&&(r=c.slice(e+2,d-2),t.end={line:f,column:d-h},E("Block",r,e,d,t)));++d}else++d;J({},a.UnexpectedToken,"ILLEGAL")}function D(){var e,t;for(t=0===d;d<p;)if(S(e=c.charCodeAt(d)))++d;else if(C(e))++d,13===e&&10===c.charCodeAt(d)&&++d,++f,h=d,t=!0;else if(47===e)if(47===(e=c.charCodeAt(d+1)))++d,++d,I(2),t=!0;else{if(42!==e)break;++d,++d,j()}else if(t&&45===e){if(45!==c.charCodeAt(d+1)||62!==c.charCodeAt(d+2))break;d+=3,I(3)}else{if(60!==e)break;if("!--"!==c.slice(d+1,d+4))break;++d,++d,++d,++d,I(4)}}function O(e){var t,n,r,o=0;for(n="u"===e?4:2,t=0;t<n;++t){if(!(d<p&&x(c[d])))return"";r=c[d++],o=16*o+"0123456789abcdef".indexOf(r.toLowerCase())}return String.fromCharCode(o)}function F(){var e,t;for(e=c.charCodeAt(d++),t=String.fromCharCode(e),92===e&&(117!==c.charCodeAt(d)&&J({},a.UnexpectedToken,"ILLEGAL"),++d,(e=O("u"))&&"\\"!==e&&A(e.charCodeAt(0))||J({},a.UnexpectedToken,"ILLEGAL"),t=e);d<p&&k(e=c.charCodeAt(d));)++d,t+=String.fromCharCode(e),92===e&&(t=t.substr(0,t.length-1),117!==c.charCodeAt(d)&&J({},a.UnexpectedToken,"ILLEGAL"),++d,(e=O("u"))&&"\\"!==e&&k(e.charCodeAt(0))||J({},a.UnexpectedToken,"ILLEGAL"),t+=e);return t}function M(){var e,t;for(e=d++;d<p;){if(92===(t=c.charCodeAt(d)))return d=e,F();if(!k(t))break;++d}return c.slice(e,d)}function L(){var e,n,r,o,i=d,s=c.charCodeAt(d),l=c[d];switch(s){case 46:case 40:case 41:case 59:case 44:case 123:case 125:case 91:case 93:case 58:case 63:case 126:return++d,_.tokenize&&(40===s?_.openParenToken=_.tokens.length:123===s&&(_.openCurlyToken=_.tokens.length)),{type:t.Punctuator,value:String.fromCharCode(s),lineNumber:f,lineStart:h,start:i,end:d};default:if(61===(e=c.charCodeAt(d+1)))switch(s){case 43:case 45:case 47:case 60:case 62:case 94:case 124:case 37:case 38:case 42:return d+=2,{type:t.Punctuator,value:String.fromCharCode(s)+String.fromCharCode(e),lineNumber:f,lineStart:h,start:i,end:d};case 33:case 61:return 61===c.charCodeAt(d+=2)&&++d,{type:t.Punctuator,value:c.slice(i,d),lineNumber:f,lineStart:h,start:i,end:d}}}return">>>="===(o=c.substr(d,4))?{type:t.Punctuator,value:o,lineNumber:f,lineStart:h,start:i,end:d+=4}:">>>"===(r=o.substr(0,3))||"<<="===r||">>="===r?{type:t.Punctuator,value:r,lineNumber:f,lineStart:h,start:i,end:d+=3}:l===(n=r.substr(0,2))[1]&&"+-<>&|".indexOf(l)>=0||"=>"===n?{type:t.Punctuator,value:n,lineNumber:f,lineStart:h,start:i,end:d+=2}:"<>=!+-*%&|^/".indexOf(l)>=0?(++d,{type:t.Punctuator,value:l,lineNumber:f,lineStart:h,start:i,end:d}):void J({},a.UnexpectedToken,"ILLEGAL")}function P(){var e,n,r;if(v(b((r=c[d]).charCodeAt(0))||"."===r,"Numeric literal must start with a decimal digit or a decimal point"),n=d,e="","."!==r){if(e=c[d++],r=c[d],"0"===e){if("x"===r||"X"===r)return++d,function(e){for(var n="";d<p&&x(c[d]);)n+=c[d++];return 0===n.length&&J({},a.UnexpectedToken,"ILLEGAL"),A(c.charCodeAt(d))&&J({},a.UnexpectedToken,"ILLEGAL"),{type:t.NumericLiteral,value:parseInt("0x"+n,16),lineNumber:f,lineStart:h,start:e,end:d}}(n);if(w(r))return function(e){for(var n="0"+c[d++];d<p&&w(c[d]);)n+=c[d++];return(A(c.charCodeAt(d))||b(c.charCodeAt(d)))&&J({},a.UnexpectedToken,"ILLEGAL"),{type:t.NumericLiteral,value:parseInt(n,8),octal:!0,lineNumber:f,lineStart:h,start:e,end:d}}(n);r&&b(r.charCodeAt(0))&&J({},a.UnexpectedToken,"ILLEGAL")}for(;b(c.charCodeAt(d));)e+=c[d++];r=c[d]}if("."===r){for(e+=c[d++];b(c.charCodeAt(d));)e+=c[d++];r=c[d]}if("e"===r||"E"===r)if(e+=c[d++],"+"!==(r=c[d])&&"-"!==r||(e+=c[d++]),b(c.charCodeAt(d)))for(;b(c.charCodeAt(d));)e+=c[d++];else J({},a.UnexpectedToken,"ILLEGAL");return A(c.charCodeAt(d))&&J({},a.UnexpectedToken,"ILLEGAL"),{type:t.NumericLiteral,value:parseFloat(e),lineNumber:f,lineStart:h,start:n,end:d}}function B(){var e,n,r,o;return m=null,D(),e=d,n=function(){var e,t,n,r;for(v("/"===(e=c[d]),"Regular expression literal must start with a slash"),t=c[d++],n=!1,r=!1;d<p;)if(t+=e=c[d++],"\\"===e)C((e=c[d++]).charCodeAt(0))&&J({},a.UnterminatedRegExp),t+=e;else if(C(e.charCodeAt(0)))J({},a.UnterminatedRegExp);else if(n)"]"===e&&(n=!1);else{if("/"===e){r=!0;break}"["===e&&(n=!0)}return r||J({},a.UnterminatedRegExp),{value:t.substr(1,t.length-2),literal:t}}(),r=function(){var e,t,n,r;for(t="",n="";d<p&&k((e=c[d]).charCodeAt(0));)if(++d,"\\"===e&&d<p)if("u"===(e=c[d])){if(r=++d,e=O("u"))for(n+=e,t+="\\u";r<d;++r)t+=c[r];else d=r,n+="u",t+="\\u";K({},a.UnexpectedToken,"ILLEGAL")}else t+="\\",K({},a.UnexpectedToken,"ILLEGAL");else n+=e,t+=e;return{value:n,literal:t}}(),o=function(e,t){var n;try{n=new RegExp(e,t)}catch(e){J({},a.InvalidRegExp)}return n}(n.value,r.value),_.tokenize?{type:t.RegularExpression,value:o,lineNumber:f,lineStart:h,start:e,end:d}:{literal:n.literal+r.literal,value:o,start:e,end:d}}function q(){var e,t,n,r;return D(),e=d,t={start:{line:f,column:d-h}},n=B(),t.end={line:f,column:d-h},_.tokenize||(_.tokens.length>0&&(r=_.tokens[_.tokens.length-1]).range[0]===e&&"Punctuator"===r.type&&("/"!==r.value&&"/="!==r.value||_.tokens.pop()),_.tokens.push({type:"RegularExpression",value:n.literal,range:[e,d],loc:t})),n}function U(){var e,n,o;return D(),d>=p?{type:t.EOF,lineNumber:f,lineStart:h,start:d,end:d}:A(e=c.charCodeAt(d))?(n=d,{type:1===(o=92===c.charCodeAt(d)?F():M()).length?t.Identifier:R(o)?t.Keyword:"null"===o?t.NullLiteral:"true"===o||"false"===o?t.BooleanLiteral:t.Identifier,value:o,lineNumber:f,lineStart:h,start:n,end:d}):40===e||41===e||59===e?L():39===e||34===e?function(){var e,n,r,o,i,s,l,u,g="",m=!1;for(l=f,u=h,v("'"===(e=c[d])||'"'===e,"String literal must starts with a quote"),n=d,++d;d<p;){if((r=c[d++])===e){e="";break}if("\\"===r)if((r=c[d++])&&C(r.charCodeAt(0)))++f,"\r"===r&&"\n"===c[d]&&++d,h=d;else switch(r){case"u":case"x":s=d,(i=O(r))?g+=i:(d=s,g+=r);break;case"n":g+="\n";break;case"r":g+="\r";break;case"t":g+="\t";break;case"b":g+="\b";break;case"f":g+="\f";break;case"v":g+="\v";break;default:w(r)?(0!==(o="01234567".indexOf(r))&&(m=!0),d<p&&w(c[d])&&(m=!0,o=8*o+"01234567".indexOf(c[d++]),"0123".indexOf(r)>=0&&d<p&&w(c[d])&&(o=8*o+"01234567".indexOf(c[d++]))),g+=String.fromCharCode(o)):g+=r}else{if(C(r.charCodeAt(0)))break;g+=r}}return""!==e&&J({},a.UnexpectedToken,"ILLEGAL"),{type:t.StringLiteral,value:g,octal:m,startLineNumber:l,startLineStart:u,lineNumber:f,lineStart:h,start:n,end:d}}():46===e?b(c.charCodeAt(d+1))?P():L():b(e)?P():_.tokenize&&47===e?function(){var e,t;if(!(e=_.tokens[_.tokens.length-1]))return q();if("Punctuator"===e.type){if("]"===e.value)return L();if(")"===e.value)return!(t=_.tokens[_.openParenToken-1])||"Keyword"!==t.type||"if"!==t.value&&"while"!==t.value&&"for"!==t.value&&"with"!==t.value?L():q();if("}"===e.value){if(_.tokens[_.openCurlyToken-3]&&"Keyword"===_.tokens[_.openCurlyToken-3].type){if(!(t=_.tokens[_.openCurlyToken-4]))return L()}else{if(!_.tokens[_.openCurlyToken-4]||"Keyword"!==_.tokens[_.openCurlyToken-4].type)return L();if(!(t=_.tokens[_.openCurlyToken-5]))return q()}return r.indexOf(t.value)>=0?L():q()}return q()}return"Keyword"===e.type?q():L()}():L()}function z(){var e,r,o;return D(),e={start:{line:f,column:d-h}},r=U(),e.end={line:f,column:d-h},r.type!==t.EOF&&(o=c.slice(r.start,r.end),_.tokens.push({type:n[r.type],value:o,range:[r.start,r.end],loc:e})),r}function $(){var e;return d=(e=m).end,f=e.lineNumber,h=e.lineStart,m=void 0!==_.tokens?z():U(),d=e.end,f=e.lineNumber,h=e.lineStart,e}function H(){var e,t,n;e=d,t=f,n=h,m=void 0!==_.tokens?z():U(),d=e,f=t,h=n}function G(e,t){this.line=e,this.column=t}function V(e,t,n,r){this.start=new G(e,t),this.end=new G(n,r)}function W(){var e,t,n,r;return e=d,t=f,n=h,D(),r=f!==t,d=e,f=t,h=n,r}function J(e,t){var n,r=Array.prototype.slice.call(arguments,2),o=t.replace(/%(\d)/g,(function(e,t){return v(t<r.length,"Message reference must be in range"),r[t]}));throw"number"==typeof e.lineNumber?((n=new Error("Line "+e.lineNumber+": "+o)).index=e.start,n.lineNumber=e.lineNumber,n.column=e.start-h+1):((n=new Error("Line "+f+": "+o)).index=d,n.lineNumber=f,n.column=d-h+1),n.description=o,n}function K(){try{J.apply(null,arguments)}catch(e){if(!_.errors)throw e;_.errors.push(e)}}function Y(e){if(e.type===t.EOF&&J(e,a.UnexpectedEOS),e.type===t.NumericLiteral&&J(e,a.UnexpectedNumber),e.type===t.StringLiteral&&J(e,a.UnexpectedString),e.type===t.Identifier&&J(e,a.UnexpectedIdentifier),e.type===t.Keyword){if(function(e){switch(e){case"class":case"enum":case"export":case"extends":case"import":case"super":return!0;default:return!1}}(e.value))J(e,a.UnexpectedReserved);else if(u&&N(e.value))return void K(e,a.StrictReservedWord);J(e,a.UnexpectedToken,e.value)}J(e,a.UnexpectedToken,e.value)}function X(e){var n=$();n.type===t.Punctuator&&n.value===e||Y(n)}function Z(e){var n=$();n.type===t.Keyword&&n.value===e||Y(n)}function Q(e){return m.type===t.Punctuator&&m.value===e}function ee(e){return m.type===t.Keyword&&m.value===e}function te(){var e;59===c.charCodeAt(d)||Q(";")?$():(e=f,D(),f===e&&(m.type===t.EOF||Q("}")||Y(m)))}function ne(e){return e.type===o.Identifier||e.type===o.MemberExpression}function re(e,t){var n,r,o;return n=u,o=m,r=we(),t&&u&&T(e[0].name)&&K(t,a.StrictParamName),u=n,g.markEnd(g.createFunctionExpression(null,e,[],r),o)}function oe(){var e,n;return n=m,(e=$()).type===t.StringLiteral||e.type===t.NumericLiteral?(u&&e.octal&&K(e,a.StrictOctalLiteral),g.markEnd(g.createLiteral(e),n)):g.markEnd(g.createIdentifier(e.value),n)}function ie(){var e,n,r,o,i,s;return s=m,(e=m).type===t.Identifier?(r=oe(),"get"!==e.value||Q(":")?"set"!==e.value||Q(":")?(X(":"),o=pe(),g.markEnd(g.createProperty("init",r,o),s)):(n=oe(),X("("),(e=m).type!==t.Identifier?(X(")"),K(e,a.UnexpectedToken,e.value),o=re([])):(i=[ye()],X(")"),o=re(i,e)),g.markEnd(g.createProperty("set",n,o),s)):(n=oe(),X("("),X(")"),o=re([]),g.markEnd(g.createProperty("get",n,o),s))):e.type!==t.EOF&&e.type!==t.Punctuator?(n=oe(),X(":"),o=pe(),g.markEnd(g.createProperty("init",n,o),s)):void Y(e)}function ae(){var e,n,r,s;if(Q("("))return function(){var e;return X("("),e=ge(),X(")"),e}();if(Q("["))return function(){var e,t=[];for(e=m,X("[");!Q("]");)Q(",")?($(),t.push(null)):(t.push(pe()),Q("]")||X(","));return $(),g.markEnd(g.createArrayExpression(t),e)}();if(Q("{"))return function(){var e,t,n,r,s,l=[],c={},d=String;for(s=m,X("{");!Q("}");)t=(e=ie()).key.type===o.Identifier?e.key.name:d(e.key.value),r="init"===e.kind?i.Data:"get"===e.kind?i.Get:i.Set,n="$"+t,Object.prototype.hasOwnProperty.call(c,n)?(c[n]===i.Data?u&&r===i.Data?K({},a.StrictDuplicateProperty):r!==i.Data&&K({},a.AccessorDataProperty):r===i.Data?K({},a.AccessorDataProperty):c[n]&r&&K({},a.AccessorGetSet),c[n]|=r):c[n]=r,l.push(e),Q("}")||X(",");return X("}"),g.markEnd(g.createObjectExpression(l),s)}();if(s=m,(e=m.type)===t.Identifier)r=g.createIdentifier($().value);else if(e===t.StringLiteral||e===t.NumericLiteral)u&&m.octal&&K(m,a.StrictOctalLiteral),r=g.createLiteral($());else if(e===t.Keyword){if(ee("function"))return function(){var e,t,n,r,o,i,s,l,c,d=null;return l=m,Z("function"),Q("(")||(e=m,d=ye(),u?T(e.value)&&K(e,a.StrictFunctionName):T(e.value)?(n=e,r=a.StrictFunctionName):N(e.value)&&(n=e,r=a.StrictReservedWord)),c=(o=Se(n)).params,t=o.stricted,n=o.firstRestricted,o.message&&(r=o.message),s=u,i=we(),u&&n&&J(n,r),u&&t&&K(t,r),u=s,g.markEnd(g.createFunctionExpression(d,c,[],i),l)}();ee("this")?($(),r=g.createThisExpression()):Y($())}else e===t.BooleanLiteral?((n=$()).value="true"===n.value,r=g.createLiteral(n)):e===t.NullLiteral?((n=$()).value=null,r=g.createLiteral(n)):Q("/")||Q("/=")?(r=g.createLiteral(void 0!==_.tokens?q():B()),H()):Y($());return g.markEnd(r,s)}function se(){var e=[];if(X("("),!Q(")"))for(;d<p&&(e.push(pe()),!Q(")"));)X(",");return X(")"),e}function le(){return X("."),function(){var e,n;return n=m,function(e){return e.type===t.Identifier||e.type===t.Keyword||e.type===t.BooleanLiteral||e.type===t.NullLiteral}(e=$())||Y(e),g.markEnd(g.createIdentifier(e.value),n)}()}function ce(){var e;return X("["),e=ge(),X("]"),e}function ue(){var e,t,n;return n=m,Z("new"),e=function(){var e,t,n,r;for(r=m,e=y.allowIn,t=ee("new")?ue():ae(),y.allowIn=e;Q(".")||Q("[");)Q("[")?(n=ce(),t=g.createMemberExpression("[",t,n)):(n=le(),t=g.createMemberExpression(".",t,n)),g.markEnd(t,r);return t}(),t=Q("(")?se():[],g.markEnd(g.createNewExpression(e,t),n)}function de(){var e,n,r=m;return e=function(){var e,t,n,r,o;for(o=m,e=y.allowIn,y.allowIn=!0,t=ee("new")?ue():ae(),y.allowIn=e;;){if(Q("."))r=le(),t=g.createMemberExpression(".",t,r);else if(Q("("))n=se(),t=g.createCallExpression(t,n);else{if(!Q("["))break;r=ce(),t=g.createMemberExpression("[",t,r)}g.markEnd(t,o)}return t}(),m.type===t.Punctuator&&(!Q("++")&&!Q("--")||W()||(u&&e.type===o.Identifier&&T(e.name)&&K({},a.StrictLHSPostfix),ne(e)||K({},a.InvalidLHSInAssignment),n=$(),e=g.markEnd(g.createPostfixExpression(n.value,e),r))),e}function fe(){var e,n,r;return m.type!==t.Punctuator&&m.type!==t.Keyword?n=de():Q("++")||Q("--")?(r=m,e=$(),n=fe(),u&&n.type===o.Identifier&&T(n.name)&&K({},a.StrictLHSPrefix),ne(n)||K({},a.InvalidLHSInAssignment),n=g.createUnaryExpression(e.value,n),n=g.markEnd(n,r)):Q("+")||Q("-")||Q("~")||Q("!")?(r=m,e=$(),n=fe(),n=g.createUnaryExpression(e.value,n),n=g.markEnd(n,r)):ee("delete")||ee("void")||ee("typeof")?(r=m,e=$(),n=fe(),n=g.createUnaryExpression(e.value,n),n=g.markEnd(n,r),u&&"delete"===n.operator&&n.argument.type===o.Identifier&&K({},a.StrictDelete)):n=de(),n}function he(e,n){var r=0;if(e.type!==t.Punctuator&&e.type!==t.Keyword)return 0;switch(e.value){case"||":r=1;break;case"&&":r=2;break;case"|":r=3;break;case"^":r=4;break;case"&":r=5;break;case"==":case"!=":case"===":case"!==":r=6;break;case"<":case">":case"<=":case">=":case"instanceof":r=7;break;case"in":r=n?7:0;break;case"<<":case">>":case">>>":r=8;break;case"+":case"-":r=9;break;case"*":case"/":case"%":r=11}return r}function pe(){var e,n,r,i,s,l;return e=m,s=m,i=n=function(){var e,t,n,r,o;return o=m,e=function(){var e,t,n,r,o,i,a,s,l,c;if(e=m,l=fe(),0===(o=he(r=m,y.allowIn)))return l;for(r.prec=o,$(),t=[e,m],i=[l,r,a=fe()];(o=he(m,y.allowIn))>0;){for(;i.length>2&&o<=i[i.length-2].prec;)a=i.pop(),s=i.pop().value,l=i.pop(),n=g.createBinaryExpression(s,l,a),t.pop(),g.markEnd(n,e=t[t.length-1]),i.push(n);(r=$()).prec=o,i.push(r),t.push(m),n=fe(),i.push(n)}for(n=i[c=i.length-1],t.pop();c>1;)n=g.createBinaryExpression(i[c-1].value,i[c-2],n),c-=2,e=t.pop(),g.markEnd(n,e);return n}(),Q("?")&&($(),t=y.allowIn,y.allowIn=!0,n=pe(),y.allowIn=t,X(":"),r=pe(),e=g.createConditionalExpression(e,n,r),g.markEnd(e,o)),e}(),m.type===t.Punctuator&&("="===(l=m.value)||"*="===l||"/="===l||"%="===l||"+="===l||"-="===l||"<<="===l||">>="===l||">>>="===l||"&="===l||"^="===l||"|="===l)&&(ne(n)||K({},a.InvalidLHSInAssignment),u&&n.type===o.Identifier&&T(n.name)&&K(e,a.StrictLHSAssignment),e=$(),r=pe(),i=g.markEnd(g.createAssignmentExpression(e.value,n,r),s)),i}function ge(){var e,t=m;if(e=pe(),Q(",")){for(e=g.createSequenceExpression([e]);d<p&&Q(",");)$(),e.expressions.push(pe());g.markEnd(e,t)}return e}function me(){var e,t;return t=m,X("{"),e=function(){for(var e,t=[];d<p&&!Q("}")&&void 0!==(e=Ae());)t.push(e);return t}(),X("}"),g.markEnd(g.createBlockStatement(e),t)}function ye(){var e,n;return n=m,(e=$()).type!==t.Identifier&&Y(e),g.markEnd(g.createIdentifier(e.value),n)}function _e(e){var t,n,r=null;return n=m,t=ye(),u&&T(t.name)&&K({},a.StrictVarName),"const"===e?(X("="),r=pe()):Q("=")&&($(),r=pe()),g.markEnd(g.createVariableDeclarator(t,r),n)}function ve(e){var t=[];do{if(t.push(_e(e)),!Q(","))break;$()}while(d<p);return t}function be(){var e,t,n,r=[];for(n=m,ee("default")?($(),e=null):(Z("case"),e=ge()),X(":");d<p&&!(Q("}")||ee("default")||ee("case"));)t=xe(),r.push(t);return g.markEnd(g.createSwitchCase(e,r),n)}function xe(){var e,n,r,i,s,l,f,h,_,v,b=m.type;if(b===t.EOF&&Y(m),b===t.Punctuator&&"{"===m.value)return me();if(i=m,b===t.Punctuator)switch(m.value){case";":return g.markEnd((X(";"),g.createEmptyStatement()),i);case"(":return g.markEnd(function(){var e=ge();return te(),g.createExpressionStatement(e)}(),i)}if(b===t.Keyword)switch(m.value){case"break":return g.markEnd((v=null,Z("break"),59===c.charCodeAt(d)?($(),y.inIteration||y.inSwitch||J({},a.IllegalBreak),g.createBreakStatement(null)):W()?(y.inIteration||y.inSwitch||J({},a.IllegalBreak),g.createBreakStatement(null)):(m.type===t.Identifier&&(v=ye(),Object.prototype.hasOwnProperty.call(y.labelSet,"$"+v.name)||J({},a.UnknownLabel,v.name)),te(),null!==v||y.inIteration||y.inSwitch||J({},a.IllegalBreak),g.createBreakStatement(v))),i);case"continue":return g.markEnd(function(){var e=null;return Z("continue"),59===c.charCodeAt(d)?($(),y.inIteration||J({},a.IllegalContinue),g.createContinueStatement(null)):W()?(y.inIteration||J({},a.IllegalContinue),g.createContinueStatement(null)):(m.type===t.Identifier&&(e=ye(),Object.prototype.hasOwnProperty.call(y.labelSet,"$"+e.name)||J({},a.UnknownLabel,e.name)),te(),null!==e||y.inIteration||J({},a.IllegalContinue),g.createContinueStatement(e))}(),i);case"debugger":return g.markEnd((Z("debugger"),te(),g.createDebuggerStatement()),i);case"do":return g.markEnd((Z("do"),_=y.inIteration,y.inIteration=!0,f=xe(),y.inIteration=_,Z("while"),X("("),h=ge(),X(")"),Q(";")&&$(),g.createDoWhileStatement(f,h)),i);case"for":return g.markEnd(function(){var e,t,n,r,o,i,s;return e=t=n=null,Z("for"),X("("),Q(";")?$():(ee("var")||ee("let")?(y.allowIn=!1,e=function(){var e,t,n;return n=m,e=$(),t=ve(),g.markEnd(g.createVariableDeclaration(t,e.value),n)}(),y.allowIn=!0,1===e.declarations.length&&ee("in")&&($(),r=e,o=ge(),e=null)):(y.allowIn=!1,e=ge(),y.allowIn=!0,ee("in")&&(ne(e)||K({},a.InvalidLHSInForIn),$(),r=e,o=ge(),e=null)),void 0===r&&X(";")),void 0===r&&(Q(";")||(t=ge()),X(";"),Q(")")||(n=ge())),X(")"),s=y.inIteration,y.inIteration=!0,i=xe(),y.inIteration=s,void 0===r?g.createForStatement(e,t,n,i):g.createForInStatement(r,o,i)}(),i);case"function":return g.markEnd(Ce(),i);case"if":return g.markEnd(function(){var e,t,n;return Z("if"),X("("),e=ge(),X(")"),t=xe(),ee("else")?($(),n=xe()):n=null,g.createIfStatement(e,t,n)}(),i);case"return":return g.markEnd((l=null,Z("return"),y.inFunctionBody||K({},a.IllegalReturn),32===c.charCodeAt(d)&&A(c.charCodeAt(d+1))?(l=ge(),te(),g.createReturnStatement(l)):W()?g.createReturnStatement(null):(Q(";")||Q("}")||m.type===t.EOF||(l=ge()),te(),g.createReturnStatement(l))),i);case"switch":return g.markEnd(function(){var e,t,n,r,o;if(Z("switch"),X("("),e=ge(),X(")"),X("{"),t=[],Q("}"))return $(),g.createSwitchStatement(e,t);for(r=y.inSwitch,y.inSwitch=!0,o=!1;d<p&&!Q("}");)null===(n=be()).test&&(o&&J({},a.MultipleDefaultsInSwitch),o=!0),t.push(n);return y.inSwitch=r,X("}"),g.createSwitchStatement(e,t)}(),i);case"throw":return g.markEnd(function(){var e;return Z("throw"),W()&&J({},a.NewlineAfterThrow),e=ge(),te(),g.createThrowStatement(e)}(),i);case"try":return g.markEnd(function(){var e,t,n,r,o=[],i=null;return Z("try"),e=me(),ee("catch")&&o.push((r=m,Z("catch"),X("("),Q(")")&&Y(m),t=ye(),u&&T(t.name)&&K({},a.StrictCatchVariable),X(")"),n=me(),g.markEnd(g.createCatchClause(t,n),r))),ee("finally")&&($(),i=me()),0!==o.length||i||J({},a.NoCatchOrFinally),g.createTryStatement(e,[],o,i)}(),i);case"var":return g.markEnd((Z("var"),s=ve(),te(),g.createVariableDeclaration(s,"var")),i);case"while":return g.markEnd(function(){var e,t,n;return Z("while"),X("("),e=ge(),X(")"),n=y.inIteration,y.inIteration=!0,t=xe(),y.inIteration=n,g.createWhileStatement(e,t)}(),i);case"with":return g.markEnd(function(){var e,t;return u&&(D(),K({},a.StrictModeWith)),Z("with"),X("("),e=ge(),X(")"),t=xe(),g.createWithStatement(e,t)}(),i)}return(e=ge()).type===o.Identifier&&Q(":")?($(),r="$"+e.name,Object.prototype.hasOwnProperty.call(y.labelSet,r)&&J({},a.Redeclaration,"Label",e.name),y.labelSet[r]=!0,n=xe(),delete y.labelSet[r],g.markEnd(g.createLabeledStatement(e,n),i)):(te(),g.markEnd(g.createExpressionStatement(e),i))}function we(){var e,n,r,i,s,l,f,h,_=[];for(h=m,X("{");d<p&&m.type===t.StringLiteral&&(n=m,e=Ae(),_.push(e),e.expression.type===o.Literal);)"use strict"===c.slice(n.start+1,n.end-1)?(u=!0,r&&K(r,a.StrictOctalLiteral)):!r&&n.octal&&(r=n);for(i=y.labelSet,s=y.inIteration,l=y.inSwitch,f=y.inFunctionBody,y.labelSet={},y.inIteration=!1,y.inSwitch=!1,y.inFunctionBody=!0;d<p&&!Q("}")&&void 0!==(e=Ae());)_.push(e);return X("}"),y.labelSet=i,y.inIteration=s,y.inSwitch=l,y.inFunctionBody=f,g.markEnd(g.createBlockStatement(_),h)}function Se(e){var t,n,r,o,i,s,l=[];if(X("("),!Q(")"))for(o={};d<p&&(n=m,t=ye(),i="$"+n.value,u?(T(n.value)&&(r=n,s=a.StrictParamName),Object.prototype.hasOwnProperty.call(o,i)&&(r=n,s=a.StrictParamDupe)):e||(T(n.value)?(e=n,s=a.StrictParamName):N(n.value)?(e=n,s=a.StrictReservedWord):Object.prototype.hasOwnProperty.call(o,i)&&(e=n,s=a.StrictParamDupe)),l.push(t),o[i]=!0,!Q(")"));)X(",");return X(")"),{params:l,stricted:r,firstRestricted:e,message:s}}function Ce(){var e,t,n,r,o,i,s,l,c,d;return c=m,Z("function"),n=m,e=ye(),u?T(n.value)&&K(n,a.StrictFunctionName):T(n.value)?(i=n,s=a.StrictFunctionName):N(n.value)&&(i=n,s=a.StrictReservedWord),d=(o=Se(i)).params,r=o.stricted,i=o.firstRestricted,o.message&&(s=o.message),l=u,t=we(),u&&i&&J(i,s),u&&r&&K(r,s),u=l,g.markEnd(g.createFunctionDeclaration(e,d,[],t),c)}function Ae(){if(m.type===t.Keyword)switch(m.value){case"const":case"let":return r=m,Z(e=m.value),n=ve(e),te(),g.markEnd(g.createVariableDeclaration(n,e),r);case"function":return Ce();default:return xe()}var e,n,r;if(m.type!==t.EOF)return xe()}function ke(){var e,t,n,r=[];for(e=0;e<_.tokens.length;++e)n={type:(t=_.tokens[e]).type,value:t.value},_.range&&(n.range=t.range),_.loc&&(n.loc=t.loc),r.push(n);_.tokens=r}(n={})[(t={BooleanLiteral:1,EOF:2,Identifier:3,Keyword:4,NullLiteral:5,NumericLiteral:6,Punctuator:7,StringLiteral:8,RegularExpression:9}).BooleanLiteral]="Boolean",n[t.EOF]="<end>",n[t.Identifier]="Identifier",n[t.Keyword]="Keyword",n[t.NullLiteral]="Null",n[t.NumericLiteral]="Numeric",n[t.Punctuator]="Punctuator",n[t.StringLiteral]="String",n[t.RegularExpression]="RegularExpression",r=["(","{","[","in","typeof","instanceof","new","return","case","delete","throw","void","=","+=","-=","*=","/=","%=","<<=",">>=",">>>=","&=","|=","^=",",","+","-","*","/","%","++","--","<<",">>",">>>","&","|","^","!","~","&&","||","?",":","===","==",">=","<=","<",">","!=","!=="],o={AssignmentExpression:"AssignmentExpression",ArrayExpression:"ArrayExpression",BlockStatement:"BlockStatement",BinaryExpression:"BinaryExpression",BreakStatement:"BreakStatement",CallExpression:"CallExpression",CatchClause:"CatchClause",ConditionalExpression:"ConditionalExpression",ContinueStatement:"ContinueStatement",DoWhileStatement:"DoWhileStatement",DebuggerStatement:"DebuggerStatement",EmptyStatement:"EmptyStatement",ExpressionStatement:"ExpressionStatement",ForStatement:"ForStatement",ForInStatement:"ForInStatement",FunctionDeclaration:"FunctionDeclaration",FunctionExpression:"FunctionExpression",Identifier:"Identifier",IfStatement:"IfStatement",Literal:"Literal",LabeledStatement:"LabeledStatement",LogicalExpression:"LogicalExpression",MemberExpression:"MemberExpression",NewExpression:"NewExpression",ObjectExpression:"ObjectExpression",Program:"Program",Property:"Property",ReturnStatement:"ReturnStatement",SequenceExpression:"SequenceExpression",SwitchStatement:"SwitchStatement",SwitchCase:"SwitchCase",ThisExpression:"ThisExpression",ThrowStatement:"ThrowStatement",TryStatement:"TryStatement",UnaryExpression:"UnaryExpression",UpdateExpression:"UpdateExpression",VariableDeclaration:"VariableDeclaration",VariableDeclarator:"VariableDeclarator",WhileStatement:"WhileStatement",WithStatement:"WithStatement"},i={Data:1,Get:2,Set:4},a={UnexpectedToken:"Unexpected token %0",UnexpectedNumber:"Unexpected number",UnexpectedString:"Unexpected string",UnexpectedIdentifier:"Unexpected identifier",UnexpectedReserved:"Unexpected reserved word",UnexpectedEOS:"Unexpected end of input",NewlineAfterThrow:"Illegal newline after throw",InvalidRegExp:"Invalid regular expression",UnterminatedRegExp:"Invalid regular expression: missing /",InvalidLHSInAssignment:"Invalid left-hand side in assignment",InvalidLHSInForIn:"Invalid left-hand side in for-in",MultipleDefaultsInSwitch:"More than one default clause in switch statement",NoCatchOrFinally:"Missing catch or finally after try",UnknownLabel:"Undefined label '%0'",Redeclaration:"%0 '%1' has already been declared",IllegalContinue:"Illegal continue statement",IllegalBreak:"Illegal break statement",IllegalReturn:"Illegal return statement",StrictModeWith:"Strict mode code may not include a with statement",StrictCatchVariable:"Catch variable may not be eval or arguments in strict mode",StrictVarName:"Variable name may not be eval or arguments in strict mode",StrictParamName:"Parameter name eval or arguments is not allowed in strict mode",StrictParamDupe:"Strict mode function may not have duplicate parameter names",StrictFunctionName:"Function name may not be eval or arguments in strict mode",StrictOctalLiteral:"Octal literals are not allowed in strict mode.",StrictDelete:"Delete of an unqualified identifier in strict mode.",StrictDuplicateProperty:"Duplicate data property in object literal not allowed in strict mode",AccessorDataProperty:"Object literal may not have data and accessor property with the same name",AccessorGetSet:"Object literal may not have multiple get/set accessors with the same name",StrictLHSAssignment:"Assignment to eval or arguments is not allowed in strict mode",StrictLHSPostfix:"Postfix increment/decrement may not have eval or arguments operand in strict mode",StrictLHSPrefix:"Prefix increment/decrement may not have eval or arguments operand in strict mode",StrictReservedWord:"Use of future reserved word in strict mode"},s={NonAsciiIdentifierStart:new RegExp("[ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԧԱ-Ֆՙա-ևא-תװ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࢠࢢ-ࢬऄ-हऽॐक़-ॡॱ-ॷॹ-ॿঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-ళవ-హఽౘౙౠౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೞೠೡೱೲഅ-ഌഎ-ഐഒ-ഺഽൎൠൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏼᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛰᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡷᢀ-ᢨᢪᢰ-ᣵᤀ-ᤜᥐ-ᥭᥰ-ᥴᦀ-ᦫᧁ-ᧇᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᳩ-ᳬᳮ-ᳱᳵᳶᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞⸯ々-〇〡-〩〱-〵〸-〼ぁ-ゖゝ-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿌ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚗꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꞎꞐ-ꞓꞠ-Ɦꟸ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꪀ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꯀ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ]"),NonAsciiIdentifierPart:new RegExp("[ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮ̀-ʹͶͷͺ-ͽΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁ҃-҇Ҋ-ԧԱ-Ֆՙա-և֑-ׇֽֿׁׂׅׄא-תװ-ײؐ-ؚؠ-٩ٮ-ۓە-ۜ۟-۪ۨ-ۼۿܐ-݊ݍ-ޱ߀-ߵߺࠀ-࠭ࡀ-࡛ࢠࢢ-ࢬࣤ-ࣾऀ-ॣ०-९ॱ-ॷॹ-ॿঁ-ঃঅ-ঌএঐও-নপ-রলশ-হ়-ৄেৈো-ৎৗড়ঢ়য়-ৣ০-ৱਁ-ਃਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹ਼ਾ-ੂੇੈੋ-੍ੑਖ਼-ੜਫ਼੦-ੵઁ-ઃઅ-ઍએ-ઑઓ-નપ-રલળવ-હ઼-ૅે-ૉો-્ૐૠ-ૣ૦-૯ଁ-ଃଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହ଼-ୄେୈୋ-୍ୖୗଡ଼ଢ଼ୟ-ୣ୦-୯ୱஂஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹா-ூெ-ைொ-்ௐௗ௦-௯ఁ-ఃఅ-ఌఎ-ఐఒ-నప-ళవ-హఽ-ౄె-ైొ-్ౕౖౘౙౠ-ౣ౦-౯ಂಃಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹ಼-ೄೆ-ೈೊ-್ೕೖೞೠ-ೣ೦-೯ೱೲംഃഅ-ഌഎ-ഐഒ-ഺഽ-ൄെ-ൈൊ-ൎൗൠ-ൣ൦-൯ൺ-ൿංඃඅ-ඖක-නඳ-රලව-ෆ්ා-ුූෘ-ෟෲෳก-ฺเ-๎๐-๙ກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ູົ-ຽເ-ໄໆ່-ໍ໐-໙ໜ-ໟༀ༘༙༠-༩༹༵༷༾-ཇཉ-ཬཱ-྄྆-ྗྙ-ྼ࿆က-၉ၐ-ႝႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚ፝-፟ᎀ-ᎏᎠ-Ᏼᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛰᜀ-ᜌᜎ-᜔ᜠ-᜴ᝀ-ᝓᝠ-ᝬᝮ-ᝰᝲᝳក-៓ៗៜ៝០-៩᠋-᠍᠐-᠙ᠠ-ᡷᢀ-ᢪᢰ-ᣵᤀ-ᤜᤠ-ᤫᤰ-᤻᥆-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉ᧐-᧙ᨀ-ᨛᨠ-ᩞ᩠-᩿᩼-᪉᪐-᪙ᪧᬀ-ᭋ᭐-᭙᭫-᭳ᮀ-᯳ᰀ-᰷᱀-᱉ᱍ-ᱽ᳐-᳔᳒-ᳶᴀ-ᷦ᷼-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼ‿⁀⁔ⁱⁿₐ-ₜ⃐-⃥⃜⃡-⃰ℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯ⵿-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞⷠ-ⷿⸯ々-〇〡-〯〱-〵〸-〼ぁ-ゖ゙゚ゝ-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿌ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘫꙀ-꙯ꙴ-꙽ꙿ-ꚗꚟ-꛱ꜗ-ꜟꜢ-ꞈꞋ-ꞎꞐ-ꞓꞠ-Ɦꟸ-ꠧꡀ-ꡳꢀ-꣄꣐-꣙꣠-ꣷꣻ꤀-꤭ꤰ-꥓ꥠ-ꥼꦀ-꧀ꧏ-꧙ꨀ-ꨶꩀ-ꩍ꩐-꩙ꩠ-ꩶꩺꩻꪀ-ꫂꫛ-ꫝꫠ-ꫯꫲ-꫶ꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꯀ-ꯪ꯬꯭꯰-꯹가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻ︀-️︠-︦︳︴﹍-﹏ﹰ-ﹴﹶ-ﻼ0-9A-Z_a-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ]")},l={name:"SyntaxTree",processComment:function(e){var t,n;if(!(e.type===o.Program&&e.body.length>0)){for(_.trailingComments.length>0?_.trailingComments[0].range[0]>=e.range[1]?(n=_.trailingComments,_.trailingComments=[]):_.trailingComments.length=0:_.bottomRightStack.length>0&&_.bottomRightStack[_.bottomRightStack.length-1].trailingComments&&_.bottomRightStack[_.bottomRightStack.length-1].trailingComments[0].range[0]>=e.range[1]&&(n=_.bottomRightStack[_.bottomRightStack.length-1].trailingComments,delete _.bottomRightStack[_.bottomRightStack.length-1].trailingComments);_.bottomRightStack.length>0&&_.bottomRightStack[_.bottomRightStack.length-1].range[0]>=e.range[0];)t=_.bottomRightStack.pop();t?t.leadingComments&&t.leadingComments[t.leadingComments.length-1].range[1]<=e.range[0]&&(e.leadingComments=t.leadingComments,delete t.leadingComments):_.leadingComments.length>0&&_.leadingComments[_.leadingComments.length-1].range[1]<=e.range[0]&&(e.leadingComments=_.leadingComments,_.leadingComments=[]),n&&(e.trailingComments=n),_.bottomRightStack.push(e)}},markEnd:function(e,t){return _.range&&(e.range=[t.start,d]),_.loc&&(e.loc=new V(void 0===t.startLineNumber?t.lineNumber:t.startLineNumber,t.start-(void 0===t.startLineStart?t.lineStart:t.startLineStart),f,d-h),this.postProcess(e)),_.attachComment&&this.processComment(e),e},postProcess:function(e){return _.source&&(e.loc.source=_.source),e},createArrayExpression:function(e){return{type:o.ArrayExpression,elements:e}},createAssignmentExpression:function(e,t,n){return{type:o.AssignmentExpression,operator:e,left:t,right:n}},createBinaryExpression:function(e,t,n){return{type:"||"===e||"&&"===e?o.LogicalExpression:o.BinaryExpression,operator:e,left:t,right:n}},createBlockStatement:function(e){return{type:o.BlockStatement,body:e}},createBreakStatement:function(e){return{type:o.BreakStatement,label:e}},createCallExpression:function(e,t){return{type:o.CallExpression,callee:e,arguments:t}},createCatchClause:function(e,t){return{type:o.CatchClause,param:e,body:t}},createConditionalExpression:function(e,t,n){return{type:o.ConditionalExpression,test:e,consequent:t,alternate:n}},createContinueStatement:function(e){return{type:o.ContinueStatement,label:e}},createDebuggerStatement:function(){return{type:o.DebuggerStatement}},createDoWhileStatement:function(e,t){return{type:o.DoWhileStatement,body:e,test:t}},createEmptyStatement:function(){return{type:o.EmptyStatement}},createExpressionStatement:function(e){return{type:o.ExpressionStatement,expression:e}},createForStatement:function(e,t,n,r){return{type:o.ForStatement,init:e,test:t,update:n,body:r}},createForInStatement:function(e,t,n){return{type:o.ForInStatement,left:e,right:t,body:n,each:!1}},createFunctionDeclaration:function(e,t,n,r){return{type:o.FunctionDeclaration,id:e,params:t,defaults:n,body:r,rest:null,generator:!1,expression:!1}},createFunctionExpression:function(e,t,n,r){return{type:o.FunctionExpression,id:e,params:t,defaults:n,body:r,rest:null,generator:!1,expression:!1}},createIdentifier:function(e){return{type:o.Identifier,name:e}},createIfStatement:function(e,t,n){return{type:o.IfStatement,test:e,consequent:t,alternate:n}},createLabeledStatement:function(e,t){return{type:o.LabeledStatement,label:e,body:t}},createLiteral:function(e){return{type:o.Literal,value:e.value,raw:c.slice(e.start,e.end)}},createMemberExpression:function(e,t,n){return{type:o.MemberExpression,computed:"["===e,object:t,property:n}},createNewExpression:function(e,t){return{type:o.NewExpression,callee:e,arguments:t}},createObjectExpression:function(e){return{type:o.ObjectExpression,properties:e}},createPostfixExpression:function(e,t){return{type:o.UpdateExpression,operator:e,argument:t,prefix:!1}},createProgram:function(e){return{type:o.Program,body:e}},createProperty:function(e,t,n){return{type:o.Property,key:t,value:n,kind:e}},createReturnStatement:function(e){return{type:o.ReturnStatement,argument:e}},createSequenceExpression:function(e){return{type:o.SequenceExpression,expressions:e}},createSwitchCase:function(e,t){return{type:o.SwitchCase,test:e,consequent:t}},createSwitchStatement:function(e,t){return{type:o.SwitchStatement,discriminant:e,cases:t}},createThisExpression:function(){return{type:o.ThisExpression}},createThrowStatement:function(e){return{type:o.ThrowStatement,argument:e}},createTryStatement:function(e,t,n,r){return{type:o.TryStatement,block:e,guardedHandlers:t,handlers:n,finalizer:r}},createUnaryExpression:function(e,t){return"++"===e||"--"===e?{type:o.UpdateExpression,operator:e,argument:t,prefix:!0}:{type:o.UnaryExpression,operator:e,argument:t,prefix:!0}},createVariableDeclaration:function(e,t){return{type:o.VariableDeclaration,declarations:e,kind:t}},createVariableDeclarator:function(e,t){return{type:o.VariableDeclarator,id:e,init:t}},createWhileStatement:function(e,t){return{type:o.WhileStatement,test:e,body:t}},createWithStatement:function(e,t){return{type:o.WithStatement,object:e,body:t}}},e.version="1.2.2",e.tokenize=function(e,n){var r;"string"==typeof e||e instanceof String||(e=String(e)),g=l,d=0,f=(c=e).length>0?1:0,h=0,p=c.length,m=null,y={allowIn:!0,labelSet:{},inFunctionBody:!1,inIteration:!1,inSwitch:!1,lastCommentStart:-1},_={},(n=n||{}).tokens=!0,_.tokens=[],_.tokenize=!0,_.openParenToken=-1,_.openCurlyToken=-1,_.range="boolean"==typeof n.range&&n.range,_.loc="boolean"==typeof n.loc&&n.loc,"boolean"==typeof n.comment&&n.comment&&(_.comments=[]),"boolean"==typeof n.tolerant&&n.tolerant&&(_.errors=[]);try{if(H(),m.type===t.EOF)return _.tokens;for($();m.type!==t.EOF;)try{$()}catch(e){if(_.errors){_.errors.push(e);break}throw e}ke(),r=_.tokens,void 0!==_.comments&&(r.comments=_.comments),void 0!==_.errors&&(r.errors=_.errors)}catch(e){throw e}finally{_={}}return r},e.parse=function(e,n){var r,i,s,v;i=String,"string"==typeof e||e instanceof String||(e=i(e)),g=l,d=0,f=(c=e).length>0?1:0,h=0,p=c.length,m=null,y={allowIn:!0,labelSet:{},inFunctionBody:!1,inIteration:!1,inSwitch:!1,lastCommentStart:-1},_={},void 0!==n&&(_.range="boolean"==typeof n.range&&n.range,_.loc="boolean"==typeof n.loc&&n.loc,_.attachComment="boolean"==typeof n.attachComment&&n.attachComment,_.loc&&null!=n.source&&(_.source=i(n.source)),"boolean"==typeof n.tokens&&n.tokens&&(_.tokens=[]),"boolean"==typeof n.comment&&n.comment&&(_.comments=[]),"boolean"==typeof n.tolerant&&n.tolerant&&(_.errors=[]),_.attachComment&&(_.range=!0,_.comments=[],_.bottomRightStack=[],_.trailingComments=[],_.leadingComments=[]));try{D(),H(),v=m,u=!1,s=function(){for(var e,n,r,i=[];d<p&&(n=m).type===t.StringLiteral&&(e=Ae(),i.push(e),e.expression.type===o.Literal);)"use strict"===c.slice(n.start+1,n.end-1)?(u=!0,r&&K(r,a.StrictOctalLiteral)):!r&&n.octal&&(r=n);for(;d<p&&void 0!==(e=Ae());)i.push(e);return i}(),r=g.markEnd(g.createProgram(s),v),void 0!==_.comments&&(r.comments=_.comments),void 0!==_.tokens&&(ke(),r.tokens=_.tokens),void 0!==_.errors&&(r.errors=_.errors)}catch(e){throw e}finally{_={}}return r},e.Syntax=function(){var e,t={};for(e in"function"==typeof Object.create&&(t=Object.create(null)),o)o.hasOwnProperty(e)&&(t[e]=o[e]);return"function"==typeof Object.freeze&&Object.freeze(t),t}()},r(void 0!==n?n:this.esprima={})},{}],1:[function(e,t,n){(function(r){var o=function(){var e={trace:function(){},yy:{},symbols_:{error:2,JSON_PATH:3,DOLLAR:4,PATH_COMPONENTS:5,LEADING_CHILD_MEMBER_EXPRESSION:6,PATH_COMPONENT:7,MEMBER_COMPONENT:8,SUBSCRIPT_COMPONENT:9,CHILD_MEMBER_COMPONENT:10,DESCENDANT_MEMBER_COMPONENT:11,DOT:12,MEMBER_EXPRESSION:13,DOT_DOT:14,STAR:15,IDENTIFIER:16,SCRIPT_EXPRESSION:17,INTEGER:18,END:19,CHILD_SUBSCRIPT_COMPONENT:20,DESCENDANT_SUBSCRIPT_COMPONENT:21,"[":22,SUBSCRIPT:23,"]":24,SUBSCRIPT_EXPRESSION:25,SUBSCRIPT_EXPRESSION_LIST:26,SUBSCRIPT_EXPRESSION_LISTABLE:27,",":28,STRING_LITERAL:29,ARRAY_SLICE:30,FILTER_EXPRESSION:31,QQ_STRING:32,Q_STRING:33,$accept:0,$end:1},terminals_:{2:"error",4:"DOLLAR",12:"DOT",14:"DOT_DOT",15:"STAR",16:"IDENTIFIER",17:"SCRIPT_EXPRESSION",18:"INTEGER",19:"END",22:"[",24:"]",28:",",30:"ARRAY_SLICE",31:"FILTER_EXPRESSION",32:"QQ_STRING",33:"Q_STRING"},productions_:[0,[3,1],[3,2],[3,1],[3,2],[5,1],[5,2],[7,1],[7,1],[8,1],[8,1],[10,2],[6,1],[11,2],[13,1],[13,1],[13,1],[13,1],[13,1],[9,1],[9,1],[20,3],[21,4],[23,1],[23,1],[26,1],[26,3],[27,1],[27,1],[27,1],[25,1],[25,1],[25,1],[29,1],[29,1]],performAction:function(e,n,r,o,i,a,s){o.ast||(o.ast=t,t.initialize());var l=a.length-1;switch(i){case 1:return o.ast.set({expression:{type:"root",value:a[l]}}),o.ast.unshift(),o.ast.yield();case 2:return o.ast.set({expression:{type:"root",value:a[l-1]}}),o.ast.unshift(),o.ast.yield();case 3:return o.ast.unshift(),o.ast.yield();case 4:return o.ast.set({operation:"member",scope:"child",expression:{type:"identifier",value:a[l-1]}}),o.ast.unshift(),o.ast.yield();case 5:case 6:case 11:case 13:case 18:case 21:case 22:case 23:break;case 7:o.ast.set({operation:"member"}),o.ast.push();break;case 8:o.ast.set({operation:"subscript"}),o.ast.push();break;case 9:case 19:o.ast.set({scope:"child"});break;case 10:case 20:o.ast.set({scope:"descendant"});break;case 12:o.ast.set({scope:"child",operation:"member"});break;case 14:o.ast.set({expression:{type:"wildcard",value:a[l]}});break;case 15:o.ast.set({expression:{type:"identifier",value:a[l]}});break;case 16:o.ast.set({expression:{type:"script_expression",value:a[l]}});break;case 17:o.ast.set({expression:{type:"numeric_literal",value:parseInt(a[l])}});break;case 24:a[l].length>1?o.ast.set({expression:{type:"union",value:a[l]}}):this.$=a[l];break;case 25:this.$=[a[l]];break;case 26:this.$=a[l-2].concat(a[l]);break;case 27:this.$={expression:{type:"numeric_literal",value:parseInt(a[l])}},o.ast.set(this.$);break;case 28:this.$={expression:{type:"string_literal",value:a[l]}},o.ast.set(this.$);break;case 29:this.$={expression:{type:"slice",value:a[l]}},o.ast.set(this.$);break;case 30:this.$={expression:{type:"wildcard",value:a[l]}},o.ast.set(this.$);break;case 31:this.$={expression:{type:"script_expression",value:a[l]}},o.ast.set(this.$);break;case 32:this.$={expression:{type:"filter_expression",value:a[l]}},o.ast.set(this.$);break;case 33:case 34:this.$=a[l]}},table:[{3:1,4:[1,2],6:3,13:4,15:[1,5],16:[1,6],17:[1,7],18:[1,8],19:[1,9]},{1:[3]},{1:[2,1],5:10,7:11,8:12,9:13,10:14,11:15,12:[1,18],14:[1,19],20:16,21:17,22:[1,20]},{1:[2,3],5:21,7:11,8:12,9:13,10:14,11:15,12:[1,18],14:[1,19],20:16,21:17,22:[1,20]},{1:[2,12],12:[2,12],14:[2,12],22:[2,12]},{1:[2,14],12:[2,14],14:[2,14],22:[2,14]},{1:[2,15],12:[2,15],14:[2,15],22:[2,15]},{1:[2,16],12:[2,16],14:[2,16],22:[2,16]},{1:[2,17],12:[2,17],14:[2,17],22:[2,17]},{1:[2,18],12:[2,18],14:[2,18],22:[2,18]},{1:[2,2],7:22,8:12,9:13,10:14,11:15,12:[1,18],14:[1,19],20:16,21:17,22:[1,20]},{1:[2,5],12:[2,5],14:[2,5],22:[2,5]},{1:[2,7],12:[2,7],14:[2,7],22:[2,7]},{1:[2,8],12:[2,8],14:[2,8],22:[2,8]},{1:[2,9],12:[2,9],14:[2,9],22:[2,9]},{1:[2,10],12:[2,10],14:[2,10],22:[2,10]},{1:[2,19],12:[2,19],14:[2,19],22:[2,19]},{1:[2,20],12:[2,20],14:[2,20],22:[2,20]},{13:23,15:[1,5],16:[1,6],17:[1,7],18:[1,8],19:[1,9]},{13:24,15:[1,5],16:[1,6],17:[1,7],18:[1,8],19:[1,9],22:[1,25]},{15:[1,29],17:[1,30],18:[1,33],23:26,25:27,26:28,27:32,29:34,30:[1,35],31:[1,31],32:[1,36],33:[1,37]},{1:[2,4],7:22,8:12,9:13,10:14,11:15,12:[1,18],14:[1,19],20:16,21:17,22:[1,20]},{1:[2,6],12:[2,6],14:[2,6],22:[2,6]},{1:[2,11],12:[2,11],14:[2,11],22:[2,11]},{1:[2,13],12:[2,13],14:[2,13],22:[2,13]},{15:[1,29],17:[1,30],18:[1,33],23:38,25:27,26:28,27:32,29:34,30:[1,35],31:[1,31],32:[1,36],33:[1,37]},{24:[1,39]},{24:[2,23]},{24:[2,24],28:[1,40]},{24:[2,30]},{24:[2,31]},{24:[2,32]},{24:[2,25],28:[2,25]},{24:[2,27],28:[2,27]},{24:[2,28],28:[2,28]},{24:[2,29],28:[2,29]},{24:[2,33],28:[2,33]},{24:[2,34],28:[2,34]},{24:[1,41]},{1:[2,21],12:[2,21],14:[2,21],22:[2,21]},{18:[1,33],27:42,29:34,30:[1,35],32:[1,36],33:[1,37]},{1:[2,22],12:[2,22],14:[2,22],22:[2,22]},{24:[2,26],28:[2,26]}],defaultActions:{27:[2,23],29:[2,30],30:[2,31],31:[2,32]},parseError:function(e,t){if(!t.recoverable)throw new Error(e);this.trace(e)},parse:function(e){var t=this,n=[0],r=[null],o=[],i=this.table,a="",s=0,l=0,c=o.slice.call(arguments,1);this.lexer.setInput(e),this.lexer.yy=this.yy,this.yy.lexer=this.lexer,this.yy.parser=this,void 0===this.lexer.yylloc&&(this.lexer.yylloc={});var u=this.lexer.yylloc;o.push(u);var d=this.lexer.options&&this.lexer.options.ranges;function f(){var e;return"number"!=typeof(e=t.lexer.lex()||1)&&(e=t.symbols_[e]||e),e}this.parseError="function"==typeof this.yy.parseError?this.yy.parseError:Object.getPrototypeOf(this).parseError;for(var h,p,g,m,y,_,v,b={};;){if(this.defaultActions[p=n[n.length-1]]?g=this.defaultActions[p]:(null==h&&(h=f()),g=i[p]&&i[p][h]),void 0===g||!g.length||!g[0]){var x;for(y in v=[],i[p])this.terminals_[y]&&y>2&&v.push("'"+this.terminals_[y]+"'");x=this.lexer.showPosition?"Parse error on line "+(s+1)+":\n"+this.lexer.showPosition()+"\nExpecting "+v.join(", ")+", got '"+(this.terminals_[h]||h)+"'":"Parse error on line "+(s+1)+": Unexpected "+(1==h?"end of input":"'"+(this.terminals_[h]||h)+"'"),this.parseError(x,{text:this.lexer.match,token:this.terminals_[h]||h,line:this.lexer.yylineno,loc:u,expected:v})}if(g[0]instanceof Array&&g.length>1)throw new Error("Parse Error: multiple actions possible at state: "+p+", token: "+h);switch(g[0]){case 1:n.push(h),r.push(this.lexer.yytext),o.push(this.lexer.yylloc),n.push(g[1]),h=null,l=this.lexer.yyleng,a=this.lexer.yytext,s=this.lexer.yylineno,u=this.lexer.yylloc;break;case 2:if(b.$=r[r.length-(_=this.productions_[g[1]][1])],b._$={first_line:o[o.length-(_||1)].first_line,last_line:o[o.length-1].last_line,first_column:o[o.length-(_||1)].first_column,last_column:o[o.length-1].last_column},d&&(b._$.range=[o[o.length-(_||1)].range[0],o[o.length-1].range[1]]),void 0!==(m=this.performAction.apply(b,[a,l,s,this.yy,g[1],r,o].concat(c))))return m;_&&(n=n.slice(0,-1*_*2),r=r.slice(0,-1*_),o=o.slice(0,-1*_)),n.push(this.productions_[g[1]][0]),r.push(b.$),o.push(b._$),n.push(i[n[n.length-2]][n[n.length-1]]);break;case 3:return!0}}return!0}},t={initialize:function(){this._nodes=[],this._node={},this._stash=[]},set:function(e){for(var t in e)this._node[t]=e[t];return this._node},node:function(e){return arguments.length&&(this._node=e),this._node},push:function(){this._nodes.push(this._node),this._node={}},unshift:function(){this._nodes.unshift(this._node),this._node={}},yield:function(){var e=this._nodes;return this.initialize(),e}},n=function(){var e={EOF:1,parseError:function(e,t){if(!this.yy.parser)throw new Error(e);this.yy.parser.parseError(e,t)},setInput:function(e){return this._input=e,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var e=this._input[0];return this.yytext+=e,this.yyleng++,this.offset++,this.match+=e,this.matched+=e,e.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),e},unput:function(e){var t=e.length,n=e.split(/(?:\r\n?|\n)/g);this._input=e+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-t-1),this.offset-=t;var r=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),n.length-1&&(this.yylineno-=n.length-1);var o=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:n?(n.length===r.length?this.yylloc.first_column:0)+r[r.length-n.length].length-n[0].length:this.yylloc.first_column-t},this.options.ranges&&(this.yylloc.range=[o[0],o[0]+this.yyleng-t]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(e){this.unput(this.match.slice(e))},pastInput:function(){var e=this.matched.substr(0,this.matched.length-this.match.length);return(e.length>20?"...":"")+e.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var e=this.match;return e.length<20&&(e+=this._input.substr(0,20-e.length)),(e.substr(0,20)+(e.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var e=this.pastInput(),t=new Array(e.length+1).join("-");return e+this.upcomingInput()+"\n"+t+"^"},test_match:function(e,t){var n,r,o;if(this.options.backtrack_lexer&&(o={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(o.yylloc.range=this.yylloc.range.slice(0))),(r=e[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=r.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:r?r[r.length-1].length-r[r.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+e[0].length},this.yytext+=e[0],this.match+=e[0],this.matches=e,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(e[0].length),this.matched+=e[0],n=this.performAction.call(this,this.yy,this,t,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),n)return n;if(this._backtrack){for(var i in o)this[i]=o[i];return!1}return!1},next:function(){if(this.done)return this.EOF;var e,t,n,r;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var o=this._currentRules(),i=0;i<o.length;i++)if((n=this._input.match(this.rules[o[i]]))&&(!t||n[0].length>t[0].length)){if(t=n,r=i,this.options.backtrack_lexer){if(!1!==(e=this.test_match(n,o[i])))return e;if(this._backtrack){t=!1;continue}return!1}if(!this.options.flex)break}return t?!1!==(e=this.test_match(t,o[r]))&&e:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){return this.next()||this.lex()},begin:function(e){this.conditionStack.push(e)},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(e){return(e=this.conditionStack.length-1-Math.abs(e||0))>=0?this.conditionStack[e]:"INITIAL"},pushState:function(e){this.begin(e)},stateStackSize:function(){return this.conditionStack.length},options:{},performAction:function(e,t,n,r){switch(n){case 0:return 4;case 1:return 14;case 2:return 12;case 3:return 15;case 4:return 16;case 5:return 22;case 6:return 24;case 7:return 28;case 8:return 30;case 9:return 18;case 10:return t.yytext=t.yytext.substr(1,t.yyleng-2),32;case 11:return t.yytext=t.yytext.substr(1,t.yyleng-2),33;case 12:return 17;case 13:return 31}},rules:[/^(?:\$)/,/^(?:\.\.)/,/^(?:\.)/,/^(?:\*)/,/^(?:[a-zA-Z_]+[a-zA-Z0-9_]*)/,/^(?:\[)/,/^(?:\])/,/^(?:,)/,/^(?:((-?(?:0|[1-9][0-9]*)))?\:((-?(?:0|[1-9][0-9]*)))?(\:((-?(?:0|[1-9][0-9]*)))?)?)/,/^(?:(-?(?:0|[1-9][0-9]*)))/,/^(?:"(?:\\["bfnrt/\\]|\\u[a-fA-F0-9]{4}|[^"\\])*")/,/^(?:'(?:\\['bfnrt/\\]|\\u[a-fA-F0-9]{4}|[^'\\])*')/,/^(?:\(.+?\)(?=\]))/,/^(?:\?\(.+?\)(?=\]))/],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13],inclusive:!0}}};return e}();function r(){this.yy={}}return e.lexer=n,r.prototype=e,e.Parser=r,new r}();void 0!==e&&void 0!==n&&(n.parser=o,n.Parser=o.Parser,n.parse=function(){return o.parse.apply(o,arguments)},n.main=function(t){t[1]||(console.log("Usage: "+t[0]+" FILE"),r.exit(1));var o=e("fs").readFileSync(e("path").normalize(t[1]),"utf8");return n.parser.parse(o)},void 0!==t&&e.main===t&&n.main(r.argv.slice(1)))}).call(this,e("_process"))},{_process:14,fs:12,path:13}],2:[function(e,t,n){t.exports={identifier:"[a-zA-Z_]+[a-zA-Z0-9_]*",integer:"-?(?:0|[1-9][0-9]*)",qq_string:'"(?:\\\\["bfnrt/\\\\]|\\\\u[a-fA-F0-9]{4}|[^"\\\\])*"',q_string:"'(?:\\\\['bfnrt/\\\\]|\\\\u[a-fA-F0-9]{4}|[^'\\\\])*'"}},{}],3:[function(e,t,n){var r=e("./dict"),o=e("fs"),i={lex:{macros:{esc:"\\\\",int:r.integer},rules:[["\\$","return 'DOLLAR'"],["\\.\\.","return 'DOT_DOT'"],["\\.","return 'DOT'"],["\\*","return 'STAR'"],[r.identifier,"return 'IDENTIFIER'"],["\\[","return '['"],["\\]","return ']'"],[",","return ','"],["({int})?\\:({int})?(\\:({int})?)?","return 'ARRAY_SLICE'"],["{int}","return 'INTEGER'"],[r.qq_string,"yytext = yytext.substr(1,yyleng-2); return 'QQ_STRING';"],[r.q_string,"yytext = yytext.substr(1,yyleng-2); return 'Q_STRING';"],["\\(.+?\\)(?=\\])","return 'SCRIPT_EXPRESSION'"],["\\?\\(.+?\\)(?=\\])","return 'FILTER_EXPRESSION'"]]},start:"JSON_PATH",bnf:{JSON_PATH:[["DOLLAR",'yy.ast.set({ expression: { type: "root", value: $1 } }); yy.ast.unshift(); return yy.ast.yield()'],["DOLLAR PATH_COMPONENTS",'yy.ast.set({ expression: { type: "root", value: $1 } }); yy.ast.unshift(); return yy.ast.yield()'],["LEADING_CHILD_MEMBER_EXPRESSION","yy.ast.unshift(); return yy.ast.yield()"],["LEADING_CHILD_MEMBER_EXPRESSION PATH_COMPONENTS",'yy.ast.set({ operation: "member", scope: "child", expression: { type: "identifier", value: $1 }}); yy.ast.unshift(); return yy.ast.yield()']],PATH_COMPONENTS:[["PATH_COMPONENT",""],["PATH_COMPONENTS PATH_COMPONENT",""]],PATH_COMPONENT:[["MEMBER_COMPONENT",'yy.ast.set({ operation: "member" }); yy.ast.push()'],["SUBSCRIPT_COMPONENT",'yy.ast.set({ operation: "subscript" }); yy.ast.push() ']],MEMBER_COMPONENT:[["CHILD_MEMBER_COMPONENT",'yy.ast.set({ scope: "child" })'],["DESCENDANT_MEMBER_COMPONENT",'yy.ast.set({ scope: "descendant" })']],CHILD_MEMBER_COMPONENT:[["DOT MEMBER_EXPRESSION",""]],LEADING_CHILD_MEMBER_EXPRESSION:[["MEMBER_EXPRESSION",'yy.ast.set({ scope: "child", operation: "member" })']],DESCENDANT_MEMBER_COMPONENT:[["DOT_DOT MEMBER_EXPRESSION",""]],MEMBER_EXPRESSION:[["STAR",'yy.ast.set({ expression: { type: "wildcard", value: $1 } })'],["IDENTIFIER",'yy.ast.set({ expression: { type: "identifier", value: $1 } })'],["SCRIPT_EXPRESSION",'yy.ast.set({ expression: { type: "script_expression", value: $1 } })'],["INTEGER",'yy.ast.set({ expression: { type: "numeric_literal", value: parseInt($1) } })'],["END",""]],SUBSCRIPT_COMPONENT:[["CHILD_SUBSCRIPT_COMPONENT",'yy.ast.set({ scope: "child" })'],["DESCENDANT_SUBSCRIPT_COMPONENT",'yy.ast.set({ scope: "descendant" })']],CHILD_SUBSCRIPT_COMPONENT:[["[ SUBSCRIPT ]",""]],DESCENDANT_SUBSCRIPT_COMPONENT:[["DOT_DOT [ SUBSCRIPT ]",""]],SUBSCRIPT:[["SUBSCRIPT_EXPRESSION",""],["SUBSCRIPT_EXPRESSION_LIST",'$1.length > 1? yy.ast.set({ expression: { type: "union", value: $1 } }) : $$ = $1']],SUBSCRIPT_EXPRESSION_LIST:[["SUBSCRIPT_EXPRESSION_LISTABLE","$$ = [$1]"],["SUBSCRIPT_EXPRESSION_LIST , SUBSCRIPT_EXPRESSION_LISTABLE","$$ = $1.concat($3)"]],SUBSCRIPT_EXPRESSION_LISTABLE:[["INTEGER",'$$ = { expression: { type: "numeric_literal", value: parseInt($1) } }; yy.ast.set($$)'],["STRING_LITERAL",'$$ = { expression: { type: "string_literal", value: $1 } }; yy.ast.set($$)'],["ARRAY_SLICE",'$$ = { expression: { type: "slice", value: $1 } }; yy.ast.set($$)']],SUBSCRIPT_EXPRESSION:[["STAR",'$$ = { expression: { type: "wildcard", value: $1 } }; yy.ast.set($$)'],["SCRIPT_EXPRESSION",'$$ = { expression: { type: "script_expression", value: $1 } }; yy.ast.set($$)'],["FILTER_EXPRESSION",'$$ = { expression: { type: "filter_expression", value: $1 } }; yy.ast.set($$)']],STRING_LITERAL:[["QQ_STRING","$$ = $1"],["Q_STRING","$$ = $1"]]}};o.readFileSync&&(i.moduleInclude=o.readFileSync(e.resolve("../include/module.js")),i.actionInclude=o.readFileSync(e.resolve("../include/action.js"))),t.exports=i},{"./dict":2,fs:12}],4:[function(e,t,n){var r=e("./aesprim"),o=e("./slice"),i=e("static-eval"),a=e("underscore").uniq,s=function(){return this.initialize.apply(this,arguments)};function l(t,n,o){var i=e("./index"),a=h(r.parse(n).body[0].expression,{"@":t.value}),s=o.replace(/\{\{\s*value\s*\}\}/g,a),l=i.nodes(t.value,s);return l.forEach((function(e){e.path=t.path.concat(e.path.slice(1))})),l}function c(e){return Array.isArray(e)}function u(e){return function(t,n,r,o){var i=t.value,a=t.path,s=[],l=function(t,i){var a;c(t)?(t.forEach((function(e,t){s.length>=o||r(t,e,n)&&s.push({path:i.concat(t),value:e})})),t.forEach((function(t,n){s.length>=o||e&&l(t,i.concat(n))}))):(a=t)&&!(a instanceof Array)&&a instanceof Object&&(this.keys(t).forEach((function(e){s.length>=o||r(e,t[e],n)&&s.push({path:i.concat(e),value:t[e]})})),this.keys(t).forEach((function(n){s.length>=o||e&&l(t[n],i.concat(n))})))}.bind(this);return l(i,a),s}}function d(e){return function(t,n,r){return this.descend(n,t.expression.value,e,r)}}function f(e){return function(t,n,r){return this.traverse(n,t.expression.value,e,r)}}function h(){try{return i.apply(this,arguments)}catch(e){}}function p(e){return e=e.filter((function(e){return e})),a(e,(function(e){return e.path.map((function(e){return String(e).replace("-","--")})).join("-")}))}function g(e){var t=String(e);return t.match(/^-?[0-9]+$/)?parseInt(t):null}s.prototype.initialize=function(){this.traverse=u(!0),this.descend=u()},s.prototype.keys=Object.keys,s.prototype.resolve=function(e){var t=[e.operation,e.scope,e.expression.type].join("-"),n=this._fns[t];if(!n)throw new Error("couldn't resolve key: "+t);return n.bind(this)},s.prototype.register=function(e,t){if(!t instanceof Function)throw new Error("handler must be a function");this._fns[e]=t},s.prototype._fns={"member-child-identifier":function(e,t){var n=e.expression.value,r=t.value;if(r instanceof Object&&n in r)return[{value:r[n],path:t.path.concat(n)}]},"member-descendant-identifier":f((function(e,t,n){return e==n})),"subscript-child-numeric_literal":d((function(e,t,n){return e===n})),"member-child-numeric_literal":d((function(e,t,n){return String(e)===String(n)})),"subscript-descendant-numeric_literal":f((function(e,t,n){return e===n})),"member-child-wildcard":d((function(){return!0})),"member-descendant-wildcard":f((function(){return!0})),"subscript-descendant-wildcard":f((function(){return!0})),"subscript-child-wildcard":d((function(){return!0})),"subscript-child-slice":function(e,t){if(c(t.value)){var n=e.expression.value.split(":").map(g),r=t.value.map((function(e,n){return{value:e,path:t.path.concat(n)}}));return o.apply(null,[r].concat(n))}},"subscript-child-union":function(e,t){var n=[];return e.expression.value.forEach((function(e){var r={operation:"subscript",scope:"child",expression:e.expression},o=this.resolve(r)(r,t);o&&(n=n.concat(o))}),this),p(n)},"subscript-descendant-union":function(t,n,r){var o=e(".."),i=this,a=[];return o.nodes(n,"$..*").slice(1).forEach((function(e){a.length>=r||t.expression.value.forEach((function(t){var n={operation:"subscript",scope:"child",expression:t.expression},r=i.resolve(n)(n,e);a=a.concat(r)}))})),p(a)},"subscript-child-filter_expression":function(e,t,n){var o=e.expression.value.slice(2,-1),i=r.parse(o).body[0].expression;return this.descend(t,null,(function(e,t){return h(i,{"@":t})}),n)},"subscript-descendant-filter_expression":function(e,t,n){var o=e.expression.value.slice(2,-1),i=r.parse(o).body[0].expression;return this.traverse(t,null,(function(e,t){return h(i,{"@":t})}),n)},"subscript-child-script_expression":function(e,t){return l(t,e.expression.value.slice(1,-1),"$[{{value}}]")},"member-child-script_expression":function(e,t){return l(t,e.expression.value.slice(1,-1),"$.{{value}}")},"member-descendant-script_expression":function(e,t){return l(t,e.expression.value.slice(1,-1),"$..value")}},s.prototype._fns["subscript-child-string_literal"]=s.prototype._fns["member-child-identifier"],s.prototype._fns["member-descendant-numeric_literal"]=s.prototype._fns["subscript-descendant-string_literal"]=s.prototype._fns["member-descendant-identifier"],t.exports=s},{"..":"jsonpath","./aesprim":"./aesprim","./index":5,"./slice":7,"static-eval":15,underscore:12}],5:[function(e,t,n){var r=e("assert"),o=e("./dict"),i=e("./parser"),a=e("./handlers"),s=function(){this.initialize.apply(this,arguments)};function l(e){return"[object String]"==Object.prototype.toString.call(e)}s.prototype.initialize=function(){this.parser=new i,this.handlers=new a},s.prototype.parse=function(e){return r.ok(l(e),"we need a path"),this.parser.parse(e)},s.prototype.parent=function(e,t){r.ok(e instanceof Object,"obj needs to be an object"),r.ok(t,"we need a path");var n=this.nodes(e,t)[0];return n.path.pop(),this.value(e,n.path)},s.prototype.apply=function(e,t,n){r.ok(e instanceof Object,"obj needs to be an object"),r.ok(t,"we need a path"),r.equal(K(n),"function","fn needs to be function");var o=this.nodes(e,t).sort((function(e,t){return t.path.length-e.path.length}));return o.forEach((function(t){var r=t.path.pop(),o=this.value(e,this.stringify(t.path)),i=t.value=n.call(e,o[r]);o[r]=i}),this),o},s.prototype.value=function(e,t,n){if(r.ok(e instanceof Object,"obj needs to be an object"),r.ok(t,"we need a path"),arguments.length>=3){var o=this.nodes(e,t).shift();if(!o)return this._vivify(e,t,n);var i=o.path.slice(-1).shift();this.parent(e,this.stringify(o.path))[i]=n}return this.query(e,this.stringify(t),1).shift()},s.prototype._vivify=function(e,t,n){var o=this;r.ok(e instanceof Object,"obj needs to be an object"),r.ok(t,"we need a path");var i=this.parser.parse(t).map((function(e){return e.expression.value})),a=function(t,n){var r=t.pop(),i=o.value(e,t);i||(a(t.concat(),"string"==typeof r?{}:[]),i=o.value(e,t)),i[r]=n};return a(i,n),this.query(e,t)[0]},s.prototype.query=function(e,t,n){r.ok(e instanceof Object,"obj needs to be an object"),r.ok(l(t),"we need a path");var o=this.nodes(e,t,n).map((function(e){return e.value}));return o},s.prototype.paths=function(e,t,n){r.ok(e instanceof Object,"obj needs to be an object"),r.ok(t,"we need a path");var o=this.nodes(e,t,n).map((function(e){return e.path}));return o},s.prototype.nodes=function(e,t,n){if(r.ok(e instanceof Object,"obj needs to be an object"),r.ok(t,"we need a path"),0===n)return[];var o=this.parser.parse(t),i=this.handlers,a=[{path:["$"],value:e}],s=[];return o.length&&"root"==o[0].expression.type&&o.shift(),o.length?(o.forEach((function(e,t){if(!(s.length>=n)){var r=i.resolve(e),l=[];a.forEach((function(i){if(!(s.length>=n)){var a=r(e,i,n);t==o.length-1?s=s.concat(a||[]):l=l.concat(a||[])}})),a=l}})),n?s.slice(0,n):s):a},s.prototype.stringify=function(e){r.ok(e,"we need a path");var t="$",n={"descendant-member":"..{{value}}","child-member":".{{value}}","descendant-subscript":"..[{{value}}]","child-subscript":"[{{value}}]"};return(e=this._normalize(e)).forEach((function(e){if("root"!=e.expression.type){var r,o=[e.scope,e.operation].join("-"),i=n[o];if(r="string_literal"==e.expression.type?JSON.stringify(e.expression.value):e.expression.value,!i)throw new Error("couldn't find template "+o);t+=i.replace(/{{value}}/,r)}})),t},s.prototype._normalize=function(e){if(r.ok(e,"we need a path"),"string"==typeof e)return this.parser.parse(e);if(Array.isArray(e)&&"string"==typeof e[0]){var t=[{expression:{type:"root",value:"$"}}];return e.forEach((function(e,n){"$"==e&&0===n||("string"==typeof e&&e.match("^"+o.identifier+"$")?t.push({operation:"member",scope:"child",expression:{value:e,type:"identifier"}}):t.push({operation:"subscript",scope:"child",expression:{value:e,type:"number"==typeof e?"numeric_literal":"string_literal"}}))})),t}if(Array.isArray(e)&&"object"==K(e[0]))return e;throw new Error("couldn't understand path "+e)},s.Handlers=a,s.Parser=i;var c=new s;c.JSONPath=s,t.exports=c},{"./dict":2,"./handlers":4,"./parser":6,assert:8}],6:[function(e,t,n){var r=e("./grammar"),o=e("../generated/parser"),i=function(){var e=new o.Parser,t=e.parseError;return e.yy.parseError=function(){e.yy.ast&&e.yy.ast.initialize(),t.apply(e,arguments)},e};i.grammar=r,t.exports=i},{"../generated/parser":1,"./grammar":3}],7:[function(e,t,n){function r(e){return String(e).match(/^[0-9]+$/)?parseInt(e):Number.isFinite(e)?parseInt(e,10):0}t.exports=function(e,t,n,o){if("string"==typeof t)throw new Error("start cannot be a string");if("string"==typeof n)throw new Error("end cannot be a string");if("string"==typeof o)throw new Error("step cannot be a string");var i=e.length;if(0===o)throw new Error("step cannot be zero");if(o=o?r(o):1,n=n<0?i+n:n,t=r(0===(t=t<0?i+t:t)?0:t||(o>0?0:i-1)),n=r(0===n?0:n||(o>0?i:-1)),t=o>0?Math.max(0,t):Math.min(i,t),n=o>0?Math.min(n,i):Math.max(-1,n),o>0&&n<=t)return[];if(o<0&&t<=n)return[];for(var a=[],s=t;s!=n&&!(o<0&&s<=n||o>0&&s>=n);s+=o)a.push(e[s]);return a}},{}],8:[function(e,t,n){var r=e("util/"),o=Array.prototype.slice,i=Object.prototype.hasOwnProperty,a=t.exports=u;function s(e,t){return r.isUndefined(t)?""+t:r.isNumber(t)&&!isFinite(t)||r.isFunction(t)||r.isRegExp(t)?t.toString():t}function l(e,t){return r.isString(e)?e.length<t?e:e.slice(0,t):e}function c(e,t,n,r,o){throw new a.AssertionError({message:n,actual:e,expected:t,operator:r,stackStartFunction:o})}function u(e,t){e||c(e,!0,t,"==",a.ok)}function d(e,t){if(e===t)return!0;if(r.isBuffer(e)&&r.isBuffer(t)){if(e.length!=t.length)return!1;for(var n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}return r.isDate(e)&&r.isDate(t)?e.getTime()===t.getTime():r.isRegExp(e)&&r.isRegExp(t)?e.source===t.source&&e.global===t.global&&e.multiline===t.multiline&&e.lastIndex===t.lastIndex&&e.ignoreCase===t.ignoreCase:r.isObject(e)||r.isObject(t)?function(e,t){if(r.isNullOrUndefined(e)||r.isNullOrUndefined(t))return!1;if(e.prototype!==t.prototype)return!1;if(r.isPrimitive(e)||r.isPrimitive(t))return e===t;var n=f(e),i=f(t);if(n&&!i||!n&&i)return!1;if(n)return d(e=o.call(e),t=o.call(t));var a,s,l=g(e),c=g(t);if(l.length!=c.length)return!1;for(l.sort(),c.sort(),s=l.length-1;s>=0;s--)if(l[s]!=c[s])return!1;for(s=l.length-1;s>=0;s--)if(!d(e[a=l[s]],t[a]))return!1;return!0}(e,t):e==t}function f(e){return"[object Arguments]"==Object.prototype.toString.call(e)}function h(e,t){return!(!e||!t)&&("[object RegExp]"==Object.prototype.toString.call(t)?t.test(e):e instanceof t||!0===t.call({},e))}function p(e,t,n,o){var i;r.isString(n)&&(o=n,n=null);try{t()}catch(e){i=e}if(o=(n&&n.name?" ("+n.name+").":".")+(o?" "+o:"."),e&&!i&&c(i,n,"Missing expected exception"+o),!e&&h(i,n)&&c(i,n,"Got unwanted exception"+o),e&&i&&n&&!h(i,n)||!e&&i)throw i}a.AssertionError=function(e){this.name="AssertionError",this.actual=e.actual,this.expected=e.expected,this.operator=e.operator,e.message?(this.message=e.message,this.generatedMessage=!1):(this.message=function(e){return l(JSON.stringify(e.actual,s),128)+" "+e.operator+" "+l(JSON.stringify(e.expected,s),128)}(this),this.generatedMessage=!0);var t=e.stackStartFunction||c;if(Error.captureStackTrace)Error.captureStackTrace(this,t);else{var n=new Error;if(n.stack){var r=n.stack,o=r.indexOf("\n"+t.name);if(o>=0){var i=r.indexOf("\n",o+1);r=r.substring(i+1)}this.stack=r}}},r.inherits(a.AssertionError,Error),a.fail=c,a.ok=u,a.equal=function(e,t,n){e!=t&&c(e,t,n,"==",a.equal)},a.notEqual=function(e,t,n){e==t&&c(e,t,n,"!=",a.notEqual)},a.deepEqual=function(e,t,n){d(e,t)||c(e,t,n,"deepEqual",a.deepEqual)},a.notDeepEqual=function(e,t,n){d(e,t)&&c(e,t,n,"notDeepEqual",a.notDeepEqual)},a.strictEqual=function(e,t,n){e!==t&&c(e,t,n,"===",a.strictEqual)},a.notStrictEqual=function(e,t,n){e===t&&c(e,t,n,"!==",a.notStrictEqual)},a.throws=function(e,t,n){p.apply(this,[!0].concat(o.call(arguments)))},a.doesNotThrow=function(e,t){p.apply(this,[!1].concat(o.call(arguments)))},a.ifError=function(e){if(e)throw e};var g=Object.keys||function(e){var t=[];for(var n in e)i.call(e,n)&&t.push(n);return t}},{"util/":11}],9:[function(e,t,n){t.exports="function"==typeof Object.create?function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}},{}],10:[function(e,t,n){t.exports=function(e){return e&&"object"===K(e)&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},{}],11:[function(e,t,n){(function(t,r){var o=/%[sdj%]/g;n.format=function(e){if(!y(e)){for(var t=[],n=0;n<arguments.length;n++)t.push(s(arguments[n]));return t.join(" ")}n=1;for(var r=arguments,i=r.length,a=String(e).replace(o,(function(e){if("%%"===e)return"%";if(n>=i)return e;switch(e){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(e){return"[Circular]"}default:return e}})),l=r[n];n<i;l=r[++n])g(l)||!b(l)?a+=" "+l:a+=" "+s(l);return a},n.deprecate=function(e,o){if(_(r.process))return function(){return n.deprecate(e,o).apply(this,arguments)};if(!0===t.noDeprecation)return e;var i=!1;return function(){if(!i){if(t.throwDeprecation)throw new Error(o);t.traceDeprecation?console.trace(o):console.error(o),i=!0}return e.apply(this,arguments)}};var i,a={};function s(e,t){var r={seen:[],stylize:c};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),p(t)?r.showHidden=t:t&&n._extend(r,t),_(r.showHidden)&&(r.showHidden=!1),_(r.depth)&&(r.depth=2),_(r.colors)&&(r.colors=!1),_(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=l),u(r,e,r.depth)}function l(e,t){var n=s.styles[t];return n?"["+s.colors[n][0]+"m"+e+"["+s.colors[n][1]+"m":e}function c(e,t){return e}function u(e,t,r){if(e.customInspect&&t&&S(t.inspect)&&t.inspect!==n.inspect&&(!t.constructor||t.constructor.prototype!==t)){var o=t.inspect(r,e);return y(o)||(o=u(e,o,r)),o}var i=function(e,t){if(_(t))return e.stylize("undefined","undefined");if(y(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}return m(t)?e.stylize(""+t,"number"):p(t)?e.stylize(""+t,"boolean"):g(t)?e.stylize("null","null"):void 0}(e,t);if(i)return i;var a=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,n){t[e]=!0})),t}(a);if(e.showHidden&&(a=Object.getOwnPropertyNames(t)),w(t)&&(a.indexOf("message")>=0||a.indexOf("description")>=0))return d(t);if(0===a.length){if(S(t))return e.stylize("[Function"+(t.name?": "+t.name:"")+"]","special");if(v(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(x(t))return e.stylize(Date.prototype.toString.call(t),"date");if(w(t))return d(t)}var l,c="",b=!1,C=["{","}"];return h(t)&&(b=!0,C=["[","]"]),S(t)&&(c=" [Function"+(t.name?": "+t.name:"")+"]"),v(t)&&(c=" "+RegExp.prototype.toString.call(t)),x(t)&&(c=" "+Date.prototype.toUTCString.call(t)),w(t)&&(c=" "+d(t)),0!==a.length||b&&0!=t.length?r<0?v(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),l=b?function(e,t,n,r,o){for(var i=[],a=0,s=t.length;a<s;++a)N(t,String(a))?i.push(f(e,t,n,r,String(a),!0)):i.push("");return o.forEach((function(o){o.match(/^\d+$/)||i.push(f(e,t,n,r,o,!0))})),i}(e,t,r,s,a):a.map((function(n){return f(e,t,r,s,n,b)})),e.seen.pop(),function(e,t,n){var r=e.reduce((function(e,t){return t.indexOf("\n"),e+t.replace(/\u001b\[\d\d?m/g,"").length+1}),0);return r>60?n[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+n[1]:n[0]+t+" "+e.join(", ")+" "+n[1]}(l,c,C)):C[0]+c+C[1]}function d(e){return"["+Error.prototype.toString.call(e)+"]"}function f(e,t,n,r,o,i){var a,s,l;if((l=Object.getOwnPropertyDescriptor(t,o)||{value:t[o]}).get?s=e.stylize(l.set?"[Getter/Setter]":"[Getter]","special"):l.set&&(s=e.stylize("[Setter]","special")),N(r,o)||(a="["+o+"]"),s||(e.seen.indexOf(l.value)<0?(s=g(n)?u(e,l.value,null):u(e,l.value,n-1)).indexOf("\n")>-1&&(s=i?s.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+s.split("\n").map((function(e){return" "+e})).join("\n")):s=e.stylize("[Circular]","special")),_(a)){if(i&&o.match(/^\d+$/))return s;(a=JSON.stringify(""+o)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(a=a.substr(1,a.length-2),a=e.stylize(a,"name")):(a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),a=e.stylize(a,"string"))}return a+": "+s}function h(e){return Array.isArray(e)}function p(e){return"boolean"==typeof e}function g(e){return null===e}function m(e){return"number"==typeof e}function y(e){return"string"==typeof e}function _(e){return void 0===e}function v(e){return b(e)&&"[object RegExp]"===C(e)}function b(e){return"object"===K(e)&&null!==e}function x(e){return b(e)&&"[object Date]"===C(e)}function w(e){return b(e)&&("[object Error]"===C(e)||e instanceof Error)}function S(e){return"function"==typeof e}function C(e){return Object.prototype.toString.call(e)}function A(e){return e<10?"0"+e.toString(10):e.toString(10)}n.debuglog=function(e){if(_(i)&&(i=t.env.NODE_DEBUG||""),e=e.toUpperCase(),!a[e])if(new RegExp("\\b"+e+"\\b","i").test(i)){var r=t.pid;a[e]=function(){var t=n.format.apply(n,arguments);console.error("%s %d: %s",e,r,t)}}else a[e]=function(){};return a[e]},n.inspect=s,s.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},s.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},n.isArray=h,n.isBoolean=p,n.isNull=g,n.isNullOrUndefined=function(e){return null==e},n.isNumber=m,n.isString=y,n.isSymbol=function(e){return"symbol"===K(e)},n.isUndefined=_,n.isRegExp=v,n.isObject=b,n.isDate=x,n.isError=w,n.isFunction=S,n.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"===K(e)||void 0===e},n.isBuffer=e("./support/isBuffer");var k=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function N(e,t){return Object.prototype.hasOwnProperty.call(e,t)}n.log=function(){var e,t;console.log("%s - %s",(t=[A((e=new Date).getHours()),A(e.getMinutes()),A(e.getSeconds())].join(":"),[e.getDate(),k[e.getMonth()],t].join(" ")),n.format.apply(n,arguments))},n.inherits=e("inherits"),n._extend=function(e,t){if(!t||!b(t))return e;for(var n=Object.keys(t),r=n.length;r--;)e[n[r]]=t[n[r]];return e}}).call(this,e("_process"),void 0!==re?re:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":10,_process:14,inherits:9}],12:[function(e,t,n){},{}],13:[function(e,t,n){(function(e){function t(e,t){for(var n=0,r=e.length-1;r>=0;r--){var o=e[r];"."===o?e.splice(r,1):".."===o?(e.splice(r,1),n++):n&&(e.splice(r,1),n--)}if(t)for(;n--;n)e.unshift("..");return e}function r(e,t){if(e.filter)return e.filter(t);for(var n=[],r=0;r<e.length;r++)t(e[r],r,e)&&n.push(e[r]);return n}n.resolve=function(){for(var n="",o=!1,i=arguments.length-1;i>=-1&&!o;i--){var a=i>=0?arguments[i]:e.cwd();if("string"!=typeof a)throw new TypeError("Arguments to path.resolve must be strings");a&&(n=a+"/"+n,o="/"===a.charAt(0))}return(o?"/":"")+(n=t(r(n.split("/"),(function(e){return!!e})),!o).join("/"))||"."},n.normalize=function(e){var i=n.isAbsolute(e),a="/"===o(e,-1);return(e=t(r(e.split("/"),(function(e){return!!e})),!i).join("/"))||i||(e="."),e&&a&&(e+="/"),(i?"/":"")+e},n.isAbsolute=function(e){return"/"===e.charAt(0)},n.join=function(){var e=Array.prototype.slice.call(arguments,0);return n.normalize(r(e,(function(e,t){if("string"!=typeof e)throw new TypeError("Arguments to path.join must be strings");return e})).join("/"))},n.relative=function(e,t){function r(e){for(var t=0;t<e.length&&""===e[t];t++);for(var n=e.length-1;n>=0&&""===e[n];n--);return t>n?[]:e.slice(t,n-t+1)}e=n.resolve(e).substr(1),t=n.resolve(t).substr(1);for(var o=r(e.split("/")),i=r(t.split("/")),a=Math.min(o.length,i.length),s=a,l=0;l<a;l++)if(o[l]!==i[l]){s=l;break}var c=[];for(l=s;l<o.length;l++)c.push("..");return(c=c.concat(i.slice(s))).join("/")},n.sep="/",n.delimiter=":",n.dirname=function(e){if("string"!=typeof e&&(e+=""),0===e.length)return".";for(var t=e.charCodeAt(0),n=47===t,r=-1,o=!0,i=e.length-1;i>=1;--i)if(47===(t=e.charCodeAt(i))){if(!o){r=i;break}}else o=!1;return-1===r?n?"/":".":n&&1===r?"/":e.slice(0,r)},n.basename=function(e,t){var n=function(e){"string"!=typeof e&&(e+="");var t,n=0,r=-1,o=!0;for(t=e.length-1;t>=0;--t)if(47===e.charCodeAt(t)){if(!o){n=t+1;break}}else-1===r&&(o=!1,r=t+1);return-1===r?"":e.slice(n,r)}(e);return t&&n.substr(-1*t.length)===t&&(n=n.substr(0,n.length-t.length)),n},n.extname=function(e){"string"!=typeof e&&(e+="");for(var t=-1,n=0,r=-1,o=!0,i=0,a=e.length-1;a>=0;--a){var s=e.charCodeAt(a);if(47!==s)-1===r&&(o=!1,r=a+1),46===s?-1===t?t=a:1!==i&&(i=1):-1!==t&&(i=-1);else if(!o){n=a+1;break}}return-1===t||-1===r||0===i||1===i&&t===r-1&&t===n+1?"":e.slice(t,r)};var o="b"==="ab".substr(-1)?function(e,t,n){return e.substr(t,n)}:function(e,t,n){return t<0&&(t=e.length+t),e.substr(t,n)}}).call(this,e("_process"))},{_process:14}],14:[function(e,t,n){var r,o,i=t.exports={};function a(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function l(e){if(r===setTimeout)return setTimeout(e,0);if((r===a||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:a}catch(e){r=a}try{o="function"==typeof clearTimeout?clearTimeout:s}catch(e){o=s}}();var c,u=[],d=!1,f=-1;function h(){d&&c&&(d=!1,c.length?u=c.concat(u):f=-1,u.length&&p())}function p(){if(!d){var e=l(h);d=!0;for(var t=u.length;t;){for(c=u,u=[];++f<t;)c&&c[f].run();f=-1,t=u.length}c=null,d=!1,function(e){if(o===clearTimeout)return clearTimeout(e);if((o===s||!o)&&clearTimeout)return o=clearTimeout,clearTimeout(e);try{return o(e)}catch(t){try{return o.call(null,e)}catch(t){return o.call(this,e)}}}(e)}}function g(e,t){this.fun=e,this.array=t}function m(){}i.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];u.push(new g(e,t)),1!==u.length||d||l(p)},g.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=m,i.addListener=m,i.once=m,i.off=m,i.removeListener=m,i.removeAllListeners=m,i.emit=m,i.prependListener=m,i.prependOnceListener=m,i.listeners=function(e){return[]},i.binding=function(e){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},{}],15:[function(e,t,n){var r=e("escodegen").generate;t.exports=function(e,t){t||(t={});var n={},o=function e(o,i){if("Literal"===o.type)return o.value;if("UnaryExpression"===o.type){var a=e(o.argument);return"+"===o.operator?+a:"-"===o.operator?-a:"~"===o.operator?~a:"!"===o.operator?!a:n}if("ArrayExpression"===o.type){for(var s=[],l=0,c=o.elements.length;l<c;l++){if((y=e(o.elements[l]))===n)return n;s.push(y)}return s}if("ObjectExpression"===o.type){var u={};for(l=0;l<o.properties.length;l++){var d=null===(_=o.properties[l]).value?_.value:e(_.value);if(d===n)return n;u[_.key.value||_.key.name]=d}return u}if("BinaryExpression"===o.type||"LogicalExpression"===o.type){if((c=e(o.left))===n)return n;var f=e(o.right);if(f===n)return n;var h=o.operator;return"=="===h?c==f:"==="===h?c===f:"!="===h?c!=f:"!=="===h?c!==f:"+"===h?c+f:"-"===h?c-f:"*"===h?c*f:"/"===h?c/f:"%"===h?c%f:"<"===h?c<f:"<="===h?c<=f:">"===h?c>f:">="===h?c>=f:"|"===h?c|f:"&"===h?c&f:"^"===h?c^f:"&&"===h?c&&f:"||"===h?c||f:n}if("Identifier"===o.type)return{}.hasOwnProperty.call(t,o.name)?t[o.name]:n;if("ThisExpression"===o.type)return{}.hasOwnProperty.call(t,"this")?t.this:n;if("CallExpression"===o.type){var p=e(o.callee);if(p===n)return n;if("function"!=typeof p)return n;var g=o.callee.object?e(o.callee.object):n;g===n&&(g=null);var m=[];for(l=0,c=o.arguments.length;l<c;l++){var y;if((y=e(o.arguments[l]))===n)return n;m.push(y)}return p.apply(g,m)}var _;if("MemberExpression"===o.type)return(u=e(o.object))===n||"function"==typeof u?n:"Identifier"===o.property.type?u[o.property.name]:(_=e(o.property))===n?n:u[_];if("ConditionalExpression"===o.type)return(a=e(o.test))===n?n:e(a?o.consequent:o.alternate);if("ExpressionStatement"===o.type)return(a=e(o.expression))===n?n:a;if("ReturnStatement"===o.type)return e(o.argument);if("FunctionExpression"===o.type){var v=o.body.body,b={};for(Object.keys(t).forEach((function(e){b[e]=t[e]})),l=0;l<o.params.length;l++){var x=o.params[l];if("Identifier"!=x.type)return n;t[x.name]=null}for(var l in v)if(e(v[l])===n)return n;t=b;var w=Object.keys(t),S=w.map((function(e){return t[e]}));return Function(w.join(", "),"return "+r(o)).apply(null,S)}if("TemplateLiteral"===o.type){var C="";for(l=0;l<o.expressions.length;l++)C+=e(o.quasis[l]),C+=e(o.expressions[l]);return C+e(o.quasis[l])}if("TaggedTemplateExpression"===o.type){var A=e(o.tag),k=o.quasi,N=k.quasis.map(e),T=k.expressions.map(e);return A.apply(null,[N].concat(T))}return"TemplateElement"===o.type?o.value.cooked:n}(e);return o===n?void 0:o}},{escodegen:12}],jsonpath:[function(e,t,n){t.exports=e("./lib/index")},{"./lib/index":5}]},{},["jsonpath"])("jsonpath")}(os)),os.exports),as=oe(is);const ss=new Set(["i","me","my","myself","we","our","ours","ourselves","you","your","yours","yourself","yourselves","he","him","his","himself","she","her","hers","herself","it","its","itself","they","them","their","theirs","themselves","what","which","who","whom","this","that","these","those","am","is","are","was","were","be","been","being","have","has","had","having","do","does","did","doing","a","an","the","and","but","if","or","because","as","until","while","of","at","by","for","with","about","against","between","into","through","during","before","after","above","below","to","from","up","down","in","out","on","off","over","under","again","further","then","once","here","there","when","where","why","how","all","any","both","each","few","more","most","other","some","such","no","nor","not","only","own","same","so","than","too","very","s","t","can","will","just","don","should","now","0","1","2","3","4","5","6","7","8","9"]);function ls(e,t){for(const[n,r]of t.entries())if(e.startsWith(r))return e.replace(r,String(n));return e}const cs="$PREFIXED_ID";function us(e,t,n){if(t===cs)return[ls(e.id,n)];let r;try{r=as.query(e,t)}catch{r=as.query(JSON.parse(JSON.stringify(e)),t)}return r}function ds(e){return e.toLowerCase().split(/[^\d:A-Za-z]+/).filter((e=>e&&!ss.has(e)))}function*fs(e){for(const t of e)yield*ds(t)}function*hs(e){for(const t of e)if("string"==typeof t)yield t;else if("object"==typeof t){const e=as.query(t,"$..*");yield*hs(e)}}function*ps(e,t,n){for(const r of t){const t=us(e,r,n);if(t.length>0)for(const e of fs(hs(t)))yield[r,e]}}async function gs(e,t,n){const r=await this.db,o=t??r.transaction(["nodes"]);es(n);const i=[...ds(e)],a=[],s=new Map;a.push(...i.map((async(e,t)=>{es(n);const r=o.objectStore("nodes").index("full-text-words");for await(const o of r.iterate(IDBKeyRange.bound(e,`${e}`,!1,!1))){es(n);const e=o.value,r=s.get(e.id)??[e,new Set];r[1].add(t),s.set(e.id,r)}}))),await Promise.all(a),es(n);const l=[];for(const[,[e,t]]of s)es(n),l.push(...ms(this.textIndexFields,e,t,i,this.prefixes));return l.sort(((e,t)=>t.score-e.score)),l.slice(0,this.options.maxSearchResults??this.DEFAULT_MAX_SEARCH_RESULTS)}function ms(e,t,n,r,o){const i=[...n].sort().map((e=>r[e])),a=i.map((e=>{const t=e.replaceAll(/[$()*+./?[\\\]^{|}-]/g,String.raw`\$&`);return new RegExp(`\\b${t}`,"gi")}));let s=[],l=0;for(const[n,i]of e.entries()){const c=new Set,u=e.length-n-1,d=[...hs(us(t,i.jsonPath,o))];for(const e of d){let n=0;const o=[];for(const[t,i]of a.entries())for(const a of e.matchAll(i)){n+=1+1*u,c.add(t);const i=a.index,s=r[t];void 0!==i&&(n+=.01*s.length,n+=s.length/e.length*100*.05,o.push({wordIndex:t,position:i}))}n+=100*c.size,l<n&&(l=n),o.sort(((e,t)=>e.position-t.position)),o.length>0&&s.push({term:t,field:i,str:e,score:n,wordMatches:o})}}s=s.filter((e=>e.score===l));for(const e of s){const{wordMatches:t}=e;for(let n=0;n<t.length-1;n++){const r=t[n],o=t[n+1],a=o.wordIndex-r.wordIndex;if(1===a||-1===a){e.score+=1,1===a&&(e.score+=1);const t=Math.abs(o.position-(r.position+i[r.wordIndex].length))-1;e.score-=.05*t}}}return s}function ys(e){return"string"==typeof e.id}function _s(e){return"string"==typeof e.sub&&"string"==typeof e.pred&&"string"==typeof e.obj}function vs(e){return Boolean(e.meta?.deprecated)}var bs,xs,ws=(xs||(xs=1,bs=function e(t,n){if(t===n)return!0;if(t&&n&&"object"==K(t)&&"object"==K(n)){if(t.constructor!==n.constructor)return!1;var r,o,i;if(Array.isArray(t)){if((r=t.length)!=n.length)return!1;for(o=r;0!=o--;)if(!e(t[o],n[o]))return!1;return!0}if(t instanceof Map&&n instanceof Map){if(t.size!==n.size)return!1;var a,s=j(t.entries());try{for(s.s();!(a=s.n()).done;)if(!n.has((o=a.value)[0]))return!1}catch(e){s.e(e)}finally{s.f()}var l,c=j(t.entries());try{for(c.s();!(l=c.n()).done;)if(!e((o=l.value)[1],n.get(o[0])))return!1}catch(e){c.e(e)}finally{c.f()}return!0}if(t instanceof Set&&n instanceof Set){if(t.size!==n.size)return!1;var u,d=j(t.entries());try{for(d.s();!(u=d.n()).done;)if(!n.has((o=u.value)[0]))return!1}catch(e){d.e(e)}finally{d.f()}return!0}if(ArrayBuffer.isView(t)&&ArrayBuffer.isView(n)){if((r=t.length)!=n.length)return!1;for(o=r;0!=o--;)if(t[o]!==n[o])return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if((r=(i=Object.keys(t)).length)!==Object.keys(n).length)return!1;for(o=r;0!=o--;)if(!Object.prototype.hasOwnProperty.call(n,i[o]))return!1;for(o=r;0!=o--;){var f=i[o];if(!e(t[f],n[f]))return!1}return!0}return t!=t&&n!=n}),bs),Ss=oe(ws);function Cs(e){return"CLASS"===e.type}function As(e){return"PROPERTY"===e.type}const ks=[{displayName:"Label",jsonPath:"$.lbl"},{displayName:"Synonym",jsonPath:"$.meta.synonyms[*].val"},{displayName:"Definition",jsonPath:"$.meta.definition.val"}];async function Ns(e){return qa(e,2,{upgrade(e,t,n,r,o){if(t<2&&(e.objectStoreNames.contains("meta")&&e.deleteObjectStore("meta"),e.objectStoreNames.contains("nodes")&&e.deleteObjectStore("nodes"),e.objectStoreNames.contains("edges")&&e.deleteObjectStore("edges")),e.objectStoreNames.contains("meta")||e.createObjectStore("meta"),!e.objectStoreNames.contains("nodes")){e.createObjectStore("nodes",{keyPath:"id"});const t=r.objectStore("nodes");t.createIndex("by-label","lbl"),t.createIndex("by-type","type"),t.createIndex("by-synonym",["meta","synonyms","val"]),t.createIndex("full-text-words","fullTextWords",{multiEntry:!0})}if(!e.objectStoreNames.contains("edges")){e.createObjectStore("edges",{autoIncrement:!0});const t=r.objectStore("edges");t.createIndex("by-subject","sub"),t.createIndex("by-object","obj"),t.createIndex("by-predicate","pred")}}})}function Ts(e){const t=new Set;for(const[,n]of e)t.add(n);return[...t]}async function Rs(e){const t=Date.now();let n,r=1;this.options.update?.("Parsing JSON",r);try{n=JSON.parse(await f.openLocation(this.sourceLocation).readFile("utf8"))}catch{throw new Error("Error in loading ontology")}r+=5,this.options.update?.("Parsing JSON complete",r);const o=Date.now(),[i,...a]=n.graphs??[];if(i){if(a.length>0)throw new Error("multiple graphs not supported");try{const n=e.transaction(["meta","nodes","edges"],"readwrite");await n.objectStore("meta").clear(),await n.objectStore("nodes").clear(),await n.objectStore("edges").clear();const a=n.objectStore("nodes"),s=Es.call(this).map((e=>e.jsonPath));if(i.nodes){let e=Math.round(r);for(const[,t]of i.nodes.entries())r+=1/i.nodes.length*64,Math.round(r)!=e&&r<100&&(this.options.update?.("Processing nodes",r),e=Math.round(r)),ys(t)&&await a.add({...t,fullTextWords:Ts(ps(t,s,this.prefixes))})}const l=n.objectStore("edges");if(i.edges){let e=Math.round(r);for(const[,t]of i.edges.entries())r+=1/i.edges.length*30,Math.round(r)!=e&&r<100&&(this.options.update?.("Processing edges",r),e=Math.round(r)),_s(t)&&await l.add(t)}await n.done;const c=e.transaction("meta","readwrite"),{update:u,...d}=this.options;await c.objectStore("meta").delete("meta"),await c.objectStore("meta").add({ontologyRecord:{name:this.ontologyName,version:this.ontologyVersion,sourceLocation:this.sourceLocation},storeOptions:d,graphMeta:i.meta,timestamp:String(new Date),schemaVersion:2,timings:{overall:Date.now()-t,load:Date.now()-o}},"meta"),await c.done}catch(t){throw await e.transaction("meta","readwrite").objectStore("meta").clear(),t}}}function Es(){return[{displayName:"ID",jsonPath:cs},...this.options.textIndexing?.indexFields??ks]}async function Is(e){const[t]=await e.transaction("meta").objectStore("meta").getAll();return!!t&&Ss(this.options.prefixes,t.storeOptions.prefixes)&&Ss(this.options.textIndexing,t.storeOptions.textIndexing)}class js{ontologyName;ontologyVersion;sourceLocation;db;options;loadOboGraphJson=Rs;getTermsByFulltext=gs;openDatabase=Ns;isDatabaseCurrent=Is;get textIndexFields(){return Es.call(this)}get prefixes(){return this.options.prefixes??new Map}DEFAULT_MAX_SEARCH_RESULTS=100;constructor(e,t,n,r){this.ontologyName=e,this.ontologyVersion=t,this.sourceLocation=n,this.options=r??{},this.db=this.prepareDatabase()}validate(){const e=[],{sourceLocation:t,sourceType:n}=this;return n?"obo-graph-json"!==n&&e.push(new Error(`ontology source file ${JSON.stringify(t)} has type ${n}, which is not yet supported`)):e.push(new Error(`unable to determine format of ontology source file ${JSON.stringify(t)}, file name must end with ".json", ".obo", or ".owl"`)),e}get sourceType(){if(o.isUriLocation(this.sourceLocation)){if(this.sourceLocation.uri.endsWith(".json"))return"obo-graph-json"}else if(o.isLocalPathLocation(this.sourceLocation)&&this.sourceLocation.localPath.endsWith(".json"))return"obo-graph-json"}get dbName(){return`Apollo Ontology "${this.ontologyName}" "${this.ontologyVersion}"`}async prepareDatabase(){const e=this.validate();if(e.length>0)throw e;const t=await this.openDatabase(this.dbName);if(await this.isDatabaseCurrent(t))return t;try{const{options:e,sourceLocation:n,sourceType:r}=this;if("obo-graph-json"!==r)throw new Error(`ontology source file ${JSON.stringify(n)} has type ${r}, which is not yet supported`);return e.update?.("",0),await this.loadOboGraphJson(t),e.update?.("",100),t}catch(e){throw t.close(),await function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).blocked,n=indexedDB.deleteDatabase(e);return t&&n.addEventListener("blocked",(function(e){return t(e.oldVersion,e)})),Pa(n).then((function(){}))}(this.dbName),e}}async termCount(e){const t=await this.db;return(e??t.transaction("nodes")).objectStore("nodes").count()}unique(e){const t=new Map,n=[];for(const r of e)t.has(r.id)||(t.set(r.id,!0),n.push(r));return n}async getTermsWithLabelOrSynonym(e,t,n){const r=t?.includeSubclasses??!0,o=await this.db,i=n??o.transaction(["nodes","edges"]),a=i.objectStore("nodes"),s=[...await a.index("by-label").getAll(e),...await a.index("by-synonym").getAll(e)];if(r){const e=await this.recurseEdges("by-object",s.map((e=>e.id)),(e=>"is_a"===e.pred),"sub",i);for(const t of e){const e=await a.get(t);e&&s.push(e)}}return s}async getPropertiesByLabel(e,t,n){const r=t?.includeSubProperties??!0,o=await this.db,i=n??o.transaction(["nodes","edges"]),a=(await this.getTermsWithLabelOrSynonym(e,{includeSubclasses:!1},i)).filter((e=>As(e)));if(r){const e=await this.recurseEdges("by-object",a.map((e=>e.id)),(e=>"subPropertyOf"===e.pred),"sub",i),t=i.objectStore("nodes");for(const n of e){const e=await t.get(n);e&&As(e)&&a.push(e)}}return a}async recurseEdges(e,t,n,r,o){const i=new Set;return await async function t(a){await Promise.all([...a].map((async a=>{const s=(await o.objectStore("edges").index(e).getAll(a)).filter((e=>n(e))).map((e=>e[r]));if(s.length>0){for(const e of s)i.add(e);await t(s)}})))}(t),i.values()}async*expandNodeSet(e,t="is_a",n,r){const o=await this.db,i=r??o.transaction(["edges"]),a=[...e],s=await this.recurseEdges("subclasses"===n?"by-object":"by-subject",a,(e=>e.pred===t),"subclasses"===n?"sub":"obj",i);for(const e of a)yield e;for(const e of s)yield e}expandSubclasses(e,t="is_a",n){return this.expandNodeSet(e,t,"subclasses",n)}expandSuperclasses(e,t="is_a",n){return this.expandNodeSet(e,t,"superclasses",n)}async getClassesThat(e,t,n){const r=await this.db,o=n??r.transaction(["nodes","edges"]),i=await this.getPropertiesByLabel(e,{includeSubProperties:!0},o),a=new Set(i.map((e=>e.id))),s=await async function(e){const t=[];for await(const n of e)t.push(n);return t}(this.expandSuperclasses(t.map((e=>e.id)),"is_a",o)),l=await this.recurseEdges("by-object",s,(e=>a.has(e.pred)),"sub",o),c=this.expandSubclasses(l,"is_a",o),u=[];for await(const e of c){const t=await o.objectStore("nodes").get(e);t&&Cs(t)&&!vs(t)&&u.push(t)}return u}async getClassesWithoutPropertyLabeled(e,t,n){const r=await this.db,o=n??r.transaction(["nodes","edges"]),i=o.objectStore("nodes"),a=o.objectStore("edges"),s=(await this.getPropertiesByLabel(e,t,o)).map((e=>e.id)),l=await(async()=>{const e=new Set;for(const t of s)for await(const n of a.index("by-predicate").iterate(t))e.add(n.value.sub);const t=new Set;for await(const n of this.expandSubclasses(e,"is_a",o))t.add(n);return t})(),c=[];for await(const e of i){const t=e.value;Cs(t)&&!l.has(t.id)&&c.push(t.id)}const u=[];for(const e of c){const t=await o.objectStore("nodes").get(e);t&&Cs(t)&&!vs(t)&&u.push(t)}return u}async getAllClasses(e){const t=await this.db,n=e??t.transaction(["nodes"]);return(await n.objectStore("nodes").index("by-type").getAll("CLASS")).filter((e=>!vs(e)))}async getAllTerms(e){const t=await this.db,n=e??t.transaction(["nodes"]);return(await n.objectStore("nodes").getAll()).filter((e=>!vs(e)))}}const Ds=l.types.model("OntologyRecord",{name:l.types.string,version:"unversioned",source:l.types.union(d.LocalPathLocation,d.UriLocation,d.BlobLocation),options:l.types.frozen(),equivalentTypes:l.types.map(l.types.array(l.types.string))}).volatile((e=>({dataStore:void 0,startedEquivalentTypeRequests:new Set}))).actions((e=>({ping(){},initDataStore(){e.dataStore=new js(e.name,e.version,l.getSnapshot(e.source),e.options)},afterCreate(){l.addDisposer(e,c.autorun((()=>{this.initDataStore()})))},setEquivalentTypes(t,n){e.equivalentTypes.set(t,n)}}))).actions((e=>({loadEquivalentTypes:l.flow((function*(t){if(!e.dataStore)return;if(e.startedEquivalentTypeRequests.has(t))return;e.startedEquivalentTypeRequests.add(t);const n=(yield e.dataStore.getTermsWithLabelOrSynonym(t)).map((e=>e.lbl)).filter((e=>null!=e));l.isAlive(e)&&e.setEquivalentTypes(t,n)}))}))).actions((e=>({afterCreate(){c.autorun((t=>{e.dataStore&&(e.loadEquivalentTypes("gene"),e.loadEquivalentTypes("pseudogene"),e.loadEquivalentTypes("transcript"),e.loadEquivalentTypes("pseudogenic_transcript"),e.loadEquivalentTypes("CDS"),e.loadEquivalentTypes("mRNA"),t.dispose())}))},setEquivalentTypes(t,n){e.equivalentTypes.set(t,n)}}))).views((e=>({isTypeOf(t,n){if(t===n)return!0;if(!e.dataStore)return!1;const r=e.equivalentTypes.get(n);return r?r.includes(t):(e.loadEquivalentTypes(n),!1)}}))),Os=l.types.model("OntologyManager",{ontologies:l.types.array(Ds),prefixes:l.types.optional(l.types.map(l.types.string),{"GO:":"http://purl.obolibrary.org/obo/GO_","SO:":"http://purl.obolibrary.org/obo/SO_"})}).views((e=>({get featureTypeOntologyName(){const t=l.getRoot(e).jbrowse.configuration;return n.readConfObject(t.ApolloPlugin,"featureTypeOntologyName")}}))).views((e=>({get featureTypeOntology(){return this.findOntology(e.featureTypeOntologyName)},findOntology:(t,n)=>e.ontologies.find((e=>e.name===t&&(void 0===n||e.version===n))),openOntology(e,t){return this.findOntology(e,t)?.dataStore},applyPrefixes:t=>ls(t,e.prefixes),expandPrefixes:t=>function(e,t){for(const[n,r]of t.entries())if(e.startsWith(String(n)))return e.replace(String(n),r);return e}(t,e.prefixes)}))).actions((e=>({addOntology(t,n,r,o){const i=e.ontologies.push({name:t,version:n,source:r,options:{prefixes:new Map(e.prefixes.entries()),...o}});e.ontologies[i-1].ping()}}))),Fs=n.ConfigurationSchema("OntologyRecord",{name:{type:"string",description:'the full name of the ontology, e.g. "Gene Ontology"',defaultValue:"My Ontology"},version:{type:"string",description:"the ontology's version string",defaultValue:"unversioned"},source:{type:"fileLocation",description:"the download location for the ontology's source file",defaultValue:{locationType:"UriLocation",uri:"http://example.com/myontology.json"}},textIndexFields:{type:"frozen",description:"JSON paths for text fields that will be indexed for text searching",defaultValue:ks}});async function Ms(e,t,n){if(!e)return;const r=await t.getTermsWithLabelOrSynonym(e.type,{includeSubclasses:!1}),o=r.filter(Cs);if(0===r.length)return;const i=await t.getClassesThat("part_of",o);return 0!==i.length?i:void 0}var Ls=a.createSvgIcon(i.jsx("path",{d:"M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"}),"Close");const Ps=ma()((e=>({dialogTitle:{background:e.palette.primary.main,color:e.palette.primary.contrastText,padding:e.spacing(2)},closeButton:{position:"absolute",right:e.spacing(1),top:e.spacing(1.5),color:e.palette.primary.contrastText}}))),Bs=p.observer((function(e){const{classes:t}=Ps(),{handleClose:n,title:r,...o}=e;return i.jsx(h.Dialog,{...o,header:i.jsxs(i.Fragment,{children:[i.jsx(s.DialogTitle,{className:t.dialogTitle,children:r}),i.jsx(s.IconButton,{"aria-label":"close",onClick:n,className:t.closeButton,children:i.jsx(Ls,{})})]})})}));function qs({fetchValidTerms:e,filterTerms:t,includeDeprecated:n,onChange:r,ontologyName:o,ontologyVersion:a,renderInput:l,session:c,style:d,value:f}){const[h,p]=u.useState(!1),[g,m]=u.useState(),[y,_]=u.useState(""),[v,b]=u.useState(),{ontologyManager:x}=c.apolloDataStore,w=x.findOntology(o,a)?.dataStore,S=w&&h&&!g,C=w&&!v,A=u.useCallback((e=>(n||!vs(e))&&(!t||t(e))),[t,n]);u.useEffect((()=>{const e=new AbortController,{signal:t}=e;return C&&async function(e,t,n,r){if(!t)return;const o=(await e.getTermsWithLabelOrSynonym(t,{includeSubclasses:!1})).find((e=>(n??(()=>!0))(e)));if(!o)throw new Error(`not a valid ${e.ontologyName} term`);return o}(w,f,A).then((e=>{_(""),t.aborted||b(e)}),(e=>{t.aborted||ts(e)||_(String(e))})),()=>{e.abort(new DOMException("Cancel getting current term from ontology store","AbortError"))}}),[c,f,A,w,C]),u.useEffect((()=>{const t=new AbortController,{signal:n}=t;return S&&async function(e,t,n,r){let o;if(t){const n=await t(e,r);n&&(o=n)}return o??=await e.getAllTerms(),n?o.filter((e=>n(e))):o}(w,e,A,n).then((e=>{e&&!n.aborted&&m(e)}),(e=>{n.aborted||ts(e)||c.notify(e instanceof Error?e.message:String(e),"error")})),()=>{t.abort(new DOMException("Canceling getting valid terms from ontology store","AbortError"))}}),[S,A,w,c,e]);const k={};return y&&(k.error=!0,k.helperText=y),i.jsx(s.Autocomplete,{style:d,autoComplete:!0,filterSelectedOptions:!0,disableClearable:!0,selectOnFocus:!0,clearOnBlur:!0,handleHomeEndKeys:!0,freeSolo:!0,value:f,options:g??[],onOpen:()=>{p(!0)},onClose:()=>{p(!1)},loading:S,renderInput:l??(e=>i.jsx(s.TextField,{...e,...k})),getOptionLabel:e=>"string"==typeof e?e:e.lbl??"",isOptionEqualToValue:(e,t)=>e.lbl===t.lbl,onChange:(e,t)=>{t&&("string"==typeof t?(b(void 0),r(f,t)):t.lbl!==f&&(_(""),b(t),r(f,t.lbl)))}})}function Us({changeManager:e,handleClose:t,session:n,sourceAssemblyId:r,sourceFeature:o}){const[a,l]=u.useState(String(o.max)),[c,d]=u.useState(String(o.min+1)),[f,h]=u.useState(""),[p,g]=u.useState(""),[m,y]=u.useState(""),_=Number(a)<=Number(c);return i.jsxs(Bs,{open:!0,title:"Add new child feature",handleClose:t,maxWidth:!1,"data-testid":"add-feature-dialog",children:[i.jsxs("form",{onSubmit:function(i){i.preventDefault(),g("");const s=(new at).toHexString(),l={_id:s,refSeq:o.refSeq,min:Number(c)-1,max:Number(a),type:f};o.strand&&(l.strand=o.strand);const u=new ht({changedIds:[o._id],typeName:"AddFeatureChange",assembly:r,addedFeature:l,parentFeatureId:o._id});e.submit(u).then((()=>{n.apolloSetSelectedFeature(s)})),t(),i.preventDefault()},children:[i.jsxs(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:[i.jsx(s.TextField,{margin:"dense",id:"start",label:"Start",type:"number",fullWidth:!0,variant:"outlined",value:c,onChange:e=>{d(e.target.value)}}),i.jsx(s.TextField,{margin:"dense",id:"end",label:"End",type:"number",fullWidth:!0,variant:"outlined",value:a,onChange:e=>{l(e.target.value)},error:_,helperText:_?'"End" must be greater than "Start"':null}),i.jsx(qs,{session:n,ontologyName:"Sequence Ontology",style:{width:170},value:f,filterTerms:Cs,fetchValidTerms:async function(e,t,n){const r=await Ms(e,t);if(r)return r;y(`Type "${e?.type}" does not have any children in the ontology`)}.bind(null,o),renderInput:e=>i.jsx(s.TextField,{...e,label:"Type",variant:"outlined",fullWidth:!0,error:Boolean(m),helperText:m}),onChange:(e,t)=>{var n;t&&(n=t,g(""),h(n))}})]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{variant:"contained",type:"submit",disabled:_||!(c&&a&&f),children:"Submit"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:t,children:"Cancel"})]})]}),p?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:p})}):null]})}const zs=["#cc79a7","#d65e00","#e69f00","#f0e442","#56b3e9","#0072b2","#009e73"];function $s({changeManager:e,handleClose:t,sourceAssemblyId:n,sourceFeature:r}){const o=r.attributes.get("apollo_color")?.[0],[a,c]=u.useState(o??zs[0]);return i.jsx(Bs,{open:!0,title:"Color feature",handleClose:t,maxWidth:!1,"data-testid":"color-feature",children:i.jsxs("form",{onSubmit:o=>{!async function(o){o.preventDefault();const i=r.attributes.get("apollo_color")?.[0];if(i===a)return void t();const s=l.getSnapshot(r.attributes),c={...s,apollo_color:[a]},u=new St({changedIds:[r._id],typeName:"FeatureAttributeChange",assembly:n,featureId:r._id,oldAttributes:s,newAttributes:c});await e.submit(u),t()}(o)},children:[i.jsxs(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:[i.jsx(s.DialogContentText,{children:"Choose a color for this feature."}),i.jsx("div",{style:{display:"flex",gap:8,marginTop:8},children:zs.map((e=>{const t=a.toLowerCase()===e;return i.jsx("button",{type:"button","aria-label":e,"aria-pressed":t,onClick:()=>{c(e)},style:{width:32,height:32,padding:0,borderRadius:4,border:"1px solid rgba(0, 0, 0, 0.3)",outline:t?"2px solid currentColor":"none",outlineOffset:2,backgroundColor:e,cursor:"pointer"}},e)}))}),i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:16},children:[i.jsx("label",{htmlFor:"color-feature-custom",children:"Custom:"}),i.jsx("input",{id:"color-feature-custom",type:"color",value:a,onChange:e=>{c(e.target.value)}})]})]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{variant:"contained",type:"submit",children:"Submit"}),i.jsx(s.Button,{variant:"outlined",color:"error",type:"button",disabled:void 0===o,onClick:()=>{!async function(){const o=l.getSnapshot(r.attributes),{apollo_color:i,...a}=o,s=new St({changedIds:[r._id],typeName:"FeatureAttributeChange",assembly:n,featureId:r._id,oldAttributes:o,newAttributes:a});await e.submit(s),t()}()},children:"Remove color"}),i.jsx(s.Button,{variant:"outlined",type:"button",onClick:t,children:"Cancel"})]})]})})}function Hs(e,t){const n=(new at).toHexString();t.push(n);const r={};if(e.children)for(const n of Object.values(e.children)){const e=Hs(n,t);r[e._id]=e}const o="string"==typeof e.refSeq?e.refSeq:e.refSeq.toHexString();return{...e,refSeq:o,children:e.children&&r,_id:n}}function Gs({changeManager:e,handleClose:t,session:r,sourceAssemblyId:o,sourceFeature:a}){const{assemblyManager:c}=r,d=c.assemblyList,[f,h]=u.useState(d.find((e=>e.name!==o))?.name),[p,g]=u.useState([]),[m,y]=u.useState(""),[_,v]=u.useState(a.min),[b,x]=u.useState("");function w(e,t){const n={};if(e.children)for(const r of Object.values(e.children)){const e=w(r,t);e.refSeq=m,e.min=e.min+t,e.max=e.max+t,n[e._id]=e}const r="string"==typeof e.refSeq?e.refSeq:e.refSeq.toHexString(),o="string"==typeof e._id?e._id:e._id.toHexString();return{...e,refSeq:r,children:e.children&&n,_id:o}}return u.useEffect((()=>{(async function(){if(y(""),!f)return void x("No assemblies to copy to");const e=await c.waitForAssembly(f);if(!e)return;const{refNameAliases:t}=e;if(!t)return;const n=[...Object.entries(t)].filter((([e,t])=>e!==t)).map((([e,t])=>({_id:e,name:t})));g(n),y(n[0]?._id||"")})().catch((e=>{x(String(e))}))}),[f,c]),i.jsxs(Bs,{open:!0,title:"Copy features and annotations",handleClose:t,maxWidth:!1,"data-testid":"copy-feature",children:[i.jsxs("form",{onSubmit:async function(n){if(!f)return;n.preventDefault(),x("");const o=a.length,i=await c.waitForAssembly(f);if(!i)return void x(`Assembly not found: ${f}.`);const s=i.getCanonicalRefName(m),u=i.regions?.find((e=>e.refName===s));if(!u)return void x(`RefSeq not found: ${m}.`);const d=_+o;if(d>u.end)return void x(`Feature would extend beyond the bounds of the selected reference sequence. (Feature would end at ${d}, but reference sequence ends at ${u.end})`);if(_<u.start)return void x(`Reference sequence starts at ${u.start}, feature cannot start before that.`);const h=[],p=Hs(l.getSnapshot(a),h),g={...p.attributes};"Parent"in g&&delete g.Parent,p.refSeq=m;const y=_-p.min;p.min=_,p.max=_+o;const v=w(p,y),b=new ht({changedIds:[p._id],typeName:"AddFeatureChange",assembly:f,addedFeature:{_id:p._id,refSeq:p.refSeq,min:p.min,max:p.max,type:p.type,children:v.children,attributes:g,strand:p.strand},copyFeature:!0,allIds:h});e.submit(b).then((()=>{r.apolloSetSelectedFeature(p._id)})),t(),n.preventDefault()},children:[i.jsxs(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:[i.jsx(s.DialogContentText,{children:"Target assembly"}),i.jsx(s.Select,{labelId:"label",value:f,onChange:function(e){h(e.target.value)},children:d.filter((e=>e.name!==o)).map((e=>i.jsx(s.MenuItem,{value:e.name,children:n.readConfObject(e,"displayName")},e.name)))}),i.jsx(s.DialogContentText,{children:"Target reference sequence"}),i.jsx(s.Select,{labelId:"label",value:m,onChange:function(e){y(e.target.value)},children:p.map((e=>i.jsx(s.MenuItem,{value:e._id,children:e.name},e._id)))}),i.jsx(s.DialogContentText,{children:"Start position in target reference sequence"}),i.jsx(s.TextField,{margin:"dense",type:"number",fullWidth:!0,variant:"outlined",value:_,onChange:e=>{v(Number(e.target.value))}})]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{disabled:!f||!m||!_,variant:"contained",type:"submit",children:"Submit"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:t,children:"Cancel"})]})]}),b?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:b})}):null]})}function Vs({changeManager:e,handleClose:t,selectedFeature:n,session:r,setSelectedFeature:o,sourceAssemblyId:a,sourceFeature:c}){const[d,f]=u.useState(""),{ontologyManager:h}=r.apolloDataStore,{featureTypeOntology:p}=h;function g(e){if(!e.parent?.children||1===e.parent.children.size)return;const t=[];for(const n of e.parent.children.values())p?.isTypeOf(n.type,"CDS")||t.push(n);t.sort(((e,t)=>e.min-t.min));const n=[];for(const t of e.parent.children.values())p?.isTypeOf(t.type,"CDS")||n.push(t);if(n.sort(((e,t)=>t.max-e.max)),e.min===t[0].min){let n;for(const r of t)if(r._id!==e._id&&r.min>=e.min){n=r.min;break}if(n&&n!=e.parent.min)return{typeName:"LocationStartChange",changedId:e.parent._id,featureId:e.parent._id,oldLocation:e.parent.min,newLocation:n}}if(e.max===n[0].max){let t;for(const r of n)if(r._id!=e._id&&r.max<=e.max){t=r.max;break}if(t&&t!=e.parent.max)return{typeName:"LocationEndChange",changedId:e.parent._id,featureId:e.parent._id,oldLocation:e.parent.max,newLocation:t}}}return i.jsxs(Bs,{open:!0,title:"Delete feature",handleClose:t,maxWidth:!1,"data-testid":"delete-feature",children:[i.jsxs("form",{onSubmit:r=>{!async function(r){r.preventDefault(),f(""),n?._id===c._id&&o();const i=[],s=new pt({changedIds:[c._id],typeName:"DeleteFeatureChange",assembly:a,changes:[{deletedFeature:l.getSnapshot(c),parentFeatureId:c.parent?._id}]});if(p&&(p.isTypeOf(c.type,"transcript")||p.isTypeOf(c.type,"pseudogenic_transcript"))){const e=g(c);e&&i.push(e)}if(p?.isTypeOf(c.type,"exon")){const e=function(e){if(!p)return;if(!p.isTypeOf(e.type,"exon"))return;if(!e.parent?.cdsLocations||0===e.parent.cdsLocations.length||0===e.parent.cdsLocations[0].length)return;if(!e.parent.children)throw new Error("Unable to find parent of CDS");if(1!=e.parent.cdsLocations.length)throw new Error("Unable to handle a transcript with multiple CDSs");const t=(e.parent.cdsLocations.at(0)??[]).sort((({min:e},{min:t})=>e-t));let n;for(const r of e.parent.children.values())if(r.type===t[0].type){n=r;break}if(!n)throw new Error("Unable to find CDS");const r=t[0].min,o=t[t.length-1].max;if(!(e.min>r&&e.max<o||e.max<r||e.min>o)){if(e.min<=r&&e.max>=o)return new pt({changedIds:[n._id],typeName:"DeleteFeatureChange",assembly:a,changes:[{deletedFeature:l.getSnapshot(n),parentFeatureId:n.parent?._id}]});if(e.min<=r&&e.max>r){let r;for(const n of t)if(n.min>e.max){r=n.min;break}if(!r)throw new Error("Error setting new CDS start");return{typeName:"LocationStartChange",changedId:n._id,featureId:n._id,oldLocation:n.min,newLocation:r}}if(e.min<o&&e.max>=o){let r;for(const n of t.reverse())if(n.max<e.min){r=n.max;break}if(!r)throw new Error("Error setting new CDS end");return{typeName:"LocationEndChange",changedId:n._id,featureId:n._id,oldLocation:n.max,newLocation:r}}throw new Error("Unexpected relationship between exon and CDS")}}(c);e&&("DeleteFeatureChange"===e.typeName?(s.changedIds.push(...e.changedIds),s.changes.push(...e.changes)):i.push(e));const t=g(c);if(t){i.push(t);const e=c.parent?.parent;if(e?.children)if("LocationStartChange"===t.typeName){let n=t.newLocation;for(const[,r]of e.children)r._id!=t.featureId&&r.min<n&&(n=r.min);n!=e.min&&i.push({typeName:t.typeName,changedId:e._id,featureId:e._id,oldLocation:e.min,newLocation:n})}else{let n=t.newLocation;for(const[,r]of e.children)r._id!=t.featureId&&r.max>n&&(n=r.max);n!=e.max&&i.push({typeName:t.typeName,changedId:e._id,featureId:e._id,oldLocation:e.max,newLocation:n})}}}const u=function(e,t){if(0===e.length)return;const n=new Et({typeName:"LocationStartChange",changedIds:[],changes:[],assembly:t}),r=new Tt({typeName:"LocationEndChange",changedIds:[],changes:[],assembly:t});for(const t of e)"LocationStartChange"===t.typeName&&(n.changedIds.push(t.changedId),n.changes.push({featureId:t.featureId,oldStart:t.oldLocation,newStart:t.newLocation})),"LocationEndChange"===t.typeName&&(r.changedIds.push(t.changedId),r.changes.push({featureId:t.featureId,oldEnd:t.oldLocation,newEnd:t.newLocation}));if(n.changedIds.length>0&&0===r.changedIds.length)return n;if(r.changedIds.length>0&&0===n.changedIds.length)return r;throw new Error("Unexpected list of changes")}(i,a);await e.submit(s),u&&await e.submit(u),t(),r.preventDefault()}(r)},children:[i.jsx(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:i.jsx(s.DialogContentText,{children:"Are you sure you want to delete the selected feature?"})}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{variant:"contained",type:"submit",children:"Yes"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:t,children:"Cancel"})]})]}),d?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:d})}):null]})}function Ws(e,t){if(e.apolloDragging)return;e.setSelectedFeature(t);const{session:n}=e,{apolloDataStore:r}=n,{featureTypeOntology:o}=r.ontologyManager;if(!o)throw new Error("featureTypeOntology is undefined");let i=!1;for(const[,e]of t.children??[])if(o.isTypeOf(e.type,"CDS")||o.isTypeOf(e.type,"exon")){i=!0;break}(o.isTypeOf(t.type,"transcript")||o.isTypeOf(t.type,"pseudogenic_transcript"))&&i?e.showFeatureDetailsWidget(t,["ApolloTranscriptDetails","apolloTranscriptDetails"]):e.showFeatureDetailsWidget(t)}function Js(e,t){const{featureTypeOntology:n}=t.apolloDataStore.ontologyManager;if(!n)throw new Error("featureTypeOntology is undefined");return n.isTypeOf(e.type,"gene")||n.isTypeOf(e.type,"pseudogene")}function Ks(e,t){const{featureTypeOntology:n}=t.apolloDataStore.ontologyManager;if(!n)throw new Error("featureTypeOntology is undefined");return n.isTypeOf(e.type,"transcript")||n.isTypeOf(e.type,"pseudogenic_transcript")}function Ys(e,t){const{featureTypeOntology:n}=t.apolloDataStore.ontologyManager;if(!n)throw new Error("featureTypeOntology is undefined");return n.isTypeOf(e.type,"exon")}function Xs(e,t){const{featureTypeOntology:n}=t.apolloDataStore.ontologyManager;if(!n)throw new Error("featureTypeOntology is undefined");return n.isTypeOf(e.type,"CDS")}function Zs(e,t){const{featureTypeOntology:n}=t.apolloDataStore.ontologyManager;if(!n)throw new Error("featureTypeOntology is undefined");const r=e.children;if(!r?.size)return!1;if(!Js(e,t))return!1;for(const[,e]of r)if(Ks(e,t)){const{children:n}=e;return!!n?.size&&[...n.values()].some((e=>Ys(e,t)))}return!1}function Qs(e,t){if(!e.parent)return{upstream:void 0,downstream:void 0};const n=e.parent;if(!n.children)throw new Error(`Error getting children of ${n._id}`);const{featureTypeOntology:r}=t.session.apolloDataStore.ontologyManager;if(!r)throw new Error("featureTypeOntology is undefined");let o=[];for(const[,e]of n.children)r.isTypeOf(e.type,"exon")&&o.push(e);const i={upstream:void 0,downstream:void 0};o=o.sort(((e,t)=>e.min<t.min?-1:1));for(const t of o)if(t.min>e.max){i.downstream=t;break}o=o.sort(((e,t)=>e.min>t.min?-1:1));for(const t of o)if(t.max<e.min){i.upstream=t;break}if(-1===n.strand){const e=i.downstream;i.downstream=i.upstream,i.upstream=e}return i}function el(e,t,n){let r=Ta;return-1===e&&(r=Ra),t&&(r=r===Ra?Ta:Ra),n&&(r=r===Ra?Ta:Ra),r}function tl(e,t,n,r){const o=r.bpToPx({refName:t,coord:e.min,regionNumber:n}),i=r.bpToPx({refName:t,coord:e.max,regionNumber:n});if(void 0===o||void 0===i)return;const{offsetPx:a}=r;return[o.offsetPx-a,i.offsetPx-a]}function nl(e,t,n){const[r,o]=n;if(!(Math.abs(o-r)<8))return Math.abs(r-t)<4?{feature:e,edge:"min"}:Math.abs(o-t)<4?{feature:e,edge:"max"}:void 0}function rl(e,t){return e._id===t?._id}function ol(e){let t;t=e.attributes.get("gff_name")?e.attributes.get("gff_name")?.join(","):e.attributes.get("gff_id")?e.attributes.get("gff_id")?.join(","):e._id;const n=`(${(e.min+1).toLocaleString("en")}..${e.max.toLocaleString("en")})`;if(t&&t.length+n.length>65){const e=60-n.length;t=e>0?t.slice(0,e):"",t=`${t}[...]`}return`${t} ${n}`}function il(e,t){const{apolloInternetAccount:n,changeManager:r,regions:i,selectedFeature:a,session:s}=e,l=[],c=n?n.role:"admin",u=!(c&&["admin","user"].includes(c)),[d]=i,f=e.getAssemblyId(d.assemblyName),h=e.getAssemblyId(d.assemblyName);return l.push({label:ol(t),type:"subHeader"},{label:"Add child feature",disabled:u,onClick:()=>{s.queueDialog((e=>[Us,{session:s,handleClose:()=>{e()},changeManager:r,sourceFeature:t,sourceAssemblyId:f,internetAccount:n}]))}},{label:"Copy features and annotations",disabled:u,onClick:()=>{s.queueDialog((e=>[Gs,{session:s,handleClose:()=>{e()},changeManager:r,sourceFeature:t,sourceAssemblyId:h}]))}},{label:"Delete feature",disabled:u,onClick:()=>{s.queueDialog((n=>[Vs,{session:s,handleClose:()=>{n()},changeManager:r,sourceFeature:t,sourceAssemblyId:h,selectedFeature:a,setSelectedFeature:t=>{e.setSelectedFeature(t)}}]))}},{label:"Color feature",disabled:u,onClick:()=>{s.queueDialog((e=>[$s,{session:s,handleClose:()=>{e()},changeManager:r,sourceFeature:t,sourceAssemblyId:h}]))}}),o.isSessionModelWithWidgets(s)&&l.push({label:"Open feature details",onClick:()=>{const e=s.addWidget("ApolloFeatureDetailsWidget","apolloFeatureDetailsWidget",{feature:t,assembly:h,refName:d.refName});s.showWidget(e)}}),l}function al(e,t,n){const r=(e.max-e.min)*t,o=Math.max(e.min-r,1),i=Math.min(e.max+r,n);return{refName:e.refSeq,start:o,end:i}}function sl(e,t,n){const r=[{featureId:e._id,oldLocation:e[n],newLocation:t}],{parent:o}=e;return o&&("min"===n&&o[n]>t||"max"===n&&o[n]<t)&&r.push(...sl(o,t,n)),r}function ll(e,t,n,r,o){const i=e._id,a=[{featureId:i,oldLocation:e[n],newLocation:t}],{parent:s,children:l}=e;if(l)for(const[,e]of l)e._id!==o&&("min"===n&&e[n]<t||"max"===n&&e[n]>t)&&a.push(...ll(e,t,n,r));if(s&&r){const e=[];if(s.children)for(const[,t]of s.children)t._id!==i&&e.push(t);if(0===e.length)a.push(...ll(s,t,n,r,i));else{const o=s[n],l=Math[n](...e.map((e=>e[n])),t);l!==o&&a.push(...ll(s,l,n,r,i))}}return a}function cl(e,t,n,r=!1){const o=e[n];if(t===o)throw new Error(`New and existing locations are the same: "${t}"`);return"min"===n?t>o?ll(e,t,n,r):sl(e,t,n):t<o?ll(e,t,n,r):sl(e,t,n)}function ul(e){return"feature"in e}async function dl(e,t){let n;try{n=await e.text()}catch{n=""}return`${t?`${t} — `:""}${e.status} ${e.statusText}${n?` (${n})`:""}`}var fl;!function(e){e.GFF3="text/x-gff3",e.FASTA="text/x-fasta",e.BGZIP_FASTA="application/x-bgzip-fasta",e.FAI="text/x-fai",e.GZI="application/x-gzi",e.EXTERNAL="text/x-external"}(fl||(fl={}));const hl=ma()((e=>({accordion:{border:`1px solid ${e.palette.divider}`,"&:not(:last-child)":{borderBottom:0}},accordionSummary:{flexDirection:"row-reverse"},accordionDetails:{padding:e.spacing(2),borderTop:"1px solid rgba(0, 0, 0, .125)"},radioIcon:{color:e.palette.tertiary.contrastText},dialog:{minWidth:550,maxWidth:800}})));function pl(e,t,n,r,o,i,a,s,l){return!(!e||!(t&&r||n===fl.GFF3&&r||r&&o&&i||a&&s&&l))}function gl({changeManager:e,handleClose:t,session:r}){const{classes:o}=hl(),{internetAccounts:a}=l.getRoot(r),{notify:c}=r,d=a.filter((e=>"ApolloInternetAccount"===e.type));if(0===d.length)throw new Error("No Apollo internet account found");const[f,h]=u.useState(""),[p,g]=u.useState(""),[m,y]=u.useState(!1),[_,v]=u.useState(fl.BGZIP_FASTA),[b,x]=u.useState(!0),[w,S]=u.useState(!1),[C,A]=u.useState(!1),[k,N]=u.useState(!0),[T,R]=u.useState(null),[E,I]=u.useState(null),[j,D]=u.useState(null),[O,F]=u.useState(""),[M,L]=u.useState(""),[P,B]=u.useState(""),[q,U]=u.useState(!1),[z,$]=u.useState(!1),[H,G]=u.useState(!1);async function V(e,t){const{jobsManager:n}=r,o=new AbortController,[{baseURL:i,getFetcher:a}]=d,s=new URL("files",i);s.searchParams.set("type",t);const l=s.href,c=new FormData;let u=e.name;const h=t===fl.BGZIP_FASTA||t===fl.FASTA&&(!w||z)||t===fl.GFF3&&H;h&&!e.name.toLocaleLowerCase().endsWith(".gz")?u=`${u}.gz`:!h&&e.name.toLocaleLowerCase().endsWith(".gz")&&(u=`${u}.txt`),c.append("file",e,u),c.append("type",t);const p=a({locationType:"UriLocation",uri:l}),m={name:`UploadAssemblyFile for ${f}`,statusMessage:"Pre-validating",progressPct:0,cancelCallback:()=>{o.abort(new DOMException(`Canceling adding of assembly "${f}"`,"AbortError")),n.abortJob(m.name)}};n.runJob(m),n.update(m.name,`Uploading ${e.name}, this may take awhile`);const{signal:y}=o,_=await p(l,{method:"POST",body:c,signal:y});if(!_.ok){const e=await dl(_,"Error when inserting new assembly (while uploading file)");return n.abortJob(m.name,e),g(e),""}const v=(await _.json())._id;return n.done(m),v}let W=!1;try{const e=new URL(O);"http:"!==e.protocol&&"https:"!==e.protocol||(W=!0)}catch{}let J=!1;try{const e=new URL(M);"http:"!==e.protocol&&"https:"!==e.protocol||(J=!0)}catch{}let K=!1;try{const e=new URL(P);"http:"!==e.protocol&&"https:"!==e.protocol||(K=!0)}catch{}const[Y,X]=u.useState("panelFastaInput"),Z=e=>(t,n)=>{n&&X(e)};return i.jsxs(Bs,{open:!0,handleClose:t,"data-testid":"add-assembly-dialog",title:"Add new assembly",maxWidth:!1,children:[i.jsxs("form",{onSubmit:async function(n){let r;if(n.preventDefault(),g(""),A(!0),U(!0),c(`Assembly "${f}" is being added`,"info"),t(),n.preventDefault(),_===fl.EXTERNAL)r=new yt({typeName:"AddAssemblyFromExternalChange",assembly:(new at).toHexString(),assemblyName:f,externalLocation:{fa:O,fai:M,gzi:P}});else{if(!T)throw new Error("Missing fasta file");if(_===fl.GFF3&&b){const e=await V(T,fl.GFF3);r=new mt({typeName:"AddAssemblyAndFeaturesFromFileChange",assembly:(new at).toHexString(),assemblyName:f,fileIds:{fa:e},parseOptions:{strict:k}})}else if(_===fl.GFF3){const e=await V(T,fl.GFF3);r=new _t({typeName:"AddAssemblyFromFileChange",assembly:(new at).toHexString(),assemblyName:f,fileIds:{fa:e}})}else if(w){const e=await V(T,fl.FASTA);r=new _t({typeName:"AddAssemblyFromFileChange",assembly:(new at).toHexString(),assemblyName:f,fileIds:{fa:e}})}else{if(!E||!j)throw new Error("Missing fasta index files");const e=await V(T,fl.BGZIP_FASTA),t=await V(E,fl.FAI),n=await V(j,fl.GZI);r=new _t({typeName:"AddAssemblyFromFileChange",assembly:(new at).toHexString(),assemblyName:f,fileIds:{fa:e,fai:t,gzi:n}})}}const[{internetAccountId:o}]=d;await e.submit(r,{internetAccountId:o,updateJobsManager:!0}),A(!1),U(!1)},"data-testid":"submit-form",children:[i.jsxs(s.DialogContent,{className:o.dialog,children:[q?i.jsx(s.LinearProgress,{}):null,i.jsx(s.TextField,{margin:"dense",id:"name",label:"Assembly name",type:"TextField",fullWidth:!0,variant:"outlined",onChange:e=>{A(!1),h(e.target.value),function(e){const{assemblies:t}=r;t.find((t=>n.readConfObject(t,"displayName")===e))?(y(!1),g(`Assembly ${e} already exists.`)):(y(!0),g(""))}(e.target.value)},disabled:C&&!p}),i.jsxs(s.Accordion,{disableGutters:!0,elevation:0,square:!0,className:o.accordion,expanded:"panelFastaInput"===Y,onChange:Z("panelFastaInput"),children:[i.jsx(s.AccordionSummary,{className:o.accordionSummary,expandIcon:"panelFastaInput"===Y?i.jsx(va,{className:o.radioIcon,sx:{fontSize:"1.2rem",ml:5}}):i.jsx(ba,{className:o.radioIcon,sx:{fontSize:"1.2rem",mr:5}}),"aria-controls":"panelFastaInputd-content",id:"panelFastaInputd-header",children:i.jsx(s.Typography,{component:"span",children:"FASTA input"})}),i.jsx(s.AccordionDetails,{className:o.accordionDetails,children:i.jsxs(s.FormGroup,{children:[i.jsx(s.FormControlLabel,{"data-testid":"files-on-url-checkbox",control:i.jsx(s.Checkbox,{onChange:()=>{v(_===fl.EXTERNAL?fl.BGZIP_FASTA:fl.EXTERNAL),_===fl.EXTERNAL&&S(!1)},checked:_===fl.EXTERNAL,disabled:w&&_!==fl.GFF3}),label:i.jsxs(s.Box,{display:"flex",alignItems:"center",children:["Use external URLs",i.jsx(s.Tooltip,{title:"Use external URLs to provide FASTA and index files. Does not copy the files to the Apollo collaboration server, so ensure the URLs are stable.",placement:"top-start",children:i.jsx(s.IconButton,{size:"small",children:i.jsx(ya,{sx:{fontSize:18}})})})]})}),i.jsx(s.FormControlLabel,{"data-testid":"sequence-is-editable-checkbox",control:i.jsx(s.Checkbox,{onChange:()=>{S(!w)}}),checked:w,disabled:_===fl.EXTERNAL,label:i.jsxs(s.Box,{display:"flex",alignItems:"center",children:["Store sequence in database",i.jsx(s.Tooltip,{title:"Enables users to edit the genomic sequence, but comes with performance impacts. Use with care.",placement:"top-start",children:i.jsx(s.IconButton,{size:"small",children:i.jsx(ya,{sx:{fontSize:18}})})})]})}),i.jsx(s.FormControlLabel,{"data-testid":"fasta-is-gzip-checkbox",control:i.jsx(s.Checkbox,{checked:!w||z,onChange:()=>{$(!w||!z)},disabled:!w}),label:"FASTA is gzip compressed"}),i.jsx(s.Table,_===fl.BGZIP_FASTA||_===fl.GFF3?{size:"small",sx:{mt:2},children:i.jsxs(s.TableBody,{children:[i.jsxs(s.TableRow,{children:[i.jsx(s.TableCell,{style:{borderBottomWidth:0},children:i.jsxs(s.Box,{display:"flex",alignItems:"center",children:[i.jsx("span",{children:"FASTA"}),i.jsx(s.Tooltip,{title:'Unless "Store sequence in database" enabled, FASTA input must be compressed with bgzip and indexed with samtools faidx (or equivalent). Compression is optional for sequences stored in the database.',children:i.jsx(s.IconButton,{size:"small",children:i.jsx(ya,{sx:{fontSize:18}})})})]})}),i.jsx(s.TableCell,{style:{borderBottomWidth:0},children:i.jsx("input",{"data-testid":"fasta-input-file",type:"file",onChange:e=>{const t=e.target.files?.item(0);t&&(R(t),t.name.endsWith(".gz")&&$(!0))},disabled:C&&!p})})]}),i.jsxs(s.TableRow,{children:[i.jsx(s.TableCell,{style:{borderBottomWidth:0},children:"FASTA index (.fai)"}),i.jsx(s.TableCell,{style:{borderBottomWidth:0},children:i.jsx("input",{"data-testid":"fai-input-file",type:"file",onChange:e=>{I(e.target.files?.item(0)??null)},disabled:C&&!p||w})})]}),i.jsxs(s.TableRow,{children:[i.jsx(s.TableCell,{style:{borderBottomWidth:0},children:"FASTA binary index (.gzi)"}),i.jsx(s.TableCell,{style:{borderBottomWidth:0},children:i.jsx("input",{"data-testid":"gzi-input-file",type:"file",onChange:e=>{D(e.target.files?.item(0)??null)},disabled:C&&!p||w})})]})]})}:{size:"small",sx:{mt:2},children:i.jsxs(s.TableBody,{children:[i.jsxs(s.TableRow,{children:[i.jsx(s.TableCell,{style:{borderBottomWidth:0},children:i.jsxs(s.Box,{display:"flex",alignItems:"center",children:[i.jsx("span",{children:"FASTA"}),i.jsx(s.Tooltip,{title:"Remote FASTA input must be compressed with bgzip and indexed with samtools faidx (or equivalent)",children:i.jsx(s.IconButton,{size:"small",children:i.jsx(ya,{sx:{fontSize:18}})})})]})}),i.jsx(s.TableCell,{style:{borderBottomWidth:0},children:i.jsx(s.TextField,{"data-testid":"fasta-input-url",variant:"outlined",value:O,error:!W,onChange:e=>{const{value:t}=e.target;F(t),L(t?`${t}.fai`:""),B(t?`${t}.gzi`:"")},disabled:C&&!p,slotProps:{input:{startAdornment:i.jsx(s.InputAdornment,{position:"start",children:i.jsx(_a,{})})}}})})]}),i.jsxs(s.TableRow,{children:[i.jsx(s.TableCell,{style:{borderBottomWidth:0},children:"FASTA index (.fai)"}),i.jsx(s.TableCell,{style:{borderBottomWidth:0},children:i.jsx(s.TextField,{"data-testid":"fai-input-url",variant:"outlined",value:M,error:!J,onChange:e=>{L(e.target.value)},disabled:C&&!p,slotProps:{input:{startAdornment:i.jsx(s.InputAdornment,{position:"start",children:i.jsx(_a,{})})}}})})]}),i.jsxs(s.TableRow,{children:[i.jsx(s.TableCell,{style:{borderBottomWidth:0},children:"FASTA binary index (.gzi)"}),i.jsx(s.TableCell,{style:{borderBottomWidth:0},children:i.jsx(s.TextField,{"data-testid":"gzi-input-url",variant:"outlined",value:P,error:!K,onChange:e=>{B(e.target.value)},disabled:C&&!p,slotProps:{input:{startAdornment:i.jsx(s.InputAdornment,{position:"start",children:i.jsx(_a,{})})}}})})]})]})})]})})]}),i.jsxs(s.Accordion,{disableGutters:!0,elevation:0,square:!0,className:o.accordion,expanded:"panelGffInput"===Y,onChange:Z("panelGffInput"),children:[i.jsx(s.AccordionSummary,{className:o.accordionSummary,expandIcon:"panelGffInput"===Y?i.jsx(va,{className:o.radioIcon,sx:{fontSize:"1.2rem",ml:5}}):i.jsx(ba,{className:o.radioIcon,sx:{fontSize:"1.2rem",mr:5}}),"aria-controls":"panelGffInputd-content",children:i.jsxs(s.Typography,{component:"span",children:["GFF3 input",i.jsx(s.Tooltip,{title:"GFF3 must includes FASTA sequences. File can be gzip compressed.",children:i.jsx(ya,{className:o.radioIcon,sx:{fontSize:18}})})]})}),i.jsx(s.AccordionDetails,{className:o.accordionDetails,children:i.jsxs(s.Box,{style:{marginTop:20},children:[i.jsx("input",{"data-testid":"gff3-input-file",type:"file",disabled:C&&!p,onChange:e=>{const t=e.target.files?.item(0);t&&(R(t),v(fl.GFF3),t.name.endsWith(".gz")&&G(!0))}}),i.jsxs(s.FormGroup,{style:{display:"grid"},children:[i.jsx(s.FormControlLabel,{control:i.jsx(s.Checkbox,{checked:b,onChange:()=>{x(!b)},disabled:C&&!p}),label:"Load features from GFF3 file"}),i.jsx(s.FormControlLabel,{label:"Strict parsing",disabled:!b||C&&!p,control:i.jsx(s.Checkbox,{checked:k,onChange:e=>{N(e.target.checked)}})}),i.jsx(s.FormHelperText,{children:"Don't import any features if any lines in the GFF3 are unable to be processed"}),i.jsx(s.FormControlLabel,{"data-testid":"gff3-is-gzip-checkbox",control:i.jsx(s.Checkbox,{checked:H,onChange:()=>{G(!H)},disabled:C&&!p}),label:"GFF3 is gzip compressed"})]})]})})]})]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{disabled:!pl(m,w,_,T,E,j,W,J,K)||C,variant:"contained",type:"submit","data-testid":"submit-button",children:C?"Submitting...":"Submit"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:t,children:"Cancel"})]})]}),p?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:p})}):null]})}const ml=[{field:"name",headerName:"Assembly Name",width:150,editable:!1},{field:"aliases",headerName:"Aliases",width:300,editable:!0}];function yl({changeManager:e,handleClose:t,session:n}){const{apolloDataStore:r}=n,{collaborationServerDriver:o}=r,a=o.getAssemblies().map((e=>({id:e.name,name:e.displayName,aliases:e.aliases.join(", ")}))),[l,c]=u.useState("");return i.jsxs(Bs,{open:!0,title:"Add assembly aliases",handleClose:t,maxWidth:"sm","data-testid":"add-assembly-alias",fullWidth:!0,children:[i.jsx(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:i.jsx(s.Box,{sx:{height:400,width:"100%"},children:i.jsx(m.DataGrid,{rows:a,columns:ml,initialState:{pagination:{paginationModel:{pageSize:5}}},pageSizeOptions:[5],processRowUpdate:(n,r)=>{const o=new gt({typeName:"AddAssemblyAliasesChange",assembly:n.id,aliases:n.aliases.split(",")});return e.submit(o).catch((()=>{c("Error submitting change")})),t(),n},disableRowSelectionOnClick:!0})})}),l?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:l})}):null]})}const _l=new Set(["TAA","TAG","TGA"]);function vl(e,t,n){let r=0;for(const o of t){const t=o.max-o.min;if(e<=r+t){const t=e-r;return 1===n?o.min+t:o.max-t}r+=t}const o=t.at(-1);if(!o)throw new Error("No exons found");return 1===n?o.max:o.min}function bl({changeManager:e,handleClose:t,refName:n,session:r,sourceAssemblyId:a,sourceFeature:l}){const[c,d]=u.useState("longest-orf"),[f,h]=u.useState(""),[p,g]=u.useState(""),[m,y]=u.useState(""),_="manual"===c&&Boolean(f)&&Boolean(p)&&Number(p)<=Number(f),v="manual"===c&&(!(f&&p)||_);return i.jsxs(Bs,{open:!0,title:"Add coding sequence",handleClose:t,maxWidth:!1,"data-testid":"add-coding-sequence",children:[i.jsxs("form",{onSubmit:i=>{!async function(i){let s,u;i.preventDefault(),y("");try{if("longest-orf"===c){const e=l.transcriptExonParts.filter((e=>"exon"===e.type));if(0===e.length)return void y("No exons found in this transcript");const i=r.apolloDataStore.getBackendDriver(a);if(!i)return void y("No backend driver found for this assembly");let c="";for(const t of e){const{seq:e}=await i.getSequence({assemblyName:a,refName:n,start:t.min,end:t.max});c+=-1===l.strand?o.revcom(e):e}const d=function(e){const t=[null,null,null];let n;for(let r=0;r<e.length-2;r++){const o=e.slice(r,r+3).toUpperCase(),i=r%3;if("ATG"===o&&null===t[i])t[i]=r;else if(_l.has(o)){const e=t[i];if(null===e)continue;(!n||n[1]-n[0]<r-e)&&(n=[e,r]),t[i]=null}}return n}(c);if(!d)return r.notify("No open reading frame found in this transcript","error"),void t();1===(l.strand??1)?(s=vl(d[0],e,1),u=vl(d[1]+3,e,1)):(u=vl(d[0],e,-1),s=vl(d[1]+3,e,-1))}else s=Number(f)-1,u=Number(p);const i=(new at).toHexString(),d={_id:i,refSeq:l.refSeq,min:s,max:u,type:"CDS"};l.strand&&(d.strand=l.strand);const h=new ht({changedIds:[l._id],typeName:"AddFeatureChange",assembly:a,addedFeature:d,parentFeatureId:l._id});await e.submit(h),r.apolloSetSelectedFeature(i),t()}catch(e){y(e instanceof Error?e.message:"An unknown error occurred")}}(i)},children:[i.jsxs(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:[i.jsx(s.FormControl,{children:i.jsxs(s.RadioGroup,{value:c,onChange:e=>{d(e.target.value)},children:[i.jsx(s.FormControlLabel,{value:"longest-orf",control:i.jsx(s.Radio,{}),label:"Calculate longest open reading frame"}),i.jsx(s.FormControlLabel,{value:"manual",control:i.jsx(s.Radio,{}),label:"Manual"})]})}),"manual"===c?i.jsxs(i.Fragment,{children:[i.jsx(s.TextField,{margin:"dense",id:"cds-min",label:"Min",type:"number",fullWidth:!0,variant:"outlined",value:f,onChange:e=>{h(e.target.value)}}),i.jsx(s.TextField,{margin:"dense",id:"cds-max",label:"Max",type:"number",fullWidth:!0,variant:"outlined",value:p,onChange:e=>{g(e.target.value)},error:_,helperText:_?'"Max" must be greater than "Min"':null})]}):null]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{variant:"contained",type:"submit",disabled:v,children:"Submit"}),i.jsx(s.Button,{variant:"outlined",type:"button",onClick:t,children:"Cancel"})]})]}),m?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:m})}):null]})}class xl{clientStore;constructor(e){this.clientStore=e}}async function wl(e,t){return qa(`Apollo-${e}`,1,{upgrade(e){const n="changes";e.objectStoreNames.contains(n)||e.createObjectStore(n,{autoIncrement:!0});for(const n of t){const t=`features-${n}`;if(!e.objectStoreNames.contains(t)){const n=e.createObjectStore(t);n.createIndex("min","min",{unique:!1}),n.createIndex("max","max",{unique:!1})}const r=`checkresults-${n}`;if(!e.objectStoreNames.contains(r)){const t=e.createObjectStore(r,{keyPath:"_id"});t.createIndex("min","start",{unique:!1}),t.createIndex("max","end",{unique:!1}),t.createIndex("featureId","featureId",{unique:!1})}}}})}class Sl extends xl{async getFeatures(e){const{assemblyName:t,end:n,refName:r,start:o}=e,i=(await this.getRegions(t)).map((e=>e.refName)),a=`features-${r}`,s=`checkresults-${r}`,l=[],c=[],u=(await wl(t,i)).transaction([a,s]);for await(const e of u.objectStore(a).index("min").iterate(IDBKeyRange.upperBound(n,!0)))e.value.max>o&&l.push(e.value);for await(const e of u.objectStore(s).index("min").iterate(IDBKeyRange.upperBound(n,!0)))e.value.end>o&&c.push(e.value);return[l,c]}async getSequence(e){const t=o.getSession(this.clientStore),{assemblyManager:n}=t,r=await n.waitForAssembly(e.assemblyName);if(!r)throw new Error(`Assembly not found: "${e.assemblyName}"`);const{configuration:i}=r,{adapter:a}=i.sequence,{pluginManager:s}=o.getEnv(this.clientStore),l=s.getAdapterType(a.type);if(!l)throw new Error(`No adapter found for "${a.type}"`);const c=new(await l.getAdapterClass())(a,void 0,s),u=await c.getSequence({...e,refName:r.getSeqAdapterRefName(e.refName)});if(!u)throw new Error(`Sequence not found: ${JSON.stringify(e)}`);return{seq:u,refSeq:e.refName}}async getRegions(e){const t=o.getSession(this.clientStore),{assemblyManager:n}=t,r=await n.waitForAssembly(e);if(!r)throw new Error(`Assembly not found: "${e}"`);const{regions:i}=r;if(!i)throw new Error(`Assembly not found: "${e}"`);return i}getAssemblies(e){return[]}async getRefNameAliases(e){const t=o.getSession(this.clientStore),{assemblyManager:n}=t,r=await n.waitForAssembly(e);if(!r)throw new Error(`Assembly not found: "${e}"`);const{configuration:i}=r,{refNameAliases:a}=i;if(!a)return[];const{pluginManager:s}=o.getEnv(this.clientStore),l=s.getAdapterType(a.adapter.type);if(!l)throw new Error(`No adapter found for "${a.adapter.type}"`);return new(await l.getAdapterClass())(a.adapter,void 0,s).getRefNameAliases({})}async submitChange(e,t){if(!st(e))return new Wt;const{assembly:n,changedIds:r}=e,o=(await this.getRegions(n)).map((e=>e.refName)),i=await wl(n,o),a=new Set,s=[],c=new Set;if(function(e){return"DeleteFeatureChange"===e.typeName}(e))for(const t of e.changes)if(t.parentFeatureId){const e=this.clientStore.getFeature(t.parentFeatureId);e&&(a.add(e.topLevelFeature),c.add(e.topLevelFeature.refSeq))}else{const{refSeq:e,_id:n}=t.deletedFeature;s.push({refSeq:e,featureId:n}),c.add(e)}else for(const e of r){const t=this.clientStore.getFeature(e);t&&(a.add(t.topLevelFeature),c.add(t.refSeq))}const u=[...c].flatMap((e=>[`features-${e}`,`checkresults-${e}`]));u.push("changes");const d=i.transaction(u,"readwrite");for(const{refSeq:e,featureId:t}of s)d.objectStore(`features-${e}`).delete(t);for(const e of a){const t=l.getSnapshot(e);d.objectStore(`features-${e.refSeq}`).put(t,e._id)}for(const{featureId:e,refSeq:t}of s){const n=d.objectStore(`checkresults-${t}`);for await(const t of n.index("featureId").iterate(e))this.clientStore.deleteCheckResult(t.value._id),t.delete()}for(const e of a){const t=d.objectStore(`checkresults-${e.refSeq}`);for await(const n of t.index("featureId").iterate(e._id))this.clientStore.deleteCheckResult(n.value._id),n.delete()}if(d.objectStore("changes").put({...e.toJSON(),createdAt:new Date}),await d.done,a.size>0){const e=[...ne.getChecks().values()],t=[];for(const r of a){const o=l.getSnapshot(r),i=async(e,t)=>(await this.getSequence({assemblyName:n,refName:r.refSeq,start:e,end:t})).seq;for(const n of e){const e=await n.checkFeature(o,i);for(const n of e)t.push({refSeq:r.refSeq,result:n,topLevelFeatureId:r._id})}}if(t.length>0){const e=o.map((e=>`checkresults-${e}`)),n=i.transaction(e,"readwrite");for(const{refSeq:e,result:r,topLevelFeatureId:o}of t)n.objectStore(`checkresults-${e}`).put({...r,featureId:o});await n.done;for(const{result:e}of t)this.clientStore.addCheckResult(e)}}return new Wt}async searchFeatures(e,t){return[]}async getCheckResults(e){const t=(await this.getRegions(e)).map((e=>e.refName)),n=await wl(e,t),r=[],o=t.map((e=>`checkresults-${e}`)),i=n.transaction(o);for(const e of o)for await(const t of i.objectStore(e).iterate())r.push(t.value);return r}async getChanges(e,t={}){const n=(await this.getRegions(e)).map((e=>e.refName)),r=await wl(e,n);let o=[];for await(const e of r.transaction("changes").store.iterate())o.push({sequence:e.key,...e.value});const{filters:i}=t;if(i?.user){const e=new RegExp(i.user,"i");o=o.filter((t=>void 0!==t.user&&e.test(t.user)))}if(i?.typeName&&(o=o.filter((e=>e.typeName===i.typeName))),i?.startTime){const e=new Date(i.startTime).getTime();o=o.filter((t=>new Date(t.createdAt).getTime()>=e))}if(i?.endTime){const e=new Date(i.endTime).getTime();o=o.filter((t=>new Date(t.createdAt).getTime()<=e))}const a=o.length,s=t.sortField??"sequence",l="asc"===(t.sortOrder??"desc")?1:-1;if(o.sort(((e,t)=>{const n=e[s],r=t[s];return n===r?0:void 0===n?1:void 0===r?-1:n<r?-l:l})),void 0!==t.page&&void 0!==t.pageSize){const e=t.page*t.pageSize;o=o.slice(e,e+t.pageSize)}return{changes:o,totalCount:a}}}const Cl={async AddFeatureChange(e,t){const{assembly:n,changes:r}=t;for(const t of r){const{addedFeature:r,parentFeatureId:o}=t;if(o){let t=e.getFeature(o);if(!t&&(await e.loadFeatures([{assemblyName:n,refName:r.refSeq,start:r.min,end:r.max}]),t=e.getFeature(o),!t))throw new Error(`Could not find parent feature "${o}"`);t.attributes.get("_id")||t.setAttribute("_id",[t._id]),t.addChild(r)}else e.addFeature(n,r)}},async DeleteFeatureChange(e,t){for(const n of t.changes){const{deletedFeature:t,parentFeatureId:r}=n;if(r){const n=e.getFeature(r);if(!n)throw new Error(`Could not find parent feature "${r}"`);n.deleteChild(t._id)}else e.getFeature(t._id)&&e.deleteFeature(t._id)}},async FeatureAttributeChange(e,t){for(const[n,r]of t.changedIds.entries()){const o=e.getFeature(r);if(!o)throw new Error(`Could not find feature with identifier "${r}"`);o.setAttributes(new Map(Object.entries(t.changes[n].newAttributes)))}},async LocationEndChange(e,t){for(const n of t.changes){const{featureId:t,newEnd:r}=n,o=e.getFeature(t);if(!o)throw new Error(`Could not find feature with identifier "${t}"`);o.setMax(r)}},async LocationStartChange(e,t){for(const n of t.changes){const{featureId:t,newStart:r}=n,o=e.getFeature(t);if(!o)throw new Error(`Could not find feature with identifier "${t}"`);o.setMin(r)}},async MergeExonsChange(e,t){for(const n of t.changes){const{firstExon:t,secondExon:r}=n,o=e.getFeature(t._id);if(!o)throw new Error(`Could not find feature with identifier "${t._id}"`);o.setMin(Math.min(t.min,r.min)),o.setMax(Math.max(t.max,r.max));const i=o.attributes.get("merged_with")?.slice()??[],a=Lt(Mt(r.attributes));i.includes(a)||i.push(a),o.setAttribute("merged_with",i),o.parent?.deleteChild(r._id)}},async SplitExonChange(e,t){for(const[n]of t.changedIds.entries()){const{exonToBeSplit:r,parentFeatureId:o,upstreamCut:i,downstreamCut:a,leftExonId:s,rightExonId:l}=t.changes[n];if(!o)throw new Error("TODO: Split exon without parent");const[c,u]=t.makeSplitExons(r,i,a,s,l),d=e.getFeature(o);if(!d)throw new Error(`Could not find parent feature "${o}"`);d.addChild(c),d.addChild(u),e.getFeature(r._id)&&e.deleteFeature(r._id)}},async MergeTranscriptsChange(e,t){for(const[n,r]of t.changedIds.entries()){const{firstTranscript:o,secondTranscript:i}=t.changes[n],a=e.getFeature(o._id);if(!a)throw new Error(`Could not find feature with identifier "${r}"`);t.mergeTranscriptsOnClient(a,i),a.parent?.deleteChild(i._id)}},async UndoMergeExonsChange(e,t){for(const n of t.changes){const{exonsToRestore:t,parentFeatureId:r}=n;if(!r)throw new Error("Parent ID is missing");const o=e.getFeature(r);if(!o)throw new Error(`Could not find parent feature "${r}"`);o.attributes.get("_id")||o.setAttribute("_id",[o._id]);for(const e of t)o.addChild(e)}},async UndoSplitExonChange(e,t){for(const n of t.changes){const{exonToRestore:t,parentFeatureId:r,idsToDelete:o}=n;if(!r)throw new Error("Parent ID is missing");const i=e.getFeature(r);if(!i)throw new Error(`Could not find parent feature "${r}"`);i.attributes.get("_id")||i.setAttribute("_id",[i._id]),i.addChild(t),o.map((e=>{i.deleteChild(e)}))}},async UndoMergeTranscriptsChange(e,t){for(const n of t.changes){const{transcriptsToRestore:t,parentFeatureId:r}=n;if(!r)throw new Error("Parent ID is missing");const o=e.getFeature(r);if(!o)throw new Error(`Could not find parent feature "${r}"`);o.attributes.get("_id")||o.setAttribute("_id",[o._id]);for(const e of t)o.addChild(e)}},async StrandChange(e,t){for(const[n,r]of t.changedIds.entries()){const o=e.getFeature(r);if(!o)throw new Error(`Could not find feature with identifier "${r}"`);o.setStrand(t.changes[n].newStrand)}},async TypeChange(e,t){for(const[n,r]of t.changedIds.entries()){const o=e.getFeature(r);if(!o)throw new Error(`Could not find feature with identifier "${r}"`);o.setType(t.changes[n].newType)}}};class Al{dataStore;constructor(e){this.dataStore=e}recentChanges=[];undoneChanges=[];async submit(e,t={}){const{addToRecents:n=!0,submitToBackend:r=!0,updateJobsManager:i=!1}=t,a=o.getSession(this.dataStore),s=new AbortController,{jobsManager:l,isLocked:c,changeInProgress:u,setChangeInProgress:d}=o.getSession(this.dataStore);if(c)return a.notify("Cannot submit changes in locked mode"),void d(!1);if(u)return void a.notify("Could not submit change, there is another change still in progress");d(!0);const f={name:e.typeName,statusMessage:"Pre-validating",progressPct:0,cancelCallback:()=>{s.abort(new DOMException(`Cancelling change "${e.typeName}"`,"AbortError"))}};i&&l.runJob(f);const h=await Kt.frontendPreValidate(e);if(!h.ok){const e=`Pre-validation failed: "${h.resultsMessages}"`;return i&&l.abortJob(f.name,e),a.notify(e,"error"),void d(!1)}const p=e.typeName,g=function(e){return e in Cl}(p)?Cl[p]:void 0;if(g)try{await g(this.dataStore,e)}catch(e){return i&&l.abortJob(f.name,String(e)),console.error(e),a.notify(`Error encountered in client: ${String(e)}. Data may be out of sync, please refresh the page`,"error"),void d(!1)}if((await Kt.frontendPostValidate(e)).ok||await this.undo(e),r){i&&l.update(f.name,"Submitting to driver");const{collaborationServerDriver:r,getBackendDriver:o}=this.dataStore,s=te(e)?o(e.assembly)??r:r;let c;try{c=await s.submitChange(e,t)}catch(t){return i&&l.abortJob(f.name,String(t)),console.error(t),a.notify(String(t),"error"),d(!1),void await this.undo(e,!1)}if(!c.ok){const t=`Post-validation failed: "${h.resultsMessages}"`;return i&&l.abortJob(f.name,t),a.notify(t,"error"),d(!1),void await this.undo(e,!1)}e.notification&&a.notify(e.notification,"success"),n&&(this.recentChanges.push(e),this.undoneChanges=[])}i&&l.done(f),d(!1)}async undo(e,t=!0){const n=e.getInverse();return this.submit(n,{submitToBackend:t,addToRecents:!1})}async redo(e,t=!0){return this.submit(e,{submitToBackend:t,addToRecents:!1})}async undoLastChange(){const e=o.getSession(this.dataStore),t=this.recentChanges.pop();if(t)return this.undoneChanges.push(t),this.undo(t);e.notify("No changes to undo!","info")}async redoLastChange(){const e=o.getSession(this.dataStore),t=this.undoneChanges.pop();if(t)return this.recentChanges.push(t),this.redo(t);e.notify("No changes to redo!","info")}}class kl extends xl{inFlight=new Map;refSeqMaps=new Map;async fetch(e,t,n){return e.getFetcher({locationType:"UriLocation",uri:t.toString()})(t,n)}async searchFeatures(e,t){const n=this.clientStore.getInternetAccount(t[0]),{baseURL:r}=n,o=new URL("features/searchFeatures",r),i=new URLSearchParams({assemblies:t.join(","),term:e});o.search=i.toString();const a=o.toString(),s=await this.fetch(n,a);if(!s.ok){const e=await dl(s,"searchFeatures failed");throw new Error(e)}return s.json()}async getFeatures(e){const{assemblyName:t,end:n,refName:r,start:i}=e,{assemblyManager:a}=o.getSession(this.clientStore);if(!a.get(t))throw new Error(`Could not find assembly with name "${t}"`);const s=(await this.getRefSeqMapping(t)).get(r);if(!s)throw new Error(`Could not find refSeq "${r}"`);const l=s.id,c=this.clientStore.getInternetAccount(t),{baseURL:u}=c,d=new URL("features/getFeatures",u),f=new URLSearchParams({refSeq:l,start:String(i),end:String(n)});d.search=f.toString();const h=d.toString(),p=await this.fetch(c,h);if(!p.ok){const e=await dl(p,"getFeatures failed");throw new Error(e)}return this.checkSocket(t,r,c),p.json()}checkSocket(e,t,n){const{socket:r}=n,o=`${e}-${t}`;r.hasListeners(o)||r.on(o,(async e=>{const t=n.retrieveToken();if(!t)return;const r=sn(t),o=new Al(this.clientStore);if(n.setLastChangeSequenceNumber(e.changeSequence),e.userSessionId===r)return;const i=ee.fromJSON(e.changeInfo);st(i)&&this.haveDataForChange(i)&&await o.submit(i,{submitToBackend:!1})}))}haveDataForChange(e){const{assembly:t,changedIds:n}=e;if(!this.clientStore.assemblies.get(t))return!1;for(const e of n)if(this.clientStore.getFeature(e))return!0;return!1}async getSequence(e){const t=`${e.refName}:${e.start}-${e.end}`,n=this.inFlight.get(t),{assemblyName:r,end:i,refName:a,start:s}=e,{assemblyManager:l}=o.getSession(this.clientStore);if(!l.get(r))throw new Error(`Could not find assembly with name "${r}"`);const c=(await this.getRefSeqMapping(r)).get(a);if(!c)throw new Error(`Could not find refSeq "${a}"`);const u=c.id;if(n)return{seq:await n,refSeq:u};const d=this.clientStore.assemblies.get(r)??this.clientStore.addAssembly(r),f=d.refSeqs.get(u)??d.addRefSeq(u,a),h=f.getSequence(s,i);if(h.length===i-s)return{seq:h,refSeq:u};const p=this.clientStore.getInternetAccount(r),{baseURL:g}=p,m=new URL("sequence",g),y=new URLSearchParams({refSeq:u,start:String(s),end:String(i)});m.search=y.toString();const _=m.toString(),v=this.getSeqFromServer(p,_,f,s,i);this.inFlight.set(t,v);const b=await v;return this.checkSocket(r,a,p),this.inFlight.delete(t),{seq:b,refSeq:u}}async getSeqFromServer(e,t,n,r,o){const i=await this.fetch(e,t);if(!i.ok){let e;try{e=await i.text()}catch{e=""}throw new Error(`getSequence failed: ${i.status} (${i.statusText})${e?` (${e})`:""}`)}const a=await i.text();return n.addSequence({sequence:a,start:r,stop:o}),a}async getRefSeqMapping(e){const t=this.refSeqMaps.get(e);if(t)return t;const{assemblyManager:n}=o.getSession(this.clientStore);if(!n.get(e))throw new Error(`Could not find assembly with name "${e}"`);const r=this.clientStore.getInternetAccount(e),{baseURL:i}=r,a=new URL("refSeqs",i),s=new URLSearchParams({assembly:e});a.search=s.toString();const l=a.toString(),c=await this.fetch(r,l);if(!c.ok){let e;try{e=await c.text()}catch{e=""}throw new Error(`getRefNameAliases failed: ${c.status} (${c.statusText})${e?` (${e})`:""}`)}const u=await c.json(),d=new Map(u.map((e=>[e.name,{refName:e.name,id:e._id,aliases:e.aliases}])));return this.refSeqMaps.set(e,d),d}async getRefNameAliases(e){return[...(await this.getRefSeqMapping(e)).values()].map((e=>({refName:e.refName,aliases:[...new Set([e.id,...e.aliases])],uniqueId:`alias-${e.id}`})))}async getRefSeqId(e,t){const n=await this.getRefSeqMapping(e);if(!n)return;const r=n.get(t);return r?.id}async getRegions(e){const{assemblyManager:t}=o.getSession(this.clientStore);if(!t.get(e))throw new Error(`Could not find assembly with name "${e}"`);const n=this.clientStore.getInternetAccount(e),{baseURL:r}=n,i=new URL("refSeqs",r),a=new URLSearchParams({assembly:e});i.search=a.toString();const s=i.toString(),l=await this.fetch(n,s);if(!l.ok){let e;try{e=await l.text()}catch{e=""}throw new Error(`getRegions failed: ${l.status} (${l.statusText})${e?` (${e})`:""}`)}return(await l.json()).map((e=>({refName:e.name,start:0,end:e.length})))}getAssemblies(e){const{assemblyManager:t}=o.getSession(this.clientStore);return t.assemblies.filter((t=>{const r=n.getConf(t,["sequence","metadata"]);return!(!(r&&r.apollo&&r.internetAccountConfigId)||e&&r.internetAccountConfigId!==e)}))}async getChanges(e,t={}){const n=this.clientStore.getInternetAccount(e),{baseURL:r}=n,o=new URL("changes",r),i={assembly:e};void 0!==t.page&&(i.page=String(t.page)),void 0!==t.pageSize&&(i.pageSize=String(t.pageSize)),t.sortField&&(i.sortField=t.sortField),t.sortOrder&&(i.sortOrder=t.sortOrder),t.filters?.user&&(i.user=t.filters.user),t.filters?.typeName&&(i.typeName=t.filters.typeName),t.filters?.startTime&&(i.startTime=t.filters.startTime),t.filters?.endTime&&(i.endTime=t.filters.endTime),o.search=new URLSearchParams(i).toString();const a=await this.fetch(n,o.toString());if(!a.ok){const e=await dl(a,"getChanges failed");throw new Error(e)}return a.json()}async getCheckResults(e){const t=this.clientStore.getInternetAccount(e),{baseURL:n}=t,r=new URL("checks",n);r.search=new URLSearchParams({assembly:e}).toString();const o=await this.fetch(t,r.toString());if(!o.ok){const e=await dl(o,"getCheckResults failed");throw new Error(e)}return o.json()}async submitChange(e,t={}){const{internetAccountId:n}=t,r=this.clientStore.getInternetAccount("assembly"in e?e.assembly:void 0,n),{baseURL:o}=r,i=new URL("changes",o).href,a=await this.fetch(r,i,{method:"POST",body:JSON.stringify(e.toJSON()),headers:{"Content-Type":"application/json"}});if(!a.ok){const e=await dl(a,"submitChange failed");throw new Error(e)}const s=new Wt;return a.ok||(s.ok=!1),s}}var Nl;function Tl(e,t,n,r){const o={_id:(new at).toHexString(),refSeq:e,type:"CDS",min:n,max:r,strand:t},i={_id:(new at).toHexString(),refSeq:e,type:"exon",min:n,max:r,strand:t},a={};return a[o._id]=o,a[i._id]=i,{_id:(new at).toHexString(),refSeq:e,type:"mRNA",min:n,max:r,strand:t,children:a}}function Rl({changeManager:e,handleClose:t,region:n,session:r}){const[o,a]=u.useState(String(n.end)),[l,c]=u.useState(String(n.start+1)),[d,f]=u.useState(Nl.GENE_AND_SUBFEATURES),[h,p]=u.useState(""),[g,m]=u.useState(),[y,_]=u.useState(""),v=Number(o)<=Number(l);let b=v||!(l&&o&&d);return(d===Nl.CUSTOM&&!h||!g&&d===Nl.GENE_AND_SUBFEATURES||!g&&d===Nl.TRANSCRIPT_AND_SUBFEATURES)&&(b=!0),i.jsxs(Bs,{open:!0,title:"Add new feature",handleClose:t,maxWidth:!1,"data-testid":"add-feature-dialog",children:[i.jsxs("form",{onSubmit:async function(i){i.preventDefault(),_("");const a=r.apolloDataStore.getBackendDriver(n.assemblyName);if(!a)return void _("No backend driver found");let s=n.refName;if(a instanceof kl){const e=await a.getRefSeqId(n.assemblyName,n.refName);if(!e)return void _(`Could not find refSeq for "${n.refName}"`);s=e}if(d===Nl.GENE_AND_SUBFEATURES){const i=Tl(s,g,Number(l)-1,Number(o)),a={};a[i._id]=i;const c=(new at).toHexString(),u=new ht({changedIds:[c],typeName:"AddFeatureChange",assembly:n.assemblyName,addedFeature:{_id:c,refSeq:s,min:Number(l)-1,max:Number(o),type:"gene",strand:g,children:a}});return e.submit(u).then((()=>{r.apolloSetSelectedFeature(c)})),void t()}if(d===Nl.TRANSCRIPT_AND_SUBFEATURES){const i=Tl(s,g,Number(l)-1,Number(o)),a=new ht({changedIds:[i._id],typeName:"AddFeatureChange",assembly:n.assemblyName,addedFeature:i});return e.submit(a).then((()=>{r.apolloSetSelectedFeature(i._id)})),void t()}if(!h)return void _("No type selected");const c=(new at).toHexString(),u=new ht({changedIds:[c],typeName:"AddFeatureChange",assembly:n.assemblyName,addedFeature:{_id:c,refSeq:s,min:Number(l)-1,max:Number(o),type:h,strand:g}});e.submit(u).then((()=>{r.apolloSetSelectedFeature(c)})),t()},"data-testid":"submit-form",children:[i.jsxs(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:[i.jsx(s.TextField,{margin:"dense",id:"start",label:"Start",type:"number",fullWidth:!0,variant:"outlined",value:Number(l),onChange:e=>{c(e.target.value)}}),i.jsx(s.TextField,{margin:"dense",id:"end",label:"End",type:"number",fullWidth:!0,variant:"outlined",value:o,onChange:e=>{a(e.target.value)},error:v,helperText:v?'"End" must be greater than "Start"':null}),i.jsxs(s.FormControl,{children:[i.jsx(s.InputLabel,{id:"demo-simple-select-label",children:"Strand"}),i.jsxs(s.Select,{labelId:"demo-simple-select-label",id:"demo-simple-select",label:"Strand",value:g?.toString(),onChange:function(e){switch(_(""),Number(e.target.value)){case 1:m(1);break;case-1:m(-1);break;default:m(void 0)}},children:[i.jsx(s.MenuItem,{value:void 0}),i.jsx(s.MenuItem,{value:1,children:"+"}),i.jsx(s.MenuItem,{value:-1,children:"-"})]})]}),i.jsx(s.FormControl,{style:{marginTop:20},children:i.jsxs(s.RadioGroup,{"aria-labelledby":"demo-radio-buttons-group-label",defaultValue:Nl.GENE_AND_SUBFEATURES,name:"radio-buttons-group",value:d,onChange:e=>{_("");const{value:t}=e.target;Object.keys(Nl).includes(t)&&f(Nl[t])},children:[i.jsx(s.FormControlLabel,{value:Nl.GENE_AND_SUBFEATURES,control:i.jsx(s.Radio,{}),label:i.jsxs(s.Box,{display:"flex",alignItems:"center",children:["Add gene and sub-features",i.jsx(s.Tooltip,{title:"This is a shortcut to create a gene with a single mRNA, exon, and CDS",children:i.jsx(s.IconButton,{size:"small",children:i.jsx(ya,{sx:{fontSize:18}})})})]})}),i.jsx(s.FormControlLabel,{value:Nl.TRANSCRIPT_AND_SUBFEATURES,control:i.jsx(s.Radio,{}),label:i.jsxs(s.Box,{display:"flex",alignItems:"center",children:["Add transcript and sub-features",i.jsx(s.Tooltip,{title:"This is a shortcut to create a single mRNA with exon and CDS, but without a parent gene",children:i.jsx(s.IconButton,{size:"small",children:i.jsx(ya,{sx:{fontSize:18}})})})]})}),i.jsx(s.FormControlLabel,{value:Nl.CUSTOM,checked:d!==Nl.GENE_AND_SUBFEATURES&&d!==Nl.TRANSCRIPT_AND_SUBFEATURES,control:i.jsx(s.Radio,{}),label:"Add feature with a sequence ontology type"})]})}),d===Nl.CUSTOM?i.jsx(qs,{session:r,ontologyName:"Sequence Ontology",style:{width:170},value:h,filterTerms:Cs,renderInput:e=>i.jsx(s.TextField,{...e,label:"Type",variant:"outlined",fullWidth:!0}),onChange:(e,t)=>{var n;t&&(n=t,_(""),p(n))}}):null]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{variant:"contained",type:"submit",disabled:b,children:"Submit"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:t,children:"Cancel"})]})]}),y?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:y})}):null]})}function El({changeManager:e,handleClose:t,session:n}){const{internetAccounts:r}=l.getRoot(n),[o,a]=u.useState(""),[c,d]=u.useState(!1),[f,h]=u.useState(!1),p=r.filter((e=>"ApolloInternetAccount"===e.type));if(0===p.length)throw new Error("No Apollo internet account found");const[g,m]=u.useState(p[0]),{collaborationServerDriver:y}=n.apolloDataStore,_=y.getAssemblies(),[v,b]=u.useState(_.at(0));return i.jsxs(Bs,{open:!0,title:"Delete Assembly",handleClose:t,maxWidth:!1,"data-testid":"delete-assembly",children:[i.jsxs("form",{onSubmit:async function(n){if(n.preventDefault(),h(!0),a(""),!v)return void a("Must select assembly!");const r=new xt({typeName:"DeleteAssemblyChange",assembly:v.name});await e.submit(r,{internetAccountId:g.internetAccountId}),t(),n.preventDefault()},children:[i.jsxs(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:[p.length>1?i.jsxs(i.Fragment,{children:[i.jsx(s.DialogContentText,{children:"Select account"}),i.jsx(s.Select,{value:g.internetAccountId,onChange:function(e){h(!1);const t=p.find((t=>t.internetAccountId===e.target.value));if(!t)throw new Error(`Could not find internetAccount with ID "${e.target.value}"`);m(t)},disabled:f&&!o,children:r.map((e=>i.jsx(s.MenuItem,{value:e.internetAccountId,children:e.name},e.id)))})]}):null,i.jsx(s.DialogContentText,{children:"Select assembly"}),i.jsx(s.Select,{labelId:"label",value:v?.name??"",onChange:function(e){const t=_.find((t=>t.name===e.target.value));b(t)},disabled:0===_.length,children:_.map((e=>i.jsx(s.MenuItem,{value:e.name,children:e.displayName},e.name)))}),i.jsx(s.DialogContentText,{children:i.jsx("strong",{style:{color:"red"},children:"NOTE: All assembly data will be deleted and this operation cannot be undone!"})}),i.jsx(s.FormGroup,{children:i.jsx(s.FormControlLabel,{control:i.jsx(s.Checkbox,{checked:c,onChange:()=>{d(!c)}}),label:"I understand that all assembly data will be deleted"})})]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{disabled:!v||!c,variant:"contained",type:"submit",children:"Delete"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:t,children:"Cancel"})]})]}),o?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:o})}):null]})}!function(e){e.GENE_AND_SUBFEATURES="GENE_AND_SUBFEATURES",e.TRANSCRIPT_AND_SUBFEATURES="TRANSCRIPT_AND_SUBFEATURES",e.CUSTOM="CUSTOM"}(Nl||(Nl={}));var Il,jl,Dl,Ol,Fl={},Ml={},Ll={},Pl={};function Bl(){if(Il)return Pl;function e(e){return decodeURIComponent(e)}function t(e,t){return String(t).replaceAll(e,(function(e){return encodeURIComponent(e).toUpperCase()}))}function n(e){return t(/[\n;\r\t=%&,\u0000-\u001f\u007f]/g,e)}function r(e){return t(/[\n\r\t%\u0000-\u001f\u007f]/g,e)}function o(t){if(null==t||!t.length||"."===t)return{};var n={};return t.replace(/\r\n|[\r\n]$/,"").split(";").forEach((function(t){var r,o,i=t.split("=",2);if(null!==(r=i[1])&&void 0!==r&&r.length){i[0]=i[0].trim();var a=n[i[0].trim()];a||(n[i[0]]=a=[]),(o=a).push.apply(o,W(i[1].split(",").map((function(e){return e.trim()})).map(e)))}})),n}function i(e){var t=[];return Object.entries(e).forEach((function(e){var r=G(e,2),o=r[0],i=r[1].map(n).join(",");t.push("".concat(n(o),"=").concat(i))})),t.length?t.join(";"):"."}function a(e,t){var n=null==e.attributes?".":i(e.attributes),o=[null===e.seq_id?".":r(e.seq_id),null===e.source?".":r(e.source),null===e.type?".":r(e.type),null===e.start?".":r(e.start),null===e.end?".":r(e.end),null===e.score?".":r(e.score),null===e.strand?".":r(e.strand),null===e.phase?".":r(e.phase),n],a="".concat(o.join("\t"),"\n");return t[a]?"":(t[a]=!0,a)}function s(e,t){if(Array.isArray(e))return e.map((function(e){return s(e,t)})).join("");var n,r=[a(e,t)];return void 0!==(n=e).child_features&&void 0!==n.derived_features&&r.push.apply(r,W(e.child_features.map((function(e){return s(e,t)}))).concat(W(e.derived_features.map((function(e){return s(e,t)}))))),r.join("")}function l(e){return s(e,{})}function c(e){var t="##".concat(e.directive);return e.value&&(t+=" ".concat(e.value)),t+"\n"}function u(e){return"# ".concat(e.comment,"\n")}function d(e){for(var t=">".concat(e.id).concat(e.description?" ".concat(e.description):"","\n"),n=Math.ceil(e.sequence.length/80),r=new Array(n),o=0;o<n;o+=1){var i=80*o;r[o]=e.sequence.slice(i,i+80)}return"".concat(t).concat(r.join("\n"),"\n")}function f(e){return"attributes"in e?l(e):"directive"in e?c(e):"sequence"in e?d(e):"comment"in e?u(e):"# (invalid item found during format)\n"}return Il=1,Object.defineProperty(Pl,"__esModule",{value:!0}),Pl.unescape=e,Pl.escape=n,Pl.escapeColumn=r,Pl.parseAttributes=o,Pl.parseFeature=function(t){var n=t.trim().split("\t").map((function(e){return"."===e||""===e?null:e}));return{seq_id:n[0]&&e(n[0]),source:n[1]&&e(n[1]),type:n[2]&&e(n[2]),start:null===n[3]?null:parseInt(n[3],10),end:null===n[4]?null:parseInt(n[4],10),score:null===n[5]?null:parseFloat(n[5]),strand:n[6],phase:n[7],attributes:null===n[8]?null:o(n[8])}},Pl.parseDirective=function(e){var t=/^\s*##\s*(\S+)\s*(.*)/.exec(e);if(!t)return null;var n=G(t,2)[1],r=G(t,3)[2],o={directive:n};if(r.length&&(r=r.replace(/\r\n|[\r\n]$/,""),o.value=r),"sequence-region"===n){var i,a,s=r.split(/\s+/,3);return B(B({},o),{},{seq_id:s[0],start:null===(i=s[1])||void 0===i?void 0:i.replaceAll(/\D/g,""),end:null===(a=s[2])||void 0===a?void 0:a.replaceAll(/\D/g,"")})}if("genome-build"===n){var l=G(r.split(/\s+/,2),2),c=l[0],u=l[1];return B(B({},o),{},{source:c,buildName:u})}return o},Pl.formatAttributes=i,Pl.formatFeature=l,Pl.formatDirective=c,Pl.formatComment=u,Pl.formatSequence=d,Pl.formatItem=function(e){return Array.isArray(e)?e.map(f):f(e)},Pl}function ql(){if(Dl)return Ml;Dl=1,Object.defineProperty(Ml,"__esModule",{value:!0}),Ml.GFFFormattingTransformer=Ml.GFFTransformer=void 0,Ml.parseStringSync=function(t,r){if(!t)return[];var o=n(null!=r?r:{}),i=[],a=i.push.bind(i),s={errorCallback:o.errorCallback};o.parseFeatures&&(s.featureCallback=a),o.parseDirectives&&(s.directiveCallback=a),o.parseComments&&(s.commentCallback=a),o.parseSequences&&(s.sequenceCallback=a);var l=new e.GFF3Parser({disableDerivesFromReferences:o.disableDerivesFromReferences||!1,bufferSize:Infinity});return t.split(/\r\n|[\r\n]/).forEach((function(e){return l.addLine.bind(l)(e,s)})),l.finish(s),i},Ml.formatSync=function(e){var n=[],r=[];e.forEach((function(e){"sequence"in e?r.push(e):n.push(e)}));var o=n.map((function(e){return Array.isArray(e)?(0,t.formatItem)(e).join(""):(0,t.formatItem)(e)})).join("");return r.length&&(o+="##FASTA\n",o+=r.map(t.formatSequence).join("")),o};var e=function(){if(jl)return Ll;jl=1,Object.defineProperty(Ll,"__esModule",{value:!0}),Ll.GFF3Parser=Ll.FASTAParser=void 0;var e=Bl(),t=function(){return I((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){};R(this,e),D(this,"seqCallback",void 0),D(this,"currentSequence",void 0),this.seqCallback=t,this.currentSequence=void 0}),[{key:"addLine",value:function(e){var t=/^>\s*(\S+)\s*(.*)/.exec(e);t?(this.flush(),this.currentSequence={id:t[1],sequence:""},t[2]&&(this.currentSequence.description=t[2].trim())):this.currentSequence&&/\S/.test(e)&&(this.currentSequence.sequence+=e.replaceAll(/\s/g,""))}},{key:"flush",value:function(){this.currentSequence&&this.seqCallback(this.currentSequence)}},{key:"finish",value:function(){this.flush()}}])}();Ll.FASTAParser=t;var n=function(){return I((function e(t){R(this,e),D(this,"endCallback",void 0),D(this,"disableDerivesFromReferences",void 0),D(this,"bufferSize",void 0),D(this,"fastaParser",void 0),D(this,"eof",!1),D(this,"lineNumber",0),D(this,"underConstructionTopLevel",[]),D(this,"underConstructionById",{}),D(this,"completedReferences",{}),D(this,"underConstructionOrphans",new Map),this.endCallback=t.endCallback||function(){},this.disableDerivesFromReferences=t.disableDerivesFromReferences||!1,this.bufferSize=void 0===t.bufferSize?Infinity:t.bufferSize}),[{key:"addLine",value:function(n,r){if(this.fastaParser)this.fastaParser.addLine(n);else if(!this.eof)if(this.lineNumber+=1,/^\s*[^#\s>]/.test(n))this.bufferLine(n,r);else{var o=/^\s*(#+)(.*)/.exec(n);if(o){var i=G(o,2)[1],a=G(o,3)[2];if(3===i.length)this.emitAllUnderConstructionFeatures(r);else if(2===i.length){var s=(0,e.parseDirective)(n);s&&("FASTA"===s.directive?(this.emitAllUnderConstructionFeatures(r),this.eof=!0,this.fastaParser=new t(r.sequenceCallback)):this.emitItem(s,r))}else a=a.replace(/\s*/,""),this.emitItem({comment:a},r)}else if(/^\s*$/.test(n));else if(/^\s*>/.test(n))this.emitAllUnderConstructionFeatures(r),this.eof=!0,this.fastaParser=new t(r.sequenceCallback),this.fastaParser.addLine(n);else{var l=n.replaceAll(/\r\n|[\r\n]$/g,"");this.parseError("GFF3 parse error. Cannot parse '".concat(l,"'."),r)}}}},{key:"finish",value:function(e){this.emitAllUnderConstructionFeatures(e),this.fastaParser&&this.fastaParser.finish(),this.endCallback()}},{key:"emitItem",value:function(e,t){Array.isArray(e)&&t.featureCallback?t.featureCallback(e):"directive"in e&&t.directiveCallback?t.directiveCallback(e):"comment"in e&&t.commentCallback&&t.commentCallback(e)}},{key:"enforceBufferSizeLimit",value:function(){for(var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=arguments.length>1?arguments[1]:void 0,r=function(t){var n;t&&Array.isArray(t)&&null!==(n=t[0].attributes)&&void 0!==n&&null!==(n=n.ID)&&void 0!==n&&n[0]&&(t[0].attributes.ID.forEach((function(t){delete e.underConstructionById[t],delete e.completedReferences[t]})),t.forEach((function(e){e.child_features&&e.child_features.forEach((function(e){return r(e)})),e.derived_features&&e.derived_features.forEach((function(e){return r(e)}))})))};this.underConstructionTopLevel.length+t>this.bufferSize;){var o=this.underConstructionTopLevel.shift();o&&(this.emitItem(o,n),r(o))}}},{key:"emitAllUnderConstructionFeatures",value:function(e){var t=this;this.underConstructionTopLevel.forEach((function(n){return t.emitItem.bind(t)(n,e)})),this.underConstructionTopLevel=[],this.underConstructionById={},this.completedReferences={},this.underConstructionOrphans.size&&this.parseError("some features reference other features that do not exist in the file (or in the same '###' scope). ".concat(Array.from(this.underConstructionOrphans.keys()).join(",")),e)}},{key:"bufferLine",value:function(t,n){var r,o,i,a=this,s=B(B({},(0,e.parseFeature)(t)),{},{child_features:[],derived_features:[]}),l=(null===(r=s.attributes)||void 0===r?void 0:r.ID)||[],c=(null===(o=s.attributes)||void 0===o?void 0:o.Parent)||[],u=this.disableDerivesFromReferences?[]:(null===(i=s.attributes)||void 0===i?void 0:i.Derives_from)||[];if(l.length||c.length||u.length){var d=void 0;l.forEach((function(e){var t=a.underConstructionById[e];t?(t[t.length-1].type!==s.type&&a.parseError('multi-line feature "'.concat(e,'" has inconsistent types: "').concat(s.type,'", "').concat(t[t.length-1].type,'"'),n),t.push(s),d=t):(d=[s],a.enforceBufferSizeLimit(1,n),c.length||u.length||a.underConstructionTopLevel.push(d),a.underConstructionById[e]=d,a.resolveReferencesTo(d,e))})),this.resolveReferencesFrom(d||[s],{Parent:c,Derives_from:u},l)}else this.emitItem([s],n)}},{key:"resolveReferencesTo",value:function(e,t){var n=this.underConstructionOrphans.get(t);n&&(e.forEach((function(e){var t;(t=e.child_features).push.apply(t,W(n.Parent))})),e.forEach((function(e){var t;(t=e.derived_features).push.apply(t,W(n.Derives_from))})),this.underConstructionOrphans.delete(t))}},{key:"parseError",value:function(e,t){var n;this.eof=!0,null===(n=t.errorCallback)||void 0===n||n.call(t,"".concat(this.lineNumber,": ").concat(e))}},{key:"postSet",value:function(e,t,n){var r=e[t];r||(e[t]=r={});var o=r[n]||!1;return r[n]=!0,o}},{key:"resolveReferencesFrom",value:function(e,t,n){var r=this;t.Parent.forEach((function(t){var o=r.underConstructionById[t];if(o)n.filter((function(e){return r.postSet(r.completedReferences,e,"Parent,".concat(t))})).length||o.forEach((function(t){t.child_features.push(e)}));else{var i=r.underConstructionOrphans.get(t);i||r.underConstructionOrphans.set(t,i={Parent:[],Derives_from:[]}),i.Parent.push(e)}})),t.Derives_from.forEach((function(t){var o=r.underConstructionById[t];if(o)n.filter((function(e){return r.postSet(r.completedReferences,e,"Derives_from,".concat(t))})).length||o.forEach((function(t){t.derived_features.push(e)}));else{var i=r.underConstructionOrphans.get(t);i||r.underConstructionOrphans.set(t,i={Parent:[],Derives_from:[]}),i.Derives_from.push(e)}}))}}])}();return Ll.GFF3Parser=n,Ll}(),t=Bl();function n(e){return B({parseFeatures:!0,parseDirectives:!1,parseSequences:!0,parseComments:!1,bufferSize:Infinity,disableDerivesFromReferences:!1,errorCallback:function(e){throw new Error(e)}},e)}Ml.GFFTransformer=function(){return I((function t(r){R(this,t),D(this,"decoder",void 0),D(this,"parser",void 0),D(this,"lastString",""),D(this,"parseFeatures",void 0),D(this,"parseDirectives",void 0),D(this,"parseComments",void 0),D(this,"parseSequences",void 0),this.decoder=new TextDecoder;var o=n(null!=r?r:{});this.parser=new e.GFF3Parser({bufferSize:o.bufferSize,disableDerivesFromReferences:o.disableDerivesFromReferences}),this.parseFeatures=o.parseFeatures,this.parseDirectives=o.parseDirectives,this.parseComments=o.parseComments,this.parseSequences=o.parseSequences,this.errorCallback=null==r?void 0:r.errorCallback}),[{key:"makeCallbacks",value:function(e){var t={errorCallback:this.emitErrorMessage.bind(this,e)};return this.parseFeatures&&(t.featureCallback=function(t){e.enqueue(t)}),this.parseDirectives&&(t.directiveCallback=function(t){e.enqueue(t)}),this.parseComments&&(t.commentCallback=function(t){e.enqueue(t)}),this.parseSequences&&(t.sequenceCallback=function(t){e.enqueue(t)}),t}},{key:"emitErrorMessage",value:function(e,t){this.errorCallback?this.errorCallback(t):e.error(t)}},{key:"transform",value:function(e,t){var n="".concat(this.lastString).concat(this.decoder.decode(e,{stream:!0})).split(/\r\n|[\r\n]/g);this.lastString=n.pop()||"";var r,o=j(n);try{for(o.s();!(r=o.n()).done;)this.parser.addLine(r.value,this.makeCallbacks(t))}catch(e){o.e(e)}finally{o.f()}}},{key:"flush",value:function(e){var t=this.makeCallbacks(e);this.lastString="".concat(this.lastString).concat(this.decoder.decode()),this.lastString&&(this.parser.addLine(this.lastString,t),this.lastString=""),this.parser.finish(t)}}])}();var r=function(){return I((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};R(this,e),D(this,"linesSinceLastSyncMark",0),D(this,"haveWeEmittedData",!1),D(this,"fastaMode",!1),D(this,"minLinesBetweenSyncMarks",void 0),D(this,"insertVersionDirective",void 0),this.minLinesBetweenSyncMarks=t.minSyncLines||100,this.insertVersionDirective=!1!==t.insertVersionDirective}),[{key:"transform",value:function(e,n){!this.haveWeEmittedData&&this.insertVersionDirective&&(!("directive"in e)||"directive"in e&&"gff-version"!==e.directive)&&n.enqueue("##gff-version 3\n"),"sequence"in e&&!this.fastaMode&&(n.enqueue("##FASTA\n"),this.fastaMode=!0);var r=Array.isArray(e)?e.map((function(e){return(0,t.formatItem)(e)})).join(""):(0,t.formatItem)(e);if(n.enqueue(r),this.linesSinceLastSyncMark>=this.minLinesBetweenSyncMarks)n.enqueue("###\n"),this.linesSinceLastSyncMark=0;else{for(var o=0,i=0;i<r.length;i+=1)"\n"===r[i]&&(o+=1);this.linesSinceLastSyncMark+=o}this.haveWeEmittedData=!0}}])}();return Ml.GFFFormattingTransformer=r,Ml}var Ul,zl=(Ol||(Ol=1,function(e){var t,n=Fl&&Fl.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),r=Fl&&Fl.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=Fl&&Fl.__importStar||(t=function(e){return t=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},t(e)},function(e){if(e&&e.__esModule)return e;var o={};if(null!=e)for(var i=t(e),a=0;a<i.length;a++)"default"!==i[a]&&n(o,e,i[a]);return r(o,e),o}),i=Fl&&Fl.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),e.util=e.defaultExport=void 0;var a=o(ql());i(ql(),e);var s=o(Bl());e.defaultExport=B(B({},a),{},{util:s}),e.default=e.defaultExport,e.util=o(Bl())}(Fl)),Fl),$l={exports:{}},Hl=(Ul||(Ul=1,function(e,t){!function(){function t(e,t,n){var r=new XMLHttpRequest;r.open("GET",e),r.responseType="blob",r.onload=function(){a(r.response,t,n)},r.onerror=function(){console.error("could not download file")},r.send()}function n(e){var t=new XMLHttpRequest;t.open("HEAD",e,!1);try{t.send()}catch(e){}return 200<=t.status&&299>=t.status}function r(e){try{e.dispatchEvent(new MouseEvent("click"))}catch(n){var t=document.createEvent("MouseEvents");t.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),e.dispatchEvent(t)}}var o="object"==("undefined"==typeof window?"undefined":K(window))&&window.window===window?window:"object"==("undefined"==typeof self?"undefined":K(self))&&self.self===self?self:"object"==K(re)&&re.global===re?re:void 0,i=o.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),a=o.saveAs||("object"!=("undefined"==typeof window?"undefined":K(window))||window!==o?function(){}:"download"in HTMLAnchorElement.prototype&&!i?function(e,i,a){var s=o.URL||o.webkitURL,l=document.createElement("a");l.download=i=i||e.name||"download",l.rel="noopener","string"==typeof e?(l.href=e,l.origin===location.origin?r(l):n(l.href)?t(e,i,a):r(l,l.target="_blank")):(l.href=s.createObjectURL(e),setTimeout((function(){s.revokeObjectURL(l.href)}),4e4),setTimeout((function(){r(l)}),0))}:"msSaveOrOpenBlob"in navigator?function(e,o,i){if(o=o||e.name||"download","string"!=typeof e)navigator.msSaveOrOpenBlob(function(e,t){return void 0===t?t={autoBom:!1}:"object"!=K(t)&&(console.warn("Deprecated: Expected third argument to be a object"),t={autoBom:!t}),t.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob(["\ufeff",e],{type:e.type}):e}(e,i),o);else if(n(e))t(e,o,i);else{var a=document.createElement("a");a.href=e,a.target="_blank",setTimeout((function(){r(a)}))}}:function(e,n,r,a){if((a=a||open("","_blank"))&&(a.document.title=a.document.body.innerText="downloading..."),"string"==typeof e)return t(e,n,r);var s="application/octet-stream"===e.type,l=/constructor/i.test(o.HTMLElement)||o.safari,c=/CriOS\/[\d]+/.test(navigator.userAgent);if((c||s&&l||i)&&"undefined"!=typeof FileReader){var u=new FileReader;u.onloadend=function(){var e=u.result;e=c?e:e.replace(/^data:[^;]*;/,"data:attachment/file;"),a?a.location.href=e:location=e,a=null},u.readAsDataURL(e)}else{var d=o.URL||o.webkitURL,f=d.createObjectURL(e);a?a.location=f:location.href=f,a=null,setTimeout((function(){d.revokeObjectURL(f)}),4e4)}});o.saveAs=a.saveAs=a,e.exports=a}()}($l)),$l.exports);function Gl(e){return i.jsx(s.SvgIcon,{viewBox:"0 0 24 24",...e,children:i.jsx("path",{d:"M23,12L19,8V11H10V13H19V16M1,18V6C1,4.89 1.9,4 3,4H15A2,2 0 0,1 17,6V9H15V6H3V18H15V15H17V18A2,2 0 0,1 15,20H3A2,2 0 0,1 1,18Z"})})}function Vl({handleClose:e,session:t,assembly:r}){const[o,a]=u.useState(!1),[l,c]=u.useState(""),{getInternetAccount:d}=t.apolloDataStore,{assemblyManager:f}=t,h=f.get(r);if(!h)return void c(`Assembly "${r}" not found`);const{internetAccountConfigId:p}=n.getConf(h,["sequence","metadata"]);return i.jsxs(Bs,{open:!0,title:"Export annotations",handleClose:e,maxWidth:!1,"data-testid":"download-gff3",children:[i.jsxs("form",{onSubmit:async function(t){t.preventDefault(),c(""),await(p?async function(e){const t=d(r,e),n=new URL("export/getID",t.baseURL),i=new URLSearchParams({assembly:r});n.search=i.toString();const a=n.toString(),s=t.getFetcher({locationType:"UriLocation",uri:a}),l=await s(a,{method:"GET"});if(!l.ok){const e=await dl(l,"Error when exporting ID");return void c(e)}const{exportID:u}=await l.json(),f=new URL("export",t.baseURL),h=new URLSearchParams({exportID:u,includeFASTA:o?"true":"false"});f.search=h.toString();const p=f.toString();window.open(p,"_blank")}(p):async function(e){const t=function(e){const t=new ReadableStream({async start(t){for await(const n of async function*(e){const t=await wl(e,[]);for(const e of t.objectStoreNames){const n=t.transaction(e);for await(const e of n.store.iterate())yield e.value}t.close()}(e)){const e=En(n);t.enqueue(e)}t.close()}});return t.pipeThrough(new TransformStream(new zl.GFFFormattingTransformer))}(e),n=`${e}.gff3`;try{const e=await globalThis.showSaveFilePicker({suggestedName:n}),r=await e.createWritable();await t.pipeTo(r)}catch{const e=await new Response(t).blob();Hl.saveAs(e,n)}}(r)),e()},children:[i.jsxs(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:[i.jsxs(s.DialogContentText,{children:["Exporting annotations for ",r]}),i.jsx(s.FormGroup,{children:i.jsx(s.FormControlLabel,{"data-testid":"include-fasta-checkbox",control:i.jsx(s.Checkbox,{checked:o,onChange:()=>{a(!o)},disabled:!p}),label:"Include fasta sequence in GFF output"})})]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{variant:"contained",type:"submit",children:"Download"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:e,children:"Cancel"})]})]}),l?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:l})}):null]})}function Wl({assemblyName:e,handleClose:t,session:n}){const{changeManager:r}=n.apolloDataStore,[o,a]=u.useState(),[l,c]=u.useState(""),[d,f]=u.useState(!1);return i.jsxs(Bs,{open:!0,title:"Import annotations",handleClose:t,children:[d?i.jsx(s.LinearProgress,{}):null,i.jsxs("form",{onSubmit:async function(n){if(n.preventDefault(),o){f(!0),c("");try{const n=o.stream().pipeThrough(new TransformStream(new zl.GFFTransformer({parseSequences:!1})));for await(const t of n){const n=Fn(t),o=new ht({changedIds:[n._id],typeName:"AddFeatureChange",assembly:e,addedFeature:n});await r.submit(o)}t()}catch(e){c(String(e))}finally{f(!1)}}},children:[i.jsxs(s.DialogContent,{children:[i.jsx(s.DialogContentText,{children:"Import annotations from a GFF3 file into the current Apollo track. Features are parsed and stored locally in the browser, so importing very large GFF3 files is not recommended."}),i.jsx("input",{type:"file",accept:".gff,.gff3",onChange:function(e){e.target.files&&a(e.target.files[0])},disabled:d}),l?i.jsx(s.DialogContentText,{color:"error",children:l}):null]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{variant:"contained",type:"submit",disabled:!o||d,children:"Import"}),i.jsx(s.Button,{variant:"outlined",onClick:t,children:"Cancel"})]})]})]})}function Jl({changeManager:e,handleClose:t,session:r}){const{apolloDataStore:o}=r,[a,l]=u.useState(),[c,d]=u.useState(),[f,h]=u.useState(""),[p,g]=u.useState(!1),[m,y]=u.useState(),[_,v]=u.useState(!1),[b,x]=u.useState(!0),[w,S]=u.useState(!1),{collaborationServerDriver:C,getInternetAccount:A}=o,k=C.getAssemblies();return u.useEffect((()=>{c&&(async()=>{const{internetAccountConfigId:e}=n.getConf(c,["sequence","metadata"]),t=A(c.name,e);if(!t)throw new Error("No Apollo internet account found");const{baseURL:r}=t,o=new URL("features/count",r),i=new URLSearchParams({assemblyId:c.name});o.search=i.toString();const a=t.getFetcher({locationType:"UriLocation",uri:o.toString()});S(!0);const s=await a(o.toString(),{method:"GET"});if(!s.ok)throw new Error(await dl(s));{const e=await s.json();y(e.count)}S(!1)})().catch((e=>{console.error(e),h(e.message??e)}))}),[A,r,c]),i.jsxs(Bs,{open:!0,title:"Import Features from GFF3 file",handleClose:t,maxWidth:!1,"data-testid":"import-features-dialog",children:[w?i.jsx(s.LinearProgress,{}):null,i.jsxs("form",{onSubmit:async function(o){o.preventDefault(),h(""),S(!0),g(!0);let i="";if(!a)return void h("must select a file");if(!c)return void h("Must select assembly to download");const{internetAccountConfigId:s}=n.getConf(c,["sequence","metadata"]),l=A(c.name,s),{baseURL:u}=l,d=new URL("files",u);d.searchParams.set("type","text/x-gff3");const f=d.href,p=new FormData;p.append("file",a),p.append("fileName",a.name),p.append("type","text/x-gff3");const m=l.getFetcher({locationType:"UriLocation",uri:f});t();const{jobsManager:y}=r,v=new AbortController,x={name:`Importing features for ${c.displayName}`,statusMessage:"Uploading file, this may take awhile",progressPct:0,cancelCallback:()=>{v.abort(new DOMException(`Canceling importing of features to ${c.displayName}`,"AbortError")),y.abortJob(x.name)}};if(y.runJob(x),m){const{signal:e}=v,t=await m(f,{method:"POST",body:p,signal:e});if(!t.ok){const e=await dl(t,"Error when inserting new features (while uploading file)");return y.abortJob(x.name,e),void h(e)}i=(await t.json())._id}const w=new vt({typeName:"AddFeaturesFromFileChange",assembly:c.name,fileId:i,parseOptions:{strict:b},deleteExistingFeatures:_});y.done(x),await e.submit(w,{updateJobsManager:!0})},children:[i.jsxs(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:[i.jsx(s.DialogContentText,{children:"Select assembly"}),i.jsx(s.Select,{labelId:"label",value:c?.name??"",onChange:function(e){const t=k.find((t=>t.name===e.target.value));d(t),g(!1)},disabled:p&&!f,children:k.map((e=>i.jsx(s.MenuItem,{value:e.name,children:e.displayName??e.name},e.name)))}),i.jsx(s.DialogContentText,{children:"Upload GFF3 to load features"}),i.jsx("input",{type:"file",onChange:function(e){g(!1),e.target.files&&l(e.target.files[0])},disabled:p&&!f}),i.jsx(s.FormControlLabel,{label:"Strict parsing",disabled:p&&!f,control:i.jsx(s.Checkbox,{checked:b,onChange:function(e){x(e.target.checked)}})}),i.jsx(s.FormHelperText,{children:"Don't import any features if any lines in the GFF3 are unable to be processed"}),m&&m>0?i.jsxs(i.Fragment,{children:[i.jsx(s.FormControlLabel,{label:"Delete existing features",disabled:p&&!f,control:i.jsx(s.Checkbox,{checked:_,onChange:function(e){v(e.target.checked)},slotProps:{input:{"aria-label":"controlled"}},color:"warning"})}),i.jsxs(s.FormHelperText,{children:["This assembly has ",m," features that will be deleted"]})]}):null]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{disabled:!(c&&a&&void 0!==m)||p,variant:"contained",type:"submit",children:p?"Submitting...":"Submit"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:t,children:"Close"})]})]}),f?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:f})}):null]})}function Kl({handleClose:e,session:t}){const{internetAccounts:n}=l.getRoot(t),[r,o]=u.useState(""),a=n.filter((e=>"ApolloInternetAccount"===e.type));if(0===a.length)throw new Error("No Apollo internet account found");const[c,d]=u.useState(a[0]);return i.jsxs(Bs,{open:!0,title:"Log out",handleClose:e,maxWidth:!1,"data-testid":"log-out",children:[i.jsxs("form",{onSubmit:function(e){e.preventDefault(),o(""),c.removeToken(),globalThis.location.reload()},children:[i.jsxs(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:[a.length>1?i.jsxs(i.Fragment,{children:[i.jsx(s.DialogContentText,{children:"Select account"}),i.jsx(s.Select,{value:c.internetAccountId,onChange:function(e){const t=a.find((t=>t.internetAccountId===e.target.value));if(!t)throw new Error(`Could not find internetAccount with ID "${e.target.value}"`);d(t)},children:n.map((e=>i.jsx(s.MenuItem,{value:e.internetAccountId,children:e.name},e.id)))})]}):null,i.jsx(s.DialogContentText,{children:"Are you sure you want to log out?"})]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{disabled:!c,variant:"contained",type:"submit",children:"Log Out"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:e,children:"Cancel"})]})]}),r?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:r})}):null]})}function Yl({handleClose:e,session:t}){const{internetAccounts:n}=l.getRoot(t),[r,o]=u.useState(""),[a,c]=u.useState(!1),d=n.filter((e=>"ApolloInternetAccount"===e.type));if(0===d.length)throw new Error("No Apollo internet account found");const[f,h]=u.useState(d[0]),[p,g]=u.useState([]),[m,y]=u.useState([]),{collaborationServerDriver:_}=t.apolloDataStore,v=_.getAssemblies(),[b,x]=u.useState(v.at(0));function w(e,t){const n=[...m],r=e.target.value;if(t)n.includes(r)||(n.push(r),y(n));else{const e=n.indexOf(r,0);-1!==e&&n.splice(e,1),y(n)}}return u.useEffect((()=>{(async function(){const{baseURL:e,getFetcher:t}=f,n=new URL("checks/types",e).href,r=t({locationType:"UriLocation",uri:n}),i=await r(n,{method:"GET"});if(!i.ok){const e=await dl(i,"Error when retrieving checks from server");return void o(e)}const a=await i.json();g(a)})().catch((e=>{o(String(e))}))}),[f]),u.useEffect((()=>{(async function(){if(!b)return;const{baseURL:e,getFetcher:t}=f,n=new URL(`assemblies/${b.name}`,e).href,r=t({locationType:"UriLocation",uri:n}),i=await r(n,{method:"GET"});if(!i.ok){const e=await dl(i,"Error when retrieving assembly from server");return void o(e)}const a=await i.json();y(a.checks)})().catch((e=>{o(String(e))}))}),[b,f]),i.jsxs(Bs,{open:!0,title:"Manage Checks",handleClose:e,"data-testid":"manage-checks",children:[i.jsxs("form",{onSubmit:async function(n){if(n.preventDefault(),!b)return void o("Must select assembly!");const{notify:r}=t,{baseURL:i,getFetcher:a}=f,s=new URL("assemblies/checks",i).href,l=a({locationType:"UriLocation",uri:s}),c=await l(s,{method:"POST",body:JSON.stringify({_id:b.name,checks:m,name:""}),headers:{"Content-Type":"application/json"}});if(c.ok)r("Assembly checks updated successfully","success"),e();else{const e=await dl(c,"Error when updating assembly checks");o(e)}},children:[i.jsxs(s.DialogContent,{children:[d.length>1?i.jsxs(i.Fragment,{children:[i.jsx(s.DialogContentText,{children:"Select account"}),i.jsx(s.Select,{value:f.internetAccountId,onChange:function(e){c(!1);const t=d.find((t=>t.internetAccountId===e.target.value));if(!t)throw new Error(`Could not find internetAccount with ID "${e.target.value}"`);h(t)},disabled:a&&!r,children:n.map((e=>i.jsx(s.MenuItem,{value:e.internetAccountId,children:e.name},e.id)))})]}):null,i.jsx(s.DialogContentText,{children:"Select assembly"}),i.jsx(s.Select,{style:{width:300},labelId:"label",value:b?.name??"",onChange:function(e){const t=v.find((t=>t.name===e.target.value));x(t)},disabled:0===v.length,children:v.map((e=>i.jsx(s.MenuItem,{value:e.name,children:e.displayName},e.name)))}),i.jsx("br",{}),i.jsx("br",{}),i.jsx(s.TableContainer,{component:s.Paper,children:i.jsxs(s.Table,{children:[i.jsx(s.TableHead,{children:i.jsxs(s.TableRow,{children:[i.jsx(s.TableCell,{children:"Check name"}),i.jsx(s.TableCell,{children:"Use check"})]})}),i.jsx(s.TableBody,{children:p.map((e=>i.jsxs(s.TableRow,{children:[i.jsx(s.TableCell,{children:e.name}),i.jsx(s.TableCell,{children:i.jsx(s.Checkbox,{value:e._id,checked:m.includes(e._id),onChange:w})})]},e._id)))})]})})]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{variant:"contained",type:"submit",children:"Submit"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:e,children:"Cancel"})]})]}),r?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:r})}):null]})}function Xl(e){return"ApolloInternetAccount"===e.type}function Zl({changeManager:e,handleClose:t,session:n}){const{internetAccounts:r}=l.getRoot(n),o=r.filter((e=>Xl(e))).filter((e=>e.role?.includes("admin")));if(0===o.length)throw new Error("No Apollo internet account found");const[a,c]=u.useState(""),[d,f]=u.useState(o[0]),[h,p]=u.useState([]);function g(e){return e===d.getUserId()}u.useEffect((()=>{(async function(){const{baseURL:e}=d,t=new URL("users",e).href,n=d.getFetcher({locationType:"UriLocation",uri:t}),r=await n(t,{method:"GET"});if(!r.ok){const e=await dl(r,"Error when getting user data from db");return void c(e)}const o=await r.json();p(o.map((e=>void 0===e.role?{...e,role:""}:e)))})().catch((e=>{c(String(e))}))}),[d]);const y=[{field:"username",headerName:"User",width:140},{field:"email",headerName:"Email",width:160},{field:"role",headerName:"Role",width:140,type:"singleSelect",valueOptions:["readOnly","user","admin","none"],getOptionLabel(e){switch(e){case"readOnly":return"Read-only";case"user":return"User";case"admin":return"Admin";case"none":return"None";default:return"unknown"}},editable:!0},{field:"actions",type:"actions",getActions:t=>[i.jsx(m.GridActionsCellItem,{icon:i.jsx(co,{}),onClick:async()=>{globalThis.confirm("Delete this user?")&&await async function(t){const n=new wt({typeName:"DeleteUserChange",userId:t});await e.submit(n,{internetAccountId:d.internetAccountId}),p((e=>e.filter((e=>e._id!==t))))}(t.id)},disabled:g(t.id),label:"Delete"},`delete-${t.id}`)]}];return i.jsxs(Bs,{open:!0,fullScreen:!0,title:"Manage users",handleClose:t,"data-testid":"manage-users",children:[i.jsxs(s.DialogContent,{children:[o.length>1?i.jsxs(i.Fragment,{children:[i.jsx(s.DialogContentText,{children:"Select account"}),i.jsx(s.Select,{value:d.internetAccountId,onChange:function(e){const t=o.find((t=>t.internetAccountId===e.target.value));if(!t)throw new Error(`Could not find internetAccount with ID "${e.target.value}"`);f(t)},disabled:!a,children:r.map((e=>i.jsx(s.MenuItem,{value:e.internetAccountId,children:e.name},e.id)))})]}):null,i.jsx("div",{style:{height:"100%",width:"100%"},children:i.jsx(m.DataGrid,{pagination:!0,rows:h,columns:y,getRowId:e=>e._id,showToolbar:!0,getRowHeight:()=>"auto",isCellEditable:e=>!g(e.id),processRowUpdate:async function(t){const n=new Ht({typeName:"UserChange",role:t.role,userId:t._id});return await e.submit(n,{internetAccountId:d.internetAccountId}),t},onProcessRowUpdateError:e=>{c(String(e))}})})]}),i.jsx(s.DialogActions,{children:i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:t,children:"Close"})}),a?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:a})}):null]})}function Ql(e,t){const n=t[e];let r;if("three_prime"===e)r=`3'end (coords: ${n.min+1}-${n.max})`;else{if("five_prime"!==e)throw new Error(`Unexpected direction: "${e}"`);r=`5'end (coords: ${n.min+1}-${n.max})`}return r}function ec({changeManager:e,handleClose:t,selectedFeature:n,setSelectedFeature:r,sourceAssemblyId:o,sourceFeature:a}){const[c,d]=u.useState(""),[f,h]=u.useState(),p=function(e){const t={},n=e.parent;if(!n)throw new Error("Unable to find parent of reference exon");let r=[];if(n.children)for(const[,e]of n.children)"exon"===e.type&&r.push(e);r=r.sort(((e,t)=>e.min===t.min?e.max-t.max:e.min-t.min)),n.strand&&-1===n.strand&&(r=r.reverse());let o=0;for(const n of r){if(n._id===e._id){r.length>o+1&&(t.three_prime=r[o+1]),o>0&&(t.five_prime=r[o-1]);break}o++}return t}(a);return i.jsxs(Bs,{open:!0,title:"Merge exons",handleClose:t,maxWidth:!1,"data-testid":"merge-exons",children:[i.jsxs("form",{onSubmit:function(i){i.preventDefault(),d("");const{parent:s}=a;if(!f||!s)return;n?._id===a._id&&r();const c=new jt({changedIds:[a._id],typeName:"MergeExonsChange",assembly:o,firstExon:l.getSnapshot(a),secondExon:l.getSnapshot(f),parentFeatureId:s._id});e.submit(c),t(),i.preventDefault()},children:[i.jsxs(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:[0===Object.keys(p).length?"There are no neighbouring exons to merge with":"Merge with exon on:",i.jsx(s.FormControl,{style:{marginTop:5},children:i.jsx(s.RadioGroup,{"aria-labelledby":"demo-radio-buttons-group-label",name:"radio-buttons-group",value:f,onChange:e=>{d("");const{value:t}=e.target;h(p[t])},children:Object.keys(p).map((e=>i.jsx(s.FormControlLabel,{value:e,control:i.jsx(s.Radio,{}),label:i.jsx(s.Box,{display:"flex",alignItems:"center",children:Ql(e,p)})},e)))})})]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{variant:"contained",type:"submit",disabled:0===Object.keys(p).length||void 0===f,children:"Submit"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:t,children:"Cancel"})]})]}),c?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:c})}):null]})}function tc(e){let t;return t=e.attributes.get("gff_name")?e.attributes.get("gff_name")?.join(","):e.attributes.get("gff_id")?e.attributes.get("gff_id")?.join(","):e._id,`${t} [${e.min+1}-${e.max}]`}function nc({changeManager:e,handleClose:t,selectedFeature:n,session:r,setSelectedFeature:o,sourceAssemblyId:a,sourceFeature:c}){const[d,f]=u.useState(""),h=function(e,t){const n=e.parent;if(!n)throw new Error("Unable to find parent of reference transcript");const{featureTypeOntology:r}=t.apolloDataStore.ontologyManager;if(!r)throw new Error("featureTypeOntology is undefined");const o={};if(n.children)for(const[,t]of n.children)r.isTypeOf(t.type,"transcript")&&t._id!==e._id&&(o[t._id]=t);return o}(c,r),p=Object.keys(h).at(0),[g,m]=u.useState(p);return i.jsxs(Bs,{open:!0,title:"Merge transcripts",handleClose:t,maxWidth:!1,"data-testid":"merge-transcripts",children:[i.jsxs("form",{onSubmit:function(r){if(r.preventDefault(),f(""),!g)return;const i=h[g];if(n?._id===c._id&&o(),!c.parent)throw new Error("Cannot find parent");const s=new Pt({changedIds:[c._id],typeName:"MergeTranscriptsChange",assembly:a,firstTranscript:l.getSnapshot(c),secondTranscript:l.getSnapshot(i),parentFeatureId:c.parent._id});e.submit(s),t()},children:[i.jsxs(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:[0===Object.keys(h).length?"There are no transcripts to merge with":"Merge with transcript:",i.jsx(s.FormControl,{style:{marginTop:5},children:i.jsx(s.RadioGroup,{"aria-labelledby":"demo-radio-buttons-group-label",name:"radio-buttons-group",value:g,onChange:e=>{f("");const{value:t}=e.target;m(t)},children:Object.keys(h).map((e=>i.jsx(s.FormControlLabel,{value:e,control:i.jsx(s.Radio,{}),label:i.jsx(s.Box,{display:"flex",alignItems:"center",children:tc(h[e])})},e)))})})]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{variant:"contained",type:"submit",disabled:0===Object.keys(h).length||void 0===g,children:"Submit"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:t,children:"Cancel"})]})]}),d?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:d})}):null]})}const rc=ma()((e=>({changeTextarea:{fontFamily:"monospace",width:600,resize:"none",border:`1px solid ${e.palette.divider}`,borderRadius:e.shape.borderRadius}})));function oc(e){const t={};for(const n of e.items)if(void 0!==n.value&&""!==n.value&&null!==n.value)switch(n.field){case"user":t.user=String(n.value);break;case"typeName":t.typeName=String(n.value);break;case"createdAt":{const e=new Date(n.value).toISOString();"after"===n.operator||"onOrAfter"===n.operator?t.startTime=e:"before"!==n.operator&&"onOrBefore"!==n.operator||(t.endTime=e);break}}return t}function ic({handleClose:e,session:t,assembly:n}){const{classes:r}=rc(),[o,a]=u.useState(),[l,c]=u.useState([]),[d,f]=u.useState(0),[h,p]=u.useState(!1),[g,y]=u.useState({page:0,pageSize:15}),[_,v]=u.useState([{field:"sequence",sort:"desc"}]),[b,x]=u.useState({items:[]}),{apolloDataStore:w}=t,{assemblyManager:S}=t,C=S.get(n),A=C?.displayName??n,k=[{field:"sequence"},{field:"typeName",headerName:"Change type",width:200,type:"singleSelect",valueOptions:[...Q.changes.keys()]},{field:"changeData",headerName:"Change JSON",width:600,sortable:!1,filterable:!1,renderCell:({value:e})=>i.jsx("textarea",{className:r.changeTextarea,value:JSON.stringify(e),readOnly:!0})},{field:"user",headerName:"User",width:140},{field:"createdAt",headerName:"Time",width:160,type:"dateTime",valueGetter:e=>e&&new Date(e)}];return u.useEffect((()=>{(async function(){const e=w.getBackendDriver(n);if(!e)return void a(`No driver found for assembly "${n}"`);p(!0);const[t]=_,r=t?.field,o=t?.sort,i="asc"===o||"desc"===o?o:void 0,{changes:s,totalCount:l}=await e.getChanges(n,{page:g.page,pageSize:g.pageSize,sortField:r,sortOrder:i,filters:oc(b)}),u=s.map((e=>{const{sequence:t,typeName:n,changes:r,user:o,createdAt:i,...a}=e;return{sequence:t,typeName:n,changeData:r??{typeName:n,...a},user:o,createdAt:i}}));c(u),f(l)})().catch((e=>{a(String(e))})).finally((()=>{p(!1)}))}),[w,n,g,_,b]),i.jsxs(Bs,{open:!0,fullScreen:!0,title:"View change log",handleClose:e,"data-testid":"view-changelog",children:[i.jsxs(s.DialogContent,{children:[i.jsxs(s.DialogContentText,{children:["Changes for ",A]}),i.jsx(m.DataGrid,{pagination:!0,paginationMode:"server",sortingMode:"server",filterMode:"server",rowCount:d,paginationModel:g,onPaginationModelChange:y,sortModel:_,onSortModelChange:v,filterModel:b,onFilterModelChange:x,loading:h,rows:l,columns:k,getRowId:e=>e.sequence,showToolbar:!0,pageSizeOptions:[5,15,25,50,100],initialState:{columns:{columnVisibilityModel:{sequence:!1}}}})]}),i.jsx(s.DialogActions,{children:i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:e,children:"Close"})}),o?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:o})}):null]})}const ac=[{field:"refName",headerName:"Ref Name"},{field:"aliases",headerName:"Aliases",editable:!0,flex:1}],sc=e=>/^[\da-f]{24}$/i.test(e),lc=p.observer((function({changeManager:e,handleClose:t,session:n}){const r=u.useRef(null),[o,a]=u.useState(""),[l,c]=u.useState(!1),[d,f]=u.useState(),[h,p]=u.useState([]),[g,y]=u.useState((()=>new Map)),{apolloDataStore:_}=n,{collaborationServerDriver:v}=_,b=v.getAssemblies();u.useEffect((()=>{b.length>0&&(f(b[0]),v.getRefNameAliases(b[0].name).then((e=>{x(e)})).catch((()=>{y(new Map),a("Error fetching refName aliases for assembly")})))}),[]);const x=e=>{const t=new Map;for(const n of e){const e=n.refName;sc(e)||t.set(e,n.aliases)}y(t)},w=()=>[...g].map(((e,t)=>({id:t,refName:e[0],aliases:e[1].filter((t=>t!==e[0])).join(", ")})));return i.jsxs(Bs,{open:!0,title:"Add reference sequence aliases",handleClose:t,maxWidth:"sm","data-testid":"add-refseq-alias",fullWidth:!0,children:[i.jsxs(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:[i.jsxs(s.Grid,{container:!0,spacing:2,children:[i.jsx(s.Grid,{children:i.jsxs(s.FormControl,{disabled:l&&!o,fullWidth:!0,children:[i.jsx(s.InputLabel,{id:"demo-simple-select-label",children:"Assembly"}),i.jsx(s.Select,{labelId:"demo-simple-select-label",id:"demo-simple-select",label:"Assembly",value:d?.name??"",onChange:e=>{const t=b.find((t=>t.name===e.target.value));f(t),t?.name&&(v.getRefNameAliases(t.name).then((e=>{x(e),a("")})).catch((()=>{y(new Map),a("Error fetching refName aliases for assembly")})),c(!1),r.current&&(r.current.value=""))},style:{minWidth:150},children:b.map((e=>i.jsx(s.MenuItem,{value:e.name,children:e.displayName},e.name)))})]})}),i.jsxs(s.Grid,{children:[i.jsx(s.InputLabel,{children:"Load RefName alias"}),i.jsx("input",{type:"file",onChange:e=>{(async e=>{if(!e.target.files)return;const t=e.target.files[0],n=(await t.text()).split("\n"),r=new Map(g);a("");for(const e of n){const t=e.split("\t");for(const e of t)r.has(e)&&r.set(e,[...r.get(e)??[],...t])}y(r)})(e).catch((()=>{a("Error reading file")}))},ref:r,disabled:l&&!o||!d})]})]}),d&&g.size>0?i.jsxs("div",{style:{height:200,width:"100%",marginTop:20},children:[i.jsx(s.InputLabel,{children:"Refname aliases found for selected assembly."}),i.jsx(m.DataGrid,{rows:w(),columns:ac,initialState:{pagination:{paginationModel:{page:0,pageSize:5}}},pageSizeOptions:[5,10],onRowSelectionModelChange:e=>{const{ids:t}=e;if(t.size>0){c(!0);const e=[...t.values()].flatMap((e=>w().filter((t=>String(t.id)===String(e)))));p(e)}else c(!1),p([])},processRowUpdate:(e,t)=>{const n=new Map(g);return n.set(e.refName,e.aliases.split(",")),y(n),e},checkboxSelection:!0,disableRowSelectionExcludeModel:!0})]}):null]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{variant:"contained",type:"submit",disabled:!l,onClick:()=>{const n=[];for(const e of h){const{refName:t}=e,r=e.aliases.split(",").map((e=>e.trim())).filter((e=>e.length>0));n.push({refName:t,aliases:r})}if(a(""),!d)return void a("No assembly selected");const r=new bt({typeName:"AddRefSeqAliasesChange",assembly:d.name,refSeqAliases:n});e.submit(r).catch((()=>{a("Error submitting change")})),t()},children:"Submit"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:t,children:"Close"})]}),o?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:o})}):null]})}));function cc({handleClose:e,session:t,assembly:n}){const[r,o]=u.useState(),[a,l]=u.useState([]),{apolloDataStore:c}=t;return u.useEffect((()=>{(async function(){const e=c.getBackendDriver(n);if(!e)return void o(`No driver found for assembly "${n}"`);const t=await e.getCheckResults(n);l(t)})().catch((e=>{o(String(e))}))}),[c,n]),i.jsxs(Bs,{open:!0,fullScreen:!0,title:"View check results",handleClose:e,"data-testid":"view-check-results",children:[i.jsxs(s.DialogContent,{children:[i.jsxs(s.DialogContentText,{children:["Check results for ",n]}),i.jsx(m.DataGrid,{pagination:!0,rows:a,columns:[{field:"_id",headerName:"id",width:50},{field:"name",headerName:"Check name",width:200},{field:"refSeq",headerName:"Reference sequence ID",width:200},{field:"ids",headerName:"Feature IDs",width:200},{field:"message",headerName:"Message",flex:1}],getRowId:e=>e._id,showToolbar:!0,initialState:{sorting:{sortModel:[{field:"name",sort:"asc"}]},columns:{columnVisibilityModel:{name:!0}}}})]}),i.jsx(s.DialogActions,{children:i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:e,children:"Close"})}),r?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:r})}):null]})}function uc(e){return e.max-e.min<2?{isSplittable:!1,comment:"This exon is too short to be split"}:{isSplittable:!0,comment:""}}function dc(e){const t=uc(e);return t.isSplittable?"Are you sure you want to split the selected exon?":t.comment}function fc({changeManager:e,handleClose:t,selectedFeature:n,setSelectedFeature:r,sourceAssemblyId:o,sourceFeature:a}){const[c,d]=u.useState(""),f=l.getSnapshot(a);return i.jsxs(Bs,{open:!0,title:"Split exon",handleClose:t,maxWidth:!1,"data-testid":"split-exon",children:[i.jsxs("form",{onSubmit:function(i){i.preventDefault(),d(""),n?._id===a._id&&r();const s=f.min+(f.max-f.min)/2,l=Math.floor(s),c=Math.ceil(s);if(!a.parent?._id)throw new Error("Splitting an exon without parent is not possible yet");const u=new qt({changedIds:[a._id],typeName:"SplitExonChange",assembly:o,exonToBeSplit:f,parentFeatureId:a.parent._id,upstreamCut:l,downstreamCut:c,leftExonId:(new at).toHexString(),rightExonId:(new at).toHexString()});e.submit(u),t(),i.preventDefault()},children:[i.jsx(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:i.jsx(s.DialogContentText,{children:dc(f)})}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{variant:"contained",type:"submit",disabled:!uc(f).isSplittable,children:"Yes"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:t,children:"Cancel"})]})]}),c?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:c})}):null]})}function hc({changeManager:e,handleClose:t,session:r,sourceAssemblyId:o,sourceFeature:a,setSelectedFeature:c}){const[d,f]=u.useState(""),{notify:h}=r;return i.jsxs(Bs,{open:!0,title:"Duplicate transcript",handleClose:t,maxWidth:!1,"data-testid":"duplicate-transcript",children:[i.jsxs("form",{onSubmit:i=>{!async function(i){i.preventDefault(),f("");try{const i=a.parent;if(!i)return void f("No parent gene found for this transcript");const s=l.getSnapshot(a),u=(new at).toHexString(),d={...s,_id:u};if(d.children){const e={};for(const[,t]of Object.entries(d.children)){const n=(new at).toHexString();e[n]={...t,_id:n}}d.children=e}const p=n.readConfObject(r.getPluginConfiguration(),"skippedAttributesOnCopy");Aa(d,new Set(p??[]));const g=new ht({parentFeatureId:i._id,changedIds:[i._id],typeName:"AddFeatureChange",assembly:o,addedFeature:d});await e.submit(g).then((()=>{c(void 0),r.apolloSetSelectedFeature(u),h("Successfully duplicated transcript","success")})),t()}catch(e){f(e instanceof Error?e.message:"Failed to duplicate transcript")}}(i)},children:[i.jsx(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:i.jsx(s.DialogContentText,{children:"Are you sure you want to create a duplicate of this transcript?"})}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{variant:"contained",type:"submit",children:"Yes"}),i.jsx(s.Button,{variant:"outlined",type:"button",onClick:t,children:"Cancel"})]})]}),d?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:d})}):null]})}var pc=a.createSvgIcon(i.jsx("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 4c1.93 0 3.5 1.57 3.5 3.5S13.93 13 12 13s-3.5-1.57-3.5-3.5S10.07 6 12 6m0 14c-2.03 0-4.43-.82-6.14-2.88C7.55 15.8 9.68 15 12 15s4.45.8 6.14 2.12C16.43 19.18 14.03 20 12 20"}),"AccountCircle"),gc=a.createSvgIcon(i.jsx("path",{d:"M12 7V3H2v18h20V7zM6 19H4v-2h2zm0-4H4v-2h2zm0-4H4V9h2zm0-4H4V5h2zm4 12H8v-2h2zm0-4H8v-2h2zm0-4H8V9h2zm0-4H8V5h2zm10 12h-8v-2h2v-2h-2v-2h2v-2h-2V9h8zm-2-8h-2v2h2zm0 4h-2v2h2z"}),"Business");function mc(e){const{color:t}=e;return i.jsx(s.SvgIcon,{viewBox:"0 0 18 18",style:{fontSize:18,marginRight:4},...e,children:"disabled"===t?i.jsx("path",{d:"M9.001,10.71 l0,-3.348 l8.424,0 c0.126,0.567,0.225,1.098,0.225,1.845 c0,5.139,-3.447,8.793,-8.64,8.793 c-4.968,0,-9,-4.032,-9,-9 c0,-4.968,4.032,-9,9,-9 c2.43,0,4.464,0.891,6.021,2.349 l-2.556,2.484 c-0.648,-0.612,-1.782,-1.332,-3.465,-1.332 c-2.979,0,-5.409,2.475,-5.409,5.508 c0,3.033,2.43,5.508,5.409,5.508 c3.447,0,4.716,-2.385,4.95,-3.798 l-4.959,0 l0,-0.009 z"}):i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M17.64,9.20454545 c0,-0.638,-0.057,-1.252,-0.164,-1.841 l-8.476,0 l0,3.481 l4.844,0 c-0.209,1.125,-0.843,2.079,-1.796,2.717 l0,2.258 l2.908,0 c1.702,-1.567,2.684,-3.874,2.684,-6.615 l0,0 z",fill:"#4285F4"}),i.jsx("path",{d:"M9,18 c2.43,0,4.467,-0.806,5.956,-2.18 l-2.908,-2.259 c-0.806,0.54,-1.837,0.859,-3.048,0.859 c-2.344,0,-4.328,-1.583,-5.036,-3.71 l-3.007,0 l0,2.332 c1.481,2.941,4.525,4.958,8.043,4.958 l0,0 z",fill:"#34A853"}),i.jsx("path",{d:"M3.96409091,10.71 c-0.18,-0.54,-0.282,-1.117,-0.282,-1.71 c0,-0.593,0.102,-1.17,0.282,-1.71 l0,-2.332 l-3.007,0 c-0.609,1.215,-0.957,2.59,-0.957,4.042 c0,1.452,0.348,2.827,0.957,4.042 l3.007,-2.332 l0,0 z",fill:"#FBBC05"}),i.jsx("path",{d:"M9,3.57954545 c1.321,0,2.508,0.454,3.44,1.346 l2.582,-2.581 c-1.559,-1.453,-3.596,-2.345,-6.022,-2.345 c-3.518,0,-6.562,2.017,-8.043,4.959 l3.007,2.331 c0.708,-2.127,2.692,-3.71,5.036,-3.71 l0,0 z",fill:"#EA4335"})]})})}function yc(e){const{color:t}=e;return i.jsxs(s.SvgIcon,{viewBox:"0 0 21 21",style:{fontSize:21},...e,children:[i.jsx("rect",{x:"1",y:"1",width:"9",height:"9",fill:"disabled"===t?"#7B7B7B":"#F25022"}),i.jsx("rect",{x:"1",y:"11",width:"9",height:"9",fill:"disabled"===t?"#7B7B7B":"#00A4EF"}),i.jsx("rect",{x:"11",y:"1",width:"9",height:"9",fill:"disabled"===t?"#939393":"#7FBA00"}),i.jsx("rect",{x:"11",y:"11",width:"9",height:"9",fill:"disabled"===t?"#B9B9B9":"#FFB900"})]})}const _c=ma()((e=>({loginButton:{marginBottom:e.spacing(1),width:"220px",height:"40px",fontSize:"16px",textTransform:"none",justifyContent:"left",padding:"3px 12px"}})));function vc(e){const{classes:t}=_c(),{message:n}=e;return i.jsx(s.Button,{className:t.loginButton,variant:"outlined",startIcon:i.jsx(mc,{}),...e,children:n})}function bc(e){const{classes:t}=_c(),{message:n}=e;return i.jsx(s.Button,{className:t.loginButton,variant:"outlined",startIcon:i.jsx(yc,{}),...e,children:n})}function xc(e){const{classes:t}=_c(),{message:n}=e;return i.jsx(s.Button,{className:t.loginButton,variant:"outlined",startIcon:i.jsx(pc,{fontSize:"small"}),...e,children:n})}function wc(e){const{classes:t}=_c(),{message:n}=e;return i.jsx(s.Button,{className:t.loginButton,variant:"outlined",startIcon:i.jsx(gc,{fontSize:"small"}),...e,children:n})}const Sc=ma()((e=>({divider:{marginTop:e.spacing(4),marginBottom:e.spacing(5)}}))),Cc=({baseURL:e,handleClose:t,name:n})=>{const{classes:r}=Sc(),[o,a]=u.useState(""),[l,c]=u.useState(null);function d(e){t(e)}if(u.useEffect((()=>{const t=new AbortController,{signal:n}=t;return async function(){const t=new URL("auth/types",e).href,r=await fetch(t,{method:"GET",signal:n});if(!r.ok){const e=await dl(r,"Error when retrieving auth types from server");return void a(e)}const o=await r.json();c(o),0===o.length&&a("No login types configured")}().catch((e=>{ts(e)||a(String(e))})),()=>{t.abort(new DOMException("Error retrieving valid authentication types","AbortError"))}}),[e]),null===l)return"Loading…";const f=l.at(0);return f&&1===l.length&&!f.needsPopup&&d(f),i.jsxs(Bs,{open:!0,title:`Log in to ${n}`,handleClose:t,maxWidth:!1,"data-testid":"login-apollo",children:[i.jsx(s.DialogContent,{style:{display:"flex",flexDirection:"column",paddingTop:8},children:l.map((e=>"google"===e.name?i.jsx(vc,{message:e.message,onClick:()=>{d(e)}},e.name):"microsoft"===e.name?i.jsx(bc,{message:e.message,onClick:()=>{d(e)}},e.name):"guest"===e.name?i.jsxs(u.Fragment,{children:[i.jsx(s.Divider,{className:r.divider}),i.jsx(xc,{message:e.message,onClick:()=>{d(e)}})]},e.name):i.jsx(wc,{message:e.message,onClick:()=>{d(e)}},e.name)))}),i.jsx(s.DialogActions,{children:i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:()=>{t()},children:"Cancel"})}),o?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:o})}):null]})},Ac="undefined"==typeof sessionStorage,kc=e=>r.InternetAccount.named("ApolloInternetAccount").props({type:l.types.literal("ApolloInternetAccount"),configuration:n.ConfigurationReference(e)}).views((e=>({get baseURL(){return n.getConf(e,"baseURL")},getUserId(){const t=e.retrieveToken();if(t)return ln(t).id}}))).volatile((()=>({role:void 0,controller:new AbortController,tokenPromise:void 0}))).actions((e=>({setRole(){const t=e.retrieveToken();if(!t)return void(e.role=void 0);const n=ln(t),{role:r,exp:o}=n;if(o<Date.now()/1e3)return e.role=void 0,void e.removeToken();e.role!==r&&(e.role=r)}}))).actions((e=>{const t=e.getFetcher;return{getFetcher(n){const r=t(n);return async(t,n)=>{const o=await r(t,n);return 403===o.status?(e.removeToken(),e.setRole(),r(t,n)):o}}}})).actions((e=>({removeToken(){sessionStorage.removeItem(e.tokenKey),e.tokenPromise=void 0}}))).actions((e=>({async getToken(t){if(e.tokenPromise)return e.tokenPromise;let n=t?.internetAccountPreAuthorization?.authInfo?.token;if(n)return e.tokenPromise=Promise.resolve(n),e.tokenPromise;if(Ac)throw new Error("Did not get internet account pre-authorization info in worker");return n=e.retrieveToken(),n?(e.tokenPromise=Promise.resolve(n),e.tokenPromise):(e.tokenPromise=new Promise(((t,n)=>{e.getTokenFromUser((n=>{e.storeToken(n),t(n)}),(t=>{e.removeToken(),n(t)}))})),e.tokenPromise)}}))).actions((e=>{let t;return{addMessageChannel(e,n){t=t=>{this.finishOAuthWindow(t,e,n)},window.addEventListener("message",t)},deleteMessageChannel(){window.removeEventListener("message",t)},finishOAuthWindow(t,n,r){if(t.data.name!==`JBrowseAuthWindow-${e.internetAccountId}`)return;const o=t.data.redirectUri.replace("#","?"),i=new URL(o),a=new URLSearchParams(i.search).get("access_token");this.deleteMessageChannel(),a?(e.storeToken(a),e.setRole(),n(a)):r(new Error("Error with token endpoint"))},async openAuthWindow(t,n,r){const i=o.isElectron?"http://localhost/auth":globalThis.location.origin+globalThis.location.pathname,a=new URL("auth/login",e.baseURL),s=new URLSearchParams({type:t,redirect_uri:i});a.search=s.toString();const l=`JBrowseAuthWindow-${e.internetAccountId}`;if(o.isElectron){const{ipcRenderer:t}=globalThis.require("electron"),o=await t.invoke("openAuthWindow",{internetAccountId:e.internetAccountId,data:{redirect_uri:i},url:a.toString()}),s=new MessageEvent("message",{data:{name:l,redirectUri:o}});this.finishOAuthWindow(s,n,r)}else this.addMessageChannel(n,r),window.open(a,l,"width=500,height=600")}}})).actions((e=>({async getTokenFromUser(t,n){const{baseURL:r}=e,o=await new Promise(((t,n)=>{const{session:r}=l.getRoot(e),{baseURL:o,name:i}=e;r.queueDialog((e=>[Cc,{name:i,handleClose:r=>{r?r instanceof Error?n(r):t(r):n(new Error("user cancelled entry")),e()},baseURL:o}]))}));if(o.needsPopup)return void e.openAuthWindow(o.name,t,n);const i=new URL("auth/login",r),a=new URLSearchParams({type:o.name});i.search=a.toString();const s=i.toString(),c=await fetch(s,{signal:e.controller.signal});if(!c.ok){const e=await dl(c,"Error when logging in");return void n(new Error(e))}const{token:u}=await c.json();t(u)}}))).volatile((()=>({lastChangeSequenceNumber:void 0}))).actions((e=>({setLastChangeSequenceNumber(t){e.lastChangeSequenceNumber=t}}))).actions((e=>({updateLastChangeSequenceNumber:l.flow((function*(){const{baseURL:t}=e,n=new URL("changes",t),r=new URLSearchParams({limit:"1"});n.search=r.toString();const o=n.toString(),i=e.getFetcher({locationType:"UriLocation",uri:o});let a;try{a=yield i(o,{method:"GET",signal:e.controller.signal})}catch(t){return void(e.controller.signal.aborted||console.error(t))}if(!a.ok){const e=yield dl(a,"Error when fetching server LastChangeSequence");throw new Error(e)}const{changes:s}=yield a.json();e.setLastChangeSequenceNumber(s.length>0?s[0].sequence:0)})),getMissingChanges:l.flow((function*(){const{session:t}=l.getRoot(e),{changeManager:n}=t.apolloDataStore;if(!e.lastChangeSequenceNumber)throw new Error("No LastChangeSequence stored in session. Please, refresh you browser to get last updates from server");const{baseURL:r,lastChangeSequenceNumber:o}=e,i=new URL("changes",r),a=new URLSearchParams({since:String(o),sort:"1"});i.search=a.toString();const s=i.toString(),c=e.getFetcher({locationType:"UriLocation",uri:s});let u;try{u=yield c(s,{method:"GET",signal:e.controller.signal})}catch(t){return void(e.controller.signal.aborted||console.error(t))}if(!u.ok)return void console.error(`Error when fetching the last updates to recover socket connection — ${u.status}`);const{changes:d}=yield u.json();for(const e of d){const t=ee.fromJSON(e);n.submit(t,{submitToBackend:!1})}}))}))).volatile((e=>{const{origin:t,pathname:n}=new URL("socket.io/",e.baseURL);return{socket:so(t,{path:n})}})).actions((e=>({addSocketListeners(){const{session:t}=l.getRoot(e),{notify:n}=t,r=e.retrieveToken();if(!r)throw new Error("No Token found");const o=sn(ln(r)),{socket:i}=e,{addCheckResult:a,changeManager:s,deleteCheckResult:c}=t.apolloDataStore;i.on("connect",(()=>{e.getMissingChanges()})),i.on("connect_error",(e=>{console.error(e),n("Could not connect to the Apollo server.","error")})),i.on("COMMON",(e=>{if("checkResult"in e)return void(e.deleted?c(e.checkResult._id):a(e.checkResult));if(sessionStorage.setItem("LastChangeSequence",String(e.changeSequence)),e.userSessionId===o)return;const t=ee.fromJSON(e.changeInfo);s.submit(t,{submitToBackend:!1})})),i.on("USER_LOCATION",(e=>{const{channel:n,locations:r,userName:i,userSessionId:a}=e;"USER_LOCATION"===n&&a!==o&&t.addOrUpdateCollaborator({name:i,id:a,locations:r})})),i.on("REQUEST_INFORMATION",(e=>{const{channel:n,userSessionId:o}=e;"REQUEST_INFORMATION"===n&&o!==r&&t.broadcastLocations()}))}}))).actions((e=>({postUserLocation:(t=>{let n;return t=>{clearTimeout(n),n=setTimeout((()=>{!async function(t){if(!l.isAlive(e)||"none"===e.role)return;const{baseURL:n,controller:r}=e,o=new URL("users/userLocation",n).href,i=new URLSearchParams(JSON.stringify(t)),a=e.getFetcher({locationType:"UriLocation",uri:o});try{if(!(await a(o,{method:"POST",body:i,signal:r.signal})).ok)throw new Error("ignore")}catch{console.error("Broadcasting user location failed")}}(t)}),300)}})()}))).volatile((()=>({roleNotificationSent:!1}))).actions((e=>{function t(){e.postUserLocation([])}function n(){if("hidden"===document.visibilityState&&e.postUserLocation([]),"visible"===document.visibilityState){const{session:t}=l.getRoot(e);t.broadcastLocations()}}return{initialize:l.flow((function*(r){if("none"===r){if(!e.roleNotificationSent){const{session:t}=l.getRoot(e);t.notify("You have registered as an Apollo user but have not been given access. Ask your administrator to enable access for your account.","warning"),e.roleNotificationSent=!0}return}if("admin"===r){const t=l.getRoot(e);o.isAbstractMenuManager(t)&&function(e){e.appendToMenu("Apollo",{label:"Admin",type:"subMenu",icon:lo,subMenu:[{label:"Add Assembly",icon:Ln,onClick:e=>{e.queueDialog((t=>[gl,{session:e,handleClose:()=>{t()},changeManager:e.apolloDataStore.changeManager}]))}},{label:"Delete Assembly",icon:co,onClick:e=>{e.queueDialog((t=>[El,{session:e,handleClose:()=>{t()},changeManager:e.apolloDataStore.changeManager}]))}},{label:"Import Features",icon:uo,onClick:e=>{e.queueDialog((t=>[Jl,{session:e,handleClose:()=>{t()},changeManager:e.apolloDataStore.changeManager}]))}},{label:"Add reference sequence aliases",onClick:e=>{e.queueDialog((t=>[lc,{session:e,handleClose:()=>{t()},changeManager:e.apolloDataStore.changeManager}]))}},{label:"Add Assembly aliases",onClick:e=>{e.queueDialog((t=>[yl,{session:e,handleClose:()=>{t()},changeManager:e.apolloDataStore.changeManager}]))}},{label:"Manage Users",icon:fo,onClick:e=>{e.queueDialog((t=>[Zl,{session:e,handleClose:()=>{t()},changeManager:e.apolloDataStore.changeManager}]))}},{label:"Manage Checks",icon:ho,onClick:e=>{e.queueDialog((t=>[Yl,{session:e,handleClose:()=>{t()}}]))}}]})}(t)}yield e.updateLastChangeSequenceNumber(),e.addSocketListeners();const{baseURL:i}=e,a=new URL("users/locations",i).href,s=e.getFetcher({locationType:"UriLocation",uri:a});yield s(a,{method:"GET",signal:e.controller.signal}),window.addEventListener("beforeunload",t),document.addEventListener("visibilitychange",n)})),removeBeforeUnloadListener(){window.removeEventListener("beforeunload",t)},removeVisibilityChangeListener(){document.removeEventListener("visibilitychange",n)}}})).actions((e=>({afterAttach(){e.setRole(),c.autorun((async t=>{if(Ac)return;const{session:n}=l.getRoot(e);if(n&&e.role)try{await e.initialize(e.role),t.dispose()}catch{}}),{name:"ApolloInternetAccount"})},beforeDestroy(){e.removeBeforeUnloadListener(),e.removeVisibilityChangeListener(),e.controller.abort(new DOMException("Cleaning up Apollo connection","AbortError")),e.socket.close()}})));var Nc=function(){return crypto.getRandomValues(new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:21)).reduce((function(e,t){return e+((t&=63)<36?t.toString(36):t<62?(t-26).toString(36).toUpperCase():t>62?"-":"_")}),"")};const Tc="undefined"==typeof sessionStorage;class Rc extends _.BaseAdapter{refNameAliasesP;async getRefNameAliases(){if(this.refNameAliasesP)return this.refNameAliasesP;const e=n.readConfObject(this.config,"assemblyId");if(!Tc){const t=this.pluginManager?.rootModel?.session?.apolloDataStore;if(!t)throw new Error("No Apollo data store found");const n=t.getBackendDriver(e);if(!n)throw new Error("No backend driver found");return await n.getRefNameAliases(e)}const t=new Promise(((t,n)=>{const r=setTimeout((()=>{n(new Error("timeout"))}),2e4),o=Nc(),i=e=>{const n=e.data;(function(e){return"object"==typeof e&&null!==e&&"apollo"in e&&!0===e.apollo&&"refNameAliases"in e})(n)&&n.messageId===o&&(clearTimeout(r),removeEventListener("message",i),t(n.refNameAliases))};addEventListener("message",i),rpcServer.emit("apollo",{apollo:!0,method:"getRefNameAliases",assembly:e,messageId:o})}));return this.refNameAliasesP=t,t}freeResources(){}}var Ec=n.ConfigurationSchema("ApolloRefNameAliasAdapter",{assemblyId:{type:"string",defaultValue:""}},{explicitlyTyped:!0});function Ic(e){return"uniqueId"in e&&"object"!==K(e.data)}var jc=function(){function e(t){var n=this;R(this,e),D(this,"data",void 0),D(this,"subfeatures",void 0),D(this,"parentHandle",void 0),D(this,"uniqueId",void 0),Ic(t)?this.data=t:(this.data=t.data,this.parentHandle=t.parent);var r,o=Ic(t)?t.uniqueId:t.id;if(null==o)throw new Error("SimpleFeature requires a unique `id` or `data.uniqueId` attribute");if(this.uniqueId=String(o),!(this.data.aliases||this.data.end-this.data.start>=0))throw new Error("invalid feature data, end less than start. end: ".concat(this.data.end," start: ").concat(this.data.start));this.data.subfeatures&&(this.subfeatures=null===(r=this.data.subfeatures)||void 0===r?void 0:r.map((function(t,r){return"function"!=typeof t.get?new e({id:t.uniqueId||"".concat(o,"-").concat(r),data:B({strand:n.data.strand},t),parent:n}):t})))}return I(e,[{key:"get",value:function(e){return"subfeatures"===e?this.subfeatures:"parent"===e?this.parent():this.data[e]}},{key:"set",value:function(e,t){this.data[e]=t}},{key:"tags",value:function(){return Object.keys(this.data)}},{key:"id",value:function(){return this.uniqueId}},{key:"parent",value:function(){return this.parentHandle}},{key:"children",value:function(){return this.get("subfeatures")}},{key:"toJSON",value:function(){var e=B(B({},this.data),{},{uniqueId:this.id()}),t=this.parent();t&&(e.parentId=t.id());var n=this.children();return n&&(e.subfeatures=n.map((function(e){return e.toJSON()}))),e}}],[{key:"fromJSON",value:function(t){return new e(B({},t))}}])}();function Dc(e){return"object"==typeof e&&null!==e&&"apollo"in e&&!0===e.apollo}const Oc="undefined"==typeof sessionStorage;class Fc extends _.BaseSequenceAdapter{regions;async getRefNames(){return(await this.getRegions()).map((e=>e.refName))}async getRegions(){if(this.regions)return this.regions;const e=n.readConfObject(this.config,"assemblyId");if(!Oc){const t=this.pluginManager?.rootModel?.session?.apolloDataStore;if(!t)throw new Error("No Apollo data store found");const n=t.getBackendDriver(e);if(!n)throw new Error("No backend driver found");const r=await n.getRegions(e);return this.regions=r,r}const t=await new Promise(((t,n)=>{const r=setTimeout((()=>{n("timeout")}),2e4),o=Nc(),i=e=>{const{data:n}=e;Dc(n)&&n.messageId===o&&(clearTimeout(r),removeEventListener("message",i),t(n.regions))};addEventListener("message",i),globalThis.rpcServer.emit("apollo",{apollo:!0,method:"getRegions",assembly:e,messageId:o})}));return this.regions=t,t}getFeatures(e){const{end:t,refName:r,start:o}=e,i=n.readConfObject(this.config,"assemblyId"),a={...e,assemblyName:i};return v.ObservableCreate((async e=>{if(!Oc){const n=this.pluginManager?.rootModel?.session?.apolloDataStore;if(!n)return void e.error("No Apollo data store found");const s=n.getBackendDriver(i);if(!s)return void e.error("No backend driver found");const l=(await s.getRegions(a.assemblyName)).find((e=>e.refName===a.refName));if(!l)return void e.error("Cannot get region");a.end>l.end&&(a.end=l.end);const{seq:c}=await s.getSequence(a);return e.next(new jc({id:`${r} ${o}-${t}`,data:{refName:r,start:o,end:t,seq:c}})),void e.complete()}const n=await new Promise(((e,t)=>{const n=setTimeout((()=>{t("timeout")}),2e4),r=Nc(),o=t=>{const{data:i}=t;Dc(i)&&i.messageId===r&&(clearTimeout(n),removeEventListener("message",o),e(i.sequence))};addEventListener("message",o),globalThis.rpcServer.emit("apollo",{apollo:!0,method:"getSequence",region:a,messageId:r})}));e.next(new jc({id:`${r} ${o}-${t}`,data:{refName:r,start:o,end:t,seq:n}})),e.complete()}))}freeResources(){}}var Mc=n.ConfigurationSchema("ApolloSequenceAdapter",{assemblyId:{type:"string",defaultValue:""}},{explicitlyTyped:!0}),Lc=function(){return I((function e(t){R(this,e),D(this,"label",void 0),D(this,"renderingComponent",void 0),D(this,"displayString",void 0),D(this,"matchedAttribute",void 0),D(this,"matchedObject",void 0),D(this,"textSearchAdapter",void 0),D(this,"relevance",void 0),D(this,"trackId",void 0),D(this,"score",void 0),D(this,"locString",void 0),D(this,"results",void 0),this.label=t.label,this.locString=t.locString,this.renderingComponent=t.renderingComponent,this.displayString=t.displayString,this.matchedAttribute=t.matchedAttribute,this.matchedObject=t.matchedObject,this.textSearchAdapter=t.textSearchAdapter,this.relevance=t.relevance,this.trackId=t.trackId,this.score=t.score||1,this.results=t.results||[]}),[{key:"getLabel",value:function(){return this.label}},{key:"getDisplayString",value:function(){return this.displayString||this.label}},{key:"getRenderingComponent",value:function(){return this.renderingComponent}},{key:"getTrackId",value:function(){return this.trackId}},{key:"getScore",value:function(){return this.score}},{key:"updateScore",value:function(e){return this.score=e,this.score}},{key:"getId",value:function(){return"".concat(this.getLabel(),"-").concat(this.getLocation(),"-").concat(this.getTrackId())}},{key:"hasLocation",value:function(){return!!this.locString}},{key:"getLocation",value:function(){return this.locString}},{key:"getComboResults",value:function(){return this.results}}])}();function Pc(e,t){const{children:n,indexedIds:r,allIds:o,...i}=t;if(JSON.stringify(i).includes(e))return t;if(n)for(const t of Object.values(n)){const n=Pc(e,t);if(n)return n}}class Bc extends _.BaseAdapter{get baseURL(){return n.readConfObject(this.config,"baseURL").uri}get trackId(){return n.readConfObject(this.config,"trackId")}get assemblyNames(){return n.readConfObject(this.config,"assemblyNames")}mapBaseResult(e,t,n){return e.map((e=>{const r=Pc(n,e)??e,o=t.getCanonicalRefName(e.refSeq);return new Lc({label:n,trackId:this.trackId,locString:`${o}:${r.min+1}..${r.max}`,matchedObject:r})}))}async searchIndex(e){const t=e.queryString,n=[],r=this.pluginManager?.rootModel?.session;if(!r)return n;const{apolloDataStore:o}=r,{assemblyManager:i}=r;for(const r of this.assemblyNames){const a=o.getBackendDriver(r),s=i.get(r);if(!a||!s)continue;const l=await a.searchFeatures(e.queryString,[r]);n.push(...this.mapBaseResult(l,s,t))}return n}freeResources(){}}var qc=n.ConfigurationSchema("ApolloTextSearchAdapter",{assemblyNames:{type:"stringArray",defaultValue:[],description:"List of assemblies covered by text search adapter"},trackId:{type:"string",defaultValue:""},baseURL:{type:"fileLocation",defaultValue:{uri:"",locationType:"UriLocation"}}},{explicitlyTyped:!0,explicitIdentifier:"textSearchAdapterId"}),Uc=a.createSvgIcon(i.jsx("path",{d:"M16.59 8.59 12 13.17 7.41 8.59 6 10l6 6 6-6z"}),"ExpandMore"),zc=a.createSvgIcon(i.jsx("path",{d:"M3 17.25V21h3.75L17.81 9.94l-3.75-3.75zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34a.996.996 0 0 0-1.41 0l-1.83 1.83 3.75 3.75z"}),"Edit"),$c=a.createSvgIcon(i.jsx("path",{d:"M6 10c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m12 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m-6 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2"}),"MoreHoriz");const Hc=ma()((e=>({attributeKey:{fontWeight:"bold",marginRight:e.spacing(2)}})));function Gc({attributeKey:e}){const{classes:t}=Hc(),n=/^[A-Z]/.test(e);let r,o=e;return e in Dn?(o=Dn[e],r=`On GFF3 export, this will be assigned to the GFF3's reserved "${o}" attribute`):function(e){return e in On}(e)?(o=On[e],r=`On GFF3 export, this will be placed in the GFF3's "${o}" column`):n&&(r="On GFF3 export, this attribute will be changed to start with a lower-case letter because attributes starting with an upper-case letter are reserved in GFF3"),i.jsxs("div",{style:{display:"flex"},children:[i.jsx(s.Typography,{className:t.attributeKey,children:o}),r?i.jsx(s.Tooltip,{title:r,children:i.jsx(s.Chip,{icon:i.jsx(ya,{}),label:"GFF3",size:"small",variant:"outlined"})}):null]})}const Vc="Custom",Wc={[Vc]:"custom"};for(const[e,t]of Object.entries(jn))Wc[`GFF ${t}`]=e;for(const[e,t]of Object.entries({score:"gff_score",source:"gff_source"}))Wc[`GFF ${t}`]=e;const Jc=p.observer((function({setKey:e,session:t}){const{pluginManager:n}=o.getEnv(t),r=n.evaluateExtensionPoint("Apollo-ReservedAttributeKeys",Wc),a=Object.keys(r).at(0)??Vc,[l,c]=u.useState(a),[d,f]=u.useState(),h=l===Vc;return i.jsxs("form",{onSubmit:function(t){t.preventDefault(),e(h?d:r[l])},children:[i.jsxs("div",{style:{display:"flex",flexDirection:"column",margin:8},children:[i.jsxs(s.FormControl,{variant:"outlined",children:[i.jsx(s.InputLabel,{id:"attribute-key-select-label",children:"Key"}),i.jsx(s.Select,{labelId:"attribute-key-select-label",value:l,label:"Key",onChange:e=>{c(e.target.value)},children:Object.keys(r).map((e=>i.jsx(s.MenuItem,{value:e,children:e},e)))})]}),h?i.jsx(s.TextField,{label:"Attribute key",variant:"outlined",id:"attributeKey",onChange:e=>{f(e.target.value)}}):null]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{color:"primary",variant:"contained",type:"submit",disabled:h&&!d,children:"Add"}),i.jsx(s.Button,{variant:"outlined",onClick:function(){e()},children:"Cancel"})]})]})}));var Kc=a.createSvgIcon(i.jsx("path",{d:"M19 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2m-2 10h-4v4h-2v-4H7v-2h4V7h2v4h4z"}),"AddBox");const Yc=p.observer((function({onChangeCommitted:e,value:t,...n}){const[r,o]=u.useState(String(t)),[a,l]=u.useState(!1),[c,d]=u.useState(null);return u.useEffect((()=>{o(String(t))}),[t]),u.useEffect((()=>{a&&(c?.blur(),l(!1))}),[a,c]),i.jsx(s.TextField,{...n,type:"text",onChange:function(e){o(e.target.value)},value:r,onKeyDown:e=>{"Enter"===e.key?c?.blur():"Escape"===e.key&&(o(String(t)),l(!0))},onBlur:()=>{r!==String(t)&&e(r)},inputRef:e=>{d(e)}})})),Xc=p.observer((function({attributeValues:e,setAttribute:t,isNew:n=!1}){const[r,o]=u.useState(e&&e.length>0?e:[""]);return i.jsxs(i.Fragment,{children:[r.map(((e,t)=>i.jsxs("div",{style:{display:"flex"},children:[i.jsx(Yc,{value:e,onChangeCommitted:e=>{!function(e,t){o((n=>{const r=[...n];return r[e]=t,r}))}(t,e)},variant:"outlined",fullWidth:!0}),i.jsx(s.IconButton,{"aria-label":"delete",size:"medium",edge:"end",onClick:()=>{!function(e){o((t=>{const n=[...t];return n.splice(e,1),n}))}(t)},children:i.jsx(co,{fontSize:"inherit"})})]},`${t}-${e}`))),i.jsx(s.IconButton,{"aria-label":"add",size:"medium",color:"secondary",edge:"start",onClick:function(){o((e=>{const t=[...e];return t.push(""),t}))},children:i.jsx(Kc,{fontSize:"inherit"})}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{color:"primary",variant:"contained",onClick:()=>{t(r.filter(Boolean))},children:n?"Add":"Update"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:()=>{t()},children:"Cancel"})]})]})}));function Zc({values:e}){return i.jsx(i.Fragment,{children:e?.map(((e,t)=>i.jsx(s.Typography,{variant:"body2",color:"textSecondary",children:e},`${t}.${e}`)))})}const Qc=ma()((e=>({list:{"li:nth-of-type(odd)":{backgroundColor:e.palette.action.focus},"li:nth-of-type(even)":{backgroundColor:e.palette.action.hover}}}))),eu=p.observer((function({assembly:e,editable:t,feature:n,session:r}){const{pluginManager:a}=o.getEnv(r),{classes:d}=Qc(),[f,h]=u.useState(null),[p,g]=u.useState(null),[m,y]=u.useState(null),[_,v]=u.useState(!1),[b,x]=u.useState(),w=Boolean(f),{changeManager:S}=r.apolloDataStore,{notify:C}=r;function A(){h(null),g(null)}const{_id:k,attributes:N}=n,T=a.evaluateExtensionPoint("Apollo-AttributeEditorComponent",Xc,{key:b});return i.jsxs(i.Fragment,{children:[i.jsxs(s.List,{className:d.list,children:[c.entries(N).map((([o,c])=>{const u=a.evaluateExtensionPoint("Apollo-AttributeEditorComponent",Xc,{key:o}),d=a.evaluateExtensionPoint("Apollo-AttributeViewerComponent",Zc,{key:o});return i.jsx(s.ListItem,{secondaryAction:t&&!m?i.jsx(s.IconButton,{edge:"end",onClick:e=>{!function(e,t){h(e.currentTarget),g(t)}(e,o)},children:i.jsx($c,{})}):null,children:i.jsx(s.ListItemText,{disableTypography:!0,primary:i.jsx(Gc,{attributeKey:o}),secondary:m===o?i.jsx(u,{session:r,attributeValues:c,setAttribute:t=>{y(null),t&&function(t,r){const o={...l.getSnapshot(N)},i=structuredClone(o);if(!(t in o))return void C(`"${t}" not found in feature attributes`,"error");if(o[t].toString()===r.toString())return;o[t]=r;const a=new St({changedIds:[n._id],typeName:"FeatureAttributeChange",assembly:e,featureId:n._id,oldAttributes:i,newAttributes:o});S.submit(a)}(o,t)}}):i.jsx(d,{values:c})})},o)})),b?i.jsx(s.ListItem,{children:i.jsx(s.ListItemText,{disableTypography:!0,primary:i.jsx(Gc,{attributeKey:b}),secondary:i.jsx(T,{session:r,attributeValues:[],setAttribute:t=>{t&&function(t,r){const o={...l.getSnapshot(N)},i=structuredClone(o);if(t in o)return void C(`Feature already has attribute "${t}"`,"error");o[t]=r;const a=new St({changedIds:[n._id],typeName:"FeatureAttributeChange",assembly:e,featureId:n._id,oldAttributes:i,newAttributes:o});S.submit(a)}(b,t),x(void 0)},isNew:!0})})}):null]}),t?i.jsx(s.Button,{color:"primary",variant:"contained",disabled:_||Boolean(b),onClick:()=>{v(!0)},children:"Add new"}):null,_?i.jsx(s.Paper,{variant:"outlined",style:{marginTop:8},children:i.jsx(Jc,{session:r,setKey:e=>{x(e),v(!1)}})}):null,i.jsxs(s.Menu,{anchorEl:f,open:w,onClose:A,children:[i.jsxs(s.MenuItem,{onClick:function(){p&&function(t){const n=l.getSnapshot(N),{[t]:r,...o}=n,i=new St({changedIds:[k],typeName:"FeatureAttributeChange",assembly:e,featureId:k,oldAttributes:n,newAttributes:o});S.submit(i)}(p),A()},children:[i.jsx(s.ListItemIcon,{children:i.jsx(co,{fontSize:"small"})}),i.jsx(s.Typography,{variant:"inherit",children:"Delete"})]}),i.jsxs(s.MenuItem,{onClick:function(){p&&y(p),A()},children:[i.jsx(s.ListItemIcon,{children:i.jsx(zc,{fontSize:"small"})}),i.jsx(s.Typography,{variant:"inherit",children:"Edit"})]})]})]})})),tu=p.observer((function({onChangeCommitted:e,value:t,...n}){const[r,o]=u.useState(String(t)),[a,l]=u.useState(!1),[c,d]=u.useState(null);u.useEffect((()=>{o(String(t))}),[t]),u.useEffect((()=>{a&&(c?.blur(),l(!1))}),[a,c]);const f=Number.isNaN(Number(r));return i.jsx(s.TextField,{...n,type:"text",onChange:function(e){o(e.target.value)},value:r,onKeyDown:e=>{"Enter"===e.key?c?.blur():"Escape"===e.key&&(o(String(t)),l(!0))},onBlur:()=>{const n=Number(r);r!==String(t)&&(Number.isNaN(n)?o(String(t)):e(n)||o(String(t)))},inputRef:e=>{d(e)},error:f,helperText:f?"Not a valid number":void 0})})),nu=p.observer((function({assembly:e,feature:t,session:n}){const[r,o]=u.useState(""),[a,l]=u.useState(""),{_id:c,assemblyId:d,max:f,min:h,strand:p,type:g}=t,m=e=>{n.notify(e.message,"error")},{changeManager:y}=n.apolloDataStore;function _(t){const{value:n}=t.target,r=n?Number(n):void 0,o=new zt({typeName:"StrandChange",changedIds:[c],featureId:c,oldStrand:p,newStrand:r,assembly:e});return y.submit(o)}return i.jsxs("div",{"data-testid":"basic_information",children:[i.jsx(tu,{margin:"dense",id:"start",label:"Start",fullWidth:!0,variant:"outlined",value:h+1,onChangeCommitted:function(t){t--;const n=new Et({typeName:"LocationStartChange",changedIds:[c],featureId:c,oldStart:h,newStart:t,assembly:e});return y.submit(n),!0}}),i.jsx(tu,{margin:"dense",id:"end",label:"End",fullWidth:!0,variant:"outlined",value:f,onChangeCommitted:function(t){const n=new Tt({typeName:"LocationEndChange",changedIds:[c],featureId:c,oldEnd:f,newEnd:t,assembly:e});return y.submit(n),!0}}),i.jsx(qs,{session:n,ontologyName:"Sequence Ontology",value:g,filterTerms:Cs,fetchValidTerms:async function(e,t,n){const r=await Ms(e,t);if(r)return r;l(`Type "${e?.type}" does not have any children in the ontology`)}.bind(null,t),renderInput:e=>i.jsx(s.TextField,{...e,label:"Type",variant:"outlined",fullWidth:!0,error:Boolean(a),helperText:a}),onChange:(e,t)=>{t&&function(e){o("");const t=new $t({typeName:"TypeChange",changedIds:[c],featureId:c,oldType:g,newType:e,assembly:d});return y.submit(t)}(t).catch(m)}}),i.jsxs("label",{children:[i.jsx("input",{type:"radio",value:"1",checked:1===p,onChange:_}),"Positive Strand (+)"]}),i.jsxs("label",{children:[i.jsx("input",{type:"radio",value:"-1",checked:-1===p,onChange:_}),"Negative Strand (-)"]}),i.jsxs("label",{children:[i.jsx("input",{type:"radio",value:"",checked:void 0===p,onChange:_}),"No Strand Information"]}),r?i.jsx(s.Typography,{color:"error",children:r}):null]})})),ru=p.observer((function(e){const{feature:t,model:n}=e,{children:r,parent:o}=t,a=[];if(r)for(const[,e]of r)a.push(e);return o??a.length>0?i.jsxs("div",{style:{marginTop:10},children:[o&&i.jsxs("div",{children:[i.jsx(s.Typography,{variant:"h6",children:"Parent:"}),i.jsxs(s.Button,{variant:"contained",onClick:()=>{n.setFeature(o)},children:[o.type,Sa(o)," (",o.min,"..",o.max,")"]})]}),a.length>0&&i.jsxs("div",{children:[i.jsxs(s.Typography,{variant:"h6",children:[1===a.length?"Child":"Children",":"]}),a.map((e=>i.jsx("div",{style:{marginBottom:5},children:i.jsxs(s.Button,{variant:"contained",onClick:()=>{n.setFeature(e)},children:[e.type,Sa(e)," (",e.min,"..",e.max,")"]})},e._id)))]})]}):null})),ou=ma()({sequence:{width:"100%",resize:"vertical"}}),iu=p.observer((function({assembly:e,feature:t,refName:n,session:r}){const o=r.apolloDataStore.assemblies.get(e),{classes:a}=ou();if(!t||!o)return null;const s=o.getByRefName(n);if(!s)return null;const{max:l,min:c}=t;let u=s.getSequence(c,l);return u?u=function(e,t,n,r,o){return`>${t}:${n+1}–${r}\n${e}`}(u,n,c,l):r.apolloDataStore.loadRefSeq([{assemblyName:e,refName:n,start:c,end:l}]),i.jsx("div",{children:i.jsx("textarea",{readOnly:!0,rows:20,className:a.sequence,value:u})})})),au=ma()((e=>({root:{padding:e.spacing(2)}}))),su=p.observer((function(e){const{model:t}=e,{assembly:n,feature:r,refName:a}=t,l=o.getSession(t),c=l.apolloDataStore.assemblies.get(n),{classes:d}=au(),[f,h]=u.useState(["attributes"]);if(u.useEffect((()=>{h(["attributes"])}),[r]),!r||!c)return null;const p=c.getByRefName(a);if(!p)return null;const{max:g,min:m}=r;function y(e,t){h(e?[...f,t]:f.filter((e=>e!==t)))}return p.getSequence(m,g)||l.apolloDataStore.loadRefSeq([{assemblyName:n,refName:a,start:m,end:g}]),i.jsxs("div",{className:d.root,children:[i.jsx(nu,{feature:r,session:l,assembly:c._id}),i.jsxs(s.Accordion,{style:{marginTop:10},expanded:f.includes("attributes"),onChange:(e,t)=>{y(t,"attributes")},children:[i.jsx(s.AccordionSummary,{expandIcon:i.jsx(Uc,{style:{color:"white"}}),"aria-controls":"panel1-content",id:"panel1-header",children:i.jsx(s.Typography,{component:"span",children:"Attributes"})}),i.jsx(s.AccordionDetails,{children:i.jsx(eu,{feature:r,session:l,assembly:c._id,editable:!0})})]}),i.jsxs(s.Accordion,{style:{marginTop:10},expanded:f.includes("sequence"),onChange:(e,t)=>{y(t,"sequence")},children:[i.jsx(s.AccordionSummary,{expandIcon:i.jsx(Uc,{style:{color:"white"}}),"aria-controls":"panel2-content",id:"panel2-header",children:i.jsx(s.Typography,{component:"span",children:"Sequence"})}),i.jsx(s.AccordionDetails,{children:f.includes("sequence")&&i.jsx(iu,{feature:r,session:l,assembly:c._id,refName:a})})]}),i.jsxs(s.Accordion,{style:{marginTop:10},expanded:f.includes("related_features"),onChange:(e,t)=>{y(t,"related_features")},children:[i.jsx(s.AccordionSummary,{expandIcon:i.jsx(Uc,{style:{color:"white"}}),"aria-controls":"panel3-content",id:"panel3-header",children:i.jsx(s.Typography,{component:"span",children:"Related features"})}),i.jsx(s.AccordionDetails,{children:i.jsx(ru,{model:t,feature:r})})]})]})}));var lu=l.types.late((function(){return cu})),cu=l.types.model("AnnotationFeatureModel",{_id:l.types.identifier,refSeq:l.types.string,type:l.types.string,min:l.types.number,max:l.types.number,strand:l.types.maybe(l.types.union(l.types.literal(1),l.types.literal(-1))),children:l.types.maybe(l.types.map(lu)),attributes:l.types.map(l.types.array(l.types.string))}).views((function(e){return{get length(){return e.max-e.min},get featureId(){return e.attributes.get("id")},get minWithChildren(){var t=e.min,n=e.children;if(!n)return t;var r,o=j(n);try{for(o.s();!(r=o.n()).done;){var i=G(r.value,2);t=Math.min(t,i[1].min)}}catch(e){o.e(e)}finally{o.f()}return t},get maxWithChildren(){var t=e.max,n=e.children;if(!n)return t;var r,o=j(n);try{for(o.s();!(r=o.n()).done;){var i=G(r.value,2);t=Math.max(t,i[1].max)}}catch(e){o.e(e)}finally{o.f()}return t},hasDescendant:function(t){var n=e.children;if(!n)return!1;var r,o=j(n);try{for(o.s();!(r=o.n()).done;){var i=G(r.value,2);if(i[0]===t)return!0;if(i[1].hasDescendant(t))return!0}}catch(e){o.e(e)}finally{o.f()}return!1},get transcriptExonParts(){var t=o.getSession(e).apolloDataStore.ontologyManager.featureTypeOntology;if(!t.isTypeOf(e.type,"transcript")&&!t.isTypeOf(e.type,"pseudogenic_transcript"))throw new Error("Feature is not a transcript or equivalent, cannot calculate exon locations");var n=e.children;if(!n)throw new Error("No exons in transcript");var r,i=W(n.values()).filter((function(e){return t.isTypeOf(e.type,"exon")})).sort((function(e,t){return e.min-t.min})),a=e.min,s=[],l=j(i);try{for(l.s();!(r=l.n()).done;){var c=r.value;c.min>a&&s.push({min:a,max:c.min,type:"intron"}),s.push({min:c.min,max:c.max,type:"exon"}),a=c.max}}catch(e){l.e(e)}finally{l.f()}return a<e.max&&s.push({min:a,max:e.max,type:"intron"}),-1===e.strand&&s.reverse(),s},get transcriptParts(){var t=o.getSession(e).apolloDataStore.ontologyManager.featureTypeOntology;if(!t.isTypeOf(e.type,"transcript")&&!t.isTypeOf(e.type,"pseudogenic_transcript"))throw new Error('Only features of type "transcript" or equivalent can calculate CDS locations');var n=e.children;if(!n)throw new Error("no CDS or exons in transcript");var r=W(n.values()).filter((function(e){return t.isTypeOf(e.type,"CDS")})),i=[];if(0===r.length)return i.push(this.transcriptExonParts),i;var a,s=j(r);try{var l=function(){var r,s=a.value,l=s.max,c=s.min,u=[],d=!1,f=[],h=j(n);try{for(h.s();!(r=h.n()).done;){var p=G(r.value,2)[1];t.isTypeOf(p.type,"exon")&&f.push({min:p.min,max:p.max})}}catch(e){h.e(e)}finally{h.f()}f.sort((function(e,t){return e.min-t.min}));for(var g=0,m=f;g<m.length;g++){var y=m[g],_=u.at(-1);_&&u.push({min:_.max,max:y.min,type:"intron"});var v,b=G(o.intersection2(c,l,y.min,y.max),2),x=b[0],w=b[1];v=d?1===e.strand?"threePrimeUTR":"fivePrimeUTR":1===e.strand?"fivePrimeUTR":"threePrimeUTR",void 0!==x&&void 0!==w?(d=!0,x===y.min&&w===y.max?u.push({min:x,max:w,phase:0,type:"CDS"}):x===y.min?u.push({min:x,max:w,phase:0,type:"CDS"},{min:w,max:y.max,type:v}):w===y.max?u.push({min:y.min,max:x,type:v},{min:x,max:w,phase:0,type:"CDS"}):u.push({min:y.min,max:x,type:v},{min:x,max:w,phase:0,type:"CDS"},{min:w,max:y.max,type:"fivePrimeUTR"===v?"threePrimeUTR":"fivePrimeUTR"})):u.push({min:y.min,max:y.max,type:v})}u.sort((function(e,t){return e.min-t.min})),-1===e.strand&&u.reverse();var S=0,C=u.map((function(e){if("CDS"!==e.type)return e;var t=S;return S=(3-(e.max-e.min-t+3)%3)%3,B(B({},e),{},{phase:t})}));i.push(C)};for(s.s();!(a=s.n()).done;)l()}catch(e){s.e(e)}finally{s.f()}return i}}})).views((function(e){return{get cdsLocations(){return e.transcriptParts.map((function(e){return e.filter((function(e){return"CDS"===e.type}))}))}}})).actions((function(e){return{setAttributes:function(t){e.attributes.clear();var n,r=j(t.entries());try{for(r.s();!(n=r.n()).done;){var o=G(n.value,2);e.attributes.set(o[0],o[1])}}catch(e){r.e(e)}finally{r.f()}},setAttribute:function(t,n){e.attributes.merge(D({},t,n))},setType:function(t){e.type=t},setRefSeq:function(t){e.refSeq=t},setMin:function(t){if(t>e.max)throw new Error('Min "'.concat(t+1,'" is greater than max "').concat(e.max,'"'));e.min!==t&&(e.min=t)},setMax:function(t){if(t<e.min)throw new Error('Max "'.concat(t,'" is less than Min "').concat(e.min,'"'));e.max!==t&&(e.max=t)},setStrand:function(t){e.strand=t},addChild:function(t){if(e.children&&e.children.size>0){var n=l.getSnapshot(e.children);e.children.clear();var r,o=j(Object.entries(B(B({},n),{},D({},t._id,t))).sort((function(e,t){var n=G(e,2)[1],r=G(t,2);return n.min-r[1].min})));try{for(o.s();!(r=o.n()).done;){var i=G(r.value,2);e.children.put(i[1])}}catch(e){o.e(e)}finally{o.f()}}else{var a;e.children=l.cast({}),null===(a=e.children)||void 0===a||a.put(t)}},deleteChild:function(t){var n;null===(n=e.children)||void 0===n||n.delete(t)}}})).actions((function(e){return{update:function(t){var n=t.children,r=t.max,o=t.min,i=t.strand;e.setRefSeq(t.refSeq),e.setMin(o),e.setMax(r),e.setStrand(i),n&&(e.children=l.cast(n))}}})).views((function(e){return{get parent(){var t;try{t=l.getParentOfType(e,cu)}catch(e){}return t},get topLevelFeature(){var t,n=e;do{try{n=t=l.getParentOfType(n,cu)}catch(e){t=void 0}}while(t);return n},get assemblyId(){for(var t=e;l.hasParent(t);)if("refSeqs"in(t=l.getParent(t))&&"_id"in t)return t._id;throw new Error("AnnotationFeatureModel: could not find parent ApolloAssembly")}}})),uu=l.types.model({start:l.types.number,stop:l.types.number,sequence:l.types.string}),du=l.types.model("ApolloRefSeq",{_id:l.types.identifier,name:l.types.string,description:"",features:l.types.map(cu),sequence:l.types.array(uu)}).actions((function(e){return{addFeature:function(t){e.features.put(t)},deleteFeature:function(t){return e.features.delete(t)},setDescription:function(t){e.description=t},addSequence:function(t){var n;if(t.sequence.length!==t.stop-t.start)throw new Error("sequence does not match declared length: ".concat(JSON.stringify(t)));if(0!==e.sequence.length){var r=e.sequence.map((function(e){return{start:e.start,stop:e.stop,sequence:e.sequence}}));r.push({start:t.start,stop:t.stop,sequence:t.sequence}),r.sort((function(e,t){return e.start===t.start?e.stop-t.stop:e.start-t.start}));var o,i=r.reduce((function(e,t){var n=e.at(-1);if(void 0===n)return[t];if(n.stop>=t.start){if(t.stop>n.stop){var r=n.stop-t.start;n.stop=t.stop,n.sequence+=t.sequence.slice(r)}}else e.push(t);return e}),[]),a=j(i);try{for(a.s();!(o=a.n()).done;){var s=o.value;if(s.sequence.length!==s.stop-s.start)throw new Error("Consolidated sequence does not match declared length")}}catch(e){a.e(e)}finally{a.f()}e.sequence.length===i.length&&e.sequence.every((function(e,t){var n;return e.start===(null===(n=i[t])||void 0===n?void 0:n.start)&&e.stop===i[t].stop}))||(e.sequence.clear(),(n=e.sequence).push.apply(n,W(i)))}else e.sequence.push(t)}}})).views((function(e){return{getSequence:function(t,n){var r,i=j(e.sequence);try{for(i.s();!(r=i.n()).done;){var a=r.value,s=a.sequence,l=a.start;if(o.isContainedWithin(t,n,l,a.stop))return s.slice(t-l,n-l)}}catch(e){i.e(e)}finally{i.f()}return""},getFeatures:function(t,n){var r,i=[],a=j(e.features);try{for(a.s();!(r=a.n()).done;){var s=G(r.value,2)[1];o.doesIntersect2(s.min,s.max,t,n)&&i.push(s)}}catch(e){a.e(e)}finally{a.f()}return i}}})),fu=l.types.model("ApolloAssembly",{_id:l.types.identifier,refSeqs:l.types.map(du),comments:l.types.array(l.types.string),backendDriverType:l.types.optional(l.types.enumeration("backendDriverType",["CollaborationServerDriver","LocalDriver"]),"CollaborationServerDriver")}).views((function(e){return{getByRefName:function(t){return W(e.refSeqs.values()).find((function(e){return e.name===t}))}}})).actions((function(e){return{addRefSeq:function(t,n,r){return e.refSeqs.put({_id:t,name:n,description:r})},addComment:function(t){return e.comments.push(t)}}})),hu=l.types.model("CheckResult",{_id:l.types.identifier,name:l.types.string,cause:l.types.string,ids:l.types.array(l.types.safeReference(cu)),refSeq:l.types.string,start:l.types.number,end:l.types.number,ignored:!1,message:l.types.string});const pu=l.types.model("ApolloFeatureDetailsWidget",{id:d.ElementId,type:l.types.literal("ApolloFeatureDetailsWidget"),feature:l.types.maybe(l.types.reference(cu,{onInvalidated(e){e.parent.setTryReload(e.invalidId),e.removeRef()}})),assembly:l.types.string,refName:l.types.string}).volatile((()=>({tryReload:void 0}))).actions((e=>({setFeature(t){e.feature=t},setTryReload(t){e.tryReload=t}}))).actions((e=>({afterAttach(){l.addDisposer(e,c.autorun((t=>{if(!e.tryReload)return;const n=o.getSession(e),{apolloDataStore:r}=n;if(!r)return;const i=r.getFeature(e.tryReload);i&&(e.setFeature(i),e.setTryReload(),t.dispose())})))}}))),gu=l.types.model("ApolloTranscriptDetails",{id:d.ElementId,type:l.types.literal("ApolloTranscriptDetails"),feature:l.types.maybe(l.types.reference(cu,{onInvalidated(e){e.parent.setTryReload(e.invalidId),e.removeRef()}})),assembly:l.types.string,refName:l.types.string}).volatile((()=>({tryReload:void 0}))).actions((e=>({setFeature(t){e.feature=t},setTryReload(t){e.tryReload=t}}))).actions((e=>({afterAttach(){l.addDisposer(e,c.autorun((t=>{if(!e.tryReload)return;const n=o.getSession(e),{apolloDataStore:r}=n;if(!r)return;const i=r.getFeature(e.tryReload);i&&(e.setFeature(i),e.setTryReload(),t.dispose())})))}})));var mu=/^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|download|draggable|encType|enterKeyHint|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/,yu=li((function(e){return mu.test(e)||111===e.charCodeAt(0)&&110===e.charCodeAt(1)&&e.charCodeAt(2)<91})),_u=function(e){return"theme"!==e},vu=function(e){return"string"==typeof e&&e.charCodeAt(0)>96?yu:_u},bu=function(e,t,n){var r;if(t){var o=t.shouldForwardProp;r=e.__emotion_forwardProp&&o?function(t){return e.__emotion_forwardProp(t)&&o(t)}:o}return"function"!=typeof r&&n&&(r=e.__emotion_forwardProp),r},xu="You have illegal escape sequence in your template literal, most likely inside content's property value.\nBecause you write your CSS inside a JavaScript string you actually have to do double escaping, so for example \"content: '\\00d7';\" should become \"content: '\\\\00d7';\".\nYou can read more about this here:\nhttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#ES2018_revision_of_illegal_escape_sequences",wu=function(e){var t=e.cache,n=e.serialized,r=e.isStringTag;return wi(t,n,r),Hi((function(){return Si(t,n,r)})),null},Su=function e(t,n){if("production"!==ae.env.NODE_ENV&&void 0===t)throw new Error("You are trying to create a styled element with an undefined component.\nYou may have forgotten to import it.");var r,o,i=t.__emotion_real===t,a=i&&t.__emotion_base||t;void 0!==n&&(r=n.label,o=n.target);var s=bu(t,n,i),l=s||vu(a),c=!l("as");return function(){var u=arguments,d=i&&void 0!==t.__emotion_styles?t.__emotion_styles.slice(0):[];if(void 0!==r&&d.push("label:"+r+";"),null==u[0]||void 0===u[0].raw)d.push.apply(d,u);else{"production"!==ae.env.NODE_ENV&&void 0===u[0][0]&&console.error(xu),d.push(u[0][0]);for(var f=u.length,h=1;h<f;h++)"production"!==ae.env.NODE_ENV&&void 0===u[0][h]&&console.error(xu),d.push(u[h],u[0][h])}var p=Wi((function(e,t,n){var r=c&&e.as||a,i="",u=[],f=e;if(null==e.theme){for(var h in f={},e)f[h]=e[h];f.theme=w.useContext(Ji)}"string"==typeof e.className?i=xi(t.registered,u,e.className):null!=e.className&&(i=e.className+" ");var p=$i(d.concat(u),t.registered,f);i+=t.key+"-"+p.name,void 0!==o&&(i+=" "+o);var g=c&&void 0===s?vu(r):l,m={};for(var y in e)c&&"as"===y||g(y)&&(m[y]=e[y]);return m.className=i,m.ref=n,w.createElement(w.Fragment,null,w.createElement(wu,{cache:t,serialized:p,isStringTag:"string"==typeof r}),w.createElement(r,m))}));return p.displayName=void 0!==r?r:"Styled("+("string"==typeof a?a:a.displayName||a.name||"Component")+")",p.defaultProps=t.defaultProps,p.__emotion_real=p,p.__emotion_base=a,p.__emotion_styles=d,p.__emotion_forwardProp=s,Object.defineProperty(p,"toString",{value:function(){return void 0===o&&"production"!==ae.env.NODE_ENV?"NO_COMPONENT_SELECTOR":"."+o}}),p.withComponent=function(t,r){return e(t,bi({},n,r,{shouldForwardProp:bu(p,r,!0)})).apply(void 0,d)},p}}.bind();async function Cu(e){if(isSecureContext){const t=new Blob([e.outerText],{type:"text/plain"}),n=new Blob([e.outerHTML],{type:"text/html"}),r=new ClipboardItem({[t.type]:t,[n.type]:n});return navigator.clipboard.write([r])}const t=t=>{t.clipboardData?.setData("text/plain",e.outerText),t.clipboardData?.setData("text/html",e.outerHTML),t.preventDefault()};document.addEventListener("copy",t),document.execCommand("copy"),document.removeEventListener("copy",t)}function Au(e){let t=0;for(const n of e)t+=n.sequence.length;return t}function ku(e,t,n){const r=[],{cdsLocations:i,strand:a,transcriptParts:s}=t;switch(e){case"genomic":case"cDNA":{const[t]=s;for(const i of t){if("cDNA"===e&&"intron"===i.type)continue;let t=n(i.min,i.max);-1===a&&(t=o.revcom(t));const s="fivePrimeUTR"===i.type||"threePrimeUTR"===i.type?"UTR":i.type,l=r.at(-1);l&&l.type===s?(l.sequence+=t,l.locs.push({min:i.min,max:i.max})):r.push({type:s,sequence:t,locs:[{min:i.min,max:i.max}]})}return r}case"CDS":{let e="";const[t]=i,s=[];for(const r of t){let t=n(r.min,r.max);-1===a&&(t=o.revcom(t)),e+=t,s.push({min:r.min,max:r.max})}return r.push({type:"CDS",sequence:e,locs:s}),r}case"protein":{let e="";const[t]=i,s=[];for(const r of t){let t=n(r.min,r.max);-1===a&&(t=o.revcom(t)),e+=t,s.push({min:r.min,max:r.max})}let l="";for(let t=0;t<e.length;t+=3){const n=e.slice(t,t+3).toUpperCase();l+=o.defaultCodonTable[n]||"&"}return r.push({type:"protein",sequence:l,locs:s}),r}}}function Nu(e){switch(e){case"upOrDownstream":return"rgb(255,255,255)";case"exon":case"UTR":return"rgb(194,106,119)";case"CDS":return"rgb(93,168,153)";case"intron":return"rgb(187,187,187)";case"protein":return"rgb(148,203,236)"}}function Tu(e){const t=[],n=e.flatMap((e=>e.locs));let[r]=n;for(let e=1;e<n.length;e++)r.min===n[e].max||r.max===n[e].min?r={min:Math.min(r.min,n[e].min),max:Math.max(r.max,n[e].max)}:(t.push(r),r=n[e]);return t.push(r),t}["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","marquee","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"].forEach((function(e){Su[e]=Su(e)}));const Ru=p.observer((function({assembly:e,feature:t,refName:n,session:r}){const o=r.apolloDataStore.assemblies.get(e),a=o?.getByRefName(n),{featureTypeOntology:l}=r.apolloDataStore.ontologyManager,c="genomic",d=["genomic","cDNA"],[f,h]=u.useState(d),[p,g]=u.useState(c),[m,y]=u.useState((()=>a?ku(c,t,((e,t)=>a.getSequence(e,t))):[])),[_,v]=u.useState((()=>Tu(m))),b=s.useTheme(),x=u.useRef(null);if(u.useEffect((()=>{const{cdsLocations:e}=t,[n]=e;h(n.length>0?[...d,"CDS","protein"]:d)}),[t]),!o||!a)return null;const w=o.getByRefName(n);if(!w)return null;if(!l)throw new Error("featureTypeOntology is undefined");return l.isTypeOf(t.type,"transcript")?i.jsxs(i.Fragment,{children:[i.jsx(s.Select,{defaultValue:"genomic",value:p,onChange:function(e){const n=e.target.value;g(n);const r=a?ku(n,t,((e,t)=>a.getSequence(e,t))):[],o=Tu(r);y(r),v(o)},size:"small","data-testid":"sequenceOptionSelector",children:f.map((e=>i.jsx(s.MenuItem,{value:e,"data-testid":`sequenceOption-${e}`,children:e},e)))}),i.jsx(s.Button,{variant:"contained",onClick:()=>{const e=x.current;e&&Cu(e)},style:{marginLeft:10},size:"medium",children:"Copy sequence"}),i.jsxs(s.Paper,{style:{fontFamily:"monospace",padding:b.spacing(),overflowX:"auto"},ref:x,children:[">",w.name,":",_.map((e=>1===t.strand?`${e.min+1}-${e.max}`:`${e.max}-${e.min+1}`)).join(";"),"(strand=",1===t.strand?"+":"-",";length=",Au(m),")",i.jsx("br",{}),function(e,t){const n=[];let r=0;for(const[t,o]of e.entries()){const e=r%60,a=r>0&&0===e?"\n":"";r+=o.sequence.length;const s=a+o.sequence.slice(0,60-e),l=[s,...Ot(o.sequence.slice(s.length),60)],c=i.jsx("span",{style:{background:Nu(o.type),color:b.palette.getContrastText(Nu(o.type)),whiteSpace:"pre-line"},children:l.join("\n")},`${o.type}-${t}`);n.push(c)}return n}(m)]})]}):null}));var Eu=a.createSvgIcon(i.jsx("path",{d:"M19 13H5v-2h14z"}),"Remove"),Iu=a.createSvgIcon(i.jsx("path",{d:"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2m0 16H8V7h11z"}),"ContentCopy"),ju=a.createSvgIcon(i.jsx("path",{d:"M9.64 7.64c.23-.5.36-1.05.36-1.64 0-2.21-1.79-4-4-4S2 3.79 2 6s1.79 4 4 4c.59 0 1.14-.13 1.64-.36L10 12l-2.36 2.36C7.14 14.13 6.59 14 6 14c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4c0-.59-.13-1.14-.36-1.64L12 14l7 7h3v-1zM6 8c-1.1 0-2-.89-2-2s.9-2 2-2 2 .89 2 2-.9 2-2 2m0 12c-1.1 0-2-.89-2-2s.9-2 2-2 2 .89 2 2-.9 2-2 2m6-7.5c-.28 0-.5-.22-.5-.5s.22-.5.5-.5.5.22.5.5-.22.5-.5.5M19 3l-6 6 2 2 7-7V3z"}),"ContentCut");const Du=Su("div")({display:"flex",justifyContent:"center",alignItems:"center",textAlign:"left",width:"100%",overflowWrap:"break-word",wordWrap:"break-word",wordBreak:"break-all","& span":{fontSize:12}}),Ou=Su(s.AccordionSummary)((()=>({minHeight:30,maxHeight:30,"&.Mui-expanded":{minHeight:30,maxHeight:30}})));function Fu({changeInProgress:e,cdsLocations:t,refData:n,strand:r,updateCDSLocation:a,cdsMin:l,cdsMax:c,feature:d,session:f}){const h=u.useRef(null),{notify:p}=f,g=[],[m]=t;for(const e of m){const t=n.getSequence(e.min,e.max);g.push(-1===r?o.revcom(t):t)}const y=g.join(""),_=[];for(let e=0;e<y.length;e+=3){const t=y.slice(e,e+3).toUpperCase();_.push(o.defaultCodonTable[t]||"&")}const v=e=>{const[n]=t;let o=0;const i=n.toSorted((({min:e},{min:t})=>e-t));if(1===r)for(const t of i){const n=t.max-t.min;if(o+n>e)return t.min+(e-o);o+=n}else if(-1===r)for(let t=i.length-1;t>=0;t--){const n=i[t],r=n.max-n.min;if(o+r>e)return n.max-(e-o);o+=r}return 1===r?l:c};return i.jsx("div",{children:i.jsxs(s.Accordion,{children:[i.jsx(Ou,{expandIcon:i.jsx(Uc,{style:{color:"white"}}),"aria-controls":"panel1-content",id:"panel1-header",children:i.jsx(s.Typography,{component:"span",fontWeight:"bold",children:"Translation"})}),i.jsxs(s.AccordionDetails,{children:[i.jsx(Du,{children:i.jsx(s.Typography,{component:"span",ref:h,style:{maxHeight:120,overflowY:"scroll"},children:_.map(((t,n)=>{const o=3*n;return i.jsx(s.Typography,"M"===t?{component:"span",style:{backgroundColor:e?"lightgray":"yellow",cursor:"pointer",border:"1px solid black"},onClick:()=>{if(e)return;const t=v(o);t!==l&&1===r&&a(l,t,d,!0),t!==c&&-1===r&&a(c,t,d,!1)},children:t}:"*"===t?{style:{backgroundColor:"red",color:"white"},component:"span",children:t}:{component:"span",children:t},o)}))})}),i.jsxs("div",{style:{marginTop:10,display:"flex",flexDirection:"row",alignItems:"center",gap:10},children:[i.jsx(s.Tooltip,{title:"Copy",children:i.jsx("button",{onClick:()=>{const e=h.current;e&&Cu(e)},style:{border:"none",background:"none",padding:0},disabled:e,children:i.jsx(Iu,{style:{fontSize:15}})})}),i.jsx(s.Tooltip,{title:"Trim",children:i.jsx("button",{onClick:()=>{if("M"===_.at(0)&&"*"===_.at(-1)||0===_.length)return;const e=_.indexOf("M"),t=3*_.lastIndexOf("*"),n=v(3*e);let o=v(t);if(1===r){if(n>o)return void p("Start codon genomic location should be less than stop codon genomic location","error");let e;o+=3,n!==l&&(e=new Promise((e=>{a(l,n,d,!0,(()=>{e(!0)}))}))),o!==c&&(e?e.then((()=>{a(c,o,d,!1)})):a(c,o,d,!1))}if(-1===r){if(n<o)return void p("Start codon genomic location should be less than stop codon genomic location","error");let e;o-=3,n!==c&&(e=new Promise((e=>{a(c,n,d,!1,(()=>{e(!0)}))}))),o!==l&&(e?e.then((()=>{a(l,o,d,!0)})):a(l,o,d,!0))}p("Translation sequence trimmed to start and stop codons","success")},style:{border:"none",background:"none",padding:0},disabled:e,children:i.jsx(ju,{style:{fontSize:15}})})})]})]})]})})}const Mu=Su(tu)((()=>({"&.MuiFormControl-root":{marginTop:0,marginBottom:0,width:"100%"},"& .MuiInputBase-input":{fontSize:12,height:20,padding:1,paddingLeft:10}}))),Lu=e=>{const{strand:t}=e;return i.jsx("div",{children:1===t?i.jsx(Ln,{}):-1===t?i.jsx(Eu,{}):i.jsx(s.Typography,{component:"span",children:"N/A"})})},Pu=p.observer((function({assembly:e,feature:t,refName:n,session:r}){const{notify:a}=r,l=r.apolloDataStore.assemblies.get(e),c=l?.getByRefName(n),{changeManager:u}=r.apolloDataStore,{changeInProgress:d}=r;if(!c)return null;const{apolloDataStore:f}=r,{featureTypeOntology:h}=f.ontologyManager;if(!h.isTypeOf(t.type,"transcript")&&!h.isTypeOf(t.type,"pseudogenic_transcript"))throw new Error("Feature is not a transcript or equivalent");const{cdsLocations:p,transcriptExonParts:g,strand:m}=t,[y]=p,[_,v]=((e,t)=>{const{transcriptExonParts:n}=e,r=n.filter((e=>t.isTypeOf(e.type,"exon"))).sort((({min:e},{min:t})=>e-t)),o=r[0]?.min,i=r[r.length-1]?.max;return[o,i]})(t,h);let b=_,x=v;const w=y.length>0;if(w){const e=y.toSorted((({min:e},{min:t})=>e-t));b=e[0].min,x=e[e.length-1].max}const S=(t,n,r,o,i)=>{if(!r.children)throw new Error("Transcript should have child features");if(t===n)return!0;const s=N(r,h,t,o);if(!s)return a("No matching CDS feature found","error"),!1;if(o&&n>=s.max)return a("Start location should be less than CDS end location","error"),!1;if(!o&&n<=s.min)return a("End location should be greater than CDS start location","error"),!1;if(!I(r,h,n,o))return a("There should be an overlapping exon for the new CDS location","error"),!1;const l=o?new Et({typeName:"LocationStartChange",changedIds:[s._id],featureId:s._id,oldStart:s.min,newStart:n,assembly:e}):new Tt({typeName:"LocationEndChange",changedIds:[s._id],featureId:s._id,oldEnd:s.max,newEnd:n,assembly:e});return u.submit(l).then((()=>{i&&i()})).catch((()=>{a("Error updating feature CDS position","error")})),!0};function C(t,n,r,o){if(!r.children)throw new Error("Transcript should have child features");const{matchingExon:i,prevExon:s,nextExon:l}=j(r,h,t,o);if(!i)return a("No matching exon found","error"),!1;if(o&&n>=i.max)return a("Start location should be less than end location","error"),!1;if(!o&&n<=i.min)return a("End location should be greater than start location","error"),!1;if(s&&s.max+2>n)return a("Error while changing start location","error"),!1;if(l&&l.min-2<n)return a("Error while changing end location","error"),!1;const c=R(r,i.min,i.max,h);if(!c)return a("No matching exon feature found","error"),!1;const d=T(r,h);if(o&&n!==i.min){const t=new Et({typeName:"LocationStartChange",changedIds:[],changes:[],assembly:e});if(s)k(c,t,n);else{const e=r.min,i=r.parent;if(n<e)i&&n<i.min&&k(i,t,n),k(r,t,n),k(c,t,n);else if(n>e&&(k(c,t,n),k(r,t,n),i)){const[e]=E(i,r,n,h,o);i.min!=e&&k(i,t,e)}}d&&d.min>=i.min&&d.min<=i.max&&n>d.min&&k(d,t,n),u.submit(t).catch((()=>{a("Error updating feature exon start position","error")}))}if(!o&&n!==i.max){const t=new Tt({typeName:"LocationEndChange",changedIds:[],changes:[],assembly:e});if(l)A(c,t,n);else{const e=r.max,i=r.parent;if(n>e)i&&n>i.max&&A(i,t,n),A(r,t,n),A(c,t,n);else if(n<e&&(A(c,t,n),A(r,t,n),i)){const[,e]=E(i,r,n,h,o);i.max!=e&&A(i,t,e)}}d&&d.max>=i.min&&d.max<=i.max&&n<d.max&&A(d,t,n),u.submit(t).catch((()=>{a("Error updating feature exon end position","error")}))}return!0}const A=(e,t,n)=>{t.changedIds.push(e._id),t.changes.push({featureId:e._id,oldEnd:e.max,newEnd:n})},k=(e,t,n)=>{t.changedIds.push(e._id),t.changes.push({featureId:e._id,oldStart:e.min,newStart:n})},N=(e,t,n,r)=>{let o;for(const[,i]of e.children??[])if(t.isTypeOf(i.type,"CDS")){if(r&&n===i.min){o=i;break}if(!r&&n===i.max){o=i;break}}return o},T=(e,t)=>{let n;for(const[,r]of e.children??[])if(t.isTypeOf(r.type,"CDS")){n=r;break}return n},R=(e,t,n,r)=>{let o;for(const[,i]of e.children??[])if(r.isTypeOf(i.type,"exon")&&t===i.min&&n===i.max){o=i;break}return o},E=(e,t,n,r,o)=>{const i=[],a=[];for(const[,s]of e.children?.entries()??[])r.isTypeOf(s.type,"transcript")&&(s._id===t._id?o?(i.push(n),a.push(s.max)):(a.push(n),i.push(s.min)):(i.push(s.min),a.push(s.max)));return[Math.min(...i),Math.max(...a)]},I=(e,t,n,r)=>{const{transcriptExonParts:o}=e;let i;for(const[,e]of o.entries())if(t.isTypeOf(e.type,"exon")){if(!r&&n>=e.min&&n<=e.max){i=e;break}if(r&&n>=e.min&&n<=e.max){i=e;break}}return i},j=(e,t,n,r)=>{const{transcriptExonParts:o,strand:i}=e;let a,s,l,c;for(const[e,i]of o.entries())if(t.isTypeOf(i.type,"exon")){if(r&&i.min===n){a=i,s=e;break}if(!r&&i.max===n){a=i,s=e;break}}if(a&&void 0!==s){if(1===i&&s>0)for(let e=s-1;e>=0;e--){const n=o[e];if(t.isTypeOf(n.type,"exon")){l=n;break}}if(-1===i&&s<o.length-1)for(let e=s+1;e<o.length;e++){const n=o[e];if(t.isTypeOf(n.type,"exon")){l=n;break}}if(1===i&&s<o.length-1)for(let e=s+1;e<o.length;e++){const n=o[e];if(t.isTypeOf(n.type,"exon")){c=n;break}}if(-1===i&&s>0)for(let e=s-1;e>=0;e--){const n=o[e];if(t.isTypeOf(n.type,"exon")){c=n;break}}}return{matchingExon:a,prevExon:l,nextExon:c}},D=(e,t)=>{let n="";if(t>0){const r=g[t-1];1===m?"intron"===r.type&&(n=c.getSequence(e.min-2,e.min)):"intron"===r.type&&(n=o.revcom(c.getSequence(e.max,e.max+2)))}return n=n.toUpperCase(),[{spliceSite:n,color:"AG"===n?"green":"red"}]},O=(e,t)=>{let n="";if(t<g.length-1){const r=g[t+1];1===m?"intron"===r.type&&(n=c.getSequence(e.max,e.max+2)):"intron"===r.type&&(n=o.revcom(c.getSequence(e.min-2,e.min)))}return n=n.toUpperCase(),[{spliceSite:n,color:"GT"===n?"green":"red"}]};return i.jsxs("div",{children:[w&&i.jsx("div",{children:i.jsxs(s.Grid,{container:!0,justifyContent:"center",alignItems:"center",style:{textAlign:"center"},children:[i.jsx(s.Grid,{size:1}),i.jsx(s.Grid,1===m?{size:4,children:i.jsx(Mu,{margin:"dense",variant:"outlined",value:b+1,onChangeCommitted:e=>S(b,e-1,t,!0),style:{border:"1px solid black",borderRadius:5},disabled:d})}:{size:4,children:i.jsx(Mu,{margin:"dense",variant:"outlined",value:x,onChangeCommitted:e=>S(x,e,t,!1),style:{border:"1px solid black",borderRadius:5},disabled:d})}),i.jsx(s.Grid,{size:2,children:i.jsx(s.Typography,{component:"span",children:"CDS"})}),i.jsx(s.Grid,1===m?{size:4,children:i.jsx(Mu,{margin:"dense",variant:"outlined",value:x,onChangeCommitted:e=>S(x,e,t,!1),style:{border:"1px solid black",borderRadius:5},disabled:d})}:{size:4,children:i.jsx(Mu,{margin:"dense",variant:"outlined",value:b+1,onChangeCommitted:e=>S(b,e-1,t,!0),style:{border:"1px solid black",borderRadius:5},disabled:d})}),i.jsx(s.Grid,{size:1})]})}),i.jsxs("div",{style:{marginTop:5,marginBottom:10},children:[i.jsx("div",{style:{textAlign:"center"},children:i.jsx(s.Typography,{children:"Exons"})}),g.map(((e,n)=>i.jsx("div",{children:"exon"===e.type&&i.jsxs(s.Grid,{container:!0,justifyContent:"center",alignItems:"center",style:{textAlign:"center"},children:[i.jsx(s.Grid,{size:1,children:0!==n&&D(e,n).map(((e,t)=>i.jsx(s.Typography,{component:"span",color:e.color,children:e.spliceSite},t)))}),i.jsx(s.Grid,1===m?{size:4,style:{padding:0},children:i.jsx(Mu,{margin:"dense",variant:"outlined",value:e.min+1,onChangeCommitted:n=>C(e.min,n-1,t,!0),disabled:d})}:{size:4,style:{padding:0},children:i.jsx(Mu,{margin:"dense",variant:"outlined",value:e.max,onChangeCommitted:n=>C(e.max,n,t,!1),disabled:d})}),i.jsx(s.Grid,{size:2,children:i.jsx(Lu,{strand:t.strand})}),i.jsx(s.Grid,1===m?{size:4,style:{padding:0},children:i.jsx(Mu,{margin:"dense",variant:"outlined",value:e.max,onChangeCommitted:n=>C(e.max,n,t,!1),disabled:d})}:{size:4,style:{padding:0},children:i.jsx(Mu,{margin:"dense",variant:"outlined",value:e.min+1,onChangeCommitted:n=>C(e.min,n-1,t,!0),disabled:d})}),i.jsx(s.Grid,{size:1,children:n!==g.length-1&&O(e,n).map(((e,t)=>i.jsx(s.Typography,{component:"span",color:e.color,children:e.spliceSite},t)))})]})},n)))]}),w&&i.jsx(Fu,{changeInProgress:d,cdsLocations:p,refData:c,strand:m,updateCDSLocation:S,cdsMin:b,cdsMax:x,feature:t,session:r})]})})),Bu=Su(s.TableCell)((()=>({fontWeight:"bold"}))),qu=p.observer((function(e){const{feature:t}=e,n=xa(t),r=wa(t);return i.jsx(s.Table,{size:"small",sx:{fontSize:"0.75rem","& .MuiTableCell-root":{padding:"4px"}},children:i.jsxs(s.TableBody,{children:[""!==n&&i.jsxs(s.TableRow,{children:[i.jsx(Bu,{children:"Name"}),i.jsx(s.TableCell,{children:xa(t)})]}),""!==r&&i.jsxs(s.TableRow,{children:[i.jsx(Bu,{children:"ID"}),i.jsx(s.TableCell,{children:wa(t)})]}),i.jsxs(s.TableRow,{children:[i.jsx(Bu,{children:"Type"}),i.jsx(s.TableCell,{children:t.type})]}),i.jsxs(s.TableRow,{children:[i.jsx(Bu,{children:"Location"}),i.jsxs(s.TableCell,{children:[e.refName,":",t.min,"..",t.max]})]}),i.jsxs(s.TableRow,{children:[i.jsx(Bu,{children:"Strand"}),i.jsx(s.TableCell,{children:(o=t.strand,1===o?"Forward":-1===o?"Reverse":"")})]})]})});var o})),Uu=ma()((e=>({root:{padding:e.spacing(2)}}))),zu=Su(s.AccordionSummary)((()=>({minHeight:30,maxHeight:30,"&.Mui-expanded":{minHeight:30,maxHeight:30}})));function $u(e){return null}const Hu=p.observer((function(e){const{classes:t}=Uu(),n=["summary","location"],[r,a]=u.useState(n),{model:c}=e,{assembly:d,feature:f,refName:h}=c;u.useEffect((()=>{a(n)}),[f]);const p=o.getSession(c),{pluginManager:g}=o.getEnv(p),m=o.getSession(c),y=m.apolloDataStore.assemblies.get(d),{internetAccounts:_}=l.getRoot(p),v=_.find((e=>"ApolloInternetAccount"===e.type)),b=["admin","user"].includes((v?v.role:"admin")??"");if(!f||!y)return null;const x=y.getByRefName(h);if(!x)return null;const{max:w,min:S}=f;function C(e,t){a(e?[...r,t]:r.filter((e=>e!==t)))}x.getSequence(S,w)||m.apolloDataStore.loadRefSeq([{assemblyName:d,refName:h,start:S,end:w}]);const A=g.evaluateExtensionPoint("Apollo-TranscriptDetailsCustomComponent-InsideSummary",$u,{feature:f,session:p}),k=g.evaluateExtensionPoint("Apollo-TranscriptDetailsCustomComponent-AfterSummary",$u,{feature:f,session:p}),N=g.evaluateExtensionPoint("Apollo-TranscriptDetailsCustomComponent-InsideLocation",$u,{feature:f,session:p}),T=g.evaluateExtensionPoint("Apollo-TranscriptDetailsCustomComponent-AfterLocation",$u,{feature:f,session:p}),R=g.evaluateExtensionPoint("Apollo-TranscriptDetailsCustomComponent-InsideAttributes",$u,{feature:f,session:p}),E=g.evaluateExtensionPoint("Apollo-TranscriptDetailsCustomComponent-AfterAttributes",$u,{feature:f,session:p}),I=g.evaluateExtensionPoint("Apollo-TranscriptDetailsCustomComponent-InsideSequence",$u,{feature:f,session:p}),j=g.evaluateExtensionPoint("Apollo-TranscriptDetailsCustomComponent-AfterSequence",$u,{feature:f,session:p});return i.jsxs("div",{className:t.root,children:[i.jsxs(s.Accordion,{expanded:r.includes("summary"),onChange:(e,t)=>{C(t,"summary")},children:[i.jsx(zu,{expandIcon:i.jsx(Uc,{style:{color:"white"}}),"aria-controls":"panel1-content",id:"panel1-header",children:i.jsx(s.Typography,{component:"span",fontWeight:"bold",children:"Summary"})}),i.jsxs(s.AccordionDetails,{children:[i.jsx(qu,{feature:f,refName:h}),i.jsx(A,{session:p,feature:f})]})]}),i.jsx(k,{session:p,feature:f}),i.jsxs(s.Accordion,{style:{marginTop:5},expanded:r.includes("location"),onChange:(e,t)=>{C(t,"location")},children:[i.jsx(zu,{expandIcon:i.jsx(Uc,{style:{color:"white"}}),"aria-controls":"panel2-content",id:"panel2-header",children:i.jsx(s.Typography,{component:"span",fontWeight:"bold",children:"Location"})}),i.jsxs(s.AccordionDetails,{children:[i.jsx(Pu,{feature:f,refName:h,session:m,assembly:y._id||""}),i.jsx(N,{session:p,feature:f})]})]}),i.jsx(T,{session:p,feature:f}),i.jsxs(s.Accordion,{style:{marginTop:5},expanded:r.includes("attrs"),onChange:(e,t)=>{C(t,"attrs")},children:[i.jsx(zu,{expandIcon:i.jsx(Uc,{style:{color:"white"}}),"aria-controls":"panel3-content",id:"panel3-header",children:i.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[i.jsxs(s.Typography,{component:"span",fontWeight:"bold",children:["Attributes"," "]}),i.jsx(s.Tooltip,{title:"Separate multiple values for the attribute with commas",children:i.jsx(ya,{style:{color:"white",fontSize:15,marginLeft:10}})})]})}),i.jsxs(s.AccordionDetails,{children:[i.jsx(eu,{feature:f,session:m,assembly:y._id||"",editable:b}),i.jsx(R,{session:p,feature:f})]})]}),i.jsx(E,{session:p,feature:f}),i.jsxs(s.Accordion,{style:{marginTop:5},expanded:r.includes("sequence"),onChange:(e,t)=>{C(t,"sequence")},children:[i.jsx(zu,{expandIcon:i.jsx(Uc,{style:{color:"white"}}),"aria-controls":"panel4-content",id:"panel4-header",children:i.jsx(s.Typography,{component:"span",fontWeight:"bold",children:"Sequence"})}),i.jsxs(s.AccordionDetails,{children:[r.includes("sequence")&&i.jsx(Ru,{feature:f,session:m,assembly:y._id||"",refName:h}),i.jsx(I,{session:p,feature:f})]})]}),i.jsx(j,{feature:f,session:p})]})})),Gu=n.ConfigurationSchema("LinearApolloDisplay",{},{explicitIdentifier:"displayId",explicitlyTyped:!0}),Vu=ma()({highlighted:{background:"orange"}}),Wu=({highlight:e,text:t})=>{const{classes:n}=Vu();if(!e)return i.jsx(i.Fragment,{children:t});const r=t.split(e);if(1===r.length)return i.jsx(i.Fragment,{children:t});const o=[];for(let t=0;t<r.length-1;t++)o.push(r[t],i.jsx("span",{className:n.highlighted,children:e}));return i.jsxs(i.Fragment,{children:[o,r.at(-1)]})},Ju=p.observer((function({feature:e,filterText:t}){const n=[...e.attributes.entries()].map((([e,t])=>{if(e.startsWith("gff_")){const n=e.slice(4);return[n.charAt(0).toUpperCase()+n.slice(1),l.getSnapshot(t)]}return"_id"===e?["ID",l.getSnapshot(t)]:[e,l.getSnapshot(t)]})).filter((([e])=>e)).map((([e,t])=>`${e}=${Array.isArray(t)?t.join(", "):t}`)).join(", ");return i.jsx(Wu,{text:n,highlight:t})})),Ku=ma()((e=>({inputWrapper:{position:"relative"},hiddenWidthSpan:{padding:e.spacing(.5),color:"transparent"},numberTextInput:{border:"none",background:"inherit",font:"inherit",position:"absolute",width:"100%",left:0}}))),Yu=p.observer((function({initialValue:e,notifyError:t,onChangeCommitted:n}){const[r,o]=u.useState(e),[a,s]=u.useState(!1),[l,c]=u.useState(null),{classes:d}=Ku();return u.useEffect((()=>{e!==r&&o(e)}),[e]),u.useEffect((()=>{a&&(l?.blur(),s(!1))}),[a,l]),i.jsxs("span",{className:d.inputWrapper,children:[i.jsx("span",{className:d.hiddenWidthSpan,"aria-hidden":!0,children:r}),i.jsx("input",{type:"text",value:r,className:d.numberTextInput,onChange:function(e){const t=Number(e.target.value);Number.isNaN(t)||o(t)},onKeyDown:t=>{"Enter"===t.key?l?.blur():"Escape"===t.key&&(o(e),s(!0))},onBlur:()=>{r!==e&&n(r).catch(t)},ref:e=>{c(e)}})]})})),Xu=ma()((e=>({typeContent:{display:"inline-block",width:"174px",height:"100%",cursor:"text"},feature:{td:{position:"relative",verticalAlign:"top",paddingLeft:"0.5em"}},arrow:{display:"inline-block",width:"1.6em",textAlign:"center",cursor:"pointer"},arrowExpanded:{transform:"rotate(90deg)"},hoveredFeature:{backgroundColor:e.palette.action.hover},typeInputElement:{border:"none",background:"none"},typeErrorMessage:{color:"red"}})));function Zu(e,t){const{changeManager:n,getAssemblyId:r,regions:i,selectedFeature:a,session:s,setSelectedFeature:c,filteredTranscripts:u,updateFilteredTranscripts:d}=e;return function(e,t,n,r,i,a,s,c,u){const d=function(e){const{internetAccounts:t}=l.getParent(e);return t.find((e=>"ApolloInternetAccount"===e.type))}(a),f=d?d.role:"admin",h=!(f&&["admin","user"].includes(f)),p=[];if(e){const l=e.attributes.get("gff_id")?.toString(),f=n(t.assemblyName),g=n(t.assemblyName);p.push({label:"Edit feature details",onClick:()=>{const n=a.addWidget("ApolloFeatureDetailsWidget","apolloFeatureDetailsWidget",{feature:e,assembly:g,refName:t.refName});a.showWidget(n)}},{label:"Add child feature",disabled:h,onClick:()=>{a.queueDialog((t=>[Us,{session:a,handleClose:()=>{t()},changeManager:s,sourceFeature:e,sourceAssemblyId:f,internetAccount:d}]))}},{label:"Copy features and annotations",disabled:h,onClick:()=>{a.queueDialog((t=>[Gs,{session:a,handleClose:()=>{t()},changeManager:s,sourceFeature:e,sourceAssemblyId:g}]))}},{label:"Delete feature",disabled:h,onClick:()=>{a.queueDialog((t=>[Vs,{session:a,handleClose:()=>{t()},changeManager:s,sourceFeature:e,sourceAssemblyId:g,selectedFeature:r,setSelectedFeature:i}]))}},{label:"Merge transcripts",disabled:h,onClick:()=>{a.queueDialog((t=>[nc,{session:a,handleClose:()=>{t()},changeManager:s,sourceFeature:e,sourceAssemblyId:g,selectedFeature:r,setSelectedFeature:i}]))}},{label:"Merge exons",disabled:h,onClick:()=>{a.queueDialog((t=>[ec,{session:a,handleClose:()=>{t()},changeManager:s,sourceFeature:e,sourceAssemblyId:g,selectedFeature:r,setSelectedFeature:i}]))}},{label:"Split exon",disabled:h,onClick:()=>{a.queueDialog((t=>[fc,{session:a,handleClose:()=>{t()},changeManager:s,sourceFeature:e,sourceAssemblyId:g,selectedFeature:r,setSelectedFeature:i}]))}});const{featureTypeOntology:m}=a.apolloDataStore.ontologyManager;if(!m)throw new Error("featureTypeOntology is undefined");(m.isTypeOf(e.type,"transcript")||m.isTypeOf(e.type,"pseudogenic_transcript"))&&o.isSessionModelWithWidgets(a)&&p.push({label:"Edit transcript details",onClick:()=>{const n=a.addWidget("ApolloTranscriptDetails","apolloTranscriptDetails",{feature:e,assembly:g,changeManager:s,refName:t.refName});a.showWidget(n)}},{label:"Duplicate feature",onClick:()=>{a.queueDialog((t=>[hc,{session:a,handleClose:()=>{t()},changeManager:s,sourceFeature:e,sourceAssemblyId:g,selectedFeature:r,setSelectedFeature:i}]))}},{label:"Visible",type:"checkbox",checked:!l||!c.includes(l),onClick:()=>{if(l){const e=c.includes(l)?c.filter((e=>e!==l)):[...c,l];u(e)}}})}return p}(t,i[0],r,a,c,s,n,u,d)}const Qu=p.observer((function e({depth:t,feature:n,isHovered:r,isSelected:o,model:a,selectedFeatureClass:s,setContextMenu:l}){const{classes:c}=Xu(),{changeManager:u,hoveredFeature:d,selectedFeature:f,session:h,tabularEditor:p}=a,{featureCollapsed:g,filterText:m}=p,{_id:y,children:_,max:v,min:b,strand:x,type:w}=n,S=!g.get(y),C=e=>{h.notify(e.message,"error")};return i.jsxs(i.Fragment,{children:[i.jsxs("tr",{onMouseEnter:e=>{a.setHoveredFeature({feature:n,bp:b})},className:c.feature+(o?` ${s}`:r?` ${c.hoveredFeature}`:""),onClick:e=>{e.stopPropagation(),a.setSelectedFeature(n)},onDoubleClick:()=>{a.setSelectedFeature(n),function(e,t){e.lgv.navTo(al(t,.1,e.lgv.totalBp))}(a,n)},onContextMenu:e=>(e.preventDefault(),l({position:{left:e.clientX+2,top:e.clientY-6},items:Zu(a,n)}),!1),children:[i.jsxs("td",{style:{whiteSpace:"nowrap",borderLeft:2*t+"em solid transparent"},children:[_?.size?i.jsx("div",{onClick:e=>{e.stopPropagation(),p.setFeatureCollapsed(y,S)},className:c.arrow+(S?` ${c.arrowExpanded}`:""),children:"❯"}):null,i.jsx("div",{className:c.typeContent,children:i.jsx(qs,{session:h,ontologyName:"Sequence Ontology",style:{width:170},value:w,filterTerms:Cs,fetchValidTerms:ed.bind(null,n),renderInput:e=>i.jsxs("div",{ref:e.InputProps.ref,children:[i.jsx("input",{type:"text",...e.inputProps,className:c.typeInputElement,style:{width:170}}),e.error?i.jsx("div",{className:c.typeErrorMessage,children:e.errorMessage??"unknown error"}):null]}),onChange:(e,t)=>{t&&function(e,t,n,r){const o=t._id,i=new $t({typeName:"TypeChange",changedIds:[o],featureId:o,oldType:n,newType:r,assembly:t.assemblyId});return e.submit(i)}(u,n,e,t).catch(C)}})})]}),i.jsx("td",{children:i.jsx(Yu,{initialValue:b+1,notifyError:C,onChangeCommitted:e=>function(e,t,n,r){const o=t._id,i=new Et({typeName:"LocationStartChange",changedIds:[o],featureId:o,oldStart:n,newStart:r,assembly:t.assemblyId});return e.submit(i)}(u,n,b,e-1)})}),i.jsx("td",{children:i.jsx(Yu,{initialValue:v,notifyError:C,onChangeCommitted:e=>function(e,t,n,r){const o=t._id,i=new Tt({typeName:"LocationEndChange",changedIds:[o],featureId:o,oldEnd:n,newEnd:r,assembly:t.assemblyId});return e.submit(i)}(u,n,v,e)})}),i.jsx("td",{children:1===x?"+":-1===x?"-":void 0}),i.jsx("td",{children:i.jsx(Ju,{filterText:m,feature:n})})]}),S&&_?[..._.entries()].filter((e=>{if(!m)return!0;const[,t]=e;return JSON.stringify(t).includes(m)})).map((([n,r])=>i.jsx(e,{isHovered:d?.feature._id===r._id,isSelected:f?._id===r._id,selectedFeatureClass:s,depth:(t||0)+1,feature:r,model:a,setContextMenu:l},n))):null]})}));async function ed(e,t,n){const{parent:r}=e;if(r){const e=(await t.getTermsWithLabelOrSynonym(r.type,{includeSubclasses:!1})).filter(Cs);if(e.length>0)return await t.getClassesThat("part_of",e)}}const td=ma()((e=>({scrollableTable:{width:"100%",height:"100%",th:{position:"sticky",top:0,zIndex:2,textAlign:"left",background:e.palette.background.paper,paddingTop:"3.2em"},td:{whiteSpace:"normal"}},selectedFeature:{backgroundColor:e.palette.action.selected}}))),nd=p.observer((function({model:e}){const{hoveredFeature:t,seenFeatures:n,selectedFeature:r,tabularEditor:o}=e,a=s.useTheme(),{classes:l}=td(),c=u.useRef(null),[d,f]=u.useState(null),{filterText:p}=o;return u.useEffect((()=>{const e=c.current;if(e&&r){const t=e.querySelector(`.${l.selectedFeature}`);if(t){const n=e.scrollTop,r=t.offsetTop-25;r>n&&r<n+e.offsetHeight||e.scroll({top:r-40,behavior:"smooth"})}}}),[r,n,l.selectedFeature]),i.jsxs("div",{ref:c,style:{width:"100%",overflowY:"auto",height:"100%"},children:[i.jsxs("table",{className:l.scrollableTable,children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"Type"}),i.jsx("th",{children:"Start"}),i.jsx("th",{children:"End"}),i.jsx("th",{children:"Strand"}),i.jsx("th",{children:"Attributes"})]})}),i.jsx("tbody",{children:[...n.entries()].filter((e=>{if(!p)return!0;const[,t]=e;return JSON.stringify(t).includes(p)})).sort(((e,t)=>e[1].min-t[1].min)).map((([n,o])=>i.jsx(Qu,{isSelected:r?._id===n,isHovered:t?.feature._id===n,selectedFeatureClass:l.selectedFeature,feature:o,model:e,depth:0,setContextMenu:f},n)))})]}),i.jsx(h.Menu,{open:Boolean(d),onMenuItemClick:(e,t)=>{t(),f(null)},onClose:()=>{f(null)},slotProps:{transition:{onExit:()=>{f(null)}}},style:{zIndex:a.zIndex.tooltip},menuItems:d?.items??[],anchorReference:"anchorPosition",anchorPosition:d?.position})]})}));var rd=a.createSvgIcon(i.jsx("path",{d:"M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"}),"Clear"),od=a.createSvgIcon(i.jsx("path",{d:"M7.41 18.59 8.83 20 12 16.83 15.17 20l1.41-1.41L12 14zm9.18-13.18L15.17 4 12 7.17 8.83 4 7.41 5.41 12 10z"}),"UnfoldLess");const id=ma()({toolbar:{width:"100%",display:"flex",paddingRight:"2em",flexDirection:"row",justifyContent:"space-between",position:"absolute",zIndex:4},filterText:{}}),ad=p.observer((function({model:e}){const t=e.tabularEditor,{classes:n}=id();return i.jsxs("div",{className:n.toolbar,children:[i.jsx(s.Tooltip,{title:"Collapse all",children:i.jsx(s.IconButton,{"aria-label":"collapse",sx:{marginTop:0},onClick:t.collapseAllFeatures,children:i.jsx(od,{})})}),i.jsx(s.TextField,{className:n.filterText,label:"Filter features",value:t.filterText,sx:{marginTop:0},variant:"outlined",onChange:e=>{t.setFilterText(e.target.value)},slotProps:{input:{endAdornment:i.jsx(s.InputAdornment,{position:"end",children:i.jsx(s.IconButton,{onClick:()=>{t.clearFilterText()},children:i.jsx(rd,{})})})}}})]})}));function sd(e){e.stopPropagation()}const ld=p.observer((function({model:e}){return e.tabularEditor.isShown?i.jsxs("div",{onMouseDown:sd,onClick:sd,style:{width:"100%",height:"100%",position:"relative"},children:[i.jsx(ad,{model:e}),i.jsx(nd,{model:e})]}):null})),cd=l.types.model("TabularEditor",{isShown:!0,featureCollapsed:l.types.map(l.types.boolean),filterText:""}).actions((e=>({setFeatureCollapsed(t,n){e.featureCollapsed.set(t,n)},setFilterText(t){e.filterText=t},clearFilterText(){e.filterText=""},collapseAllFeatures(){const t=l.getParent(e);for(const[n]of t.seenFeatures.entries())e.featureCollapsed.set(n,!0)},togglePane(){e.isShown=!e.isShown},hidePane(){e.isShown=!1},showPane(){e.isShown=!0}})));function ud(e,t,n){const{lgv:r}=e,{bpPerPx:o,offsetPx:i}=r;return n.offsetPx-i+(n.reversed?n.end-t.max:t.min-n.start)/o}function dd(e,t,n,r){const{apolloRowHeight:o,lgv:i}=e,{bpPerPx:a}=i;return[n*o,Math.round(ud(e,t,r)),Math.round((t.max-t.min)/a),o]}function fd(e,t,n,r,o,i,a,l){const c=function(e,t,n){const{theme:r}=e;switch(n){case"select":return r.palette.action.disabled;case"hover":return r.palette.action.focus;case"highlight":{const{attributes:e}=t,n=e.get("apollo_color");return n?.[0]}}}(e,a,l);c&&(t.fillStyle=s.alpha(c,.3),t.fillRect(n,r,o,i))}function hd(e,t,n,r,o,i){e.strokeStyle=i,e.lineWidth=1,e.strokeRect(t+.5,n+.5,r-1,o-1)}function pd(e,t,n){const{refName:r,regionNumber:o,x:i}=e,{lgv:a}=n,{offsetPx:s}=a,l=a.bpToPx({refName:r,coord:t.min,regionNumber:o}),c=a.bpToPx({refName:r,coord:t.max,regionNumber:o});if(void 0!==l&&void 0!==c){const e=l.offsetPx-s,t=c.offsetPx-s;if(Math.abs(t-e)<8)return;if(Math.abs(e-i)<4)return"min";if(Math.abs(t-i)<4)return"max"}}function gd(e,t,n,r,o,i){const[a,s,l,c]=dd(e,n,r,o);fd(e,t,s,a,l,c,n,i)}const md={draw:function(e,t,n,r,o,i){const{selectedFeature:a,theme:s}=e,[l,c,u,d]=dd(e,n,r,i);u>2&&(t.fillStyle=s.palette.background.default,t.fillRect(c,l,u,d)),hd(t,c,l,u,d,s.palette.text.primary),rl(n,a)&&gd(e,t,n,r,i,"select")},drawDragPreview:function(e,t,n,r,o){const{apolloDragging:i,theme:a}=e;if(!i)return;const{current:l,start:c}=i,u=Math.min(l.bp,c.bp),d=Math.max(l.bp,c.bp),[f,h,p,g]=dd(e,{min:u,max:d},r,o);t.fillStyle=s.alpha(a.palette.info.main,.2),t.fillRect(h,f,p,g),t.setLineDash([6]),hd(t,h,f,p,g,a.palette.info.main)},drawOverlay:gd,getContextMenuItems:function(e){const{hoveredFeature:t}=e;return t?il(e,t.feature):[]},getLayout:function(e,t){return{byFeature:new Map([[t._id,0]]),byRow:[[{feature:t,rowInFeature:0}]],min:t.min,max:t.max}},isDraggable:!0};function yd(e,t,n,r,i,a){const{apolloRowHeight:s,canvasPatterns:l,theme:c}=e,[u,d,f]=dd(e,n,i,a),h=Math.round(s/2);if(f>2){const e=o.getFrame(n.min,n.max,r??1,n.phase),i=c.palette.framesCDS.at(e)?.main;t.fillStyle=i??"black",t.fillRect(d,u,f,s);const p=l.forward,g=l.backward;if(p&&g&&r){const{reversed:e}=a,n=e?-1:1,[o,i]=r*n==1?[p,g]:[g,p];t.fillStyle=o,t.fillRect(d,u,f,h),t.fillStyle=i,t.fillRect(d,u+h,f,h)}}hd(t,d,u,f,s,c.palette.text.primary)}function _d(e,t,n,r,o,i){const{apolloRowHeight:a}=e,[s,l,c]=dd(e,n,r,o);fd(e,t,l,s,c,1*a,n,i)}const{drawDragPreview:vd}=md,bd={draw:function(e,t,n,r,o,i){const a=n.parent;if(!a)return void md.draw(e,t,n,r,0,i);const{cdsLocations:s}=a,l=s.find((e=>{const t=e.at(1===n.strand?0:-1)?.min,r=e.at(1===n.strand?-1:0)?.max;return n.min===t&&n.max===r}));if(!l)return;for(const o of l)yd(e,t,o,n.strand,r,i);const{selectedFeature:c}=e;rl(n,c)&&_d(e,t,n,r,i,"select")},drawDragPreview:vd,drawOverlay:_d,getContextMenuItems:function(){return[]},getLayout:function(e,t){return{byFeature:new Map([[t._id,0]]),byRow:[[{feature:t,rowInFeature:0}]],min:t.min,max:t.max}},isDraggable:!0};function xd(e,t,n,r,o,i){const{apolloRowHeight:a}=e,[,s,l]=dd(e,n,r,o),c=Math.round(.6*a),u=Math.round(c/2);fd(e,t,s,Math.round(u/2)+r*a,l,c,n,i)}const{drawDragPreview:wd}=md,Sd={draw:function(e,t,n,r,o,i){const{apolloRowHeight:a,canvasPatterns:s,selectedFeature:l,theme:c}=e,[,u,d]=dd(e,n,r,i),f=Math.round(.6*a),h=Math.round(f/2),p=Math.round(h/2)+r*a;if(d>2){t.fillStyle="rgb(211,211,211)",t.fillRect(u,p,d,f);const e=s.forward,r=s.backward,{strand:o}=n;if(e&&r&&o){const{reversed:n}=i,a=n?-1:1,[s,l]=o*a==1?[e,r]:[r,e];t.fillStyle=s,t.fillRect(u,p,d,h),t.fillStyle=l,t.fillRect(u,p+h,d,h)}}hd(t,u,p,d,f,c.palette.text.primary),rl(n,l)&&xd(e,t,n,r,i,"select")},drawDragPreview:wd,drawOverlay:xd,getContextMenuItems:function(e,t){const{apolloInternetAccount:n,changeManager:r,regions:i,selectedFeature:a,session:s}=e,[l]=i,c=e.getAssemblyId(l.assemblyName),u="admin"===(n?n.role:"admin"),d=[],f=Qs(t,e),h=o.getContainingView(e);if(f.upstream){const n=f.upstream;d.push({label:"Go to upstream exon",icon:el(t.strand,!0,h.displayedRegions.at(0)?.reversed),onClick:()=>{h.navTo(al(n,.1,h.totalBp)),Ws(e,n)}})}if(f.downstream){const n=f.downstream;d.push({label:"Go to downstream exon",icon:el(t.strand,!1,h.displayedRegions.at(0)?.reversed),onClick:()=>{h.navTo(al(n,.1,h.totalBp)),Ws(e,n)}})}return d.push({label:"Merge exons",disabled:!u,onClick:()=>{s.queueDialog((n=>[ec,{session:s,handleClose:()=>{n()},changeManager:r,sourceFeature:t,sourceAssemblyId:c,selectedFeature:a,setSelectedFeature:t=>{e.setSelectedFeature(t)}}]))}},{label:"Split exon",disabled:!u,onClick:()=>{s.queueDialog((n=>[fc,{session:s,handleClose:()=>{n()},changeManager:r,sourceFeature:t,sourceAssemblyId:c,selectedFeature:a,setSelectedFeature:t=>{e.setSelectedFeature(t)}}]))}}),d},getLayout:function(e,t){return{byFeature:new Map([[t._id,0]]),byRow:[[{feature:t,rowInFeature:0}]],min:t.min,max:t.max}},isDraggable:!0};function Cd(e,t){return kd(e,t).byRow.length}function Ad(e,t,n,r,o,i,a){if(a>0)return;const{apolloRowHeight:s}=e,[l,c,u]=dd(e,n,r,o);fd(e,t,c,l,u,Cd(e,n)*s,n,i)}function kd(e,t){const n={byFeature:new Map([[t._id,0]]),byRow:[[{feature:t,rowInFeature:0}]],min:t.min,max:t.max},{children:r}=t;if(!r)return n;n.byRow=[];const{getGlyph:o}=e;for(const[,i]of r){const r=o(i).getLayout(e,i),a=n.byRow.length;for(const[e,o]of r.byRow.entries())n.byRow.push([{feature:t,rowInFeature:a+e},...o]);for(const e of r.byFeature.entries()){const[t,r]=e;n.byFeature.set(t,r+a)}}return n}const{drawDragPreview:Nd}=md,Td={draw:function(e,t,r,o,i,a){if(i>0)return;const{apolloRowHeight:l,theme:c,selectedFeature:u,session:d}=e,[f,h,p]=dd(e,r,o,a),g=Cd(e,r)*l;if(p>2){const e=n.readConfObject(d.getPluginConfiguration(),"geneBackgroundColor",{featureType:r.type})??s.alpha(c.palette.background.paper,.6);t.fillStyle=e,t.fillRect(h,f,p,g)}hd(t,h,f,p,g,c.palette.text.primary),rl(r,u)&&Ad(e,t,r,o,a,"select",i)},drawDragPreview:Nd,drawOverlay:Ad,getContextMenuItems:function(){return[]},getLayout:kd,isDraggable:!1};function Rd(e,t){return Id(e,t).byRow.length}function Ed(e,t,n,r,o,i){const{apolloRowHeight:a}=e,[s,l,c]=dd(e,n,r,o);fd(e,t,l,s,c,Rd(e,n)*a,n,i)}function Id(e,t){const n={byFeature:new Map([[t._id,0]]),byRow:[[{feature:t,rowInFeature:0}]],min:t.min,max:t.max},{children:r}=t;if(!r)return n;const{getGlyph:o}=e;for(const[,i]of r){const r=o(i).getLayout(e,i),a=n.byRow.length;for(const[e,o]of r.byRow.entries())n.byRow.push([{feature:t,rowInFeature:a+e},...o]);for(const e of r.byFeature.entries()){const[t,r]=e;n.byFeature.set(t,r+a)}}return n}const{drawDragPreview:jd}=md,Dd={draw:function(e,t,n,r,o,i){if(o>0)return;const{apolloRowHeight:a,selectedFeature:l,theme:c}=e,[u,d,f]=dd(e,n,r,i),h=Rd(e,n)*a;f>2&&(t.fillStyle=s.alpha(c.palette.background.paper,.6),t.fillRect(d,u,f,h)),hd(t,d,u,f,h,c.palette.text.primary),md.draw(e,t,n,r,0,i),rl(n,l)&&Ed(e,t,n,r,i,"select")},drawDragPreview:jd,drawOverlay:Ed,getContextMenuItems:function(){return[]},getLayout:Id,isDraggable:!0};function*Od(e,t,n=1){if(e!==t)if(e<t)for(let r=e;r<t;r+=n)yield r;else for(let r=e;r>t;r-=n)yield r}function Fd(e,t,n,r,o,i){const{apolloRowHeight:a}=e,[s,l,c]=dd(e,n,r,o),u=a*function(e,t){return Md(e,t).byRow.length}(e,n);fd(e,t,l,s,c,u,n,i)}function Md(e,t){const n={byFeature:new Map([[t._id,0]]),byRow:[[{feature:t,rowInFeature:0}]],min:t.min,max:t.max},{children:r}=t;if(!r)return n;n.byRow=[];const o=function(e,t){const{children:n}=t;if(!n)return[];const{session:r}=e;return[...n.values()].filter((e=>Ys(e,r)))}(e,t),i=function(e,t){const{children:n}=t;if(!n)return[];const{session:r}=e;return[...n.values()].filter((e=>!Ys(e,r)))}(e,t);if(n.byFeature.set(t._id,0),0===i.length){const e=[];e.push({feature:t,rowInFeature:0});for(const t of o)e.push({feature:t,rowInFeature:0}),n.byFeature.set(t._id,0);return n.byRow.push(e),n}const{getGlyph:a,session:s}=e;let l=0;for(const[r,c]of i.entries()){const i=[];if(i.push({feature:t,rowInFeature:r+l}),Xs(c,s)){for(const e of o)i.push({feature:e,rowInFeature:l}),n.byFeature.set(e._id,l);i.push({feature:c,rowInFeature:l}),n.byFeature.set(c._id,l)}else{const t=a(c).getLayout(e,c).byRow.length;for(let e=0;e<t;e++)i.push({feature:c,rowInFeature:e}),n.byFeature.set(c._id,e);l+=t-1}n.byRow.push(i)}return n}const{drawDragPreview:Ld}=md,Pd={draw:function(e,t,n,r,o,i){!function(e,t,n,r,o){const{apolloRowHeight:i,lgv:a,theme:s}=e,{bpPerPx:l}=a,{reversed:c}=o,u=Math.round(ud(e,n,o)),d=Math.round(n.length/l),f=Math.round(i/2)+r*i;t.strokeStyle=s.palette.text.primary;const{strand:h=1}=n;t.beginPath();const p=h*(c?-1:1);let g=u-(-1===p?5:0),m=u+d+(-1===p?0:5);g=Math.max(g,0),m=Math.min(m,globalThis.innerWidth),t.moveTo(g,f),t.lineTo(m,f);const y=g+(-1===p?0:3),_=m-(-1===p?3:0),v=-1===p?3:-3,b=-1===p?Od(y,_,20):Od(_,y,20);for(const e of b)t.moveTo(e+v,f+v),t.lineTo(e,f),t.lineTo(e+v,f-v);t.stroke()}(e,t,n,r,i);const{selectedFeature:a}=e;rl(n,a)&&Fd(e,t,n,r,i,"select")},drawDragPreview:Ld,drawOverlay:Fd,getContextMenuItems:function(e,t){const{changeManager:n,regions:r,selectedFeature:i,session:a}=e,[s]=r,l=e.getAssemblyId(s.assemblyName),c=[];o.isSessionModelWithWidgets(a)&&c.splice(1,0,{label:"Open transcript editor",onClick:()=>{const e=a.addWidget("ApolloTranscriptDetails","apolloTranscriptDetails",{feature:t,assembly:l,changeManager:n,refName:s.refName});a.showWidget(e)}}),c.push({label:"Merge transcript",onClick:()=>{a.queueDialog((r=>[nc,{session:a,handleClose:()=>{r()},changeManager:n,sourceFeature:t,sourceAssemblyId:l,selectedFeature:i,setSelectedFeature:t=>{e.setSelectedFeature(t)}}]))}},{label:"Duplicate feature",onClick:()=>{a.queueDialog((r=>[hc,{session:a,handleClose:()=>{r()},changeManager:n,sourceFeature:t,sourceAssemblyId:l,selectedFeature:i,setSelectedFeature:t=>{e.setSelectedFeature(t)}}]))}});const{children:u}=t;return u?(0===[...u.values()].filter((e=>Xs(e,a))).length&&c.push({label:"Add coding sequence",onClick:()=>{a.queueDialog((e=>[bl,{session:a,handleClose:()=>{e()},changeManager:n,sourceFeature:t,sourceAssemblyId:l,refName:s.refName}]))}}),c):[]},getLayout:Md,isDraggable:!1};var Bd=a.createSvgIcon(i.jsx("path",{fillRule:"evenodd",d:"M20 3H4c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2M10 17H5v-2h5zm0-4H5v-2h5zm0-4H5V7h5zm4.82 6L12 12.16l1.41-1.41 1.41 1.42L17.99 9l1.42 1.42z"}),"FactCheck"),qd=a.createSvgIcon(i.jsx("path",{d:"m19.07 4.93-1.41 1.41C19.1 7.79 20 9.79 20 12c0 4.42-3.58 8-8 8s-8-3.58-8-8c0-4.08 3.05-7.44 7-7.93v2.02C8.16 6.57 6 9.03 6 12c0 3.31 2.69 6 6 6s6-2.69 6-6c0-1.66-.67-3.16-1.76-4.24l-1.41 1.41C15.55 9.9 16 10.9 16 12c0 2.21-1.79 4-4 4s-4-1.79-4-4c0-1.86 1.28-3.41 3-3.86v2.14c-.6.35-1 .98-1 1.72 0 1.1.9 2 2 2s2-.9 2-2c0-.74-.4-1.38-1-1.72V2h-1C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10c0-2.76-1.12-5.26-2.93-7.07"}),"TrackChanges");const Ud=p.observer((function({featureTypes:e,handleClose:t,onUpdate:n,session:r}){const[o,a]=u.useState(""),[l,c]=u.useState(e);return i.jsx(Bs,{open:!0,maxWidth:!1,"data-testid":"filter-features-dialog",title:"Filter features by type",handleClose:t,children:i.jsxs(s.DialogContent,{children:[i.jsx(s.DialogContentText,{children:"Select the feature types you want to display in the apollo track"}),i.jsxs(s.Grid,{container:!0,spacing:2,children:[i.jsx(s.Grid,{size:8,children:i.jsx(qs,{session:r,ontologyName:"Sequence Ontology",style:{width:"100%"},value:o,filterTerms:Cs,renderInput:e=>i.jsx(s.TextField,{...e,label:"Feature type",variant:"outlined",fullWidth:!0}),onChange:(e,t)=>{t&&(e=>{a(e)})(t)}})}),i.jsx(s.Grid,{size:4,children:i.jsx(s.Button,{variant:"contained",onClick:()=>{if(o){if(l.includes(o))return;n([...l,o]),c([...l,o])}},disabled:!o,style:{marginTop:9},size:"medium",children:"Add"})})]}),l.length>0&&i.jsxs("div",{children:[i.jsx("hr",{}),i.jsxs("div",{style:{width:300},children:[i.jsx(s.DialogContentText,{children:"Selected feature types:"}),i.jsx(s.Box,{sx:{display:"flex",flexWrap:"wrap",gap:.5},children:l.map((e=>i.jsx(s.Chip,{label:e,onDelete:()=>{(e=>{const t=l.filter((t=>t!==e));n(t),c(t)})(e)}},e)))})]})]})]})})})),zd=p.observer((function({model:e,handleClose:t}){const[n,r]=u.useState(`${e.zoomThresholdSetting}`);return i.jsx(h.Dialog,{open:!0,onClose:t,title:"Edit zoom threshold setting",children:i.jsxs(s.DialogContent,{children:[i.jsx(s.Typography,{children:"The zoom level in base pairs (bp) per pixel at which features are rendered in this Annotations track. Increasing the value will allow features to render when zooming out, but might impact performance."}),i.jsx(s.TextField,{label:"Threshold value (bpPerPx)",value:n,onChange:e=>{r(e.target.value)}}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{variant:"contained",onClick:()=>{e.setZoomThresholdSetting({zoomThreshold:+n}),t()},children:"Submit"}),i.jsx(s.Button,{variant:"contained",color:"secondary",onClick:()=>{t()},children:"Cancel"})]})]})})})),$d=ma()((e=>({canvasContainer:{position:"relative",left:0},canvas:{position:"absolute",left:0},center:{display:"flex",justifyContent:"center"},ellipses:{textOverflow:"ellipsis",overflow:"hidden"},avatar:{position:"static",height:"100%",width:"100%",overflow:"visible",color:e.palette.warning.light,backgroundColor:e.palette.warning.contrastText},box:{position:"absolute",overflow:"visible"},badge:{display:"inline-block"},loading:{position:"absolute",right:e.spacing(3),zIndex:10,pointerEvents:"none",textAlign:"right"},locked:{position:"absolute",right:e.spacing(3),top:e.spacing(6),zIndex:1,pointerEvents:"none",textAlign:"right"}})));function Hd(e,t,n){const r=new Map;for(const t of e)(r.get(t.message)??r.set(t.message,[]).get(t.message)).push(t);const o=[];for(const[e,n]of r.entries()){if(0===n.length)continue;n.sort(((e,t)=>e.start-t.start));let r=[n[0]],i=n[0].start,a=n[0].start+t;const s=()=>{const t=r.map((e=>e.start)).sort(((e,t)=>e-t)),n=Math.floor(t.length/2),s=r[0].ids;o.push({_id:r[0]._id,message:e,start:t.length%2?t[n]:(t[n-1]+t[n])/2,count:r.length,members:[...r],range:{min:i,max:a},featureIds:s})};for(let e=1;e<n.length;e++){const o=n[e],l=o.start,c=l+t;l<=a?(r.push(o),l<i&&(i=l),c>a&&(a=c)):(s(),r=[o],i=l,a=c)}s()}return o.sort(((e,t)=>e.message.localeCompare(t.message)||e.start-t.start)),o}function Gd(e,t,n){return"M"===e?t.palette.startCodon:"*"===e?n?t.palette.text.primary:t.palette.stopCodon:void 0}function Vd(e,t){const n=e.toUpperCase();return"A"===n||"C"===n||"G"===n||"T"===n?t.palette.bases[n].main:"lightgray"}function Wd(e,t){return function(e,t){return function(e,t){const i=function(e,t){return function(e,t){const i=function(e,t){return r.BaseDisplay.named("BaseLinearApolloDisplay").props({type:l.types.literal("LinearApolloDisplay"),configuration:n.ConfigurationReference(t),graphical:!0,table:!1,showCheckResults:!0,zoomThreshold:200,heightPreConfig:l.types.maybe(l.types.refinement("displayHeight",l.types.number,(e=>e>=20))),filteredFeatureTypes:l.types.array(l.types.string),loadingState:!1}).views((e=>{const{configuration:t,renderProps:n}=e;return{renderProps:()=>({...n(),...b.getParentRenderProps(e),config:t.renderer})}})).volatile((()=>({scrollTop:0}))).views((e=>({get lgv(){return o.getContainingView(e)},get height(){return e.heightPreConfig?e.heightPreConfig:e.graphical&&e.table?400:e.graphical?100:200},get loading(){return e.loadingState},get zoomThresholdSetting(){return e.zoomThreshold??n.getConf(e,"zoomThreshold")}}))).views((e=>({get rendererTypeName(){return e.configuration.renderer.type},get session(){return o.getSession(e)},get regions(){return e.lgv.dynamicBlocks.contentBlocks.map((({assemblyName:e,end:t,refName:n,start:r})=>({assemblyName:e,refName:n,start:Math.round(r),end:Math.round(t)})))},regionCannotBeRendered(){if(e.lgv&&e.lgv.bpPerPx>=e.zoomThreshold)return"Zoom in to see annotations"}}))).views((e=>({get apolloInternetAccount(){const[t]=e.regions,{internetAccounts:r}=l.getRoot(e),{assemblyName:o}=t,{assemblyManager:i}=e.session,a=i.get(o);if(!a)throw new Error(`No assembly found with name ${o}`);const{internetAccountConfigId:s}=n.getConf(a,["sequence","metadata"]);return r.find((e=>n.getConf(e,"internetAccountId")===s))},get changeManager(){return e.session.apolloDataStore.changeManager},getAssemblyId(t){const{assemblyManager:n}=e.session,r=n.get(t);if(!r)throw new Error(`Could not find assembly named ${t}`);return r.name},get selectedFeature(){return e.session.apolloSelectedFeature},get hoveredFeature(){return e.session.apolloHoveredFeature}}))).actions((e=>({setScrollTop(t){e.scrollTop=t},setHeight:t=>(e.heightPreConfig=Math.max(t,20),e.height),resizeHeight(t){const n=e.height;return this.setHeight(e.height+t)-n},showGraphicalOnly(){e.graphical=!0,e.table=!1},showTableOnly(){e.graphical=!1,e.table=!0},showGraphicalAndTable(){e.graphical=!0,e.table=!0},toggleShowCheckResults(){e.showCheckResults=!e.showCheckResults},updateFilteredFeatureTypes(t){e.filteredFeatureTypes=l.cast(t)},setLoading(t){e.loadingState=t},setZoomThresholdSetting({zoomThreshold:t}){e.zoomThreshold=t}}))).views((e=>{const{filteredFeatureTypes:t,trackMenuItems:n}=e;return{trackMenuItems(){const{graphical:r,table:i,showCheckResults:a,session:s}=e,[c]=e.regions,{assemblyName:u}=c,d=s.apolloDataStore.getBackendDriver(u),f=[...n(),{type:"subMenu",label:"Appearance",subMenu:[{label:"Show graphical display",type:"radio",checked:r&&!i,onClick:()=>{e.showGraphicalOnly()}},{label:"Show table display",type:"radio",checked:i&&!r,onClick:()=>{e.showTableOnly()}},{label:"Show both graphical and table display",type:"radio",checked:i&&r,onClick:()=>{e.showGraphicalAndTable()}},{label:"Check Results",type:"checkbox",checked:a,onClick:()=>{e.toggleShowCheckResults()}},{label:"Change zoom threshold",onClick:()=>{o.getSession(e).queueDialog((t=>[zd,{model:e,handleClose:t}]))}}]},{label:"Filter features by type",onClick:()=>{const{session:n}=e;e.session.queueDialog((r=>[Ud,{session:n,handleClose:()=>{r()},featureTypes:l.getSnapshot(t),onUpdate:t=>{e.updateFilteredFeatureTypes(t)}}]))}}];return d instanceof Sl&&f.push({label:"Import annotations",icon:uo,onClick:()=>{s.queueDialog((e=>[Wl,{session:s,assemblyName:u,handleClose:()=>{e()}}]))}}),f.push({label:"Export annotations",icon:Gl,onClick:()=>{const[t]=e.regions,{assemblyName:n}=t,r=e.getAssemblyId(n);if(!r)return;const{session:o}=e;o.queueDialog((e=>[Vl,{session:o,handleClose:()=>{e()},assembly:r}]))}},{label:"View Change Log",icon:qd,onClick:()=>{const[t]=e.regions,{assemblyName:n}=t,r=e.getAssemblyId(n);if(!r)return;const{session:o}=e;o.queueDialog((e=>[ic,{session:o,handleClose:()=>{e()},assembly:r}]))}},{label:"View Check Results",icon:Bd,onClick:()=>{const[t]=e.regions,{assemblyName:n}=t,r=e.getAssemblyId(n);if(!r)return;const{session:o}=e;o.queueDialog((e=>[cc,{session:o,handleClose:()=>{e()},assembly:r}]))}}),f}}})).actions((e=>({setSelectedFeature(t){e.session.apolloSetSelectedFeature(t)},setHoveredFeature(t){e.session.apolloSetHoveredFeature(t)},showFeatureDetailsWidget(t,n){const[r]=e.regions,{assemblyName:o,refName:i}=r,a=e.getAssemblyId(o);if(!a)return;const{session:s}=e,{changeManager:l}=s.apolloDataStore,[c,u]=n??["ApolloFeatureDetailsWidget","apolloFeatureDetailsWidget"],d=s.addWidget(c,u,{feature:t,assembly:a,refName:i,changeManager:l});s.showWidget(d)},afterAttach(){l.addDisposer(e,c.autorun((()=>{e.lgv.initialized&&!e.regionCannotBeRendered()&&(e.setLoading(!0),e.session.apolloDataStore.loadFeatures(e.regions).then((()=>{setTimeout((()=>{e.setLoading(!1)}),1e3)})))}),{name:"LinearApolloDisplayLoadFeatures",delay:1e3}))}})))}(0,t);return i.named("LinearApolloDisplayLayouts").props({cleanupBoundary:2e5}).volatile((()=>({seenFeatures:c.observable.map()}))).views((e=>({getAnnotationFeatureById:t=>e.seenFeatures.get(t),getGlyph:t=>Js(t,e.session)?Td:Ks(t,e.session)?Pd:Ys(t,e.session)?Sd:Xs(t,e.session)?bd:t.children?.size?Dd:md}))).actions((e=>({addSeenFeature(t){e.seenFeatures.set(t._id,t)},deleteSeenFeature(t){e.seenFeatures.delete(t)}}))).views((e=>({getCanonicalRefName(t,n){const{assemblyManager:r}=e.session,o=r.get(t);if(!o)throw new Error("no assembly in layout");const i=o.getCanonicalRefName(n);if(!i)throw new Error("no canonical refName in layout");return i}}))).views((e=>({isFeatureDisplayed(t){const n=e.getCanonicalRefName(t.assemblyId,t.refSeq);return e.lgv.displayedRegions.some((r=>{const{end:i,refName:a,start:s}=r;return!(e.filteredFeatureTypes.length>0&&!e.filteredFeatureTypes.includes(t.type)||n!==a||!o.doesIntersect2(s,i,t.min,t.max))}))}}))).views((e=>({get layouts(){const t=new Map;for(const[n,r]of e.seenFeatures.entries()){if(!l.isAlive(r)){e.deleteSeenFeature(n);continue}if(!e.isFeatureDisplayed(r))continue;const i=e.getGlyph(r).getLayout(e,r),a=e.getCanonicalRefName(r.assemblyId,r.refSeq);let s=t.get(r.assemblyId);s||(s=new Map,t.set(r.assemblyId,s));const c=s.get(a);if(!c){s.set(a,i);continue}let u=0;e:for(;;){let e=c.byRow.at(u);if(!e){c.byRow.push(...i.byRow);for(const e of i.byFeature.entries()){const[t,n]=e;c.byFeature.set(t,n+u)}c.min=Math.min(c.min,i.min),c.max=Math.max(c.max,i.max);break e}const t=u+i.byRow.length-1;let n=u;for(;e&&u<=t;){for(const t of e.values())if(o.doesIntersect2(i.min,i.max,t.feature.min,t.feature.max)){u+=1;continue e}n+=1,e=c.byRow.at(n)}for(let e=0;e<i.byRow.length;e++){const t=c.byRow.at(u+e);t?t.push(...i.byRow[e]):c.byRow.push(i.byRow[e])}for(const e of i.byFeature.entries()){const[t,n]=e;c.byFeature.set(t,n+u)}c.min=Math.min(c.min,i.min),c.max=Math.max(c.max,i.max);break e}}return t},getRowForFeature(t){const n=e.getCanonicalRefName(t.assemblyId,t.refSeq);return this.layouts.get(t.assemblyId)?.get(n)?.byFeature.get(t._id)},getFeaturesAtPosition(e,t,n,r){const o=this.layouts.get(e);if(!o)return[];const i=o.get(t);if(!i)return[];const a=i.byRow.at(n);return a?a.filter((({feature:e})=>r>=e.min&&r<=e.max)).map((e=>e.feature)):[]}}))).views((e=>({highestRow(t){const n=e.layouts.get(t);return n?Math.max(0,...[...n.values()].map((e=>e.byRow.length))):0}}))).actions((e=>({afterAttach(){l.addDisposer(e,c.autorun((()=>{if(e.lgv.initialized&&!e.regionCannotBeRendered()){for(const[t,n]of e.seenFeatures.entries()){let r=!1;for(const t of e.regions)if(o.doesIntersect2(t.start-e.cleanupBoundary,t.end+e.cleanupBoundary,n.min,n.max)){r=!0;break}r||e.deleteSeenFeature(t)}for(const t of e.regions){const n=e.session.apolloDataStore.assemblies.get(t.assemblyName),r=n?.getByRefName(t.refName),i=r?.features;if(i)for(const[,n]of i)o.doesIntersect2(t.start,t.end,n.min,n.max)&&!e.seenFeatures.has(n._id)&&e.addSeenFeature(n)}}}),{name:"LinearApolloDisplaySetSeenFeatures",delay:1e3}))}})))}(0,t).named("LinearApolloDisplayRendering").props({apolloRowHeight:20,detailsMinHeight:200,detailsHeight:200,isShown:!0,filteredTranscripts:l.types.array(l.types.string)}).volatile((()=>({canvas:null,overlayCanvas:null,collaboratorCanvas:null,theme:s.createTheme()}))).views((e=>({featuresHeight:t=>(e.highestRow(t)+1)*e.apolloRowHeight,get canvasPatterns(){const t={forward:null,backward:null},n=document.createElement("canvas"),r=n?.getContext("2d");if(!r)return t;const o=10;n.width=n.height=o;const{theme:i}=e,a="light"===i.palette.mode?"rgba(0,0,0,0)":"rgba(0,0,0,0.75)",s="light"===i.palette.mode?"rgba(255,255,255,0.25)":"rgba(0,0,0,0.50)",l=["forward","backward"];for(const e of l){const i="forward"===e?r.createLinearGradient(0,o,o,0):r.createLinearGradient(0,0,o,o);i.addColorStop(0,a),i.addColorStop(.25,a),i.addColorStop(.25,s),i.addColorStop(.5,s),i.addColorStop(.5,a),i.addColorStop(.75,a),i.addColorStop(.75,s),i.addColorStop(1,s),r.fillStyle=i,r.clearRect(0,0,o,o),r.fillRect(0,0,o,o),t[e]=r.createPattern(n,"repeat")}return t}}))).actions((e=>({toggleShown(){e.isShown=!e.isShown},setDetailsHeight(t){e.detailsHeight=e.isShown?Math.max(Math.min(t,e.height-100),Math.min(e.height,e.detailsMinHeight)):t},setCanvas(t){e.canvas=t},setOverlayCanvas(t){e.overlayCanvas=t},setCollaboratorCanvas(t){e.collaboratorCanvas=t},setTheme(t){e.theme=t}}))).actions((e=>({afterAttach(){l.addDisposer(e,c.autorun((()=>{if(!e.lgv.initialized||e.regionCannotBeRendered())return;const t=e.collaboratorCanvas?.getContext("2d");if(t){t.clearRect(0,0,e.lgv.dynamicBlocks.totalWidthPx,e.featuresHeight(e.lgv.assemblyNames[0]));for(const n of e.session.collaborators){const{locations:r}=n;if(0===r.length)continue;let o=0;for(const i of e.lgv.displayedRegions){for(const a of r){if(a.refSeq!==i.refName)continue;const{end:r,refSeq:s,start:l}=a,c=e.lgv.bpToPx({refName:s,coord:l,regionNumber:o});if(!c)continue;const u=c.offsetPx-e.lgv.offsetPx,d=(r-l)/e.lgv.bpPerPx;t.fillStyle="rgba(0,255,0,.2)",t.fillRect(u,1,d,100),t.fillStyle="black",t.fillText(n.name,u+1,11,d-2)}o++}}}}),{name:"LinearApolloDisplayRenderCollaborators"})),l.addDisposer(e,c.autorun((()=>{const{canvas:t,layouts:n,lgv:r}=e;if(!r.initialized||e.regionCannotBeRendered()||!t)return;const{dynamicBlocks:i,offsetPx:a}=r,s=t.getContext("2d");if(!s)return;const l=n.get(r.assemblyNames[0]);if(l){s.clearRect(0,0,t.width,t.height);for(const n of i.contentBlocks){const r=n.offsetPx-a;s.save(),s.beginPath(),s.rect(r,0,n.widthPx,t.height),s.clip();const i=l.get(n.refName);if(!i)return;const{byRow:c}=i;for(const[t,r]of c.entries())for(const i of r){const{feature:r,rowInFeature:a}=i;o.doesIntersect2(n.start,n.end,r.min,r.max)&&e.getGlyph(r).draw(e,s,r,t,a,n)}for(const[t,r]of c.entries())for(const i of r){const{feature:r,rowInFeature:a}=i;o.doesIntersect2(n.start,n.end,r.min,r.max)&&e.getGlyph(r).drawOverlay(e,s,r,t,n,"highlight",a)}s.restore()}}}),{name:"LinearApolloDisplayRenderFeatures"}))}})))}(0,t);return i.named("LinearApolloDisplayMouseEvents").volatile((()=>({apolloDragging:null,cursor:void 0}))).views((e=>({getMousePosition:t=>function(e,t){const n=e.currentTarget,{clientX:r,clientY:o}=e,{left:i,top:a}=n.getBoundingClientRect(),s=r-i,l=o-a,{coord:c,index:u,assemblyName:d,refName:f}=t.pxToBp(s);return{x:s,y:l,assemblyName:d,refName:f,bp:c,regionNumber:u}}(t,e.lgv),getFeaturesAtMousePosition(t){const{bp:n,assemblyName:r,refName:o,y:i}=t,a=Math.floor(i/e.apolloRowHeight),s=e.layouts.get(r)?.get(o);return s?e.getFeaturesAtPosition(r,o,a,n):[]}}))).actions((e=>({continueDrag(t,n){if(!e.apolloDragging)throw new Error("continueDrag() called with no current drag in progress");n.stopPropagation(),e.apolloDragging={...e.apolloDragging,current:t}},setDragging(t){e.apolloDragging=t??null}}))).actions((e=>({setCursor(t){e.cursor!==t&&(e.cursor=t)},updateFilteredTranscripts(e){}}))).actions((()=>({onClick(){}})))}(0,t).views((e=>({contextMenuItems(t){const n=e.getMousePosition(t),r=e.getFeaturesAtMousePosition(n);if(1===r.length)return il(e,r[0]);const o=[];for(const t of r){const n=e.getGlyph(t);o.push({label:t.type,subMenu:[...il(e,t),...n.getContextMenuItems(e,t)]})}return o}}))).actions((e=>{function t(t){"Escape"===t.key&&e.setDragging()}return{startDrag(n,r,o,i=!1){globalThis.addEventListener("keydown",t,!0),e.apolloDragging={start:n,current:n,feature:r,edge:o,shrinkParent:i}},endDrag(){if(globalThis.removeEventListener("keydown",t,!0),!e.apolloDragging)throw new Error("endDrag() called with no current drag in progress");const{current:n,edge:r,feature:o,start:i,shrinkParent:a}=e.apolloDragging;if(Math.abs(n.x-i.x)<=4)return e.setDragging(),void e.setCursor();const{displayedRegions:s}=e.lgv,l=e.getAssemblyId(s[i.regionNumber].assemblyName),c=cl(o,n.bp,r,a),u="max"===r?new Tt({typeName:"LocationEndChange",changedIds:c.map((e=>e.featureId)),changes:c.map((e=>({featureId:e.featureId,oldEnd:e.oldLocation,newEnd:e.newLocation}))),assembly:l}):new Et({typeName:"LocationStartChange",changedIds:c.map((e=>e.featureId)),changes:c.map((e=>({featureId:e.featureId,oldStart:e.oldLocation,newStart:e.newLocation}))),assembly:l});e.changeManager.submit(u),e.setDragging(),e.setCursor()}}})).actions((e=>({onMouseDown(t){const n=e.getMousePosition(t),r=e.getFeaturesAtMousePosition(n);for(const o of r.toReversed())if(e.getGlyph(o).isDraggable){const r=pd(n,o,e);if(r)return t.stopPropagation(),void e.startDrag(n,o,r,!0)}},onMouseMove(t){const n=e.getMousePosition(t);if(e.apolloDragging)return e.setCursor("col-resize"),void e.continueDrag(n,t);const r=e.getFeaturesAtMousePosition(n);let o=r.at(-1);if(o&&Xs(o,e.session)){const t=r.at(-2);t&&!Ys(t,e.session)&&(o=t)}o?e.setHoveredFeature({feature:o,bp:n.bp}):e.setHoveredFeature();for(const t of r.toReversed())if(e.getGlyph(t).isDraggable&&pd(n,t,e))return void e.setCursor("col-resize");e.setCursor()},onMouseLeave(t){e.setDragging(),e.setHoveredFeature()},onMouseUp(t){if(e.apolloDragging)return void e.endDrag();const n=e.getMousePosition(t),r=e.getFeaturesAtMousePosition(n);let o=r.at(-1);if(o&&Xs(o,e.session)){const t=r.at(-2);t&&!Ys(t,e.session)&&(o=t)}o?(Ws(e,o),e.setSelectedFeature(o)):e.setSelectedFeature()}}))).actions((e=>({afterAttach(){l.addDisposer(e,c.autorun((()=>{const{lgv:t,overlayCanvas:n}=e;if(!t.initialized||e.regionCannotBeRendered()||!n)return;const{dynamicBlocks:r,offsetPx:i}=t,a=n.getContext("2d");if(!a)return;a.clearRect(0,0,n.width,n.height);const{apolloDragging:s,hoveredFeature:l}=e;if(!l)return;const{feature:c}=l,u=e.getGlyph(c),d=e.getRowForFeature(c);if(void 0!==d)for(const t of r.contentBlocks){const r=t.offsetPx-i;if(a.save(),a.beginPath(),a.rect(r,0,t.widthPx,n.height),a.clip(),t.assemblyName===c.assemblyId&&o.doesIntersect2(t.start,t.end,c.min,c.max)&&u.drawOverlay(e,a,c,d,t,"hover"),s){const{current:n,start:r,feature:i}=s,l=Math.min(n.bp,r.bp),c=Math.max(n.bp,r.bp);if(o.doesIntersect2(t.start,t.end,l,c)){const n=e.getGlyph(i),r=e.getRowForFeature(i);void 0!==r&&n.drawDragPreview(e,a,i,r,t)}}a.restore()}}),{name:"LinearApolloDisplayRenderMouseoverAndDrag"}))}})))}(0,t).props({tabularEditor:l.types.optional(cd,{})}).named("LinearApolloDisplay")}const Jd=n.ConfigurationSchema("LinearApolloReferenceSequenceDisplay",{},{explicitIdentifier:"displayId",explicitlyTyped:!0});function Kd(e,t,n){const r=t<=1?[2,1,0,7,6,5]:[2,1,0,5,4,3];n&&r.reverse(),r.unshift(0);const o=r.at(e);if(void 0===o)throw new Error("could not find row");return o}function Yd(e,t,n,r){return r.offsetPx-n+(r.reversed?r.end-e.max:e.min-r.start)/t}function Xd(e,t,n,r,o,i,a=!1){e.fillStyle=a?i.palette.action.disabled:i.palette.action.focus,e.fillRect(t,n,r,o),e.strokeStyle=a?i.palette.text.secondary:i.palette.text.primary,e.strokeStyle=i.palette.text.primary,e.strokeRect(t,n,r,o)}function Zd(e,t,n,r,o,i,a,s=!1){const l=function(e,t,n){if(!(t>1||void 0===e))return n?1===e?4:3:1===e?3:4}(t.strand,n,i.reversed);void 0!==l&&Xd(e,Yd(t,n,r,i),l*o,t.length/n,o,a,s)}function Qd(e,t,n,r,i,a,s,l=!1){const c=t.parent;if(!c)return;const u=c.cdsLocations.find((e=>{const n=e.at(1===t.strand?0:-1)?.min,r=e.at(1===t.strand?-1:0)?.max;return t.min===n&&t.max===r}));if(u)for(const c of u){const u=Kd(o.getFrame(c.min,c.max,t.strand??1,c.phase),n,a.reversed);Xd(e,Yd(c,n,r,a),u*i,(c.max-c.min)/n,i,s,l)}}function ef(e,t,n,r,o){const i=Math.min(r,10);e.fillStyle="#000",e.font=`${i}px`;const a=e.measureText(o).width,s=Math.round(t+(r-a)/2);e.fillText(o,s,n+10)}function tf(e,t,n,r,o,i,a,s){const l=t<=1?[3,2,1,0,0,-1,-2,-3]:[3,2,1,-1,-2,-3];s&&l.reverse();for(const[t,s]of l.entries()){const l=n.palette.framesCDS.at(s)?.main;if(!l)continue;const c=t*a;e.fillStyle=r?n.palette.background.default:l,e.fillRect(o,c,i,a),r&&hd(e,o,c,i,a,n.palette.grey[200])}}function nf(e,t,n,r,i,a,s){if(1/i<1)return;const l=Math.round(r+n/i),c=Math.round(r+(n+1)/i)-l,u=[-1,1];for(const n of u){const r=(1===n?3:4)*a,u=1===n?t:o.revcom(t);e.fillStyle=Vd(u,s),e.fillRect(l,r,c,a),1/i>=12&&(hd(e,l,r,c,a,s.palette.text.disabled),ef(e,l,r,c,u))}}function rf(e,t,n,r,i,a,s,l,c,u,d){const f=(s<=1?[0,2,1,0,7,6,5]:[0,2,1,0,5,4,3]).map((e=>e*c)),h=[-1,1];for(const p of h){const h=o.getFrame(l,l+3,p,0),g=f.at(h);if(void 0===g)continue;const m=Math.round(n+r/s),y=Math.round(n+(r+3)/s)-m,_=1===p?t:o.revcom(t),v=o.defaultCodonTable[_],b=Gd(v,i,a);b&&(d&&"*"==v||u&&"*"!=v)&&(e.fillStyle=b,e.fillRect(m,g,y,c)),1/s>=4&&(hd(e,m,g,y,c,i.palette.text.disabled),ef(e,m,g,y,v))}}function of(e,t){return function(e,t){const i=function(e,t){return r.BaseDisplay.named("BaseLinearApolloReferenceSequenceDisplay").props({type:l.types.literal("LinearApolloReferenceSequenceDisplay"),configuration:n.ConfigurationReference(t),showStartCodons:!1,showStopCodons:!0,highContrast:!1,heightPreConfig:l.types.maybe(l.types.refinement("displayHeight",l.types.number,(e=>e>=20))),sequenceRowHeight:15}).views((e=>{const{configuration:t,renderProps:n}=e;return{renderProps:()=>({...n(),...b.getParentRenderProps(e),config:t.renderer})}})).views((e=>({get lgv(){return o.getContainingView(e)}}))).views((e=>({get rendererTypeName(){return e.configuration.renderer.type},get session(){return o.getSession(e)},get regions(){return e.lgv.dynamicBlocks.contentBlocks.map((({assemblyName:e,end:t,refName:n,start:r})=>({assemblyName:e,refName:n,start:Math.round(r),end:Math.round(t)})))},regionCannotBeRendered(){if(e.lgv&&e.lgv.bpPerPx>3)return"Zoom in to see sequence"}}))).views((e=>({get expandedRegions(){return e.lgv.dynamicBlocks.contentBlocks.map((e=>{const{assemblyName:t,end:n,refName:r,start:o}=e,{parentRegion:i}=e;return{assemblyName:t,refName:r,start:Math.round(Math.max(o-5,i.start)),end:Math.round(Math.min(n+5,i.end))}}))},get apolloInternetAccount(){const[t]=e.regions,{internetAccounts:r}=l.getRoot(e),{assemblyName:o}=t,{assemblyManager:i}=e.session,a=i.get(o);if(!a)throw new Error(`No assembly found with name ${o}`);const{internetAccountConfigId:s}=n.getConf(a,["sequence","metadata"]);return r.find((e=>n.getConf(e,"internetAccountId")===s))},get changeManager(){return e.session.apolloDataStore.changeManager},getAssemblyId(t){const{assemblyManager:n}=e.session,r=n.get(t);if(!r)throw new Error(`Could not find assembly named ${t}`);return r.name},get selectedFeature(){return e.session.apolloSelectedFeature},get hoveredFeature(){return e.session.apolloHoveredFeature},get height(){const{sequenceRowHeight:t}=e;return e.lgv.bpPerPx<=1?8*t:6*t}}))).volatile((()=>({scrollTop:0}))).actions((e=>({setScrollTop(t){e.scrollTop=t},setHeight:t=>(e.heightPreConfig=Math.max(t,20),e.height),resizeHeight(t){const n=e.height;return this.setHeight(e.height+t)-n},toggleShowStartCodons(){e.showStartCodons=!e.showStartCodons},toggleShowStopCodons(){e.showStopCodons=!e.showStopCodons},toggleHighContrast(){e.highContrast=!e.highContrast}}))).views((e=>{const{trackMenuItems:t}=e;return{trackMenuItems(){const{showStartCodons:n,showStopCodons:r,highContrast:o}=e;return[...t(),{type:"subMenu",label:"Appearance",subMenu:[{label:"Show start codons",type:"checkbox",checked:n,onClick:()=>{e.toggleShowStartCodons()}},{label:"Show stop codons",type:"checkbox",checked:r,onClick:()=>{e.toggleShowStopCodons()}},{label:"Use high contrast colors",type:"checkbox",checked:o,onClick:()=>{e.toggleHighContrast()}}]}]}}})).actions((e=>({afterAttach(){l.addDisposer(e,c.autorun((()=>{e.lgv.initialized&&!e.regionCannotBeRendered()&&e.lgv.bpPerPx<=3&&e.session.apolloDataStore.loadRefSeq(e.expandedRegions)}),{name:"LinearApolloReferenceSequenceDisplayLoadFeatures",delay:1e3}))}})))}(0,t);return i.named("LinearApolloReferenceSequenceDisplayRendering").volatile((()=>({seqTrackCanvas:null,seqTrackOverlayCanvas:null,theme:s.createTheme()}))).actions((e=>({setSeqTrackCanvas(t){e.seqTrackCanvas=t},setSeqTrackOverlayCanvas(t){e.seqTrackOverlayCanvas=t},setTheme(t){e.theme=t},afterAttach(){l.addDisposer(e,c.autorun((()=>{const{lgv:t,seqTrackCanvas:n,theme:r,highContrast:i,showStartCodons:a,showStopCodons:s,sequenceRowHeight:l,session:c}=e;if(!t.initialized||e.regionCannotBeRendered()||!n)return;if(3/t.bpPerPx<1)return;const{bpPerPx:u,offsetPx:d,dynamicBlocks:f}=t;!function(e,t,n,r,i,a,s,l,c,u){const d=e.getContext("2d");if(!d)return;d.clearRect(0,0,e.width,e.height);const{apolloDataStore:f}=u;for(const e of i.contentBlocks){const i=e.offsetPx-r;tf(d,n,t,a,i,e.widthPx,c,e.reversed);const u=f.assemblies.get(e.assemblyName),h=u?.getByRefName(e.refName),p=Math.floor(e.start),g=Math.ceil(e.end);let m=h?.getSequence(p,g);if(!m)return;m=m.toUpperCase(),e.reversed&&(m=o.revcom(m));const y=i-(e.reversed?g-e.end:e.start-p)/n;for(let r=0;r<m.length;r++){const o=e.reversed?g-r:p+r,i=m.slice(r,r+3);nf(d,m[r],r,y,n,c,t),3===i.length&&rf(d,i,y,r,t,a,n,o,c,s,l)}}}(n,r,u,d,f,i,a,s,l,c)}),{name:"LinearApolloReferenceSequenceDisplayRenderSequence"})),l.addDisposer(e,c.autorun((()=>{const{seqTrackOverlayCanvas:t}=e;if(!e.lgv.initialized||e.regionCannotBeRendered()||!t)return;const n=t.getContext("2d");if(!n)return;n.clearRect(0,0,e.lgv.dynamicBlocks.totalWidthPx,e.height);const{hoveredFeature:r,selectedFeature:o,lgv:i,sequenceRowHeight:a,session:s,theme:l}=e;if(!r&&!o)return;const{bpPerPx:c,dynamicBlocks:u,offsetPx:d}=i;!function(e,t,n,r,o,i,a,s,l,c){const{featureTypeOntology:u}=a.apolloDataStore.ontologyManager;if(!u)throw new Error("featureTypeOntology is undefined");for(const a of c.contentBlocks){t.save(),t.beginPath(),t.rect(a.offsetPx-l,0,a.widthPx,e.height),t.clip();for(const e of[r,n?.feature].filter((e=>void 0!==e)))u.isTypeOf(e.type,"CDS")?Qd(t,e,s,l,o,a,i,e._id===r?._id):Zd(t,e,s,l,o,a,i,e._id===r?._id);t.restore()}}(t,n,r,o,a,l,s,c,d,u)}),{name:"LinearApolloReferenceSequenceDisplayRenderSequenceHighlight"}))}})))}(0,t).named("LinearApolloReferenceSequenceDisplay")}const af=p.observer((function(e){const t=s.useTheme(),{model:n}=e,{height:r,regionCannotBeRendered:a,setSeqTrackCanvas:l,setSeqTrackOverlayCanvas:c,setTheme:d}=n,{classes:f}=$d();u.useEffect((()=>{d(t)}),[t,d]);const h=o.getContainingView(n),p=a();return p?i.jsx(s.Alert,{severity:"warning",classes:{message:f.ellipses},slotProps:{root:{className:f.center}},children:i.jsx(s.Tooltip,{title:p,children:i.jsx("div",{children:p})})}):i.jsx(i.Fragment,{children:3/h.bpPerPx>=1?i.jsxs("div",{className:f.canvasContainer,style:{width:h.dynamicBlocks.totalWidthPx,height:r},children:[i.jsx("canvas",{ref:async e=>{await Promise.resolve(),l(e)},width:h.dynamicBlocks.totalWidthPx,height:r,className:f.canvas,"data-testid":"seqTrackCanvas"}),i.jsx("canvas",{ref:async e=>{await Promise.resolve(),c(e)},width:h.dynamicBlocks.totalWidthPx,height:r,className:f.canvas,"data-testid":"seqTrackOverlayCanvas"})]}):null})})),sf=n.ConfigurationSchema("LinearApolloSixFrameDisplay",{},{explicitIdentifier:"displayId",explicitlyTyped:!0}),lf=p.observer((function({sourceFeature:e,filteredTranscripts:t,handleClose:n,onUpdate:r}){const o=[];if(e.children)for(const[,t]of e.children){const e=t.attributes.get("gff_id")?.toString();e&&o.push(e)}const[a,l]=u.useState(t);return i.jsx(Bs,{open:!0,maxWidth:!1,"data-testid":"filter-transcripts-dialog",title:"Filter transcripts by ID",handleClose:n,children:i.jsxs(s.DialogContent,{children:[i.jsx(s.DialogContentText,{children:"Select the alternate transcripts you want to display in the apollo track"}),i.jsx(s.Grid,{container:!0,spacing:2,children:i.jsx(s.Grid,{size:8,children:i.jsx(s.FormGroup,{children:o.map((e=>i.jsx(s.FormControlLabel,{control:i.jsx(s.Checkbox,{checked:!a.includes(e),onChange:()=>{(e=>{const t=a.includes(e)?a.filter((t=>t!==e)):[...a,e];r(t),l(t)})(e)},slotProps:{input:{"aria-label":"controlled"}}}),label:e},e)))})})})]})})}));let cf=null,uf=null,df=null,ff=null;const hf=globalThis.document.createElement("canvas");if(hf?.getContext)for(const e of["forward","backward"])for(const t of["light","dark"]){const n=document.createElement("canvas"),r=10;n.width=n.height=r;const o=n.getContext("2d");if(o){const i="light"===t?"rgba(0,0,0,0)":"rgba(0,0,0,0.75)",a="light"===t?"rgba(255,255,255,0.25)":"rgba(0,0,0,0.50)",s="forward"===e?o.createLinearGradient(0,r,r,0):o.createLinearGradient(0,0,r,r);s.addColorStop(0,i),s.addColorStop(.25,i),s.addColorStop(.25,a),s.addColorStop(.5,a),s.addColorStop(.5,i),s.addColorStop(.75,i),s.addColorStop(.75,a),s.addColorStop(1,a),o.fillStyle=s,o.fillRect(0,0,10,10),"forward"===e?"light"===t?cf=o.createPattern(n,"repeat"):df=o.createPattern(n,"repeat"):"light"===t?uf=o.createPattern(n,"repeat"):ff=o.createPattern(n,"repeat")}}function pf(e,t){for(const n of e)if(Ss(n,t))return!0;return!1}function gf(e,t,n){const{filteredTranscripts:r,session:i}=n,{apolloDataStore:a}=i,{featureTypeOntology:s}=a.ontologyManager;if(!s)throw new Error("featureTypeOntology is undefined");const l=s.isTypeOf(t.type,"transcript"),c=t.attributes.get("gff_id")?.toString();if(c&&r.includes(c))return;const{bp:u,refName:d,regionNumber:f,x:h}=e,{lgv:p}=n;if(l){const e=t;if(!e.children)return;const n=[],r=[];for(const t of e.children.values()){const e=s.isTypeOf(t.type,"exon"),o=s.isTypeOf(t.type,"CDS");e?n.push(t):o&&r.push(t)}const i=n.find((e=>{const[t,n]=o.intersection2(u,u+1,e.min,e.max);return void 0!==t&&void 0!==n}));if(i){const e=tl(i,d,f,p);if(e){const t=nl(i,h,e);if(t)return t}}for(const t of e.cdsLocations)for(const e of t){const t=tl(e,d,f,p);if(t){const e=r.find((e=>{const[t,n]=o.intersection2(u,u+1,e.min,e.max);return void 0!==t&&void 0!==n}));if(e){const n=nl(e,h,t);if(n)return n}}}}}const mf={draw:function(e,t,n,r,i){const{apolloRowHeight:a,lgv:l,session:c,theme:u,highestRow:d,filteredTranscripts:f,selectedFeature:h,showFeatureLabels:p}=r,{bpPerPx:g,displayedRegions:m,offsetPx:y}=l,_=m[i],{refName:v,reversed:b}=_,x=a,w=x,S=x,C=x,A=p?2:1,k=u.palette.text.primary,{attributes:N,children:T,min:R,strand:E}=t;if(!T)return;const{apolloDataStore:I}=c,{featureTypeOntology:j}=I.ontologyManager;if(!j)throw new Error("featureTypeOntology is undefined");const D=[],O=(l.bpToPx({refName:v,coord:R,regionNumber:i})?.offsetPx??0)-y,F=t.length/g,M=b?O-F:O,L=(1==E?3:4)*A*x;e.fillStyle=u.palette.text.primary,e.fillRect(M,L,F,C),e.fillStyle=rl(t,h)?s.alpha("rgb(0,0,0)",.7):s.alpha(u.palette.background.paper,.7),e.fillRect(M+1,L+1,F-2,C-2);const P=rl(t,h),B={x:M,y:L,h:C,text:N.get("gff_id")?.toString(),color:k,isSelected:P};P?D.unshift(B):D.push(B);const q="dark"===u.palette.mode?df:cf,U="dark"===u.palette.mode?ff:uf,z=b?-1:1;let $=null,H=null;E&&([$,H]=E*z==1?[q,U]:[U,q]),$&&H&&(e.fillStyle=$,e.fillRect(M+1,L+1,F-2,(C-2)/2),e.fillStyle=H,e.fillRect(M+1,L+(C-2)/2,F-2,(C-2)/2));const G=new Set;for(const[,t]of T){if(!j.isTypeOf(t.type,"transcript")&&!j.isTypeOf(t.type,"pseudogenic_transcript"))continue;const{children:n,cdsLocations:r}=t;if(!n)continue;const a=t.attributes.get("gff_id")?.toString();if(a&&f.includes(a))continue;for(const[,t]of n){if(!j.isTypeOf(t.type,"exon"))continue;const n=(l.bpToPx({refName:v,coord:t.min,regionNumber:i})?.offsetPx??0)-y,r=t.length/g,o=b?n-r:n,a=L+(C-w)/2,c=rl(t,h);if(e.fillStyle=u.palette.text.primary,e.fillRect(o,a,r,w),r>2){e.clearRect(o+1,a+1,r-2,w-2),e.fillStyle=c?"rgb(0,0,0)":s.alpha("#f5f500",.6),e.fillRect(o+1,a+1,r-2,w-2),$&&H&&(e.fillStyle=$,e.fillRect(o+1,a+1,r-2,(w-2)/2),e.fillStyle=H,e.fillRect(o+1,a+1+(w-2)/2,r-2,(w-2)/2));const n={x:o,y:a,h:w,text:t.attributes.get("gff_id")?.toString(),color:k,isSelected:c};c?D.unshift(n):D.push(n)}}const c=rl(t,h?.parent);let m=0,_=0;for(const n of r){let r=0,a=0,s=1;for(const f of n.toSorted(((e,t)=>e.max-t.max)))if(h&&c&&j.isTypeOf(h.type,"CDS")||!pf(G,f)){const n=(f.max-f.min)/g,w=(l.bpToPx({refName:v,coord:f.min,regionNumber:i})?.offsetPx??0)-y;m=b?w-n:w,e.fillStyle=u.palette.text.primary;const C=o.getFrame(f.min,f.max,t.strand??1,f.phase),k=(p?[0,4,2,0,14,12,10]:[0,2,1,0,7,6,5]).at(C);if(void 0===k)continue;if(_=k*x,e.fillRect(m,_,n,S),s>1){const t=[(m-a)/2+a,Math.max(C<0?x*A*d+1:1,Math.min(r,_)-x/2)];e.strokeStyle="rgb(0, 128, 128)",e.beginPath(),e.moveTo(a,r),e.lineTo(...t),e.stroke(),e.moveTo(...t),e.lineTo(m,_+x/2),e.stroke()}if(a=m+n,r=_+x/2,s+=1,n>2){e.clearRect(m+1,_+1,n-2,S-2);const t=u.palette.framesCDS.at(C)?.main,r=t??"rgb(171,71,188)";e.fillStyle=r,e.fillStyle=h&&c&&j.isTypeOf(h.type,"CDS")?"rgb(0,0,0)":r,e.fillRect(m+1,_+1,n-2,S-2),$&&H&&(e.fillStyle=$,e.fillRect(m+1,_+1,n-2,(S-2)/2),e.fillStyle=H,e.fillRect(m+1,_+(S-2)/2,n-2,(S-2)/2))}G.add(f)}}const N={x:m,y:_,h:S,text:t.attributes.get("gff_id")?.toString(),color:k,isSelected:c};c?D.unshift(N):D.push(N)}p&&function(e,t,n="10px sans-serif"){for(let r=t.length-1;r>=0;--r){const i=t[r];e.fillStyle=i.color;const a=i.x+1,s=i.y+i.h,l=o.measureText(i.text,10);i.isSelected&&(e.font="bold ".concat(n)),i.text&&(e.clearRect(a-5,s,l+10,i.h),e.fillText(i.text,a,s+11,l),e.font=n)}}(e,D)},drawDragPreview:function(e,t){const{apolloDragging:n,apolloRowHeight:r,lgv:o,theme:i}=e,{bpPerPx:a,displayedRegions:l,offsetPx:c}=o;if(!n)return;const{current:u,edge:d,feature:f,start:h}=n,p=Math.floor(h.y/r),g=l[h.regionNumber],m=(g.reversed?g.end-f[d]:f[d]-g.start)/a-c,y=Math.min(u.x,m),_=p*r,v=Math.abs(u.x-m),b=1*r;t.strokeStyle=i.palette.info.main,t.setLineDash([6]),t.strokeRect(y,_,v,b),t.fillStyle=s.alpha(i.palette.info.main,.2),t.fillRect(y,_,v,b)},drawOverlay:function(e,t){const{hoveredFeature:n,apolloRowHeight:r,filteredTranscripts:i,lgv:a,highestRow:s,session:l,showFeatureLabels:c}=e;if(!n)return;const{feature:u}=n,{apolloDataStore:d}=l,{featureTypeOntology:f}=d.ontologyManager;if(!f)throw new Error("featureTypeOntology is undefined");if(!f.isTypeOf(u.type,"transcript"))return;const h=u.attributes.get("gff_id")?.toString();if(h&&i.includes(h))return;const p=e.getFeatureLayoutPosition(u);if(!p)return;const{bpPerPx:g,displayedRegions:m,offsetPx:y}=a,{layoutIndex:_}=p,v=m[_],{refName:b,reversed:x}=v,w=r,S=w,C=c?2:1,{cdsLocations:A,strand:k}=u;for(const e of A){let n=0,r=0,i=1;for(const l of e.toSorted(((e,t)=>e.max-t.max))){const e=(l.max-l.min)/g,u=(a.bpToPx({refName:b,coord:l.min,regionNumber:_})?.offsetPx??0)-y,d=x?u-e:u,f=o.getFrame(l.min,l.max,k??1,l.phase),h=(c?[0,4,2,0,14,12,10]:[0,2,1,0,7,6,5]).at(f);if(void 0===h)continue;const p=h*w;if(i>1){const e=[(d-r)/2+r,Math.max(f<0?w*C*s+1:1,Math.min(n,p)-w/2)];t.strokeStyle="rgb(0, 0, 0)",t.lineWidth=2,t.beginPath(),t.moveTo(r,n),t.lineTo(...e),t.stroke(),t.moveTo(...e),t.lineTo(d,p+w/2),t.stroke()}r=d+e,n=p+w/2,i+=1,e>2&&(t.fillStyle="rgba(255,0,0,0.6)",t.fillRect(d,p,e,S))}}},drawTooltip:function(e,t){const{hoveredFeature:n,apolloRowHeight:r,filteredTranscripts:i,lgv:a,session:l,showFeatureLabels:c,theme:u}=e;if(!n)return;const{feature:d,bp:f}=n,{featureTypeOntology:h}=l.apolloDataStore.ontologyManager;if(!h)throw new Error("featureTypeOntology is undefined");if(!h.isTypeOf(d.type,"transcript"))return;const{attributes:p,strand:g,type:m}=d,y=e.getFeatureLayoutPosition(d);if(!y)return;const _=p.get("gff_id")?.toString();if(_&&i.includes(_))return;const{layoutIndex:v}=y,{bpPerPx:b,displayedRegions:x,offsetPx:w}=a,S=x[v],{refName:C,reversed:A}=S,k=r;let N,T="Loc: ";for(const e of d.cdsLocations)for(const t of e)if(f>=t.min&&f<=t.max){N=t;break}if(!N)return;const{max:R,min:E,phase:I}=N;T+=`${E+1}–${R}`;let j=(a.bpToPx({refName:C,coord:A?R:E,regionNumber:v})?.offsetPx??0)-w;const D=o.getFrame(E,R,g??1,I),O=(c?[0,4,2,0,14,12,10]:[0,2,1,0,7,6,5]).at(D);if(void 0===O)return;const F=O*k,M=(R-E)/b,L=`Type: ${N.type}`,P=p.get("gff_name")?.find((e=>""!==e)),B=[t.measureText(L).width,t.measureText(T).width];P&&B.push(t.measureText(`Parent Type: ${m}`).width,t.measureText(`Parent Name: ${P}`).width);const q=Math.max(...B);j=j+M+5,t.fillStyle=s.alpha(u.palette.text.primary,.7),t.fillRect(j,F,q+4,4===B.length?55:35),t.beginPath(),t.moveTo(j,F),t.lineTo(j-5,F+5),t.lineTo(j,F+10),t.fill(),t.fillStyle=u.palette.background.default;let U=F+12;t.fillText(L,j+2,U),P&&(U+=12,t.fillText(`Parent Type: ${m}`,j+2,U),U+=12,t.fillText(`Parent Name: ${P}`,j+2,U)),U+=12,t.fillText(T,j+2,U)},getContextMenuItems:function(e,t){const{apolloInternetAccount:n,hoveredFeature:r,changeManager:i,filteredTranscripts:a,regions:s,selectedFeature:c,session:u}=e,[d]=s,f=e.getAssemblyId(d.assemblyName),h=[],p=n?n.role:"admin",g=!(p&&["admin","user"].includes(p));if(!r)return h;const{featureTypeOntology:m}=u.apolloDataStore.ontologyManager;if(!m)throw new Error("featureTypeOntology is undefined");if(ul(t)){const{bp:n,feature:r}=t;let s=Ca(r,n);Xs(r,u)&&(s=Ca(r,n,!0));for(const t of s){const n=t.attributes.get("gff_id")?.toString();if(n&&a.includes(n))continue;const r=il(e,t);if(Ys(t,u)){const n=Qs(t,e),a=o.getContainingView(e);if(n.upstream){const o=n.upstream;r.push({label:"Go to upstream exon",icon:el(t.strand,!0,a.displayedRegions.at(0)?.reversed),onClick:()=>{a.navTo(al(o,.1,a.totalBp)),Ws(e,o)}})}if(n.downstream){const o=n.downstream;r.push({label:"Go to downstream exon",icon:el(t.strand,!1,a.displayedRegions.at(0)?.reversed),onClick:()=>{a.navTo(al(o,.1,a.totalBp)),Ws(e,o)}})}r.push({label:"Merge exons",disabled:g,onClick:()=>{u.queueDialog((n=>[ec,{session:u,handleClose:()=>{n()},changeManager:i,sourceFeature:t,sourceAssemblyId:f,selectedFeature:c,setSelectedFeature:t=>{e.setSelectedFeature(t)}}]))}},{label:"Split exon",disabled:g,onClick:()=>{u.queueDialog((n=>[fc,{session:u,handleClose:()=>{n()},changeManager:i,sourceFeature:t,sourceAssemblyId:f,selectedFeature:c,setSelectedFeature:t=>{e.setSelectedFeature(t)}}]))}})}m.isTypeOf(t.type,"gene")&&r.push({label:"Filter alternate transcripts",onClick:()=>{u.queueDialog((n=>[lf,{handleClose:()=>{n()},sourceFeature:t,filteredTranscripts:l.getSnapshot(a),onUpdate:t=>{e.updateFilteredTranscripts(t)}}]))}}),h.push({label:t.type,subMenu:r})}}return h},getContextMenuItemsForFeature:il,onMouseDown:function(e,t,n){const{feature:r}=t,o=gf(t,r,e);o&&(n.stopPropagation(),e.startDrag(t,o.feature,o.edge,!0))},onMouseLeave:function(){},onMouseMove:function(e,t){if(ul(t)){const{feature:n,bp:r}=t;if(e.setHoveredFeature({feature:n,bp:r}),gf(t,n,e))return void e.setCursor("col-resize")}e.setCursor()},onMouseUp:function(e,t){if(!e.apolloDragging&&ul(t)){const{feature:n}=t,{session:r}=e,{apolloDataStore:o}=r,{featureTypeOntology:i}=o.ontologyManager;if(e.setSelectedFeature(n),!i)throw new Error("featureTypeOntology is undefined");let a=!1;for(const[,e]of n.children??[])if(i.isTypeOf(e.type,"CDS")||i.isTypeOf(e.type,"exon")){a=!0;break}(i.isTypeOf(n.type,"transcript")||i.isTypeOf(n.type,"pseudogenic_transcript"))&&a?e.showFeatureDetailsWidget(n,["ApolloTranscriptDetails","apolloTranscriptDetails"]):e.showFeatureDetailsWidget(n)}}};function yf(e,t,n,r,i,a,s,l,c,u,d,f){const h=(u?[0,4,2,0,14,12,10]:[0,2,1,0,7,6,5]).map((e=>e*c)),p=[-1,1];for(const u of p){const p=o.getFrame(l,l+3,u,0),g=h.at(p);if(void 0===g)continue;const m=Math.round(n+r/s),y=0===Math.round(3/s)?1:Math.round(3/s),_=1===u?t:o.revcom(t),v=o.defaultCodonTable[_],b=Gd(v,i,a);b&&(f&&"*"==v||d&&"*"!=v)&&(e.fillStyle=b,e.fillRect(m,g,y,c))}}function _f(e,t){return function(e,t){return function(e,t){const i=function(e,t){return function(e,t){const i=function(e,t){return r.BaseDisplay.named("BaseLinearApolloSixFrameDisplay").props({type:l.types.literal("LinearApolloSixFrameDisplay"),configuration:n.ConfigurationReference(t),graphical:!0,table:!1,showFeatureLabels:!0,showStartCodons:!1,showStopCodons:!0,showCheckResults:!0,zoomThreshold:200,heightPreConfig:l.types.maybe(l.types.refinement("displayHeight",l.types.number,(e=>e>=20))),filteredFeatureTypes:l.types.array(l.types.string)}).views((e=>{const{configuration:t,renderProps:n}=e;return{renderProps:()=>({...n(),...b.getParentRenderProps(e),config:t.renderer})}})).volatile((()=>({scrollTop:0}))).views((e=>({get lgv(){return o.getContainingView(e)},get height(){return e.heightPreConfig?e.heightPreConfig:e.graphical&&e.table?500:e.graphical?e.showFeatureLabels?400:200:300},get zoomThresholdSetting(){return e.zoomThreshold??n.getConf(e,"zoomThreshold")}}))).views((e=>({get rendererTypeName(){return e.configuration.renderer.type},get session(){return o.getSession(e)},get regions(){return e.lgv.dynamicBlocks.contentBlocks.map((({assemblyName:e,end:t,refName:n,start:r})=>({assemblyName:e,refName:n,start:Math.round(r),end:Math.round(t)})))},regionCannotBeRendered(){if(e.lgv&&e.lgv.bpPerPx>=e.zoomThreshold)return"Zoom in to see annotations"}}))).views((e=>({get apolloInternetAccount(){const[t]=e.regions,{internetAccounts:r}=l.getRoot(e),{assemblyName:o}=t,{assemblyManager:i}=e.session,a=i.get(o);if(!a)throw new Error(`No assembly found with name ${o}`);const{internetAccountConfigId:s}=n.getConf(a,["sequence","metadata"]);return r.find((e=>n.getConf(e,"internetAccountId")===s))},get changeManager(){return e.session.apolloDataStore.changeManager},getAssemblyId(t){const{assemblyManager:n}=e.session,r=n.get(t);if(!r)throw new Error(`Could not find assembly named ${t}`);return r.name},get selectedFeature(){return e.session.apolloSelectedFeature},get hoveredFeature(){return e.session.apolloHoveredFeature}}))).actions((e=>({setScrollTop(t){e.scrollTop=t},setHeight:t=>(e.heightPreConfig=Math.max(t,20),e.height),resizeHeight(t){const n=e.height;return this.setHeight(e.height+t)-n},showGraphicalOnly(){e.graphical=!0,e.table=!1},showTableOnly(){e.graphical=!1,e.table=!0},showGraphicalAndTable(){e.graphical=!0,e.table=!0},toggleShowFeatureLabels(){e.showFeatureLabels=!e.showFeatureLabels},toggleShowStartCodons(){e.showStartCodons=!e.showStartCodons},toggleShowStopCodons(){e.showStopCodons=!e.showStopCodons},toggleShowCheckResults(){e.showCheckResults=!e.showCheckResults},updateFilteredFeatureTypes(t){e.filteredFeatureTypes=l.cast(t)},setZoomThresholdSetting({zoomThreshold:t}){e.zoomThreshold=t}}))).views((e=>{const{filteredFeatureTypes:t,trackMenuItems:n}=e;return{trackMenuItems(){const{graphical:r,table:i,showFeatureLabels:a,showStartCodons:s,showStopCodons:c,showCheckResults:u}=e;return[...n(),{type:"subMenu",label:"Appearance",subMenu:[{label:"Show graphical display",type:"radio",checked:r&&!i,onClick:()=>{e.showGraphicalOnly()}},{label:"Show table display",type:"radio",checked:i&&!r,onClick:()=>{e.showTableOnly()}},{label:"Show both graphical and table display",type:"radio",checked:i&&r,onClick:()=>{e.showGraphicalAndTable()}},{label:"Feature Labels",type:"checkbox",checked:a,onClick:()=>{e.toggleShowFeatureLabels()}},{label:"Show start codons",type:"checkbox",checked:s,onClick:()=>{e.toggleShowStartCodons()}},{label:"Show stop codons",type:"checkbox",checked:c,onClick:()=>{e.toggleShowStopCodons()}},{label:"Check Results",type:"checkbox",checked:u,onClick:()=>{e.toggleShowCheckResults()}},{label:"Change zoom threshold",onClick:()=>{o.getSession(e).queueDialog((t=>[zd,{model:e,handleClose:t}]))}}]},{label:"Filter features by type",onClick:()=>{const{session:n}=e;e.session.queueDialog((r=>[Ud,{session:n,handleClose:()=>{r()},featureTypes:l.getSnapshot(t),onUpdate:t=>{e.updateFilteredFeatureTypes(t)}}]))}}]}}})).actions((e=>({setSelectedFeature(t){e.session.apolloSetSelectedFeature(t)},setHoveredFeature(t){e.session.apolloSetHoveredFeature(t)},showFeatureDetailsWidget(t,n){const[r]=e.regions,{assemblyName:o,refName:i}=r,a=e.getAssemblyId(o);if(!a)return;const{session:s}=e,{changeManager:l}=s.apolloDataStore,[c,u]=n??["ApolloFeatureDetailsWidget","apolloFeatureDetailsWidget"],d=s.addWidget(c,u,{feature:t,assembly:a,refName:i,changeManager:l});s.showWidget(d)},afterAttach(){l.addDisposer(e,c.autorun((()=>{e.lgv.initialized&&!e.regionCannotBeRendered()&&(e.session.apolloDataStore.loadFeatures(e.regions),e.lgv.bpPerPx<=e.zoomThreshold&&e.session.apolloDataStore.loadRefSeq(e.regions))}),{name:"LinearApolloSixFrameDisplayLoadFeatures",delay:1e3}))}})))}(0,t);return i.named("LinearApolloSixFrameDisplayLayouts").props({featuresMinMaxLimit:5e5}).volatile((()=>({seenFeatures:c.observable.map()}))).views((e=>({get featuresMinMax(){const{assemblyManager:t}=e.session;return e.lgv.displayedRegions.map((n=>{const r=t.get(n.assemblyName);let i,a;const{end:s,refName:l,start:c}=n;for(const[,t]of e.seenFeatures)l!==r?.getCanonicalRefName(t.refSeq)||!o.doesIntersect2(c,s,t.min,t.max)||t.length>e.featuresMinMaxLimit||(void 0===i&&({min:i}=t),void 0===a&&({max:a}=t),t.minWithChildren<i&&({min:i}=t),t.maxWithChildren>a&&({max:a}=t));if(void 0!==i&&void 0!==a)return[i,a]}))},getGlyph:e=>mf,featureLabelSpacer:t=>e.showFeatureLabels?2*t-1:t}))).actions((e=>({addSeenFeature(t){e.seenFeatures.set(t._id,t)},deleteSeenFeature(t){e.seenFeatures.delete(t)}}))).views((e=>({get geneTrackRowNums(){return[4,5].map((t=>e.featureLabelSpacer(t)))}}))).views((e=>({get featureLayouts(){const{assemblyManager:t}=e.session;return e.lgv.displayedRegions.map(((n,r)=>{const i=t.get(n.assemblyName),a=new Map;if(!e.featuresMinMax[r])return a;const{end:s,refName:c,start:u}=n;for(const[t,n]of e.seenFeatures.entries()){if(!l.isAlive(n)){e.deleteSeenFeature(t);continue}if(c!==i?.getCanonicalRefName(n.refSeq)||!o.doesIntersect2(u,s,n.min,n.max))continue;const{featureTypeOntology:r}=e.session.apolloDataStore.ontologyManager;if(!r)throw new Error("featureTypeOntology is undefined");if(Zs(n,e.session)){const t=1==n.strand?e.geneTrackRowNums[0]:e.geneTrackRowNums[1];a.get(t)||a.set(t,[]);const i=a.get(t);i?.push({rowNum:t,feature:n});const{children:s}=n;if(!s)continue;for(const[,t]of s)if(r.isTypeOf(t.type,"transcript")){const{cdsLocations:n,strand:i,children:s}=t;if(s)for(const[,t]of s){if(!r.isTypeOf(t.type,"exon"))continue;const n=1==t.strand?e.geneTrackRowNums[0]:e.geneTrackRowNums[1],o=a.get(n);o?.push({rowNum:n,feature:t})}for(const r of n)for(const n of r){const r=o.getFrame(n.min,n.max,i??1,n.phase),s=(e.showFeatureLabels?[0,5,3,1,15,13,11]:[0,2,1,0,8,7,6]).at(r);if(void 0===s)continue;a.get(s)||a.set(s,[]);const l=a.get(s);l?.push({rowNum:s,feature:t})}}}}return a}))},getFeatureLayoutPosition(e){const{featureLayouts:t}=this;for(const[n,r]of t.entries())for(const[,t]of r)for(const{feature:r}of t)if(e._id===r._id)return{layoutIndex:n,layoutRow:0,featureRow:0}}}))).views((e=>({get highestRow(){return 5}}))).actions((e=>({afterAttach(){l.addDisposer(e,c.autorun((()=>{if(e.lgv.initialized&&!e.regionCannotBeRendered())for(const t of e.regions){const n=e.session.apolloDataStore.assemblies.get(t.assemblyName),r=n?.getByRefName(t.refName),i=r?.features;if(i)for(const[,n]of i)o.doesIntersect2(t.start,t.end,n.min,n.max)&&!e.seenFeatures.has(n._id)&&e.addSeenFeature(n)}}),{name:"LinearApolloSixFrameDisplaySetSeenFeatures",delay:1e3}))}})))}(0,t).named("LinearApolloSixFrameDisplayRendering").props({apolloRowHeight:20,detailsMinHeight:200,detailsHeight:200,lastRowTooltipBufferHeight:120,isShown:!0,filteredTranscripts:l.types.array(l.types.string)}).volatile((()=>({canvas:null,overlayCanvas:null,collaboratorCanvas:null,theme:s.createTheme()}))).views((e=>({get featuresHeight(){return(e.highestRow+1)*e.apolloRowHeight*(e.showFeatureLabels?2:1)+e.lastRowTooltipBufferHeight}}))).actions((e=>({toggleShown(){e.isShown=!e.isShown},setDetailsHeight(t){e.detailsHeight=e.isShown?Math.max(Math.min(t,e.height-100),Math.min(e.height,e.detailsMinHeight)):t},setCanvas(t){e.canvas=t},setOverlayCanvas(t){e.overlayCanvas=t},setCollaboratorCanvas(t){e.collaboratorCanvas=t},setTheme(t){e.theme=t}}))).actions((e=>({afterAttach(){l.addDisposer(e,c.autorun((()=>{if(!e.lgv.initialized||e.regionCannotBeRendered())return;const t=e.collaboratorCanvas?.getContext("2d");if(t){t.clearRect(0,0,e.lgv.dynamicBlocks.totalWidthPx,e.featuresHeight);for(const n of e.session.collaborators){const{locations:r}=n;if(0===r.length)continue;let o=0;for(const i of e.lgv.displayedRegions){for(const a of r){if(a.refSeq!==i.refName)continue;const{end:r,refSeq:s,start:l}=a,c=e.lgv.bpToPx({refName:s,coord:l,regionNumber:o});if(!c)continue;const u=c.offsetPx-e.lgv.offsetPx,d=(r-l)/e.lgv.bpPerPx;t.fillStyle="rgba(0,255,0,.2)",t.fillRect(u,1,d,100),t.fillStyle="black",t.fillText(n.name,u+1,11,d-2)}o++}}}}),{name:"LinearApolloSixFrameDisplayRenderCollaborators"})),l.addDisposer(e,c.autorun((()=>{const{apolloRowHeight:t,canvas:n,featureLayouts:r,featuresHeight:i,lgv:a,session:s,theme:l,showFeatureLabels:c,showStartCodons:u,showStopCodons:d}=e;if(!a.initialized||e.regionCannotBeRendered())return;const{bpPerPx:f,offsetPx:h,displayedRegions:p,dynamicBlocks:g}=a,m=n?.getContext("2d");if(m){m.clearRect(0,0,g.totalWidthPx,i);for(const[t,n]of r.entries()){const r=p[t];for(const[i,a]of n.entries())for(const{feature:n}of a){if(!Zs(n,e.session))continue;if(!o.doesIntersect2(r.start,r.end,n.min,n.max))continue;const{topLevelFeature:a}=n,s=e.getGlyph(a);void 0!==s&&s.draw(m,a,i,e,t)}}if(u||d){const{apolloDataStore:e}=s;for(const n of g.contentBlocks){const r=e.assemblies.get(n.assemblyName),o=r?.getByRefName(n.refName),i=Math.floor(n.start),a=Math.ceil(n.end);let s=o?.getSequence(i,a);if(!s)break;s=s.toUpperCase();const p=Math.round(n.offsetPx-h-(n.start-i)/f);for(let e=0;e<s.length;e++){const n=i+e;yf(m,s.slice(e,e+3),p,e,l,!0,f,n,t,c,u,d)}}}}}),{name:"LinearApolloSixFrameDisplayRenderFeatures"}))}})))}(0,t);return i.named("LinearApolloSixFrameDisplayMouseEvents").volatile((()=>({apolloDragging:null,cursor:void 0}))).views((e=>({getMousePosition(t){const n=function(e,t){const n=e.currentTarget,{clientX:r,clientY:o}=e,{left:i,top:a}=n.getBoundingClientRect(),s=r-i,l=o-a,{coord:c,index:u,refName:d}=t.pxToBp(s);return{x:s,y:l,refName:d,bp:c,regionNumber:u}}(t,e.lgv),{bp:r,regionNumber:i,y:a}=n,s=Math.floor(a/e.apolloRowHeight)+1,l=e.featureLayouts[i].get(s);if(!l)return n;const{featureTypeOntology:c}=e.session.apolloDataStore.ontologyManager;if(!c)throw new Error("featureTypeOntology is undefined");const u=e.geneTrackRowNums.includes(s)?l.find((e=>"exon"==e.feature.type&&r>=e.feature.min&&r<=e.feature.max))??l.find((e=>r>=e.feature.min&&r<=e.feature.max)):l.find((t=>{const{feature:n}=t,i=n.attributes.get("gff_id")?.toString();if(!c.isTypeOf(n.type,"transcript"))return!1;for(const t of n.cdsLocations)for(const a of t){const t=o.getFrame(a.min,a.max,n.strand??1,a.phase),l=(e.showFeatureLabels?[0,5,3,1,15,13,11]:[0,2,1,0,8,7,6]).at(t);if(s===l&&r>=a.min&&r<=a.max)return void 0===i||!e.filteredTranscripts.includes(i)}return!1}));if(!u)return n;const{feature:d}=u;return{...n,feature:d}}}))).actions((e=>({continueDrag(t,n){if(!e.apolloDragging)throw new Error("continueDrag() called with no current drag in progress");n.stopPropagation(),e.apolloDragging={...e.apolloDragging,current:t}},setDragging(t){e.apolloDragging=t??null}}))).actions((e=>({setCursor(t){e.cursor!==t&&(e.cursor=t)},updateFilteredTranscripts(t){e.filteredTranscripts=l.cast(t)}}))).actions((()=>({onClick(){}})))}(0,t).views((e=>({contextMenuItems(t){const{hoveredFeature:n}=e;if(!n)return[];const r=e.getMousePosition(t),{topLevelFeature:o}=n.feature,i=e.getGlyph(o);return ul(r)?i.getContextMenuItems(e,r):[]}}))).actions((e=>({startDrag(t,n,r,o=!1){e.apolloDragging={start:t,current:t,feature:n,edge:r,shrinkParent:o}},endDrag(){if(!e.apolloDragging)throw new Error("endDrag() called with no current drag in progress");const{current:t,edge:n,feature:r,start:o,shrinkParent:i}=e.apolloDragging;if(Math.abs(t.x-o.x)<=4)return e.setDragging(),void e.setCursor();const{displayedRegions:a}=e.lgv,s=e.getAssemblyId(a[o.regionNumber].assemblyName),l=cl(r,t.bp,n,i),c="max"===n?new Tt({typeName:"LocationEndChange",changedIds:l.map((e=>e.featureId)),changes:l.map((e=>({featureId:e.featureId,oldEnd:e.oldLocation,newEnd:e.newLocation}))),assembly:s}):new Et({typeName:"LocationStartChange",changedIds:l.map((e=>e.featureId)),changes:l.map((e=>({featureId:e.featureId,oldStart:e.oldLocation,newStart:e.newLocation}))),assembly:s});e.changeManager.submit(c),e.setDragging(),e.setCursor()}}))).actions((e=>({onMouseDown(t){const n=e.getMousePosition(t);ul(n)&&e.getGlyph(n.feature).onMouseDown(e,n,t)},onMouseMove(t){const n=e.getMousePosition(t);if(e.apolloDragging)return e.setCursor("col-resize"),void e.continueDrag(n,t);ul(n)?e.getGlyph(n.feature).onMouseMove(e,n,t):(e.setHoveredFeature(),e.setCursor())},onMouseLeave(t){e.setDragging(),e.setHoveredFeature();const n=e.getMousePosition(t);ul(n)&&e.getGlyph(n.feature).onMouseLeave(e,n,t)},onMouseUp(t){const n=e.getMousePosition(t);ul(n)?e.getGlyph(n.feature).onMouseUp(e,n,t):e.setSelectedFeature(),e.apolloDragging&&e.endDrag()}}))).actions((e=>({afterAttach(){l.addDisposer(e,c.autorun((()=>{if(!e.lgv.initialized||e.regionCannotBeRendered())return;const t=e.overlayCanvas?.getContext("2d");if(!t)return;t.clearRect(0,0,e.lgv.dynamicBlocks.totalWidthPx,e.featuresHeight);const{apolloDragging:n,hoveredFeature:r}=e;if(!r)return;const o=e.getGlyph(r.feature);o.drawOverlay(e,t),o.drawTooltip(e,t),n&&e.getGlyph(n.feature.topLevelFeature).drawDragPreview(e,t)}),{name:"LinearApolloSixFrameDisplayRenderMouseoverAndDrag"}))}})))}(0,t).props({tabularEditor:l.types.optional(cd,{})}).named("LinearApolloSixFrameDisplay")}const vf=n.ConfigurationSchema("ApolloPlugin",{ontologies:l.types.array(Fs),featureTypeOntologyName:{description:"Name of the feature type ontology",type:"string",defaultValue:"Sequence Ontology"},hasRole:{description:"Flag used internally by jbrowse-plugin-apollo",type:"boolean",defaultValue:!1},skippedAttributesOnCopy:{description:"Feature attribute keys to skip when copying features",type:"stringArray",defaultValue:[]},geneBackgroundColor:{description:"Color for feature background",type:"string",defaultValue:"jexl:geneBackgroundColor(featureType)",contextVariable:["featureType"]}},{actions:e=>({addOntology(t){e.ontologies.push(t)}})}),bf=(e,t)=>{const{featureTypeOntology:n}=t.apolloDataStore.ontologyManager;if(!n)throw new Error("featureTypeOntology is undefined");return n.isTypeOf(e.type,"gene")||n.isTypeOf(e.type,"transcript")||n.isTypeOf(e.type,"pseudogene")||n.isTypeOf(e.type,"pseudogenic_transcript")},xf=(e,t)=>{const{featureTypeOntology:n}=t.apolloDataStore.ontologyManager;if(!n)throw new Error("featureTypeOntology is undefined");return n.isTypeOf(e.type,"gene")||n.isTypeOf(e.type,"pseudogene")},wf=(e,t)=>{const{featureTypeOntology:n}=t.apolloDataStore.ontologyManager;if(!n)throw new Error("featureTypeOntology is undefined");return n.isTypeOf(e.type,"transcript")||n.isTypeOf(e.type,"pseudogenic_transcript")};function Sf(e){const{attributes:t}=e,n=["gene_name","gene_id","gene_stable_id"];for(const e of n){const n=t?.[e];if(n?.[0])return n[0]}return""}const Cf=e=>{const t=function(e){const{attributes:t}=e,n=["name","gff_name","transcript_name","gene_name"];for(const e of n){const n=t?.[e];if(n?.[0])return n[0]}return""}(e),n=function(e){const{attributes:t}=e,n=["id","gff_id","transcript_id","gene_id","gene_stable_id","stable_id"];for(const e of n){const n=t?.[e];if(n?.[0])return n[0]}return""}(e);return t?`${e.type} - ${t}`:n?`${e.type} - ${n}`:e.type};function Af({annotationFeature:e,assembly:t,handleClose:r,refSeqId:o,session:a,region:c}){const d=a,f=n.readConfObject(d.getPluginConfiguration(),"skippedAttributesOnCopy"),h=new Set(f??[]),{featureTypeOntology:p}=d.apolloDataStore.ontologyManager,g=u.useMemo((()=>Object.keys(e.children??{})),[e]),[m,y]=u.useState(!0),[_,v]=u.useState(g),[b,x]=u.useState(""),[w,S]=u.useState([]),[C,A]=u.useState(!1),[k,N]=u.useState(),T=d.apolloDataStore.assemblies.get(t.name),R=T?.refSeqs.get(o),E=R?.getFeatures(c.start,c.end);u.useEffect((()=>{x("");const e=(()=>{const e=[];for(const t of E??[])if(!(t.min>c.end||t.max<c.start)&&p?.isTypeOf(t.type,"gene")){const n=l.getSnapshot(t);e.push(n)}return e})();S(e),N(e[0])}),[_,p,E,m,c]);const I=async e=>{if(k)for(const n of Object.keys(e)){const r={...e[n]};if(Aa(r,h),r.strand=k.strand,r.children)for(const e of Object.keys(r.children))r.children[e].strand=k.strand;const o=new ht({parentFeatureId:k._id,changedIds:[k._id],typeName:"AddFeatureChange",assembly:t.name,addedFeature:r});await O(o,n)}},j=async n=>{const r={};for(const[e,t]of Object.entries(n)){const n={...t};Aa(n,h),r[e]=n}const i=(new at).toHexString(),a=Math.min(...Object.values(r).map((e=>e.min))),s=Math.max(...Object.values(r).map((e=>e.max))),l=new ht({changedIds:[i],typeName:"AddFeatureChange",assembly:t.name,addedFeature:{_id:i,refSeq:o,min:a,max:s,strand:e.strand,type:"gene",children:r,attributes:{name:[Sf(e)],gene_name:[Sf(e)]}}});await O(l,i)},D=async(e,n)=>{if(!k)return;const r=[];e!==k.min&&r.push(new Et({typeName:"LocationStartChange",changedIds:[k._id],featureId:k._id,assembly:t.name,oldStart:k.min,newStart:e})),n!==k.max&&r.push(new Tt({typeName:"LocationEndChange",changedIds:[k._id],featureId:k._id,assembly:t.name,oldEnd:k.max,newEnd:n}));for(const e of r)await O(e)},O=async(e,t)=>{await d.apolloDataStore.changeManager.submit(e).then((()=>{d.apolloSetSelectedFeature(t)}))};return i.jsxs(Bs,{open:!0,title:"Create Apollo Annotation",handleClose:r,fullWidth:!0,maxWidth:"sm",children:[i.jsx(s.DialogTitle,{fontSize:15,children:"Select the feature to be copied to apollo track"}),i.jsxs(s.DialogContent,{children:[i.jsxs(s.Box,{sx:{ml:3},children:[bf(e,d)&&i.jsx(s.FormControlLabel,{control:i.jsx(s.Checkbox,{size:"small",checked:m,onChange:e=>{const t=e.target.checked;y(t),v(t?g:[])}}),label:`${Cf(e)} (${e.min+1}..${e.max})`}),e.children&&i.jsx(s.Box,{sx:{display:"flex",flexDirection:"column",ml:3},children:Object.values(e.children).filter((e=>wf(e,d))).map((e=>i.jsx(s.FormControlLabel,{control:i.jsx(s.Checkbox,{size:"small",checked:_.includes(e._id),onChange:t=>{((e,t)=>{v((n=>e.target.checked?[...n,t._id]:n.filter((e=>e!==t._id))))})(t,e)}}),label:`${Cf(e)} (${e.min+1}..${e.max})`},e._id)))})]}),w.length>0&&(!m&&_.length>0||m&&wf(e,d))&&i.jsxs("div",{style:{border:"1px solid #ccc",marginTop:20,padding:10,borderRadius:5},children:[i.jsxs(s.Box,{sx:{ml:3},children:[i.jsx(s.Typography,{variant:"caption",fontSize:12,children:"Select the destination feature to copy the selected features"}),i.jsx(s.Box,{sx:{mt:1},children:i.jsx(s.Select,{labelId:"label",style:{width:"100%"},value:k?._id??"",onChange:e=>{const t=w.find((t=>t._id===e.target.value));N(t)},disabled:C,children:w.map((e=>i.jsx(s.MenuItem,{value:e._id,children:`${Cf(e)} (${e.min+1}..${e.max})`},e._id)))})})]}),i.jsx(s.Box,{sx:{ml:3},children:i.jsx(s.FormGroup,{children:i.jsx(s.FormControlLabel,{control:i.jsx(s.Checkbox,{checked:C,onChange:e=>{A(e.target.checked)}}),label:"Create new gene"})})})]})]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{variant:"contained",type:"submit",disabled:0===_.length||!m&&_.length>0&&!k,onClick:async()=>{if(m){if(xf(e,d)&&(await(async()=>{const n={...e};let r;if(Aa(n,h),n.children&&_.length!==Object.values(n.children).length){const o={};for(const e of _)o[e]=n.children[e];r=new ht({changedIds:[e._id],typeName:"AddFeatureChange",assembly:t.name,addedFeature:{...n,children:o}})}else r=new ht({changedIds:[e._id],typeName:"AddFeatureChange",assembly:t.name,addedFeature:n});await O(r,e._id)})(),a.notify("Successfully copied selected gene and transcript(s)","success")),wf(e,d))if(k&&!C){const t={};if(t[e._id]=e,k.max<e.max||k.min>e.min){const n=Math.min(k.min,e.min),r=Math.max(k.max,e.max);await D(n,r),await I(t)}else await I(t);a.notify("Successfully copied selected transcripts to destination gene","success")}else{const t={};t[e._id]=e,await j(t),a.notify("Successfully created a new gene with selected transcripts","success")}}else{if(!e.children)return;if(k&&!C){const t={};for(const n of _)t[n]=e.children[n];const n=Math.min(...Object.values(t).map((e=>e.min))),r=Math.max(...Object.values(t).map((e=>e.max)));if(k.min>n||k.max<r){const e=Math.min(k.min,n),o=Math.max(k.max,r);await D(e,o),await I(t)}else await I(t);a.notify("Successfully copied transcript to destination gene","success")}else{const t={};for(const n of _)t[n]=e.children[n];await j(t),a.notify("Successfully created a new gene with selected transcript","success")}}r()},children:"Create"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:r,children:"Cancel"})]}),b?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:b})}):null]})}function kf(e){return i.jsx(s.SvgIcon,{viewBox:"0 0 856 855",style:{fontSize:18,marginRight:4},...e,children:i.jsxs("g",{children:[i.jsx("path",{style:{opacity:.68,fill:"#AEAEAE"},d:"M276.7,656.9l85-148h102.9c23.1,0,16.1-16,11.1-25l-134-238.5l85-148l185,315.6c0,0-15-26.3,0,0\n\t\t\tc53,92.9-24,243.9-132,243.9c-6,0-4,0-6.4,0H276.7z"}),i.jsx("polygon",{style:{opacity:.85,fill:"#717171"},points:"49.7,756.9 219.1,756.9 513.7,246.9 425.7,99.9 \t\t"}),i.jsx("polygon",{style:{opacity:.85,fill:"#717171"},points:"630,756.9 806.4,756.9 513.7,246.9 425.1,400.2 \t\t"}),i.jsx("polygon",{style:{fill:"#C6C6C6"},points:"175.7,657.3 195.6,657.3 277.9,508.9 254.1,508.9 170.6,657.3 \t\t"}),i.jsx("polygon",{style:{fill:"#C6C6C6"},points:"369.7,657.3 389.6,657.3 471.9,508.9 448.1,508.9 364.6,657.3 \t\t"}),i.jsx("polygon",{style:{fill:"#C6C6C6"},points:"321.7,657.3 341.6,657.3 423.9,508.9 400.1,508.9 316.6,657.3 \t\t"}),i.jsx("polygon",{style:{fill:"#C6C6C6"},points:"224.7,657.3 244.6,657.3 326.9,508.9 303.1,508.9 219.6,657.3 \t\t"}),i.jsx("polygon",{style:{fill:"#C6C6C6"},points:"273.7,657.3 293.6,657.3 375.9,508.9 352.1,508.9 268.6,657.3 \t\t"})]})})}function Nf(e){if("LinearPileupDisplay"!==e.name)return e;const{stateModel:t}=e,n=t.views((e=>({getFirstRegion:()=>o.getContainingView(e).dynamicBlocks.contentBlocks[0],getAssembly(){const t=this.getFirstRegion(),n=o.getSession(e),{assemblyManager:r}=n,{assemblyName:i}=t,a=r.get(i);if(!a)throw new Error(`Could not find assembly named ${i}`);return a},getAnnotationFeature(e,t){const n=e.get("start"),r=e.get("end"),o=e.get("name");let i;const a=e.get("tags"),{ts:s,TS:l,XS:c}=a;for(const e of[s,l,c])!i&&e&&([1,"1","+"].includes(e)?i=1:[-1,"-1","-"].includes(e)&&(i=-1));i??=e.get("strand");const u=function(e){const t=/(\d+)([MIDNSHPX=])/g,n=[];let r;for(;null!==(r=t.exec(e));)n.push([r[2],Number.parseInt(r[1],10)]);return n}(e.get("CIGAR"));let d,f=n;const h=[];for(const[e,t]of u)switch(e){case"M":case"=":case"X":d??=f,f+=t;break;case"N":void 0!==d&&(h.push({start:d,end:f}),d=void 0),f+=t;break;case"D":f+=t;break;case"I":case"S":case"H":case"P":break;default:throw new Error(`Unknown CIGAR operation: ${e}`)}void 0!==d&&h.push({start:d,end:f});const p={_id:at().toHexString(),refSeq:t,min:n,max:r,type:"mRNA",strand:i};if(o&&(p.attributes={},p.attributes.gff_name=[o]),0===h.length)return p;p.children={};for(const e of h){const n={_id:at().toHexString(),refSeq:t,min:e.start,max:e.end,type:"exon",strand:i};p.children[n._id]=n}return p}}))).views((e=>{const t=e.contextMenuItems;return{contextMenuItems(){const n=o.getSession(e),r=e.getAssembly(),i=e.getFirstRegion(),a=e.contextMenuFeature;return a?[...t(),{label:"Create Apollo annotation",icon:kf,onClick:async()=>{const t=n.apolloDataStore.getBackendDriver(i.assemblyName);let o=i.refName;if(t instanceof kl){const e=await t.getRefSeqId(i.assemblyName,i.refName);if(!e)throw new Error(`Could not find refSeq for "${i.refName}"`);o=e}n.queueDialog((t=>[Af,{session:n,handleClose:()=>{t()},annotationFeature:e.getAnnotationFeature(a,o),assembly:r,refSeqId:o,region:i}]))}}]:t()}}}));return e.stateModel=n,e}function Tf(e,t){const n=e.get("subfeatures");return[{start:e.get("start")+1,end:e.get("end"),seq_id:t,source:e.get("source")??null,type:e.get("type")??null,score:e.get("score")??null,strand:e.get("strand")?1===e.get("strand")?"+":"-":null,phase:null!==e.get("phase")||void 0!==e.get("phase")?e.get("phase"):null,attributes:jf(e),derived_features:[],child_features:n?n.map((e=>Tf(e,t))):[]}]}function Rf(e,t){return Fn(Tf(e,t))}const Ef=new Set(["start","end","type","strand","refName","subfeatures","derived_features","phase","source","score","parent","__jbrowsefmt","length","position","uniqueId","exonFrames","parentId","thickStart","thickEnd","_lineHash"]),If={id:"gff_id",name:"gff_name",alias:"gff_alias",target:"gff_target",gap:"gff_gap",derives_from:"gff_derives_from",note:"gff_note",dbxref:"gff_dbxref",ontology_term:"gff_ontology_term",is_circular:"gff_is_circular"};function jf(e){const t={};for(const[n,r]of Object.entries(e.toJSON()))Ef.has(n)||(t[If[n]??n]=Array.isArray(r)?r.map(String):[String(r)]);return t}function Df(e){if("LinearBasicDisplay"!==e.name)return e;const{stateModel:t}=e,n=t.views((e=>({getFirstRegion:()=>o.getContainingView(e).dynamicBlocks.contentBlocks[0],getAssembly(){const t=e.getFirstRegion(),n=o.getSession(e),{assemblyManager:r}=n,{assemblyName:i}=t,a=r.get(i);if(!a)throw new Error(`Could not find assembly named ${i}`);return a}}))).views((e=>{const t=e.contextMenuItems;return{contextMenuItems(){const n=o.getSession(e),r=e.getAssembly(),i=e.getFirstRegion(),a=e.contextMenuFeature;if(!a)return t();const s=function(e){let t=e,n=e.get("parent");for(;n;)t=n,n=n.get("parent");return t}(a);return[...t(),{label:"Create Apollo annotation",icon:kf,onClick:async()=>{const e=n.apolloDataStore.getBackendDriver(i.assemblyName);let t=i.refName;if(e instanceof kl){const n=await e.getRefSeqId(i.assemblyName,i.refName);if(!n)throw new Error(`Could not find refSeq for "${i.refName}"`);t=n}const o=Rf(s,t);n.queueDialog((e=>[Af,{session:n,handleClose:()=>{e()},annotationFeature:o,assembly:r,refSeqId:t,region:i}]))}}]}}}));return e.stateModel=n,e}var Of=a.createSvgIcon(i.jsx("path",{d:"m12 8-6 6 1.41 1.41L12 10.83l4.59 4.58L18 14z"}),"ExpandLess"),Ff=a.createSvgIcon(i.jsx("path",{d:"M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2m-6 9c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2m3.1-9H8.9V6c0-1.71 1.39-3.1 3.1-3.1s3.1 1.39 3.1 3.1z"}),"Lock"),Mf=a.createSvgIcon(i.jsx("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m1 15h-2v-2h2zm0-4h-2V7h2z"}),"Error");const Lf=p.observer((function({display:e}){const{classes:t}=$d(),{apolloDragging:n,apolloRowHeight:r,lgv:a,session:l,showCheckResults:c}=e,{assemblyManager:u}=l;return c?a.dynamicBlocks.contentBlocks.map((c=>{const d=a.bpPerPx*r,f=u.get(c.assemblyName);return f?Hd([...l.apolloDataStore.checkResults.values()].filter((e=>f.isValidRefName(e.refSeq)&&f.getCanonicalRefName(e.refSeq)===c.refName&&o.doesIntersect2(c.start,c.end,e.start,e.end))),d).map((o=>{const a=Math.round(ud(e,o.range,c)),[l]=o.featureIds;if(!l)return null;const u=e.getRowForFeature(l)??0;return i.jsx(s.Tooltip,{title:o.message,children:i.jsx(s.Box,{className:t.box,style:{top:u*r,left:a,height:r,width:r,pointerEvents:n?"none":"auto"},children:i.jsx(s.Badge,{className:t.badge,badgeContent:o.count,color:"primary",overlap:"circular",anchorOrigin:{vertical:"bottom",horizontal:"right"},invisible:o.count<=1,children:i.jsx(s.Avatar,{className:t.avatar,children:i.jsx(Mf,{"data-testid":`ErrorIcon-${o.start}`})})})})},o._id)})):null})):null})),Pf=p.observer((function(e){const{mouseCooordinate:t,session:n,dragging:r}=e,{apolloHoveredFeature:o}=n;if(!t||!o||r)return;const[a,s]=t,{feature:l}=o,{attributes:c,min:u,max:d}=l,f=`Loc: ${u+1}..${d}`,p=`Type: ${l.type}`,g=c.get("gff_name")?.find((e=>""!==e));return i.jsxs(h.BaseTooltip,{clientPoint:{x:a,y:s},placement:"top-start",children:[p,i.jsx("br",{}),g?i.jsxs(i.Fragment,{children:[g,i.jsx("br",{})]}):null,f]})})),Bf=p.observer((function(e){const{model:t}=e,{apolloDragging:n,cursor:r,featuresHeight:a,isShown:s,onMouseDown:l,onMouseLeave:c,onMouseMove:d,onMouseUp:f,session:h,setOverlayCanvas:p}=t,{classes:g}=$d(),m=o.getContainingView(t),[y,_]=u.useState();if(!s)return null;const v=a(m.assemblyNames[0]);return i.jsxs(i.Fragment,{children:[i.jsx("canvas",{ref:async e=>{await Promise.resolve(),p(e)},width:m.dynamicBlocks.totalWidthPx,height:v,onMouseMove:(...e)=>{const[t]=e;_([t.clientX,t.clientY]),d(...e)},onMouseLeave:(...e)=>{_(void 0),c(...e)},onMouseDown:l,onMouseUp:f,className:g.canvas,style:{cursor:r??"default"},"data-testid":"overlayCanvas"}),i.jsx(Pf,{mouseCooordinate:y,session:h,dragging:Boolean(n)})]})})),qf=p.observer((function(e){const t=s.useTheme(),{model:n}=e,{loading:r,contextMenuItems:a,featuresHeight:l,isShown:c,regionCannotBeRendered:d,session:f,setCanvas:p,setCollaboratorCanvas:g,setTheme:m}=n,{classes:y}=$d(),_=o.getContainingView(n);u.useEffect((()=>{m(t)}),[t,m]);const[v,b]=u.useState(),[x,w]=u.useState([]),S=d();if(!c)return null;const C=l(_.assemblyNames[0]);return i.jsxs("div",{className:y.canvasContainer,style:{width:_.dynamicBlocks.totalWidthPx,height:C},onContextMenu:e=>{e.preventDefault(),x.length>0?w([]):(b([e.clientX,e.clientY]),w(a(e)))},children:[f.isLocked?i.jsx("div",{className:y.locked,"data-testid":"lock-icon",children:i.jsx(Ff,{})}):null,r?i.jsx("div",{className:y.loading,children:i.jsx(s.CircularProgress,{size:"18px"})}):null,S?i.jsx(s.Alert,{severity:"warning",classes:{message:y.ellipses},slotProps:{root:{className:y.center}},children:i.jsx(s.Tooltip,{title:S,children:i.jsx("div",{children:S})})}):i.jsxs(i.Fragment,{children:[i.jsx("canvas",{ref:async e=>{await Promise.resolve(),g(e)},width:_.dynamicBlocks.totalWidthPx,height:C,className:y.canvas,"data-testid":"collaboratorCanvas"}),i.jsx("canvas",{ref:async e=>{await Promise.resolve(),p(e)},width:_.dynamicBlocks.totalWidthPx,height:C,className:y.canvas,"data-testid":"canvas"}),i.jsx(Bf,{model:n}),i.jsx(Lf,{display:n}),i.jsx(h.Menu,{open:x.length>0,onMenuItemClick:(e,t)=>{t(),w([])},onClose:()=>{w([])},slotProps:{transition:{onExit:()=>{w([])}}},anchorReference:"anchorPosition",anchorPosition:v?{top:v[1],left:v[0]}:void 0,menuItems:x})]})]})})),Uf=p.observer((function({model:e,hrStyle:t={margin:0,top:0,color:"black"},idx:n}){const{apolloRowHeight:r,highestRow:o,showFeatureLabels:a}=e,s=a?2:1;return i.jsx("div",{style:{position:"absolute",left:0,top:r*s*(o+1)/2+n*s*r,width:"100%"},children:i.jsx("hr",{style:t})})})),zf=p.observer((function(e,t){const n=s.useTheme(),{model:r}=e,{apolloRowHeight:a,contextMenuItems:l,cursor:c,featuresHeight:d,geneTrackRowNums:f,isShown:p,onMouseDown:g,onMouseLeave:m,onMouseMove:y,onMouseUp:_,regionCannotBeRendered:v,session:b,setCanvas:x,setCollaboratorCanvas:w,setOverlayCanvas:S,setTheme:C,showCheckResults:A,showFeatureLabels:k}=r,{classes:N}=$d(),T=o.getContainingView(r);u.useEffect((()=>{C(n)}),[n,C]);const[R,E]=u.useState(),[I,j]=u.useState([]),D=v();if(!p)return null;const{assemblyManager:O}=b;return i.jsx(i.Fragment,{children:i.jsxs("div",{className:N.canvasContainer,style:{width:T.dynamicBlocks.totalWidthPx,height:d},onContextMenu:e=>{e.preventDefault(),I.length>0?j([]):(E([e.clientX,e.clientY]),j(l(e)))},children:[b.isLocked?i.jsx("div",{className:N.locked,"data-testid":"lock-icon",children:i.jsx(Ff,{})}):null,D?i.jsx(s.Alert,{severity:"warning",classes:{message:N.ellipses},slotProps:{root:{className:N.center}},children:i.jsx(s.Tooltip,{title:D,children:i.jsx("div",{children:D})})}):i.jsxs(i.Fragment,{children:[i.jsx(Uf,{model:r,idx:0}),i.jsx(Uf,{model:r,hrStyle:{margin:0,top:0,color:"grey",opacity:.4},idx:1}),i.jsx(Uf,{model:r,idx:2}),i.jsx("canvas",{ref:async e=>{await Promise.resolve(),w(e)},width:T.dynamicBlocks.totalWidthPx,height:d,className:N.canvas,"data-testid":"collaboratorCanvas"}),i.jsx("canvas",{ref:async e=>{await Promise.resolve(),x(e)},width:T.dynamicBlocks.totalWidthPx,height:d,className:N.canvas,"data-testid":"canvas"}),i.jsx("canvas",{ref:async e=>{await Promise.resolve(),S(e)},width:T.dynamicBlocks.totalWidthPx,height:d,onMouseMove:y,onMouseLeave:m,onMouseDown:g,onMouseUp:_,className:N.canvas,style:{cursor:c??"default"},"data-testid":"overlayCanvas"}),T.displayedRegions.flatMap(((e,n)=>{const r=T.bpPerPx*a,l=O.get(e.assemblyName);return A?Hd([...b.apolloDataStore.checkResults.values()].filter((t=>l?.isValidRefName(t.refSeq)&&l.getCanonicalRefName(t.refSeq)===e.refName&&o.doesIntersect2(e.start,e.end,t.start,t.end))),r).map((r=>{const l=(T.bpToPx({refName:e.refName,coord:r.start,regionNumber:n})?.offsetPx??0)-T.offsetPx,[c]=r.featureIds;if(!c?.parent||!Zs(c.parent,b))return null;let u;for(const e of c.cdsLocations)for(const t of e){const e=o.getFrame(t.min,t.max,c.strand??1,t.phase),n=(k?[0,5,3,1,15,13,11]:[0,2,1,0,8,7,6]).at(e);if(void 0!==n&&r.start>=t.min&&r.start<=t.max){u=n-1;break}}return void 0===u&&(u=(1==c.strand?f[0]:f[1])-1),i.jsx(s.Tooltip,{title:r.message,children:i.jsx(s.Box,{className:N.box,style:{top:u*a,left:l,height:a,width:a,pointerEvents:t?"none":"auto"},children:i.jsx(s.Badge,{className:N.badge,badgeContent:r.count,color:"primary",overlap:"circular",anchorOrigin:{vertical:"bottom",horizontal:"right"},invisible:r.count<=1,children:i.jsx(s.Avatar,{className:N.avatar,children:i.jsx(Mf,{"data-testid":`ErrorIcon-${r.start}`})})})})},r._id)})):null})),i.jsx(h.Menu,{open:I.length>0,onMenuItemClick:(e,t)=>{t(),j([])},onClose:()=>{j([])},slotProps:{transition:{onExit:()=>{j([])}}},anchorReference:"anchorPosition",anchorPosition:R?{top:R[1],left:R[0]}:void 0,style:{zIndex:n.zIndex.tooltip},menuItems:I})]})]})})})),$f=ma()((e=>({shading:{background:s.alpha(e.palette.primary.main,.2),overflowX:"hidden"},details:{background:e.palette.background.paper},accordionControl:{height:12,width:"100%","&:hover":{background:e.palette.action.hover},display:"flex",alignItems:"center",justifyContent:"center"},accordionRoot:{background:e.palette.divider},resizeHandle:{width:"100%",height:4,position:"absolute",cursor:"row-resize",zIndex:100},expandIcon:{},title:{userSelect:"none"},alertContainer:{display:"flex",alignItems:"center",justifyContent:"center"}})));function Hf(e,t){const{apolloRowHeight:n,selectedFeature:r}=e;if(t.current&&r){let o;if("getFeatureLayoutPosition"in e){const t=e.getFeatureLayoutPosition(r);t&&(o=t.layoutRow+t.featureRow)}else o=e.getRowForFeature(r);void 0!==o&&t.current.scroll({top:o*n,behavior:"smooth"})}}const Gf=({onResize:e})=>{const{classes:t}=$f(),n=u.useCallback((t=>{t.stopPropagation(),t.preventDefault(),e(t.movementY)}),[e]);return i.jsx("div",{onMouseDown:e=>{e.stopPropagation();const t=new AbortController,{signal:r}=t;function o(){t.abort(new DOMException("Canceling drag event listener","AbortError"))}globalThis.addEventListener("mousemove",n,{signal:r}),globalThis.addEventListener("mouseup",o,{signal:r}),globalThis.addEventListener("mouseleave",o,{signal:r})},onClick:e=>{e.stopPropagation(),e.preventDefault()},className:t.resizeHandle})},Vf=p.observer((function({onClick:e,onResize:t,open:n,title:r}){const{classes:o}=$f();return i.jsxs("div",{className:o.accordionRoot,children:[n&&t?i.jsx(Gf,{onResize:t}):null,i.jsxs("div",{className:o.accordionControl,onClick:e,children:[i.jsx(n?Of:Uc,{className:o.expandIcon}),r?i.jsx(s.Typography,{className:o.title,variant:"caption",component:"span",children:r}):null]})]})})),Wf=p.observer((function({model:e,...t}){const n=o.getSession(e),{ontologyManager:r}=n.apolloDataStore,{featureTypeOntology:a}=r,l=a?.dataStore,{classes:c}=$f(),{graphical:d,height:f,isShown:h,selectedFeature:p,table:g,tabularEditor:m,toggleShown:y}=e,_=u.useRef(null);u.useEffect((()=>{Hf(e,_)}),[e,p]);const v=t=>{e.setDetailsHeight(e.detailsHeight-t)};if(!l)return i.jsx("div",{className:c.alertContainer,children:i.jsx(s.Alert,{severity:"error",children:"Could not load feature type ontology."})});if(d&&g){const n=m.isShown?e.detailsHeight:0,r=h?f-e.detailsHeight-24:0;return i.jsxs("div",{style:{height:f},children:[i.jsx(Vf,{open:h,title:"Graphical",onClick:y}),i.jsx("div",{className:c.shading,ref:_,style:{height:r},children:i.jsx(qf,{model:e,...t})}),i.jsx(Vf,{title:"Table",open:m.isShown,onClick:m.togglePane,onResize:v}),i.jsx("div",{className:c.details,style:{height:n},children:i.jsx(ld,{model:e})})]})}return i.jsx("div",d?{className:c.shading,ref:_,style:{height:f},children:i.jsx(qf,{model:e,...t})}:{className:c.details,style:{height:f},children:i.jsx(ld,{model:e})})})),Jf=p.observer((function({model:e,...t}){const n=o.getSession(e),{ontologyManager:r}=n.apolloDataStore,{featureTypeOntology:a}=r,l=a?.dataStore,{classes:c}=$f(),{detailsHeight:d,graphical:f,height:h,isShown:p,selectedFeature:g,table:m,tabularEditor:y,toggleShown:_}=e,v=u.useRef(null);u.useEffect((()=>{Hf(e,v)}),[e,g]);const b=t=>{e.setDetailsHeight(d-t)};if(!l)return i.jsx("div",{className:c.alertContainer,children:i.jsx(s.Alert,{severity:"error",children:"Could not load feature type ontology."})});if(f&&m){const n=y.isShown?d:0,r=p?h-d-24:0;return i.jsxs("div",{style:{height:h},children:[i.jsx(Vf,{open:p,title:"Graphical",onClick:_}),i.jsx("div",{className:c.shading,ref:v,style:{height:r},children:i.jsx(zf,{model:e,...t})}),i.jsx(Vf,{title:"Table",open:y.isShown,onClick:y.togglePane,onResize:b}),i.jsx("div",{className:c.details,style:{height:n},children:i.jsx(ld,{model:e})})]})}return i.jsx("div",f?{className:c.shading,ref:v,style:{height:h},children:i.jsx(zf,{model:e,...t})}:{className:c.details,style:{height:h},children:i.jsx(ld,{model:e})})}));var Kf=a.createSvgIcon(i.jsx("path",{d:"m17 7-1.41 1.41L18.17 11H8v2h10.17l-2.58 2.58L17 17l5-5zM4 5h8V3H4c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h8v-2H4z"}),"Logout"),Yf=a.createSvgIcon(i.jsx("path",{d:"M18.4 10.6C16.55 8.99 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16c1.05-3.19 4.05-5.5 7.6-5.5 1.95 0 3.73.72 5.12 1.88L13 16h9V7z"}),"Redo"),Xf=a.createSvgIcon(i.jsx("path",{d:"M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8"}),"Undo"),Zf=a.createSvgIcon(i.jsx("path",{d:"M17 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V7zm-5 16c-1.66 0-3-1.34-3-3s1.34-3 3-3 3 1.34 3 3-1.34 3-3 3m3-10H5V5h10z"}),"Save");const Qf=l.types.model("JobsManager",{}).views((e=>({get jobStatusWidget(){const{widgets:t}=o.getSession(e);return t.get("JobsList")??o.getSession(e).addWidget("JobsListWidget","JobsList")}}))).actions((e=>({update(t,n,r){e.jobStatusWidget.updateJobStatusMessage(t,n),r&&e.jobStatusWidget.updateJobProgressPct(t,r)},abortJob(t,n){const r=o.getSession(e);if(o.isSessionModelWithWidgets(r)){r.showWidget(e.jobStatusWidget),e.jobStatusWidget.updateJobStatusMessage(t,n??"Aborted unexpectedly");const o=e.jobStatusWidget.jobs.findIndex((e=>e.name===t));e.jobStatusWidget.addAbortedJob({...e.jobStatusWidget.jobs[o]}),e.jobStatusWidget.removeJob(t),r.notify("Job aborted","info")}},runJob(t){const n=o.getSession(e);o.isSessionModelWithWidgets(n)&&(n.showWidget(e.jobStatusWidget),e.jobStatusWidget.addJob(t))},done(t){const n=o.getSession(e);o.isSessionModelWithWidgets(n)&&(n.showWidget(e.jobStatusWidget),e.jobStatusWidget.removeJob(t.name),e.jobStatusWidget.addFinishedJob({name:t.name,statusMessage:"All operations successful",progressPct:100,cancelCallback:t.cancelCallback}))}})));function eh(e){const t={};if(e.children)for(const n of Object.values(e.children)){const e=eh(n);t[e._id]=e}return{...e,_id:(new at).toHexString(),children:e.children?t:void 0}}function th({assemblyName:e,changeManager:t,existingFeature:n,featureSnapshot:r,handleClose:o}){const[a,l]=u.useState("keepExisting"),[c,d]=u.useState(""),[f,h]=u.useState(!1);return i.jsxs(Bs,{open:!0,title:"Duplicate Feature Detected",handleClose:o,maxWidth:"sm",fullWidth:!0,children:[i.jsxs(s.DialogContent,{children:[i.jsxs(s.DialogContentText,{children:["A feature with ID “",r._id,"” already exists. How would you like to resolve this conflict?"]}),i.jsxs(s.FormControl,{component:"fieldset",sx:{mt:2},children:[i.jsx(s.FormLabel,{component:"legend",children:"Resolution"}),i.jsxs(s.RadioGroup,{value:a,onChange:e=>{l(e.target.value)},children:[i.jsx(s.FormControlLabel,{value:"keepExisting",control:i.jsx(s.Radio,{}),label:"Keep the existing feature"}),i.jsx(s.FormControlLabel,{value:"useNew",control:i.jsx(s.Radio,{}),label:"Replace with the new feature"}),i.jsx(s.FormControlLabel,{value:"keepBoth",control:i.jsx(s.Radio,{}),label:"Keep both (assign new IDs to the incoming feature)"})]})]}),c?i.jsx(s.DialogContentText,{color:"error",sx:{mt:1},children:c}):null]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{variant:"contained",onClick:async()=>{d(""),h(!0);try{if("useNew"===a){const o=new pt({typeName:"DeleteFeatureChange",assembly:e,changedIds:[n._id],deletedFeature:n});await t.submit(o);const i=new ht({typeName:"AddFeatureChange",assembly:e,changedIds:[r._id],addedFeature:r});await t.submit(i)}else if("keepBoth"===a){const n=eh(r),o=new ht({typeName:"AddFeatureChange",assembly:e,changedIds:[n._id],addedFeature:n});await t.submit(o)}o()}catch(e){d(String(e)),h(!1)}},disabled:f,children:"Confirm"}),i.jsx(s.Button,{onClick:o,disabled:f,children:"Cancel"})]})]})}function nh(e,t){const r=e.evaluateExtensionPoint("Apollo-extendAnnotationFeature",cu),i=function(e){return l.types.model("ClientDataStore",{typeName:l.types.optional(l.types.literal("Client"),"Client"),assemblies:l.types.map(fu),checkResults:l.types.map(hu),ontologyManager:l.types.optional(Os,{})}).views((t=>({get internetAccounts(){return l.getRoot(t).internetAccounts},get pluginConfiguration(){return l.getRoot(t).jbrowse.configuration.ApolloPlugin},getFeature:n=>l.resolveIdentifier(e,t.assemblies,n)}))).actions((e=>({addAssembly(t,n){const r={_id:t,refSeqs:{}};return n&&(r.backendDriverType=n),e.assemblies.put(r)}}))).actions((e=>({addFeature(t,n){const r=o.getSession(e),{assemblyManager:i}=r;let a=e.assemblies.get(t);if(!a){if(!i.get(t))throw new Error(`Could not find assembly "${t}" to add feature "${n._id}"`);a=e.addAssembly(t)}let s=a.refSeqs.get(n.refSeq);if(!s){const e=i.get(t);if(!e)throw new Error(`Could not find assembly "${t}" to add feature "${n._id}"`);const r=e.getCanonicalRefName(n.refSeq);if(!r)throw new Error(`Could not find refSeq "${n.refSeq}" to add feature "${n._id}"`);s=a.addRefSeq(n.refSeq,r)}s.features.put(n)},deleteFeature(t){const n=e.getFeature(t);if(!n)throw new Error(`Could not find feature "${t}" to delete`);const{_id:r,parent:o}=n;o?o.deleteChild(t):l.getParentOfType(n,du).deleteFeature(r)},deleteAssembly(t){e.assemblies.delete(t)},addCheckResult(t){e.checkResults.put(t)},addCheckResults(t){for(const n of t)e.checkResults.has(n._id)||e.checkResults.put(n)},deleteCheckResult(t){e.checkResults.delete(t)},clearCheckResults(){e.checkResults.clear()}}))).volatile((e=>({changeManager:new Al(e),collaborationServerDriver:new kl(e),localDriver:new Sl(e)}))).actions((e=>({afterCreate(){l.addDisposer(e,c.autorun((()=>{const{ontologyManager:t,pluginConfiguration:r}=e,i=r.ontologies;for(const r of i||[]){const[i,a,s,l]=[n.readConfObject(r,"name"),n.readConfObject(r,"version"),n.readConfObject(r,"source"),n.readConfObject(r,"textIndexFields")];if(!t.findOntology(i)){const n=o.getSession(e),{jobsManager:r}=n,c=new AbortController,u=`Loading ontology "${i}"`,d={name:u,statusMessage:`Loading ontology "${i}", version "${a}", this may take a while`,progressPct:0,cancelCallback:()=>{c.abort(new DOMException(`Canceling loading of ontology "${i}"`,"AbortError")),r.abortJob(d.name)}};t.addOntology(i,a,s,{textIndexing:{indexFields:l},update:(e,t)=>{0!==t?100!==t?r.update(u,e,t):r.done(d):r.runJob(d)}})}}})))}}))).views((e=>({getBackendDriver(t){const r=o.getSession(e),{assemblyManager:i}=r,a=i.get(t);if(!a)return;const{internetAccountConfigId:s}=n.getConf(a,["sequence","metadata"]);return s?e.collaborationServerDriver:e.localDriver},getInternetAccount(t,r){if(!(t??r))throw new Error("Must provide either assemblyName or internetAccountId");let i=r;if(t&&!i){const{assemblyManager:r}=o.getSession(e),a=r.get(t);if(!a)throw new Error(`No assembly found with name ${t}`);({internetAccountConfigId:i}=n.getConf(a,["sequence","metadata"]))}const{internetAccounts:a}=e,s=a.find((e=>e.internetAccountId===i));if(!s)throw new Error(`No InternetAccount found with config id ${r}`);return s}}))).actions((e=>({loadFeatures:l.flow((function*(t){for(const n of t){const t=e.getBackendDriver(n.assemblyName);if(!t)return;const[r,o]=yield t.getFeatures(n);if(0===r.length)continue;const{assemblyName:i,refName:a}=n,s=e.assemblies.get(i)??e.assemblies.put({_id:i,refSeqs:{}}),[l]=r,c=s.refSeqs.get(l.refSeq)??s.refSeqs.put({_id:l.refSeq,name:a,features:{}});for(const e of r)c.features.has(e._id)||c.features.put(e);e.addCheckResults(o)}})),loadRefSeq:l.flow((function*(t){for(const n of t){const t=e.getBackendDriver(n.assemblyName);if(!t)return;const{refSeq:r,seq:o}=yield t.getSequence(n),{assemblyName:i,end:a,refName:s,start:l}=n,c=e.assemblies.get(i)??e.assemblies.put({_id:i,refSeqs:{}});(c.refSeqs.get(r)??c.refSeqs.put({_id:r,name:s,sequence:[]})).addSequence({start:l,stop:a,sequence:o})}}))})))}(r),a=t.props({apolloDataStore:l.types.optional(i,{typeName:"Client"}),apolloSelectedFeature:l.types.safeReference(r),jobsManager:l.types.optional(Qf,{}),isLocked:l.types.optional(l.types.boolean,!1),changeInProgress:l.types.optional(l.types.boolean,!1)}).volatile((()=>({apolloHoveredFeature:void 0,abortController:new AbortController}))).extend((()=>{const e=c.observable.array([]);return{views:{get collaborators(){return e}},actions:{addOrUpdateCollaborator(t){const n=e.find((e=>e.id===t.id));n?n.locations=t.locations:e.push(t)}}}})).actions((e=>({apolloSetSelectedFeature(t){e.apolloSelectedFeature=t},apolloSetHoveredFeature(t){e.apolloHoveredFeature=t},addApolloLocalTrackConfig(t){const n=`apollo_track_${t.name}`;e.tracks.some((e=>e.trackId===n))||l.getRoot(e).jbrowse.addTrackConf({type:"ApolloTrack",trackId:n,name:`Annotations (${t.displayName})`,assemblyNames:[t.name],category:["Apollo"]})},toggleLocked(){e.isLocked=!e.isLocked},setChangeInProgress(t){e.changeInProgress=t},getPluginConfiguration(){const{jbrowse:t}=l.getRoot(e);return t.configuration.ApolloPlugin},broadcastLocations(){const{internetAccounts:t}=l.getRoot(e),n=[];for(const t of e.views){if("LinearGenomeView"!==t.type)return;const r=t;if(r.initialized){const{dynamicBlocks:t}=r;for(const r of t.contentBlocks){const{assemblyName:t,end:o,refName:i,start:a}=r,s=e.apolloDataStore.assemblies.get(t);"CollaborationServerDriver"===s?.backendDriverType&&n.push({assemblyName:t,refName:i,start:a,end:o})}}}if(0===n.length){for(const e of t)Xl(e)&&e.postUserLocation([]);return}const r=[];for(const e of t)if(Xl(e)){for(const e of n)r.push({assemblyId:e.assemblyName,refSeq:e.refName,start:e.start,end:e.end});e.postUserLocation(r)}}}))).actions((e=>({apolloSetEventualSelectedFeature:c.flow((function*(t){yield c.when((()=>Boolean(e.apolloDataStore.getFeature(t)))),e.apolloSetSelectedFeature(t)}))}))).volatile((e=>({previousSnapshot:l.getSnapshot(e)}))).actions((e=>({afterCreate(){l.applySnapshot(e,{name:e.name,id:e.id});const{internetAccounts:t,jbrowse:r,reloadPluginManagerCallback:o}=l.getRoot(e);l.addDisposer(e,c.autorun((()=>{const n=[];for(const t of e.views){if("LinearGenomeView"!==t.type)return;const r=t;if(r.initialized){const{dynamicBlocks:t}=r;for(const r of t.contentBlocks){const{assemblyName:t,end:o,refName:i,start:a}=r,s=e.apolloDataStore.assemblies.get(t);"CollaborationServerDriver"===s?.backendDriverType&&n.push({assemblyName:t,refName:i,start:a,end:o})}}}if(0===n.length){for(const e of t)Xl(e)&&e.postUserLocation([]);return}const r=[];for(const e of t)if(Xl(e)){for(const e of n)r.push({assemblyId:e.assemblyName,refSeq:e.refName,start:e.start,end:e.end});e.postUserLocation(r)}}),{name:"ApolloSessionBroadcastLocations"})),l.addDisposer(e,c.autorun((async i=>{const a=r.configuration.ApolloPlugin,s=n.readConfObject(a,"hasRole"),c=n.readConfObject(a,"featureTypeOntologyName"),u=t.some((e=>Xl(e))),d=e.assemblyManager.assemblies.filter((e=>!n.getConf(e,["sequence","metadata"]).apollo));if(!u||s){const{assemblies:t}=e.assemblyManager;if(0===t.length)return;const{pluginConfiguration:r}=e.apolloDataStore;r.ontologies.find((e=>n.readConfObject(e,"name")===c))||r.addOntology({name:"Sequence Ontology",version:"01c33c6d9b6c8dca12e7d3e37b49ee113093c2fa",source:{uri:"https://raw.githubusercontent.com/The-Sequence-Ontology/SO-Ontologies/01c33c6d9b6c8dca12e7d3e37b49ee113093c2fa/Ontology_Files/so.json",locationType:"UriLocation"}});for(const t of d)e.addApolloLocalTrackConfig(t);return l.applySnapshot(e,e.previousSnapshot),void i.dispose()}const{signal:f}=e.abortController;for(const n of t){if("ApolloInternetAccount"!==n.type)continue;const{baseURL:t}=n,r=new URL("jbrowse/config.json",t).href,a=n.getFetcher({locationType:"UriLocation",uri:r});let s,l;try{s=await a(r,{signal:f})}catch(t){e.abortController.signal.aborted||console.error(t);continue}if(s.ok){try{l=await s.json()}catch(e){console.error(e);continue}l.configuration.ApolloPlugin.hasRole&&(o(l,e.previousSnapshot),i.dispose())}else{const e=await dl(s,"Failed to fetch assemblies");console.error(e)}}}),{name:"ApolloSessionLoadConfig"}))},beforeDestroy(){e.abortController.abort(new DOMException("Clean up Apollo session","AbortError"))}}))).actions((e=>({async afterCreate(){if(o.isElectron)return;const t=new URL(globalThis.location.href).searchParams.get("apolloFeatures");if(!t)return;const{assemblyManager:n}=e;await async function(e,t,n,r){const o=function(e){let t=e.replaceAll("-","+").replaceAll("_","/");const n=t.length%4;return n&&(t+="=".repeat(4-n)),t}(e),i=await async function(e){const t=atob(e),n=Uint8Array.from(t,(e=>e.charCodeAt(0))),r=new Blob([n]).stream(),o=new DecompressionStream("gzip"),i=r.pipeThrough(o),a=new Response(i),s=await a.arrayBuffer();return JSON.parse((new TextDecoder).decode(s))}(o);for(const[e,o]of Object.entries(i)){if(!(t.getBackendDriver(e)instanceof Sl))continue;const i=await n.waitForAssembly(e);if(!i)throw new Error(`Assembly not found: "${e}"`);const{regions:a}=i;if(!a)throw new Error(`Assembly not found: "${e}"`);const s=a.map((e=>e.refName)),l=await wl(e,s);for(const n of o){const o=`features-${n.refSeq}`,i=await l.get(o,n._id);if(void 0===i){const r=new ht({typeName:"AddFeatureChange",assembly:e,changedIds:[n._id],addedFeature:n});await t.changeManager.submit(r)}else{const o=JSON.parse(JSON.stringify(i));Ss(n,o)||await new Promise((i=>{r.queueDialog((r=>[th,{featureSnapshot:n,existingFeature:o,assemblyName:e,changeManager:t.changeManager,handleClose:()=>{r(),i()}}]))}))}}}}(t,e.apolloDataStore,n,e),await new Promise((e=>setTimeout(e,2e3)));const r=new URL(globalThis.location.href);r.searchParams.delete("apolloFeatures"),globalThis.history.replaceState(null,"",r.toString())},afterAttach(){l.addDisposer(e,c.autorun((t=>{const{focusedViewId:n,activeWidgets:r}=e;if(!n||!r)return;const o=r.get("hierarchicalTrackSelector");o?.setView(n),t.dispose()})))}}))).views((e=>{const t=e.getTrackActions;return{getTrackActions(r){if("ApolloTrack"===r.type||"ReferenceSequenceTrack"===r.type)return t?.(r);const o=n.readConfObject(r,"trackId");return o.endsWith("-sessionTrack")?[...t?.(r)??[],{label:"Save track to Apollo",onClick:async()=>{const{internetAccounts:t,jbrowse:n}=l.getRoot(e);let i;i=kt(l.getSnapshot(n)),0===Object.keys(i).length&&(i=void 0);const a={...l.getSnapshot(r),trackId:o.slice(0,o.length-13)};for(const n of t){if("ApolloInternetAccount"!==n.type)continue;const t=new Nt({typeName:"ImportJBrowseConfigChange",oldJBrowseConfig:i,newJBrowseConfig:{...i,tracks:i?.tracks&&[...i.tracks,a]}}),{internetAccountId:r}=n;await e.apolloDataStore.changeManager.submit(t,{internetAccountId:r});const{notify:o}=e;o("Track added","success")}e.deleteTrackConf(r),n.addTrackConf(a)},icon:Zf}]:[...t?.(r)??[],{label:"Remove track from Apollo",onClick:async()=>{const{internetAccounts:t,jbrowse:n}=l.getRoot(e);let i;i=kt(l.getSnapshot(n)),0===Object.keys(i).length&&(i=void 0);const a=i?.tracks?.filter((e=>e.trackId!==o));for(const n of t){if("ApolloInternetAccount"!==n.type)continue;const t=new Nt({typeName:"ImportJBrowseConfigChange",oldJBrowseConfig:i,newJBrowseConfig:{...i,tracks:a}}),{internetAccountId:r}=n;await e.apolloDataStore.changeManager.submit(t,{internetAccountId:r});const{notify:o}=e;o("Track removed","success")}e.deleteTrackConf(r),n.deleteTrackConf(r)},icon:Zf}]}}}));return l.types.snapshotProcessor(a,{postProcessor(e,t){if(e.apolloSelectedFeature=void 0,e.apolloDataStore={typeName:"Client",checkResults:{}},!t)return e;const{apolloDataStore:n}=t,{checkResults:r}=n;for(const[,e]of r){const[t]=e.ids}return e}})}const rh="WorkerGlobalScope"in globalThis;for(const[e,t]of Object.entries(Gt))Q.registerChange(e,t);const oh=new Sn;ne.registerCheck(oh.name,oh);const ih=new Rn;ne.registerCheck(ih.name,ih),Kt.registerValidation(new Xt),Kt.registerValidation(new Zt),e.default=class extends t{name="ApolloPlugin";version="1.1.0";configurationSchema=vf;install(e){!function(e){e.addAdapterType((()=>new y({name:"ApolloSequenceAdapter",configSchema:Mc,adapterMetadata:{category:void 0,hiddenFromGUI:!0,description:void 0},AdapterClass:Fc})))}(e),function(e){e.addAdapterType((()=>new y({name:"ApolloRefNameAliasAdapter",configSchema:Ec,adapterMetadata:{category:void 0,hiddenFromGUI:!0,description:void 0},AdapterClass:Rc})))}(e),function(e){e.addTextSearchAdapterType((()=>new r.TextSearchAdapterType({name:"ApolloTextSearchAdapter",displayName:"Apollo text search adapter",configSchema:qc,AdapterClass:Bc,description:"Apollo Text Search adapter"})))}(e),e.addWidgetType((()=>{const e=n.ConfigurationSchema("ApolloFeatureDetailsWidget",{});return new r.WidgetType({name:"ApolloFeatureDetailsWidget",heading:"Apollo feature details",configSchema:e,stateModel:pu,ReactComponent:su})})),e.addWidgetType((()=>{const e=n.ConfigurationSchema("ApolloTranscriptDetails",{});return new r.WidgetType({name:"ApolloTranscriptDetails",heading:"Apollo transcript details",configSchema:e,stateModel:gu,ReactComponent:Hu})})),e.addTrackType((()=>{const t=n.ConfigurationSchema("ApolloTrack",{adapter:""},{baseConfiguration:r.createBaseTrackConfig(e),explicitIdentifier:"trackId"});return new r.TrackType({name:"ApolloTrack",configSchema:t,stateModel:r.createBaseTrackModel(e,"ApolloTrack",t)})})),e.addInternetAccountType((()=>new r.InternetAccountType({name:"ApolloInternetAccount",configSchema:Pn,stateModel:kc(Pn)}))),e.addDisplayType((()=>new r.DisplayType({name:"LinearApolloDisplay",configSchema:Gu,stateModel:Wd(0,Gu),trackType:"ApolloTrack",viewType:"LinearGenomeView",ReactComponent:Wf}))),e.addDisplayType((()=>new r.DisplayType({name:"LinearApolloSixFrameDisplay",configSchema:sf,stateModel:_f(0,sf),trackType:"ApolloTrack",viewType:"LinearGenomeView",ReactComponent:Jf}))),e.addDisplayType((()=>new r.DisplayType({name:"LinearApolloReferenceSequenceDisplay",configSchema:Jd,stateModel:of(0,Jd),displayName:"Apollo reference sequence display",trackType:"ReferenceSequenceTrack",viewType:"LinearGenomeView",ReactComponent:af}))),e.addToExtensionPoint("Core-extendSession",nh.bind(this,e)),e.addToExtensionPoint("Core-extendPluggableElement",(e=>{if("LinearGenomeView"===e.name){const{stateModel:t}=e,n=t.views((e=>{const t=e.rubberBandMenuItems;return{rubberBandMenuItems:()=>[...t(),{label:"Add new feature",icon:Ln,onClick:()=>{const t=o.getSession(e),{leftOffset:n,rightOffset:r}=e,i=e.getSelectedRegions(n,r);t.queueDialog((e=>[Rl,{session:t,handleClose:()=>{e()},region:i[0],changeManager:t.apolloDataStore.changeManager}]))}}]}}));e.stateModel=n}return e})),e.addToExtensionPoint("Core-extendPluggableElement",Nf),e.addToExtensionPoint("Core-extendPluggableElement",Df),e.addToExtensionPoint("Core-preProcessTrackConfig",(e=>{if("ReferenceSequenceTrack"!==e.type)return e;const t=e.displays??[],n=t.findIndex((e=>"LinearApolloReferenceSequenceDisplay"===e.type));if(0===n)return e;if(-1===n)return{...e,displays:[{type:"LinearApolloReferenceSequenceDisplay",displayId:`${e.trackId}-LinearApolloReferenceSequenceDisplay`},...t]};const r=t.toSpliced(n,1);return r.unshift({type:"LinearApolloReferenceSequenceDisplay",displayId:`${e.trackId}-LinearApolloReferenceSequenceDisplay`}),{...e,displays:r}})),e.addToExtensionPoint("LinearGenomeView-searchResultSelected",((e,t)=>{const{session:n,result:r}=t,o=r.getTrackId(),i=r.matchedObject;return o?.startsWith("apollo_track_")&&i&&n.apolloSetEventualSelectedFeature(i._id),e})),rh||e.addToExtensionPoint("Core-extendWorker",(t=>"on"in t.client&&t.client.on?(t.client.on("apollo",(async n=>{if("object"!=typeof(r=n)||null===r||!("apollo"in r)||!0!==r.apollo)return;var r;const{apollo:o,messageId:i,method:a}=n;switch(a){case"getSequence":{const{region:r}=n,{assemblyName:a}=r,s=e.rootModel?.session?.apolloDataStore;if(!s)break;const l=s.getBackendDriver(a);if(!l)break;const{seq:c}=await l.getSequence(r);t.worker.postMessage({apollo:o,messageId:i,sequence:c});break}case"getRegions":{const{assembly:r}=n,a=e.rootModel?.session?.apolloDataStore;if(!a)break;const s=a.getBackendDriver(r);if(!s)break;const l=await s.getRegions(r);t.worker.postMessage({apollo:o,messageId:i,regions:l});break}case"getRefNameAliases":{const{assembly:r}=n,a=e.rootModel?.session?.apolloDataStore;if(!a)break;const s=a.getBackendDriver(r);if(!s)break;const l=await s.getRefNameAliases(r);t.worker.postMessage({apollo:o,messageId:i,refNameAliases:l});break}}})),t):t))}configure(e){o.isAbstractMenuManager(e.rootModel)&&(e.jexl.addFunction("geneBackgroundColor",(e=>"pseudogene"===e?s.alpha("rgb(148, 203, 236)",.6):"ncRNA_gene"===e?s.alpha("rgb(194, 106, 119)",.6):void 0)),function(e){e.insertInMenu("Apollo",{label:"Redo",icon:Yf,onClick(e){const{apolloDataStore:t}=e;t.changeManager.redoLastChange()}},0),e.insertInMenu("Apollo",{label:"Undo",icon:Xf,onClick(e){const{apolloDataStore:t}=e;t.changeManager.undoLastChange()}},0),e.appendToMenu("Apollo",{label:"Lock/Unlock session",onClick:e=>{e.toggleLocked()}});const{internetAccounts:t}=e;t.some((e=>Xl(e)))&&e.appendToMenu("Apollo",{label:"Log out",icon:Kf,onClick:e=>{e.queueDialog((t=>[Kl,{session:e,handleClose:()=>{t()}}]))}})}(e.rootModel))}},Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@jbrowse/core/Plugin"),require("@jbrowse/core/configuration"),require("@jbrowse/core/pluggableElementTypes"),require("@jbrowse/core/util"),require("react/jsx-runtime"),require("@mui/material/utils"),require("@mui/material"),require("@jbrowse/mobx-state-tree"),require("mobx"),require("react"),require("@jbrowse/core/util/types/mst"),require("@jbrowse/core/util/io"),require("@jbrowse/core/ui"),require("mobx-react"),require("@mui/material/styles"),require("@mui/x-data-grid"),require("@jbrowse/core/pluggableElementTypes/AdapterType"),require("@jbrowse/core/data_adapters/BaseAdapter"),require("@jbrowse/core/util/rxjs"),require("@jbrowse/core/util/tracks")):"function"==typeof define&&define.amd?define(["exports","@jbrowse/core/Plugin","@jbrowse/core/configuration","@jbrowse/core/pluggableElementTypes","@jbrowse/core/util","react/jsx-runtime","@mui/material/utils","@mui/material","@jbrowse/mobx-state-tree","mobx","react","@jbrowse/core/util/types/mst","@jbrowse/core/util/io","@jbrowse/core/ui","mobx-react","@mui/material/styles","@mui/x-data-grid","@jbrowse/core/pluggableElementTypes/AdapterType","@jbrowse/core/data_adapters/BaseAdapter","@jbrowse/core/util/rxjs","@jbrowse/core/util/tracks"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).JBrowsePluginApollo={},e.JBrowseExports["@jbrowse/core/Plugin"],e.JBrowseExports["@jbrowse/core/configuration"],e.JBrowseExports["@jbrowse/core/pluggableElementTypes"],e.JBrowseExports["@jbrowse/core/util"],e.JBrowseExports["react/jsx-runtime"],e.JBrowseExports["@mui/material/utils"],e.JBrowseExports["@mui/material"],e.JBrowseExports["@jbrowse/mobx-state-tree"],e.JBrowseExports.mobx,e.JBrowseExports.react,e.JBrowseExports["@jbrowse/core/util/types/mst"],e.JBrowseExports["@jbrowse/core/util/io"],e.JBrowseExports["@jbrowse/core/ui"],e.JBrowseExports["mobx-react"],e.JBrowseExports["@mui/material/styles"],e.JBrowseExports["@mui/x-data-grid"],e.JBrowseExports["@jbrowse/core/pluggableElementTypes/AdapterType"],e.JBrowseExports["@jbrowse/core/data_adapters/BaseAdapter"],e.JBrowseExports["@jbrowse/core/util/rxjs"],e.JBrowseExports["@jbrowse/core/util/tracks"])}(this,(function(e,t,n,r,o,i,a,s,l,c,u,d,f,h,p,g,m,y,_,v,b){"use strict";function x(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,t}var w=x(u);function S(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 A(e,t,n,r,o,i,a){try{var s=e[i](a),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,o)}function k(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function a(e){A(i,r,o,a,s,"next",e)}function s(e){A(i,r,o,a,s,"throw",e)}a(void 0)}))}}function N(e){return new S(e,0)}function T(e,t,n){return t=F(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,L()?Reflect.construct(t,n||[],F(e).constructor):t.apply(e,n))}function R(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function E(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,J(r.key),r)}}function I(e,t,n){return t&&E(e.prototype,t),n&&E(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function j(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=Y(e))||t){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}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 i,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}function D(e,t,n){return(t=J(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function O(){return O="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=F(e)););return e}(e,t);if(r){var o=Object.getOwnPropertyDescriptor(r,t);return o.get?o.get.call(arguments.length<3?e:n):o.value}},O.apply(null,arguments)}function F(e){return F=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},F(e)}function M(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&&H(e,t)}function L(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(L=function(){return!!e})()}function P(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 B(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?P(Object(n),!0).forEach((function(t){D(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):P(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function q(e,t){if(null==e)return{};var n,r,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}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)-1===t.indexOf(n=i[r])&&{}.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function U(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function i(n,r,o,i){var l=Object.create((r&&r.prototype instanceof s?r:s).prototype);return z(l,"_invoke",function(n,r,o){var i,s,l,c=0,u=o||[],d=!1,f={p:0,n:0,v:e,a:h,f:h.bind(e,4),d:function(t,n){return i=t,s=0,l=e,f.n=n,a}};function h(n,r){for(s=n,l=r,t=0;!d&&c&&!o&&t<u.length;t++){var o,i=u[t],h=f.p,p=i[2];n>3?(o=p===r)&&(l=i[(s=i[4])?5:(s=3,3)],i[4]=i[5]=e):i[0]<=h&&((o=n<2&&h<i[1])?(s=0,f.v=r,f.n=i[1]):h<p&&(o=n<3||i[0]>r||r>p)&&(i[4]=n,i[5]=r,f.n=p,s=0))}if(o||n>1)return a;throw d=!0,r}return function(o,u,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===u&&h(u,p),s=u,l=p;(t=s<2?e:l)||!d;){i||(s?s<3?(s>1&&(f.n=-1),h(s,l)):f.n=l:f.v=l);try{if(c=2,i){if(s||(o="next"),t=i[o]){if(!(t=t.call(i,l)))throw TypeError("iterator result is not an object");if(!t.done)return t;l=t.value,s<2&&(s=0)}else 1===s&&(t=i.return)&&t.call(i),s<2&&(l=TypeError("The iterator does not provide a '"+o+"' method"),s=1);i=e}else if((t=(d=f.n<0)?l:n.call(r,f))!==a)break}catch(t){i=e,s=1,l=t}finally{c=1}}return{value:t,done:d}}}(n,o,i),!0),l}var a={};function s(){}function l(){}function c(){}t=Object.getPrototypeOf;var u=[][r]?t(t([][r]())):(z(t={},r,(function(){return this})),t),d=c.prototype=s.prototype=Object.create(u);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,z(e,o,"GeneratorFunction")),e.prototype=Object.create(d),e}return l.prototype=c,z(d,"constructor",c),z(c,"constructor",l),l.displayName="GeneratorFunction",z(c,o,"GeneratorFunction"),z(d),z(d,o,"Generator"),z(d,r,(function(){return this})),z(d,"toString",(function(){return"[object Generator]"})),(U=function(){return{w:i,m:f}})()}function z(e,t,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}z=function(e,t,n,r){function i(t,n){z(e,t,(function(e){return this._invoke(t,n,e)}))}t?o?o(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(i("next",0),i("throw",1),i("return",2))},z(e,t,n,r)}function $(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 H(e,t){return H=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},H(e,t)}function G(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,o,i,a,s=[],l=!0,c=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=i.call(n)).done)&&(s.push(r.value),s.length!==t);l=!0);}catch(e){c=!0,o=e}finally{try{if(!l&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(e,t)||Y(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 V(e,t,n,r){var o=O(F(1&r?e.prototype:e),t,n);return 2&r&&"function"==typeof o?function(e){return o.apply(n,e)}:o}function W(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)||Y(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 J(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,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}function K(e){return K="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},K(e)}function Y(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 X(e){var t,n;function r(t,n){try{var i=e[t](n),a=i.value,s=a instanceof S;Promise.resolve(s?a.v:a).then((function(n){if(s){var l="return"===t?"return":"next";if(!a.k||n.done)return r(l,n);n=e[l](n).value}o(i.done?"return":"normal",n)}),(function(e){r("throw",e)}))}catch(e){o("throw",e)}}function o(e,o){switch(e){case"return":t.resolve({value:o,done:!0});break;case"throw":t.reject(o);break;default:t.resolve({value:o,done:!1})}(t=t.next)?r(t.key,t.arg):n=null}this._invoke=function(e,o){return new Promise((function(i,a){var s={key:e,arg:o,resolve:i,reject:a,next:null};n?n=n.next=s:(t=n=s,r(e,o))}))},"function"!=typeof e.return&&(this.return=void 0)}function Z(e){var t="function"==typeof Map?new Map:void 0;return Z=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return function(e,t,n){if(L())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,t);var o=new(e.bind.apply(e,r));return n&&H(o,n.prototype),o}(e,arguments,F(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),H(n,e)},Z(e)}X.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},X.prototype.next=function(e){return this._invoke("next",e)},X.prototype.throw=function(e){return this._invoke("throw",e)},X.prototype.return=function(e){return this._invoke("return",e)};var Q=new(function(){return I((function e(){R(this,e),D(this,"changes",new Map)}),[{key:"registerChange",value:function(e,t){if(this.changes.has(e))throw new Error('change type "'.concat(e,'" has already been registered'));this.changes.set(e,t)}},{key:"getChangeType",value:function(e){var t=this.changes.get(e);if(!t)throw new Error('No change constructor registered for "'.concat(e,'"'));return t}}])}()),ee=function(){return I((function e(t,n){var r;R(this,e),D(this,"logger",void 0),this.logger=null!==(r=null==n?void 0:n.logger)&&void 0!==r?r:console}),[{key:"notification",get:function(){return""}}],[{key:"fromJSON",value:function(e,t){return new(Q.getChangeType(e.typeName))(e,(null==t?void 0:t.logger)&&{logger:t.logger})}}])}();function te(e){return function(e){return void 0!==e.getInverse}(e)&&void 0!==e.assembly}var ne=new(function(){return I((function e(){R(this,e),D(this,"checks",new Map)}),[{key:"registerCheck",value:function(e,t){if(this.checks.has(e))throw new Error('check "'.concat(e,'" has already been registered'));this.checks.set(e,t)}},{key:"getCheck",value:function(e){var t=this.checks.get(e);if(!t)throw new Error('No check constructor registered for "'.concat(e,'"'));return t}},{key:"getChecks",value:function(){return this.checks}}])}()),re="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function oe(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ie="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},ae={env:{}},se=[],le=[],ce="undefined"!=typeof Uint8Array?Uint8Array:Array,ue=!1;function de(){ue=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)se[t]=e[t],le[e.charCodeAt(t)]=t;le["-".charCodeAt(0)]=62,le["_".charCodeAt(0)]=63}function fe(e,t,n){for(var r,o=[],i=t;i<n;i+=3)o.push(se[(r=(e[i]<<16)+(e[i+1]<<8)+e[i+2])>>18&63]+se[r>>12&63]+se[r>>6&63]+se[63&r]);return o.join("")}function he(e,t,n,r,o){var i,a,s=8*o-r-1,l=(1<<s)-1,c=l>>1,u=-7,d=n?o-1:0,f=n?-1:1,h=e[t+d];for(d+=f,i=h&(1<<-u)-1,h>>=-u,u+=s;u>0;i=256*i+e[t+d],d+=f,u-=8);for(a=i&(1<<-u)-1,i>>=-u,u+=r;u>0;a=256*a+e[t+d],d+=f,u-=8);if(0===i)i=1-c;else{if(i===l)return a?NaN:Infinity*(h?-1:1);a+=Math.pow(2,r),i-=c}return(h?-1:1)*a*Math.pow(2,i-r)}function pe(e,t,n,r,o,i){var a,s,l,c=8*i-o-1,u=(1<<c)-1,d=u>>1,f=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,h=r?0:i-1,p=r?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||Infinity===t?(s=isNaN(t)?1:0,a=u):(a=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-a))<1&&(a--,l*=2),(t+=a+d>=1?f/l:f*Math.pow(2,1-d))*l>=2&&(a++,l/=2),a+d>=u?(s=0,a=u):a+d>=1?(s=(t*l-1)*Math.pow(2,o),a+=d):(s=t*Math.pow(2,d-1)*Math.pow(2,o),a=0));o>=8;e[n+h]=255&s,h+=p,s/=256,o-=8);for(a=a<<o|s,c+=o;c>0;e[n+h]=255&a,h+=p,a/=256,c-=8);e[n+h-p]|=128*g}var ge={}.toString,me=Array.isArray||function(e){return"[object Array]"==ge.call(e)};function ye(){return ve.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function _e(e,t){if(ye()<t)throw new RangeError("Invalid typed array length");return ve.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=ve.prototype:(null===e&&(e=new ve(t)),e.length=t),e}function ve(e,t,n){if(!(ve.TYPED_ARRAY_SUPPORT||this instanceof ve))return new ve(e,t,n);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return we(this,e)}return be(this,e,t,n)}function be(e,t,n,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,n,r){if(n<0||t.byteLength<n)throw new RangeError("'offset' is out of bounds");if(t.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");return t=void 0===n&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,n):new Uint8Array(t,n,r),ve.TYPED_ARRAY_SUPPORT?(e=t).__proto__=ve.prototype:e=Se(e,t),e}(e,t,n,r):"string"==typeof t?function(e,t,n){if("string"==typeof n&&""!==n||(n="utf8"),!ve.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|ke(t,n),o=(e=_e(e,r)).write(t,n);return o!==r&&(e=e.slice(0,o)),e}(e,t,n):function(e,t){if(Ae(t)){var n=0|Ce(t.length);return 0===(e=_e(e,n)).length||t.copy(e,0,0,n),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(r=t.length)!=r?_e(e,0):Se(e,t);if("Buffer"===t.type&&me(t.data))return Se(e,t.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function xe(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function we(e,t){if(xe(t),e=_e(e,t<0?0:0|Ce(t)),!ve.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function Se(e,t){var n=t.length<0?0:0|Ce(t.length);e=_e(e,n);for(var r=0;r<n;r+=1)e[r]=255&t[r];return e}function Ce(e){if(e>=ye())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+ye().toString(16)+" bytes");return 0|e}function Ae(e){return!(null==e||!e._isBuffer)}function ke(e,t){if(Ae(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return tt(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return nt(e).length;default:if(r)return tt(e).length;t=(""+t).toLowerCase(),r=!0}}function Ne(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return ze(this,t,n);case"utf8":case"utf-8":return Pe(this,t,n);case"ascii":return qe(this,t,n);case"latin1":case"binary":return Ue(this,t,n);case"base64":return Le(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return $e(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function Te(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function Re(e,t,n,r,o){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=o?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(o)return-1;n=e.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof t&&(t=ve.from(t,r)),Ae(t))return 0===t.length?-1:Ee(e,t,n,r,o);if("number"==typeof t)return t&=255,ve.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):Ee(e,[t],n,r,o);throw new TypeError("val must be string, number or Buffer")}function Ee(e,t,n,r,o){var i,a=1,s=e.length,l=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;a=2,s/=2,l/=2,n/=2}function c(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(o){var u=-1;for(i=n;i<s;i++)if(c(e,i)===c(t,-1===u?0:i-u)){if(-1===u&&(u=i),i-u+1===l)return u*a}else-1!==u&&(i-=i-u),u=-1}else for(n+l>s&&(n=s-l),i=n;i>=0;i--){for(var d=!0,f=0;f<l;f++)if(c(e,i+f)!==c(t,f)){d=!1;break}if(d)return i}return-1}function Ie(e,t,n,r){n=Number(n)||0;var o=e.length-n;r?(r=Number(r))>o&&(r=o):r=o;var i=t.length;if(i%2!=0)throw new TypeError("Invalid hex string");r>i/2&&(r=i/2);for(var a=0;a<r;++a){var s=parseInt(t.substr(2*a,2),16);if(isNaN(s))return a;e[n+a]=s}return a}function je(e,t,n,r){return rt(tt(t,e.length-n),e,n,r)}function De(e,t,n,r){return rt(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function Oe(e,t,n,r){return De(e,t,n,r)}function Fe(e,t,n,r){return rt(nt(t),e,n,r)}function Me(e,t,n,r){return rt(function(e,t){for(var n,r,o=[],i=0;i<e.length&&!((t-=2)<0);++i)r=(n=e.charCodeAt(i))>>8,o.push(n%256),o.push(r);return o}(t,e.length-n),e,n,r)}function Le(e,t,n){return function(e){var t;ue||de();for(var n=e.length,r=n%3,o="",i=[],a=16383,s=0,l=n-r;s<l;s+=a)i.push(fe(e,s,s+a>l?l:s+a));return 1===r?(o+=se[(t=e[n-1])>>2],o+=se[t<<4&63],o+="=="):2===r&&(o+=se[(t=(e[n-2]<<8)+e[n-1])>>10],o+=se[t>>4&63],o+=se[t<<2&63],o+="="),i.push(o),i.join("")}(0===t&&n===e.length?e:e.slice(t,n))}function Pe(e,t,n){n=Math.min(e.length,n);for(var r=[],o=t;o<n;){var i,a,s,l,c=e[o],u=null,d=c>239?4:c>223?3:c>191?2:1;if(o+d<=n)switch(d){case 1:c<128&&(u=c);break;case 2:128==(192&(i=e[o+1]))&&(l=(31&c)<<6|63&i)>127&&(u=l);break;case 3:a=e[o+2],128==(192&(i=e[o+1]))&&128==(192&a)&&(l=(15&c)<<12|(63&i)<<6|63&a)>2047&&(l<55296||l>57343)&&(u=l);break;case 4:a=e[o+2],s=e[o+3],128==(192&(i=e[o+1]))&&128==(192&a)&&128==(192&s)&&(l=(15&c)<<18|(63&i)<<12|(63&a)<<6|63&s)>65535&&l<1114112&&(u=l)}null===u?(u=65533,d=1):u>65535&&(r.push((u-=65536)>>>10&1023|55296),u=56320|1023&u),r.push(u),o+=d}return function(e){var t=e.length;if(t<=Be)return String.fromCharCode.apply(String,e);for(var n="",r=0;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=Be));return n}(r)}ve.TYPED_ARRAY_SUPPORT=void 0===ie.TYPED_ARRAY_SUPPORT||ie.TYPED_ARRAY_SUPPORT,ve.poolSize=8192,ve._augment=function(e){return e.__proto__=ve.prototype,e},ve.from=function(e,t,n){return be(null,e,t,n)},ve.TYPED_ARRAY_SUPPORT&&(ve.prototype.__proto__=Uint8Array.prototype,ve.__proto__=Uint8Array),ve.alloc=function(e,t,n){return function(e,t,n,r){return xe(t),t<=0?_e(e,t):void 0!==n?"string"==typeof r?_e(e,t).fill(n,r):_e(e,t).fill(n):_e(e,t)}(null,e,t,n)},ve.allocUnsafe=function(e){return we(null,e)},ve.allocUnsafeSlow=function(e){return we(null,e)},ve.isBuffer=function(e){return null!=e&&(!!e._isBuffer||ot(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&ot(e.slice(0,0))}(e))},ve.compare=function(e,t){if(!Ae(e)||!Ae(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,o=0,i=Math.min(n,r);o<i;++o)if(e[o]!==t[o]){n=e[o],r=t[o];break}return n<r?-1:r<n?1:0},ve.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},ve.concat=function(e,t){if(!me(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return ve.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=ve.allocUnsafe(t),o=0;for(n=0;n<e.length;++n){var i=e[n];if(!Ae(i))throw new TypeError('"list" argument must be an Array of Buffers');i.copy(r,o),o+=i.length}return r},ve.byteLength=ke,ve.prototype._isBuffer=!0,ve.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)Te(this,t,t+1);return this},ve.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)Te(this,t,t+3),Te(this,t+1,t+2);return this},ve.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)Te(this,t,t+7),Te(this,t+1,t+6),Te(this,t+2,t+5),Te(this,t+3,t+4);return this},ve.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?Pe(this,0,e):Ne.apply(this,arguments)},ve.prototype.equals=function(e){if(!Ae(e))throw new TypeError("Argument must be a Buffer");return this===e||0===ve.compare(this,e)},ve.prototype.inspect=function(){var e="";return this.length>0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),"<Buffer "+e+">"},ve.prototype.compare=function(e,t,n,r,o){if(!Ae(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),t<0||n>e.length||r<0||o>this.length)throw new RangeError("out of range index");if(r>=o&&t>=n)return 0;if(r>=o)return-1;if(t>=n)return 1;if(this===e)return 0;for(var i=(o>>>=0)-(r>>>=0),a=(n>>>=0)-(t>>>=0),s=Math.min(i,a),l=this.slice(r,o),c=e.slice(t,n),u=0;u<s;++u)if(l[u]!==c[u]){i=l[u],a=c[u];break}return i<a?-1:a<i?1:0},ve.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},ve.prototype.indexOf=function(e,t,n){return Re(this,e,t,n,!0)},ve.prototype.lastIndexOf=function(e,t,n){return Re(this,e,t,n,!1)},ve.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var o=this.length-t;if((void 0===n||n>o)&&(n=o),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var i=!1;;)switch(r){case"hex":return Ie(this,e,t,n);case"utf8":case"utf-8":return je(this,e,t,n);case"ascii":return De(this,e,t,n);case"latin1":case"binary":return Oe(this,e,t,n);case"base64":return Fe(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Me(this,e,t,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0}},ve.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Be=4096;function qe(e,t,n){var r="";n=Math.min(e.length,n);for(var o=t;o<n;++o)r+=String.fromCharCode(127&e[o]);return r}function Ue(e,t,n){var r="";n=Math.min(e.length,n);for(var o=t;o<n;++o)r+=String.fromCharCode(e[o]);return r}function ze(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var o="",i=t;i<n;++i)o+=et(e[i]);return o}function $e(e,t,n){for(var r=e.slice(t,n),o="",i=0;i<r.length;i+=2)o+=String.fromCharCode(r[i]+256*r[i+1]);return o}function He(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function Ge(e,t,n,r,o,i){if(!Ae(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||t<i)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError("Index out of range")}function Ve(e,t,n,r){t<0&&(t=65535+t+1);for(var o=0,i=Math.min(e.length-n,2);o<i;++o)e[n+o]=(t&255<<8*(r?o:1-o))>>>8*(r?o:1-o)}function We(e,t,n,r){t<0&&(t=4294967295+t+1);for(var o=0,i=Math.min(e.length-n,4);o<i;++o)e[n+o]=t>>>8*(r?o:3-o)&255}function Je(e,t,n,r,o,i){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function Ke(e,t,n,r,o){return o||Je(e,0,n,4),pe(e,t,n,r,23,4),n+4}function Ye(e,t,n,r,o){return o||Je(e,0,n,8),pe(e,t,n,r,52,8),n+8}ve.prototype.slice=function(e,t){var n,r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e),ve.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=ve.prototype;else{var o=t-e;n=new ve(o,void 0);for(var i=0;i<o;++i)n[i]=this[i+e]}return n},ve.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||He(e,t,this.length);for(var r=this[e],o=1,i=0;++i<t&&(o*=256);)r+=this[e+i]*o;return r},ve.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||He(e,t,this.length);for(var r=this[e+--t],o=1;t>0&&(o*=256);)r+=this[e+--t]*o;return r},ve.prototype.readUInt8=function(e,t){return t||He(e,1,this.length),this[e]},ve.prototype.readUInt16LE=function(e,t){return t||He(e,2,this.length),this[e]|this[e+1]<<8},ve.prototype.readUInt16BE=function(e,t){return t||He(e,2,this.length),this[e]<<8|this[e+1]},ve.prototype.readUInt32LE=function(e,t){return t||He(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},ve.prototype.readUInt32BE=function(e,t){return t||He(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},ve.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||He(e,t,this.length);for(var r=this[e],o=1,i=0;++i<t&&(o*=256);)r+=this[e+i]*o;return r>=(o*=128)&&(r-=Math.pow(2,8*t)),r},ve.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||He(e,t,this.length);for(var r=t,o=1,i=this[e+--r];r>0&&(o*=256);)i+=this[e+--r]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*t)),i},ve.prototype.readInt8=function(e,t){return t||He(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},ve.prototype.readInt16LE=function(e,t){t||He(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},ve.prototype.readInt16BE=function(e,t){t||He(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},ve.prototype.readInt32LE=function(e,t){return t||He(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},ve.prototype.readInt32BE=function(e,t){return t||He(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},ve.prototype.readFloatLE=function(e,t){return t||He(e,4,this.length),he(this,e,!0,23,4)},ve.prototype.readFloatBE=function(e,t){return t||He(e,4,this.length),he(this,e,!1,23,4)},ve.prototype.readDoubleLE=function(e,t){return t||He(e,8,this.length),he(this,e,!0,52,8)},ve.prototype.readDoubleBE=function(e,t){return t||He(e,8,this.length),he(this,e,!1,52,8)},ve.prototype.writeUIntLE=function(e,t,n,r){e=+e,t|=0,n|=0,r||Ge(this,e,t,n,Math.pow(2,8*n)-1,0);var o=1,i=0;for(this[t]=255&e;++i<n&&(o*=256);)this[t+i]=e/o&255;return t+n},ve.prototype.writeUIntBE=function(e,t,n,r){e=+e,t|=0,n|=0,r||Ge(this,e,t,n,Math.pow(2,8*n)-1,0);var o=n-1,i=1;for(this[t+o]=255&e;--o>=0&&(i*=256);)this[t+o]=e/i&255;return t+n},ve.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||Ge(this,e,t,1,255,0),ve.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},ve.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||Ge(this,e,t,2,65535,0),ve.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Ve(this,e,t,!0),t+2},ve.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||Ge(this,e,t,2,65535,0),ve.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Ve(this,e,t,!1),t+2},ve.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||Ge(this,e,t,4,4294967295,0),ve.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):We(this,e,t,!0),t+4},ve.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||Ge(this,e,t,4,4294967295,0),ve.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):We(this,e,t,!1),t+4},ve.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var o=Math.pow(2,8*n-1);Ge(this,e,t,n,o-1,-o)}var i=0,a=1,s=0;for(this[t]=255&e;++i<n&&(a*=256);)e<0&&0===s&&0!==this[t+i-1]&&(s=1),this[t+i]=(e/a>>0)-s&255;return t+n},ve.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var o=Math.pow(2,8*n-1);Ge(this,e,t,n,o-1,-o)}var i=n-1,a=1,s=0;for(this[t+i]=255&e;--i>=0&&(a*=256);)e<0&&0===s&&0!==this[t+i+1]&&(s=1),this[t+i]=(e/a>>0)-s&255;return t+n},ve.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||Ge(this,e,t,1,127,-128),ve.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},ve.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||Ge(this,e,t,2,32767,-32768),ve.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Ve(this,e,t,!0),t+2},ve.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||Ge(this,e,t,2,32767,-32768),ve.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Ve(this,e,t,!1),t+2},ve.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||Ge(this,e,t,4,2147483647,-2147483648),ve.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):We(this,e,t,!0),t+4},ve.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||Ge(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),ve.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):We(this,e,t,!1),t+4},ve.prototype.writeFloatLE=function(e,t,n){return Ke(this,e,t,!0,n)},ve.prototype.writeFloatBE=function(e,t,n){return Ke(this,e,t,!1,n)},ve.prototype.writeDoubleLE=function(e,t,n){return Ye(this,e,t,!0,n)},ve.prototype.writeDoubleBE=function(e,t,n){return Ye(this,e,t,!1,n)},ve.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var o,i=r-n;if(this===e&&n<t&&t<r)for(o=i-1;o>=0;--o)e[o+t]=this[o+n];else if(i<1e3||!ve.TYPED_ARRAY_SUPPORT)for(o=0;o<i;++o)e[o+t]=this[o+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+i),t);return i},ve.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===e.length){var o=e.charCodeAt(0);o<256&&(e=o)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!ve.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;var i;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(i=t;i<n;++i)this[i]=e;else{var a=Ae(e)?e:tt(new ve(e,r).toString()),s=a.length;for(i=0;i<n-t;++i)this[i+t]=a[i%s]}return this};var Xe,Ze,Qe=/[^+\/0-9A-Za-z-_]/g;function et(e){return e<16?"0"+e.toString(16):e.toString(16)}function tt(e,t){var n;t=t||Infinity;for(var r=e.length,o=null,i=[],a=0;a<r;++a){if((n=e.charCodeAt(a))>55295&&n<57344){if(!o){if(n>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(a+1===r){(t-=3)>-1&&i.push(239,191,189);continue}o=n;continue}if(n<56320){(t-=3)>-1&&i.push(239,191,189),o=n;continue}n=65536+(o-55296<<10|n-56320)}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,n<128){if((t-=1)<0)break;i.push(n)}else if(n<2048){if((t-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function nt(e){return function(e){var t,n,r,o,i,a;ue||de();var s=e.length;if(s%4>0)throw new Error("Invalid string. Length must be a multiple of 4");a=new ce(3*s/4-(i="="===e[s-2]?2:"="===e[s-1]?1:0)),r=i>0?s-4:s;var l=0;for(t=0,n=0;t<r;t+=4,n+=3)o=le[e.charCodeAt(t)]<<18|le[e.charCodeAt(t+1)]<<12|le[e.charCodeAt(t+2)]<<6|le[e.charCodeAt(t+3)],a[l++]=o>>16&255,a[l++]=o>>8&255,a[l++]=255&o;return 2===i?(o=le[e.charCodeAt(t)]<<2|le[e.charCodeAt(t+1)]>>4,a[l++]=255&o):1===i&&(o=le[e.charCodeAt(t)]<<10|le[e.charCodeAt(t+1)]<<4|le[e.charCodeAt(t+2)]>>2,a[l++]=o>>8&255,a[l++]=255&o),a}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Qe,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function rt(e,t,n,r){for(var o=0;o<r&&!(o+n>=t.length||o>=e.length);++o)t[o+n]=e[o];return o}function ot(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}var it=function(){if(Ze)return Xe;Ze=1;for(var e=Math.floor(16777215*Math.random()),t=c.index=parseInt(16777215*Math.random(),10),n=(void 0===ae||"number"!=typeof ae.pid?Math.floor(1e5*Math.random()):ae.pid)%65535,r=function(){try{return _Buffer}catch(e){try{return ve}catch(e){return null}}}(),o=function(e){return!(null==e||!e.constructor||"function"!=typeof e.constructor.isBuffer||!e.constructor.isBuffer(e))},i=[],a=0;a<256;a++)i[a]=(a<=15?"0":"")+a.toString(16);var s=new RegExp("^[0-9a-fA-F]{24}$"),l=[];for(a=0;a<10;)l[48+a]=a++;for(;a<16;)l[55+a]=l[87+a]=a++;function c(e){if(!(this instanceof c))return new c(e);if(e&&(e instanceof c||"ObjectID"===e._bsontype))return e;if(this._bsontype="ObjectID",null!=e&&"number"!=typeof e){var t=c.isValid(e);if(!t&&null!=e)throw new Error("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters");if(t&&"string"==typeof e&&24===e.length)return c.createFromHexString(e);if(null==e||12!==e.length){if(null!=e&&"function"==typeof e.toHexString)return e;throw new Error("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters")}this.id=e}else this.id=this.generate(e)}Xe=c,c.default=c,c.createFromTime=function(e){return new c(function(e,t){return 8===(t=t.toString(16)).length?t:"00000000".substring(t.length,8)+t}(0,e=parseInt(e,10)%4294967295)+"0000000000000000")},c.createFromHexString=function(e){if(void 0===e||null!=e&&24!==e.length)throw new Error("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters");for(var t="",n=0;n<24;)t+=String.fromCharCode(l[e.charCodeAt(n++)]<<4|l[e.charCodeAt(n++)]);return new c(t)},c.isValid=function(e){return null!=e&&("number"==typeof e||("string"==typeof e?12===e.length||24===e.length&&s.test(e):e instanceof c||(o(e)?c.isValid(e.toString("hex")):!("function"!=typeof e.toHexString||!r||!(e.id instanceof r||"string"==typeof e.id))&&(12===e.id.length||24===e.id.length&&s.test(e.id)))))},c.prototype={constructor:c,toHexString:function(){if(!this.id||!this.id.length)throw new Error("invalid ObjectId, ObjectId.id must be either a string or a Buffer, but is ["+JSON.stringify(this.id)+"]");if(24===this.id.length)return this.id;if(o(this.id))return this.id.toString("hex");for(var e="",t=0;t<this.id.length;t++)e+=i[this.id.charCodeAt(t)];return e},equals:function(e){return e instanceof c?this.toString()===e.toString():"string"==typeof e&&c.isValid(e)&&12===e.length&&o(this.id)?e===this.id.toString("binary"):"string"==typeof e&&c.isValid(e)&&24===e.length?e.toLowerCase()===this.toHexString():"string"==typeof e&&c.isValid(e)&&12===e.length?e===this.id:!(null==e||!(e instanceof c||e.toHexString))&&e.toHexString()===this.toHexString()},getTimestamp:function(){var e,t=new Date;return e=o(this.id)?this.id[3]|this.id[2]<<8|this.id[1]<<16|this.id[0]<<24:this.id.charCodeAt(3)|this.id.charCodeAt(2)<<8|this.id.charCodeAt(1)<<16|this.id.charCodeAt(0)<<24,t.setTime(1e3*Math.floor(e)),t},generate:function(r){"number"!=typeof r&&(r=~~(Date.now()/1e3)),r=parseInt(r,10)%4294967295;var o=t=(t+1)%16777215;return String.fromCharCode(r>>24&255,r>>16&255,r>>8&255,255&r,e>>16&255,e>>8&255,255&e,n>>8&255,255&n,o>>16&255,o>>8&255,255&o)}};var u=Symbol&&Symbol.for&&Symbol.for("nodejs.util.inspect.custom")||"inspect";return c.prototype[u]=function(){return"ObjectID("+this+")"},c.prototype.toJSON=c.prototype.toHexString,c.prototype.toString=c.prototype.toHexString,Xe}(),at=oe(it);function st(e){return te(e)&&void 0!==e.changedIds}var lt=new(function(){return I((function e(){R(this,e),D(this,"changes",new Map)}),[{key:"registerChange",value:function(e,t){if(this.changes.has(e))throw new Error('change type "'.concat(e,'" has already been registered'));this.changes.set(e,t)}},{key:"getChangeType",value:function(e){var t=this.changes.get(e);if(!t)throw new Error('No change constructor registered for "'.concat(e,'"'));return t}}])}()),ct=function(){return I((function e(t,n){var r;R(this,e),D(this,"logger",void 0),this.logger=null!==(r=null==n?void 0:n.logger)&&void 0!==r?r:console}),[{key:"notification",get:function(){return""}}],[{key:"fromJSON",value:function(e,t){return new(lt.getChangeType(e.typeName))(e,(null==t?void 0:t.logger)&&{logger:t.logger})}}])}(),ut=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"assembly",void 0),r.assembly=e.assembly,r}return M(t,e),I(t,[{key:"getIndexedIds",value:function(e,t){var n,r=[],o=j(null!=t?t:[]);try{for(o.s();!(n=o.n()).done;){var i=n.value,a=e.attributes,s=a instanceof Map?a.get(i):null==a?void 0:a[i];null!=s&&s[0]&&r.push(s[0])}}catch(e){o.e(e)}finally{o.f()}if(e.children){var l,c=j(e.children instanceof Map?e.children.values():Object.values(e.children));try{for(c.s();!(l=c.n()).done;){var u=this.getIndexedIds(l.value,t);r.push.apply(r,W(u))}}catch(e){c.e(e)}finally{c.f()}}return r}}])}(ct),dt=I((function e(){R(this,e)})),ft=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"changedIds",void 0),r.changedIds=e.changedIds,r}return M(t,e),I(t,[{key:"getFeatureFromId",value:function(e,t){var n,r,o,i,a=this.logger;if(null===(n=a.verbose)||void 0===n||n.call(a,"Entry=".concat(JSON.stringify(e))),e._id.equals(t))return null===(i=a.debug)||void 0===i||i.call(a,"Top level featureId matches in the object ".concat(JSON.stringify(e))),e;null===(r=a.debug)||void 0===r||r.call(a,"FeatureId was not found on top level so lets make recursive call...");var s,l=j(null!==(o=e.children)&&void 0!==o?o:new Map);try{for(l.s();!(s=l.n()).done;){var c=G(s.value,2),u=this.getFeatureFromId(c[1],t);if(u)return u}}catch(e){l.e(e)}finally{l.f()}return null}},{key:"getChildFeatureIds",value:function(e){if(!e.children)return[];var t,n=[],r=j((e.children instanceof Map?e.children:new Map(Object.entries(e.children)))||new Map);try{for(r.s();!(t=r.n()).done;){var o=G(t.value,2);n.push.apply(n,[o[0]].concat(W(this.getChildFeatureIds(o[1]))))}}catch(e){r.e(e)}finally{r.f()}return n}},{key:"generateNewIds",value:function(e,t){var n=(new at).toHexString();t.push(n);var r={};if(e.children)for(var o=0,i=Object.values(e.children);o<i.length;o++){var a=this.generateNewIds(i[o],t);r[a._id]=a}var s="string"==typeof e.refSeq?e.refSeq:e.refSeq.toHexString();return B(B({},e),{},{refSeq:s,children:e.children&&r,_id:n})}},{key:"addChild",value:function(e,t){var n,r;if(null===(n=e.attributes)||void 0===n||!n._id){var o=e.attributes,i=void 0===o?{}:o;i=B({_id:[e._id.toString()]},JSON.parse(JSON.stringify(i))),e.attributes=i}var a=t._id;null!==(r=e.children)&&void 0!==r||(e.children=new Map),e.children.set(a,B(B({allIds:[]},t),{},{_id:a})),e.children=new Map(W(e.children.entries()).sort((function(e,t){return e[1].min-t[1].min})))}},{key:"findAndDeleteChildFeature",value:function(e,t){if(!e.children)throw new Error("Feature ".concat(e._id.toHexString()," has no children"));var n=e._id,r=e.children,o=r.get(t);if(o){var i=this.getChildFeatureIds(o);return r.delete(t),i}var a,s=j(r);try{for(s.s();!(a=s.n()).done;){var l=G(a.value,2)[1];try{return this.findAndDeleteChildFeature(l,t)}catch(e){}}}catch(e){s.e(e)}finally{s.f()}throw new Error('Feature "'.concat(t,'" not found in ').concat(n.toHexString()))}}])}(ut),ht=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","AddFeatureChange"),D(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return M(t,e),I(t,[{key:"notification",get:function(){return"Feature added successfully"}},{key:"toJSON",value:function(){var e=this.assembly,t=this.changedIds,n=this.changes,r=this.typeName;if(1===n.length){var o=G(n,1)[0];return{typeName:r,changedIds:t,assembly:e,addedFeature:o.addedFeature,parentFeatureId:o.parentFeatureId,copyFeature:o.copyFeature,allIds:o.allIds}}return{typeName:r,changedIds:t,assembly:e,changes:n}}},{key:"getInverse",value:function(){var e=this.assembly,t=this.changes,n=this.logger,r=W(this.changedIds).reverse(),o=W(t).reverse().map((function(e){return{deletedFeature:e.addedFeature,parentFeatureId:e.parentFeatureId}}));return new pt({changedIds:r,typeName:"DeleteFeatureChange",changes:o,assembly:e},{logger:n})}}])}(ft),pt=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","DeleteFeatureChange"),D(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return M(t,e),I(t,[{key:"notification",get:function(){return"Feature deleted successfully"}},{key:"toJSON",value:function(){var e=this.assembly,t=this.changedIds,n=this.changes,r=this.typeName;if(1===n.length){var o=G(n,1)[0];return{typeName:r,changedIds:t,assembly:e,deletedFeature:o.deletedFeature,parentFeatureId:o.parentFeatureId}}return{typeName:r,changedIds:t,assembly:e,changes:n}}},{key:"getInverse",value:function(){var e,t=this.assembly,n=this.changes,r=this.logger,o=W(this.changedIds).reverse(),i=W(n).reverse().map((function(e){return{addedFeature:e.deletedFeature,parentFeatureId:e.parentFeatureId}}));return null===(e=r.debug)||void 0===e||e.call(r,"INVERSE CHANGE '".concat(JSON.stringify(i),"'")),new ht({changedIds:o,typeName:"AddFeatureChange",changes:i,assembly:t},{logger:r})}}])}(ft),gt=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","AddAssemblyAliasesChange"),D(r,"aliases",void 0),r.aliases=e.aliases,r}return M(t,e),I(t,[{key:"getInverse",value:function(){throw new Error("Method not implemented.")}},{key:"toJSON",value:function(){return{assembly:this.assembly,typeName:this.typeName,aliases:this.aliases}}},{key:"notification",get:function(){return"Assembly aliases have been added."}}])}(ut),mt=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","AddAssemblyAndFeaturesFromFileChange"),D(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return M(t,e),I(t,[{key:"notification",get:function(){return'Assembly "'.concat(this.changes[0].assemblyName,'" added successfully. To use it, please refresh the page.')}},{key:"toJSON",value:function(){var e=this.assembly,t=this.changes,n=this.typeName;if(1===t.length){var r=G(t,1)[0];return{typeName:n,assembly:e,assemblyName:r.assemblyName,fileIds:r.fileIds}}return{typeName:n,assembly:e,changes:t}}},{key:"getInverse",value:function(){return new t({typeName:this.typeName,changes:this.changes,assembly:this.assembly},{logger:this.logger})}}])}(ut),yt=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","AddAssemblyFromExternalChange"),D(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return M(t,e),I(t,[{key:"notification",get:function(){return'Assembly "'.concat(this.changes[0].assemblyName,'" added successfully. To use it, please refresh the page.')}},{key:"toJSON",value:function(){var e=this.assembly,t=this.changes,n=this.typeName;if(1===t.length){var r=G(t,1)[0];return{typeName:n,assembly:e,assemblyName:r.assemblyName,externalLocation:r.externalLocation}}return{typeName:n,assembly:e,changes:t}}},{key:"getInverse",value:function(){return new t({typeName:this.typeName,changes:this.changes,assembly:this.assembly},{logger:this.logger})}}])}(ut),_t=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","AddAssemblyFromFileChange"),D(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return M(t,e),I(t,[{key:"notification",get:function(){return'Assembly "'.concat(this.changes[0].assemblyName,'" added successfully. To use it, please refresh the page.')}},{key:"toJSON",value:function(){var e=this.assembly,t=this.changes,n=this.typeName;if(1===t.length){var r=G(t,1)[0];return{typeName:n,assembly:e,assemblyName:r.assemblyName,fileIds:r.fileIds}}return{typeName:n,assembly:e,changes:t}}},{key:"getInverse",value:function(){return new t({typeName:this.typeName,changes:this.changes,assembly:this.assembly},{logger:this.logger})}}])}(ut),vt=function(e){function t(e,n){var r,o;return R(this,t),D(o=T(this,t,[e,n]),"typeName","AddFeaturesFromFileChange"),D(o,"changes",void 0),D(o,"deleteExistingFeatures",!1),o.deleteExistingFeatures=null!==(r=e.deleteExistingFeatures)&&void 0!==r&&r,o.changes="changes"in e?e.changes:[e],o}return M(t,e),I(t,[{key:"notification",get:function(){return"Features have been added. To see them, please refresh the page."}},{key:"toJSON",value:function(){var e=this.assembly,t=this.changes,n=this.deleteExistingFeatures,r=this.typeName;return 1===t.length?{typeName:r,assembly:e,fileId:G(t,1)[0].fileId,deleteExistingFeatures:n}:{typeName:r,assembly:e,changes:t,deleteExistingFeatures:n}}},{key:"getInverse",value:function(){return new t({typeName:this.typeName,changes:this.changes,assembly:this.assembly},{logger:this.logger})}}])}(ut),bt=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","AddRefSeqAliasesChange"),D(r,"refSeqAliases",void 0),r.refSeqAliases=e.refSeqAliases,r}return M(t,e),I(t,[{key:"getInverse",value:function(){throw new Error("Method not implemented.")}},{key:"toJSON",value:function(){return{assembly:this.assembly,typeName:this.typeName,refSeqAliases:this.refSeqAliases}}},{key:"notification",get:function(){return"RefSeq aliases have been added."}}])}(ut),xt=function(e){function t(){var e;R(this,t);for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return D(e=T(this,t,[].concat(r)),"typeName","DeleteAssemblyChange"),e}return M(t,e),I(t,[{key:"notification",get:function(){return'Assembly "'.concat(this.assembly,'" deleted successfully.')}},{key:"toJSON",value:function(){return{typeName:this.typeName,assembly:this.assembly}}},{key:"getInverse",value:function(){return new t({typeName:"DeleteAssemblyChange",assembly:this.assembly},{logger:this.logger})}}])}(ut),wt=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","DeleteUserChange"),D(r,"changes",void 0),D(r,"userId",void 0),r.changes="changes"in e?e.changes:[e],r.userId=e.userId,r}return M(t,e),I(t,[{key:"toJSON",value:function(){return{typeName:this.typeName,userId:this.userId}}},{key:"getInverse",value:function(){return new t({typeName:this.typeName,userId:this.userId},{logger:this.logger})}}])}(ct),St=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","FeatureAttributeChange"),D(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return M(t,e),I(t,[{key:"toJSON",value:function(){var e=this.assembly,t=this.changedIds,n=this.changes,r=this.typeName;if(1===n.length){var o=G(n,1)[0];return{typeName:r,changedIds:t,assembly:e,featureId:o.featureId,oldAttributes:o.oldAttributes,newAttributes:o.newAttributes}}return{typeName:r,changedIds:t,assembly:e,changes:n}}},{key:"getInverse",value:function(){var e=this.assembly,n=this.changes,r=this.logger;return new t({changedIds:W(this.changedIds).reverse(),typeName:"FeatureAttributeChange",changes:W(n).reverse().map((function(e){return{featureId:e.featureId,oldAttributes:e.newAttributes,newAttributes:e.oldAttributes}})),assembly:e},{logger:r})}}])}(ft),Ct=["__v","_id","assemblies","configuration","internetAccounts","plugins","tracks"],At=["hasRole"];function kt(e){var t,n=e.assemblies,r=e.configuration,o=e.internetAccounts,i=e.plugins,a=e.tracks,s=q(e,Ct);if(n&&(s.assemblies=n.filter((function(e){return"ApolloSequenceAdapter"!==e.sequence.adapter.type}))),null!=r&&null!==(t=r.ApolloPlugin)&&void 0!==t&&t.hasRole){var l=q(r.ApolloPlugin,At);s.configuration=B(B({},r),{},{ApolloPlugin:l})}return o&&(s.internetAccounts=o.filter((function(e){return"ApolloInternetAccount"!==e.type}))),i&&(s.plugins=i.filter((function(e){return"Apollo"!==e.name}))),a&&(s.tracks=a.filter((function(e){return"ApolloTrack"!==e.type}))),s}var Nt=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","ImportJBrowseConfigChange"),D(r,"oldJBrowseConfig",void 0),D(r,"newJBrowseConfig",void 0),r.oldJBrowseConfig=e.oldJBrowseConfig,r.newJBrowseConfig=e.newJBrowseConfig,r}return M(t,e),I(t,[{key:"toJSON",value:function(){return{typeName:this.typeName,oldJBrowseConfig:this.oldJBrowseConfig,newJBrowseConfig:this.newJBrowseConfig}}},{key:"getInverse",value:function(){return new t({typeName:"ImportJBrowseConfigChange",oldJBrowseConfig:this.newJBrowseConfig,newJBrowseConfig:this.oldJBrowseConfig},{logger:this.logger})}}])}(ct),Tt=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","LocationEndChange"),D(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return M(t,e),I(t,[{key:"toJSON",value:function(){var e=this.assembly,t=this.changedIds,n=this.changes,r=this.typeName;if(1===n.length){var o=G(n,1)[0];return{typeName:r,changedIds:t,assembly:e,featureId:o.featureId,oldEnd:o.oldEnd,newEnd:o.newEnd}}return{typeName:r,changedIds:t,assembly:e,changes:n}}},{key:"getInverse",value:function(){var e=this.assembly,n=this.changes,r=this.logger,o=this.typeName;return new t({changedIds:W(this.changedIds).reverse(),typeName:o,changes:W(n).reverse().map((function(e){return{featureId:e.featureId,oldEnd:e.newEnd,newEnd:e.oldEnd}})),assembly:e},{logger:r})}}])}(ft);function Rt(e){return"LocationEndChange"===e.typeName}var Et=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","LocationStartChange"),D(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return M(t,e),I(t,[{key:"toJSON",value:function(){var e=this.assembly,t=this.changedIds,n=this.changes,r=this.typeName;if(1===n.length){var o=G(n,1)[0];return{typeName:r,changedIds:t,assembly:e,featureId:o.featureId,oldStart:o.oldStart,newStart:o.newStart}}return{typeName:r,changedIds:t,assembly:e,changes:n}}},{key:"getInverse",value:function(){var e=this.assembly,n=this.changes,r=this.logger,o=this.typeName;return new t({changedIds:W(this.changedIds).reverse(),typeName:o,changes:W(n).reverse().map((function(e){return{featureId:e.featureId,oldStart:e.newStart,newStart:e.oldStart}})),assembly:e},{logger:r})}}])}(ft);function It(e){return"LocationStartChange"===e.typeName}var jt=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","MergeExonsChange"),D(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return M(t,e),I(t,[{key:"notification",get:function(){return"Exons successfully merged"}},{key:"toJSON",value:function(){var e=this.assembly,t=this.changedIds,n=this.changes,r=this.typeName;if(1===n.length){var o=G(n,1)[0];return{typeName:r,changedIds:t,assembly:e,firstExon:o.firstExon,secondExon:o.secondExon,parentFeatureId:o.parentFeatureId}}return{typeName:r,changedIds:t,assembly:e,changes:n}}},{key:"getInverse",value:function(){var e,t=this.assembly,n=this.changes,r=this.logger,o=W(this.changedIds).reverse(),i=W(n).reverse().map((function(e){return{exonsToRestore:[e.firstExon,e.secondExon],parentFeatureId:e.parentFeatureId}}));return null===(e=r.debug)||void 0===e||e.call(r,"INVERSE CHANGE '".concat(JSON.stringify(i),"'")),new Dt({changedIds:o,typeName:"UndoMergeExonsChange",changes:i,assembly:t},{logger:r})}}])}(ft),Dt=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","UndoMergeExonsChange"),D(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return M(t,e),I(t,[{key:"toJSON",value:function(){var e=this.assembly,t=this.changedIds,n=this.changes,r=this.typeName;if(1===n.length){var o=G(n,1)[0];return{typeName:r,changedIds:t,assembly:e,exonsToRestore:o.exonsToRestore,parentFeatureId:o.parentFeatureId}}return{typeName:r,changedIds:t,assembly:e,changes:n}}},{key:"getInverse",value:function(){var e=this.assembly,t=this.changes,n=this.logger,r=W(this.changedIds).reverse(),o=W(t).reverse().map((function(e){return{firstExon:e.exonsToRestore[0],secondExon:e.exonsToRestore[1],parentFeatureId:e.parentFeatureId}}));return new jt({changedIds:r,typeName:"MergeExonsChange",changes:o,assembly:e},{logger:n})}}])}(ft);function Ot(e,t){for(var n=[],r=0;r<e.length;r+=t){var o=e.slice(r,r+t);n.push(o)}return n}function Ft(e){var t,n,r=e,o=null===(t=r.attributes.get("gff_id"))||void 0===t?void 0:t.join(",");if(o)return"ID=".concat(o," (_id: ").concat(e._id.toString(),")");var i=null===(n=r.attributes.get("gff_name"))||void 0===n?void 0:n.join(",");return i?"Name=".concat(i," (_id: ").concat(e._id.toString(),")"):"_id: ".concat(e._id.toString())}function Mt(e){var t={};if(!e)return t;for(var n=0,r=Object.entries(e);n<r.length;n++){var o=G(r[n],2),i=o[1];t[o[0]]=null==i?void 0:i.slice()}return t}function Lt(e){if(!e)return"";for(var t=[],n=0,r=Object.entries(e);n<r.length;n++){var o=G(r[n],2),i=o[1],a=o[0];a.startsWith("gff_")&&(a=(a=a.slice(4)).charAt(0).toUpperCase()+a.slice(1)),t.push(i?"".concat(a,"=").concat(i.join(",")):a)}return encodeURIComponent(t.join(";"))}var Pt=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","MergeTranscriptsChange"),D(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return M(t,e),I(t,[{key:"notification",get:function(){return"Transcripts successfully merged"}},{key:"toJSON",value:function(){var e=this.assembly,t=this.changedIds,n=this.changes,r=this.typeName;if(1===n.length){var o=G(n,1)[0];return{typeName:r,changedIds:t,assembly:e,firstTranscript:o.firstTranscript,secondTranscript:o.secondTranscript,parentFeatureId:o.parentFeatureId}}return{typeName:r,changedIds:t,assembly:e,changes:n}}},{key:"mergeTranscriptsOnServer",value:function(e,t){e.min=Math.min(e.min,t.min),e.max=Math.max(e.max,t.max);var n=e.attributes?JSON.parse(JSON.stringify(e.attributes)):{};if(t.attributes&&(Object.keys(n).includes("merged_with")||(n.merged_with=[]),n.merged_with.push(Lt(Mt(t.attributes)))),e.attributes=n,t.children)for(var r=0,o=Object.entries(t.children);r<o.length;r++){var i=G(o[r],2);this.mergeFeatureIntoTranscriptOnServer(i[1],e)}}},{key:"mergeFeatureIntoTranscriptOnServer",value:function(e,t){var n,r=this;null!==(n=t.children)&&void 0!==n||(t.children=new Map);var i,a,s,l=!1,c=j(t.children);try{for(c.s();!(s=c.n()).done;){var u=G(s.value,2)[1];if(l&&i?a=!0:(a=!1,i=u),i.type===e.type&&i.type===u.type&&o.doesIntersect2(e.min,e.max,i.min,i.max)&&o.doesIntersect2(u.min,u.max,i.min,i.max)){var d,f;i.min=Math.min(e.min,i.min,u.min),i.max=Math.max(e.max,i.max,u.max),null!==(f=(d=i).attributes)&&void 0!==f||(d.attributes={});var h=JSON.parse(JSON.stringify(i.attributes));Object.keys(h).includes("merged_with")||(h.merged_with=[]);var p=h.merged_with;if(p.push(Lt(Mt(e.attributes))),a){var g=u.attributes?JSON.parse(JSON.stringify(u.attributes)):void 0;p.push(Lt(g)),t.children.delete(u._id.toString())}h.merged_with=W(new Set(p)),i.attributes=h,l=!0}}}catch(e){c.e(e)}finally{c.f()}l&&i&&e.children&&Object.entries(e.children).map((function(e){var t=G(e,2);r.addChild(i,t[1])})),this.addChild(t,l&&i?i:e)}},{key:"mergeTranscriptsOnClient",value:function(e,t){var n,r;e.setMin(Math.min(e.min,t.min)),e.setMax(Math.max(e.max,t.max));var o=null!==(n=null===(r=e.attributes.get("merged_with"))||void 0===r?void 0:r.slice())&&void 0!==n?n:[],i=Lt(Mt(t.attributes));if(o.includes(i)||o.push(i),e.setAttribute("merged_with",o),t.children)for(var a=0,s=Object.entries(t.children);a<s.length;a++){var l=G(s[a],2);this.mergeFeatureIntoTranscriptOnClient(l[1],e)}}},{key:"mergeFeatureIntoTranscriptOnClient",value:function(e,t){var n;null!==(n=t.children)&&void 0!==n||(t.children=new Map);var r,i,a,s=!1,c=j(t.children);try{for(c.s();!(a=c.n()).done;){var u=G(a.value,2)[1];if(s&&r?i=!0:(i=!1,r=u),r.type===e.type&&r.type===u.type&&o.doesIntersect2(e.min,e.max,r.min,r.max)&&o.doesIntersect2(u.min,u.max,r.min,r.max)){var d,f;r.setMin(Math.min(e.min,r.min,u.min)),r.setMax(Math.max(e.max,r.max,u.max));var h=null!==(d=null===(f=r.attributes.get("merged_with"))||void 0===f?void 0:f.slice())&&void 0!==d?d:[];h.push(Lt(Mt(e.attributes))),i&&(h.push(Lt(l.getSnapshot(u).attributes)),t.deleteChild(u._id)),r.setAttribute("merged_with",W(new Set(h))),s=!0}}}catch(e){c.e(e)}finally{c.f()}s&&r&&e.children&&Object.entries(e.children).map((function(e){var t=G(e,2);r.addChild(t[1])})),t.addChild(s&&r?l.getSnapshot(r):e)}},{key:"getInverse",value:function(){var e,t=this.assembly,n=this.changes,r=this.logger,o=W(this.changedIds).reverse(),i=W(n).reverse().map((function(e){return{transcriptsToRestore:[e.firstTranscript,e.secondTranscript],parentFeatureId:e.parentFeatureId}}));return null===(e=r.debug)||void 0===e||e.call(r,"INVERSE CHANGE '".concat(JSON.stringify(i),"'")),new Bt({changedIds:o,typeName:"UndoMergeTranscriptsChange",changes:i,assembly:t},{logger:r})}}])}(ft),Bt=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","UndoMergeTranscriptsChange"),D(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return M(t,e),I(t,[{key:"toJSON",value:function(){var e=this.assembly,t=this.changedIds,n=this.changes,r=this.typeName;if(1===n.length){var o=G(n,1)[0];return{typeName:r,changedIds:t,assembly:e,transcriptsToRestore:o.transcriptsToRestore,parentFeatureId:o.parentFeatureId}}return{typeName:r,changedIds:t,assembly:e,changes:n}}},{key:"getInverse",value:function(){var e=this.assembly,t=this.changes,n=this.logger,r=W(this.changedIds).reverse(),o=W(t).reverse().map((function(e){return{firstTranscript:e.transcriptsToRestore[0],secondTranscript:e.transcriptsToRestore[1],parentFeatureId:e.parentFeatureId}}));return new Pt({changedIds:r,typeName:"MergeTranscriptsChange",changes:o,assembly:e},{logger:n})}}])}(ft),qt=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","SplitExonChange"),D(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return M(t,e),I(t,[{key:"notification",get:function(){return"Exon successfully split"}},{key:"toJSON",value:function(){var e=this.assembly,t=this.changedIds,n=this.changes,r=this.typeName;if(1===n.length){var o=G(n,1)[0];return{typeName:r,changedIds:t,assembly:e,exonToBeSplit:o.exonToBeSplit,parentFeatureId:o.parentFeatureId,upstreamCut:o.upstreamCut,downstreamCut:o.downstreamCut,leftExonId:o.leftExonId,rightExonId:o.rightExonId}}return{typeName:r,changedIds:t,assembly:e,changes:n}}},{key:"getInverse",value:function(){var e,t=this.assembly,n=this.changes,r=this.logger,o=W(this.changedIds).reverse(),i=W(n).reverse().map((function(e){return{exonToRestore:e.exonToBeSplit,parentFeatureId:e.parentFeatureId,idsToDelete:[e.leftExonId,e.rightExonId],upstreamCut:e.upstreamCut,downstreamCut:e.downstreamCut,leftExonId:e.leftExonId,rightExonId:e.rightExonId}}));return null===(e=r.debug)||void 0===e||e.call(r,"INVERSE CHANGE '".concat(JSON.stringify(i),"'")),new Ut({changedIds:o,typeName:"UndoSplitExonChange",changes:i,assembly:t},{logger:r})}},{key:"makeSplitExons",value:function(e,t,n,r,o){var i=JSON.parse(JSON.stringify(e));delete i.attributes._id,delete i.attributes.gff_id;var a=structuredClone(i);a._id=r,a.max=t;var s=structuredClone(i);return s.min=n,s._id=o,[a,s]}}])}(ft),Ut=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","UndoSplitExonChange"),D(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return M(t,e),I(t,[{key:"toJSON",value:function(){var e=this.assembly,t=this.changedIds,n=this.changes,r=this.typeName;if(1===n.length){var o=G(n,1)[0];return{typeName:r,changedIds:t,assembly:e,exonToRestore:o.exonToRestore,parentFeatureId:o.parentFeatureId,idsToDelete:o.idsToDelete,upstreamCut:o.upstreamCut,downstreamCut:o.downstreamCut,leftExonId:o.leftExonId,rightExonId:o.rightExonId}}return{typeName:r,changedIds:t,assembly:e,changes:n}}},{key:"getInverse",value:function(){var e=this.assembly,t=this.changes,n=this.logger,r=W(this.changedIds).reverse(),o=W(t).reverse().map((function(e){return{parentFeatureId:e.parentFeatureId,exonToBeSplit:e.exonToRestore,upstreamCut:e.upstreamCut,downstreamCut:e.downstreamCut,leftExonId:e.leftExonId,rightExonId:e.rightExonId}}));return new qt({changedIds:r,typeName:"SplitExonChange",changes:o,assembly:e},{logger:n})}}])}(ft),zt=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","StrandChange"),D(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return M(t,e),I(t,[{key:"toJSON",value:function(){var e=this.assembly,t=this.changedIds,n=this.changes,r=this.typeName;if(1===n.length){var o=G(n,1)[0];return{typeName:r,changedIds:t,assembly:e,featureId:o.featureId,oldStrand:o.oldStrand,newStrand:o.newStrand}}return{typeName:r,changedIds:t,assembly:e,changes:n}}},{key:"getInverse",value:function(){var e=this.assembly,n=this.changes,r=this.logger,o=this.typeName;return new t({changedIds:W(this.changedIds).reverse(),typeName:o,changes:W(n).reverse().map((function(e){return{featureId:e.featureId,oldStrand:e.newStrand,newStrand:e.oldStrand}})),assembly:e},{logger:r})}}])}(ft),$t=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","TypeChange"),D(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return M(t,e),I(t,[{key:"toJSON",value:function(){var e=this.assembly,t=this.changedIds,n=this.changes,r=this.typeName;if(1===n.length){var o=G(n,1)[0];return{typeName:r,changedIds:t,assembly:e,featureId:o.featureId,oldType:o.oldType,newType:o.newType}}return{typeName:r,changedIds:t,assembly:e,changes:n}}},{key:"getInverse",value:function(){var e=this.assembly,n=this.changes,r=this.logger,o=this.typeName;return new t({changedIds:W(this.changedIds).reverse(),typeName:o,changes:W(n).reverse().map((function(e){return{featureId:e.featureId,oldType:e.newType,newType:e.oldType}})),assembly:e},{logger:r})}}])}(ft),Ht=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","UserChange"),D(r,"changes",void 0),D(r,"userId",void 0),r.changes="changes"in e?e.changes:[e],r.userId=e.userId,r}return M(t,e),I(t,[{key:"toJSON",value:function(){var e=this.changes,t=this.typeName,n=this.userId;return 1===e.length?{typeName:t,userId:n,role:G(e,1)[0].role}:{typeName:t,userId:n,changes:e}}},{key:"getInverse",value:function(){return new t({typeName:this.typeName,changes:this.changes,userId:this.userId},{logger:this.logger})}}])}(ct),Gt=B(B({},{AddFeatureChange:ht,DeleteFeatureChange:pt,FeatureAttributeChange:St,LocationEndChange:Tt,LocationStartChange:Et,MergeExonsChange:jt,SplitExonChange:qt,MergeTranscriptsChange:Pt,UndoMergeExonsChange:Dt,UndoSplitExonChange:Ut,UndoMergeTranscriptsChange:Bt,StrandChange:zt,TypeChange:$t}),{},{AddAssemblyAndFeaturesFromFileChange:mt,AddAssemblyFromFileChange:_t,AddAssemblyFromExternalChange:yt,AddFeaturesFromFileChange:vt,DeleteAssemblyChange:xt,DeleteUserChange:wt,ImportJBrowseConfigChange:Nt,UserChange:Ht,AddRefSeqAliasesChange:bt,AddAssemblyAliasesChange:gt}),Vt=function(){return I((function e(){R(this,e)}),[{key:"frontendPreValidate",value:(o=k(U().m((function e(t){return U().w((function(e){for(;;)if(0===e.n)return e.a(2,{validationName:this.name})}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"frontendPostValidate",value:(r=k(U().m((function e(t){return U().w((function(e){for(;;)if(0===e.n)return e.a(2,{validationName:this.name})}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"backendPreValidate",value:(n=k(U().m((function e(t){return U().w((function(e){for(;;)if(0===e.n)return e.a(2,{validationName:this.name})}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"backendPostValidate",value:(t=k(U().m((function e(t,n){return U().w((function(e){for(;;)if(0===e.n)return e.a(2,{validationName:this.name})}),e,this)}))),function(e,n){return t.apply(this,arguments)})},{key:"possibleValues",value:(e=k(U().m((function e(t){return U().w((function(e){for(;;)if(0===e.n)return e.a(2,void 0)}),e)}))),function(t){return e.apply(this,arguments)})}]);var e,t,n,r,o}(),Wt=function(){return I((function e(){R(this,e),D(this,"results",[]),D(this,"ok",!0)}),[{key:"resultsMessages",get:function(){return this.results.map((function(e){var t;return null===(t=e.error)||void 0===t?void 0:t.message})).filter(Boolean).join(", ")}},{key:"add",value:function(e){this.results.push(e),e.error&&(this.ok=!1)}}])}(),Jt=function(){return I((function e(){R(this,e),D(this,"validations",new Set)}),[{key:"registerValidation",value:function(e){this.validations.add(e)}},{key:"frontendPreValidate",value:(o=k(U().m((function e(t){var n,r,o,i,a;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:n=new Wt,r=j(this.validations),e.p=1,r.s();case 2:if((o=r.n()).done){e.n=5;break}return i=o.value,e.n=3,i.frontendPreValidate(t);case 3:if(n.add(a=e.v),!a.error){e.n=4;break}return e.a(3,5);case 4:e.n=2;break;case 5:e.n=7;break;case 6:e.p=6,r.e(e.v);case 7:return e.p=7,r.f(),e.f(7);case 8:return e.a(2,n)}}),e,this,[[1,6,7,8]])}))),function(e){return o.apply(this,arguments)})},{key:"frontendPostValidate",value:(r=k(U().m((function e(t){var n,r,o,i,a;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:n=new Wt,r=j(this.validations),e.p=1,r.s();case 2:if((o=r.n()).done){e.n=5;break}return i=o.value,e.n=3,i.frontendPostValidate(t);case 3:if(n.add(a=e.v),!a.error){e.n=4;break}return e.a(3,5);case 4:e.n=2;break;case 5:e.n=7;break;case 6:e.p=6,r.e(e.v);case 7:return e.p=7,r.f(),e.f(7);case 8:return e.a(2,n)}}),e,this,[[1,6,7,8]])}))),function(e){return r.apply(this,arguments)})},{key:"backendPreValidate",value:(n=k(U().m((function e(t){var n,r,o,i,a;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:n=new Wt,r=j(this.validations),e.p=1,r.s();case 2:if((o=r.n()).done){e.n=5;break}return i=o.value,e.n=3,i.backendPreValidate(t);case 3:if(n.add(a=e.v),!a.error){e.n=4;break}return e.a(3,5);case 4:e.n=2;break;case 5:e.n=7;break;case 6:e.p=6,r.e(e.v);case 7:return e.p=7,r.f(),e.f(7);case 8:return e.a(2,n)}}),e,this,[[1,6,7,8]])}))),function(e){return n.apply(this,arguments)})},{key:"backendPostValidate",value:(t=k(U().m((function e(t,n){var r,o,i,a,s,l,c;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:r=n.featureModel,o=n.session,i=new Wt,a=j(this.validations),e.p=1,a.s();case 2:if((s=a.n()).done){e.n=5;break}return l=s.value,e.n=3,l.backendPostValidate(t,{featureModel:r,session:o});case 3:if(i.add(c=e.v),!c.error){e.n=4;break}return e.a(3,5);case 4:e.n=2;break;case 5:e.n=7;break;case 6:e.p=6,a.e(e.v);case 7:return e.p=7,a.f(),e.f(7);case 8:return e.a(2,i)}}),e,this,[[1,6,7,8]])}))),function(e,n){return t.apply(this,arguments)})},{key:"possibleValues",value:(e=k(U().m((function e(t){var n,r,o,i;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:n=j(this.validations),e.p=1,n.s();case 2:if((r=n.n()).done){e.n=5;break}return o=r.value,e.n=3,o.possibleValues(t);case 3:if(!(i=e.v)){e.n=4;break}return e.a(2,i);case 4:e.n=2;break;case 5:e.n=7;break;case 6:e.p=6,n.e(e.v);case 7:return e.p=7,n.f(),e.f(7);case 8:return e.a(2)}}),e,this,[[1,6,7,8]])}))),function(t){return e.apply(this,arguments)})}]);var e,t,n,r,o}(),Kt=new Jt,Yt=["2A_self_cleaving_peptide_region","4_methylcytosine","5S_SINE_retrotransposon","5_carboxylcytosine","5_formylcytosine","5_hydroxymethylcytosine","5_methylcytosine","7SL_SINE_retrotransposon","8_oxoadenine","8_oxoguanine","AACCCT_box","AFLP_fragment","AP_1_binding_site","ARIA","ARRET","ARS","ARS_consensus_sequence","ASPE_primer","AUG_initiated_uORF","AU_rich_element","A_box","A_box_type_1","A_box_type_2","A_minor_RNA_motif","A_to_C_transversion","A_to_G_transition","A_to_T_transversion","Ace2_UAS","Alu_deletion","Alu_insertion","BAC","BAC_cloned_genomic_insert","BAC_end","BAC_read_contig","BREd_motif","BREu_motif","B_box","Bel_Pao_LTR_retrotransposon","Bruno_response_element","C-D_H_ACA_box_scaRNA","C-D_H_ACA_box_scaRNA_gene","CAAT_signal","CAAX_box","CACTA_TIR_transposon","CAGE_cluster","CAGE_tag","CArG_box","CCAAT_motif","CCA_tail","CDRE_motif","CDS","CDS_extension","CDS_five_prime_extension","CDS_fragment","CDS_independently_known","CDS_predicted","CDS_region","CDS_supported_by_EST_or_cDNA_data","CDS_supported_by_domain_match_data","CDS_supported_by_peptide_spectrum_match","CDS_supported_by_sequence_similarity_data","CDS_three_prime_extension","CRE","CRISPR","CSL_response_element","CTCF_binding_site","CTG_start_codon","C_D_box_scaRNA","C_D_box_scaRNA_gene","C_D_box_snoRNA","C_D_box_snoRNA_gene","C_D_box_snoRNA_primary_transcript","C_box","C_cluster","C_gene_segment","C_region","C_to_A_transversion","C_to_G_transversion","C_to_T_transition","C_to_T_transition_at_pCpG_site","ChIP_seq_region","Copia_LTR_retrotransposon","CpG_island","Crick_strand","Crypton_YR_transposon","CsrB_RsmB_RNA","CuRE","DArT_marker","DCE","DCE_SI","DCE_SII","DCE_SIII","DDB_box","DHU_loop","DIRS_YR_retrotransposon","DJ_C_cluster","DJ_J_C_cluster","DJ_J_cluster","DJ_gene_segment","DMv1_motif","DMv2_motif","DMv3_motif","DMv4_motif","DMv5_motif","DNA_aptamer","DNA_binding_site","DNA_chromosome","DNA_constraint_sequence","DNA_loop","DNA_loop_anchor","DNA_motif","DNA_sequence_secondary_structure","DNA_transposon","DNAzyme","DNaseI_hypersensitive_site","DPE1_motif","DPE_motif","DRE","DRE_motif","DSR_motif","D_DJ_C_cluster","D_DJ_J_C_cluster","D_DJ_J_cluster","D_DJ_cluster","D_J_C_cluster","D_J_cluster","D_cluster","D_gene_recombination_feature","D_gene_segment","D_loop","DsrA_RNA","ER_retention_signal","EST","EST_match","E_box_motif","Endogenous_Retrovirus_LTR_retrotransposon","FLEX_element","FRE","FRT_site","GAGA_motif","GATA_box","GC_rich_promoter_region","GNA_oligo","GTT_trinucleotide_repeat","GT_dinucleotide_repeat","G_box","G_quartet","G_to_A_transition","G_to_C_transversion","G_to_T_transversion","GcvB_RNA","Gypsy_LTR_retrotransposon","H2AK5_acetylation_site","H2AK9_acetylation_site","H2AZK11_acetylation_site","H2AZK13_acetylation_site","H2AZK15_acetylation_site","H2AZK4_acetylation_site","H2AZK7_acetylation_site","H2BK120_acetylation_site","H2BK12_acetylation_site","H2BK15_acetylation_site","H2BK20_acetylation_site","H2BK5_acetylation_site","H2BK5_monomethylation_site","H2B_ubiquitination_site","H3K14_acetylation_site","H3K18_acetylation_site","H3K20_trimethylation_site","H3K23_acetylation_site","H3K23_dimethylation_site","H3K27_acetylation_site","H3K27_dimethylation_site","H3K27_methylation_site","H3K27_monomethylation_site","H3K27_trimethylation_site","H3K36_acetylation_site","H3K36_dimethylation_site","H3K36_methylation_site","H3K36_monomethylation_site","H3K36_trimethylation_site","H3K4_acetylation_site","H3K4_dimethylation_site","H3K4_methylation_site","H3K4_monomethylation_site","H3K4_trimethylation","H3K56_acetylation_site","H3K79_dimethylation_site","H3K79_methylation_site","H3K79_monomethylation_site","H3K79_trimethylation_site","H3K9_acetylation_site","H3K9_dimethylation_site","H3K9_methylation_site","H3K9_monomethylation_site","H3K9_trimethylation_site","H3R2_dimethylation_site","H3R2_monomethylation_site","H4K12_acetylation_site","H4K16_acetylation_site","H4K20_monomethylation_site","H4K4_trimethylation_site","H4K5_acetylation_site","H4K8_acetylation_site","H4K91_acetylation_site","H4K_acylation_region","H4R3_dimethylation_site","HERV_deletion","HERV_insertion","HSE","H_ACA_box_scaRNA","H_ACA_box_scaRNA_gene","H_ACA_box_snoRNA","H_ACA_box_snoRNA_gene","H_ACA_box_snoRNA_primary_transcript","H_pseudoknot","Hoogsteen_base_pair","I-box","IG_C_gene","IG_C_pseudogene","IG_D_gene","IG_J_gene","IG_J_pseudogene","IG_V_gene","IG_V_pseudogene","INR1_motif","INR_motif","IRLinv_site","IRRinv_site","ISRE","I_LINE_retrotransposon","J_C_cluster","J_cluster","J_gene_recombination_feature","J_gene_segment","J_heptamer","J_nonamer","J_spacer","Jockey_LINE_retrotransposon","KEN_box","K_turn_RNA_motif","L1_LINE_retrotransposon","LARD","LINE1_deletion","LINE1_insertion","LINE_element","LNA_oligo","LOZ1_response_element","LTR_component","LTR_retrotransposon","L_box","MCB","MITE","MNP","MNV","MNV_artifact","MTE","Mat2P","Mat3M","Merlin_TIR_transposon","MicF_RNA","Mutator_TIR_transposon","N2_2_prime_O_dimethylguanosine","N2_7_2prirme_O_trimethylguanosine","N2_7_dimethylguanosine","N2_N2_2_prime_O_trimethylguanosine","N2_N2_7_trimethylguanosine","N2_N2_dimethylguanosine","N2_methylguanosine","N4_2_prime_O_dimethylcytidine","N4_N4_2_prime_O_trimethylcytidine","N4_acetyl_2_prime_O_methylcytidine","N4_acetylcytidine","N4_methylcytidine","N6_2_prime_O_dimethyladenosine","N6_N6_2_prime_O_trimethyladenosine","N6_N6_dimethyladenosine","N6_acetyladenosine","N6_cis_hydroxyisopentenyl_adenosine","N6_glycinylcarbamoyladenosine","N6_hydroxynorvalylcarbamoyladenosine","N6_isopentenyladenosine","N6_methyl_N6_threonylcarbamoyladenosine","N6_methyladenine","N6_methyladenosine","N6_threonylcarbamoyladenosine","NDM2_motif","NDM3_motif","NMD_polymorphic_pseudogene_transcript","NMD_transcript","NSD_transcript","N_region","Ngaro_YR_retrotransposon","ORF","Okazaki_fragment","OxyS_RNA","PAC","PAC_end","PCB","PCR_product","PIF_Harbinger_TIR_transposon","PIP_box","PNA_oligo","PSE_motif","P_TIR_transposon","Penelope_retrotransposon","Phage_RNA_Polymerase_Promoter","Pho7_binding_site","QTL","R2_LINE_retrotransposon","RAPD","RFLP_fragment","RH_map","RNA_6S","RNA_7SK","RNA_7SK_gene","RNA_aptamer","RNA_chromosome","RNA_hook_turn","RNA_internal_loop","RNA_junction_loop","RNA_motif","RNA_polymerase_III_TATA_box","RNA_polymerase_II_TATA_box","RNA_sequence_secondary_structure","RNA_stability_element","RNA_thermometer","RNAi_reagent","RNApol_III_promoter","RNApol_III_promoter_type_1","RNApol_III_promoter_type_2","RNApol_III_promoter_type_3","RNApol_II_core_promoter","RNApol_II_promoter","RNApol_I_promoter","RNase_MRP_RNA","RNase_MRP_RNA_gene","RNase_P_RNA","RNase_P_RNA_gene","RRE_RNA","RR_tract","RST","RST_match","RTE_LINE_retrotransposon","R_GNA_oligo","R_LTR_region","R_five_prime_LTR_region","R_three_prime_LTR_region","Retrovirus_LTR_retrotransposon","Robertsonian_fusion","RprA_RNA","SAGE_tag","SECIS_element","SHP_box","SINE_element","SL10_acceptor_site","SL11_acceptor_site","SL12_acceptor_site","SL1_acceptor_site","SL2_acceptor_site","SL3_acceptor_site","SL4_acceptor_site","SL5_acceptor_site","SL6_acceptor_site","SL7_acceptor_site","SL8_acceptor_site","SL9_acceptor_site","SNP","SNV","SNV_artifact","SP6_RNA_Polymerase_Promoter","SRP_RNA","SRP_RNA_gene","SRP_RNA_primary_transcript","STREP_motif","STS","STS_map","SUMO_interaction_motif","SVA_deletion","SVA_insertion","S_GNA_oligo","S_region","Sap1_recognition_motif","Shine_Dalgarno_sequence","T3_RNA_Polymerase_Promoter","T7_RNA_Polymerase_Promoter","TATA_box","TCS_element","TCT_motif","TERRA","TFRS_collection","TFRS_module","TF_binding_site","TNA_oligo","TRIM","TR_C_Gene","TR_D_Gene","TR_J_Gene","TR_J_pseudogene","TR_V_Gene","TR_V_pseudogene","TR_box","TSS","T_cell_receptor_gene","T_cell_receptor_pseudogene","T_loop","T_to_A_transversion","T_to_C_transition","T_to_G_transversion","Tc1_Mariner_TIR_transposon","Transib_TIR_transposon","U11_snRNA","U12_intron","U12_snRNA","U14_snoRNA","U14_snoRNA_gene","U14_snoRNA_primary_transcript","U1_snRNA","U2_intron","U2_snRNA","U3_LTR_region","U3_five_prime_LTR_region","U3_snoRNA","U3_snoRNA_gene","U3_three_prime_LTR_region","U4_snRNA","U4atac_snRNA","U5_LTR_region","U5_five_prime_LTR_region","U5_snRNA","U5_three_prime_LTR_region","U6_snRNA","U6atac_snRNA","U7_snRNA","UAA_stop_codon_signal","UAG_stop_codon_signal","UGA_stop_codon_signal","UNAAAC_motif","UPD","UST","UST_match","UTR","UTR_intron","UTR_region","U_box","VDJ_C_cluster","VDJ_J_C_cluster","VDJ_J_cluster","VDJ_gene_segment","VD_gene_segment","VJ_C_cluster","VJ_J_C_cluster","VJ_J_cluster","VJ_gene_segment","V_DJ_C_cluster","V_DJ_J_C_cluster","V_DJ_J_cluster","V_DJ_cluster","V_D_DJ_C_cluster","V_D_DJ_J_C_cluster","V_D_DJ_J_cluster","V_D_DJ_cluster","V_D_J_C_cluster","V_D_J_cluster","V_J_C_cluster","V_J_cluster","V_VDJ_C_cluster","V_VDJ_J_C_cluster","V_VDJ_J_cluster","V_VDJ_cluster","V_VJ_C_cluster","V_VJ_J_C_cluster","V_VJ_J_cluster","V_VJ_cluster","V_cluster","V_gene_recombination_feature","V_gene_segment","V_heptamer","V_nonamer","V_region","V_spacer","Viper_YR_retrotransposon","WC_base_pair","W_region","Watson_strand","X_element","X_element_combinatorial_repeat","X_region","YAC","YAC_end","YR_retrotransposon","Y_RNA","Y_RNA_gene","Y_RNA_primary_transcript","Y_prime_element","Y_region","Z1_region","Z2_region","Zas1_recognition_motif","aberrant_processed_transcript","accessible_DNA_region","active_peptide","adaptive_island","alanine","alanine_tRNA_primary_transcript","alanyl_tRNA","allelic_pseudogene","allelic_pseudogenic_rRNA","allelic_pseudogenic_tRNA","allelically_excluded_gene","alpha_beta_motif","alpha_helix","alternate_sequence_site","alternatively_spliced_transcript","amber_stop_codon","ambisense_ssRNA_viral_sequence","amino_acid","amplification_origin","anchor_binding_site","anchor_region","androgen_response_element","anti_ARRET","anticodon","anticodon_loop","antiparallel_beta_strand","antisense_RNA","antisense_lncRNA","antisense_lncRNA_gene","antisense_primary_transcript","apicoplast_chromosome","apicoplast_gene","aptamer","archaeal_intron","archaeosine","arginine","arginine_tRNA_primary_transcript","arginyl_tRNA","asparagine","asparagine_tRNA_primary_transcript","asparaginyl_tRNA","aspartic_acid","aspartic_acid_tRNA_primary_transcript","aspartyl_tRNA","assembly","assembly_component","assembly_error_correction","asx_motif","asx_turn","asx_turn_left_handed_type_one","asx_turn_left_handed_type_two","asx_turn_right_handed_type_one","asx_turn_right_handed_type_two","asymmetric_RNA_internal_loop","attB_site","attC_site","attCtn_site","attI_site","attL_site","attP_site","attR_site","attenuator","autocatalytically_spliced_intron","bacterial_RNApol_promoter","bacterial_RNApol_promoter_sigma54_element","bacterial_RNApol_promoter_sigma_70_element","bacterial_RNApol_promoter_sigma_ecf_element","bacterial_terminator","base","base_call_error_correction","base_pair","beta_bulge","beta_bulge_loop","beta_bulge_loop_five","beta_bulge_loop_six","beta_strand","beta_turn","beta_turn_left_handed_type_one","beta_turn_left_handed_type_two","beta_turn_right_handed_type_one","beta_turn_right_handed_type_two","beta_turn_type_eight","beta_turn_type_six","beta_turn_type_six_a","beta_turn_type_six_a_one","beta_turn_type_six_a_two","beta_turn_type_six_b","bidirectional_promoter","bidirectional_promoter_lncRNA","binding_site","biochemical_region_of_peptide","biological_region","biomaterial_region","biosynthetic_gene_cluster","blocked_reading_frame","blunt_end_restriction_enzyme_cleavage_junction","blunt_end_restriction_enzyme_cleavage_site","boundary_element","branch_site","cDNA_clone","cDNA_match","c_terminal_region","candidate_gene","canonical_five_prime_splice_site","canonical_three_prime_splice_site","cap","capped_mRNA","capped_primary_transcript","cassette_pseudogene","catalytic_residue","catmat_left_handed_four","catmat_left_handed_three","catmat_right_handed_four","catmat_right_handed_three","central_hydrophobic_region_of_signal_peptide","centromere","centromere_DNA_Element_I","centromere_DNA_Element_II","centromere_DNA_Element_III","centromeric_repeat","chimeric_cDNA_clone","chloroplast_DNA_read","chloroplast_chromosome","chromatin_regulatory_region","chromoplast_chromosome","chromoplast_gene","chromosomal_regulatory_element","chromosomal_structural_element","chromosomal_translocation","chromosome","chromosome_arm","chromosome_band","chromosome_breakage_sequence","chromosome_breakpoint","chromosome_part","circular_double_stranded_DNA_chromosome","circular_double_stranded_RNA_chromosome","circular_mRNA","circular_ncRNA","circular_plasmid","circular_single_stranded_DNA_chromosome","circular_single_stranded_RNA_chromosome","cis_acting_homologous_chromosome_pairing_region","cis_regulatory_frameshift_element","cis_regulatory_module","cis_splice_site","class_II_RNA","class_I_RNA","cleaved_for_gpi_anchor_region","cleaved_initiator_methionine","cleaved_peptide_region","clip","clone","clone_end","clone_insert","clone_insert_end","clone_insert_start","cloned_cDNA_insert","cloned_genomic_insert","cloned_region","coding_conserved_region","coding_end","coding_exon","coding_region_of_exon","coding_start","coding_transcript_with_retained_intron","codon","coiled_coil","cointegrated_plasmid","common_fragile_site","complex_chromosomal_rearrangement","complex_operon","complex_regulon","complex_structural_alteration","complex_substitution","compositionally_biased_region_of_peptide","conformational_switch","conjugative_transposon","consensus_AFLP_fragment","consensus_gDNA","consensus_mRNA","consensus_region","conserved_region","constitutive_promoter","contig","contig_collection","contig_read","copy_number_gain","copy_number_loss","copy_number_variation","core_eukaryotic_promoter_element","core_prokaryotic_promoter_element","core_promoter_element","core_viral_promoter_element","cosmid","cross_genome_match","cryptic_gene","cryptic_promoter","cryptic_prophage","cryptic_splice_site","cryptogene","ct_gene","cyanelle_chromosome","cyanelle_gene","cyclic_translocation","cysteine","cysteine_tRNA_primary_transcript","cysteinyl_tRNA","cytoplasmic_polypeptide_region","cytosolic_16S_rRNA","cytosolic_18S_rRNA","cytosolic_23S_rRNA","cytosolic_25S_rRNA","cytosolic_28S_rRNA","cytosolic_2S_rRNA","cytosolic_5S_rRNA","cytosolic_5_8S_rRNA","cytosolic_LSU_rRNA","cytosolic_LSU_rRNA_gene","cytosolic_SSU_rRNA","cytosolic_SSU_rRNA_gene","cytosolic_rRNA","cytosolic_rRNA_16S_gene","cytosolic_rRNA_18S_gene","cytosolic_rRNA_23S_gene","cytosolic_rRNA_25S_gene","cytosolic_rRNA_28S_gene","cytosolic_rRNA_2S_gene","cytosolic_rRNA_5S_gene","cytosolic_rRNA_5_8S_gene","cytosolic_rRNA_gene","dCAPS_primer","databank_entry","decayed_exon","defective_conjugative_transposon","deficient_translocation","deletion","deletion_artifact","deletion_breakpoint","deletion_junction","delins","destruction_box","dg_repeat","dh_repeat","dicistronic_mRNA","dicistronic_primary_transcript","dicistronic_transcript","dif_site","dihydrouridine","dinucleotide_repeat_microsatellite_feature","direct_repeat","direct_tandem_duplication","disabled_reading_frame","dispersed_repeat","distal_duplication","distal_promoter_element","distant_three_prime_recoding_signal","double_stranded_DNA_chromosome","double_stranded_RNA_chromosome","ds_DNA_viral_sequence","ds_RNA_viral_sequence","ds_oligo","duplicated_pseudogene","duplication","duplication_artifact","dye_terminator_read","early_origin_of_replication","edited_CDS","edited_mRNA","edited_transcript","edited_transcript_by_A_to_I_substitution","edited_transcript_feature","editing_block","editing_domain","endogenous_retroviral_gene","endonuclease_spliced_intron","endosomal_localization_signal","engineered_episome","engineered_foreign_gene","engineered_foreign_region","engineered_foreign_repetitive_element","engineered_foreign_transposable_element","engineered_foreign_transposable_element_gene","engineered_fusion_gene","engineered_gene","engineered_insert","engineered_plasmid","engineered_region","engineered_rescue_region","engineered_tag","engineered_transposable_element","enhancer","enhancerRNA","enhancer_binding_site","enhancer_blocking_element","enhancer_bound_by_factor","enhancer_trap_construct","enzymatic_RNA","enzymatic_RNA_gene","epigenetically_modified_gene","epigenetically_modified_region","epigenomically_modified_region","episome","epitope","epoxyqueuosine","eukaryotic_promoter","eukaryotic_terminator","exemplar_mRNA","exon","exon_junction","exon_of_single_exon_gene","exon_region","exonic_splice_enhancer","exonic_splicing_silencer","experimental_feature","experimental_result_region","experimentally_defined_binding_region","expressed_sequence_assembly","expressed_sequence_match","extended_cis_splice_site","extended_intronic_splice_region","external_transcribed_spacer_region","extrachromosomal_mobile_genetic_element","extramembrane_polypeptide_region","fingerprint_map","five_aminomethyl_two_thiouridine","five_carbamoylmethyl_two_prime_O_methyluridine","five_carbamoylmethyluridine","five_carboxyhydroxymethyl_uridine","five_carboxyhydroxymethyl_uridine_methyl_ester","five_carboxymethylaminomethyl_two_prime_O_methyluridine","five_carboxymethylaminomethyl_two_thiouridine","five_carboxymethylaminomethyluridine","five_carboxymethyluridine","five_formyl_two_prime_O_methylcytidine","five_formylcytidine","five_hydroxymethylcytidine","five_hydroxyuridine","five_isopentenylaminomethyl_two_prime_O_methyluridine","five_isopentenylaminomethyl_two_thiouridine","five_isopentenylaminomethyl_uridine","five_methoxycarbonylmethyl_two_prime_O_methyluridine","five_methoxycarbonylmethyl_two_thiouridine","five_methoxycarbonylmethyluridine","five_methoxyuridine","five_methyl_2_thiouridine","five_methylaminomethyl_two_selenouridine","five_methylaminomethyl_two_thiouridine","five_methylaminomethyluridine","five_methylcytidine","five_methyldihydrouridine","five_methyluridine","five_prime_D_heptamer","five_prime_D_nonamer","five_prime_D_recombination_signal_sequence","five_prime_D_spacer","five_prime_EST","five_prime_LTR","five_prime_LTR_component","five_prime_RST","five_prime_UST","five_prime_UTR","five_prime_UTR_intron","five_prime_cis_splice_site","five_prime_clip","five_prime_coding_exon","five_prime_coding_exon_coding_region","five_prime_coding_exon_noncoding_region","five_prime_flanking_region","five_prime_intron","five_prime_noncoding_exon","five_prime_open_reading_frame","five_prime_recoding_site","five_prime_restriction_enzyme_junction","five_prime_sticky_end_restriction_enzyme_cleavage_site","five_prime_terminal_inverted_repeat","five_taurinomethyl_two_thiouridine","five_taurinomethyluridine","five_two_prime_O_dimethylcytidine","five_two_prime_O_dimethyluridine","flanking_region","flanking_repeat","flanking_three_prime_quadruplet_recoding_signal","floxed_gene","foldback_element","foreign_gene","foreign_transposable_element","forkhead_motif","forward_primer","fosmid","four_bp_start_codon","four_demethylwyosine","four_thiouridine","fragile_site","fragment_assembly","functional_candidate_gene","functional_gene_region","fusion_gene","gRNA_gene","galactosyl_queuosine","gamma_turn","gamma_turn_classic","gamma_turn_inverse","gap","gene","gene_array","gene_cassette","gene_cassette_array","gene_component_region","gene_fragment","gene_group","gene_member_region","gene_rearranged_at_DNA_level","gene_segment","gene_silenced_by_DNA_methylation","gene_silenced_by_DNA_modification","gene_silenced_by_RNA_interference","gene_silenced_by_histone_deacetylation","gene_silenced_by_histone_methylation","gene_silenced_by_histone_modification","gene_subarray","gene_trap_construct","gene_with_dicistronic_mRNA","gene_with_dicistronic_primary_transcript","gene_with_dicistronic_transcript","gene_with_edited_transcript","gene_with_mRNA_recoded_by_translational_bypass","gene_with_mRNA_with_frameshift","gene_with_non_canonical_start_codon","gene_with_polyadenylated_mRNA","gene_with_polycistronic_transcript","gene_with_recoded_mRNA","gene_with_start_codon_CUG","gene_with_stop_codon_read_through","gene_with_stop_codon_redefined_as_pyrrolysine","gene_with_stop_codon_redefined_as_selenocysteine","gene_with_trans_spliced_transcript","gene_with_transcript_with_translational_frameshift","genetic_marker","genomic_DNA_contig","genomic_DNA_read","genomic_clone","genomic_island","genomically_contaminated_cDNA_clone","glutamic_acid","glutamic_acid_tRNA_primary_transcript","glutamine","glutamine_tRNA_primary_transcript","glutaminyl_tRNA","glutamyl_tRNA","glycine","glycine_tRNA_primary_transcript","glycyl_tRNA","golden_path","golden_path_fragment","group_1_intron_homing_endonuclease_target_region","group_IIA_intron","group_IIB_intron","group_IIC_intron","group_III_intron","group_II_intron","group_I_intron","guide_RNA","guide_RNA_region","hAT_TIR_transposon","hammerhead_ribozyme","haplotype_block","helitron","helix_turn_helix","heptamer_of_recombination_feature_of_vertebrate_immune_system_gene","heritable_phenotypic_marker","high_identity_region","histidine","histidine_tRNA_primary_transcript","histidyl_tRNA","histone_2AZ_acetylation_site","histone_2A_acetylation_site","histone_2B_acetylation_site","histone_3_acetylation_site","histone_4_acetylation_site","histone_acetylation_site","histone_acylation_region","histone_binding_site","histone_methylation_site","histone_modification","histone_ubiqitination_site","homing_endonuclease_binding_site","homol_D_box","homol_E_box","homologous_chromosome_recognition_and_pairing_locus","homologous_region","hpRNA","hpRNA_gene","hydrophobic_region_of_peptide","hydroxywybutosine","iDNA","i_motif","immature_peptide_region","immunoglobulin_gene","immunoglobulin_pseudogene","immunoglobulin_region","imprinting_control_region","indel_artifact","inducible_promoter","inert_DNA_spacer","inosine","insertion","insertion_artifact","insertion_breakpoint","insertion_sequence","insertion_site","insulator","insulator_binding_site","integrated_mobile_genetic_element","integrated_plasmid","integration_excision_site","integron","intein","intein_encoding_region","interband","interchromosomal_breakpoint","interchromosomal_translocation","intergenic_region","interior_coding_exon","interior_exon","interior_intron","intermediate_element","internal_Shine_Dalgarno_sequence","internal_UTR","internal_eliminated_sequence","internal_guide_sequence","internal_ribosome_entry_site","internal_transcribed_spacer_region","intrachromosomal_breakpoint","intrachromosomal_translocation","intramembrane_polypeptide_region","intrinsically_unstructured_polypeptide_region","introgressed_chromosome_region","intron","intron_base_5","intron_domain","intronic_regulatory_region","intronic_splice_enhancer","intronic_splicing_silencer","invalidated_cDNA_clone","inversion","inversion_breakpoint","inversion_cum_translocation","inversion_site","inversion_site_part","inverted_intrachromosomal_transposition","inverted_repeat","inverted_tandem_duplication","iron_repressed_GATA_element","iron_responsive_element","isoleucine","isoleucine_tRNA_primary_transcript","isoleucyl_tRNA","isomiR","isowyosine","junction","kinetoplast_gene","knob","kozak_sequence","lambda_vector","lariat_intron","late_origin_of_replication","left_handed_peptide_helix","leucine","leucine_tRNA_primary_transcript","leucoplast_chromosome","leucoplast_gene","leucyl_tRNA","ligand_binding_site","ligation_based_read","lincRNA","lincRNA_gene","linear_double_stranded_DNA_chromosome","linear_double_stranded_RNA_chromosome","linear_plasmid","linear_single_stranded_DNA_chromosome","linear_single_stranded_RNA_chromosome","linkage_group","lipoprotein_signal_peptide","lncRNA","lncRNA_gene","lncRNA_primary_transcript","lncRNA_with_retained_intron","loR","locus_control_region","long_terminal_repeat","long_terminal_repeat_transcript","loop","low_complexity_region","loxP_site","lysidine","lysine","lysine_tRNA_primary_transcript","lysosomal_localization_signal","lysyl_tRNA","mRNA","mRNA_contig","mRNA_read","mRNA_recoded_by_codon_redefinition","mRNA_recoded_by_translational_bypass","mRNA_region","mRNA_with_frameshift","mRNA_with_minus_1_frameshift","mRNA_with_minus_2_frameshift","mRNA_with_plus_1_frameshift","mRNA_with_plus_2_frameshift","macronuclear_chromosome","macronucleus_destined_segment","major_TSS","mannosyl_queuosine","match","match_part","maternal_uniparental_disomy","maternally_imprinted_gene","mathematically_defined_repeat","mating_type_M_box","mating_type_region","mating_type_region_motif","mating_type_region_replication_fork_barrier","matrix_attachment_site","mature_protein_region","mature_protein_region_of_CDS","mature_transcript","mature_transcript_region","maxicircle","maxicircle_gene","meiotic_recombination_region","membrane_peptide_loop","membrane_structure","metabolic_island","metal_binding_site","methionine","methionine_tRNA_primary_transcript","methionyl_tRNA","methylated_DNA_base_feature","methylated_adenine","methylated_cytosine","methylation_guide_snoRNA","methylation_guide_snoRNA_gene","methylation_guide_snoRNA_primary_transcript","methylinosine","methylwyosine","miRNA","miRNA_antiguide","miRNA_gene","miRNA_loop","miRNA_primary_transcript","miRNA_primary_transcript_region","miRNA_stem","miRNA_target_site","miR_encoding_Y_RNA_primary_transcript","miR_encoding_lncRNA_primary_transcript","miR_encoding_shRNA_primary_transcript","miR_encoding_snoRNA_primary_transcript","miR_encoding_tRNA_primary_transcript","miR_encoding_vaultRNA_primary_transcript","miRtron","microarray_oligo","micronuclear_chromosome","microsatellite","mini_exon_donor_RNA","mini_gene","minicircle","minicircle_gene","minisatellite","minor_TSS","minus_10_signal","minus_12_signal","minus_1_translational_frameshift","minus_24_signal","minus_2_translational_frameshift","minus_35_signal","mitochondrial_DNA_read","mitochondrial_D_loop","mitochondrial_chromosome","mitochondrial_contig","mitochondrial_control_region","mitochondrial_supercontig","mitochondrial_targeting_signal","mitotic_recombination_region","moR","mobile_element_deletion","mobile_element_insertion","mobile_genetic_element","mobile_intron","modified_DNA_base","modified_L_alanine","modified_L_arginine","modified_L_asparagine","modified_L_aspartic_acid","modified_L_cysteine","modified_L_glutamic_acid","modified_L_glutamine","modified_L_histidine","modified_L_isoleucine","modified_L_leucine","modified_L_lysine","modified_L_methionine","modified_L_phenylalanine","modified_L_proline","modified_L_selenocysteine","modified_L_serine","modified_L_threonine","modified_L_tryptophan","modified_L_tyrosine","modified_L_valine","modified_RNA_base_feature","modified_adenine","modified_adenosine","modified_amino_acid_feature","modified_cytidine","modified_cytosine","modified_glycine","modified_guanine","modified_guanosine","modified_inosine","modified_uridine","molecular_contact_region","monocistronic_mRNA","monocistronic_primary_transcript","monocistronic_transcript","monomeric_repeat","morpholino_oligo","mt_LSU_rRNA","mt_LSU_rRNA_gene","mt_SSU_rRNA","mt_SSU_rRNA_gene","mt_gene","mt_rRNA","mt_rRNA_gene","mt_tRNA","multiplexing_sequence_identifier","mutated_variant_site","mutational_hotspot","n_terminal_region","natural_plasmid","natural_transposable_element","natural_variant_site","ncRNA","ncRNA_gene","nc_conserved_region","nc_primary_transcript","negative_sense_ssRNA_viral_sequence","negatively_autoregulated_gene","nested_repeat","nested_tandem_repeat","nested_transposon","no_output","no_sequence_alteration","non_AUG_initiated_uORF","non_LTR_retrotransposon","non_LTR_retrotransposon_polymeric_tract","non_adjacent_residues","non_allelic_homologous_recombination_region","non_canonical_five_prime_splice_site","non_canonical_start_codon","non_canonical_three_prime_splice_site","non_complimentary_stem","non_cytoplasmic_polypeptide_region","non_processed_pseudogene","non_terminal_residue","non_transcribed_region","nonamer_of_recombination_feature_of_vertebrate_immune_system_gene","noncoding_exon","noncoding_region_of_exon","novel_sequence_insertion","nuclear_chromosome","nuclear_export_signal","nuclear_gene","nuclear_localization_signal","nuclear_mt_pseudogene","nuclear_rim_localization_signal","nuclease_binding_site","nuclease_hypersensitive_site","nuclease_sensitive_site","nucleomorph_gene","nucleomorphic_chromosome","nucleotide_binding_site","nucleotide_cleavage_site","nucleotide_match","nucleotide_motif","nucleotide_to_protein_binding_site","ochre_stop_codon","octamer_motif","oligo","oligo_U_tail","one_methyl_three_three_amino_three_carboxypropyl_pseudouridine","one_methyladenosine","one_methylguanosine","one_methylinosine","one_methylpseudouridine","one_two_prime_O_dimethyladenosine","one_two_prime_O_dimethylguanosine","one_two_prime_O_dimethylinosine","opal_stop_codon","open_chromatin_region","operator","operon","oriC","oriT","oriV","origin_of_replication","orphan_CDS","orthologous_region","outron","overlapping_EST_set","overlapping_feature_set","paired_end_fragment","parallel_beta_strand","paralogous_region","partial_genomic_sequence_assembly","partially_processed_cDNA_clone","paternal_uniparental_disomy","paternally_imprinted_gene","pathogenic_island","peptide_coil","peptide_helix","peptide_localization_signal","peroxywybutosine","phage_sequence","phagemid","phenylalanine","phenylalanine_tRNA_primary_transcript","phenylalanyl_tRNA","pheromone_response_element","phosphorylation_site","piRNA","piRNA_gene","pi_helix","piggyBac_TIR_transposon","plasmid","plasmid_gene","plasmid_vector","plastid_LSU_rRNA","plastid_LSU_rRNA_gene","plastid_SSU_rRNA","plastid_SSU_rRNA_gene","plastid_gene","plastid_rRNA","plastid_rRNA_gene","plus_1_translational_frameshift","plus_2_translational_frameshift","point_centromere","point_mutation","polinton","polyA_primed_cDNA_clone","polyA_sequence","polyA_signal_sequence","polyA_site","polyA_site_cluster","polyadenylated_mRNA","polycistronic_mRNA","polycistronic_primary_transcript","polycistronic_transcript","polymerase_synthesis_read","polymorphic_pseudogene","polymorphic_pseudogene_processed_transcript","polymorphic_pseudogene_with_retained_intron","polypeptide","polypeptide_DNA_contact","polypeptide_binding_motif","polypeptide_calcium_ion_contact_site","polypeptide_catalytic_motif","polypeptide_cobalt_ion_contact_site","polypeptide_conserved_motif","polypeptide_conserved_region","polypeptide_copper_ion_contact_site","polypeptide_domain","polypeptide_iron_ion_contact_site","polypeptide_ligand_contact","polypeptide_magnesium_ion_contact_site","polypeptide_manganese_ion_contact_site","polypeptide_metal_contact","polypeptide_molybdenum_ion_contact_site","polypeptide_motif","polypeptide_nest_left_right_motif","polypeptide_nest_motif","polypeptide_nest_right_left_motif","polypeptide_nickel_ion_contact_site","polypeptide_region","polypeptide_repeat","polypeptide_secondary_structure","polypeptide_sequencing_information","polypeptide_structural_motif","polypeptide_structural_region","polypeptide_tungsten_ion_contact_site","polypeptide_turn_motif","polypeptide_variation_site","polypeptide_zinc_ion_contact_site","polypyrimidine_tract","positional_candidate_gene","positive_sense_ssRNA_viral_sequence","positively_autoregulated_gene","possible_assembly_error","possible_base_call_error","post_translationally_modified_region","post_translationally_regulated_gene","pre_edited_mRNA","pre_edited_region","pre_miRNA","predicted_gene","predicted_transcript","presence_absence_variation","priRNA","primary_transcript","primary_transcript_region","primer","primer_binding_site","primer_match","probe","processed_pseudogene","processed_pseudogenic_rRNA","processed_pseudogenic_tRNA","processed_transcript","prokaryotic_promoter","proline","proline_tRNA_primary_transcript","prolyl_tRNA","promoter","promoter_element","promoter_flanking_region","promoter_targeting_sequence","promoter_trap_construct","propeptide","propeptide_cleavage_site","propeptide_region_of_CDS","prophage","proplastid_gene","protease_site","protein_binding_site","protein_coding_gene","protein_coding_primary_transcript","protein_hmm_match","protein_match","protein_protein_contact","protein_stability_element","proviral_gene","proviral_region","proximal_promoter_element","pseudogene","pseudogene_by_unequal_crossing_over","pseudogene_processed_transcript","pseudogenic_CDS","pseudogenic_exon","pseudogenic_gene_segment","pseudogenic_rRNA","pseudogenic_region","pseudogenic_tRNA","pseudogenic_transcript","pseudogenic_transcript_with_retained_intron","pseudoknot","pseudouridine","pseudouridylation_guide_snoRNA","pseudouridylation_guide_snoRNA_gene","pumilio_response_element","purine_to_pyrimidine_transversion","purine_transition","pyrimidine_to_purine_transversion","pyrimidine_transition","pyrosequenced_read","pyrrolysine","pyrrolysine_tRNA_primary_transcript","pyrrolysyl_tRNA","queuosine","rDNA_intergenic_spacer_element","rDNA_replication_fork_barrier","rRNA","rRNA_21S_gene","rRNA_cleavage_RNA","rRNA_cleavage_snoRNA_primary_transcript","rRNA_gene","rRNA_large_subunit_primary_transcript","rRNA_primary_transcript","rRNA_primary_transcript_region","rRNA_small_subunit_primary_transcript","rare_fragile_site","rasiRNA","read","read_pair","reading_frame","reagent","rearrangement_region","reciprocal_chromosomal_translocation","recoded_codon","recoded_mRNA","recoding_pseudoknot","recoding_stimulatory_region","recombination_enhancer","recombination_feature","recombination_feature_of_rearranged_gene","recombination_hotspot","recombination_regulatory_region","recombination_signal_sequence","recombinationally_inverted_gene","recombinationally_rearranged_gene","recombinationally_rearranged_vertebrate_immune_system_gene","recursive_splice_site","ref_miRNA","region","regional_centromere","regional_centromere_central_core","regional_centromere_inner_repeat_region","regional_centromere_outer_repeat_region","regional_centromere_outer_repeat_transcript","regulatory_promoter_element","regulatory_region","regulon","remark","repeat_component","repeat_fragment","repeat_instability_region","repeat_region","repeat_unit","replication_regulatory_region","replication_start_site","replicon","rescue_gene","rescue_mini_gene","rescue_region","resolution_site","response_element","restriction_enzyme_assembly_scar","restriction_enzyme_binding_site","restriction_enzyme_cleavage_junction","restriction_enzyme_five_prime_single_strand_overhang","restriction_enzyme_recognition_site","restriction_enzyme_region","restriction_enzyme_single_strand_overhang","restriction_enzyme_three_prime_single_strand_overhang","restriction_fragment","retinoic_acid_responsive_element","retrogene","retron","retrotransposon","reverse_Hoogsteen_base_pair","reverse_primer","rho_dependent_bacterial_terminator","rho_independent_bacterial_terminator","ribonuclease_site","ribosome_entry_site","riboswitch","ribothymidine","ribozyme","ribozyme_gene","right_handed_peptide_helix","sORF","sarcin_like_RNA_motif","satellite_DNA","sbRNA","sbRNA_gene","scRNA","scRNA_gene","scRNA_primary_transcript","scaRNA","scaRNA_gene","schellmann_loop","schellmann_loop_seven","schellmann_loop_six","selection_marker","selenocysteine","selenocysteine_tRNA_primary_transcript","selenocysteinyl_tRNA","self_cleaving_ribozyme","sense_intronic_ncRNA","sense_intronic_ncRNA_gene","sense_overlap_ncRNA","sense_overlap_ncRNA_gene","sequence_alteration","sequence_alteration_artifact","sequence_assembly","sequence_comparison","sequence_conflict","sequence_difference","sequence_feature","sequence_length_alteration","sequence_motif","sequence_rearrangement_feature","sequence_secondary_structure","sequence_uncertainty","sequencing_primer","serine","serine_tRNA_primary_transcript","serine_threonine_motif","serine_threonine_staple_motif","serine_threonine_turn","seryl_tRNA","seven_aminomethyl_seven_deazaguanosine","seven_cyano_seven_deazaguanosine","seven_deazaguanosine","seven_methylguanine","seven_methylguanosine","sgRNA","shRNA","shRNA_primary_transcript","shadow_enhancer","short_tandem_repeat_variation","siRNA","signal_anchor","signal_peptide","signal_peptide_region_of_CDS","signature","silenced_gene","silencer","silent_mating_type_cassette_array","simple_operon","simple_regulon","simple_sequence_length_variation","single_strand_restriction_enzyme_cleavage_site","single_stranded_DNA_chromosome","single_stranded_RNA_chromosome","sisRNA","site_specific_recombination_target_region","smFISH_probe","small_regulatory_ncRNA","snRNA","snRNA_gene","snRNA_primary_transcript","sncRNA","sncRNA_gene","snoRNA","snoRNA_gene","snoRNA_primary_transcript","solo_LTR","sonicate_fragment","specific_recombination_site","splice_enhancer","splice_junction","splice_region","splice_site","spliced_leader_RNA","spliceosomal_intron","spliceosomal_intron_region","splicing_regulatory_region","spot_42_RNA","spurious_protein","ss_RNA_viral_sequence","ss_oligo","st_turn_left_handed_type_one","st_turn_left_handed_type_two","st_turn_right_handed_type_one","st_turn_right_handed_type_two","start_codon","stem","stem_loop","stem_loop_region","sterol_regulatory_element","sticky_end_restriction_enzyme_cleavage_site","stop_codon","stop_codon_read_through","stop_codon_redefined_as_pyrrolysine","stop_codon_redefined_as_selenocysteine","stop_codon_signal","structural_alteration","substitution","substitution_artifact","subtelomere","sugar_edge_base_pair","supercontig","symbiosis_island","symmetric_RNA_internal_loop","syntenic_region","synthetic_oligo","tRNA","tRNA_SINE_retrotransposon","tRNA_gene","tRNA_intron","tRNA_primary_transcript","tRNA_region","tag","tandem_duplication","tandem_repeat","target_site_duplication","targeting_vector","tasiRNA","tasiRNA_primary_transcript","teb1_recognition_motif","telomerase_RNA","telomerase_RNA_gene","telomere","telomeric_D_loop","telomeric_repeat","telomeric_transcript","template_region","terminal_inverted_repeat","terminal_inverted_repeat_element","terminal_repeat","terminator","terminator_of_type_2_RNApol_III_promoter","tetraloop","tetranucleotide_repeat_microsatellite_feature","three_methylcytidine","three_methylpseudouridine","three_methyluridine","three_prime_D_heptamer","three_prime_D_nonamer","three_prime_D_recombination_signal_sequence","three_prime_D_spacer","three_prime_EST","three_prime_LTR","three_prime_LTR_component","three_prime_RACE_clone","three_prime_RST","three_prime_UST","three_prime_UTR","three_prime_UTR_intron","three_prime_cis_splice_site","three_prime_clip","three_prime_coding_exon","three_prime_coding_exon_coding_region","three_prime_coding_exon_noncoding_region","three_prime_flanking_region","three_prime_intron","three_prime_noncoding_exon","three_prime_overlapping_ncrna","three_prime_recoding_site","three_prime_repeat_recoding_signal","three_prime_restriction_enzyme_junction","three_prime_stem_loop_structure","three_prime_sticky_end_restriction_enzyme_cleavage_site","three_prime_terminal_inverted_repeat","three_ten_helix","three_three_amino_three_carboxypropyl_uridine","three_two_prime_O_dimethyluridine","threonine","threonine_tRNA_primary_transcript","threonyl_tRNA","tiling_path","tiling_path_clone","tiling_path_fragment","tmRNA","tmRNA_acceptor_piece","tmRNA_coding_piece","tmRNA_gene","tmRNA_primary_transcript","tmRNA_region","tnaORF","topologically_associated_domain","topologically_associated_domain_boundary","topologically_defined_region","trans_splice_acceptor_site","trans_splice_donor_site","trans_splice_junction","trans_splice_site","trans_spliced_mRNA","trans_spliced_transcript","transcribed_cluster","transcribed_fragment","transcribed_processed_pseudogene","transcribed_spacer_region","transcribed_unitary_pseudogene","transcribed_unprocessed_pseudogene","transcript","transcript_bound_by_nucleic_acid","transcript_bound_by_protein","transcript_region","transcript_with_translational_frameshift","transcription_end_site","transcription_factor_regulatory_site","transcription_pause_site","transcription_start_cluster","transcription_termination_signal","transcription_unit","transcriptional_cis_regulatory_region","transgene","transgenic_insertion","transgenic_transposable_element","transit_peptide","transit_peptide_region_of_CDS","transition","translated_nucleotide_match","translated_processed_pseudogene","translated_unprocessed_pseudogene","translation_regulatory_region","translational_frameshift","translationally_regulated_gene","translocation","translocation_breakpoint","translocation_element","transmembrane_helix","transmembrane_polypeptide_region","transposable_element","transposable_element_CDS","transposable_element_flanking_region","transposable_element_gene","transposable_element_insertion_site","transposable_element_pseudogene","transposon_fragment","transversion","trinucleotide_repeat_microsatellite_feature","tryptophan","tryptophan_tRNA_primary_transcript","tryptophanyl_tRNA","twintron","two_methyladenosine","two_methylthio_N6_cis_hydroxyisopentenyl_adenosine","two_methylthio_N6_hydroxynorvalyl_carbamoyladenosine","two_methylthio_N6_isopentenyladenosine","two_methylthio_N6_methyladenosine","two_methylthio_N6_threonyl_carbamoyladenosine","two_prime_O_methyladenosine","two_prime_O_methylcytidine","two_prime_O_methylguanosine","two_prime_O_methylinosine","two_prime_O_methylpseudouridine","two_prime_O_methyluridine","two_prime_O_ribosyladenosine_phosphate","two_prime_O_ribosylguanosine_phosphate","two_thio_two_prime_O_methyluridine","two_thiocytidine","two_thiouridine","tyrosine","tyrosine_tRNA_primary_transcript","tyrosyl_tRNA","uORF","ultracontig","unassigned_supercontig","unconfirmed_transcript","undermodified_hydroxywybutosine","unedited_region","unigene_cluster","unit_of_gene_expression","unitary_pseudogene","unitary_pseudogenic_rRNA","unitary_pseudogenic_tRNA","unprocessed_pseudogenic_rRNA","unprocessed_pseudogenic_tRNA","unspecified_indel","untranslated_region_polycistronic_mRNA","upstream_AUG_codon","uridine_five_oxyacetic_acid","uridine_five_oxyacetic_acid_methyl_ester","vacuolar_sorting_signal","validated_cDNA_clone","valine","valine_tRNA_primary_transcript","valyl_tRNA","vaultRNA_primary_transcript","vault_RNA","vault_RNA_gene","vector_replicon","vertebrate_immune_system_gene","vertebrate_immune_system_gene_recombination_feature","vertebrate_immune_system_gene_recombination_signal_feature","vertebrate_immune_system_gene_recombination_spacer","vertebrate_immune_system_pseudogene","vertebrate_immunoglobulin_T_cell_receptor_gene_cluster","vertebrate_immunoglobulin_T_cell_receptor_rearranged_gene_cluster","vertebrate_immunoglobulin_T_cell_receptor_rearranged_segment","vertebrate_immunoglobulin_T_cell_receptor_segment","viral_promoter","viral_sequence","virtual_sequence","wild_type_rescue_gene","wobble_base_pair","wybutosine","wyosine","zinc_finger_binding_site","zinc_repressed_element"],Xt=function(e){function t(){var e;R(this,t);for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return D(e=T(this,t,[].concat(r)),"name","Core"),e}return M(t,e),I(t,[{key:"frontendPreValidate",value:(r=k(U().m((function e(t){var n,r,o;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:if(!("oldType"in(i=t))||!("newType"in i)){e.n=7;break}n=j(t.changes),e.p=1,n.s();case 2:if((r=n.n()).done){e.n=4;break}if(Yt.includes((o=r.value).newType)){e.n=3;break}return e.a(2,{validationName:this.name,error:{message:'"'.concat(o.newType,'" is not a valid SO sequence_feature term')}});case 3:e.n=2;break;case 4:e.n=6;break;case 5:e.p=5,n.e(e.v);case 6:return e.p=6,n.f(),e.f(6);case 7:return e.a(2,{validationName:this.name})}var i}),e,this,[[1,5,6,7]])}))),function(e){return r.apply(this,arguments)})},{key:"possibleValues",value:(n=k(U().m((function e(t){return U().w((function(e){for(;;)switch(e.n){case 0:if("type"!==t){e.n=1;break}return e.a(2,Yt);case 1:return e.a(2)}}),e)}))),function(e){return n.apply(this,arguments)})}]);var n,r}(Vt),Zt=function(e){function t(){var e;R(this,t);for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return D(e=T(this,t,[].concat(r)),"name","ParentChildValidation"),e}return M(t,e),I(t,[{key:"backendPostValidate",value:(r=k(U().m((function e(t,n){var r,o;return U().w((function(e){for(;;)switch(e.n){case 0:if(r=n.featureModel,o=n.session,!Rt(t)&&!It(t)){e.n=1;break}return e.a(2,this.validateParentChildRelationships(t,{session:o,featureModel:r}));case 1:return e.a(2,{validationName:this.name})}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"validateParentChildRelationships",value:(n=k(U().m((function e(t,n){var r,o,i,a,s,l,c,u,d;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:r=n.featureModel,o=n.session,i=[],a=j(t.changes),e.p=1,l=U().m((function e(){var t,n,a;return U().w((function(e){for(;;)switch(e.n){case 0:return t=s.value.featureId,e.n=1,r.findOne({allIds:t}).session(o).exec();case 1:if(n=e.v){e.n=2;break}throw a="ERROR: The following featureId was not found in database ='".concat(t,"'"),new Error(a);case 2:i.some((function(e){return e._id===n._id}))||i.push(n);case 3:return e.a(2)}}),e)})),a.s();case 2:if((s=a.n()).done){e.n=4;break}return e.d($(l()),3);case 3:e.n=2;break;case 4:e.n=6;break;case 5:e.p=5,a.e(e.v);case 6:return e.p=6,a.f(),e.f(6);case 7:c=0,u=i;case 8:if(!(c<u.length)){e.n=12;break}d=u[c],e.p=9,this.checkChildFeatureBoundaries(d),e.n=11;break;case 10:return e.p=10,e.a(2,{validationName:this.name,error:{message:String(e.v)}});case 11:c++,e.n=8;break;case 12:return e.a(2,{validationName:this.name})}}),e,this,[[9,10],[1,5,6,7]])}))),function(e,t){return n.apply(this,arguments)})},{key:"checkChildFeatureBoundaries",value:function(e){if(e.children){var t,n=j(e.children||new Map);try{for(n.s();!(t=n.n()).done;){var r=G(t.value,2)[1];if(null!==e.min&&null!==e.max&&null!==r.min&&null!==r.max&&(r.max>e.max||r.min<e.min))throw new Error("Feature ".concat(Ft(r)," exceeds the bounds of its parent, ").concat(Ft(e)));this.checkChildFeatureBoundaries(r)}}catch(e){n.e(e)}finally{n.f()}}}}]);var n,r}(Vt);function Qt(e){this.message=e}(Qt.prototype=new Error).name="InvalidCharacterError";var en,tn,nn="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new Qt("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,r,o=0,i=0,a="";r=t.charAt(i++);~r&&(n=o%4?64*n+r:r,o++%4)?a+=String.fromCharCode(255&n>>(-2*o&6)):0)r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(r);return a};function rn(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(nn(e).replace(/(.)/g,(function(e,t){var n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(t)}catch(e){return nn(t)}}function on(e){this.message=e}function an(e,t){if("string"!=typeof e)throw new on("Invalid token specified");var n=!0===(t=t||{}).header?0:1;try{return JSON.parse(rn(e.split(".")[n]))}catch(e){throw new on("Invalid token specified: "+e.message)}}function sn(e){var t="string"==typeof e?an(e):e;return"".concat(t.id,"-").concat(t.iat)}function ln(e){return an(e)}function cn(e){var t,n,r=null===(t=e.attributes)||void 0===t||null===(t=t.gff_id)||void 0===t?void 0:t.join(", ");if(r)return"".concat(r," (_id: ").concat(e._id,")");var o=null===(n=e.attributes)||void 0===n||null===(n=n.gff_name)||void 0===n?void 0:n.join(", ");return o?"".concat(o," (_id: ").concat(e._id,")"):"_id: ".concat(e._id)}(on.prototype=new Error).name="InvalidTokenError",function(e){e[e.TAG=0]="TAG",e[e.TAA=1]="TAA",e[e.TGA=2]="TGA"}(en||(en={})),function(e){e[e.ATG=0]="ATG"}(tn||(tn={}));var un,dn="CDSCheck";!function(e){e[e.InternalStopCodon=0]="InternalStopCodon",e[e.MissingStartCodon=1]="MissingStartCodon",e[e.MissingStopCodon=2]="MissingStopCodon"}(un||(un={}));var fn={G:"C",A:"T",T:"A",C:"G",R:"Y",Y:"R",M:"K",K:"M",S:"S",W:"W",H:"D",B:"V",V:"B",D:"H",N:"N"};function hn(e){var t,n=[],r=j(e);try{for(r.s();!(t=r.n()).done;){var o=t.value,i=fn[o.toUpperCase()];if(void 0===i)throw new TypeError('Cannot complement nucleotide: "'.concat(o,'"'));o===o.toLowerCase()?n.push(i.toLowerCase()):n.push(i)}}catch(e){r.e(e)}finally{r.f()}return n.reverse().join("")}function pn(e,t,n){return gn.apply(this,arguments)}function gn(){return(gn=k(U().m((function e(t,n,r){var o;return U().w((function(e){for(;;)switch(e.n){case 0:return e.n=1,Promise.all(t.map((function(e){return r(e.min,e.max)})));case 1:return o=e.v.join(""),-1===n&&(o=hn(o)),e.a(2,o)}}),e)})))).apply(this,arguments)}function mn(e){for(var t=[],n=0;n<=e.length-3;n+=3)t.push(e.slice(n,n+3));return t}function yn(e,t,n){return-1===n?e>t:e<t}function _n(e,t,n){for(var r,o,i=e.toSorted(-1===t?function(e,t){return e.min<t.min?1:-1}:function(e,t){return e.min<t.min?-1:1}),a=0,s=0;s<i.length;s++)for(var l=i[s],c=l.phase,u=-1===t?l.min:l.max,d=-1===t?l.max-c:l.min+c;yn(d,u,t);d=-1===t?d-3:d+3){if(r=d,o=-1===t?r-3:r+3,-1===t&&o<l.min?o=i[s+1].max-i[s+1].phase:o>l.max&&(o=i[s+1].min+i[s+1].phase),a===n)return[r,o].sort((function(e,t){return e-t}));a++}}function vn(e,t){return bn.apply(this,arguments)}function bn(){return(bn=k(U().m((function e(t,n){var r,o,i,a,s,l,c,u,d,f,h,p,g,m,y,_,v,b,x,w,S,C,A,k,N,T,R,E,I,D,O,F,M,L;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:if(r=[],o=t._id,i=t.max,a=t.min,s=t.refSeq,l=t.strand,c=xn(t)){e.n=1;break}return e.a(2,r);case 1:u=[o],d=j(c),e.p=2,d.s();case 3:if((f=d.n()).done){e.n=13;break}return y=f.value,e.n=4,pn(y,l,n);case 4:v=mn(_=e.v),b=-1===l?null!==(h=null===(p=y.at(0))||void 0===p?void 0:p.min)&&void 0!==h?h:a:null!==(g=null===(m=y.at(-1))||void 0===m?void 0:m.max)&&void 0!==g?g:i,_.length%3==0?((x=v.at(0))&&!(x.toUpperCase()in tn)&&(k=-1===l?null!==(w=null===(S=y.at(-1))||void 0===S?void 0:S.max)&&void 0!==w?w:i:null!==(C=null===(A=y.at(0))||void 0===A?void 0:A.min)&&void 0!==C?C:a,k=-1===l?k-3:k,r.push({_id:(new at).toHexString(),name:dn,cause:un[un.MissingStartCodon],ids:u,refSeq:s,start:k,end:k,message:'Unexpected start codon "'.concat(x,'" in feature "').concat(cn(t),'": ')})),(N=v.at(-1))&&!(N.toUpperCase()in en)&&r.push({_id:(new at).toHexString(),name:dn,cause:un[un.MissingStopCodon],ids:u,refSeq:s,start:b,end:b,message:'Missing stop codon in feature "'.concat(cn(t),'"')})):r.push({_id:(new at).toHexString(),name:dn,cause:un[un.MissingStopCodon],ids:u,refSeq:s,start:b,end:b,message:'Missing stop codon in feature "'.concat(cn(t),'"')}),T=j(v.entries()),e.p=5,T.s();case 6:if((R=T.n()).done){e.n=9;break}if(E=G(R.value,2),D=E[1],(I=E[0])!==v.length-1){e.n=7;break}return e.a(3,9);case 7:(O=_n(y,l,I))&&D.toUpperCase()in en&&(F=G(O,2),M=F[0],L=F[1],r.push({_id:(new at).toHexString(),name:dn,cause:un[un.InternalStopCodon],ids:u,refSeq:s,start:M,end:L,message:'Internal stop codon in feature "'.concat(cn(t),'"')}));case 8:e.n=6;break;case 9:e.n=11;break;case 10:e.p=10,T.e(e.v);case 11:return e.p=11,T.f(),e.f(11);case 12:e.n=3;break;case 13:e.n=15;break;case 14:e.p=14,d.e(e.v);case 15:return e.p=15,d.f(),e.f(15);case 16:return e.a(2,r)}}),e,null,[[5,10,11,12],[2,14,15,16]])})))).apply(this,arguments)}function xn(e){if("mRNA"===e.type){var t=e.children,n=e.strand;if(t){var r=Object.values(t).filter((function(e){return"CDS"===e.type}));if(0!==r.length){var i,a=[],s=j(r);try{var l=function(){for(var e=i.value,r=e.max,s=e.min,l=[],c=0,u=Object.values(t);c<u.length;c++){var d=u[c];if("exon"===d.type){var f=G(o.intersection2(s,r,d.min,d.max),2),h=f[0],p=f[1];void 0!==h&&void 0!==p&&l.push({min:h,max:p})}}l.sort((function(e,t){return e.min-t.min})),-1===n&&l.reverse();var g=0,m=l.map((function(e){var t=g;return g=(3-(e.max-e.min-t+3)%3)%3,B(B({},e),{},{phase:t})}));m.sort((function(e,t){return e.min<t.min?-1:1})),a.push(m)};for(s.s();!(i=s.n()).done;)l()}catch(e){s.e(e)}finally{s.f()}return a.length>1&&a.sort((function(e,t){return e[0].min<t[0].min?-1:1})),a}}}}var wn,Sn=function(e){function t(){var e;R(this,t);for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return D(e=T(this,t,[].concat(r)),"name",dn),D(e,"causes",Object.values(un).filter((function(e){return Number.isNaN(Number(e))}))),D(e,"version",1),D(e,"isDefault",!0),e}return M(t,e),I(t,[{key:"checkFeature",value:(n=k(U().m((function e(t,n){var r,o,i,a,s,l,c;return U().w((function(e){for(;;)switch(e.n){case 0:if("mRNA"!==t.type){e.n=1;break}return e.a(2,vn(t,n));case 1:if(t.children){e.n=2;break}return e.a(2,[]);case 2:r=[],o=0,i=Object.values(t.children);case 3:if(!(o<i.length)){e.n=6;break}return a=i[o],s=r.push,l=r,c=W,e.n=4,this.checkFeature(a,n);case 4:s.apply.call(s,l,c(e.v));case 5:o++,e.n=3;break;case 6:return e.a(2,r)}}),e,this)}))),function(e,t){return n.apply(this,arguments)})}]);var n}(dt);!function(e){e[e.NonCanonicalSpliceSiteAtFivePrime=0]="NonCanonicalSpliceSiteAtFivePrime",e[e.NonCanonicalSpliceSiteAtThreePrime=1]="NonCanonicalSpliceSiteAtThreePrime"}(wn||(wn={}));var Cn="TranscriptCheck";function An(e,t){return kn.apply(this,arguments)}function kn(){return kn=k(U().m((function e(t,n){var r,i,a,s,l,c,u,d,f,h,p,g;return U().w((function(e){for(;;)switch(e.n){case 0:if(t.children){e.n=1;break}return e.a(2,[]);case 1:for(r=[],i=0,a=Object.entries(t.children);i<a.length;i++)s=G(a[i],2),"exon"===(l=s[1]).type&&r.push(l);if(!(r.length<2)){e.n=2;break}return e.a(2,[]);case 2:r.sort((function(e,t){return e.min<t.min?-1:1})),c=[],u=0;case 3:if(!(u<r.length-1)){e.n=7;break}return d=r[u].max,f=r[u+1].min,-1===t.strand?(f=(h=[d,f])[0],d=h[1],d-=2):f-=2,e.n=4,n(d,d+2);case 4:return p=e.v,e.n=5,n(f,f+2);case 5:g=e.v,-1===t.strand&&(g=o.revcom(g),p=o.revcom(p)),c.push({fivePrimeSeq:p,fivePrimeMin:d,threePrimeSeq:g,threePrimeMin:f});case 6:u++,e.n=3;break;case 7:return e.a(2,c)}}),e)}))),kn.apply(this,arguments)}function Nn(e,t){return Tn.apply(this,arguments)}function Tn(){return(Tn=k(U().m((function e(t,n){var r,o,i,a,s,l;return U().w((function(e){for(;;)switch(e.n){case 0:return r=[],o=new Set(["GT"]),i=new Set(["AG"]),e.n=1,An(t,n);case 1:a=j(e.v);try{for(a.s();!(s=a.n()).done;)o.has((l=s.value).fivePrimeSeq.toUpperCase())||r.push({_id:(new at).toHexString(),name:Cn,cause:wn[wn.NonCanonicalSpliceSiteAtFivePrime],ids:[t._id],refSeq:t.refSeq,start:l.fivePrimeMin,end:l.fivePrimeMin+2,message:'Unexpected 5′ splice site in "'.concat(cn(t),'". Expected: ').concat(W(o).join("|"),", got: ").concat(l.fivePrimeSeq)}),i.has(l.threePrimeSeq.toUpperCase())||r.push({_id:(new at).toHexString(),name:Cn,cause:wn[wn.NonCanonicalSpliceSiteAtThreePrime],ids:[t._id],refSeq:t.refSeq,start:l.threePrimeMin,end:l.threePrimeMin+2,message:'Unexpected 3′ splice site in "'.concat(cn(t),'". Expected: ').concat(W(i).join("|"),", got: ").concat(l.threePrimeSeq)})}catch(e){a.e(e)}finally{a.f()}return e.a(2,r)}}),e)})))).apply(this,arguments)}var Rn=function(e){function t(){var e;R(this,t);for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return D(e=T(this,t,[].concat(r)),"name","TranscriptCheck"),D(e,"causes",Object.values(wn).filter((function(e){return Number.isNaN(Number(e))}))),D(e,"version",1),D(e,"isDefault",!0),e}return M(t,e),I(t,[{key:"checkFeature",value:(n=k(U().m((function e(t,n){var r,o,i,a,s,l,c;return U().w((function(e){for(;;)switch(e.n){case 0:if("mRNA"!==t.type&&"transcript"!==t.type&&"pseudogenic_transcript"!==t.type){e.n=1;break}return e.a(2,Nn(t,n));case 1:if(t.children){e.n=2;break}return e.a(2,[]);case 2:r=[],o=0,i=Object.values(t.children);case 3:if(!(o<i.length)){e.n=6;break}return a=i[o],s=r.push,l=r,c=W,e.n=4,this.checkFeature(a,n);case 4:s.apply.call(s,l,c(e.v));case 5:o++,e.n=3;break;case 6:return e.a(2,r)}}),e,this)}))),function(e,t){return n.apply(this,arguments)})}]);var n}(dt);function En(e,t,n){var r;return("apollo_feature_container"===e.type?Object.values(null!==(r=e.children)&&void 0!==r?r:{}):[e]).map((function(e){var n,r,o,i,a,s=JSON.parse(JSON.stringify(null!==(n=e.attributes)&&void 0!==n?n:{})),l=[],c=null!==(r=null===(o=e.attributes)||void 0===o||null===(o=o.gff_source)||void 0===o?void 0:o[0])&&void 0!==r?r:null;delete s.gff_source,t&&(s.Parent=[t]),s.gff_id?(s.ID=s.gff_id,delete s.gff_id):e.children&&(s.ID=[e._id]),s.gff_name&&(s.Name=s.gff_name,delete s.gff_name),s.gff_alias&&(s.Alias=s.gff_alias,delete s.gff_alias),s.gff_target&&(s.Target=s.gff_target,delete s.gff_target),s.gff_gap&&(s.Gap=s.gff_gap,delete s.gff_gap),s.gff_derives_from&&(s.Derives_from=s.gff_derives_from,delete s.gff_derives_from),s.gff_note&&(s.Note=s.gff_note,delete s.gff_note),s.gff_dbxref&&(s.Dbxref=s.gff_dbxref,delete s.gff_dbxref),s.gff_is_circular&&(s.Is_circular=s.gff_is_circular,delete s.gff_is_circular),s.gff_ontology_term&&(l.push.apply(l,W(s.gff_ontology_term)),delete s.gff_ontology_term),s["Gene Ontology"]&&(l.push.apply(l,W(s["Gene Ontology"])),delete s["Gene Ontology"]),s["Sequence Ontology"]&&(l.push.apply(l,W(s["Sequence Ontology"])),delete s["Sequence Ontology"]),l.length>0&&(s.Ontology_term=l);var u=null===(i=e.attributes)||void 0===i?void 0:i.gff_score,d=null;return u&&u.length>0&&(u[0]&&(d=Number(u[0]),Number.isNaN(d)&&(d=null)),delete s.gff_score),{start:e.min+1,end:e.max,seq_id:e.refSeq,source:c,type:e.type,score:d,strand:e.strand?1===e.strand?"+":"-":null,phase:null,attributes:Object.keys(s).length>0?s:null,derived_features:[],child_features:In(e,null===(a=s.ID)||void 0===a?void 0:a[0])}}))}function In(e,t,n){if(!e.children)return[];if("mRNA"===e.type){for(var r=[],i=function(e){var t;try{t=function(e){if("mRNA"!==e.type)throw new Error('Only features of type "mRNA" or equivalent can calculate CDS locations');if(!e.children)throw new Error("no CDS or exons in mRNA");var t=Object.values(e.children),n=t.filter((function(e){return"CDS"===e.type}));if(0===n.length)throw new Error("no CDS in mRNA");var r,i=[],a=j(n);try{var s=function(){for(var n=r.value,a=n.max,s=n.min,l=[],c=!1,u=[],d=0,f=t;d<f.length;d++){var h=f[d];"exon"===h.type&&u.push({min:h.min,max:h.max})}u.sort((function(e,t){return e.min-t.min}));for(var p=0,g=u;p<g.length;p++){var m=g[p],y=l.at(-1);y&&l.push({min:y.max,max:m.min,type:"intron"});var _,v=G(o.intersection2(s,a,m.min,m.max),2),b=v[0],x=v[1];_=c?1===e.strand?"threePrimeUTR":"fivePrimeUTR":1===e.strand?"fivePrimeUTR":"threePrimeUTR",void 0!==b&&void 0!==x?(c=!0,b===m.min&&x===m.max?l.push({min:b,max:x,phase:0,type:"CDS"}):b===m.min?l.push({min:b,max:x,phase:0,type:"CDS"},{min:x,max:m.max,type:_}):x===m.max?l.push({min:m.min,max:b,type:_},{min:b,max:x,phase:0,type:"CDS"}):l.push({min:m.min,max:b,type:_},{min:b,max:x,phase:0,type:"CDS"},{min:x,max:m.max,type:"fivePrimeUTR"===_?"threePrimeUTR":"fivePrimeUTR"})):l.push({min:m.min,max:m.max,type:_})}l.sort((function(e,t){return e.min-t.min})),-1===e.strand&&l.reverse();var w=0,S=l.map((function(e){if("CDS"!==e.type)return e;var t=w;return w=(3-(e.max-e.min-t+3)%3)%3,B(B({},e),{},{phase:t})}));i.push(S)};for(a.s();!(r=a.n()).done;)s()}catch(e){a.e(e)}finally{a.f()}return i}(e)}catch(e){return[]}return t.map((function(e){return e.filter((function(e){return"CDS"===e.type}))}))}(e),a=0,s=0,l=Object.values(e.children);s<l.length;s++){var c=l[s],u=En(c,t);if("CDS"===c.type){var d,f=j(i[a]);try{for(f.s();!(d=f.n()).done;){var h=d.value,p=JSON.parse(JSON.stringify(u));if(1!=p.length)throw new Error("Unexpected CDS: ".concat(JSON.stringify(p,null,2)));p[0].start=h.min+1,p[0].end=h.max,p[0].phase=h.phase.toString(),p[0].type=h.type,r.push(p)}}catch(e){f.e(e)}finally{f.f()}a++}else r.push(u)}return r}return Object.values(e.children).map((function(e){return En(e,t)}))}var jn={ID:"gff_id",Name:"gff_name",Alias:"gff_alias",Parent:"gff_parent",Target:"gff_target",Gap:"gff_gap",Derives_from:"gff_derives_from",Note:"gff_note",Dbxref:"gff_dbxref",Ontology_term:"gff_ontology_term",Is_circular:"gff_is_circular"},Dn={gff_id:"ID",gff_name:"Name",gff_alias:"Alias",gff_parent:"Parent",gff_target:"Target",gff_gap:"Gap",gff_derives_from:"Derives_from",gff_note:"Note",gff_dbxref:"Dbxref",gff_ontology_term:"Ontology_term",gff_is_circular:"Is_circular"},On={gff_score:"score",gff_source:"source"};function Fn(e,t){var n=G(e,1)[0],r=n.end,i=n.seq_id,a=n.start,s=n.strand;if(!i)throw new Error("feature does not have seq_id: ".concat(JSON.stringify(n)));if(null===a)throw new Error("feature does not have start: ".concat(JSON.stringify(n)));if(null===r)throw new Error("feature does not have end: ".concat(JSON.stringify(n)));var l=function(e){var t=e.map((function(e){return e.start})).filter((function(e){return null!==e})),n=e.map((function(e){return e.end})).filter((function(e){return null!==e}));return[Math.min.apply(Math,W(t))-1,Math.max.apply(Math,W(n))]}(e),c=G(l,2),u=c[0],d=c[1],f=function(e,t,n){var r={},i=e.filter((function(e){return e.child_features.length>0}));if(i.length>1)throw new Error("Features with multiple locations may not have children");if(e.length>1&&"CDS"!==e[0].type){var a,s=j(e);try{for(s.s();!(a=s.n()).done;){var l=Fn([a.value],t);r[l._id]=l}}catch(e){s.e(e)}finally{s.f()}return r}if(0!==i.length){var c,u=G(i,1)[0].child_features,d=[],f=[],h=[],p=new Set,g=j(u);try{for(g.s();!(c=g.n()).done;){var m=c.value;if(!p.has(m)){p.add(m);var y=G(m,1)[0];if("exon"===y.type&&f.push(m),"three_prime_UTR"!==y.type&&"five_prime_UTR"!==y.type||h.push(m),"three_prime_UTR"!==y.type&&"five_prime_UTR"!==y.type&&"intron"!==y.type&&"start_codon"!==y.type&&"stop_codon"!==y.type)if("CDS"===y.type)d.push(m);else{var _=Fn(m,t);r[_._id]=_}}}}catch(e){g.e(e)}finally{g.f()}if(d.length>0){var v,b=function(e,t){var n=e.map((function(e){return e.length}));if(n.some((function(e){return e>1})))return e.map((function(e){return Fn(e,t)}));var r=e.map((function(e){return e[0]})).filter((function(e){return null!==e.start&&null!==e.end})).sort((function(e,t){return e.start-t.start}));if(!r.some((function(e,t){var n=r.at(t+1);return!!n&&o.doesIntersect2(e.start,e.end,n.start,n.end)})))return[Fn(r,t)];var i,a=e.map((function(e){return e[0]})),s=[],l=j(a);try{var c=function(){var e=i.value,t=s.at(-1);if(!t)return s.push([e]),1;t.some((function(t){return o.doesIntersect2(t.start,t.end,e.start,e.end)}))?s.push([e]):t.push(e)};for(l.s();!(i=l.n()).done;)c()}catch(e){l.e(e)}finally{l.f()}return s.map((function(e){return Fn(e,t)}))}(d,t),x=j(b);try{for(x.s();!(v=x.n()).done;){var w=v.value;r[w._id]=w}}catch(e){x.e(e)}finally{x.f()}var S,C=function(e,t,n,r,o){var i,a=[],s=j(n);try{for(s.s();!(i=s.n()).done;){var l,c=j(i.value);try{for(c.s();!(l=c.n()).done;){var u=l.value;if(!u.start||!u.end)throw new Error("UTR has undefined start and/or end\n: ".concat(JSON.stringify(u,null,2)));var d=void 0;"+"===u.strand?d=1:"-"===u.strand&&(d=-1),a.push({_id:(new at).toHexString(),refSeq:r,type:"exon",min:u.start-1,max:u.end,strand:d})}}catch(e){c.e(e)}finally{c.f()}}}catch(e){s.e(e)}finally{s.f()}a.sort((function(e,t){return e.min-t.min}));var f,h=[],p=j(e);try{for(p.s();!(f=p.n()).done;){var g=f.value;g.sort((function(e,t){if(!e.start||!t.start)throw new Error("CDS has undefined start");return e.start-t.start}));for(var m=0;m<g.length;m++){var y,_=g[m],v=!1,b=j(t);try{for(b.s();!(y=b.n()).done;){var x=y.value;if(1!=x.length)throw new Error("Unexpected number of exons");var w=G(x,1)[0];if(w.start&&w.end&&_.start&&_.end&&w.start<=_.start&&w.end>=_.end){v=!0;break}}}catch(e){b.e(e)}finally{b.f()}if(!v){if(!_.start||!_.end)throw new Error("CDS has undefined start and/or end: ".concat(JSON.stringify(_,null,2)));var S=void 0;"+"===_.strand?S=1:"-"===_.strand&&(S=-1);var C={_id:(new at).toHexString(),refSeq:r,type:"exon",min:_.start-1,max:_.end,strand:S};if(0===m){var A,k=j(a);try{for(k.s();!(A=k.n()).done;){var N=A.value;if(N.max>C.min)break;N.max===C.min?C.min=N.min:h.push(N)}}catch(e){k.e(e)}finally{k.f()}}if(m===g.length-1){var T,R=j(a);try{for(R.s();!(T=R.n()).done;){var E=T.value;E.min<C.max||(E.min===C.max?C.max=E.max:h.push(E))}}catch(e){R.e(e)}finally{R.f()}}h.push(C)}}}}catch(e){p.e(e)}finally{p.f()}var I=function(e){if(0===e.length)return[];e.sort((function(e,t){return e.min-t.min}));var t=[];t.push(e[0]);for(var n=1;n<e.length;n++){var r=t.at(-1),o=e[n];r&&o.min<=r.max?r.max=Math.max(r.max,o.max):t.push(o)}return t}(h);return I}(d,f,h,b[0].refSeq),A=j(C);try{for(A.s();!(S=A.n()).done;){var k=S.value;r[k._id]=k}}catch(e){A.e(e)}finally{A.f()}}return Object.keys(r).length>0?r:void 0}}(e,t),h=function(e){var t={},n=e.map((function(e){return e.score})).filter((function(e){return null!==e})),r=e.map((function(e){return e.source})).filter((function(e){return null!==e})),o=e.map((function(e){return e.attributes})).filter((function(e){return null!==e}));if(n.length>0){var i=G(n,1)[0];n.length>1&&(i=n.reduce((function(e,t){return e+t}),0)/n.length),t.gff_score=[String(i)]}if(r.length>0){var a=G(r,1)[0];r.length>1&&(a=W(new Set(r)).join(",")),t.gff_source=[a]}if(o.length>0){var s,l=j(o);try{for(l.s();!(s=l.n()).done;)for(var c=0,u=Object.entries(s.value);c<u.length;c++){var d=G(u[c],2),f=d[0],h=d[1];if("Parent"!==f){var p=f in jn?jn[f]:f,g=t[p];if(g){var m=new Set([].concat(W(g),W(h)));t[p]=W(m)}else t[p]=h}}}catch(e){l.e(e)}finally{l.f()}}if(Object.keys(t).length>0)return t}(e),p={_id:(new at).toHexString(),refSeq:i,type:Mn(e),min:u,max:d};if(s)if("+"===s)p.strand=1;else{if("-"!==s)throw new Error('Unknown strand: "'.concat(s,'"'));p.strand=-1}return f&&(p.children=f),h&&(p.attributes=h),p}function Mn(e){var t=G(e,1)[0];if(1===e.length||"CDS"===t.type){var n=t.type;if(!n)throw new Error("feature does not have type: ".concat(JSON.stringify(t)));return n}return"apollo_feature_container"}var Ln=a.createSvgIcon(i.jsx("path",{d:"M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6z"}),"Add");const Pn=n.ConfigurationSchema("ApolloInternetAccount",{baseURL:{description:"Location of Apollo server",type:"string",defaultValue:""},tokenType:{description:"A custom name for a token to include in the header",type:"string",defaultValue:"Bearer"}},{baseConfiguration:r.BaseInternetAccountConfig,explicitlyTyped:!0});var Bn=Object.create(null);Bn.open="0",Bn.close="1",Bn.ping="2",Bn.pong="3",Bn.message="4",Bn.upgrade="5",Bn.noop="6";var qn=Object.create(null);Object.keys(Bn).forEach((function(e){qn[Bn[e]]=e}));var Un,zn={type:"error",data:"parser error"},$n="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Object.prototype.toString.call(Blob),Hn="function"==typeof ArrayBuffer,Gn=function(e){return"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer},Vn=function(e,t,n){var r=e.type,o=e.data;return $n&&o instanceof Blob?t?n(o):Wn(o,n):Hn&&(o instanceof ArrayBuffer||Gn(o))?t?n(o):Wn(new Blob([o]),n):n(Bn[r]+(o||""))},Wn=function(e,t){var n=new FileReader;return n.onload=function(){var e=n.result.split(",")[1];t("b"+(e||""))},n.readAsDataURL(e)};function Jn(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}for(var Kn="undefined"==typeof Uint8Array?[]:new Uint8Array(256),Yn=0;Yn<64;Yn++)Kn["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charCodeAt(Yn)]=Yn;var Xn,Zn="function"==typeof ArrayBuffer,Qn=function(e,t){if("string"!=typeof e)return{type:"message",data:tr(e,t)};var n=e.charAt(0);return"b"===n?{type:"message",data:er(e.substring(1),t)}:qn[n]?e.length>1?{type:qn[n],data:e.substring(1)}:{type:qn[n]}:zn},er=function(e,t){if(Zn){var n=function(e){var t,n,r,o,i,a=.75*e.length,s=e.length,l=0;"="===e[e.length-1]&&(a--,"="===e[e.length-2]&&a--);var c=new ArrayBuffer(a),u=new Uint8Array(c);for(t=0;t<s;t+=4)n=Kn[e.charCodeAt(t)],r=Kn[e.charCodeAt(t+1)],o=Kn[e.charCodeAt(t+2)],i=Kn[e.charCodeAt(t+3)],u[l++]=n<<2|r>>4,u[l++]=(15&r)<<4|o>>2,u[l++]=(3&o)<<6|63&i;return c}(e);return tr(n,t)}return{base64:!0,data:e}},tr=function(e,t){return"blob"===t?e instanceof Blob?e:new Blob([e]):e instanceof ArrayBuffer?e:e.buffer},nr=String.fromCharCode(30);function rr(e){return e.reduce((function(e,t){return e+t.length}),0)}function or(e,t){if(e[0].length===t)return e.shift();for(var n=new Uint8Array(t),r=0,o=0;o<t;o++)n[o]=e[0][r++],r===e[0].length&&(e.shift(),r=0);return e.length&&r<e[0].length&&(e[0]=e[0].slice(r)),n}function ir(e){if(e)return function(e){for(var t in ir.prototype)e[t]=ir.prototype[t];return e}(e)}ir.prototype.on=ir.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},ir.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},ir.prototype.off=ir.prototype.removeListener=ir.prototype.removeAllListeners=ir.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var o=0;o<r.length;o++)if((n=r[o])===t||n.fn===t){r.splice(o,1);break}return 0===r.length&&delete this._callbacks["$"+e],this},ir.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),n=this._callbacks["$"+e],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(n){r=0;for(var o=(n=n.slice(0)).length;r<o;++r)n[r].apply(this,t)}return this},ir.prototype.emitReserved=ir.prototype.emit,ir.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},ir.prototype.hasListeners=function(e){return!!this.listeners(e).length};var ar=function(){return"undefined"!=typeof self?self:"undefined"!=typeof window?window:Function("return this")()}();function sr(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return n.reduce((function(t,n){return e.hasOwnProperty(n)&&(t[n]=e[n]),t}),{})}var lr=ar.setTimeout,cr=ar.clearTimeout;function ur(e,t){t.useNativeTimers?(e.setTimeoutFn=lr.bind(ar),e.clearTimeoutFn=cr.bind(ar)):(e.setTimeoutFn=ar.setTimeout.bind(ar),e.clearTimeoutFn=ar.clearTimeout.bind(ar))}var dr,fr=function(e){function t(e,n,r){var o;return R(this,t),(o=T(this,t,[e])).description=n,o.context=r,o.type="TransportError",o}return M(t,e),I(t)}(Z(Error)),hr=function(e){function t(e){var n;return R(this,t),(n=T(this,t)).writable=!1,ur(n,e),n.opts=e,n.query=e.query,n.socket=e.socket,n}return M(t,e),I(t,[{key:"onError",value:function(e,n,r){return V(t,"emitReserved",this,3)(["error",new fr(e,n,r)]),this}},{key:"open",value:function(){return this.readyState="opening",this.doOpen(),this}},{key:"close",value:function(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this}},{key:"send",value:function(e){"open"===this.readyState&&this.write(e)}},{key:"onOpen",value:function(){this.readyState="open",this.writable=!0,V(t,"emitReserved",this,3)(["open"])}},{key:"onData",value:function(e){var t=Qn(e,this.socket.binaryType);this.onPacket(t)}},{key:"onPacket",value:function(e){V(t,"emitReserved",this,3)(["packet",e])}},{key:"onClose",value:function(e){this.readyState="closed",V(t,"emitReserved",this,3)(["close",e])}},{key:"pause",value:function(e){}},{key:"createUri",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}},{key:"_hostname",value:function(){var e=this.opts.hostname;return-1===e.indexOf(":")?e:"["+e+"]"}},{key:"_port",value:function(){return this.opts.port&&(this.opts.secure&&Number(443!==this.opts.port)||!this.opts.secure&&80!==Number(this.opts.port))?":"+this.opts.port:""}},{key:"_query",value:function(e){var t=function(e){var t="";for(var n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t}(e);return t.length?"?"+t:""}}])}(ir),pr="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),gr=64,mr=0;function yr(e){var t="";do{t=pr[e%gr]+t,e=Math.floor(e/gr)}while(e>0);return t}function _r(){var e=yr(+new Date);return e!==dr?(mr=0,dr=e):e+"."+yr(mr++)}var vr=!1;try{vr="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(e){}var br=vr;function xr(e){var t=e.xdomain;try{if("undefined"!=typeof XMLHttpRequest&&(!t||br))return new XMLHttpRequest}catch(e){}if(!t)try{return new(ar[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(e){}}function wr(){}var Sr=function(){return null!=new xr({xdomain:!1}).responseType}(),Cr=function(e){function t(e){var n;if(R(this,t),(n=T(this,t,[e])).polling=!1,"undefined"!=typeof location){var r="https:"===location.protocol,o=location.port;o||(o=r?"443":"80"),n.xd="undefined"!=typeof location&&e.hostname!==location.hostname||o!==e.port}return n.supportsBinary=Sr&&!(e&&e.forceBase64),n.opts.withCredentials&&(n.cookieJar=void 0),n}return M(t,e),I(t,[{key:"name",get:function(){return"polling"}},{key:"doOpen",value:function(){this.poll()}},{key:"pause",value:function(e){var t=this;this.readyState="pausing";var n=function(){t.readyState="paused",e()};if(this.polling||!this.writable){var r=0;this.polling&&(r++,this.once("pollComplete",(function(){--r||n()}))),this.writable||(r++,this.once("drain",(function(){--r||n()})))}else n()}},{key:"poll",value:function(){this.polling=!0,this.doPoll(),this.emitReserved("poll")}},{key:"onData",value:function(e){var t=this;(function(e,t){for(var n=e.split(nr),r=[],o=0;o<n.length;o++){var i=Qn(n[o],t);if(r.push(i),"error"===i.type)break}return r})(e,this.socket.binaryType).forEach((function(e){if("opening"===t.readyState&&"open"===e.type&&t.onOpen(),"close"===e.type)return t.onClose({description:"transport closed by the server"}),!1;t.onPacket(e)})),"closed"!==this.readyState&&(this.polling=!1,this.emitReserved("pollComplete"),"open"===this.readyState&&this.poll())}},{key:"doClose",value:function(){var e=this,t=function(){e.write([{type:"close"}])};"open"===this.readyState?t():this.once("open",t)}},{key:"write",value:function(e){var t=this;this.writable=!1,function(e,n){var r=e.length,o=new Array(r),i=0;e.forEach((function(e,n){Vn(e,!1,(function(e){var a;o[n]=e,++i===r&&(a=o.join(nr),t.doWrite(a,(function(){t.writable=!0,t.emitReserved("drain")})))}))}))}(e)}},{key:"uri",value:function(){var e=this.opts.secure?"https":"http",t=this.query||{};return!1!==this.opts.timestampRequests&&(t[this.opts.timestampParam]=_r()),this.supportsBinary||t.sid||(t.b64=1),this.createUri(e,t)}},{key:"request",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return Object.assign(e,{xd:this.xd,cookieJar:this.cookieJar},this.opts),new Ar(this.uri(),e)}},{key:"doWrite",value:function(e,t){var n=this,r=this.request({method:"POST",data:e});r.on("success",t),r.on("error",(function(e,t){n.onError("xhr post error",e,t)}))}},{key:"doPoll",value:function(){var e=this,t=this.request();t.on("data",this.onData.bind(this)),t.on("error",(function(t,n){e.onError("xhr poll error",t,n)})),this.pollXhr=t}}])}(hr),Ar=function(e){function t(e,n){var r;return R(this,t),ur(r=T(this,t),n),r.opts=n,r.method=n.method||"GET",r.uri=e,r.data=void 0!==n.data?n.data:null,r.create(),r}return M(t,e),I(t,[{key:"create",value:function(){var e,n=this,r=sr(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");r.xdomain=!!this.opts.xd;var o=this.xhr=new xr(r);try{o.open(this.method,this.uri,!0);try{if(this.opts.extraHeaders)for(var i in o.setDisableHeaderCheck&&o.setDisableHeaderCheck(!0),this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(i)&&o.setRequestHeader(i,this.opts.extraHeaders[i])}catch(e){}if("POST"===this.method)try{o.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(e){}try{o.setRequestHeader("Accept","*/*")}catch(e){}null===(e=this.opts.cookieJar)||void 0===e||e.addCookies(o),"withCredentials"in o&&(o.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(o.timeout=this.opts.requestTimeout),o.onreadystatechange=function(){var e;3===o.readyState&&(null===(e=n.opts.cookieJar)||void 0===e||e.parseCookies(o)),4===o.readyState&&(200===o.status||1223===o.status?n.onLoad():n.setTimeoutFn((function(){n.onError("number"==typeof o.status?o.status:0)}),0))},o.send(this.data)}catch(e){return void this.setTimeoutFn((function(){n.onError(e)}),0)}"undefined"!=typeof document&&(this.index=t.requestsCount++,t.requests[this.index]=this)}},{key:"onError",value:function(e){this.emitReserved("error",e,this.xhr),this.cleanup(!0)}},{key:"cleanup",value:function(e){if(null!=this.xhr){if(this.xhr.onreadystatechange=wr,e)try{this.xhr.abort()}catch(e){}"undefined"!=typeof document&&delete t.requests[this.index],this.xhr=null}}},{key:"onLoad",value:function(){var e=this.xhr.responseText;null!==e&&(this.emitReserved("data",e),this.emitReserved("success"),this.cleanup())}},{key:"abort",value:function(){this.cleanup()}}])}(ir);function kr(){for(var e in Ar.requests)Ar.requests.hasOwnProperty(e)&&Ar.requests[e].abort()}Ar.requestsCount=0,Ar.requests={},"undefined"!=typeof document&&("function"==typeof attachEvent?attachEvent("onunload",kr):"function"==typeof addEventListener&&addEventListener("onpagehide"in ar?"pagehide":"unload",kr,!1));var Nr=function(){return"function"==typeof Promise&&"function"==typeof Promise.resolve?function(e){return Promise.resolve().then(e)}:function(e,t){return t(e,0)}}(),Tr=ar.WebSocket||ar.MozWebSocket,Rr="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase(),Er=function(e){function t(e){var n;return R(this,t),(n=T(this,t,[e])).supportsBinary=!e.forceBase64,n}return M(t,e),I(t,[{key:"name",get:function(){return"websocket"}},{key:"doOpen",value:function(){if(this.check()){var e=this.uri(),t=this.opts.protocols,n=Rr?{}:sr(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=Rr?new Tr(e,t,n):t?new Tr(e,t):new Tr(e)}catch(e){return this.emitReserved("error",e)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}}},{key:"addEventListeners",value:function(){var e=this;this.ws.onopen=function(){e.opts.autoUnref&&e.ws._socket.unref(),e.onOpen()},this.ws.onclose=function(t){return e.onClose({description:"websocket connection closed",context:t})},this.ws.onmessage=function(t){return e.onData(t.data)},this.ws.onerror=function(t){return e.onError("websocket error",t)}}},{key:"write",value:function(e){var t=this;this.writable=!1;for(var n=function(){var n=r===e.length-1;Vn(e[r],t.supportsBinary,(function(e){try{t.ws.send(e)}catch(e){}n&&Nr((function(){t.writable=!0,t.emitReserved("drain")}),t.setTimeoutFn)}))},r=0;r<e.length;r++)n()}},{key:"doClose",value:function(){void 0!==this.ws&&(this.ws.close(),this.ws=null)}},{key:"uri",value:function(){var e=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=_r()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}},{key:"check",value:function(){return!!Tr}}])}(hr),Ir=function(e){function t(){return R(this,t),T(this,t,arguments)}return M(t,e),I(t,[{key:"name",get:function(){return"webtransport"}},{key:"doOpen",value:function(){var e=this;"function"==typeof WebTransport&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then((function(){e.onClose()})).catch((function(t){e.onError("webtransport error",t)})),this.transport.ready.then((function(){e.transport.createBidirectionalStream().then((function(t){var n=function(e,t){Xn||(Xn=new TextDecoder);var n=[],r=0,o=-1,i=!1;return new TransformStream({transform:function(a,s){for(n.push(a);;){if(0===r){if(rr(n)<1)break;var l=or(n,1);i=128==(128&l[0]),r=(o=127&l[0])<126?3:126===o?1:2}else if(1===r){if(rr(n)<2)break;var c=or(n,2);o=new DataView(c.buffer,c.byteOffset,c.length).getUint16(0),r=3}else if(2===r){if(rr(n)<8)break;var u=or(n,8),d=new DataView(u.buffer,u.byteOffset,u.length),f=d.getUint32(0);if(f>Math.pow(2,21)-1){s.enqueue(zn);break}o=f*Math.pow(2,32)+d.getUint32(4),r=3}else{if(rr(n)<o)break;var h=or(n,o);s.enqueue(Qn(i?h:Xn.decode(h),t)),r=0}if(0===o||o>e){s.enqueue(zn);break}}}})}(Number.MAX_SAFE_INTEGER,e.socket.binaryType),r=t.readable.pipeThrough(n).getReader(),o=new TransformStream({transform:function(e,t){!function(e,t){$n&&e.data instanceof Blob?e.data.arrayBuffer().then(Jn).then(t):Hn&&(e.data instanceof ArrayBuffer||Gn(e.data))?t(Jn(e.data)):Vn(e,!1,(function(e){Un||(Un=new TextEncoder),t(Un.encode(e))}))}(e,(function(n){var r,o=n.length;if(o<126)r=new Uint8Array(1),new DataView(r.buffer).setUint8(0,o);else if(o<65536){r=new Uint8Array(3);var i=new DataView(r.buffer);i.setUint8(0,126),i.setUint16(1,o)}else{r=new Uint8Array(9);var a=new DataView(r.buffer);a.setUint8(0,127),a.setBigUint64(1,BigInt(o))}e.data&&"string"!=typeof e.data&&(r[0]|=128),t.enqueue(r),t.enqueue(n)}))}});o.readable.pipeTo(t.writable),e.writer=o.writable.getWriter();var i=function(){r.read().then((function(t){t.done||(e.onPacket(t.value),i())})).catch((function(e){}))};i();var a={type:"open"};e.query.sid&&(a.data='{"sid":"'.concat(e.query.sid,'"}')),e.writer.write(a).then((function(){return e.onOpen()}))}))})))}},{key:"write",value:function(e){var t=this;this.writable=!1;for(var n=function(){var n=r===e.length-1;t.writer.write(e[r]).then((function(){n&&Nr((function(){t.writable=!0,t.emitReserved("drain")}),t.setTimeoutFn)}))},r=0;r<e.length;r++)n()}},{key:"doClose",value:function(){var e;null===(e=this.transport)||void 0===e||e.close()}}])}(hr),jr={websocket:Er,webtransport:Ir,polling:Cr},Dr=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Or=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Fr(e){var t,n,r=e,o=e.indexOf("["),i=e.indexOf("]");-1!=o&&-1!=i&&(e=e.substring(0,o)+e.substring(o,i).replace(/:/g,";")+e.substring(i,e.length));for(var a,s=Dr.exec(e||""),l={},c=14;c--;)l[Or[c]]=s[c]||"";return-1!=o&&-1!=i&&(l.source=r,l.host=l.host.substring(1,l.host.length-1).replace(/;/g,":"),l.authority=l.authority.replace("[","").replace("]","").replace(/;/g,":"),l.ipv6uri=!0),l.pathNames=(n=(t=l.path).replace(/\/{2,9}/g,"/").split("/"),"/"!=t.slice(0,1)&&0!==t.length||n.splice(0,1),"/"==t.slice(-1)&&n.splice(n.length-1,1),n),l.queryKey=(a={},l.query.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,(function(e,t,n){t&&(a[t]=n)})),a),l}var Mr=function(e){function t(e){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return R(this,t),(n=T(this,t)).binaryType="arraybuffer",n.writeBuffer=[],e&&"object"===K(e)&&(r=e,e=null),e?(e=Fr(e),r.hostname=e.host,r.secure="https"===e.protocol||"wss"===e.protocol,r.port=e.port,e.query&&(r.query=e.query)):r.host&&(r.hostname=Fr(r.host).host),ur(n,r),n.secure=null!=r.secure?r.secure:"undefined"!=typeof location&&"https:"===location.protocol,r.hostname&&!r.port&&(r.port=n.secure?"443":"80"),n.hostname=r.hostname||("undefined"!=typeof location?location.hostname:"localhost"),n.port=r.port||("undefined"!=typeof location&&location.port?location.port:n.secure?"443":"80"),n.transports=r.transports||["polling","websocket","webtransport"],n.writeBuffer=[],n.prevBufferLen=0,n.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},r),n.opts.path=n.opts.path.replace(/\/$/,"")+(n.opts.addTrailingSlash?"/":""),"string"==typeof n.opts.query&&(n.opts.query=function(e){for(var t={},n=e.split("&"),r=0,o=n.length;r<o;r++){var i=n[r].split("=");t[decodeURIComponent(i[0])]=decodeURIComponent(i[1])}return t}(n.opts.query)),n.id=null,n.upgrades=null,n.pingInterval=null,n.pingTimeout=null,n.pingTimeoutTimer=null,"function"==typeof addEventListener&&(n.opts.closeOnBeforeunload&&(n.beforeunloadEventListener=function(){n.transport&&(n.transport.removeAllListeners(),n.transport.close())},addEventListener("beforeunload",n.beforeunloadEventListener,!1)),"localhost"!==n.hostname&&(n.offlineEventListener=function(){n.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",n.offlineEventListener,!1))),n.open(),n}return M(t,e),I(t,[{key:"createTransport",value:function(e){var t=Object.assign({},this.opts.query);t.EIO=4,t.transport=e,this.id&&(t.sid=this.id);var n=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new jr[e](n)}},{key:"open",value:function(){var e,n=this;if(this.opts.rememberUpgrade&&t.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))e="websocket";else{if(0===this.transports.length)return void this.setTimeoutFn((function(){n.emitReserved("error","No transports available")}),0);e=this.transports[0]}this.readyState="opening";try{e=this.createTransport(e)}catch(e){return this.transports.shift(),void this.open()}e.open(),this.setTransport(e)}},{key:"setTransport",value:function(e){var t=this;this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",(function(e){return t.onClose("transport close",e)}))}},{key:"probe",value:function(e){var n=this,r=this.createTransport(e),o=!1;t.priorWebsocketSuccess=!1;var i=function(){o||(r.send([{type:"ping",data:"probe"}]),r.once("packet",(function(e){if(!o)if("pong"===e.type&&"probe"===e.data){if(n.upgrading=!0,n.emitReserved("upgrading",r),!r)return;t.priorWebsocketSuccess="websocket"===r.name,n.transport.pause((function(){o||"closed"!==n.readyState&&(d(),n.setTransport(r),r.send([{type:"upgrade"}]),n.emitReserved("upgrade",r),r=null,n.upgrading=!1,n.flush())}))}else{var i=new Error("probe error");i.transport=r.name,n.emitReserved("upgradeError",i)}})))};function a(){o||(o=!0,d(),r.close(),r=null)}var s=function(e){var t=new Error("probe error: "+e);t.transport=r.name,a(),n.emitReserved("upgradeError",t)};function l(){s("transport closed")}function c(){s("socket closed")}function u(e){r&&e.name!==r.name&&a()}var d=function(){r.removeListener("open",i),r.removeListener("error",s),r.removeListener("close",l),n.off("close",c),n.off("upgrading",u)};r.once("open",i),r.once("error",s),r.once("close",l),this.once("close",c),this.once("upgrading",u),-1!==this.upgrades.indexOf("webtransport")&&"webtransport"!==e?this.setTimeoutFn((function(){o||r.open()}),200):r.open()}},{key:"onOpen",value:function(){if(this.readyState="open",t.priorWebsocketSuccess="websocket"===this.transport.name,this.emitReserved("open"),this.flush(),"open"===this.readyState&&this.opts.upgrade)for(var e=0,n=this.upgrades.length;e<n;e++)this.probe(this.upgrades[e])}},{key:"onPacket",value:function(e){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),this.resetPingTimeout(),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this.sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong");break;case"error":var t=new Error("server error");t.code=e.data,this.onError(t);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data)}}},{key:"onHandshake",value:function(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this.upgrades=this.filterUpgrades(e.upgrades),this.pingInterval=e.pingInterval,this.pingTimeout=e.pingTimeout,this.maxPayload=e.maxPayload,this.onOpen(),"closed"!==this.readyState&&this.resetPingTimeout()}},{key:"resetPingTimeout",value:function(){var e=this;this.clearTimeoutFn(this.pingTimeoutTimer),this.pingTimeoutTimer=this.setTimeoutFn((function(){e.onClose("ping timeout")}),this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}},{key:"onDrain",value:function(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emitReserved("drain"):this.flush()}},{key:"flush",value:function(){if("closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){var e=this.getWritablePackets();this.transport.send(e),this.prevBufferLen=e.length,this.emitReserved("flush")}}},{key:"getWritablePackets",value:function(){if(!(this.maxPayload&&"polling"===this.transport.name&&this.writeBuffer.length>1))return this.writeBuffer;for(var e,t=1,n=0;n<this.writeBuffer.length;n++){var r=this.writeBuffer[n].data;if(r&&(t+="string"==typeof(e=r)?function(e){for(var t=0,n=0,r=0,o=e.length;r<o;r++)(t=e.charCodeAt(r))<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(r++,n+=4);return n}(e):Math.ceil(1.33*(e.byteLength||e.size))),n>0&&t>this.maxPayload)return this.writeBuffer.slice(0,n);t+=2}return this.writeBuffer}},{key:"write",value:function(e,t,n){return this.sendPacket("message",e,t,n),this}},{key:"send",value:function(e,t,n){return this.sendPacket("message",e,t,n),this}},{key:"sendPacket",value:function(e,t,n,r){if("function"==typeof t&&(r=t,t=void 0),"function"==typeof n&&(r=n,n=null),"closing"!==this.readyState&&"closed"!==this.readyState){(n=n||{}).compress=!1!==n.compress;var o={type:e,data:t,options:n};this.emitReserved("packetCreate",o),this.writeBuffer.push(o),r&&this.once("flush",r),this.flush()}}},{key:"close",value:function(){var e=this,t=function(){e.onClose("forced close"),e.transport.close()},n=function(){e.off("upgrade",n),e.off("upgradeError",n),t()},r=function(){e.once("upgrade",n),e.once("upgradeError",n)};return"opening"!==this.readyState&&"open"!==this.readyState||(this.readyState="closing",this.writeBuffer.length?this.once("drain",(function(){e.upgrading?r():t()})):this.upgrading?r():t()),this}},{key:"onError",value:function(e){t.priorWebsocketSuccess=!1,this.emitReserved("error",e),this.onClose("transport error",e)}},{key:"onClose",value:function(e,t){"opening"!==this.readyState&&"open"!==this.readyState&&"closing"!==this.readyState||(this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),"function"==typeof removeEventListener&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this.prevBufferLen=0)}},{key:"filterUpgrades",value:function(e){for(var t=[],n=0,r=e.length;n<r;n++)~this.transports.indexOf(e[n])&&t.push(e[n]);return t}}])}(ir);Mr.protocol=4;var Lr="function"==typeof ArrayBuffer,Pr=function(e){return"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer},Br=Object.prototype.toString,qr="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Br.call(Blob),Ur="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===Br.call(File);function zr(e){return Lr&&(e instanceof ArrayBuffer||Pr(e))||qr&&e instanceof Blob||Ur&&e instanceof File}function $r(e,t){if(!e||"object"!==K(e))return!1;if(Array.isArray(e)){for(var n=0,r=e.length;n<r;n++)if($r(e[n]))return!0;return!1}if(zr(e))return!0;if(e.toJSON&&"function"==typeof e.toJSON&&1===arguments.length)return $r(e.toJSON(),!0);for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)&&$r(e[o]))return!0;return!1}function Hr(e){var t=[],n=e;return n.data=Gr(e.data,t),n.attachments=t.length,{packet:n,buffers:t}}function Gr(e,t){if(!e)return e;if(zr(e)){var n={_placeholder:!0,num:t.length};return t.push(e),n}if(Array.isArray(e)){for(var r=new Array(e.length),o=0;o<e.length;o++)r[o]=Gr(e[o],t);return r}if("object"===K(e)&&!(e instanceof Date)){var i={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(i[a]=Gr(e[a],t));return i}return e}function Vr(e,t){return e.data=Wr(e.data,t),delete e.attachments,e}function Wr(e,t){if(!e)return e;if(e&&!0===e._placeholder){if("number"==typeof e.num&&e.num>=0&&e.num<t.length)return t[e.num];throw new Error("illegal attachments")}if(Array.isArray(e))for(var n=0;n<e.length;n++)e[n]=Wr(e[n],t);else if("object"===K(e))for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(e[r]=Wr(e[r],t));return e}var Jr,Kr=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];!function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"}(Jr||(Jr={}));var Yr=function(){return I((function e(t){R(this,e),this.replacer=t}),[{key:"encode",value:function(e){return e.type!==Jr.EVENT&&e.type!==Jr.ACK||!$r(e)?[this.encodeAsString(e)]:this.encodeAsBinary({type:e.type===Jr.EVENT?Jr.BINARY_EVENT:Jr.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id})}},{key:"encodeAsString",value:function(e){var t=""+e.type;return e.type!==Jr.BINARY_EVENT&&e.type!==Jr.BINARY_ACK||(t+=e.attachments+"-"),e.nsp&&"/"!==e.nsp&&(t+=e.nsp+","),null!=e.id&&(t+=e.id),null!=e.data&&(t+=JSON.stringify(e.data,this.replacer)),t}},{key:"encodeAsBinary",value:function(e){var t=Hr(e),n=this.encodeAsString(t.packet),r=t.buffers;return r.unshift(n),r}}])}();function Xr(e){return"[object Object]"===Object.prototype.toString.call(e)}var Zr=function(e){function t(e){var n;return R(this,t),(n=T(this,t)).reviver=e,n}return M(t,e),I(t,[{key:"add",value:function(e){var n;if("string"==typeof e){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");var r=(n=this.decodeString(e)).type===Jr.BINARY_EVENT;r||n.type===Jr.BINARY_ACK?(n.type=r?Jr.EVENT:Jr.ACK,this.reconstructor=new Qr(n),0===n.attachments&&V(t,"emitReserved",this,3)(["decoded",n])):V(t,"emitReserved",this,3)(["decoded",n])}else{if(!zr(e)&&!e.base64)throw new Error("Unknown type: "+e);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");(n=this.reconstructor.takeBinaryData(e))&&(this.reconstructor=null,V(t,"emitReserved",this,3)(["decoded",n]))}}},{key:"decodeString",value:function(e){var n=0,r={type:Number(e.charAt(0))};if(void 0===Jr[r.type])throw new Error("unknown packet type "+r.type);if(r.type===Jr.BINARY_EVENT||r.type===Jr.BINARY_ACK){for(var o=n+1;"-"!==e.charAt(++n)&&n!=e.length;);var i=e.substring(o,n);if(i!=Number(i)||"-"!==e.charAt(n))throw new Error("Illegal attachments");r.attachments=Number(i)}if("/"===e.charAt(n+1)){for(var a=n+1;++n&&","!==e.charAt(n)&&n!==e.length;);r.nsp=e.substring(a,n)}else r.nsp="/";var s=e.charAt(n+1);if(""!==s&&Number(s)==s){for(var l=n+1;++n;){var c=e.charAt(n);if(null==c||Number(c)!=c){--n;break}if(n===e.length)break}r.id=Number(e.substring(l,n+1))}if(e.charAt(++n)){var u=this.tryParse(e.substr(n));if(!t.isPayloadValid(r.type,u))throw new Error("invalid payload");r.data=u}return r}},{key:"tryParse",value:function(e){try{return JSON.parse(e,this.reviver)}catch(e){return!1}}},{key:"destroy",value:function(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}],[{key:"isPayloadValid",value:function(e,t){switch(e){case Jr.CONNECT:return Xr(t);case Jr.DISCONNECT:return void 0===t;case Jr.CONNECT_ERROR:return"string"==typeof t||Xr(t);case Jr.EVENT:case Jr.BINARY_EVENT:return Array.isArray(t)&&("number"==typeof t[0]||"string"==typeof t[0]&&-1===Kr.indexOf(t[0]));case Jr.ACK:case Jr.BINARY_ACK:return Array.isArray(t)}}}])}(ir),Qr=function(){return I((function e(t){R(this,e),this.packet=t,this.buffers=[],this.reconPack=t}),[{key:"takeBinaryData",value:function(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){var t=Vr(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}},{key:"finishedReconstruction",value:function(){this.reconPack=null,this.buffers=[]}}])}(),eo={__proto__:null,Decoder:Zr,Encoder:Yr,get PacketType(){return Jr}};function to(e,t,n){return e.on(t,n),function(){e.off(t,n)}}var no=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),ro=function(e){function t(e,n,r){var o;return R(this,t),(o=T(this,t)).connected=!1,o.recovered=!1,o.receiveBuffer=[],o.sendBuffer=[],o._queue=[],o._queueSeq=0,o.ids=0,o.acks={},o.flags={},o.io=e,o.nsp=n,r&&r.auth&&(o.auth=r.auth),o._opts=Object.assign({},r),o.io._autoConnect&&o.open(),o}return M(t,e),I(t,[{key:"disconnected",get:function(){return!this.connected}},{key:"subEvents",value:function(){if(!this.subs){var e=this.io;this.subs=[to(e,"open",this.onopen.bind(this)),to(e,"packet",this.onpacket.bind(this)),to(e,"error",this.onerror.bind(this)),to(e,"close",this.onclose.bind(this))]}}},{key:"active",get:function(){return!!this.subs}},{key:"connect",value:function(){return this.connected||(this.subEvents(),this.io._reconnecting||this.io.open(),"open"===this.io._readyState&&this.onopen()),this}},{key:"open",value:function(){return this.connect()}},{key:"send",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.unshift("message"),this.emit.apply(this,t),this}},{key:"emit",value:function(e){if(no.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];if(n.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(n),this;var o={type:Jr.EVENT,data:n,options:{}};if(o.options.compress=!1!==this.flags.compress,"function"==typeof n[n.length-1]){var i=this.ids++,a=n.pop();this._registerAckCallback(i,a),o.id=i}return this.flags.volatile&&(!(this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable)||!this.connected)||(this.connected?(this.notifyOutgoingListeners(o),this.packet(o)):this.sendBuffer.push(o)),this.flags={},this}},{key:"_registerAckCallback",value:function(e,t){var n,r=this,o=null!==(n=this.flags.timeout)&&void 0!==n?n:this._opts.ackTimeout;if(void 0!==o){var i=this.io.setTimeoutFn((function(){delete r.acks[e];for(var n=0;n<r.sendBuffer.length;n++)r.sendBuffer[n].id===e&&r.sendBuffer.splice(n,1);t.call(r,new Error("operation has timed out"))}),o);this.acks[e]=function(){r.io.clearTimeoutFn(i);for(var e=arguments.length,n=new Array(e),o=0;o<e;o++)n[o]=arguments[o];t.apply(r,[null].concat(n))}}else this.acks[e]=t}},{key:"emitWithAck",value:function(e){for(var t=this,n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];var i=void 0!==this.flags.timeout||void 0!==this._opts.ackTimeout;return new Promise((function(n,o){r.push((function(e,t){return i?e?o(e):n(t):n(e)})),t.emit.apply(t,[e].concat(r))}))}},{key:"_addToQueue",value:function(e){var t,n=this;"function"==typeof e[e.length-1]&&(t=e.pop());var r={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((function(e){if(r===n._queue[0]){if(null!==e)r.tryCount>n._opts.retries&&(n._queue.shift(),t&&t(e));else if(n._queue.shift(),t){for(var o=arguments.length,i=new Array(o>1?o-1:0),a=1;a<o;a++)i[a-1]=arguments[a];t.apply(void 0,[null].concat(i))}return r.pending=!1,n._drainQueue()}})),this._queue.push(r),this._drainQueue()}},{key:"_drainQueue",value:function(){if(this.connected&&0!==this._queue.length){var e=this._queue[0];e.pending&&!(arguments.length>0&&void 0!==arguments[0]&&arguments[0])||(e.pending=!0,e.tryCount++,this.flags=e.flags,this.emit.apply(this,e.args))}}},{key:"packet",value:function(e){e.nsp=this.nsp,this.io._packet(e)}},{key:"onopen",value:function(){var e=this;"function"==typeof this.auth?this.auth((function(t){e._sendConnectPacket(t)})):this._sendConnectPacket(this.auth)}},{key:"_sendConnectPacket",value:function(e){this.packet({type:Jr.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}},{key:"onerror",value:function(e){this.connected||this.emitReserved("connect_error",e)}},{key:"onclose",value:function(e,t){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t)}},{key:"onpacket",value:function(e){if(e.nsp===this.nsp)switch(e.type){case Jr.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case Jr.EVENT:case Jr.BINARY_EVENT:this.onevent(e);break;case Jr.ACK:case Jr.BINARY_ACK:this.onack(e);break;case Jr.DISCONNECT:this.ondisconnect();break;case Jr.CONNECT_ERROR:this.destroy();var t=new Error(e.data.message);t.data=e.data.data,this.emitReserved("connect_error",t)}}},{key:"onevent",value:function(e){var t=e.data||[];null!=e.id&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}},{key:"emitEvent",value:function(e){if(this._anyListeners&&this._anyListeners.length){var n,r=j(this._anyListeners.slice());try{for(r.s();!(n=r.n()).done;)n.value.apply(this,e)}catch(e){r.e(e)}finally{r.f()}}V(t,"emit",this,1).apply(this,e),this._pid&&e.length&&"string"==typeof e[e.length-1]&&(this._lastOffset=e[e.length-1])}},{key:"ack",value:function(e){var t=this,n=!1;return function(){if(!n){n=!0;for(var r=arguments.length,o=new Array(r),i=0;i<r;i++)o[i]=arguments[i];t.packet({type:Jr.ACK,id:e,data:o})}}}},{key:"onack",value:function(e){var t=this.acks[e.id];"function"==typeof t&&(t.apply(this,e.data),delete this.acks[e.id])}},{key:"onconnect",value:function(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}},{key:"emitBuffered",value:function(){var e=this;this.receiveBuffer.forEach((function(t){return e.emitEvent(t)})),this.receiveBuffer=[],this.sendBuffer.forEach((function(t){e.notifyOutgoingListeners(t),e.packet(t)})),this.sendBuffer=[]}},{key:"ondisconnect",value:function(){this.destroy(),this.onclose("io server disconnect")}},{key:"destroy",value:function(){this.subs&&(this.subs.forEach((function(e){return e()})),this.subs=void 0),this.io._destroy(this)}},{key:"disconnect",value:function(){return this.connected&&this.packet({type:Jr.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}},{key:"close",value:function(){return this.disconnect()}},{key:"compress",value:function(e){return this.flags.compress=e,this}},{key:"volatile",get:function(){return this.flags.volatile=!0,this}},{key:"timeout",value:function(e){return this.flags.timeout=e,this}},{key:"onAny",value:function(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}},{key:"prependAny",value:function(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}},{key:"offAny",value:function(e){if(!this._anyListeners)return this;if(e){for(var t=this._anyListeners,n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyListeners=[];return this}},{key:"listenersAny",value:function(){return this._anyListeners||[]}},{key:"onAnyOutgoing",value:function(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}},{key:"prependAnyOutgoing",value:function(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}},{key:"offAnyOutgoing",value:function(e){if(!this._anyOutgoingListeners)return this;if(e){for(var t=this._anyOutgoingListeners,n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyOutgoingListeners=[];return this}},{key:"listenersAnyOutgoing",value:function(){return this._anyOutgoingListeners||[]}},{key:"notifyOutgoingListeners",value:function(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){var t,n=j(this._anyOutgoingListeners.slice());try{for(n.s();!(t=n.n()).done;)t.value.apply(this,e.data)}catch(e){n.e(e)}finally{n.f()}}}}])}(ir);function oo(e){this.ms=(e=e||{}).min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}oo.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=0==(1&Math.floor(10*t))?e-n:e+n}return 0|Math.min(e,this.max)},oo.prototype.reset=function(){this.attempts=0},oo.prototype.setMin=function(e){this.ms=e},oo.prototype.setMax=function(e){this.max=e},oo.prototype.setJitter=function(e){this.jitter=e};var io=function(e){function t(e,n){var r,o;R(this,t),(r=T(this,t)).nsps={},r.subs=[],e&&"object"===K(e)&&(n=e,e=void 0),(n=n||{}).path=n.path||"/socket.io",r.opts=n,ur(r,n),r.reconnection(!1!==n.reconnection),r.reconnectionAttempts(n.reconnectionAttempts||Infinity),r.reconnectionDelay(n.reconnectionDelay||1e3),r.reconnectionDelayMax(n.reconnectionDelayMax||5e3),r.randomizationFactor(null!==(o=n.randomizationFactor)&&void 0!==o?o:.5),r.backoff=new oo({min:r.reconnectionDelay(),max:r.reconnectionDelayMax(),jitter:r.randomizationFactor()}),r.timeout(null==n.timeout?2e4:n.timeout),r._readyState="closed",r.uri=e;var i=n.parser||eo;return r.encoder=new i.Encoder,r.decoder=new i.Decoder,r._autoConnect=!1!==n.autoConnect,r._autoConnect&&r.open(),r}return M(t,e),I(t,[{key:"reconnection",value:function(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection}},{key:"reconnectionAttempts",value:function(e){return void 0===e?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}},{key:"reconnectionDelay",value:function(e){var t;return void 0===e?this._reconnectionDelay:(this._reconnectionDelay=e,null===(t=this.backoff)||void 0===t||t.setMin(e),this)}},{key:"randomizationFactor",value:function(e){var t;return void 0===e?this._randomizationFactor:(this._randomizationFactor=e,null===(t=this.backoff)||void 0===t||t.setJitter(e),this)}},{key:"reconnectionDelayMax",value:function(e){var t;return void 0===e?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,null===(t=this.backoff)||void 0===t||t.setMax(e),this)}},{key:"timeout",value:function(e){return arguments.length?(this._timeout=e,this):this._timeout}},{key:"maybeReconnectOnOpen",value:function(){!this._reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}},{key:"open",value:function(e){var t=this;if(~this._readyState.indexOf("open"))return this;this.engine=new Mr(this.uri,this.opts);var n=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;var o=to(n,"open",(function(){r.onopen(),e&&e()})),i=function(n){t.cleanup(),t._readyState="closed",t.emitReserved("error",n),e?e(n):t.maybeReconnectOnOpen()},a=to(n,"error",i);if(!1!==this._timeout){var s=this.setTimeoutFn((function(){o(),i(new Error("timeout")),n.close()}),this._timeout);this.opts.autoUnref&&s.unref(),this.subs.push((function(){t.clearTimeoutFn(s)}))}return this.subs.push(o),this.subs.push(a),this}},{key:"connect",value:function(e){return this.open(e)}},{key:"onopen",value:function(){this.cleanup(),this._readyState="open",this.emitReserved("open");var e=this.engine;this.subs.push(to(e,"ping",this.onping.bind(this)),to(e,"data",this.ondata.bind(this)),to(e,"error",this.onerror.bind(this)),to(e,"close",this.onclose.bind(this)),to(this.decoder,"decoded",this.ondecoded.bind(this)))}},{key:"onping",value:function(){this.emitReserved("ping")}},{key:"ondata",value:function(e){try{this.decoder.add(e)}catch(e){this.onclose("parse error",e)}}},{key:"ondecoded",value:function(e){var t=this;Nr((function(){t.emitReserved("packet",e)}),this.setTimeoutFn)}},{key:"onerror",value:function(e){this.emitReserved("error",e)}},{key:"socket",value:function(e,t){var n=this.nsps[e];return n?this._autoConnect&&!n.active&&n.connect():(n=new ro(this,e,t),this.nsps[e]=n),n}},{key:"_destroy",value:function(e){for(var t=0,n=Object.keys(this.nsps);t<n.length;t++)if(this.nsps[n[t]].active)return;this._close()}},{key:"_packet",value:function(e){for(var t=this.encoder.encode(e),n=0;n<t.length;n++)this.engine.write(t[n],e.options)}},{key:"cleanup",value:function(){this.subs.forEach((function(e){return e()})),this.subs.length=0,this.decoder.destroy()}},{key:"_close",value:function(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}},{key:"disconnect",value:function(){return this._close()}},{key:"onclose",value:function(e,t){this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}},{key:"reconnect",value:function(){var e=this;if(this._reconnecting||this.skipReconnect)return this;var t=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{var n=this.backoff.duration();this._reconnecting=!0;var r=this.setTimeoutFn((function(){t.skipReconnect||(e.emitReserved("reconnect_attempt",t.backoff.attempts),t.skipReconnect||t.open((function(n){n?(t._reconnecting=!1,t.reconnect(),e.emitReserved("reconnect_error",n)):t.onreconnect()})))}),n);this.opts.autoUnref&&r.unref(),this.subs.push((function(){e.clearTimeoutFn(r)}))}}},{key:"onreconnect",value:function(){var e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}])}(ir),ao={};function so(e,t){"object"===K(e)&&(t=e,e=void 0);var n,r=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2?arguments[2]:void 0,r=e;n=n||"undefined"!=typeof location&&location,null==e&&(e=n.protocol+"//"+n.host),"string"==typeof e&&("/"===e.charAt(0)&&(e="/"===e.charAt(1)?n.protocol+e:n.host+e),/^(https?|wss?):\/\//.test(e)||(e=void 0!==n?n.protocol+"//"+e:"https://"+e),r=Fr(e)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";var o=-1!==r.host.indexOf(":")?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+o+":"+r.port+t,r.href=r.protocol+"://"+o+(n&&n.port===r.port?"":":"+r.port),r}(e,(t=t||{}).path||"/socket.io"),o=r.source,i=r.id;return t.forceNew||t["force new connection"]||!1===t.multiplex||ao[i]&&r.path in ao[i].nsps?n=new io(o,t):(ao[i]||(ao[i]=new io(o,t)),n=ao[i]),r.query&&!t.query&&(t.query=r.queryKey),n.socket(r.path,t)}Object.assign(so,{Manager:io,Socket:ro,io:so,connect:so});var lo=a.createSvgIcon([i.jsx("path",{d:"M17 11c.34 0 .67.04 1 .09V6.27L10.5 3 3 6.27v4.91c0 4.54 3.2 8.79 7.5 9.82.55-.13 1.08-.32 1.6-.55-.69-.98-1.1-2.17-1.1-3.45 0-3.31 2.69-6 6-6"},"0"),i.jsx("path",{d:"M17 13c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4m0 1.38c.62 0 1.12.51 1.12 1.12s-.51 1.12-1.12 1.12-1.12-.51-1.12-1.12.5-1.12 1.12-1.12m0 5.37c-.93 0-1.74-.46-2.24-1.17.05-.72 1.51-1.08 2.24-1.08s2.19.36 2.24 1.08c-.5.71-1.31 1.17-2.24 1.17"},"1")],"AdminPanelSettings"),co=a.createSvgIcon(i.jsx("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6zM19 4h-3.5l-1-1h-5l-1 1H5v2h14z"}),"Delete"),uo=a.createSvgIcon(i.jsx("path",{d:"M21 3.01H3c-1.1 0-2 .9-2 2V9h2V4.99h18v14.03H3V15H1v4.01c0 1.1.9 1.98 2 1.98h18c1.1 0 2-.88 2-1.98v-14c0-1.11-.9-2-2-2M11 16l4-4-4-4v3H1v2h10z"}),"Input"),fo=a.createSvgIcon(i.jsx("path",{d:"M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4m0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4"}),"Person"),ho=a.createSvgIcon(i.jsx("path",{d:"M16.54 11 13 7.46l1.41-1.41 2.12 2.12 4.24-4.24 1.41 1.41zM11 7H2v2h9zm10 6.41L19.59 12 17 14.59 14.41 12 13 13.41 15.59 16 13 18.59 14.41 20 17 17.41 19.59 20 21 18.59 18.41 16zM11 15H2v2h9z"}),"Rule"),po=function(){function e(e){var t=this;this._insertTag=function(e){t.container.insertBefore(e,0===t.tags.length?t.insertionPoint?t.insertionPoint.nextSibling:t.prepend?t.container.firstChild:t.before:t.tags[t.tags.length-1].nextSibling),t.tags.push(e)},this.isSpeedy=void 0===e.speedy?"production"===ae.env.NODE_ENV:e.speedy,this.tags=[],this.ctr=0,this.nonce=e.nonce,this.key=e.key,this.container=e.container,this.prepend=e.prepend,this.insertionPoint=e.insertionPoint,this.before=null}var t=e.prototype;return t.hydrate=function(e){e.forEach(this._insertTag)},t.insert=function(e){this.ctr%(this.isSpeedy?65e3:1)==0&&this._insertTag(function(e){var t=document.createElement("style");return t.setAttribute("data-emotion",e.key),void 0!==e.nonce&&t.setAttribute("nonce",e.nonce),t.appendChild(document.createTextNode("")),t.setAttribute("data-s",""),t}(this));var t=this.tags[this.tags.length-1];if("production"!==ae.env.NODE_ENV){var n=64===e.charCodeAt(0)&&105===e.charCodeAt(1);n&&this._alreadyInsertedOrderInsensitiveRule&&console.error("You're attempting to insert the following rule:\n"+e+"\n\n`@import` rules must be before all other types of rules in a stylesheet but other rules have already been inserted. Please ensure that `@import` rules are before all other rules."),this._alreadyInsertedOrderInsensitiveRule=this._alreadyInsertedOrderInsensitiveRule||!n}if(this.isSpeedy){var r=function(e){if(e.sheet)return e.sheet;for(var t=0;t<document.styleSheets.length;t++)if(document.styleSheets[t].ownerNode===e)return document.styleSheets[t]}(t);try{r.insertRule(e,r.cssRules.length)}catch(t){"production"===ae.env.NODE_ENV||/:(-moz-placeholder|-moz-focus-inner|-moz-focusring|-ms-input-placeholder|-moz-read-write|-moz-read-only|-ms-clear|-ms-expand|-ms-reveal){/.test(e)||console.error('There was a problem inserting the following rule: "'+e+'"',t)}}else t.appendChild(document.createTextNode(e));this.ctr++},t.flush=function(){this.tags.forEach((function(e){return e.parentNode&&e.parentNode.removeChild(e)})),this.tags=[],this.ctr=0,"production"!==ae.env.NODE_ENV&&(this._alreadyInsertedOrderInsensitiveRule=!1)},e}(),go="-ms-",mo="-moz-",yo="-webkit-",_o="comm",vo="rule",bo="decl",xo="@keyframes",wo=Math.abs,So=String.fromCharCode,Co=Object.assign;function Ao(e){return e.trim()}function ko(e,t,n){return e.replace(t,n)}function No(e,t){return e.indexOf(t)}function To(e,t){return 0|e.charCodeAt(t)}function Ro(e,t,n){return e.slice(t,n)}function Eo(e){return e.length}function Io(e){return e.length}function jo(e,t){return t.push(e),e}var Do=1,Oo=1,Fo=0,Mo=0,Lo=0,Po="";function Bo(e,t,n,r,o,i,a){return{value:e,root:t,parent:n,type:r,props:o,children:i,line:Do,column:Oo,length:a,return:""}}function qo(e,t){return Co(Bo("",null,null,"",null,null,0),e,{length:-e.length},t)}function Uo(){return Lo=Mo>0?To(Po,--Mo):0,Oo--,10===Lo&&(Oo=1,Do--),Lo}function zo(){return Lo=Mo<Fo?To(Po,Mo++):0,Oo++,10===Lo&&(Oo=1,Do++),Lo}function $o(){return To(Po,Mo)}function Ho(){return Mo}function Go(e,t){return Ro(Po,e,t)}function Vo(e){switch(e){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function Wo(e){return Do=Oo=1,Fo=Eo(Po=e),Mo=0,[]}function Jo(e){return Po="",e}function Ko(e){return Ao(Go(Mo-1,Zo(91===e?e+2:40===e?e+1:e)))}function Yo(e){for(;(Lo=$o())&&Lo<33;)zo();return Vo(e)>2||Vo(Lo)>3?"":" "}function Xo(e,t){for(;--t&&zo()&&!(Lo<48||Lo>102||Lo>57&&Lo<65||Lo>70&&Lo<97););return Go(e,Ho()+(t<6&&32==$o()&&32==zo()))}function Zo(e){for(;zo();)switch(Lo){case e:return Mo;case 34:case 39:34!==e&&39!==e&&Zo(Lo);break;case 40:41===e&&Zo(e);break;case 92:zo()}return Mo}function Qo(e,t){for(;zo()&&e+Lo!==57&&(e+Lo!==84||47!==$o()););return"/*"+Go(t,Mo-1)+"*"+So(47===e?e:zo())}function ei(e){for(;!Vo($o());)zo();return Go(e,Mo)}function ti(e){return Jo(ni("",null,null,null,[""],e=Wo(e),0,[0],e))}function ni(e,t,n,r,o,i,a,s,l){for(var c=0,u=0,d=a,f=0,h=0,p=0,g=1,m=1,y=1,_=0,v="",b=o,x=i,w=r,S=v;m;)switch(p=_,_=zo()){case 40:if(108!=p&&58==To(S,d-1)){-1!=No(S+=ko(Ko(_),"&","&\f"),"&\f")&&(y=-1);break}case 34:case 39:case 91:S+=Ko(_);break;case 9:case 10:case 13:case 32:S+=Yo(p);break;case 92:S+=Xo(Ho()-1,7);continue;case 47:switch($o()){case 42:case 47:jo(oi(Qo(zo(),Ho()),t,n),l);break;default:S+="/"}break;case 123*g:s[c++]=Eo(S)*y;case 125*g:case 59:case 0:switch(_){case 0:case 125:m=0;case 59+u:-1==y&&(S=ko(S,/\f/g,"")),h>0&&Eo(S)-d&&jo(h>32?ii(S+";",r,n,d-1):ii(ko(S," ","")+";",r,n,d-2),l);break;case 59:S+=";";default:if(jo(w=ri(S,t,n,c,u,o,s,v,b=[],x=[],d),i),123===_)if(0===u)ni(S,t,w,w,b,i,d,s,x);else switch(99===f&&110===To(S,3)?100:f){case 100:case 108:case 109:case 115:ni(e,w,w,r&&jo(ri(e,w,w,0,0,o,s,v,o,b=[],d),x),o,x,d,s,r?b:x);break;default:ni(S,w,w,w,[""],x,0,s,x)}}c=u=h=0,g=y=1,v=S="",d=a;break;case 58:d=1+Eo(S),h=p;default:if(g<1)if(123==_)--g;else if(125==_&&0==g++&&125==Uo())continue;switch(S+=So(_),_*g){case 38:y=u>0?1:(S+="\f",-1);break;case 44:s[c++]=(Eo(S)-1)*y,y=1;break;case 64:45===$o()&&(S+=Ko(zo())),f=$o(),u=d=Eo(v=S+=ei(Ho())),_++;break;case 45:45===p&&2==Eo(S)&&(g=0)}}return i}function ri(e,t,n,r,o,i,a,s,l,c,u){for(var d=o-1,f=0===o?i:[""],h=Io(f),p=0,g=0,m=0;p<r;++p)for(var y=0,_=Ro(e,d+1,d=wo(g=a[p])),v=e;y<h;++y)(v=Ao(g>0?f[y]+" "+_:ko(_,/&\f/g,f[y])))&&(l[m++]=v);return Bo(e,t,n,0===o?vo:s,l,c,u)}function oi(e,t,n){return Bo(e,t,n,_o,So(Lo),Ro(e,2,-2),0)}function ii(e,t,n,r){return Bo(e,t,n,bo,Ro(e,0,r),Ro(e,r+1,-1),r)}function ai(e,t){for(var n="",r=Io(e),o=0;o<r;o++)n+=t(e[o],o,e,t)||"";return n}function si(e,t,n,r){switch(e.type){case"@layer":if(e.children.length)break;case"@import":case bo:return e.return=e.return||e.value;case _o:return"";case xo:return e.return=e.value+"{"+ai(e.children,r)+"}";case vo:e.value=e.props.join(",")}return Eo(n=ai(e.children,r))?e.return=e.value+"{"+n+"}":""}function li(e){var t=Object.create(null);return function(n){return void 0===t[n]&&(t[n]=e(n)),t[n]}}var ci=function(e,t,n){for(var r=0,o=0;r=o,o=$o(),38===r&&12===o&&(t[n]=1),!Vo(o);)zo();return Go(e,Mo)},ui=new WeakMap,di=function(e){if("rule"===e.type&&e.parent&&!(e.length<1)){for(var t=e.value,n=e.parent,r=e.column===n.column&&e.line===n.line;"rule"!==n.type;)if(!(n=n.parent))return;if((1!==e.props.length||58===t.charCodeAt(0)||ui.get(n))&&!r){ui.set(e,!0);for(var o=[],i=function(e,t){return Jo(function(e,t){var n=-1,r=44;do{switch(Vo(r)){case 0:38===r&&12===$o()&&(t[n]=1),e[n]+=ci(Mo-1,t,n);break;case 2:e[n]+=Ko(r);break;case 4:if(44===r){e[++n]=58===$o()?"&\f":"",t[n]=e[n].length;break}default:e[n]+=So(r)}}while(r=zo());return e}(Wo(e),t))}(t,o),a=n.props,s=0,l=0;s<i.length;s++)for(var c=0;c<a.length;c++,l++)e.props[l]=o[s]?i[s].replace(/&\f/g,a[c]):a[c]+" "+i[s]}}},fi=function(e){if("decl"===e.type){var t=e.value;108===t.charCodeAt(0)&&98===t.charCodeAt(2)&&(e.return="",e.value="")}},hi=function(e){return"comm"===e.type&&e.children.indexOf("emotion-disable-server-rendering-unsafe-selector-warning-please-do-not-use-this-the-warning-exists-for-a-reason")>-1},pi=function(e){return 105===e.type.charCodeAt(1)&&64===e.type.charCodeAt(0)},gi=function(e){e.type="",e.value="",e.return="",e.children="",e.props=""},mi=function(e,t,n){pi(e)&&(e.parent?(console.error("`@import` rules can't be nested inside other rules. Please move it to the top level and put it before regular rules. Keep in mind that they can only be used within global styles."),gi(e)):function(e,t){for(var n=e-1;n>=0;n--)if(!pi(t[n]))return!0;return!1}(t,n)&&(console.error("`@import` rules can't be after other rules. Please put your `@import` rules before your other rules."),gi(e)))};function yi(e,t){switch(function(e,t){return 45^To(e,0)?(((t<<2^To(e,0))<<2^To(e,1))<<2^To(e,2))<<2^To(e,3):0}(e,t)){case 5103:return yo+"print-"+e+e;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return yo+e+e;case 5349:case 4246:case 4810:case 6968:case 2756:return yo+e+mo+e+go+e+e;case 6828:case 4268:return yo+e+go+e+e;case 6165:return yo+e+go+"flex-"+e+e;case 5187:return yo+e+ko(e,/(\w+).+(:[^]+)/,yo+"box-$1$2"+go+"flex-$1$2")+e;case 5443:return yo+e+go+"flex-item-"+ko(e,/flex-|-self/,"")+e;case 4675:return yo+e+go+"flex-line-pack"+ko(e,/align-content|flex-|-self/,"")+e;case 5548:return yo+e+go+ko(e,"shrink","negative")+e;case 5292:return yo+e+go+ko(e,"basis","preferred-size")+e;case 6060:return yo+"box-"+ko(e,"-grow","")+yo+e+go+ko(e,"grow","positive")+e;case 4554:return yo+ko(e,/([^-])(transform)/g,"$1"+yo+"$2")+e;case 6187:return ko(ko(ko(e,/(zoom-|grab)/,yo+"$1"),/(image-set)/,yo+"$1"),e,"")+e;case 5495:case 3959:return ko(e,/(image-set\([^]*)/,yo+"$1$`$1");case 4968:return ko(ko(e,/(.+:)(flex-)?(.*)/,yo+"box-pack:$3"+go+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+yo+e+e;case 4095:case 3583:case 4068:case 2532:return ko(e,/(.+)-inline(.+)/,yo+"$1$2")+e;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(Eo(e)-1-t>6)switch(To(e,t+1)){case 109:if(45!==To(e,t+4))break;case 102:return ko(e,/(.+:)(.+)-([^]+)/,"$1"+yo+"$2-$3$1"+mo+(108==To(e,t+3)?"$3":"$2-$3"))+e;case 115:return~No(e,"stretch")?yi(ko(e,"stretch","fill-available"),t)+e:e}break;case 4949:if(115!==To(e,t+1))break;case 6444:switch(To(e,Eo(e)-3-(~No(e,"!important")&&10))){case 107:return ko(e,":",":"+yo)+e;case 101:return ko(e,/(.+:)([^;!]+)(;|!.+)?/,"$1"+yo+(45===To(e,14)?"inline-":"")+"box$3$1"+yo+"$2$3$1"+go+"$2box$3")+e}break;case 5936:switch(To(e,t+11)){case 114:return yo+e+go+ko(e,/[svh]\w+-[tblr]{2}/,"tb")+e;case 108:return yo+e+go+ko(e,/[svh]\w+-[tblr]{2}/,"tb-rl")+e;case 45:return yo+e+go+ko(e,/[svh]\w+-[tblr]{2}/,"lr")+e}return yo+e+go+e+e}return e}var _i=[function(e,t,n,r){if(e.length>-1&&!e.return)switch(e.type){case bo:e.return=yi(e.value,e.length);break;case xo:return ai([qo(e,{value:ko(e.value,"@","@"+yo)})],r);case vo:if(e.length)return function(e,t){return e.map(t).join("")}(e.props,(function(t){switch(function(e,t){return(e=/(::plac\w+|:read-\w+)/.exec(e))?e[0]:e}(t)){case":read-only":case":read-write":return ai([qo(e,{props:[ko(t,/:(read-\w+)/,":-moz-$1")]})],r);case"::placeholder":return ai([qo(e,{props:[ko(t,/:(plac\w+)/,":"+yo+"input-$1")]}),qo(e,{props:[ko(t,/:(plac\w+)/,":-moz-$1")]}),qo(e,{props:[ko(t,/:(plac\w+)/,go+"input-$1")]})],r)}return""}))}}],vi=function(e){var t=e.key;if("production"!==ae.env.NODE_ENV&&!t)throw new Error("You have to configure `key` for your cache. Please make sure it's unique (and not equal to 'css') as it's used for linking styles to your cache.\nIf multiple caches share the same key they might \"fight\" for each other's style elements.");if("css"===t){var n=document.querySelectorAll("style[data-emotion]:not([data-s])");Array.prototype.forEach.call(n,(function(e){-1!==e.getAttribute("data-emotion").indexOf(" ")&&(document.head.appendChild(e),e.setAttribute("data-s",""))}))}var r=e.stylisPlugins||_i;if("production"!==ae.env.NODE_ENV&&/[^a-z-]/.test(t))throw new Error('Emotion key must only contain lower case alphabetical characters and - but "'+t+'" was passed');var o,i,a={},s=[];o=e.container||document.head,Array.prototype.forEach.call(document.querySelectorAll('style[data-emotion^="'+t+' "]'),(function(e){for(var t=e.getAttribute("data-emotion").split(" "),n=1;n<t.length;n++)a[t[n]]=!0;s.push(e)}));var l=[di,fi];"production"!==ae.env.NODE_ENV&&l.push(function(e){return function(t,n,r){if("rule"===t.type&&!e.compat){var o=t.value.match(/(:first|:nth|:nth-last)-child/g);if(o){for(var i=t.parent?t.parent.children:r,a=i.length-1;a>=0;a--){var s=i[a];if(s.line<t.line)break;if(s.column<t.column){if(hi(s))return;break}}o.forEach((function(e){console.error('The pseudo class "'+e+'" is potentially unsafe when doing server-side rendering. Try changing it to "'+e.split("-child")[0]+'-of-type".')}))}}}}({get compat(){return h.compat}}),mi);var c,u,d=[si,"production"!==ae.env.NODE_ENV?function(e){e.root||(e.return?c.insert(e.return):e.value&&e.type!==_o&&c.insert(e.value+"{}"))}:(u=function(e){c.insert(e)},function(e){e.root||(e=e.return)&&u(e)})],f=function(e){var t=Io(e);return function(n,r,o,i){for(var a="",s=0;s<t;s++)a+=e[s](n,r,o,i)||"";return a}}(l.concat(r,d));i=function(e,t,n,r){c=n,"production"!==ae.env.NODE_ENV&&void 0!==t.map&&(c={insert:function(e){n.insert(e+t.map)}}),function(e){ai(ti(e),f)}(e?e+"{"+t.styles+"}":t.styles),r&&(h.inserted[t.name]=!0)};var h={key:t,sheet:new po({key:t,container:o,nonce:e.nonce,speedy:e.speedy,prepend:e.prepend,insertionPoint:e.insertionPoint}),nonce:e.nonce,inserted:a,registered:{},insert:i};return h.sheet.hydrate(s),h};function bi(){return bi=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},bi.apply(this,arguments)}function xi(e,t,n){var r="";return n.split(" ").forEach((function(n){void 0!==e[n]?t.push(e[n]+";"):r+=n+" "})),r}var wi=function(e,t,n){var r=e.key+"-"+t.name;!1===n&&void 0===e.registered[r]&&(e.registered[r]=t.styles)},Si=function(e,t,n){wi(e,t,n);var r=e.key+"-"+t.name;if(void 0===e.inserted[t.name]){var o=t;do{e.insert(t===o?"."+r:"",o,e.sheet,!0),o=o.next}while(void 0!==o)}},Ci={animationIterationCount:1,aspectRatio:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1},Ai="You have illegal escape sequence in your template literal, most likely inside content's property value.\nBecause you write your CSS inside a JavaScript string you actually have to do double escaping, so for example \"content: '\\00d7';\" should become \"content: '\\\\00d7';\".\nYou can read more about this here:\nhttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#ES2018_revision_of_illegal_escape_sequences",ki=/[A-Z]|^ms/g,Ni=/_EMO_([^_]+?)_([^]*?)_EMO_/g,Ti=function(e){return 45===e.charCodeAt(1)},Ri=function(e){return null!=e&&"boolean"!=typeof e},Ei=li((function(e){return Ti(e)?e:e.replace(ki,"-$&").toLowerCase()})),Ii=function(e,t){switch(e){case"animation":case"animationName":if("string"==typeof t)return t.replace(Ni,(function(e,t,n){return Ui={name:t,styles:n,next:Ui},t}))}return 1===Ci[e]||Ti(e)||"number"!=typeof t||0===t?t:t+"px"};if("production"!==ae.env.NODE_ENV){var ji=/(var|attr|counters?|url|element|(((repeating-)?(linear|radial))|conic)-gradient)\(|(no-)?(open|close)-quote/,Di=["normal","none","initial","inherit","unset"],Oi=Ii,Fi=/^-ms-/,Mi=/-(.)/g,Li={};Ii=function(e,t){if("content"===e&&("string"!=typeof t||-1===Di.indexOf(t)&&!ji.test(t)&&(t.charAt(0)!==t.charAt(t.length-1)||'"'!==t.charAt(0)&&"'"!==t.charAt(0))))throw new Error("You seem to be using a value for 'content' without quotes, try replacing it with `content: '\""+t+"\"'`");var n=Oi(e,t);return""===n||Ti(e)||-1===e.indexOf("-")||void 0!==Li[e]||(Li[e]=!0,console.error("Using kebab-case for css properties in objects is not supported. Did you mean "+e.replace(Fi,"ms-").replace(Mi,(function(e,t){return t.toUpperCase()}))+"?")),n}}var Pi="Component selectors can only be used in conjunction with @emotion/babel-plugin, the swc Emotion plugin, or another Emotion-aware compiler transform.";function Bi(e,t,n){if(null==n)return"";if(void 0!==n.__emotion_styles){if("production"!==ae.env.NODE_ENV&&"NO_COMPONENT_SELECTOR"===n.toString())throw new Error(Pi);return n}switch(K(n)){case"boolean":return"";case"object":if(1===n.anim)return Ui={name:n.name,styles:n.styles,next:Ui},n.name;if(void 0!==n.styles){var r=n.next;if(void 0!==r)for(;void 0!==r;)Ui={name:r.name,styles:r.styles,next:Ui},r=r.next;var o=n.styles+";";return"production"!==ae.env.NODE_ENV&&void 0!==n.map&&(o+=n.map),o}return function(e,t,n){var r="";if(Array.isArray(n))for(var o=0;o<n.length;o++)r+=Bi(e,t,n[o])+";";else for(var i in n){var a=n[i];if("object"!==K(a))null!=t&&void 0!==t[a]?r+=i+"{"+t[a]+"}":Ri(a)&&(r+=Ei(i)+":"+Ii(i,a)+";");else{if("NO_COMPONENT_SELECTOR"===i&&"production"!==ae.env.NODE_ENV)throw new Error(Pi);if(!Array.isArray(a)||"string"!=typeof a[0]||null!=t&&void 0!==t[a[0]]){var s=Bi(e,t,a);switch(i){case"animation":case"animationName":r+=Ei(i)+":"+s+";";break;default:"production"!==ae.env.NODE_ENV&&"undefined"===i&&console.error("You have passed in falsy value as style object's key (can happen when in example you pass unexported component as computed key)."),r+=i+"{"+s+"}"}}else for(var l=0;l<a.length;l++)Ri(a[l])&&(r+=Ei(i)+":"+Ii(i,a[l])+";")}}return r}(e,t,n);case"function":if(void 0!==e){var i=Ui,a=n(e);return Ui=i,Bi(e,t,a)}"production"!==ae.env.NODE_ENV&&console.error("Functions that are interpolated in css calls will be stringified.\nIf you want to have a css call based on props, create a function that returns a css call like this\nlet dynamicStyle = (props) => css`color: ${props.color}`\nIt can be called directly with props or interpolated in a styled call like this\nlet SomeComponent = styled('div')`${dynamicStyle}`");break;case"string":if("production"!==ae.env.NODE_ENV){var s=[],l=n.replace(Ni,(function(e,t,n){var r="animation"+s.length;return s.push("const "+r+" = keyframes`"+n.replace(/^@keyframes animation-\w+/,"")+"`"),"${"+r+"}"}));s.length&&console.error("`keyframes` output got interpolated into plain string, please wrap it with `css`.\n\nInstead of doing this:\n\n"+[].concat(s,["`"+l+"`"]).join("\n")+"\n\nYou should wrap it with `css` like this:\n\ncss`"+l+"`")}}if(null==t)return n;var c=t[n];return void 0!==c?c:n}var qi,Ui,zi=/label:\s*([^\s;\n{]+)\s*(;|$)/g;"production"!==ae.env.NODE_ENV&&(qi=/\/\*#\ssourceMappingURL=data:application\/json;\S+\s+\*\//g);var $i=function(e,t,n){if(1===e.length&&"object"===K(e[0])&&null!==e[0]&&void 0!==e[0].styles)return e[0];var r=!0,o="";Ui=void 0;var i,a=e[0];null==a||void 0===a.raw?(r=!1,o+=Bi(n,t,a)):("production"!==ae.env.NODE_ENV&&void 0===a[0]&&console.error(Ai),o+=a[0]);for(var s=1;s<e.length;s++)o+=Bi(n,t,e[s]),r&&("production"!==ae.env.NODE_ENV&&void 0===a[s]&&console.error(Ai),o+=a[s]);"production"!==ae.env.NODE_ENV&&(o=o.replace(qi,(function(e){return i=e,""}))),zi.lastIndex=0;for(var l,c="";null!==(l=zi.exec(o));)c+="-"+l[1];var u=function(e){for(var t,n=0,r=0,o=e.length;o>=4;++r,o-=4)t=1540483477*(65535&(t=255&e.charCodeAt(r)|(255&e.charCodeAt(++r))<<8|(255&e.charCodeAt(++r))<<16|(255&e.charCodeAt(++r))<<24))+(59797*(t>>>16)<<16),n=1540483477*(65535&(t^=t>>>24))+(59797*(t>>>16)<<16)^1540483477*(65535&n)+(59797*(n>>>16)<<16);switch(o){case 3:n^=(255&e.charCodeAt(r+2))<<16;case 2:n^=(255&e.charCodeAt(r+1))<<8;case 1:n=1540483477*(65535&(n^=255&e.charCodeAt(r)))+(59797*(n>>>16)<<16)}return(((n=1540483477*(65535&(n^=n>>>13))+(59797*(n>>>16)<<16))^n>>>15)>>>0).toString(36)}(o)+c;return"production"!==ae.env.NODE_ENV?{name:u,styles:o,map:i,next:Ui,toString:function(){return"You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."}}:{name:u,styles:o,next:Ui}},Hi=!!w.useInsertionEffect&&w.useInsertionEffect||function(e){return e()},Gi={}.hasOwnProperty,Vi=w.createContext("undefined"!=typeof HTMLElement?vi({key:"css"}):null);"production"!==ae.env.NODE_ENV&&(Vi.displayName="EmotionCacheContext");var Wi=function(e){return u.forwardRef((function(t,n){var r=u.useContext(Vi);return e(t,r,n)}))},Ji=w.createContext({});"production"!==ae.env.NODE_ENV&&(Ji.displayName="EmotionThemeContext");var Ki="__EMOTION_TYPE_PLEASE_DO_NOT_USE__",Yi="__EMOTION_LABEL_PLEASE_DO_NOT_USE__",Xi=function(e){var t=e.cache,n=e.serialized,r=e.isStringTag;return wi(t,n,r),Hi((function(){return Si(t,n,r)})),null},Zi=Wi((function(e,t,n){var r=e.css;"string"==typeof r&&void 0!==t.registered[r]&&(r=t.registered[r]);var o=e[Ki],i=[r],a="";"string"==typeof e.className?a=xi(t.registered,i,e.className):null!=e.className&&(a=e.className+" ");var s=$i(i,void 0,w.useContext(Ji));if("production"!==ae.env.NODE_ENV&&-1===s.name.indexOf("-")){var l=e[Yi];l&&(s=$i([s,"label:"+l+";"]))}a+=t.key+"-"+s.name;var c={};for(var u in e)!Gi.call(e,u)||"css"===u||u===Ki||"production"!==ae.env.NODE_ENV&&u===Yi||(c[u]=e[u]);return c.ref=n,c.className=a,w.createElement(w.Fragment,null,w.createElement(Xi,{cache:t,serialized:s,isStringTag:"string"==typeof o}),w.createElement(o,c))}));"production"!==ae.env.NODE_ENV&&(Zi.displayName="EmotionCssPropInternal");var Qi={animationIterationCount:1,aspectRatio:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,scale:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1};function ea(e){var t=Object.create(null);return function(n){return void 0===t[n]&&(t[n]=e(n)),t[n]}}var ta=/[A-Z]|^ms/g,na=/_EMO_([^_]+?)_([^]*?)_EMO_/g,ra=function(e){return 45===e.charCodeAt(1)},oa=function(e){return null!=e&&"boolean"!=typeof e},ia=ea((function(e){return ra(e)?e:e.replace(ta,"-$&").toLowerCase()})),aa=function(e,t){switch(e){case"animation":case"animationName":if("string"==typeof t)return t.replace(na,(function(e,t,n){return la={name:t,styles:n,next:la},t}))}return 1===Qi[e]||ra(e)||"number"!=typeof t||0===t?t:t+"px"};function sa(e,t,n){if(null==n)return"";if(void 0!==n.__emotion_styles)return n;switch(K(n)){case"boolean":return"";case"object":if(1===n.anim)return la={name:n.name,styles:n.styles,next:la},n.name;var r=n;if(void 0!==r.styles){var o=r.next;if(void 0!==o)for(;void 0!==o;)la={name:o.name,styles:o.styles,next:la},o=o.next;return r.styles+";"}return function(e,t,n){var r="";if(Array.isArray(n))for(var o=0;o<n.length;o++)r+=sa(e,t,n[o])+";";else for(var i in n){var a=n[i];if("object"!==K(a)){var s=a;null!=t&&void 0!==t[s]?r+=i+"{"+t[s]+"}":oa(s)&&(r+=ia(i)+":"+aa(i,s)+";")}else if(!Array.isArray(a)||"string"!=typeof a[0]||null!=t&&void 0!==t[a[0]]){var l=sa(e,t,a);switch(i){case"animation":case"animationName":r+=ia(i)+":"+l+";";break;default:r+=i+"{"+l+"}"}}else for(var c=0;c<a.length;c++)oa(a[c])&&(r+=ia(i)+":"+aa(i,a[c])+";")}return r}(e,t,n)}if(null==t)return n;var i=t[n];return void 0!==i?i:n}var la,ca=/label:\s*([^\s;{]+)\s*(;|$)/g,ua=function(e){for(var t=e.length,n=0,r="";n<t;n++){var o=e[n];if(null!=o){var i=void 0;switch(K(o)){case"boolean":break;case"object":if(Array.isArray(o))i=ua(o);else{var a=o;for(var s in i="",a)a[s]&&s&&(i&&(i+=" "),i+=s)}break;default:i=o}i&&(r&&(r+=" "),r+=i)}}return r},da=function(){return{createCssAndCx:function(e){var t=e.cache,n=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];var o=function(e,t,n){if(1===e.length&&"object"===K(e[0])&&null!==e[0]&&void 0!==e[0].styles)return e[0];var r=!0,o="";la=void 0;var i=e[0];null==i||void 0===i.raw?(r=!1,o+=sa(n,t,i)):o+=i[0];for(var a=1;a<e.length;a++)o+=sa(n,t,e[a]),r&&(o+=i[a]);ca.lastIndex=0;for(var s,l="";null!==(s=ca.exec(o));)l+="-"+s[1];var c=function(e){for(var t,n=0,r=0,o=e.length;o>=4;++r,o-=4)t=1540483477*(65535&(t=255&e.charCodeAt(r)|(255&e.charCodeAt(++r))<<8|(255&e.charCodeAt(++r))<<16|(255&e.charCodeAt(++r))<<24))+(59797*(t>>>16)<<16),n=1540483477*(65535&(t^=t>>>24))+(59797*(t>>>16)<<16)^1540483477*(65535&n)+(59797*(n>>>16)<<16);switch(o){case 3:n^=(255&e.charCodeAt(r+2))<<16;case 2:n^=(255&e.charCodeAt(r+1))<<8;case 1:n=1540483477*(65535&(n^=255&e.charCodeAt(r)))+(59797*(n>>>16)<<16)}return(((n=1540483477*(65535&(n^=n>>>13))+(59797*(n>>>16)<<16))^n>>>15)>>>0).toString(36)}(o)+l;return{name:c,styles:o,next:la}}(n,t.registered);!function(e,t,n){!function(e,t,n){var r=e.key+"-"+t.name;void 0===e.registered[r]&&(e.registered[r]=t.styles)}(e,t);var r=e.key+"-"+t.name;if(void 0===e.inserted[t.name]){var o=t;do{e.insert(t===o?"."+r:"",o,e.sheet,!0),o=o.next}while(void 0!==o)}}(t,o);var i="".concat(t.key,"-").concat(o.name),a=n[0];return function(e){return e instanceof Object&&!("styles"in e)&&!("length"in e)&&!("__emotion_styles"in e)}(a)&&ha.saveClassNameCSSObjectMapping(t,i,a),i};return{css:n,cx:function(){for(var e=arguments.length,r=new Array(e),o=0;o<e;o++)r[o]=arguments[o];var i=ua(r),a=ha.fixClassName(t,i,n);return function(e,t,n){var r=[],o=function(e,t,n){var r="";return n.split(" ").forEach((function(n){void 0!==e[n]?t.push(e[n]+";"):n&&(r+=n+" ")})),r}(e,r,n);return r.length<2?n:o+t(r)}(t.registered,n,a)}}}}}(),fa=da.createCssAndCx,ha=function(){var e=new WeakMap;return{saveClassNameCSSObjectMapping:function(t,n,r){var o=e.get(t);void 0===o&&(o=new Map,e.set(t,o)),o.set(n,r)},fixClassName:function(t,n,r){if(!n.includes(" "))return n;var o,i,a=e.get(t);return ua((o=n.split(" ").map((function(e){return[e,null==a?void 0:a.get(e)]})),i=!1,o.map((function(e){var t,n=G(e,2),r=n[0],o=n[1];if(void 0===o)return r;if(i)t={"&&":o};else for(var a in t=r,o)if(a.startsWith("@media")){i=!0;break}return t}))).map((function(e){return"string"==typeof e?e:r(e)})))}}}(),pa=function(){return u.useContext(Vi)};function ga(e){var t=e.useTheme,n=function(e){var t=e.useCache;return{useCssAndCx:function(){var e=t(),n=u.useMemo((function(){return fa({cache:e})}),[e]);return{css:n.css,cx:n.cx}}}}({useCache:pa}),r=n.useCssAndCx;return{makeStyles:function(){return function(e){var n="function"==typeof e?e:function(){return e};return function(e,o){var i=t(),a=r(),s=a.css,l=a.cx,c=u.useMemo((function(){for(var e=n(i),t={},r=0,o=Object.keys(e);r<o.length;r++){var a=o[r];t[a]=s(e[a])}return t}),[s,i]),d=null==o?void 0:o.props.classes,f=function(e){if(!(e instanceof Object)||"function"==typeof e)return e;var t=[];for(var n in e){var r=e[n],o=K(r);if("string"!==o&&("number"!==o||isNaN(r))&&"boolean"!==o&&null!=r)return e;t.push("".concat(n,":").concat(o,"_").concat(r))}return"xSqLiJdLMd9s".concat(t.join("|"))}(d),h=u.useMemo((function(){return d?function(e,t,n){if(!(t instanceof Object))return e;var r=Object.keys(t);if(0===r.length)return e;for(var o={},i=0,a=Object.keys(e);i<a.length;i++){var s=a[i];o[s]=n(e[s],t[s])}for(var l=0,c=r;l<c.length;l++){var u=c[l];if(!(u in e)){var d=t[u];"string"==typeof d&&(o[u]=d)}}return o}(c,d,l):c}),[c,f,l]);return{classes:h,theme:i,css:s,cx:l}}}}}}var ma=ga({useTheme:g.useTheme}).makeStyles,ya=a.createSvgIcon(i.jsx("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m1 15h-2v-6h2zm0-8h-2V7h2z"}),"Info"),_a=a.createSvgIcon(i.jsx("path",{d:"M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1M8 13h8v-2H8zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5"}),"Link"),va=a.createSvgIcon(i.jsx("path",{d:"M12 7c-2.76 0-5 2.24-5 5s2.24 5 5 5 5-2.24 5-5-2.24-5-5-5m0-5C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8"}),"RadioButtonChecked"),ba=a.createSvgIcon(i.jsx("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8"}),"RadioButtonUnchecked");function xa(e){const{attributes:t}=e,n=t.get("gff_name");return n?n[0]:""}function wa(e){const{attributes:t}=e,n=t.get("gff_id"),r=t.get("transcript_id"),o=t.get("exon_id"),i=t.get("protein_id");return n?n[0]:r?r[0]:o?o[0]:i?i[0]:""}function Sa(e){const t=xa(e),n=wa(e);return t?`: ${t}`:n?`: ${n}`:""}function Ca(e,t,n=!1){const r=[];r.push(e);for(const t of function(e){const t=[];let{parent:n}=e;for(;n;)t.push(n),({parent:n}=n);return t}(e))r.push(t);const o=function(e){const t=[];if(e.children)for(const[,n]of e.children)t.push(n);return t}(e);for(const e of o)e.min<t&&e.max>=t&&r.push(e);if(!n)return r;if(e.parent){const n=e.parent.children;if(n)for(const[,o]of n)o._id!=e._id&&o.min<t&&o.max>=t&&r.push(o)}return r}function Aa(e,t){if(e.attributes){const n={};for(const[r,o]of Object.entries(e.attributes))t.has(r)||(n[r]=o);e.attributes=0===Object.keys(n).length?void 0:n}if(e.children){const n={};for(const[r,o]of Object.entries(e.children)){const e={...o};Aa(e,t),n[r]=e}e.children=n}}var ka,Na,Ta=a.createSvgIcon(i.jsx("path",{d:"m7.58 16.89 5.77-4.07c.56-.4.56-1.24 0-1.63L7.58 7.11C6.91 6.65 6 7.12 6 7.93v8.14c0 .81.91 1.28 1.58.82M16 7v10c0 .55.45 1 1 1s1-.45 1-1V7c0-.55-.45-1-1-1s-1 .45-1 1"}),"SkipNextRounded"),Ra=a.createSvgIcon(i.jsx("path",{d:"M7 6c.55 0 1 .45 1 1v10c0 .55-.45 1-1 1s-1-.45-1-1V7c0-.55.45-1 1-1m3.66 6.82 5.77 4.07c.66.47 1.58-.01 1.58-.82V7.93c0-.81-.91-1.28-1.58-.82l-5.77 4.07c-.57.4-.57 1.24 0 1.64"}),"SkipPreviousRounded"),Ea=function(e,t){return t.some((function(t){return e instanceof t}))},Ia=new WeakMap,ja=new WeakMap,Da=new WeakMap,Oa=new WeakMap,Fa=new WeakMap,Ma={get:function(e,t,n){if(e instanceof IDBTransaction){if("done"===t)return ja.get(e);if("objectStoreNames"===t)return e.objectStoreNames||Da.get(e);if("store"===t)return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return Pa(e[t])},set:function(e,t,n){return e[t]=n,!0},has:function(e,t){return e instanceof IDBTransaction&&("done"===t||"store"===t)||t in e}};function La(e){Ma=e(Ma)}function Pa(e){if(e instanceof IDBRequest)return t=e,(n=new Promise((function(e,n){var r=function(){t.removeEventListener("success",o),t.removeEventListener("error",i)},o=function(){e(Pa(t.result)),r()},i=function(){n(t.error),r()};t.addEventListener("success",o),t.addEventListener("error",i)}))).then((function(e){e instanceof IDBCursor&&Ia.set(e,t)})).catch((function(){})),Fa.set(n,t),n;var t,n;if(Oa.has(e))return Oa.get(e);var r=function(e){return"function"==typeof e?(t=e)!==IDBDatabase.prototype.transaction||"objectStoreNames"in IDBTransaction.prototype?(Na||(Na=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(t)?function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return t.apply(Ba(this),n),Pa(Ia.get(this))}:function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return Pa(t.apply(Ba(this),n))}:function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];var i=t.call.apply(t,[Ba(this),e].concat(r));return Da.set(i,e.sort?e.sort():[e]),Pa(i)}:(e instanceof IDBTransaction&&function(e){if(!ja.has(e)){var t=new Promise((function(t,n){var r=function(){e.removeEventListener("complete",o),e.removeEventListener("error",i),e.removeEventListener("abort",i)},o=function(){t(),r()},i=function(){n(e.error||new DOMException("AbortError","AbortError")),r()};e.addEventListener("complete",o),e.addEventListener("error",i),e.addEventListener("abort",i)}));ja.set(e,t)}}(e),Ea(e,ka||(ka=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction]))?new Proxy(e,Ma):e);var t}(e);return r!==e&&(Oa.set(e,r),Fa.set(r,e)),r}var Ba=function(e){return Fa.get(e)};function qa(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.blocked,o=n.upgrade,i=n.blocking,a=n.terminated,s=indexedDB.open(e,t),l=Pa(s);return o&&s.addEventListener("upgradeneeded",(function(e){o(Pa(s.result),e.oldVersion,e.newVersion,Pa(s.transaction),e)})),r&&s.addEventListener("blocked",(function(e){return r(e.oldVersion,e.newVersion,e)})),l.then((function(e){a&&e.addEventListener("close",(function(){return a()})),i&&e.addEventListener("versionchange",(function(e){return i(e.oldVersion,e.newVersion,e)}))})).catch((function(){})),l}var Ua=["get","getKey","getAll","getAllKeys","count"],za=["put","add","delete","clear"],$a=new Map;function Ha(e,t){if(e instanceof IDBDatabase&&!(t in e)&&"string"==typeof t){if($a.get(t))return $a.get(t);var n=t.replace(/FromIndex$/,""),r=t!==n,o=za.includes(n);if(n in(r?IDBIndex:IDBObjectStore).prototype&&(o||Ua.includes(n))){var i=function(){var e=k(U().m((function e(t){var i,a,s,l,c,u,d=arguments;return U().w((function(e){for(;;)switch(e.n){case 0:for(a=this.transaction(t,o?"readwrite":"readonly"),s=a.store,l=d.length,c=new Array(l>1?l-1:0),u=1;u<l;u++)c[u-1]=d[u];return r&&(s=s.index(c.shift())),e.n=1,Promise.all([(i=s)[n].apply(i,c),o&&a.done]);case 1:return e.a(2,e.v[0])}}),e,this)})));return function(t){return e.apply(this,arguments)}}();return $a.set(t,i),i}}}La((function(e){return B(B({},e),{},{get:function(t,n,r){return Ha(t,n)||e.get(t,n,r)},has:function(t,n){return!!Ha(t,n)||e.has(t,n)}})}));var Ga=["continue","continuePrimaryKey","advance"],Va={},Wa=new WeakMap,Ja=new WeakMap,Ka={get:function(e,t){if(!Ga.includes(t))return e[t];var n=Va[t];return n||(n=Va[t]=function(){var e;Wa.set(this,(e=Ja.get(this))[t].apply(e,arguments))}),n}};function Ya(){return Xa.apply(this,arguments)}function Xa(){return Xa=function(e){return function(){return new X(e.apply(this,arguments))}}(U().m((function e(){var t,n,r,o=arguments;return U().w((function(e){for(;;)switch(e.n){case 0:if((t=this)instanceof IDBCursor){e.n=2;break}return e.n=1,N((n=t).openCursor.apply(n,o));case 1:t=e.v;case 2:if(t){e.n=3;break}return e.a(2);case 3:r=new Proxy(t,Ka),Ja.set(r,t),Fa.set(r,Ba(t));case 4:if(!t){e.n=7;break}return e.n=5,r;case 5:return e.n=6,N(Wa.get(r)||t.continue());case 6:t=e.v,Wa.delete(r),e.n=4;break;case 7:return e.a(2)}}),e,this)}))),Xa.apply(this,arguments)}function Za(e,t){return t===Symbol.asyncIterator&&Ea(e,[IDBIndex,IDBObjectStore,IDBCursor])||"iterate"===t&&Ea(e,[IDBIndex,IDBObjectStore])}La((function(e){return B(B({},e),{},{get:function(t,n,r){return Za(t,n)?Ya:e.get(t,n,r)},has:function(t,n){return Za(t,n)||e.has(t,n)}})}));var Qa=function(e){function t(){var e;R(this,t);for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return D(e=T(this,t,[].concat(r)),"code",void 0),e}return M(t,e),I(t)}(Z(Error));function es(e){if(e){if(!(e instanceof AbortSignal))throw new TypeError("must pass an AbortSignal");if(e.aborted)throw function(){if("undefined"!=typeof DOMException)return new DOMException("aborted","AbortError");var e=new Qa("aborted");return e.code="ERR_ABORTED",e}()}}function ts(e){return e instanceof Error&&("AbortError"===e.name||"ERR_ABORTED"===e.code||/\b(aborted|aborterror)\b/i.test(e.message))}function ns(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var rs,os={exports:{}},is=(rs||(rs=1,function(e,t){e.exports=function e(t,n,r){function o(a,s){if(!n[a]){if(!t[a]){if(!s&&ns)return ns(a);if(i)return i(a,!0);var l=new Error("Cannot find module '"+a+"'");throw l.code="MODULE_NOT_FOUND",l}var c=n[a]={exports:{}};t[a][0].call(c.exports,(function(e){return o(t[a][1][e]||e)}),c,c.exports,e,t,n,r)}return n[a].exports}for(var i=ns,a=0;a<r.length;a++)o(r[a]);return o}({"./aesprim":[function(e,t,n){var r;r=function(e){var t,n,r,o,i,a,s,l,c,u,d,f,h,p,g,m,y,_;function v(e,t){if(!e)throw new Error("ASSERT: "+t)}function b(e){return e>=48&&e<=57}function x(e){return"0123456789abcdefABCDEF".indexOf(e)>=0}function w(e){return"01234567".indexOf(e)>=0}function S(e){return 32===e||9===e||11===e||12===e||160===e||e>=5760&&[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279].indexOf(e)>=0}function C(e){return 10===e||13===e||8232===e||8233===e}function A(e){return 64==e||36===e||95===e||e>=65&&e<=90||e>=97&&e<=122||92===e||e>=128&&s.NonAsciiIdentifierStart.test(String.fromCharCode(e))}function k(e){return 36===e||95===e||e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||92===e||e>=128&&s.NonAsciiIdentifierPart.test(String.fromCharCode(e))}function N(e){switch(e){case"implements":case"interface":case"package":case"private":case"protected":case"public":case"static":case"yield":case"let":return!0;default:return!1}}function T(e){return"eval"===e||"arguments"===e}function R(e){if(u&&N(e))return!0;switch(e.length){case 2:return"if"===e||"in"===e||"do"===e;case 3:return"var"===e||"for"===e||"new"===e||"try"===e||"let"===e;case 4:return"this"===e||"else"===e||"case"===e||"void"===e||"with"===e||"enum"===e;case 5:return"while"===e||"break"===e||"catch"===e||"throw"===e||"const"===e||"yield"===e||"class"===e||"super"===e;case 6:return"return"===e||"typeof"===e||"delete"===e||"switch"===e||"export"===e||"import"===e;case 7:return"default"===e||"finally"===e||"extends"===e;case 8:return"function"===e||"continue"===e||"debugger"===e;case 10:return"instanceof"===e;default:return!1}}function E(e,t,n,r,o){var i;v("number"==typeof n,"Comment must have valid position"),y.lastCommentStart>=n||(y.lastCommentStart=n,i={type:e,value:t},_.range&&(i.range=[n,r]),_.loc&&(i.loc=o),_.comments.push(i),_.attachComment&&(_.leadingComments.push(i),_.trailingComments.push(i)))}function I(e){var t,n,r,o;for(t=d-e,n={start:{line:f,column:d-h-e}};d<p;)if(r=c.charCodeAt(d),++d,C(r))return _.comments&&(o=c.slice(t+e,d-1),n.end={line:f,column:d-h-1},E("Line",o,t,d-1,n)),13===r&&10===c.charCodeAt(d)&&++d,++f,void(h=d);_.comments&&(o=c.slice(t+e,d),n.end={line:f,column:d-h},E("Line",o,t,d,n))}function j(){var e,t,n,r;for(_.comments&&(e=d-2,t={start:{line:f,column:d-h-2}});d<p;)if(C(n=c.charCodeAt(d)))13===n&&10===c.charCodeAt(d+1)&&++d,++f,++d,h=d,d>=p&&J({},a.UnexpectedToken,"ILLEGAL");else if(42===n){if(47===c.charCodeAt(d+1))return++d,++d,void(_.comments&&(r=c.slice(e+2,d-2),t.end={line:f,column:d-h},E("Block",r,e,d,t)));++d}else++d;J({},a.UnexpectedToken,"ILLEGAL")}function D(){var e,t;for(t=0===d;d<p;)if(S(e=c.charCodeAt(d)))++d;else if(C(e))++d,13===e&&10===c.charCodeAt(d)&&++d,++f,h=d,t=!0;else if(47===e)if(47===(e=c.charCodeAt(d+1)))++d,++d,I(2),t=!0;else{if(42!==e)break;++d,++d,j()}else if(t&&45===e){if(45!==c.charCodeAt(d+1)||62!==c.charCodeAt(d+2))break;d+=3,I(3)}else{if(60!==e)break;if("!--"!==c.slice(d+1,d+4))break;++d,++d,++d,++d,I(4)}}function O(e){var t,n,r,o=0;for(n="u"===e?4:2,t=0;t<n;++t){if(!(d<p&&x(c[d])))return"";r=c[d++],o=16*o+"0123456789abcdef".indexOf(r.toLowerCase())}return String.fromCharCode(o)}function F(){var e,t;for(e=c.charCodeAt(d++),t=String.fromCharCode(e),92===e&&(117!==c.charCodeAt(d)&&J({},a.UnexpectedToken,"ILLEGAL"),++d,(e=O("u"))&&"\\"!==e&&A(e.charCodeAt(0))||J({},a.UnexpectedToken,"ILLEGAL"),t=e);d<p&&k(e=c.charCodeAt(d));)++d,t+=String.fromCharCode(e),92===e&&(t=t.substr(0,t.length-1),117!==c.charCodeAt(d)&&J({},a.UnexpectedToken,"ILLEGAL"),++d,(e=O("u"))&&"\\"!==e&&k(e.charCodeAt(0))||J({},a.UnexpectedToken,"ILLEGAL"),t+=e);return t}function M(){var e,t;for(e=d++;d<p;){if(92===(t=c.charCodeAt(d)))return d=e,F();if(!k(t))break;++d}return c.slice(e,d)}function L(){var e,n,r,o,i=d,s=c.charCodeAt(d),l=c[d];switch(s){case 46:case 40:case 41:case 59:case 44:case 123:case 125:case 91:case 93:case 58:case 63:case 126:return++d,_.tokenize&&(40===s?_.openParenToken=_.tokens.length:123===s&&(_.openCurlyToken=_.tokens.length)),{type:t.Punctuator,value:String.fromCharCode(s),lineNumber:f,lineStart:h,start:i,end:d};default:if(61===(e=c.charCodeAt(d+1)))switch(s){case 43:case 45:case 47:case 60:case 62:case 94:case 124:case 37:case 38:case 42:return d+=2,{type:t.Punctuator,value:String.fromCharCode(s)+String.fromCharCode(e),lineNumber:f,lineStart:h,start:i,end:d};case 33:case 61:return 61===c.charCodeAt(d+=2)&&++d,{type:t.Punctuator,value:c.slice(i,d),lineNumber:f,lineStart:h,start:i,end:d}}}return">>>="===(o=c.substr(d,4))?{type:t.Punctuator,value:o,lineNumber:f,lineStart:h,start:i,end:d+=4}:">>>"===(r=o.substr(0,3))||"<<="===r||">>="===r?{type:t.Punctuator,value:r,lineNumber:f,lineStart:h,start:i,end:d+=3}:l===(n=r.substr(0,2))[1]&&"+-<>&|".indexOf(l)>=0||"=>"===n?{type:t.Punctuator,value:n,lineNumber:f,lineStart:h,start:i,end:d+=2}:"<>=!+-*%&|^/".indexOf(l)>=0?(++d,{type:t.Punctuator,value:l,lineNumber:f,lineStart:h,start:i,end:d}):void J({},a.UnexpectedToken,"ILLEGAL")}function P(){var e,n,r;if(v(b((r=c[d]).charCodeAt(0))||"."===r,"Numeric literal must start with a decimal digit or a decimal point"),n=d,e="","."!==r){if(e=c[d++],r=c[d],"0"===e){if("x"===r||"X"===r)return++d,function(e){for(var n="";d<p&&x(c[d]);)n+=c[d++];return 0===n.length&&J({},a.UnexpectedToken,"ILLEGAL"),A(c.charCodeAt(d))&&J({},a.UnexpectedToken,"ILLEGAL"),{type:t.NumericLiteral,value:parseInt("0x"+n,16),lineNumber:f,lineStart:h,start:e,end:d}}(n);if(w(r))return function(e){for(var n="0"+c[d++];d<p&&w(c[d]);)n+=c[d++];return(A(c.charCodeAt(d))||b(c.charCodeAt(d)))&&J({},a.UnexpectedToken,"ILLEGAL"),{type:t.NumericLiteral,value:parseInt(n,8),octal:!0,lineNumber:f,lineStart:h,start:e,end:d}}(n);r&&b(r.charCodeAt(0))&&J({},a.UnexpectedToken,"ILLEGAL")}for(;b(c.charCodeAt(d));)e+=c[d++];r=c[d]}if("."===r){for(e+=c[d++];b(c.charCodeAt(d));)e+=c[d++];r=c[d]}if("e"===r||"E"===r)if(e+=c[d++],"+"!==(r=c[d])&&"-"!==r||(e+=c[d++]),b(c.charCodeAt(d)))for(;b(c.charCodeAt(d));)e+=c[d++];else J({},a.UnexpectedToken,"ILLEGAL");return A(c.charCodeAt(d))&&J({},a.UnexpectedToken,"ILLEGAL"),{type:t.NumericLiteral,value:parseFloat(e),lineNumber:f,lineStart:h,start:n,end:d}}function B(){var e,n,r,o;return m=null,D(),e=d,n=function(){var e,t,n,r;for(v("/"===(e=c[d]),"Regular expression literal must start with a slash"),t=c[d++],n=!1,r=!1;d<p;)if(t+=e=c[d++],"\\"===e)C((e=c[d++]).charCodeAt(0))&&J({},a.UnterminatedRegExp),t+=e;else if(C(e.charCodeAt(0)))J({},a.UnterminatedRegExp);else if(n)"]"===e&&(n=!1);else{if("/"===e){r=!0;break}"["===e&&(n=!0)}return r||J({},a.UnterminatedRegExp),{value:t.substr(1,t.length-2),literal:t}}(),r=function(){var e,t,n,r;for(t="",n="";d<p&&k((e=c[d]).charCodeAt(0));)if(++d,"\\"===e&&d<p)if("u"===(e=c[d])){if(r=++d,e=O("u"))for(n+=e,t+="\\u";r<d;++r)t+=c[r];else d=r,n+="u",t+="\\u";K({},a.UnexpectedToken,"ILLEGAL")}else t+="\\",K({},a.UnexpectedToken,"ILLEGAL");else n+=e,t+=e;return{value:n,literal:t}}(),o=function(e,t){var n;try{n=new RegExp(e,t)}catch(e){J({},a.InvalidRegExp)}return n}(n.value,r.value),_.tokenize?{type:t.RegularExpression,value:o,lineNumber:f,lineStart:h,start:e,end:d}:{literal:n.literal+r.literal,value:o,start:e,end:d}}function q(){var e,t,n,r;return D(),e=d,t={start:{line:f,column:d-h}},n=B(),t.end={line:f,column:d-h},_.tokenize||(_.tokens.length>0&&(r=_.tokens[_.tokens.length-1]).range[0]===e&&"Punctuator"===r.type&&("/"!==r.value&&"/="!==r.value||_.tokens.pop()),_.tokens.push({type:"RegularExpression",value:n.literal,range:[e,d],loc:t})),n}function U(){var e,n,o;return D(),d>=p?{type:t.EOF,lineNumber:f,lineStart:h,start:d,end:d}:A(e=c.charCodeAt(d))?(n=d,{type:1===(o=92===c.charCodeAt(d)?F():M()).length?t.Identifier:R(o)?t.Keyword:"null"===o?t.NullLiteral:"true"===o||"false"===o?t.BooleanLiteral:t.Identifier,value:o,lineNumber:f,lineStart:h,start:n,end:d}):40===e||41===e||59===e?L():39===e||34===e?function(){var e,n,r,o,i,s,l,u,g="",m=!1;for(l=f,u=h,v("'"===(e=c[d])||'"'===e,"String literal must starts with a quote"),n=d,++d;d<p;){if((r=c[d++])===e){e="";break}if("\\"===r)if((r=c[d++])&&C(r.charCodeAt(0)))++f,"\r"===r&&"\n"===c[d]&&++d,h=d;else switch(r){case"u":case"x":s=d,(i=O(r))?g+=i:(d=s,g+=r);break;case"n":g+="\n";break;case"r":g+="\r";break;case"t":g+="\t";break;case"b":g+="\b";break;case"f":g+="\f";break;case"v":g+="\v";break;default:w(r)?(0!==(o="01234567".indexOf(r))&&(m=!0),d<p&&w(c[d])&&(m=!0,o=8*o+"01234567".indexOf(c[d++]),"0123".indexOf(r)>=0&&d<p&&w(c[d])&&(o=8*o+"01234567".indexOf(c[d++]))),g+=String.fromCharCode(o)):g+=r}else{if(C(r.charCodeAt(0)))break;g+=r}}return""!==e&&J({},a.UnexpectedToken,"ILLEGAL"),{type:t.StringLiteral,value:g,octal:m,startLineNumber:l,startLineStart:u,lineNumber:f,lineStart:h,start:n,end:d}}():46===e?b(c.charCodeAt(d+1))?P():L():b(e)?P():_.tokenize&&47===e?function(){var e,t;if(!(e=_.tokens[_.tokens.length-1]))return q();if("Punctuator"===e.type){if("]"===e.value)return L();if(")"===e.value)return!(t=_.tokens[_.openParenToken-1])||"Keyword"!==t.type||"if"!==t.value&&"while"!==t.value&&"for"!==t.value&&"with"!==t.value?L():q();if("}"===e.value){if(_.tokens[_.openCurlyToken-3]&&"Keyword"===_.tokens[_.openCurlyToken-3].type){if(!(t=_.tokens[_.openCurlyToken-4]))return L()}else{if(!_.tokens[_.openCurlyToken-4]||"Keyword"!==_.tokens[_.openCurlyToken-4].type)return L();if(!(t=_.tokens[_.openCurlyToken-5]))return q()}return r.indexOf(t.value)>=0?L():q()}return q()}return"Keyword"===e.type?q():L()}():L()}function z(){var e,r,o;return D(),e={start:{line:f,column:d-h}},r=U(),e.end={line:f,column:d-h},r.type!==t.EOF&&(o=c.slice(r.start,r.end),_.tokens.push({type:n[r.type],value:o,range:[r.start,r.end],loc:e})),r}function $(){var e;return d=(e=m).end,f=e.lineNumber,h=e.lineStart,m=void 0!==_.tokens?z():U(),d=e.end,f=e.lineNumber,h=e.lineStart,e}function H(){var e,t,n;e=d,t=f,n=h,m=void 0!==_.tokens?z():U(),d=e,f=t,h=n}function G(e,t){this.line=e,this.column=t}function V(e,t,n,r){this.start=new G(e,t),this.end=new G(n,r)}function W(){var e,t,n,r;return e=d,t=f,n=h,D(),r=f!==t,d=e,f=t,h=n,r}function J(e,t){var n,r=Array.prototype.slice.call(arguments,2),o=t.replace(/%(\d)/g,(function(e,t){return v(t<r.length,"Message reference must be in range"),r[t]}));throw"number"==typeof e.lineNumber?((n=new Error("Line "+e.lineNumber+": "+o)).index=e.start,n.lineNumber=e.lineNumber,n.column=e.start-h+1):((n=new Error("Line "+f+": "+o)).index=d,n.lineNumber=f,n.column=d-h+1),n.description=o,n}function K(){try{J.apply(null,arguments)}catch(e){if(!_.errors)throw e;_.errors.push(e)}}function Y(e){if(e.type===t.EOF&&J(e,a.UnexpectedEOS),e.type===t.NumericLiteral&&J(e,a.UnexpectedNumber),e.type===t.StringLiteral&&J(e,a.UnexpectedString),e.type===t.Identifier&&J(e,a.UnexpectedIdentifier),e.type===t.Keyword){if(function(e){switch(e){case"class":case"enum":case"export":case"extends":case"import":case"super":return!0;default:return!1}}(e.value))J(e,a.UnexpectedReserved);else if(u&&N(e.value))return void K(e,a.StrictReservedWord);J(e,a.UnexpectedToken,e.value)}J(e,a.UnexpectedToken,e.value)}function X(e){var n=$();n.type===t.Punctuator&&n.value===e||Y(n)}function Z(e){var n=$();n.type===t.Keyword&&n.value===e||Y(n)}function Q(e){return m.type===t.Punctuator&&m.value===e}function ee(e){return m.type===t.Keyword&&m.value===e}function te(){var e;59===c.charCodeAt(d)||Q(";")?$():(e=f,D(),f===e&&(m.type===t.EOF||Q("}")||Y(m)))}function ne(e){return e.type===o.Identifier||e.type===o.MemberExpression}function re(e,t){var n,r,o;return n=u,o=m,r=we(),t&&u&&T(e[0].name)&&K(t,a.StrictParamName),u=n,g.markEnd(g.createFunctionExpression(null,e,[],r),o)}function oe(){var e,n;return n=m,(e=$()).type===t.StringLiteral||e.type===t.NumericLiteral?(u&&e.octal&&K(e,a.StrictOctalLiteral),g.markEnd(g.createLiteral(e),n)):g.markEnd(g.createIdentifier(e.value),n)}function ie(){var e,n,r,o,i,s;return s=m,(e=m).type===t.Identifier?(r=oe(),"get"!==e.value||Q(":")?"set"!==e.value||Q(":")?(X(":"),o=pe(),g.markEnd(g.createProperty("init",r,o),s)):(n=oe(),X("("),(e=m).type!==t.Identifier?(X(")"),K(e,a.UnexpectedToken,e.value),o=re([])):(i=[ye()],X(")"),o=re(i,e)),g.markEnd(g.createProperty("set",n,o),s)):(n=oe(),X("("),X(")"),o=re([]),g.markEnd(g.createProperty("get",n,o),s))):e.type!==t.EOF&&e.type!==t.Punctuator?(n=oe(),X(":"),o=pe(),g.markEnd(g.createProperty("init",n,o),s)):void Y(e)}function ae(){var e,n,r,s;if(Q("("))return function(){var e;return X("("),e=ge(),X(")"),e}();if(Q("["))return function(){var e,t=[];for(e=m,X("[");!Q("]");)Q(",")?($(),t.push(null)):(t.push(pe()),Q("]")||X(","));return $(),g.markEnd(g.createArrayExpression(t),e)}();if(Q("{"))return function(){var e,t,n,r,s,l=[],c={},d=String;for(s=m,X("{");!Q("}");)t=(e=ie()).key.type===o.Identifier?e.key.name:d(e.key.value),r="init"===e.kind?i.Data:"get"===e.kind?i.Get:i.Set,n="$"+t,Object.prototype.hasOwnProperty.call(c,n)?(c[n]===i.Data?u&&r===i.Data?K({},a.StrictDuplicateProperty):r!==i.Data&&K({},a.AccessorDataProperty):r===i.Data?K({},a.AccessorDataProperty):c[n]&r&&K({},a.AccessorGetSet),c[n]|=r):c[n]=r,l.push(e),Q("}")||X(",");return X("}"),g.markEnd(g.createObjectExpression(l),s)}();if(s=m,(e=m.type)===t.Identifier)r=g.createIdentifier($().value);else if(e===t.StringLiteral||e===t.NumericLiteral)u&&m.octal&&K(m,a.StrictOctalLiteral),r=g.createLiteral($());else if(e===t.Keyword){if(ee("function"))return function(){var e,t,n,r,o,i,s,l,c,d=null;return l=m,Z("function"),Q("(")||(e=m,d=ye(),u?T(e.value)&&K(e,a.StrictFunctionName):T(e.value)?(n=e,r=a.StrictFunctionName):N(e.value)&&(n=e,r=a.StrictReservedWord)),c=(o=Se(n)).params,t=o.stricted,n=o.firstRestricted,o.message&&(r=o.message),s=u,i=we(),u&&n&&J(n,r),u&&t&&K(t,r),u=s,g.markEnd(g.createFunctionExpression(d,c,[],i),l)}();ee("this")?($(),r=g.createThisExpression()):Y($())}else e===t.BooleanLiteral?((n=$()).value="true"===n.value,r=g.createLiteral(n)):e===t.NullLiteral?((n=$()).value=null,r=g.createLiteral(n)):Q("/")||Q("/=")?(r=g.createLiteral(void 0!==_.tokens?q():B()),H()):Y($());return g.markEnd(r,s)}function se(){var e=[];if(X("("),!Q(")"))for(;d<p&&(e.push(pe()),!Q(")"));)X(",");return X(")"),e}function le(){return X("."),function(){var e,n;return n=m,function(e){return e.type===t.Identifier||e.type===t.Keyword||e.type===t.BooleanLiteral||e.type===t.NullLiteral}(e=$())||Y(e),g.markEnd(g.createIdentifier(e.value),n)}()}function ce(){var e;return X("["),e=ge(),X("]"),e}function ue(){var e,t,n;return n=m,Z("new"),e=function(){var e,t,n,r;for(r=m,e=y.allowIn,t=ee("new")?ue():ae(),y.allowIn=e;Q(".")||Q("[");)Q("[")?(n=ce(),t=g.createMemberExpression("[",t,n)):(n=le(),t=g.createMemberExpression(".",t,n)),g.markEnd(t,r);return t}(),t=Q("(")?se():[],g.markEnd(g.createNewExpression(e,t),n)}function de(){var e,n,r=m;return e=function(){var e,t,n,r,o;for(o=m,e=y.allowIn,y.allowIn=!0,t=ee("new")?ue():ae(),y.allowIn=e;;){if(Q("."))r=le(),t=g.createMemberExpression(".",t,r);else if(Q("("))n=se(),t=g.createCallExpression(t,n);else{if(!Q("["))break;r=ce(),t=g.createMemberExpression("[",t,r)}g.markEnd(t,o)}return t}(),m.type===t.Punctuator&&(!Q("++")&&!Q("--")||W()||(u&&e.type===o.Identifier&&T(e.name)&&K({},a.StrictLHSPostfix),ne(e)||K({},a.InvalidLHSInAssignment),n=$(),e=g.markEnd(g.createPostfixExpression(n.value,e),r))),e}function fe(){var e,n,r;return m.type!==t.Punctuator&&m.type!==t.Keyword?n=de():Q("++")||Q("--")?(r=m,e=$(),n=fe(),u&&n.type===o.Identifier&&T(n.name)&&K({},a.StrictLHSPrefix),ne(n)||K({},a.InvalidLHSInAssignment),n=g.createUnaryExpression(e.value,n),n=g.markEnd(n,r)):Q("+")||Q("-")||Q("~")||Q("!")?(r=m,e=$(),n=fe(),n=g.createUnaryExpression(e.value,n),n=g.markEnd(n,r)):ee("delete")||ee("void")||ee("typeof")?(r=m,e=$(),n=fe(),n=g.createUnaryExpression(e.value,n),n=g.markEnd(n,r),u&&"delete"===n.operator&&n.argument.type===o.Identifier&&K({},a.StrictDelete)):n=de(),n}function he(e,n){var r=0;if(e.type!==t.Punctuator&&e.type!==t.Keyword)return 0;switch(e.value){case"||":r=1;break;case"&&":r=2;break;case"|":r=3;break;case"^":r=4;break;case"&":r=5;break;case"==":case"!=":case"===":case"!==":r=6;break;case"<":case">":case"<=":case">=":case"instanceof":r=7;break;case"in":r=n?7:0;break;case"<<":case">>":case">>>":r=8;break;case"+":case"-":r=9;break;case"*":case"/":case"%":r=11}return r}function pe(){var e,n,r,i,s,l;return e=m,s=m,i=n=function(){var e,t,n,r,o;return o=m,e=function(){var e,t,n,r,o,i,a,s,l,c;if(e=m,l=fe(),0===(o=he(r=m,y.allowIn)))return l;for(r.prec=o,$(),t=[e,m],i=[l,r,a=fe()];(o=he(m,y.allowIn))>0;){for(;i.length>2&&o<=i[i.length-2].prec;)a=i.pop(),s=i.pop().value,l=i.pop(),n=g.createBinaryExpression(s,l,a),t.pop(),g.markEnd(n,e=t[t.length-1]),i.push(n);(r=$()).prec=o,i.push(r),t.push(m),n=fe(),i.push(n)}for(n=i[c=i.length-1],t.pop();c>1;)n=g.createBinaryExpression(i[c-1].value,i[c-2],n),c-=2,e=t.pop(),g.markEnd(n,e);return n}(),Q("?")&&($(),t=y.allowIn,y.allowIn=!0,n=pe(),y.allowIn=t,X(":"),r=pe(),e=g.createConditionalExpression(e,n,r),g.markEnd(e,o)),e}(),m.type===t.Punctuator&&("="===(l=m.value)||"*="===l||"/="===l||"%="===l||"+="===l||"-="===l||"<<="===l||">>="===l||">>>="===l||"&="===l||"^="===l||"|="===l)&&(ne(n)||K({},a.InvalidLHSInAssignment),u&&n.type===o.Identifier&&T(n.name)&&K(e,a.StrictLHSAssignment),e=$(),r=pe(),i=g.markEnd(g.createAssignmentExpression(e.value,n,r),s)),i}function ge(){var e,t=m;if(e=pe(),Q(",")){for(e=g.createSequenceExpression([e]);d<p&&Q(",");)$(),e.expressions.push(pe());g.markEnd(e,t)}return e}function me(){var e,t;return t=m,X("{"),e=function(){for(var e,t=[];d<p&&!Q("}")&&void 0!==(e=Ae());)t.push(e);return t}(),X("}"),g.markEnd(g.createBlockStatement(e),t)}function ye(){var e,n;return n=m,(e=$()).type!==t.Identifier&&Y(e),g.markEnd(g.createIdentifier(e.value),n)}function _e(e){var t,n,r=null;return n=m,t=ye(),u&&T(t.name)&&K({},a.StrictVarName),"const"===e?(X("="),r=pe()):Q("=")&&($(),r=pe()),g.markEnd(g.createVariableDeclarator(t,r),n)}function ve(e){var t=[];do{if(t.push(_e(e)),!Q(","))break;$()}while(d<p);return t}function be(){var e,t,n,r=[];for(n=m,ee("default")?($(),e=null):(Z("case"),e=ge()),X(":");d<p&&!(Q("}")||ee("default")||ee("case"));)t=xe(),r.push(t);return g.markEnd(g.createSwitchCase(e,r),n)}function xe(){var e,n,r,i,s,l,f,h,_,v,b=m.type;if(b===t.EOF&&Y(m),b===t.Punctuator&&"{"===m.value)return me();if(i=m,b===t.Punctuator)switch(m.value){case";":return g.markEnd((X(";"),g.createEmptyStatement()),i);case"(":return g.markEnd(function(){var e=ge();return te(),g.createExpressionStatement(e)}(),i)}if(b===t.Keyword)switch(m.value){case"break":return g.markEnd((v=null,Z("break"),59===c.charCodeAt(d)?($(),y.inIteration||y.inSwitch||J({},a.IllegalBreak),g.createBreakStatement(null)):W()?(y.inIteration||y.inSwitch||J({},a.IllegalBreak),g.createBreakStatement(null)):(m.type===t.Identifier&&(v=ye(),Object.prototype.hasOwnProperty.call(y.labelSet,"$"+v.name)||J({},a.UnknownLabel,v.name)),te(),null!==v||y.inIteration||y.inSwitch||J({},a.IllegalBreak),g.createBreakStatement(v))),i);case"continue":return g.markEnd(function(){var e=null;return Z("continue"),59===c.charCodeAt(d)?($(),y.inIteration||J({},a.IllegalContinue),g.createContinueStatement(null)):W()?(y.inIteration||J({},a.IllegalContinue),g.createContinueStatement(null)):(m.type===t.Identifier&&(e=ye(),Object.prototype.hasOwnProperty.call(y.labelSet,"$"+e.name)||J({},a.UnknownLabel,e.name)),te(),null!==e||y.inIteration||J({},a.IllegalContinue),g.createContinueStatement(e))}(),i);case"debugger":return g.markEnd((Z("debugger"),te(),g.createDebuggerStatement()),i);case"do":return g.markEnd((Z("do"),_=y.inIteration,y.inIteration=!0,f=xe(),y.inIteration=_,Z("while"),X("("),h=ge(),X(")"),Q(";")&&$(),g.createDoWhileStatement(f,h)),i);case"for":return g.markEnd(function(){var e,t,n,r,o,i,s;return e=t=n=null,Z("for"),X("("),Q(";")?$():(ee("var")||ee("let")?(y.allowIn=!1,e=function(){var e,t,n;return n=m,e=$(),t=ve(),g.markEnd(g.createVariableDeclaration(t,e.value),n)}(),y.allowIn=!0,1===e.declarations.length&&ee("in")&&($(),r=e,o=ge(),e=null)):(y.allowIn=!1,e=ge(),y.allowIn=!0,ee("in")&&(ne(e)||K({},a.InvalidLHSInForIn),$(),r=e,o=ge(),e=null)),void 0===r&&X(";")),void 0===r&&(Q(";")||(t=ge()),X(";"),Q(")")||(n=ge())),X(")"),s=y.inIteration,y.inIteration=!0,i=xe(),y.inIteration=s,void 0===r?g.createForStatement(e,t,n,i):g.createForInStatement(r,o,i)}(),i);case"function":return g.markEnd(Ce(),i);case"if":return g.markEnd(function(){var e,t,n;return Z("if"),X("("),e=ge(),X(")"),t=xe(),ee("else")?($(),n=xe()):n=null,g.createIfStatement(e,t,n)}(),i);case"return":return g.markEnd((l=null,Z("return"),y.inFunctionBody||K({},a.IllegalReturn),32===c.charCodeAt(d)&&A(c.charCodeAt(d+1))?(l=ge(),te(),g.createReturnStatement(l)):W()?g.createReturnStatement(null):(Q(";")||Q("}")||m.type===t.EOF||(l=ge()),te(),g.createReturnStatement(l))),i);case"switch":return g.markEnd(function(){var e,t,n,r,o;if(Z("switch"),X("("),e=ge(),X(")"),X("{"),t=[],Q("}"))return $(),g.createSwitchStatement(e,t);for(r=y.inSwitch,y.inSwitch=!0,o=!1;d<p&&!Q("}");)null===(n=be()).test&&(o&&J({},a.MultipleDefaultsInSwitch),o=!0),t.push(n);return y.inSwitch=r,X("}"),g.createSwitchStatement(e,t)}(),i);case"throw":return g.markEnd(function(){var e;return Z("throw"),W()&&J({},a.NewlineAfterThrow),e=ge(),te(),g.createThrowStatement(e)}(),i);case"try":return g.markEnd(function(){var e,t,n,r,o=[],i=null;return Z("try"),e=me(),ee("catch")&&o.push((r=m,Z("catch"),X("("),Q(")")&&Y(m),t=ye(),u&&T(t.name)&&K({},a.StrictCatchVariable),X(")"),n=me(),g.markEnd(g.createCatchClause(t,n),r))),ee("finally")&&($(),i=me()),0!==o.length||i||J({},a.NoCatchOrFinally),g.createTryStatement(e,[],o,i)}(),i);case"var":return g.markEnd((Z("var"),s=ve(),te(),g.createVariableDeclaration(s,"var")),i);case"while":return g.markEnd(function(){var e,t,n;return Z("while"),X("("),e=ge(),X(")"),n=y.inIteration,y.inIteration=!0,t=xe(),y.inIteration=n,g.createWhileStatement(e,t)}(),i);case"with":return g.markEnd(function(){var e,t;return u&&(D(),K({},a.StrictModeWith)),Z("with"),X("("),e=ge(),X(")"),t=xe(),g.createWithStatement(e,t)}(),i)}return(e=ge()).type===o.Identifier&&Q(":")?($(),r="$"+e.name,Object.prototype.hasOwnProperty.call(y.labelSet,r)&&J({},a.Redeclaration,"Label",e.name),y.labelSet[r]=!0,n=xe(),delete y.labelSet[r],g.markEnd(g.createLabeledStatement(e,n),i)):(te(),g.markEnd(g.createExpressionStatement(e),i))}function we(){var e,n,r,i,s,l,f,h,_=[];for(h=m,X("{");d<p&&m.type===t.StringLiteral&&(n=m,e=Ae(),_.push(e),e.expression.type===o.Literal);)"use strict"===c.slice(n.start+1,n.end-1)?(u=!0,r&&K(r,a.StrictOctalLiteral)):!r&&n.octal&&(r=n);for(i=y.labelSet,s=y.inIteration,l=y.inSwitch,f=y.inFunctionBody,y.labelSet={},y.inIteration=!1,y.inSwitch=!1,y.inFunctionBody=!0;d<p&&!Q("}")&&void 0!==(e=Ae());)_.push(e);return X("}"),y.labelSet=i,y.inIteration=s,y.inSwitch=l,y.inFunctionBody=f,g.markEnd(g.createBlockStatement(_),h)}function Se(e){var t,n,r,o,i,s,l=[];if(X("("),!Q(")"))for(o={};d<p&&(n=m,t=ye(),i="$"+n.value,u?(T(n.value)&&(r=n,s=a.StrictParamName),Object.prototype.hasOwnProperty.call(o,i)&&(r=n,s=a.StrictParamDupe)):e||(T(n.value)?(e=n,s=a.StrictParamName):N(n.value)?(e=n,s=a.StrictReservedWord):Object.prototype.hasOwnProperty.call(o,i)&&(e=n,s=a.StrictParamDupe)),l.push(t),o[i]=!0,!Q(")"));)X(",");return X(")"),{params:l,stricted:r,firstRestricted:e,message:s}}function Ce(){var e,t,n,r,o,i,s,l,c,d;return c=m,Z("function"),n=m,e=ye(),u?T(n.value)&&K(n,a.StrictFunctionName):T(n.value)?(i=n,s=a.StrictFunctionName):N(n.value)&&(i=n,s=a.StrictReservedWord),d=(o=Se(i)).params,r=o.stricted,i=o.firstRestricted,o.message&&(s=o.message),l=u,t=we(),u&&i&&J(i,s),u&&r&&K(r,s),u=l,g.markEnd(g.createFunctionDeclaration(e,d,[],t),c)}function Ae(){if(m.type===t.Keyword)switch(m.value){case"const":case"let":return r=m,Z(e=m.value),n=ve(e),te(),g.markEnd(g.createVariableDeclaration(n,e),r);case"function":return Ce();default:return xe()}var e,n,r;if(m.type!==t.EOF)return xe()}function ke(){var e,t,n,r=[];for(e=0;e<_.tokens.length;++e)n={type:(t=_.tokens[e]).type,value:t.value},_.range&&(n.range=t.range),_.loc&&(n.loc=t.loc),r.push(n);_.tokens=r}(n={})[(t={BooleanLiteral:1,EOF:2,Identifier:3,Keyword:4,NullLiteral:5,NumericLiteral:6,Punctuator:7,StringLiteral:8,RegularExpression:9}).BooleanLiteral]="Boolean",n[t.EOF]="<end>",n[t.Identifier]="Identifier",n[t.Keyword]="Keyword",n[t.NullLiteral]="Null",n[t.NumericLiteral]="Numeric",n[t.Punctuator]="Punctuator",n[t.StringLiteral]="String",n[t.RegularExpression]="RegularExpression",r=["(","{","[","in","typeof","instanceof","new","return","case","delete","throw","void","=","+=","-=","*=","/=","%=","<<=",">>=",">>>=","&=","|=","^=",",","+","-","*","/","%","++","--","<<",">>",">>>","&","|","^","!","~","&&","||","?",":","===","==",">=","<=","<",">","!=","!=="],o={AssignmentExpression:"AssignmentExpression",ArrayExpression:"ArrayExpression",BlockStatement:"BlockStatement",BinaryExpression:"BinaryExpression",BreakStatement:"BreakStatement",CallExpression:"CallExpression",CatchClause:"CatchClause",ConditionalExpression:"ConditionalExpression",ContinueStatement:"ContinueStatement",DoWhileStatement:"DoWhileStatement",DebuggerStatement:"DebuggerStatement",EmptyStatement:"EmptyStatement",ExpressionStatement:"ExpressionStatement",ForStatement:"ForStatement",ForInStatement:"ForInStatement",FunctionDeclaration:"FunctionDeclaration",FunctionExpression:"FunctionExpression",Identifier:"Identifier",IfStatement:"IfStatement",Literal:"Literal",LabeledStatement:"LabeledStatement",LogicalExpression:"LogicalExpression",MemberExpression:"MemberExpression",NewExpression:"NewExpression",ObjectExpression:"ObjectExpression",Program:"Program",Property:"Property",ReturnStatement:"ReturnStatement",SequenceExpression:"SequenceExpression",SwitchStatement:"SwitchStatement",SwitchCase:"SwitchCase",ThisExpression:"ThisExpression",ThrowStatement:"ThrowStatement",TryStatement:"TryStatement",UnaryExpression:"UnaryExpression",UpdateExpression:"UpdateExpression",VariableDeclaration:"VariableDeclaration",VariableDeclarator:"VariableDeclarator",WhileStatement:"WhileStatement",WithStatement:"WithStatement"},i={Data:1,Get:2,Set:4},a={UnexpectedToken:"Unexpected token %0",UnexpectedNumber:"Unexpected number",UnexpectedString:"Unexpected string",UnexpectedIdentifier:"Unexpected identifier",UnexpectedReserved:"Unexpected reserved word",UnexpectedEOS:"Unexpected end of input",NewlineAfterThrow:"Illegal newline after throw",InvalidRegExp:"Invalid regular expression",UnterminatedRegExp:"Invalid regular expression: missing /",InvalidLHSInAssignment:"Invalid left-hand side in assignment",InvalidLHSInForIn:"Invalid left-hand side in for-in",MultipleDefaultsInSwitch:"More than one default clause in switch statement",NoCatchOrFinally:"Missing catch or finally after try",UnknownLabel:"Undefined label '%0'",Redeclaration:"%0 '%1' has already been declared",IllegalContinue:"Illegal continue statement",IllegalBreak:"Illegal break statement",IllegalReturn:"Illegal return statement",StrictModeWith:"Strict mode code may not include a with statement",StrictCatchVariable:"Catch variable may not be eval or arguments in strict mode",StrictVarName:"Variable name may not be eval or arguments in strict mode",StrictParamName:"Parameter name eval or arguments is not allowed in strict mode",StrictParamDupe:"Strict mode function may not have duplicate parameter names",StrictFunctionName:"Function name may not be eval or arguments in strict mode",StrictOctalLiteral:"Octal literals are not allowed in strict mode.",StrictDelete:"Delete of an unqualified identifier in strict mode.",StrictDuplicateProperty:"Duplicate data property in object literal not allowed in strict mode",AccessorDataProperty:"Object literal may not have data and accessor property with the same name",AccessorGetSet:"Object literal may not have multiple get/set accessors with the same name",StrictLHSAssignment:"Assignment to eval or arguments is not allowed in strict mode",StrictLHSPostfix:"Postfix increment/decrement may not have eval or arguments operand in strict mode",StrictLHSPrefix:"Prefix increment/decrement may not have eval or arguments operand in strict mode",StrictReservedWord:"Use of future reserved word in strict mode"},s={NonAsciiIdentifierStart:new RegExp("[ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԧԱ-Ֆՙա-ևא-תװ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࢠࢢ-ࢬऄ-हऽॐक़-ॡॱ-ॷॹ-ॿঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-ళవ-హఽౘౙౠౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೞೠೡೱೲഅ-ഌഎ-ഐഒ-ഺഽൎൠൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏼᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛰᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡷᢀ-ᢨᢪᢰ-ᣵᤀ-ᤜᥐ-ᥭᥰ-ᥴᦀ-ᦫᧁ-ᧇᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᳩ-ᳬᳮ-ᳱᳵᳶᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞⸯ々-〇〡-〩〱-〵〸-〼ぁ-ゖゝ-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿌ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚗꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꞎꞐ-ꞓꞠ-Ɦꟸ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꪀ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꯀ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ]"),NonAsciiIdentifierPart:new RegExp("[ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮ̀-ʹͶͷͺ-ͽΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁ҃-҇Ҋ-ԧԱ-Ֆՙա-և֑-ׇֽֿׁׂׅׄא-תװ-ײؐ-ؚؠ-٩ٮ-ۓە-ۜ۟-۪ۨ-ۼۿܐ-݊ݍ-ޱ߀-ߵߺࠀ-࠭ࡀ-࡛ࢠࢢ-ࢬࣤ-ࣾऀ-ॣ०-९ॱ-ॷॹ-ॿঁ-ঃঅ-ঌএঐও-নপ-রলশ-হ়-ৄেৈো-ৎৗড়ঢ়য়-ৣ০-ৱਁ-ਃਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹ਼ਾ-ੂੇੈੋ-੍ੑਖ਼-ੜਫ਼੦-ੵઁ-ઃઅ-ઍએ-ઑઓ-નપ-રલળવ-હ઼-ૅે-ૉો-્ૐૠ-ૣ૦-૯ଁ-ଃଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହ଼-ୄେୈୋ-୍ୖୗଡ଼ଢ଼ୟ-ୣ୦-୯ୱஂஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹா-ூெ-ைொ-்ௐௗ௦-௯ఁ-ఃఅ-ఌఎ-ఐఒ-నప-ళవ-హఽ-ౄె-ైొ-్ౕౖౘౙౠ-ౣ౦-౯ಂಃಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹ಼-ೄೆ-ೈೊ-್ೕೖೞೠ-ೣ೦-೯ೱೲംഃഅ-ഌഎ-ഐഒ-ഺഽ-ൄെ-ൈൊ-ൎൗൠ-ൣ൦-൯ൺ-ൿංඃඅ-ඖක-නඳ-රලව-ෆ්ා-ුූෘ-ෟෲෳก-ฺเ-๎๐-๙ກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ູົ-ຽເ-ໄໆ່-ໍ໐-໙ໜ-ໟༀ༘༙༠-༩༹༵༷༾-ཇཉ-ཬཱ-྄྆-ྗྙ-ྼ࿆က-၉ၐ-ႝႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚ፝-፟ᎀ-ᎏᎠ-Ᏼᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛰᜀ-ᜌᜎ-᜔ᜠ-᜴ᝀ-ᝓᝠ-ᝬᝮ-ᝰᝲᝳក-៓ៗៜ៝០-៩᠋-᠍᠐-᠙ᠠ-ᡷᢀ-ᢪᢰ-ᣵᤀ-ᤜᤠ-ᤫᤰ-᤻᥆-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉ᧐-᧙ᨀ-ᨛᨠ-ᩞ᩠-᩿᩼-᪉᪐-᪙ᪧᬀ-ᭋ᭐-᭙᭫-᭳ᮀ-᯳ᰀ-᰷᱀-᱉ᱍ-ᱽ᳐-᳔᳒-ᳶᴀ-ᷦ᷼-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼ‿⁀⁔ⁱⁿₐ-ₜ⃐-⃥⃜⃡-⃰ℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯ⵿-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞⷠ-ⷿⸯ々-〇〡-〯〱-〵〸-〼ぁ-ゖ゙゚ゝ-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿌ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘫꙀ-꙯ꙴ-꙽ꙿ-ꚗꚟ-꛱ꜗ-ꜟꜢ-ꞈꞋ-ꞎꞐ-ꞓꞠ-Ɦꟸ-ꠧꡀ-ꡳꢀ-꣄꣐-꣙꣠-ꣷꣻ꤀-꤭ꤰ-꥓ꥠ-ꥼꦀ-꧀ꧏ-꧙ꨀ-ꨶꩀ-ꩍ꩐-꩙ꩠ-ꩶꩺꩻꪀ-ꫂꫛ-ꫝꫠ-ꫯꫲ-꫶ꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꯀ-ꯪ꯬꯭꯰-꯹가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻ︀-️︠-︦︳︴﹍-﹏ﹰ-ﹴﹶ-ﻼ0-9A-Z_a-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ]")},l={name:"SyntaxTree",processComment:function(e){var t,n;if(!(e.type===o.Program&&e.body.length>0)){for(_.trailingComments.length>0?_.trailingComments[0].range[0]>=e.range[1]?(n=_.trailingComments,_.trailingComments=[]):_.trailingComments.length=0:_.bottomRightStack.length>0&&_.bottomRightStack[_.bottomRightStack.length-1].trailingComments&&_.bottomRightStack[_.bottomRightStack.length-1].trailingComments[0].range[0]>=e.range[1]&&(n=_.bottomRightStack[_.bottomRightStack.length-1].trailingComments,delete _.bottomRightStack[_.bottomRightStack.length-1].trailingComments);_.bottomRightStack.length>0&&_.bottomRightStack[_.bottomRightStack.length-1].range[0]>=e.range[0];)t=_.bottomRightStack.pop();t?t.leadingComments&&t.leadingComments[t.leadingComments.length-1].range[1]<=e.range[0]&&(e.leadingComments=t.leadingComments,delete t.leadingComments):_.leadingComments.length>0&&_.leadingComments[_.leadingComments.length-1].range[1]<=e.range[0]&&(e.leadingComments=_.leadingComments,_.leadingComments=[]),n&&(e.trailingComments=n),_.bottomRightStack.push(e)}},markEnd:function(e,t){return _.range&&(e.range=[t.start,d]),_.loc&&(e.loc=new V(void 0===t.startLineNumber?t.lineNumber:t.startLineNumber,t.start-(void 0===t.startLineStart?t.lineStart:t.startLineStart),f,d-h),this.postProcess(e)),_.attachComment&&this.processComment(e),e},postProcess:function(e){return _.source&&(e.loc.source=_.source),e},createArrayExpression:function(e){return{type:o.ArrayExpression,elements:e}},createAssignmentExpression:function(e,t,n){return{type:o.AssignmentExpression,operator:e,left:t,right:n}},createBinaryExpression:function(e,t,n){return{type:"||"===e||"&&"===e?o.LogicalExpression:o.BinaryExpression,operator:e,left:t,right:n}},createBlockStatement:function(e){return{type:o.BlockStatement,body:e}},createBreakStatement:function(e){return{type:o.BreakStatement,label:e}},createCallExpression:function(e,t){return{type:o.CallExpression,callee:e,arguments:t}},createCatchClause:function(e,t){return{type:o.CatchClause,param:e,body:t}},createConditionalExpression:function(e,t,n){return{type:o.ConditionalExpression,test:e,consequent:t,alternate:n}},createContinueStatement:function(e){return{type:o.ContinueStatement,label:e}},createDebuggerStatement:function(){return{type:o.DebuggerStatement}},createDoWhileStatement:function(e,t){return{type:o.DoWhileStatement,body:e,test:t}},createEmptyStatement:function(){return{type:o.EmptyStatement}},createExpressionStatement:function(e){return{type:o.ExpressionStatement,expression:e}},createForStatement:function(e,t,n,r){return{type:o.ForStatement,init:e,test:t,update:n,body:r}},createForInStatement:function(e,t,n){return{type:o.ForInStatement,left:e,right:t,body:n,each:!1}},createFunctionDeclaration:function(e,t,n,r){return{type:o.FunctionDeclaration,id:e,params:t,defaults:n,body:r,rest:null,generator:!1,expression:!1}},createFunctionExpression:function(e,t,n,r){return{type:o.FunctionExpression,id:e,params:t,defaults:n,body:r,rest:null,generator:!1,expression:!1}},createIdentifier:function(e){return{type:o.Identifier,name:e}},createIfStatement:function(e,t,n){return{type:o.IfStatement,test:e,consequent:t,alternate:n}},createLabeledStatement:function(e,t){return{type:o.LabeledStatement,label:e,body:t}},createLiteral:function(e){return{type:o.Literal,value:e.value,raw:c.slice(e.start,e.end)}},createMemberExpression:function(e,t,n){return{type:o.MemberExpression,computed:"["===e,object:t,property:n}},createNewExpression:function(e,t){return{type:o.NewExpression,callee:e,arguments:t}},createObjectExpression:function(e){return{type:o.ObjectExpression,properties:e}},createPostfixExpression:function(e,t){return{type:o.UpdateExpression,operator:e,argument:t,prefix:!1}},createProgram:function(e){return{type:o.Program,body:e}},createProperty:function(e,t,n){return{type:o.Property,key:t,value:n,kind:e}},createReturnStatement:function(e){return{type:o.ReturnStatement,argument:e}},createSequenceExpression:function(e){return{type:o.SequenceExpression,expressions:e}},createSwitchCase:function(e,t){return{type:o.SwitchCase,test:e,consequent:t}},createSwitchStatement:function(e,t){return{type:o.SwitchStatement,discriminant:e,cases:t}},createThisExpression:function(){return{type:o.ThisExpression}},createThrowStatement:function(e){return{type:o.ThrowStatement,argument:e}},createTryStatement:function(e,t,n,r){return{type:o.TryStatement,block:e,guardedHandlers:t,handlers:n,finalizer:r}},createUnaryExpression:function(e,t){return"++"===e||"--"===e?{type:o.UpdateExpression,operator:e,argument:t,prefix:!0}:{type:o.UnaryExpression,operator:e,argument:t,prefix:!0}},createVariableDeclaration:function(e,t){return{type:o.VariableDeclaration,declarations:e,kind:t}},createVariableDeclarator:function(e,t){return{type:o.VariableDeclarator,id:e,init:t}},createWhileStatement:function(e,t){return{type:o.WhileStatement,test:e,body:t}},createWithStatement:function(e,t){return{type:o.WithStatement,object:e,body:t}}},e.version="1.2.2",e.tokenize=function(e,n){var r;"string"==typeof e||e instanceof String||(e=String(e)),g=l,d=0,f=(c=e).length>0?1:0,h=0,p=c.length,m=null,y={allowIn:!0,labelSet:{},inFunctionBody:!1,inIteration:!1,inSwitch:!1,lastCommentStart:-1},_={},(n=n||{}).tokens=!0,_.tokens=[],_.tokenize=!0,_.openParenToken=-1,_.openCurlyToken=-1,_.range="boolean"==typeof n.range&&n.range,_.loc="boolean"==typeof n.loc&&n.loc,"boolean"==typeof n.comment&&n.comment&&(_.comments=[]),"boolean"==typeof n.tolerant&&n.tolerant&&(_.errors=[]);try{if(H(),m.type===t.EOF)return _.tokens;for($();m.type!==t.EOF;)try{$()}catch(e){if(_.errors){_.errors.push(e);break}throw e}ke(),r=_.tokens,void 0!==_.comments&&(r.comments=_.comments),void 0!==_.errors&&(r.errors=_.errors)}catch(e){throw e}finally{_={}}return r},e.parse=function(e,n){var r,i,s,v;i=String,"string"==typeof e||e instanceof String||(e=i(e)),g=l,d=0,f=(c=e).length>0?1:0,h=0,p=c.length,m=null,y={allowIn:!0,labelSet:{},inFunctionBody:!1,inIteration:!1,inSwitch:!1,lastCommentStart:-1},_={},void 0!==n&&(_.range="boolean"==typeof n.range&&n.range,_.loc="boolean"==typeof n.loc&&n.loc,_.attachComment="boolean"==typeof n.attachComment&&n.attachComment,_.loc&&null!=n.source&&(_.source=i(n.source)),"boolean"==typeof n.tokens&&n.tokens&&(_.tokens=[]),"boolean"==typeof n.comment&&n.comment&&(_.comments=[]),"boolean"==typeof n.tolerant&&n.tolerant&&(_.errors=[]),_.attachComment&&(_.range=!0,_.comments=[],_.bottomRightStack=[],_.trailingComments=[],_.leadingComments=[]));try{D(),H(),v=m,u=!1,s=function(){for(var e,n,r,i=[];d<p&&(n=m).type===t.StringLiteral&&(e=Ae(),i.push(e),e.expression.type===o.Literal);)"use strict"===c.slice(n.start+1,n.end-1)?(u=!0,r&&K(r,a.StrictOctalLiteral)):!r&&n.octal&&(r=n);for(;d<p&&void 0!==(e=Ae());)i.push(e);return i}(),r=g.markEnd(g.createProgram(s),v),void 0!==_.comments&&(r.comments=_.comments),void 0!==_.tokens&&(ke(),r.tokens=_.tokens),void 0!==_.errors&&(r.errors=_.errors)}catch(e){throw e}finally{_={}}return r},e.Syntax=function(){var e,t={};for(e in"function"==typeof Object.create&&(t=Object.create(null)),o)o.hasOwnProperty(e)&&(t[e]=o[e]);return"function"==typeof Object.freeze&&Object.freeze(t),t}()},r(void 0!==n?n:this.esprima={})},{}],1:[function(e,t,n){(function(r){var o=function(){var e={trace:function(){},yy:{},symbols_:{error:2,JSON_PATH:3,DOLLAR:4,PATH_COMPONENTS:5,LEADING_CHILD_MEMBER_EXPRESSION:6,PATH_COMPONENT:7,MEMBER_COMPONENT:8,SUBSCRIPT_COMPONENT:9,CHILD_MEMBER_COMPONENT:10,DESCENDANT_MEMBER_COMPONENT:11,DOT:12,MEMBER_EXPRESSION:13,DOT_DOT:14,STAR:15,IDENTIFIER:16,SCRIPT_EXPRESSION:17,INTEGER:18,END:19,CHILD_SUBSCRIPT_COMPONENT:20,DESCENDANT_SUBSCRIPT_COMPONENT:21,"[":22,SUBSCRIPT:23,"]":24,SUBSCRIPT_EXPRESSION:25,SUBSCRIPT_EXPRESSION_LIST:26,SUBSCRIPT_EXPRESSION_LISTABLE:27,",":28,STRING_LITERAL:29,ARRAY_SLICE:30,FILTER_EXPRESSION:31,QQ_STRING:32,Q_STRING:33,$accept:0,$end:1},terminals_:{2:"error",4:"DOLLAR",12:"DOT",14:"DOT_DOT",15:"STAR",16:"IDENTIFIER",17:"SCRIPT_EXPRESSION",18:"INTEGER",19:"END",22:"[",24:"]",28:",",30:"ARRAY_SLICE",31:"FILTER_EXPRESSION",32:"QQ_STRING",33:"Q_STRING"},productions_:[0,[3,1],[3,2],[3,1],[3,2],[5,1],[5,2],[7,1],[7,1],[8,1],[8,1],[10,2],[6,1],[11,2],[13,1],[13,1],[13,1],[13,1],[13,1],[9,1],[9,1],[20,3],[21,4],[23,1],[23,1],[26,1],[26,3],[27,1],[27,1],[27,1],[25,1],[25,1],[25,1],[29,1],[29,1]],performAction:function(e,n,r,o,i,a,s){o.ast||(o.ast=t,t.initialize());var l=a.length-1;switch(i){case 1:return o.ast.set({expression:{type:"root",value:a[l]}}),o.ast.unshift(),o.ast.yield();case 2:return o.ast.set({expression:{type:"root",value:a[l-1]}}),o.ast.unshift(),o.ast.yield();case 3:return o.ast.unshift(),o.ast.yield();case 4:return o.ast.set({operation:"member",scope:"child",expression:{type:"identifier",value:a[l-1]}}),o.ast.unshift(),o.ast.yield();case 5:case 6:case 11:case 13:case 18:case 21:case 22:case 23:break;case 7:o.ast.set({operation:"member"}),o.ast.push();break;case 8:o.ast.set({operation:"subscript"}),o.ast.push();break;case 9:case 19:o.ast.set({scope:"child"});break;case 10:case 20:o.ast.set({scope:"descendant"});break;case 12:o.ast.set({scope:"child",operation:"member"});break;case 14:o.ast.set({expression:{type:"wildcard",value:a[l]}});break;case 15:o.ast.set({expression:{type:"identifier",value:a[l]}});break;case 16:o.ast.set({expression:{type:"script_expression",value:a[l]}});break;case 17:o.ast.set({expression:{type:"numeric_literal",value:parseInt(a[l])}});break;case 24:a[l].length>1?o.ast.set({expression:{type:"union",value:a[l]}}):this.$=a[l];break;case 25:this.$=[a[l]];break;case 26:this.$=a[l-2].concat(a[l]);break;case 27:this.$={expression:{type:"numeric_literal",value:parseInt(a[l])}},o.ast.set(this.$);break;case 28:this.$={expression:{type:"string_literal",value:a[l]}},o.ast.set(this.$);break;case 29:this.$={expression:{type:"slice",value:a[l]}},o.ast.set(this.$);break;case 30:this.$={expression:{type:"wildcard",value:a[l]}},o.ast.set(this.$);break;case 31:this.$={expression:{type:"script_expression",value:a[l]}},o.ast.set(this.$);break;case 32:this.$={expression:{type:"filter_expression",value:a[l]}},o.ast.set(this.$);break;case 33:case 34:this.$=a[l]}},table:[{3:1,4:[1,2],6:3,13:4,15:[1,5],16:[1,6],17:[1,7],18:[1,8],19:[1,9]},{1:[3]},{1:[2,1],5:10,7:11,8:12,9:13,10:14,11:15,12:[1,18],14:[1,19],20:16,21:17,22:[1,20]},{1:[2,3],5:21,7:11,8:12,9:13,10:14,11:15,12:[1,18],14:[1,19],20:16,21:17,22:[1,20]},{1:[2,12],12:[2,12],14:[2,12],22:[2,12]},{1:[2,14],12:[2,14],14:[2,14],22:[2,14]},{1:[2,15],12:[2,15],14:[2,15],22:[2,15]},{1:[2,16],12:[2,16],14:[2,16],22:[2,16]},{1:[2,17],12:[2,17],14:[2,17],22:[2,17]},{1:[2,18],12:[2,18],14:[2,18],22:[2,18]},{1:[2,2],7:22,8:12,9:13,10:14,11:15,12:[1,18],14:[1,19],20:16,21:17,22:[1,20]},{1:[2,5],12:[2,5],14:[2,5],22:[2,5]},{1:[2,7],12:[2,7],14:[2,7],22:[2,7]},{1:[2,8],12:[2,8],14:[2,8],22:[2,8]},{1:[2,9],12:[2,9],14:[2,9],22:[2,9]},{1:[2,10],12:[2,10],14:[2,10],22:[2,10]},{1:[2,19],12:[2,19],14:[2,19],22:[2,19]},{1:[2,20],12:[2,20],14:[2,20],22:[2,20]},{13:23,15:[1,5],16:[1,6],17:[1,7],18:[1,8],19:[1,9]},{13:24,15:[1,5],16:[1,6],17:[1,7],18:[1,8],19:[1,9],22:[1,25]},{15:[1,29],17:[1,30],18:[1,33],23:26,25:27,26:28,27:32,29:34,30:[1,35],31:[1,31],32:[1,36],33:[1,37]},{1:[2,4],7:22,8:12,9:13,10:14,11:15,12:[1,18],14:[1,19],20:16,21:17,22:[1,20]},{1:[2,6],12:[2,6],14:[2,6],22:[2,6]},{1:[2,11],12:[2,11],14:[2,11],22:[2,11]},{1:[2,13],12:[2,13],14:[2,13],22:[2,13]},{15:[1,29],17:[1,30],18:[1,33],23:38,25:27,26:28,27:32,29:34,30:[1,35],31:[1,31],32:[1,36],33:[1,37]},{24:[1,39]},{24:[2,23]},{24:[2,24],28:[1,40]},{24:[2,30]},{24:[2,31]},{24:[2,32]},{24:[2,25],28:[2,25]},{24:[2,27],28:[2,27]},{24:[2,28],28:[2,28]},{24:[2,29],28:[2,29]},{24:[2,33],28:[2,33]},{24:[2,34],28:[2,34]},{24:[1,41]},{1:[2,21],12:[2,21],14:[2,21],22:[2,21]},{18:[1,33],27:42,29:34,30:[1,35],32:[1,36],33:[1,37]},{1:[2,22],12:[2,22],14:[2,22],22:[2,22]},{24:[2,26],28:[2,26]}],defaultActions:{27:[2,23],29:[2,30],30:[2,31],31:[2,32]},parseError:function(e,t){if(!t.recoverable)throw new Error(e);this.trace(e)},parse:function(e){var t=this,n=[0],r=[null],o=[],i=this.table,a="",s=0,l=0,c=o.slice.call(arguments,1);this.lexer.setInput(e),this.lexer.yy=this.yy,this.yy.lexer=this.lexer,this.yy.parser=this,void 0===this.lexer.yylloc&&(this.lexer.yylloc={});var u=this.lexer.yylloc;o.push(u);var d=this.lexer.options&&this.lexer.options.ranges;function f(){var e;return"number"!=typeof(e=t.lexer.lex()||1)&&(e=t.symbols_[e]||e),e}this.parseError="function"==typeof this.yy.parseError?this.yy.parseError:Object.getPrototypeOf(this).parseError;for(var h,p,g,m,y,_,v,b={};;){if(this.defaultActions[p=n[n.length-1]]?g=this.defaultActions[p]:(null==h&&(h=f()),g=i[p]&&i[p][h]),void 0===g||!g.length||!g[0]){var x;for(y in v=[],i[p])this.terminals_[y]&&y>2&&v.push("'"+this.terminals_[y]+"'");x=this.lexer.showPosition?"Parse error on line "+(s+1)+":\n"+this.lexer.showPosition()+"\nExpecting "+v.join(", ")+", got '"+(this.terminals_[h]||h)+"'":"Parse error on line "+(s+1)+": Unexpected "+(1==h?"end of input":"'"+(this.terminals_[h]||h)+"'"),this.parseError(x,{text:this.lexer.match,token:this.terminals_[h]||h,line:this.lexer.yylineno,loc:u,expected:v})}if(g[0]instanceof Array&&g.length>1)throw new Error("Parse Error: multiple actions possible at state: "+p+", token: "+h);switch(g[0]){case 1:n.push(h),r.push(this.lexer.yytext),o.push(this.lexer.yylloc),n.push(g[1]),h=null,l=this.lexer.yyleng,a=this.lexer.yytext,s=this.lexer.yylineno,u=this.lexer.yylloc;break;case 2:if(b.$=r[r.length-(_=this.productions_[g[1]][1])],b._$={first_line:o[o.length-(_||1)].first_line,last_line:o[o.length-1].last_line,first_column:o[o.length-(_||1)].first_column,last_column:o[o.length-1].last_column},d&&(b._$.range=[o[o.length-(_||1)].range[0],o[o.length-1].range[1]]),void 0!==(m=this.performAction.apply(b,[a,l,s,this.yy,g[1],r,o].concat(c))))return m;_&&(n=n.slice(0,-1*_*2),r=r.slice(0,-1*_),o=o.slice(0,-1*_)),n.push(this.productions_[g[1]][0]),r.push(b.$),o.push(b._$),n.push(i[n[n.length-2]][n[n.length-1]]);break;case 3:return!0}}return!0}},t={initialize:function(){this._nodes=[],this._node={},this._stash=[]},set:function(e){for(var t in e)this._node[t]=e[t];return this._node},node:function(e){return arguments.length&&(this._node=e),this._node},push:function(){this._nodes.push(this._node),this._node={}},unshift:function(){this._nodes.unshift(this._node),this._node={}},yield:function(){var e=this._nodes;return this.initialize(),e}},n=function(){var e={EOF:1,parseError:function(e,t){if(!this.yy.parser)throw new Error(e);this.yy.parser.parseError(e,t)},setInput:function(e){return this._input=e,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var e=this._input[0];return this.yytext+=e,this.yyleng++,this.offset++,this.match+=e,this.matched+=e,e.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),e},unput:function(e){var t=e.length,n=e.split(/(?:\r\n?|\n)/g);this._input=e+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-t-1),this.offset-=t;var r=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),n.length-1&&(this.yylineno-=n.length-1);var o=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:n?(n.length===r.length?this.yylloc.first_column:0)+r[r.length-n.length].length-n[0].length:this.yylloc.first_column-t},this.options.ranges&&(this.yylloc.range=[o[0],o[0]+this.yyleng-t]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(e){this.unput(this.match.slice(e))},pastInput:function(){var e=this.matched.substr(0,this.matched.length-this.match.length);return(e.length>20?"...":"")+e.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var e=this.match;return e.length<20&&(e+=this._input.substr(0,20-e.length)),(e.substr(0,20)+(e.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var e=this.pastInput(),t=new Array(e.length+1).join("-");return e+this.upcomingInput()+"\n"+t+"^"},test_match:function(e,t){var n,r,o;if(this.options.backtrack_lexer&&(o={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(o.yylloc.range=this.yylloc.range.slice(0))),(r=e[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=r.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:r?r[r.length-1].length-r[r.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+e[0].length},this.yytext+=e[0],this.match+=e[0],this.matches=e,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(e[0].length),this.matched+=e[0],n=this.performAction.call(this,this.yy,this,t,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),n)return n;if(this._backtrack){for(var i in o)this[i]=o[i];return!1}return!1},next:function(){if(this.done)return this.EOF;var e,t,n,r;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var o=this._currentRules(),i=0;i<o.length;i++)if((n=this._input.match(this.rules[o[i]]))&&(!t||n[0].length>t[0].length)){if(t=n,r=i,this.options.backtrack_lexer){if(!1!==(e=this.test_match(n,o[i])))return e;if(this._backtrack){t=!1;continue}return!1}if(!this.options.flex)break}return t?!1!==(e=this.test_match(t,o[r]))&&e:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){return this.next()||this.lex()},begin:function(e){this.conditionStack.push(e)},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(e){return(e=this.conditionStack.length-1-Math.abs(e||0))>=0?this.conditionStack[e]:"INITIAL"},pushState:function(e){this.begin(e)},stateStackSize:function(){return this.conditionStack.length},options:{},performAction:function(e,t,n,r){switch(n){case 0:return 4;case 1:return 14;case 2:return 12;case 3:return 15;case 4:return 16;case 5:return 22;case 6:return 24;case 7:return 28;case 8:return 30;case 9:return 18;case 10:return t.yytext=t.yytext.substr(1,t.yyleng-2),32;case 11:return t.yytext=t.yytext.substr(1,t.yyleng-2),33;case 12:return 17;case 13:return 31}},rules:[/^(?:\$)/,/^(?:\.\.)/,/^(?:\.)/,/^(?:\*)/,/^(?:[a-zA-Z_]+[a-zA-Z0-9_]*)/,/^(?:\[)/,/^(?:\])/,/^(?:,)/,/^(?:((-?(?:0|[1-9][0-9]*)))?\:((-?(?:0|[1-9][0-9]*)))?(\:((-?(?:0|[1-9][0-9]*)))?)?)/,/^(?:(-?(?:0|[1-9][0-9]*)))/,/^(?:"(?:\\["bfnrt/\\]|\\u[a-fA-F0-9]{4}|[^"\\])*")/,/^(?:'(?:\\['bfnrt/\\]|\\u[a-fA-F0-9]{4}|[^'\\])*')/,/^(?:\(.+?\)(?=\]))/,/^(?:\?\(.+?\)(?=\]))/],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13],inclusive:!0}}};return e}();function r(){this.yy={}}return e.lexer=n,r.prototype=e,e.Parser=r,new r}();void 0!==e&&void 0!==n&&(n.parser=o,n.Parser=o.Parser,n.parse=function(){return o.parse.apply(o,arguments)},n.main=function(t){t[1]||(console.log("Usage: "+t[0]+" FILE"),r.exit(1));var o=e("fs").readFileSync(e("path").normalize(t[1]),"utf8");return n.parser.parse(o)},void 0!==t&&e.main===t&&n.main(r.argv.slice(1)))}).call(this,e("_process"))},{_process:14,fs:12,path:13}],2:[function(e,t,n){t.exports={identifier:"[a-zA-Z_]+[a-zA-Z0-9_]*",integer:"-?(?:0|[1-9][0-9]*)",qq_string:'"(?:\\\\["bfnrt/\\\\]|\\\\u[a-fA-F0-9]{4}|[^"\\\\])*"',q_string:"'(?:\\\\['bfnrt/\\\\]|\\\\u[a-fA-F0-9]{4}|[^'\\\\])*'"}},{}],3:[function(e,t,n){var r=e("./dict"),o=e("fs"),i={lex:{macros:{esc:"\\\\",int:r.integer},rules:[["\\$","return 'DOLLAR'"],["\\.\\.","return 'DOT_DOT'"],["\\.","return 'DOT'"],["\\*","return 'STAR'"],[r.identifier,"return 'IDENTIFIER'"],["\\[","return '['"],["\\]","return ']'"],[",","return ','"],["({int})?\\:({int})?(\\:({int})?)?","return 'ARRAY_SLICE'"],["{int}","return 'INTEGER'"],[r.qq_string,"yytext = yytext.substr(1,yyleng-2); return 'QQ_STRING';"],[r.q_string,"yytext = yytext.substr(1,yyleng-2); return 'Q_STRING';"],["\\(.+?\\)(?=\\])","return 'SCRIPT_EXPRESSION'"],["\\?\\(.+?\\)(?=\\])","return 'FILTER_EXPRESSION'"]]},start:"JSON_PATH",bnf:{JSON_PATH:[["DOLLAR",'yy.ast.set({ expression: { type: "root", value: $1 } }); yy.ast.unshift(); return yy.ast.yield()'],["DOLLAR PATH_COMPONENTS",'yy.ast.set({ expression: { type: "root", value: $1 } }); yy.ast.unshift(); return yy.ast.yield()'],["LEADING_CHILD_MEMBER_EXPRESSION","yy.ast.unshift(); return yy.ast.yield()"],["LEADING_CHILD_MEMBER_EXPRESSION PATH_COMPONENTS",'yy.ast.set({ operation: "member", scope: "child", expression: { type: "identifier", value: $1 }}); yy.ast.unshift(); return yy.ast.yield()']],PATH_COMPONENTS:[["PATH_COMPONENT",""],["PATH_COMPONENTS PATH_COMPONENT",""]],PATH_COMPONENT:[["MEMBER_COMPONENT",'yy.ast.set({ operation: "member" }); yy.ast.push()'],["SUBSCRIPT_COMPONENT",'yy.ast.set({ operation: "subscript" }); yy.ast.push() ']],MEMBER_COMPONENT:[["CHILD_MEMBER_COMPONENT",'yy.ast.set({ scope: "child" })'],["DESCENDANT_MEMBER_COMPONENT",'yy.ast.set({ scope: "descendant" })']],CHILD_MEMBER_COMPONENT:[["DOT MEMBER_EXPRESSION",""]],LEADING_CHILD_MEMBER_EXPRESSION:[["MEMBER_EXPRESSION",'yy.ast.set({ scope: "child", operation: "member" })']],DESCENDANT_MEMBER_COMPONENT:[["DOT_DOT MEMBER_EXPRESSION",""]],MEMBER_EXPRESSION:[["STAR",'yy.ast.set({ expression: { type: "wildcard", value: $1 } })'],["IDENTIFIER",'yy.ast.set({ expression: { type: "identifier", value: $1 } })'],["SCRIPT_EXPRESSION",'yy.ast.set({ expression: { type: "script_expression", value: $1 } })'],["INTEGER",'yy.ast.set({ expression: { type: "numeric_literal", value: parseInt($1) } })'],["END",""]],SUBSCRIPT_COMPONENT:[["CHILD_SUBSCRIPT_COMPONENT",'yy.ast.set({ scope: "child" })'],["DESCENDANT_SUBSCRIPT_COMPONENT",'yy.ast.set({ scope: "descendant" })']],CHILD_SUBSCRIPT_COMPONENT:[["[ SUBSCRIPT ]",""]],DESCENDANT_SUBSCRIPT_COMPONENT:[["DOT_DOT [ SUBSCRIPT ]",""]],SUBSCRIPT:[["SUBSCRIPT_EXPRESSION",""],["SUBSCRIPT_EXPRESSION_LIST",'$1.length > 1? yy.ast.set({ expression: { type: "union", value: $1 } }) : $$ = $1']],SUBSCRIPT_EXPRESSION_LIST:[["SUBSCRIPT_EXPRESSION_LISTABLE","$$ = [$1]"],["SUBSCRIPT_EXPRESSION_LIST , SUBSCRIPT_EXPRESSION_LISTABLE","$$ = $1.concat($3)"]],SUBSCRIPT_EXPRESSION_LISTABLE:[["INTEGER",'$$ = { expression: { type: "numeric_literal", value: parseInt($1) } }; yy.ast.set($$)'],["STRING_LITERAL",'$$ = { expression: { type: "string_literal", value: $1 } }; yy.ast.set($$)'],["ARRAY_SLICE",'$$ = { expression: { type: "slice", value: $1 } }; yy.ast.set($$)']],SUBSCRIPT_EXPRESSION:[["STAR",'$$ = { expression: { type: "wildcard", value: $1 } }; yy.ast.set($$)'],["SCRIPT_EXPRESSION",'$$ = { expression: { type: "script_expression", value: $1 } }; yy.ast.set($$)'],["FILTER_EXPRESSION",'$$ = { expression: { type: "filter_expression", value: $1 } }; yy.ast.set($$)']],STRING_LITERAL:[["QQ_STRING","$$ = $1"],["Q_STRING","$$ = $1"]]}};o.readFileSync&&(i.moduleInclude=o.readFileSync(e.resolve("../include/module.js")),i.actionInclude=o.readFileSync(e.resolve("../include/action.js"))),t.exports=i},{"./dict":2,fs:12}],4:[function(e,t,n){var r=e("./aesprim"),o=e("./slice"),i=e("static-eval"),a=e("underscore").uniq,s=function(){return this.initialize.apply(this,arguments)};function l(t,n,o){var i=e("./index"),a=h(r.parse(n).body[0].expression,{"@":t.value}),s=o.replace(/\{\{\s*value\s*\}\}/g,a),l=i.nodes(t.value,s);return l.forEach((function(e){e.path=t.path.concat(e.path.slice(1))})),l}function c(e){return Array.isArray(e)}function u(e){return function(t,n,r,o){var i=t.value,a=t.path,s=[],l=function(t,i){var a;c(t)?(t.forEach((function(e,t){s.length>=o||r(t,e,n)&&s.push({path:i.concat(t),value:e})})),t.forEach((function(t,n){s.length>=o||e&&l(t,i.concat(n))}))):(a=t)&&!(a instanceof Array)&&a instanceof Object&&(this.keys(t).forEach((function(e){s.length>=o||r(e,t[e],n)&&s.push({path:i.concat(e),value:t[e]})})),this.keys(t).forEach((function(n){s.length>=o||e&&l(t[n],i.concat(n))})))}.bind(this);return l(i,a),s}}function d(e){return function(t,n,r){return this.descend(n,t.expression.value,e,r)}}function f(e){return function(t,n,r){return this.traverse(n,t.expression.value,e,r)}}function h(){try{return i.apply(this,arguments)}catch(e){}}function p(e){return e=e.filter((function(e){return e})),a(e,(function(e){return e.path.map((function(e){return String(e).replace("-","--")})).join("-")}))}function g(e){var t=String(e);return t.match(/^-?[0-9]+$/)?parseInt(t):null}s.prototype.initialize=function(){this.traverse=u(!0),this.descend=u()},s.prototype.keys=Object.keys,s.prototype.resolve=function(e){var t=[e.operation,e.scope,e.expression.type].join("-"),n=this._fns[t];if(!n)throw new Error("couldn't resolve key: "+t);return n.bind(this)},s.prototype.register=function(e,t){if(!t instanceof Function)throw new Error("handler must be a function");this._fns[e]=t},s.prototype._fns={"member-child-identifier":function(e,t){var n=e.expression.value,r=t.value;if(r instanceof Object&&n in r)return[{value:r[n],path:t.path.concat(n)}]},"member-descendant-identifier":f((function(e,t,n){return e==n})),"subscript-child-numeric_literal":d((function(e,t,n){return e===n})),"member-child-numeric_literal":d((function(e,t,n){return String(e)===String(n)})),"subscript-descendant-numeric_literal":f((function(e,t,n){return e===n})),"member-child-wildcard":d((function(){return!0})),"member-descendant-wildcard":f((function(){return!0})),"subscript-descendant-wildcard":f((function(){return!0})),"subscript-child-wildcard":d((function(){return!0})),"subscript-child-slice":function(e,t){if(c(t.value)){var n=e.expression.value.split(":").map(g),r=t.value.map((function(e,n){return{value:e,path:t.path.concat(n)}}));return o.apply(null,[r].concat(n))}},"subscript-child-union":function(e,t){var n=[];return e.expression.value.forEach((function(e){var r={operation:"subscript",scope:"child",expression:e.expression},o=this.resolve(r)(r,t);o&&(n=n.concat(o))}),this),p(n)},"subscript-descendant-union":function(t,n,r){var o=e(".."),i=this,a=[];return o.nodes(n,"$..*").slice(1).forEach((function(e){a.length>=r||t.expression.value.forEach((function(t){var n={operation:"subscript",scope:"child",expression:t.expression},r=i.resolve(n)(n,e);a=a.concat(r)}))})),p(a)},"subscript-child-filter_expression":function(e,t,n){var o=e.expression.value.slice(2,-1),i=r.parse(o).body[0].expression;return this.descend(t,null,(function(e,t){return h(i,{"@":t})}),n)},"subscript-descendant-filter_expression":function(e,t,n){var o=e.expression.value.slice(2,-1),i=r.parse(o).body[0].expression;return this.traverse(t,null,(function(e,t){return h(i,{"@":t})}),n)},"subscript-child-script_expression":function(e,t){return l(t,e.expression.value.slice(1,-1),"$[{{value}}]")},"member-child-script_expression":function(e,t){return l(t,e.expression.value.slice(1,-1),"$.{{value}}")},"member-descendant-script_expression":function(e,t){return l(t,e.expression.value.slice(1,-1),"$..value")}},s.prototype._fns["subscript-child-string_literal"]=s.prototype._fns["member-child-identifier"],s.prototype._fns["member-descendant-numeric_literal"]=s.prototype._fns["subscript-descendant-string_literal"]=s.prototype._fns["member-descendant-identifier"],t.exports=s},{"..":"jsonpath","./aesprim":"./aesprim","./index":5,"./slice":7,"static-eval":15,underscore:12}],5:[function(e,t,n){var r=e("assert"),o=e("./dict"),i=e("./parser"),a=e("./handlers"),s=function(){this.initialize.apply(this,arguments)};function l(e){return"[object String]"==Object.prototype.toString.call(e)}s.prototype.initialize=function(){this.parser=new i,this.handlers=new a},s.prototype.parse=function(e){return r.ok(l(e),"we need a path"),this.parser.parse(e)},s.prototype.parent=function(e,t){r.ok(e instanceof Object,"obj needs to be an object"),r.ok(t,"we need a path");var n=this.nodes(e,t)[0];return n.path.pop(),this.value(e,n.path)},s.prototype.apply=function(e,t,n){r.ok(e instanceof Object,"obj needs to be an object"),r.ok(t,"we need a path"),r.equal(K(n),"function","fn needs to be function");var o=this.nodes(e,t).sort((function(e,t){return t.path.length-e.path.length}));return o.forEach((function(t){var r=t.path.pop(),o=this.value(e,this.stringify(t.path)),i=t.value=n.call(e,o[r]);o[r]=i}),this),o},s.prototype.value=function(e,t,n){if(r.ok(e instanceof Object,"obj needs to be an object"),r.ok(t,"we need a path"),arguments.length>=3){var o=this.nodes(e,t).shift();if(!o)return this._vivify(e,t,n);var i=o.path.slice(-1).shift();this.parent(e,this.stringify(o.path))[i]=n}return this.query(e,this.stringify(t),1).shift()},s.prototype._vivify=function(e,t,n){var o=this;r.ok(e instanceof Object,"obj needs to be an object"),r.ok(t,"we need a path");var i=this.parser.parse(t).map((function(e){return e.expression.value})),a=function(t,n){var r=t.pop(),i=o.value(e,t);i||(a(t.concat(),"string"==typeof r?{}:[]),i=o.value(e,t)),i[r]=n};return a(i,n),this.query(e,t)[0]},s.prototype.query=function(e,t,n){r.ok(e instanceof Object,"obj needs to be an object"),r.ok(l(t),"we need a path");var o=this.nodes(e,t,n).map((function(e){return e.value}));return o},s.prototype.paths=function(e,t,n){r.ok(e instanceof Object,"obj needs to be an object"),r.ok(t,"we need a path");var o=this.nodes(e,t,n).map((function(e){return e.path}));return o},s.prototype.nodes=function(e,t,n){if(r.ok(e instanceof Object,"obj needs to be an object"),r.ok(t,"we need a path"),0===n)return[];var o=this.parser.parse(t),i=this.handlers,a=[{path:["$"],value:e}],s=[];return o.length&&"root"==o[0].expression.type&&o.shift(),o.length?(o.forEach((function(e,t){if(!(s.length>=n)){var r=i.resolve(e),l=[];a.forEach((function(i){if(!(s.length>=n)){var a=r(e,i,n);t==o.length-1?s=s.concat(a||[]):l=l.concat(a||[])}})),a=l}})),n?s.slice(0,n):s):a},s.prototype.stringify=function(e){r.ok(e,"we need a path");var t="$",n={"descendant-member":"..{{value}}","child-member":".{{value}}","descendant-subscript":"..[{{value}}]","child-subscript":"[{{value}}]"};return(e=this._normalize(e)).forEach((function(e){if("root"!=e.expression.type){var r,o=[e.scope,e.operation].join("-"),i=n[o];if(r="string_literal"==e.expression.type?JSON.stringify(e.expression.value):e.expression.value,!i)throw new Error("couldn't find template "+o);t+=i.replace(/{{value}}/,r)}})),t},s.prototype._normalize=function(e){if(r.ok(e,"we need a path"),"string"==typeof e)return this.parser.parse(e);if(Array.isArray(e)&&"string"==typeof e[0]){var t=[{expression:{type:"root",value:"$"}}];return e.forEach((function(e,n){"$"==e&&0===n||("string"==typeof e&&e.match("^"+o.identifier+"$")?t.push({operation:"member",scope:"child",expression:{value:e,type:"identifier"}}):t.push({operation:"subscript",scope:"child",expression:{value:e,type:"number"==typeof e?"numeric_literal":"string_literal"}}))})),t}if(Array.isArray(e)&&"object"==K(e[0]))return e;throw new Error("couldn't understand path "+e)},s.Handlers=a,s.Parser=i;var c=new s;c.JSONPath=s,t.exports=c},{"./dict":2,"./handlers":4,"./parser":6,assert:8}],6:[function(e,t,n){var r=e("./grammar"),o=e("../generated/parser"),i=function(){var e=new o.Parser,t=e.parseError;return e.yy.parseError=function(){e.yy.ast&&e.yy.ast.initialize(),t.apply(e,arguments)},e};i.grammar=r,t.exports=i},{"../generated/parser":1,"./grammar":3}],7:[function(e,t,n){function r(e){return String(e).match(/^[0-9]+$/)?parseInt(e):Number.isFinite(e)?parseInt(e,10):0}t.exports=function(e,t,n,o){if("string"==typeof t)throw new Error("start cannot be a string");if("string"==typeof n)throw new Error("end cannot be a string");if("string"==typeof o)throw new Error("step cannot be a string");var i=e.length;if(0===o)throw new Error("step cannot be zero");if(o=o?r(o):1,n=n<0?i+n:n,t=r(0===(t=t<0?i+t:t)?0:t||(o>0?0:i-1)),n=r(0===n?0:n||(o>0?i:-1)),t=o>0?Math.max(0,t):Math.min(i,t),n=o>0?Math.min(n,i):Math.max(-1,n),o>0&&n<=t)return[];if(o<0&&t<=n)return[];for(var a=[],s=t;s!=n&&!(o<0&&s<=n||o>0&&s>=n);s+=o)a.push(e[s]);return a}},{}],8:[function(e,t,n){var r=e("util/"),o=Array.prototype.slice,i=Object.prototype.hasOwnProperty,a=t.exports=u;function s(e,t){return r.isUndefined(t)?""+t:r.isNumber(t)&&!isFinite(t)||r.isFunction(t)||r.isRegExp(t)?t.toString():t}function l(e,t){return r.isString(e)?e.length<t?e:e.slice(0,t):e}function c(e,t,n,r,o){throw new a.AssertionError({message:n,actual:e,expected:t,operator:r,stackStartFunction:o})}function u(e,t){e||c(e,!0,t,"==",a.ok)}function d(e,t){if(e===t)return!0;if(r.isBuffer(e)&&r.isBuffer(t)){if(e.length!=t.length)return!1;for(var n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}return r.isDate(e)&&r.isDate(t)?e.getTime()===t.getTime():r.isRegExp(e)&&r.isRegExp(t)?e.source===t.source&&e.global===t.global&&e.multiline===t.multiline&&e.lastIndex===t.lastIndex&&e.ignoreCase===t.ignoreCase:r.isObject(e)||r.isObject(t)?function(e,t){if(r.isNullOrUndefined(e)||r.isNullOrUndefined(t))return!1;if(e.prototype!==t.prototype)return!1;if(r.isPrimitive(e)||r.isPrimitive(t))return e===t;var n=f(e),i=f(t);if(n&&!i||!n&&i)return!1;if(n)return d(e=o.call(e),t=o.call(t));var a,s,l=g(e),c=g(t);if(l.length!=c.length)return!1;for(l.sort(),c.sort(),s=l.length-1;s>=0;s--)if(l[s]!=c[s])return!1;for(s=l.length-1;s>=0;s--)if(!d(e[a=l[s]],t[a]))return!1;return!0}(e,t):e==t}function f(e){return"[object Arguments]"==Object.prototype.toString.call(e)}function h(e,t){return!(!e||!t)&&("[object RegExp]"==Object.prototype.toString.call(t)?t.test(e):e instanceof t||!0===t.call({},e))}function p(e,t,n,o){var i;r.isString(n)&&(o=n,n=null);try{t()}catch(e){i=e}if(o=(n&&n.name?" ("+n.name+").":".")+(o?" "+o:"."),e&&!i&&c(i,n,"Missing expected exception"+o),!e&&h(i,n)&&c(i,n,"Got unwanted exception"+o),e&&i&&n&&!h(i,n)||!e&&i)throw i}a.AssertionError=function(e){this.name="AssertionError",this.actual=e.actual,this.expected=e.expected,this.operator=e.operator,e.message?(this.message=e.message,this.generatedMessage=!1):(this.message=function(e){return l(JSON.stringify(e.actual,s),128)+" "+e.operator+" "+l(JSON.stringify(e.expected,s),128)}(this),this.generatedMessage=!0);var t=e.stackStartFunction||c;if(Error.captureStackTrace)Error.captureStackTrace(this,t);else{var n=new Error;if(n.stack){var r=n.stack,o=r.indexOf("\n"+t.name);if(o>=0){var i=r.indexOf("\n",o+1);r=r.substring(i+1)}this.stack=r}}},r.inherits(a.AssertionError,Error),a.fail=c,a.ok=u,a.equal=function(e,t,n){e!=t&&c(e,t,n,"==",a.equal)},a.notEqual=function(e,t,n){e==t&&c(e,t,n,"!=",a.notEqual)},a.deepEqual=function(e,t,n){d(e,t)||c(e,t,n,"deepEqual",a.deepEqual)},a.notDeepEqual=function(e,t,n){d(e,t)&&c(e,t,n,"notDeepEqual",a.notDeepEqual)},a.strictEqual=function(e,t,n){e!==t&&c(e,t,n,"===",a.strictEqual)},a.notStrictEqual=function(e,t,n){e===t&&c(e,t,n,"!==",a.notStrictEqual)},a.throws=function(e,t,n){p.apply(this,[!0].concat(o.call(arguments)))},a.doesNotThrow=function(e,t){p.apply(this,[!1].concat(o.call(arguments)))},a.ifError=function(e){if(e)throw e};var g=Object.keys||function(e){var t=[];for(var n in e)i.call(e,n)&&t.push(n);return t}},{"util/":11}],9:[function(e,t,n){t.exports="function"==typeof Object.create?function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}},{}],10:[function(e,t,n){t.exports=function(e){return e&&"object"===K(e)&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},{}],11:[function(e,t,n){(function(t,r){var o=/%[sdj%]/g;n.format=function(e){if(!y(e)){for(var t=[],n=0;n<arguments.length;n++)t.push(s(arguments[n]));return t.join(" ")}n=1;for(var r=arguments,i=r.length,a=String(e).replace(o,(function(e){if("%%"===e)return"%";if(n>=i)return e;switch(e){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(e){return"[Circular]"}default:return e}})),l=r[n];n<i;l=r[++n])g(l)||!b(l)?a+=" "+l:a+=" "+s(l);return a},n.deprecate=function(e,o){if(_(r.process))return function(){return n.deprecate(e,o).apply(this,arguments)};if(!0===t.noDeprecation)return e;var i=!1;return function(){if(!i){if(t.throwDeprecation)throw new Error(o);t.traceDeprecation?console.trace(o):console.error(o),i=!0}return e.apply(this,arguments)}};var i,a={};function s(e,t){var r={seen:[],stylize:c};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),p(t)?r.showHidden=t:t&&n._extend(r,t),_(r.showHidden)&&(r.showHidden=!1),_(r.depth)&&(r.depth=2),_(r.colors)&&(r.colors=!1),_(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=l),u(r,e,r.depth)}function l(e,t){var n=s.styles[t];return n?"["+s.colors[n][0]+"m"+e+"["+s.colors[n][1]+"m":e}function c(e,t){return e}function u(e,t,r){if(e.customInspect&&t&&S(t.inspect)&&t.inspect!==n.inspect&&(!t.constructor||t.constructor.prototype!==t)){var o=t.inspect(r,e);return y(o)||(o=u(e,o,r)),o}var i=function(e,t){if(_(t))return e.stylize("undefined","undefined");if(y(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}return m(t)?e.stylize(""+t,"number"):p(t)?e.stylize(""+t,"boolean"):g(t)?e.stylize("null","null"):void 0}(e,t);if(i)return i;var a=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,n){t[e]=!0})),t}(a);if(e.showHidden&&(a=Object.getOwnPropertyNames(t)),w(t)&&(a.indexOf("message")>=0||a.indexOf("description")>=0))return d(t);if(0===a.length){if(S(t))return e.stylize("[Function"+(t.name?": "+t.name:"")+"]","special");if(v(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(x(t))return e.stylize(Date.prototype.toString.call(t),"date");if(w(t))return d(t)}var l,c="",b=!1,C=["{","}"];return h(t)&&(b=!0,C=["[","]"]),S(t)&&(c=" [Function"+(t.name?": "+t.name:"")+"]"),v(t)&&(c=" "+RegExp.prototype.toString.call(t)),x(t)&&(c=" "+Date.prototype.toUTCString.call(t)),w(t)&&(c=" "+d(t)),0!==a.length||b&&0!=t.length?r<0?v(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),l=b?function(e,t,n,r,o){for(var i=[],a=0,s=t.length;a<s;++a)N(t,String(a))?i.push(f(e,t,n,r,String(a),!0)):i.push("");return o.forEach((function(o){o.match(/^\d+$/)||i.push(f(e,t,n,r,o,!0))})),i}(e,t,r,s,a):a.map((function(n){return f(e,t,r,s,n,b)})),e.seen.pop(),function(e,t,n){var r=e.reduce((function(e,t){return t.indexOf("\n"),e+t.replace(/\u001b\[\d\d?m/g,"").length+1}),0);return r>60?n[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+n[1]:n[0]+t+" "+e.join(", ")+" "+n[1]}(l,c,C)):C[0]+c+C[1]}function d(e){return"["+Error.prototype.toString.call(e)+"]"}function f(e,t,n,r,o,i){var a,s,l;if((l=Object.getOwnPropertyDescriptor(t,o)||{value:t[o]}).get?s=e.stylize(l.set?"[Getter/Setter]":"[Getter]","special"):l.set&&(s=e.stylize("[Setter]","special")),N(r,o)||(a="["+o+"]"),s||(e.seen.indexOf(l.value)<0?(s=g(n)?u(e,l.value,null):u(e,l.value,n-1)).indexOf("\n")>-1&&(s=i?s.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+s.split("\n").map((function(e){return" "+e})).join("\n")):s=e.stylize("[Circular]","special")),_(a)){if(i&&o.match(/^\d+$/))return s;(a=JSON.stringify(""+o)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(a=a.substr(1,a.length-2),a=e.stylize(a,"name")):(a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),a=e.stylize(a,"string"))}return a+": "+s}function h(e){return Array.isArray(e)}function p(e){return"boolean"==typeof e}function g(e){return null===e}function m(e){return"number"==typeof e}function y(e){return"string"==typeof e}function _(e){return void 0===e}function v(e){return b(e)&&"[object RegExp]"===C(e)}function b(e){return"object"===K(e)&&null!==e}function x(e){return b(e)&&"[object Date]"===C(e)}function w(e){return b(e)&&("[object Error]"===C(e)||e instanceof Error)}function S(e){return"function"==typeof e}function C(e){return Object.prototype.toString.call(e)}function A(e){return e<10?"0"+e.toString(10):e.toString(10)}n.debuglog=function(e){if(_(i)&&(i=t.env.NODE_DEBUG||""),e=e.toUpperCase(),!a[e])if(new RegExp("\\b"+e+"\\b","i").test(i)){var r=t.pid;a[e]=function(){var t=n.format.apply(n,arguments);console.error("%s %d: %s",e,r,t)}}else a[e]=function(){};return a[e]},n.inspect=s,s.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},s.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},n.isArray=h,n.isBoolean=p,n.isNull=g,n.isNullOrUndefined=function(e){return null==e},n.isNumber=m,n.isString=y,n.isSymbol=function(e){return"symbol"===K(e)},n.isUndefined=_,n.isRegExp=v,n.isObject=b,n.isDate=x,n.isError=w,n.isFunction=S,n.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"===K(e)||void 0===e},n.isBuffer=e("./support/isBuffer");var k=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function N(e,t){return Object.prototype.hasOwnProperty.call(e,t)}n.log=function(){var e,t;console.log("%s - %s",(t=[A((e=new Date).getHours()),A(e.getMinutes()),A(e.getSeconds())].join(":"),[e.getDate(),k[e.getMonth()],t].join(" ")),n.format.apply(n,arguments))},n.inherits=e("inherits"),n._extend=function(e,t){if(!t||!b(t))return e;for(var n=Object.keys(t),r=n.length;r--;)e[n[r]]=t[n[r]];return e}}).call(this,e("_process"),void 0!==re?re:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":10,_process:14,inherits:9}],12:[function(e,t,n){},{}],13:[function(e,t,n){(function(e){function t(e,t){for(var n=0,r=e.length-1;r>=0;r--){var o=e[r];"."===o?e.splice(r,1):".."===o?(e.splice(r,1),n++):n&&(e.splice(r,1),n--)}if(t)for(;n--;n)e.unshift("..");return e}function r(e,t){if(e.filter)return e.filter(t);for(var n=[],r=0;r<e.length;r++)t(e[r],r,e)&&n.push(e[r]);return n}n.resolve=function(){for(var n="",o=!1,i=arguments.length-1;i>=-1&&!o;i--){var a=i>=0?arguments[i]:e.cwd();if("string"!=typeof a)throw new TypeError("Arguments to path.resolve must be strings");a&&(n=a+"/"+n,o="/"===a.charAt(0))}return(o?"/":"")+(n=t(r(n.split("/"),(function(e){return!!e})),!o).join("/"))||"."},n.normalize=function(e){var i=n.isAbsolute(e),a="/"===o(e,-1);return(e=t(r(e.split("/"),(function(e){return!!e})),!i).join("/"))||i||(e="."),e&&a&&(e+="/"),(i?"/":"")+e},n.isAbsolute=function(e){return"/"===e.charAt(0)},n.join=function(){var e=Array.prototype.slice.call(arguments,0);return n.normalize(r(e,(function(e,t){if("string"!=typeof e)throw new TypeError("Arguments to path.join must be strings");return e})).join("/"))},n.relative=function(e,t){function r(e){for(var t=0;t<e.length&&""===e[t];t++);for(var n=e.length-1;n>=0&&""===e[n];n--);return t>n?[]:e.slice(t,n-t+1)}e=n.resolve(e).substr(1),t=n.resolve(t).substr(1);for(var o=r(e.split("/")),i=r(t.split("/")),a=Math.min(o.length,i.length),s=a,l=0;l<a;l++)if(o[l]!==i[l]){s=l;break}var c=[];for(l=s;l<o.length;l++)c.push("..");return(c=c.concat(i.slice(s))).join("/")},n.sep="/",n.delimiter=":",n.dirname=function(e){if("string"!=typeof e&&(e+=""),0===e.length)return".";for(var t=e.charCodeAt(0),n=47===t,r=-1,o=!0,i=e.length-1;i>=1;--i)if(47===(t=e.charCodeAt(i))){if(!o){r=i;break}}else o=!1;return-1===r?n?"/":".":n&&1===r?"/":e.slice(0,r)},n.basename=function(e,t){var n=function(e){"string"!=typeof e&&(e+="");var t,n=0,r=-1,o=!0;for(t=e.length-1;t>=0;--t)if(47===e.charCodeAt(t)){if(!o){n=t+1;break}}else-1===r&&(o=!1,r=t+1);return-1===r?"":e.slice(n,r)}(e);return t&&n.substr(-1*t.length)===t&&(n=n.substr(0,n.length-t.length)),n},n.extname=function(e){"string"!=typeof e&&(e+="");for(var t=-1,n=0,r=-1,o=!0,i=0,a=e.length-1;a>=0;--a){var s=e.charCodeAt(a);if(47!==s)-1===r&&(o=!1,r=a+1),46===s?-1===t?t=a:1!==i&&(i=1):-1!==t&&(i=-1);else if(!o){n=a+1;break}}return-1===t||-1===r||0===i||1===i&&t===r-1&&t===n+1?"":e.slice(t,r)};var o="b"==="ab".substr(-1)?function(e,t,n){return e.substr(t,n)}:function(e,t,n){return t<0&&(t=e.length+t),e.substr(t,n)}}).call(this,e("_process"))},{_process:14}],14:[function(e,t,n){var r,o,i=t.exports={};function a(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function l(e){if(r===setTimeout)return setTimeout(e,0);if((r===a||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:a}catch(e){r=a}try{o="function"==typeof clearTimeout?clearTimeout:s}catch(e){o=s}}();var c,u=[],d=!1,f=-1;function h(){d&&c&&(d=!1,c.length?u=c.concat(u):f=-1,u.length&&p())}function p(){if(!d){var e=l(h);d=!0;for(var t=u.length;t;){for(c=u,u=[];++f<t;)c&&c[f].run();f=-1,t=u.length}c=null,d=!1,function(e){if(o===clearTimeout)return clearTimeout(e);if((o===s||!o)&&clearTimeout)return o=clearTimeout,clearTimeout(e);try{return o(e)}catch(t){try{return o.call(null,e)}catch(t){return o.call(this,e)}}}(e)}}function g(e,t){this.fun=e,this.array=t}function m(){}i.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];u.push(new g(e,t)),1!==u.length||d||l(p)},g.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=m,i.addListener=m,i.once=m,i.off=m,i.removeListener=m,i.removeAllListeners=m,i.emit=m,i.prependListener=m,i.prependOnceListener=m,i.listeners=function(e){return[]},i.binding=function(e){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},{}],15:[function(e,t,n){var r=e("escodegen").generate;t.exports=function(e,t){t||(t={});var n={},o=function e(o,i){if("Literal"===o.type)return o.value;if("UnaryExpression"===o.type){var a=e(o.argument);return"+"===o.operator?+a:"-"===o.operator?-a:"~"===o.operator?~a:"!"===o.operator?!a:n}if("ArrayExpression"===o.type){for(var s=[],l=0,c=o.elements.length;l<c;l++){if((y=e(o.elements[l]))===n)return n;s.push(y)}return s}if("ObjectExpression"===o.type){var u={};for(l=0;l<o.properties.length;l++){var d=null===(_=o.properties[l]).value?_.value:e(_.value);if(d===n)return n;u[_.key.value||_.key.name]=d}return u}if("BinaryExpression"===o.type||"LogicalExpression"===o.type){if((c=e(o.left))===n)return n;var f=e(o.right);if(f===n)return n;var h=o.operator;return"=="===h?c==f:"==="===h?c===f:"!="===h?c!=f:"!=="===h?c!==f:"+"===h?c+f:"-"===h?c-f:"*"===h?c*f:"/"===h?c/f:"%"===h?c%f:"<"===h?c<f:"<="===h?c<=f:">"===h?c>f:">="===h?c>=f:"|"===h?c|f:"&"===h?c&f:"^"===h?c^f:"&&"===h?c&&f:"||"===h?c||f:n}if("Identifier"===o.type)return{}.hasOwnProperty.call(t,o.name)?t[o.name]:n;if("ThisExpression"===o.type)return{}.hasOwnProperty.call(t,"this")?t.this:n;if("CallExpression"===o.type){var p=e(o.callee);if(p===n)return n;if("function"!=typeof p)return n;var g=o.callee.object?e(o.callee.object):n;g===n&&(g=null);var m=[];for(l=0,c=o.arguments.length;l<c;l++){var y;if((y=e(o.arguments[l]))===n)return n;m.push(y)}return p.apply(g,m)}var _;if("MemberExpression"===o.type)return(u=e(o.object))===n||"function"==typeof u?n:"Identifier"===o.property.type?u[o.property.name]:(_=e(o.property))===n?n:u[_];if("ConditionalExpression"===o.type)return(a=e(o.test))===n?n:e(a?o.consequent:o.alternate);if("ExpressionStatement"===o.type)return(a=e(o.expression))===n?n:a;if("ReturnStatement"===o.type)return e(o.argument);if("FunctionExpression"===o.type){var v=o.body.body,b={};for(Object.keys(t).forEach((function(e){b[e]=t[e]})),l=0;l<o.params.length;l++){var x=o.params[l];if("Identifier"!=x.type)return n;t[x.name]=null}for(var l in v)if(e(v[l])===n)return n;t=b;var w=Object.keys(t),S=w.map((function(e){return t[e]}));return Function(w.join(", "),"return "+r(o)).apply(null,S)}if("TemplateLiteral"===o.type){var C="";for(l=0;l<o.expressions.length;l++)C+=e(o.quasis[l]),C+=e(o.expressions[l]);return C+e(o.quasis[l])}if("TaggedTemplateExpression"===o.type){var A=e(o.tag),k=o.quasi,N=k.quasis.map(e),T=k.expressions.map(e);return A.apply(null,[N].concat(T))}return"TemplateElement"===o.type?o.value.cooked:n}(e);return o===n?void 0:o}},{escodegen:12}],jsonpath:[function(e,t,n){t.exports=e("./lib/index")},{"./lib/index":5}]},{},["jsonpath"])("jsonpath")}(os)),os.exports),as=oe(is);const ss=new Set(["i","me","my","myself","we","our","ours","ourselves","you","your","yours","yourself","yourselves","he","him","his","himself","she","her","hers","herself","it","its","itself","they","them","their","theirs","themselves","what","which","who","whom","this","that","these","those","am","is","are","was","were","be","been","being","have","has","had","having","do","does","did","doing","a","an","the","and","but","if","or","because","as","until","while","of","at","by","for","with","about","against","between","into","through","during","before","after","above","below","to","from","up","down","in","out","on","off","over","under","again","further","then","once","here","there","when","where","why","how","all","any","both","each","few","more","most","other","some","such","no","nor","not","only","own","same","so","than","too","very","s","t","can","will","just","don","should","now","0","1","2","3","4","5","6","7","8","9"]);function ls(e,t){for(const[n,r]of t.entries())if(e.startsWith(r))return e.replace(r,String(n));return e}const cs="$PREFIXED_ID";function us(e,t,n){if(t===cs)return[ls(e.id,n)];let r;try{r=as.query(e,t)}catch{r=as.query(JSON.parse(JSON.stringify(e)),t)}return r}function ds(e){return e.toLowerCase().split(/[^\d:A-Za-z]+/).filter((e=>e&&!ss.has(e)))}function*fs(e){for(const t of e)yield*ds(t)}function*hs(e){for(const t of e)if("string"==typeof t)yield t;else if("object"==typeof t){const e=as.query(t,"$..*");yield*hs(e)}}function*ps(e,t,n){for(const r of t){const t=us(e,r,n);if(t.length>0)for(const e of fs(hs(t)))yield[r,e]}}async function gs(e,t,n){const r=await this.db,o=t??r.transaction(["nodes"]);es(n);const i=[...ds(e)],a=[],s=new Map;a.push(...i.map((async(e,t)=>{es(n);const r=o.objectStore("nodes").index("full-text-words");for await(const o of r.iterate(IDBKeyRange.bound(e,`${e}`,!1,!1))){es(n);const e=o.value,r=s.get(e.id)??[e,new Set];r[1].add(t),s.set(e.id,r)}}))),await Promise.all(a),es(n);const l=[];for(const[,[e,t]]of s)es(n),l.push(...ms(this.textIndexFields,e,t,i,this.prefixes));return l.sort(((e,t)=>t.score-e.score)),l.slice(0,this.options.maxSearchResults??this.DEFAULT_MAX_SEARCH_RESULTS)}function ms(e,t,n,r,o){const i=[...n].sort().map((e=>r[e])),a=i.map((e=>{const t=e.replaceAll(/[$()*+./?[\\\]^{|}-]/g,String.raw`\$&`);return new RegExp(`\\b${t}`,"gi")}));let s=[],l=0;for(const[n,i]of e.entries()){const c=new Set,u=e.length-n-1,d=[...hs(us(t,i.jsonPath,o))];for(const e of d){let n=0;const o=[];for(const[t,i]of a.entries())for(const a of e.matchAll(i)){n+=1+1*u,c.add(t);const i=a.index,s=r[t];void 0!==i&&(n+=.01*s.length,n+=s.length/e.length*100*.05,o.push({wordIndex:t,position:i}))}n+=100*c.size,l<n&&(l=n),o.sort(((e,t)=>e.position-t.position)),o.length>0&&s.push({term:t,field:i,str:e,score:n,wordMatches:o})}}s=s.filter((e=>e.score===l));for(const e of s){const{wordMatches:t}=e;for(let n=0;n<t.length-1;n++){const r=t[n],o=t[n+1],a=o.wordIndex-r.wordIndex;if(1===a||-1===a){e.score+=1,1===a&&(e.score+=1);const t=Math.abs(o.position-(r.position+i[r.wordIndex].length))-1;e.score-=.05*t}}}return s}function ys(e){return"string"==typeof e.id}function _s(e){return"string"==typeof e.sub&&"string"==typeof e.pred&&"string"==typeof e.obj}function vs(e){return Boolean(e.meta?.deprecated)}var bs,xs,ws=(xs||(xs=1,bs=function e(t,n){if(t===n)return!0;if(t&&n&&"object"==K(t)&&"object"==K(n)){if(t.constructor!==n.constructor)return!1;var r,o,i;if(Array.isArray(t)){if((r=t.length)!=n.length)return!1;for(o=r;0!=o--;)if(!e(t[o],n[o]))return!1;return!0}if(t instanceof Map&&n instanceof Map){if(t.size!==n.size)return!1;var a,s=j(t.entries());try{for(s.s();!(a=s.n()).done;)if(!n.has((o=a.value)[0]))return!1}catch(e){s.e(e)}finally{s.f()}var l,c=j(t.entries());try{for(c.s();!(l=c.n()).done;)if(!e((o=l.value)[1],n.get(o[0])))return!1}catch(e){c.e(e)}finally{c.f()}return!0}if(t instanceof Set&&n instanceof Set){if(t.size!==n.size)return!1;var u,d=j(t.entries());try{for(d.s();!(u=d.n()).done;)if(!n.has((o=u.value)[0]))return!1}catch(e){d.e(e)}finally{d.f()}return!0}if(ArrayBuffer.isView(t)&&ArrayBuffer.isView(n)){if((r=t.length)!=n.length)return!1;for(o=r;0!=o--;)if(t[o]!==n[o])return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if((r=(i=Object.keys(t)).length)!==Object.keys(n).length)return!1;for(o=r;0!=o--;)if(!Object.prototype.hasOwnProperty.call(n,i[o]))return!1;for(o=r;0!=o--;){var f=i[o];if(!e(t[f],n[f]))return!1}return!0}return t!=t&&n!=n}),bs),Ss=oe(ws);function Cs(e){return"CLASS"===e.type}function As(e){return"PROPERTY"===e.type}const ks=[{displayName:"Label",jsonPath:"$.lbl"},{displayName:"Synonym",jsonPath:"$.meta.synonyms[*].val"},{displayName:"Definition",jsonPath:"$.meta.definition.val"}];async function Ns(e){return qa(e,2,{upgrade(e,t,n,r,o){if(t<2&&(e.objectStoreNames.contains("meta")&&e.deleteObjectStore("meta"),e.objectStoreNames.contains("nodes")&&e.deleteObjectStore("nodes"),e.objectStoreNames.contains("edges")&&e.deleteObjectStore("edges")),e.objectStoreNames.contains("meta")||e.createObjectStore("meta"),!e.objectStoreNames.contains("nodes")){e.createObjectStore("nodes",{keyPath:"id"});const t=r.objectStore("nodes");t.createIndex("by-label","lbl"),t.createIndex("by-type","type"),t.createIndex("by-synonym",["meta","synonyms","val"]),t.createIndex("full-text-words","fullTextWords",{multiEntry:!0})}if(!e.objectStoreNames.contains("edges")){e.createObjectStore("edges",{autoIncrement:!0});const t=r.objectStore("edges");t.createIndex("by-subject","sub"),t.createIndex("by-object","obj"),t.createIndex("by-predicate","pred")}}})}function Ts(e){const t=new Set;for(const[,n]of e)t.add(n);return[...t]}async function Rs(e){const t=Date.now();let n,r=1;this.options.update?.("Parsing JSON",r);try{n=JSON.parse(await f.openLocation(this.sourceLocation).readFile("utf8"))}catch{throw new Error("Error in loading ontology")}r+=5,this.options.update?.("Parsing JSON complete",r);const o=Date.now(),[i,...a]=n.graphs??[];if(i){if(a.length>0)throw new Error("multiple graphs not supported");try{const n=e.transaction(["meta","nodes","edges"],"readwrite");await n.objectStore("meta").clear(),await n.objectStore("nodes").clear(),await n.objectStore("edges").clear();const a=n.objectStore("nodes"),s=Es.call(this).map((e=>e.jsonPath));if(i.nodes){let e=Math.round(r);for(const[,t]of i.nodes.entries())r+=1/i.nodes.length*64,Math.round(r)!=e&&r<100&&(this.options.update?.("Processing nodes",r),e=Math.round(r)),ys(t)&&await a.add({...t,fullTextWords:Ts(ps(t,s,this.prefixes))})}const l=n.objectStore("edges");if(i.edges){let e=Math.round(r);for(const[,t]of i.edges.entries())r+=1/i.edges.length*30,Math.round(r)!=e&&r<100&&(this.options.update?.("Processing edges",r),e=Math.round(r)),_s(t)&&await l.add(t)}await n.done;const c=e.transaction("meta","readwrite"),{update:u,...d}=this.options;await c.objectStore("meta").delete("meta"),await c.objectStore("meta").add({ontologyRecord:{name:this.ontologyName,version:this.ontologyVersion,sourceLocation:this.sourceLocation},storeOptions:d,graphMeta:i.meta,timestamp:String(new Date),schemaVersion:2,timings:{overall:Date.now()-t,load:Date.now()-o}},"meta"),await c.done}catch(t){throw await e.transaction("meta","readwrite").objectStore("meta").clear(),t}}}function Es(){return[{displayName:"ID",jsonPath:cs},...this.options.textIndexing?.indexFields??ks]}async function Is(e){const[t]=await e.transaction("meta").objectStore("meta").getAll();return!!t&&Ss(this.options.prefixes,t.storeOptions.prefixes)&&Ss(this.options.textIndexing,t.storeOptions.textIndexing)}class js{ontologyName;ontologyVersion;sourceLocation;db;options;loadOboGraphJson=Rs;getTermsByFulltext=gs;openDatabase=Ns;isDatabaseCurrent=Is;get textIndexFields(){return Es.call(this)}get prefixes(){return this.options.prefixes??new Map}DEFAULT_MAX_SEARCH_RESULTS=100;constructor(e,t,n,r){this.ontologyName=e,this.ontologyVersion=t,this.sourceLocation=n,this.options=r??{},this.db=this.prepareDatabase()}validate(){const e=[],{sourceLocation:t,sourceType:n}=this;return n?"obo-graph-json"!==n&&e.push(new Error(`ontology source file ${JSON.stringify(t)} has type ${n}, which is not yet supported`)):e.push(new Error(`unable to determine format of ontology source file ${JSON.stringify(t)}, file name must end with ".json", ".obo", or ".owl"`)),e}get sourceType(){if(o.isUriLocation(this.sourceLocation)){if(this.sourceLocation.uri.endsWith(".json"))return"obo-graph-json"}else if(o.isLocalPathLocation(this.sourceLocation)&&this.sourceLocation.localPath.endsWith(".json"))return"obo-graph-json"}get dbName(){return`Apollo Ontology "${this.ontologyName}" "${this.ontologyVersion}"`}async prepareDatabase(){const e=this.validate();if(e.length>0)throw e;const t=await this.openDatabase(this.dbName);if(await this.isDatabaseCurrent(t))return t;try{const{options:e,sourceLocation:n,sourceType:r}=this;if("obo-graph-json"!==r)throw new Error(`ontology source file ${JSON.stringify(n)} has type ${r}, which is not yet supported`);return e.update?.("",0),await this.loadOboGraphJson(t),e.update?.("",100),t}catch(e){throw t.close(),await function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).blocked,n=indexedDB.deleteDatabase(e);return t&&n.addEventListener("blocked",(function(e){return t(e.oldVersion,e)})),Pa(n).then((function(){}))}(this.dbName),e}}async termCount(e){const t=await this.db;return(e??t.transaction("nodes")).objectStore("nodes").count()}unique(e){const t=new Map,n=[];for(const r of e)t.has(r.id)||(t.set(r.id,!0),n.push(r));return n}async getTermsWithLabelOrSynonym(e,t,n){const r=t?.includeSubclasses??!0,o=await this.db,i=n??o.transaction(["nodes","edges"]),a=i.objectStore("nodes"),s=[...await a.index("by-label").getAll(e),...await a.index("by-synonym").getAll(e)];if(r){const e=await this.recurseEdges("by-object",s.map((e=>e.id)),(e=>"is_a"===e.pred),"sub",i);for(const t of e){const e=await a.get(t);e&&s.push(e)}}return s}async getPropertiesByLabel(e,t,n){const r=t?.includeSubProperties??!0,o=await this.db,i=n??o.transaction(["nodes","edges"]),a=(await this.getTermsWithLabelOrSynonym(e,{includeSubclasses:!1},i)).filter((e=>As(e)));if(r){const e=await this.recurseEdges("by-object",a.map((e=>e.id)),(e=>"subPropertyOf"===e.pred),"sub",i),t=i.objectStore("nodes");for(const n of e){const e=await t.get(n);e&&As(e)&&a.push(e)}}return a}async recurseEdges(e,t,n,r,o){const i=new Set;return await async function t(a){await Promise.all([...a].map((async a=>{const s=(await o.objectStore("edges").index(e).getAll(a)).filter((e=>n(e))).map((e=>e[r]));if(s.length>0){for(const e of s)i.add(e);await t(s)}})))}(t),i.values()}async*expandNodeSet(e,t="is_a",n,r){const o=await this.db,i=r??o.transaction(["edges"]),a=[...e],s=await this.recurseEdges("subclasses"===n?"by-object":"by-subject",a,(e=>e.pred===t),"subclasses"===n?"sub":"obj",i);for(const e of a)yield e;for(const e of s)yield e}expandSubclasses(e,t="is_a",n){return this.expandNodeSet(e,t,"subclasses",n)}expandSuperclasses(e,t="is_a",n){return this.expandNodeSet(e,t,"superclasses",n)}async getClassesThat(e,t,n){const r=await this.db,o=n??r.transaction(["nodes","edges"]),i=await this.getPropertiesByLabel(e,{includeSubProperties:!0},o),a=new Set(i.map((e=>e.id))),s=await async function(e){const t=[];for await(const n of e)t.push(n);return t}(this.expandSuperclasses(t.map((e=>e.id)),"is_a",o)),l=await this.recurseEdges("by-object",s,(e=>a.has(e.pred)),"sub",o),c=this.expandSubclasses(l,"is_a",o),u=[];for await(const e of c){const t=await o.objectStore("nodes").get(e);t&&Cs(t)&&!vs(t)&&u.push(t)}return u}async getClassesWithoutPropertyLabeled(e,t,n){const r=await this.db,o=n??r.transaction(["nodes","edges"]),i=o.objectStore("nodes"),a=o.objectStore("edges"),s=(await this.getPropertiesByLabel(e,t,o)).map((e=>e.id)),l=await(async()=>{const e=new Set;for(const t of s)for await(const n of a.index("by-predicate").iterate(t))e.add(n.value.sub);const t=new Set;for await(const n of this.expandSubclasses(e,"is_a",o))t.add(n);return t})(),c=[];for await(const e of i){const t=e.value;Cs(t)&&!l.has(t.id)&&c.push(t.id)}const u=[];for(const e of c){const t=await o.objectStore("nodes").get(e);t&&Cs(t)&&!vs(t)&&u.push(t)}return u}async getAllClasses(e){const t=await this.db,n=e??t.transaction(["nodes"]);return(await n.objectStore("nodes").index("by-type").getAll("CLASS")).filter((e=>!vs(e)))}async getAllTerms(e){const t=await this.db,n=e??t.transaction(["nodes"]);return(await n.objectStore("nodes").getAll()).filter((e=>!vs(e)))}}const Ds=l.types.model("OntologyRecord",{name:l.types.string,version:"unversioned",source:l.types.union(d.LocalPathLocation,d.UriLocation,d.BlobLocation),options:l.types.frozen(),equivalentTypes:l.types.map(l.types.array(l.types.string))}).volatile((e=>({dataStore:void 0,startedEquivalentTypeRequests:new Set}))).actions((e=>({ping(){},initDataStore(){e.dataStore=new js(e.name,e.version,l.getSnapshot(e.source),e.options)},afterCreate(){l.addDisposer(e,c.autorun((()=>{this.initDataStore()})))},setEquivalentTypes(t,n){e.equivalentTypes.set(t,n)}}))).actions((e=>({loadEquivalentTypes:l.flow((function*(t){if(!e.dataStore)return;if(e.startedEquivalentTypeRequests.has(t))return;e.startedEquivalentTypeRequests.add(t);const n=(yield e.dataStore.getTermsWithLabelOrSynonym(t)).map((e=>e.lbl)).filter((e=>null!=e));l.isAlive(e)&&e.setEquivalentTypes(t,n)}))}))).actions((e=>({afterCreate(){c.autorun((t=>{e.dataStore&&(e.loadEquivalentTypes("gene"),e.loadEquivalentTypes("pseudogene"),e.loadEquivalentTypes("transcript"),e.loadEquivalentTypes("pseudogenic_transcript"),e.loadEquivalentTypes("CDS"),e.loadEquivalentTypes("mRNA"),t.dispose())}))},setEquivalentTypes(t,n){e.equivalentTypes.set(t,n)}}))).views((e=>({isTypeOf(t,n){if(t===n)return!0;if(!e.dataStore)return!1;const r=e.equivalentTypes.get(n);return r?r.includes(t):(e.loadEquivalentTypes(n),!1)}}))),Os=l.types.model("OntologyManager",{ontologies:l.types.array(Ds),prefixes:l.types.optional(l.types.map(l.types.string),{"GO:":"http://purl.obolibrary.org/obo/GO_","SO:":"http://purl.obolibrary.org/obo/SO_"})}).views((e=>({get featureTypeOntologyName(){const t=l.getRoot(e).jbrowse.configuration;return n.readConfObject(t.ApolloPlugin,"featureTypeOntologyName")}}))).views((e=>({get featureTypeOntology(){return this.findOntology(e.featureTypeOntologyName)},findOntology:(t,n)=>e.ontologies.find((e=>e.name===t&&(void 0===n||e.version===n))),openOntology(e,t){return this.findOntology(e,t)?.dataStore},applyPrefixes:t=>ls(t,e.prefixes),expandPrefixes:t=>function(e,t){for(const[n,r]of t.entries())if(e.startsWith(String(n)))return e.replace(String(n),r);return e}(t,e.prefixes)}))).actions((e=>({addOntology(t,n,r,o){const i=e.ontologies.push({name:t,version:n,source:r,options:{prefixes:new Map(e.prefixes.entries()),...o}});e.ontologies[i-1].ping()}}))),Fs=n.ConfigurationSchema("OntologyRecord",{name:{type:"string",description:'the full name of the ontology, e.g. "Gene Ontology"',defaultValue:"My Ontology"},version:{type:"string",description:"the ontology's version string",defaultValue:"unversioned"},source:{type:"fileLocation",description:"the download location for the ontology's source file",defaultValue:{locationType:"UriLocation",uri:"http://example.com/myontology.json"}},textIndexFields:{type:"frozen",description:"JSON paths for text fields that will be indexed for text searching",defaultValue:ks}});async function Ms(e,t,n){if(!e)return;const r=await t.getTermsWithLabelOrSynonym(e.type,{includeSubclasses:!1}),o=r.filter(Cs);if(0===r.length)return;const i=await t.getClassesThat("part_of",o);return 0!==i.length?i:void 0}var Ls=a.createSvgIcon(i.jsx("path",{d:"M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"}),"Close");const Ps=ma()((e=>({dialogTitle:{background:e.palette.primary.main,color:e.palette.primary.contrastText,padding:e.spacing(2)},closeButton:{position:"absolute",right:e.spacing(1),top:e.spacing(1.5),color:e.palette.primary.contrastText}}))),Bs=p.observer((function(e){const{classes:t}=Ps(),{handleClose:n,title:r,...o}=e;return i.jsx(h.Dialog,{...o,header:i.jsxs(i.Fragment,{children:[i.jsx(s.DialogTitle,{className:t.dialogTitle,children:r}),i.jsx(s.IconButton,{"aria-label":"close",onClick:n,className:t.closeButton,children:i.jsx(Ls,{})})]})})}));function qs({fetchValidTerms:e,filterTerms:t,includeDeprecated:n,onChange:r,ontologyName:o,ontologyVersion:a,renderInput:l,session:c,style:d,value:f}){const[h,p]=u.useState(!1),[g,m]=u.useState(),[y,_]=u.useState(""),[v,b]=u.useState(),{ontologyManager:x}=c.apolloDataStore,w=x.findOntology(o,a)?.dataStore,S=w&&h&&!g,C=w&&!v,A=u.useCallback((e=>(n||!vs(e))&&(!t||t(e))),[t,n]);u.useEffect((()=>{const e=new AbortController,{signal:t}=e;return C&&async function(e,t,n,r){if(!t)return;const o=(await e.getTermsWithLabelOrSynonym(t,{includeSubclasses:!1})).find((e=>(n??(()=>!0))(e)));if(!o)throw new Error(`not a valid ${e.ontologyName} term`);return o}(w,f,A).then((e=>{_(""),t.aborted||b(e)}),(e=>{t.aborted||ts(e)||_(String(e))})),()=>{e.abort(new DOMException("Cancel getting current term from ontology store","AbortError"))}}),[c,f,A,w,C]),u.useEffect((()=>{const t=new AbortController,{signal:n}=t;return S&&async function(e,t,n,r){let o;if(t){const n=await t(e,r);n&&(o=n)}return o??=await e.getAllTerms(),n?o.filter((e=>n(e))):o}(w,e,A,n).then((e=>{e&&!n.aborted&&m(e)}),(e=>{n.aborted||ts(e)||c.notify(e instanceof Error?e.message:String(e),"error")})),()=>{t.abort(new DOMException("Canceling getting valid terms from ontology store","AbortError"))}}),[S,A,w,c,e]);const k={};return y&&(k.error=!0,k.helperText=y),i.jsx(s.Autocomplete,{style:d,autoComplete:!0,filterSelectedOptions:!0,disableClearable:!0,selectOnFocus:!0,clearOnBlur:!0,handleHomeEndKeys:!0,freeSolo:!0,value:f,options:g??[],onOpen:()=>{p(!0)},onClose:()=>{p(!1)},loading:S,renderInput:l??(e=>i.jsx(s.TextField,{...e,...k})),getOptionLabel:e=>"string"==typeof e?e:e.lbl??"",isOptionEqualToValue:(e,t)=>e.lbl===t.lbl,onChange:(e,t)=>{t&&("string"==typeof t?(b(void 0),r(f,t)):t.lbl!==f&&(_(""),b(t),r(f,t.lbl)))}})}function Us({changeManager:e,handleClose:t,session:n,sourceAssemblyId:r,sourceFeature:o}){const[a,l]=u.useState(String(o.max)),[c,d]=u.useState(String(o.min+1)),[f,h]=u.useState(""),[p,g]=u.useState(""),[m,y]=u.useState(""),_=Number(a)<=Number(c);return i.jsxs(Bs,{open:!0,title:"Add new child feature",handleClose:t,maxWidth:!1,"data-testid":"add-feature-dialog",children:[i.jsxs("form",{onSubmit:function(i){i.preventDefault(),g("");const s=(new at).toHexString(),l={_id:s,refSeq:o.refSeq,min:Number(c)-1,max:Number(a),type:f};o.strand&&(l.strand=o.strand);const u=new ht({changedIds:[o._id],typeName:"AddFeatureChange",assembly:r,addedFeature:l,parentFeatureId:o._id});e.submit(u).then((()=>{n.apolloSetSelectedFeature(s)})),t(),i.preventDefault()},children:[i.jsxs(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:[i.jsx(s.TextField,{margin:"dense",id:"start",label:"Start",type:"number",fullWidth:!0,variant:"outlined",value:c,onChange:e=>{d(e.target.value)}}),i.jsx(s.TextField,{margin:"dense",id:"end",label:"End",type:"number",fullWidth:!0,variant:"outlined",value:a,onChange:e=>{l(e.target.value)},error:_,helperText:_?'"End" must be greater than "Start"':null}),i.jsx(qs,{session:n,ontologyName:"Sequence Ontology",style:{width:170},value:f,filterTerms:Cs,fetchValidTerms:async function(e,t,n){const r=await Ms(e,t);if(r)return r;y(`Type "${e?.type}" does not have any children in the ontology`)}.bind(null,o),renderInput:e=>i.jsx(s.TextField,{...e,label:"Type",variant:"outlined",fullWidth:!0,error:Boolean(m),helperText:m}),onChange:(e,t)=>{var n;t&&(n=t,g(""),h(n))}})]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{variant:"contained",type:"submit",disabled:_||!(c&&a&&f),children:"Submit"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:t,children:"Cancel"})]})]}),p?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:p})}):null]})}const zs=["#cc79a7","#d65e00","#e69f00","#f0e442","#56b3e9","#0072b2","#009e73"];function $s({changeManager:e,handleClose:t,sourceAssemblyId:n,sourceFeature:r}){const o=r.attributes.get("apollo_color")?.[0],[a,c]=u.useState(o??zs[0]);return i.jsx(Bs,{open:!0,title:"Color feature",handleClose:t,maxWidth:!1,"data-testid":"color-feature",children:i.jsxs("form",{onSubmit:o=>{!async function(o){o.preventDefault();const i=r.attributes.get("apollo_color")?.[0];if(i===a)return void t();const s=l.getSnapshot(r.attributes),c={...s,apollo_color:[a]},u=new St({changedIds:[r._id],typeName:"FeatureAttributeChange",assembly:n,featureId:r._id,oldAttributes:s,newAttributes:c});await e.submit(u),t()}(o)},children:[i.jsxs(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:[i.jsx(s.DialogContentText,{children:"Choose a color for this feature."}),i.jsx("div",{style:{display:"flex",gap:8,marginTop:8},children:zs.map((e=>{const t=a.toLowerCase()===e;return i.jsx("button",{type:"button","aria-label":e,"aria-pressed":t,onClick:()=>{c(e)},style:{width:32,height:32,padding:0,borderRadius:4,border:"1px solid rgba(0, 0, 0, 0.3)",outline:t?"2px solid currentColor":"none",outlineOffset:2,backgroundColor:e,cursor:"pointer"}},e)}))}),i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:16},children:[i.jsx("label",{htmlFor:"color-feature-custom",children:"Custom:"}),i.jsx("input",{id:"color-feature-custom",type:"color",value:a,onChange:e=>{c(e.target.value)}})]})]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{variant:"contained",type:"submit",children:"Submit"}),i.jsx(s.Button,{variant:"outlined",color:"error",type:"button",disabled:void 0===o,onClick:()=>{!async function(){const o=l.getSnapshot(r.attributes),{apollo_color:i,...a}=o,s=new St({changedIds:[r._id],typeName:"FeatureAttributeChange",assembly:n,featureId:r._id,oldAttributes:o,newAttributes:a});await e.submit(s),t()}()},children:"Remove color"}),i.jsx(s.Button,{variant:"outlined",type:"button",onClick:t,children:"Cancel"})]})]})})}function Hs(e,t){const n=(new at).toHexString();t.push(n);const r={};if(e.children)for(const n of Object.values(e.children)){const e=Hs(n,t);r[e._id]=e}const o="string"==typeof e.refSeq?e.refSeq:e.refSeq.toHexString();return{...e,refSeq:o,children:e.children&&r,_id:n}}function Gs({changeManager:e,handleClose:t,session:r,sourceAssemblyId:o,sourceFeature:a}){const{assemblyManager:c}=r,d=c.assemblyList,[f,h]=u.useState(d.find((e=>e.name!==o))?.name),[p,g]=u.useState([]),[m,y]=u.useState(""),[_,v]=u.useState(a.min),[b,x]=u.useState("");function w(e,t){const n={};if(e.children)for(const r of Object.values(e.children)){const e=w(r,t);e.refSeq=m,e.min=e.min+t,e.max=e.max+t,n[e._id]=e}const r="string"==typeof e.refSeq?e.refSeq:e.refSeq.toHexString(),o="string"==typeof e._id?e._id:e._id.toHexString();return{...e,refSeq:r,children:e.children&&n,_id:o}}return u.useEffect((()=>{(async function(){if(y(""),!f)return void x("No assemblies to copy to");const e=await c.waitForAssembly(f);if(!e)return;const{refNameAliases:t}=e;if(!t)return;const n=[...Object.entries(t)].filter((([e,t])=>e!==t)).map((([e,t])=>({_id:e,name:t})));g(n),y(n[0]?._id||"")})().catch((e=>{x(String(e))}))}),[f,c]),i.jsxs(Bs,{open:!0,title:"Copy features and annotations",handleClose:t,maxWidth:!1,"data-testid":"copy-feature",children:[i.jsxs("form",{onSubmit:async function(n){if(!f)return;n.preventDefault(),x("");const o=a.length,i=await c.waitForAssembly(f);if(!i)return void x(`Assembly not found: ${f}.`);const s=i.getCanonicalRefName(m),u=i.regions?.find((e=>e.refName===s));if(!u)return void x(`RefSeq not found: ${m}.`);const d=_+o;if(d>u.end)return void x(`Feature would extend beyond the bounds of the selected reference sequence. (Feature would end at ${d}, but reference sequence ends at ${u.end})`);if(_<u.start)return void x(`Reference sequence starts at ${u.start}, feature cannot start before that.`);const h=[],p=Hs(l.getSnapshot(a),h),g={...p.attributes};"Parent"in g&&delete g.Parent,p.refSeq=m;const y=_-p.min;p.min=_,p.max=_+o;const v=w(p,y),b=new ht({changedIds:[p._id],typeName:"AddFeatureChange",assembly:f,addedFeature:{_id:p._id,refSeq:p.refSeq,min:p.min,max:p.max,type:p.type,children:v.children,attributes:g,strand:p.strand},copyFeature:!0,allIds:h});e.submit(b).then((()=>{r.apolloSetSelectedFeature(p._id)})),t(),n.preventDefault()},children:[i.jsxs(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:[i.jsx(s.DialogContentText,{children:"Target assembly"}),i.jsx(s.Select,{labelId:"label",value:f,onChange:function(e){h(e.target.value)},children:d.filter((e=>e.name!==o)).map((e=>i.jsx(s.MenuItem,{value:e.name,children:n.readConfObject(e,"displayName")},e.name)))}),i.jsx(s.DialogContentText,{children:"Target reference sequence"}),i.jsx(s.Select,{labelId:"label",value:m,onChange:function(e){y(e.target.value)},children:p.map((e=>i.jsx(s.MenuItem,{value:e._id,children:e.name},e._id)))}),i.jsx(s.DialogContentText,{children:"Start position in target reference sequence"}),i.jsx(s.TextField,{margin:"dense",type:"number",fullWidth:!0,variant:"outlined",value:_,onChange:e=>{v(Number(e.target.value))}})]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{disabled:!f||!m||!_,variant:"contained",type:"submit",children:"Submit"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:t,children:"Cancel"})]})]}),b?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:b})}):null]})}function Vs({changeManager:e,handleClose:t,selectedFeature:n,session:r,setSelectedFeature:o,sourceAssemblyId:a,sourceFeature:c}){const[d,f]=u.useState(""),{ontologyManager:h}=r.apolloDataStore,{featureTypeOntology:p}=h;function g(e){if(!e.parent?.children||1===e.parent.children.size)return;const t=[];for(const n of e.parent.children.values())p?.isTypeOf(n.type,"CDS")||t.push(n);t.sort(((e,t)=>e.min-t.min));const n=[];for(const t of e.parent.children.values())p?.isTypeOf(t.type,"CDS")||n.push(t);if(n.sort(((e,t)=>t.max-e.max)),e.min===t[0].min){let n;for(const r of t)if(r._id!==e._id&&r.min>=e.min){n=r.min;break}if(n&&n!=e.parent.min)return{typeName:"LocationStartChange",changedId:e.parent._id,featureId:e.parent._id,oldLocation:e.parent.min,newLocation:n}}if(e.max===n[0].max){let t;for(const r of n)if(r._id!=e._id&&r.max<=e.max){t=r.max;break}if(t&&t!=e.parent.max)return{typeName:"LocationEndChange",changedId:e.parent._id,featureId:e.parent._id,oldLocation:e.parent.max,newLocation:t}}}return i.jsxs(Bs,{open:!0,title:"Delete feature",handleClose:t,maxWidth:!1,"data-testid":"delete-feature",children:[i.jsxs("form",{onSubmit:r=>{!async function(r){r.preventDefault(),f(""),n?._id===c._id&&o();const i=[],s=new pt({changedIds:[c._id],typeName:"DeleteFeatureChange",assembly:a,changes:[{deletedFeature:l.getSnapshot(c),parentFeatureId:c.parent?._id}]});if(p&&(p.isTypeOf(c.type,"transcript")||p.isTypeOf(c.type,"pseudogenic_transcript"))){const e=g(c);e&&i.push(e)}if(p?.isTypeOf(c.type,"exon")){const e=function(e){if(!p)return;if(!p.isTypeOf(e.type,"exon"))return;if(!e.parent?.cdsLocations||0===e.parent.cdsLocations.length||0===e.parent.cdsLocations[0].length)return;if(!e.parent.children)throw new Error("Unable to find parent of CDS");if(1!=e.parent.cdsLocations.length)throw new Error("Unable to handle a transcript with multiple CDSs");const t=(e.parent.cdsLocations.at(0)??[]).sort((({min:e},{min:t})=>e-t));let n;for(const r of e.parent.children.values())if(r.type===t[0].type){n=r;break}if(!n)throw new Error("Unable to find CDS");const r=t[0].min,o=t[t.length-1].max;if(!(e.min>r&&e.max<o||e.max<r||e.min>o)){if(e.min<=r&&e.max>=o)return new pt({changedIds:[n._id],typeName:"DeleteFeatureChange",assembly:a,changes:[{deletedFeature:l.getSnapshot(n),parentFeatureId:n.parent?._id}]});if(e.min<=r&&e.max>r){let r;for(const n of t)if(n.min>e.max){r=n.min;break}if(!r)throw new Error("Error setting new CDS start");return{typeName:"LocationStartChange",changedId:n._id,featureId:n._id,oldLocation:n.min,newLocation:r}}if(e.min<o&&e.max>=o){let r;for(const n of t.reverse())if(n.max<e.min){r=n.max;break}if(!r)throw new Error("Error setting new CDS end");return{typeName:"LocationEndChange",changedId:n._id,featureId:n._id,oldLocation:n.max,newLocation:r}}throw new Error("Unexpected relationship between exon and CDS")}}(c);e&&("DeleteFeatureChange"===e.typeName?(s.changedIds.push(...e.changedIds),s.changes.push(...e.changes)):i.push(e));const t=g(c);if(t){i.push(t);const e=c.parent?.parent;if(e?.children)if("LocationStartChange"===t.typeName){let n=t.newLocation;for(const[,r]of e.children)r._id!=t.featureId&&r.min<n&&(n=r.min);n!=e.min&&i.push({typeName:t.typeName,changedId:e._id,featureId:e._id,oldLocation:e.min,newLocation:n})}else{let n=t.newLocation;for(const[,r]of e.children)r._id!=t.featureId&&r.max>n&&(n=r.max);n!=e.max&&i.push({typeName:t.typeName,changedId:e._id,featureId:e._id,oldLocation:e.max,newLocation:n})}}}const u=function(e,t){if(0===e.length)return;const n=new Et({typeName:"LocationStartChange",changedIds:[],changes:[],assembly:t}),r=new Tt({typeName:"LocationEndChange",changedIds:[],changes:[],assembly:t});for(const t of e)"LocationStartChange"===t.typeName&&(n.changedIds.push(t.changedId),n.changes.push({featureId:t.featureId,oldStart:t.oldLocation,newStart:t.newLocation})),"LocationEndChange"===t.typeName&&(r.changedIds.push(t.changedId),r.changes.push({featureId:t.featureId,oldEnd:t.oldLocation,newEnd:t.newLocation}));if(n.changedIds.length>0&&0===r.changedIds.length)return n;if(r.changedIds.length>0&&0===n.changedIds.length)return r;throw new Error("Unexpected list of changes")}(i,a);await e.submit(s),u&&await e.submit(u),t(),r.preventDefault()}(r)},children:[i.jsx(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:i.jsx(s.DialogContentText,{children:"Are you sure you want to delete the selected feature?"})}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{variant:"contained",type:"submit",children:"Yes"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:t,children:"Cancel"})]})]}),d?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:d})}):null]})}function Ws(e,t){if(e.apolloDragging)return;e.setSelectedFeature(t);const{session:n}=e,{apolloDataStore:r}=n,{featureTypeOntology:o}=r.ontologyManager;if(!o)throw new Error("featureTypeOntology is undefined");let i=!1;for(const[,e]of t.children??[])if(o.isTypeOf(e.type,"CDS")||o.isTypeOf(e.type,"exon")){i=!0;break}(o.isTypeOf(t.type,"transcript")||o.isTypeOf(t.type,"pseudogenic_transcript"))&&i?e.showFeatureDetailsWidget(t,["ApolloTranscriptDetails","apolloTranscriptDetails"]):e.showFeatureDetailsWidget(t)}function Js(e,t){const{featureTypeOntology:n}=t.apolloDataStore.ontologyManager;if(!n)throw new Error("featureTypeOntology is undefined");return n.isTypeOf(e.type,"gene")||n.isTypeOf(e.type,"pseudogene")}function Ks(e,t){const{featureTypeOntology:n}=t.apolloDataStore.ontologyManager;if(!n)throw new Error("featureTypeOntology is undefined");return n.isTypeOf(e.type,"transcript")||n.isTypeOf(e.type,"pseudogenic_transcript")}function Ys(e,t){const{featureTypeOntology:n}=t.apolloDataStore.ontologyManager;if(!n)throw new Error("featureTypeOntology is undefined");return n.isTypeOf(e.type,"exon")}function Xs(e,t){const{featureTypeOntology:n}=t.apolloDataStore.ontologyManager;if(!n)throw new Error("featureTypeOntology is undefined");return n.isTypeOf(e.type,"CDS")}function Zs(e,t){const{featureTypeOntology:n}=t.apolloDataStore.ontologyManager;if(!n)throw new Error("featureTypeOntology is undefined");const r=e.children;if(!r?.size)return!1;if(!Js(e,t))return!1;for(const[,e]of r)if(Ks(e,t)){const{children:n}=e;return!!n?.size&&[...n.values()].some((e=>Ys(e,t)))}return!1}function Qs(e,t){if(!e.parent)return{upstream:void 0,downstream:void 0};const n=e.parent;if(!n.children)throw new Error(`Error getting children of ${n._id}`);const{featureTypeOntology:r}=t.session.apolloDataStore.ontologyManager;if(!r)throw new Error("featureTypeOntology is undefined");let o=[];for(const[,e]of n.children)r.isTypeOf(e.type,"exon")&&o.push(e);const i={upstream:void 0,downstream:void 0};o=o.sort(((e,t)=>e.min<t.min?-1:1));for(const t of o)if(t.min>e.max){i.downstream=t;break}o=o.sort(((e,t)=>e.min>t.min?-1:1));for(const t of o)if(t.max<e.min){i.upstream=t;break}if(-1===n.strand){const e=i.downstream;i.downstream=i.upstream,i.upstream=e}return i}function el(e,t,n){let r=Ta;return-1===e&&(r=Ra),t&&(r=r===Ra?Ta:Ra),n&&(r=r===Ra?Ta:Ra),r}function tl(e,t,n,r){const o=r.bpToPx({refName:t,coord:e.min,regionNumber:n}),i=r.bpToPx({refName:t,coord:e.max,regionNumber:n});if(void 0===o||void 0===i)return;const{offsetPx:a}=r;return[o.offsetPx-a,i.offsetPx-a]}function nl(e,t,n){const[r,o]=n;if(!(Math.abs(o-r)<8))return Math.abs(r-t)<4?{feature:e,edge:"min"}:Math.abs(o-t)<4?{feature:e,edge:"max"}:void 0}function rl(e,t){return e._id===t?._id}function ol(e){let t;t=e.attributes.get("gff_name")?e.attributes.get("gff_name")?.join(","):e.attributes.get("gff_id")?e.attributes.get("gff_id")?.join(","):e._id;const n=`(${(e.min+1).toLocaleString("en")}..${e.max.toLocaleString("en")})`;if(t&&t.length+n.length>65){const e=60-n.length;t=e>0?t.slice(0,e):"",t=`${t}[...]`}return`${t} ${n}`}function il(e,t){const{apolloInternetAccount:n,changeManager:r,regions:i,selectedFeature:a,session:s}=e,l=[],c=n?n.role:"admin",u=!(c&&["admin","user"].includes(c)),[d]=i,f=e.getAssemblyId(d.assemblyName),h=e.getAssemblyId(d.assemblyName);return l.push({label:ol(t),type:"subHeader"},{label:"Add child feature",disabled:u,onClick:()=>{s.queueDialog((e=>[Us,{session:s,handleClose:()=>{e()},changeManager:r,sourceFeature:t,sourceAssemblyId:f,internetAccount:n}]))}},{label:"Copy features and annotations",disabled:u,onClick:()=>{s.queueDialog((e=>[Gs,{session:s,handleClose:()=>{e()},changeManager:r,sourceFeature:t,sourceAssemblyId:h}]))}},{label:"Delete feature",disabled:u,onClick:()=>{s.queueDialog((n=>[Vs,{session:s,handleClose:()=>{n()},changeManager:r,sourceFeature:t,sourceAssemblyId:h,selectedFeature:a,setSelectedFeature:t=>{e.setSelectedFeature(t)}}]))}},{label:"Color feature",disabled:u,onClick:()=>{s.queueDialog((e=>[$s,{session:s,handleClose:()=>{e()},changeManager:r,sourceFeature:t,sourceAssemblyId:h}]))}}),o.isSessionModelWithWidgets(s)&&l.push({label:"Open feature details",onClick:()=>{const e=s.addWidget("ApolloFeatureDetailsWidget","apolloFeatureDetailsWidget",{feature:t,assembly:h,refName:d.refName});s.showWidget(e)}}),l}function al(e,t,n){const r=(e.max-e.min)*t,o=Math.max(e.min-r,1),i=Math.min(e.max+r,n);return{refName:e.refSeq,start:o,end:i}}function sl(e,t,n){const r=[{featureId:e._id,oldLocation:e[n],newLocation:t}],{parent:o}=e;return o&&("min"===n&&o[n]>t||"max"===n&&o[n]<t)&&r.push(...sl(o,t,n)),r}function ll(e,t,n,r,o){const i=e._id,a=[{featureId:i,oldLocation:e[n],newLocation:t}],{parent:s,children:l}=e;if(l)for(const[,e]of l)e._id!==o&&("min"===n&&e[n]<t||"max"===n&&e[n]>t)&&a.push(...ll(e,t,n,r));if(s&&r){const e=[];if(s.children)for(const[,t]of s.children)t._id!==i&&e.push(t);if(0===e.length)a.push(...ll(s,t,n,r,i));else{const o=s[n],l=Math[n](...e.map((e=>e[n])),t);l!==o&&a.push(...ll(s,l,n,r,i))}}return a}function cl(e,t,n,r=!1){const o=e[n];if(t===o)throw new Error(`New and existing locations are the same: "${t}"`);return"min"===n?t>o?ll(e,t,n,r):sl(e,t,n):t<o?ll(e,t,n,r):sl(e,t,n)}function ul(e){return"feature"in e}async function dl(e,t){let n;try{n=await e.text()}catch{n=""}return`${t?`${t} — `:""}${e.status} ${e.statusText}${n?` (${n})`:""}`}var fl;!function(e){e.GFF3="text/x-gff3",e.FASTA="text/x-fasta",e.BGZIP_FASTA="application/x-bgzip-fasta",e.FAI="text/x-fai",e.GZI="application/x-gzi",e.EXTERNAL="text/x-external"}(fl||(fl={}));const hl=ma()((e=>({accordion:{border:`1px solid ${e.palette.divider}`,"&:not(:last-child)":{borderBottom:0}},accordionSummary:{flexDirection:"row-reverse"},accordionDetails:{padding:e.spacing(2),borderTop:"1px solid rgba(0, 0, 0, .125)"},radioIcon:{color:e.palette.tertiary.contrastText},dialog:{minWidth:550,maxWidth:800}})));function pl(e,t,n,r,o,i,a,s,l){return!(!e||!(t&&r||n===fl.GFF3&&r||r&&o&&i||a&&s&&l))}function gl({changeManager:e,handleClose:t,session:r}){const{classes:o}=hl(),{internetAccounts:a}=l.getRoot(r),{notify:c}=r,d=a.filter((e=>"ApolloInternetAccount"===e.type));if(0===d.length)throw new Error("No Apollo internet account found");const[f,h]=u.useState(""),[p,g]=u.useState(""),[m,y]=u.useState(!1),[_,v]=u.useState(fl.BGZIP_FASTA),[b,x]=u.useState(!0),[w,S]=u.useState(!1),[C,A]=u.useState(!1),[k,N]=u.useState(!0),[T,R]=u.useState(null),[E,I]=u.useState(null),[j,D]=u.useState(null),[O,F]=u.useState(""),[M,L]=u.useState(""),[P,B]=u.useState(""),[q,U]=u.useState(!1),[z,$]=u.useState(!1),[H,G]=u.useState(!1);async function V(e,t){const{jobsManager:n}=r,o=new AbortController,[{baseURL:i,getFetcher:a}]=d,s=new URL("files",i);s.searchParams.set("type",t);const l=s.href,c=new FormData;let u=e.name;const h=t===fl.BGZIP_FASTA||t===fl.FASTA&&(!w||z)||t===fl.GFF3&&H;h&&!e.name.toLocaleLowerCase().endsWith(".gz")?u=`${u}.gz`:!h&&e.name.toLocaleLowerCase().endsWith(".gz")&&(u=`${u}.txt`),c.append("file",e,u),c.append("type",t);const p=a({locationType:"UriLocation",uri:l}),m={name:`UploadAssemblyFile for ${f}`,statusMessage:"Pre-validating",progressPct:0,cancelCallback:()=>{o.abort(new DOMException(`Canceling adding of assembly "${f}"`,"AbortError")),n.abortJob(m.name)}};n.runJob(m),n.update(m.name,`Uploading ${e.name}, this may take awhile`);const{signal:y}=o,_=await p(l,{method:"POST",body:c,signal:y});if(!_.ok){const e=await dl(_,"Error when inserting new assembly (while uploading file)");return n.abortJob(m.name,e),g(e),""}const v=(await _.json())._id;return n.done(m),v}let W=!1;try{const e=new URL(O);"http:"!==e.protocol&&"https:"!==e.protocol||(W=!0)}catch{}let J=!1;try{const e=new URL(M);"http:"!==e.protocol&&"https:"!==e.protocol||(J=!0)}catch{}let K=!1;try{const e=new URL(P);"http:"!==e.protocol&&"https:"!==e.protocol||(K=!0)}catch{}const[Y,X]=u.useState("panelFastaInput"),Z=e=>(t,n)=>{n&&X(e)};return i.jsxs(Bs,{open:!0,handleClose:t,"data-testid":"add-assembly-dialog",title:"Add new assembly",maxWidth:!1,children:[i.jsxs("form",{onSubmit:async function(n){let r;if(n.preventDefault(),g(""),A(!0),U(!0),c(`Assembly "${f}" is being added`,"info"),t(),n.preventDefault(),_===fl.EXTERNAL)r=new yt({typeName:"AddAssemblyFromExternalChange",assembly:(new at).toHexString(),assemblyName:f,externalLocation:{fa:O,fai:M,gzi:P}});else{if(!T)throw new Error("Missing fasta file");if(_===fl.GFF3&&b){const e=await V(T,fl.GFF3);r=new mt({typeName:"AddAssemblyAndFeaturesFromFileChange",assembly:(new at).toHexString(),assemblyName:f,fileIds:{fa:e},parseOptions:{strict:k}})}else if(_===fl.GFF3){const e=await V(T,fl.GFF3);r=new _t({typeName:"AddAssemblyFromFileChange",assembly:(new at).toHexString(),assemblyName:f,fileIds:{fa:e}})}else if(w){const e=await V(T,fl.FASTA);r=new _t({typeName:"AddAssemblyFromFileChange",assembly:(new at).toHexString(),assemblyName:f,fileIds:{fa:e}})}else{if(!E||!j)throw new Error("Missing fasta index files");const e=await V(T,fl.BGZIP_FASTA),t=await V(E,fl.FAI),n=await V(j,fl.GZI);r=new _t({typeName:"AddAssemblyFromFileChange",assembly:(new at).toHexString(),assemblyName:f,fileIds:{fa:e,fai:t,gzi:n}})}}const[{internetAccountId:o}]=d;await e.submit(r,{internetAccountId:o,updateJobsManager:!0}),A(!1),U(!1)},"data-testid":"submit-form",children:[i.jsxs(s.DialogContent,{className:o.dialog,children:[q?i.jsx(s.LinearProgress,{}):null,i.jsx(s.TextField,{margin:"dense",id:"name",label:"Assembly name",type:"TextField",fullWidth:!0,variant:"outlined",onChange:e=>{A(!1),h(e.target.value),function(e){const{assemblies:t}=r;t.find((t=>n.readConfObject(t,"displayName")===e))?(y(!1),g(`Assembly ${e} already exists.`)):(y(!0),g(""))}(e.target.value)},disabled:C&&!p}),i.jsxs(s.Accordion,{disableGutters:!0,elevation:0,square:!0,className:o.accordion,expanded:"panelFastaInput"===Y,onChange:Z("panelFastaInput"),children:[i.jsx(s.AccordionSummary,{className:o.accordionSummary,expandIcon:"panelFastaInput"===Y?i.jsx(va,{className:o.radioIcon,sx:{fontSize:"1.2rem",ml:5}}):i.jsx(ba,{className:o.radioIcon,sx:{fontSize:"1.2rem",mr:5}}),"aria-controls":"panelFastaInputd-content",id:"panelFastaInputd-header",children:i.jsx(s.Typography,{component:"span",children:"FASTA input"})}),i.jsx(s.AccordionDetails,{className:o.accordionDetails,children:i.jsxs(s.FormGroup,{children:[i.jsx(s.FormControlLabel,{"data-testid":"files-on-url-checkbox",control:i.jsx(s.Checkbox,{onChange:()=>{v(_===fl.EXTERNAL?fl.BGZIP_FASTA:fl.EXTERNAL),_===fl.EXTERNAL&&S(!1)},checked:_===fl.EXTERNAL,disabled:w&&_!==fl.GFF3}),label:i.jsxs(s.Box,{display:"flex",alignItems:"center",children:["Use external URLs",i.jsx(s.Tooltip,{title:"Use external URLs to provide FASTA and index files. Does not copy the files to the Apollo collaboration server, so ensure the URLs are stable.",placement:"top-start",children:i.jsx(s.IconButton,{size:"small",children:i.jsx(ya,{sx:{fontSize:18}})})})]})}),i.jsx(s.FormControlLabel,{"data-testid":"sequence-is-editable-checkbox",control:i.jsx(s.Checkbox,{onChange:()=>{S(!w)}}),checked:w,disabled:_===fl.EXTERNAL,label:i.jsxs(s.Box,{display:"flex",alignItems:"center",children:["Store sequence in database",i.jsx(s.Tooltip,{title:"Enables users to edit the genomic sequence, but comes with performance impacts. Use with care.",placement:"top-start",children:i.jsx(s.IconButton,{size:"small",children:i.jsx(ya,{sx:{fontSize:18}})})})]})}),i.jsx(s.FormControlLabel,{"data-testid":"fasta-is-gzip-checkbox",control:i.jsx(s.Checkbox,{checked:!w||z,onChange:()=>{$(!w||!z)},disabled:!w}),label:"FASTA is gzip compressed"}),i.jsx(s.Table,_===fl.BGZIP_FASTA||_===fl.GFF3?{size:"small",sx:{mt:2},children:i.jsxs(s.TableBody,{children:[i.jsxs(s.TableRow,{children:[i.jsx(s.TableCell,{style:{borderBottomWidth:0},children:i.jsxs(s.Box,{display:"flex",alignItems:"center",children:[i.jsx("span",{children:"FASTA"}),i.jsx(s.Tooltip,{title:'Unless "Store sequence in database" enabled, FASTA input must be compressed with bgzip and indexed with samtools faidx (or equivalent). Compression is optional for sequences stored in the database.',children:i.jsx(s.IconButton,{size:"small",children:i.jsx(ya,{sx:{fontSize:18}})})})]})}),i.jsx(s.TableCell,{style:{borderBottomWidth:0},children:i.jsx("input",{"data-testid":"fasta-input-file",type:"file",onChange:e=>{const t=e.target.files?.item(0);t&&(R(t),t.name.endsWith(".gz")&&$(!0))},disabled:C&&!p})})]}),i.jsxs(s.TableRow,{children:[i.jsx(s.TableCell,{style:{borderBottomWidth:0},children:"FASTA index (.fai)"}),i.jsx(s.TableCell,{style:{borderBottomWidth:0},children:i.jsx("input",{"data-testid":"fai-input-file",type:"file",onChange:e=>{I(e.target.files?.item(0)??null)},disabled:C&&!p||w})})]}),i.jsxs(s.TableRow,{children:[i.jsx(s.TableCell,{style:{borderBottomWidth:0},children:"FASTA binary index (.gzi)"}),i.jsx(s.TableCell,{style:{borderBottomWidth:0},children:i.jsx("input",{"data-testid":"gzi-input-file",type:"file",onChange:e=>{D(e.target.files?.item(0)??null)},disabled:C&&!p||w})})]})]})}:{size:"small",sx:{mt:2},children:i.jsxs(s.TableBody,{children:[i.jsxs(s.TableRow,{children:[i.jsx(s.TableCell,{style:{borderBottomWidth:0},children:i.jsxs(s.Box,{display:"flex",alignItems:"center",children:[i.jsx("span",{children:"FASTA"}),i.jsx(s.Tooltip,{title:"Remote FASTA input must be compressed with bgzip and indexed with samtools faidx (or equivalent)",children:i.jsx(s.IconButton,{size:"small",children:i.jsx(ya,{sx:{fontSize:18}})})})]})}),i.jsx(s.TableCell,{style:{borderBottomWidth:0},children:i.jsx(s.TextField,{"data-testid":"fasta-input-url",variant:"outlined",value:O,error:!W,onChange:e=>{const{value:t}=e.target;F(t),L(t?`${t}.fai`:""),B(t?`${t}.gzi`:"")},disabled:C&&!p,slotProps:{input:{startAdornment:i.jsx(s.InputAdornment,{position:"start",children:i.jsx(_a,{})})}}})})]}),i.jsxs(s.TableRow,{children:[i.jsx(s.TableCell,{style:{borderBottomWidth:0},children:"FASTA index (.fai)"}),i.jsx(s.TableCell,{style:{borderBottomWidth:0},children:i.jsx(s.TextField,{"data-testid":"fai-input-url",variant:"outlined",value:M,error:!J,onChange:e=>{L(e.target.value)},disabled:C&&!p,slotProps:{input:{startAdornment:i.jsx(s.InputAdornment,{position:"start",children:i.jsx(_a,{})})}}})})]}),i.jsxs(s.TableRow,{children:[i.jsx(s.TableCell,{style:{borderBottomWidth:0},children:"FASTA binary index (.gzi)"}),i.jsx(s.TableCell,{style:{borderBottomWidth:0},children:i.jsx(s.TextField,{"data-testid":"gzi-input-url",variant:"outlined",value:P,error:!K,onChange:e=>{B(e.target.value)},disabled:C&&!p,slotProps:{input:{startAdornment:i.jsx(s.InputAdornment,{position:"start",children:i.jsx(_a,{})})}}})})]})]})})]})})]}),i.jsxs(s.Accordion,{disableGutters:!0,elevation:0,square:!0,className:o.accordion,expanded:"panelGffInput"===Y,onChange:Z("panelGffInput"),children:[i.jsx(s.AccordionSummary,{className:o.accordionSummary,expandIcon:"panelGffInput"===Y?i.jsx(va,{className:o.radioIcon,sx:{fontSize:"1.2rem",ml:5}}):i.jsx(ba,{className:o.radioIcon,sx:{fontSize:"1.2rem",mr:5}}),"aria-controls":"panelGffInputd-content",children:i.jsxs(s.Typography,{component:"span",children:["GFF3 input",i.jsx(s.Tooltip,{title:"GFF3 must includes FASTA sequences. File can be gzip compressed.",children:i.jsx(ya,{className:o.radioIcon,sx:{fontSize:18}})})]})}),i.jsx(s.AccordionDetails,{className:o.accordionDetails,children:i.jsxs(s.Box,{style:{marginTop:20},children:[i.jsx("input",{"data-testid":"gff3-input-file",type:"file",disabled:C&&!p,onChange:e=>{const t=e.target.files?.item(0);t&&(R(t),v(fl.GFF3),t.name.endsWith(".gz")&&G(!0))}}),i.jsxs(s.FormGroup,{style:{display:"grid"},children:[i.jsx(s.FormControlLabel,{control:i.jsx(s.Checkbox,{checked:b,onChange:()=>{x(!b)},disabled:C&&!p}),label:"Load features from GFF3 file"}),i.jsx(s.FormControlLabel,{label:"Strict parsing",disabled:!b||C&&!p,control:i.jsx(s.Checkbox,{checked:k,onChange:e=>{N(e.target.checked)}})}),i.jsx(s.FormHelperText,{children:"Don't import any features if any lines in the GFF3 are unable to be processed"}),i.jsx(s.FormControlLabel,{"data-testid":"gff3-is-gzip-checkbox",control:i.jsx(s.Checkbox,{checked:H,onChange:()=>{G(!H)},disabled:C&&!p}),label:"GFF3 is gzip compressed"})]})]})})]})]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{disabled:!pl(m,w,_,T,E,j,W,J,K)||C,variant:"contained",type:"submit","data-testid":"submit-button",children:C?"Submitting...":"Submit"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:t,children:"Cancel"})]})]}),p?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:p})}):null]})}const ml=[{field:"name",headerName:"Assembly Name",width:150,editable:!1},{field:"aliases",headerName:"Aliases",width:300,editable:!0}];function yl({changeManager:e,handleClose:t,session:n}){const{apolloDataStore:r}=n,{collaborationServerDriver:o}=r,a=o.getAssemblies().map((e=>({id:e.name,name:e.displayName,aliases:e.aliases.join(", ")}))),[l,c]=u.useState("");return i.jsxs(Bs,{open:!0,title:"Add assembly aliases",handleClose:t,maxWidth:"sm","data-testid":"add-assembly-alias",fullWidth:!0,children:[i.jsx(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:i.jsx(s.Box,{sx:{height:400,width:"100%"},children:i.jsx(m.DataGrid,{rows:a,columns:ml,initialState:{pagination:{paginationModel:{pageSize:5}}},pageSizeOptions:[5],processRowUpdate:(n,r)=>{const o=new gt({typeName:"AddAssemblyAliasesChange",assembly:n.id,aliases:n.aliases.split(",")});return e.submit(o).catch((()=>{c("Error submitting change")})),t(),n},disableRowSelectionOnClick:!0})})}),l?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:l})}):null]})}const _l=new Set(["TAA","TAG","TGA"]);function vl(e,t,n){let r=0;for(const o of t){const t=o.max-o.min;if(e<=r+t){const t=e-r;return 1===n?o.min+t:o.max-t}r+=t}const o=t.at(-1);if(!o)throw new Error("No exons found");return 1===n?o.max:o.min}function bl({changeManager:e,handleClose:t,refName:n,session:r,sourceAssemblyId:a,sourceFeature:l}){const[c,d]=u.useState("longest-orf"),[f,h]=u.useState(""),[p,g]=u.useState(""),[m,y]=u.useState(""),_="manual"===c&&Boolean(f)&&Boolean(p)&&Number(p)<=Number(f),v="manual"===c&&(!(f&&p)||_);return i.jsxs(Bs,{open:!0,title:"Add coding sequence",handleClose:t,maxWidth:!1,"data-testid":"add-coding-sequence",children:[i.jsxs("form",{onSubmit:i=>{!async function(i){let s,u;i.preventDefault(),y("");try{if("longest-orf"===c){const e=l.transcriptExonParts.filter((e=>"exon"===e.type));if(0===e.length)return void y("No exons found in this transcript");const i=r.apolloDataStore.getBackendDriver(a);if(!i)return void y("No backend driver found for this assembly");let c="";for(const t of e){const{seq:e}=await i.getSequence({assemblyName:a,refName:n,start:t.min,end:t.max});c+=-1===l.strand?o.revcom(e):e}const d=function(e){const t=[null,null,null];let n;for(let r=0;r<e.length-2;r++){const o=e.slice(r,r+3).toUpperCase(),i=r%3;if("ATG"===o&&null===t[i])t[i]=r;else if(_l.has(o)){const e=t[i];if(null===e)continue;(!n||n[1]-n[0]<r-e)&&(n=[e,r]),t[i]=null}}return n}(c);if(!d)return r.notify("No open reading frame found in this transcript","error"),void t();1===(l.strand??1)?(s=vl(d[0],e,1),u=vl(d[1]+3,e,1)):(u=vl(d[0],e,-1),s=vl(d[1]+3,e,-1))}else s=Number(f)-1,u=Number(p);const i=(new at).toHexString(),d={_id:i,refSeq:l.refSeq,min:s,max:u,type:"CDS"};l.strand&&(d.strand=l.strand);const h=new ht({changedIds:[l._id],typeName:"AddFeatureChange",assembly:a,addedFeature:d,parentFeatureId:l._id});await e.submit(h),r.apolloSetSelectedFeature(i),t()}catch(e){y(e instanceof Error?e.message:"An unknown error occurred")}}(i)},children:[i.jsxs(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:[i.jsx(s.FormControl,{children:i.jsxs(s.RadioGroup,{value:c,onChange:e=>{d(e.target.value)},children:[i.jsx(s.FormControlLabel,{value:"longest-orf",control:i.jsx(s.Radio,{}),label:"Calculate longest open reading frame"}),i.jsx(s.FormControlLabel,{value:"manual",control:i.jsx(s.Radio,{}),label:"Manual"})]})}),"manual"===c?i.jsxs(i.Fragment,{children:[i.jsx(s.TextField,{margin:"dense",id:"cds-min",label:"Min",type:"number",fullWidth:!0,variant:"outlined",value:f,onChange:e=>{h(e.target.value)}}),i.jsx(s.TextField,{margin:"dense",id:"cds-max",label:"Max",type:"number",fullWidth:!0,variant:"outlined",value:p,onChange:e=>{g(e.target.value)},error:_,helperText:_?'"Max" must be greater than "Min"':null})]}):null]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{variant:"contained",type:"submit",disabled:v,children:"Submit"}),i.jsx(s.Button,{variant:"outlined",type:"button",onClick:t,children:"Cancel"})]})]}),m?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:m})}):null]})}class xl{clientStore;constructor(e){this.clientStore=e}}async function wl(e,t){return qa(`Apollo-${e}`,1,{upgrade(e){const n="changes";e.objectStoreNames.contains(n)||e.createObjectStore(n,{autoIncrement:!0});for(const n of t){const t=`features-${n}`;if(!e.objectStoreNames.contains(t)){const n=e.createObjectStore(t);n.createIndex("min","min",{unique:!1}),n.createIndex("max","max",{unique:!1})}const r=`checkresults-${n}`;if(!e.objectStoreNames.contains(r)){const t=e.createObjectStore(r,{keyPath:"_id"});t.createIndex("min","start",{unique:!1}),t.createIndex("max","end",{unique:!1}),t.createIndex("featureId","featureId",{unique:!1})}}}})}class Sl extends xl{async getFeatures(e){const{assemblyName:t,end:n,refName:r,start:o}=e,i=(await this.getRegions(t)).map((e=>e.refName)),a=`features-${r}`,s=`checkresults-${r}`,l=[],c=[],u=(await wl(t,i)).transaction([a,s]);for await(const e of u.objectStore(a).index("min").iterate(IDBKeyRange.upperBound(n,!0)))e.value.max>o&&l.push(e.value);for await(const e of u.objectStore(s).index("min").iterate(IDBKeyRange.upperBound(n,!0)))e.value.end>o&&c.push(e.value);return[l,c]}async getSequence(e){const t=o.getSession(this.clientStore),{assemblyManager:n}=t,r=await n.waitForAssembly(e.assemblyName);if(!r)throw new Error(`Assembly not found: "${e.assemblyName}"`);const{configuration:i}=r,{adapter:a}=i.sequence,{pluginManager:s}=o.getEnv(this.clientStore),l=s.getAdapterType(a.type);if(!l)throw new Error(`No adapter found for "${a.type}"`);const c=new(await l.getAdapterClass())(a,void 0,s),u=await c.getSequence({...e,refName:r.getSeqAdapterRefName(e.refName)});if(!u)throw new Error(`Sequence not found: ${JSON.stringify(e)}`);return{seq:u,refSeq:e.refName}}async getRegions(e){const t=o.getSession(this.clientStore),{assemblyManager:n}=t,r=await n.waitForAssembly(e);if(!r)throw new Error(`Assembly not found: "${e}"`);const{regions:i}=r;if(!i)throw new Error(`Assembly not found: "${e}"`);return i}getAssemblies(e){return[]}async getRefNameAliases(e){const t=o.getSession(this.clientStore),{assemblyManager:n}=t,r=await n.waitForAssembly(e);if(!r)throw new Error(`Assembly not found: "${e}"`);const{configuration:i}=r,{refNameAliases:a}=i;if(!a)return[];const{pluginManager:s}=o.getEnv(this.clientStore),l=s.getAdapterType(a.adapter.type);if(!l)throw new Error(`No adapter found for "${a.adapter.type}"`);return new(await l.getAdapterClass())(a.adapter,void 0,s).getRefNameAliases({})}async submitChange(e,t){if(!st(e))return new Wt;const{assembly:n,changedIds:r}=e,o=(await this.getRegions(n)).map((e=>e.refName)),i=await wl(n,o),a=new Set,s=[],c=new Set;if(function(e){return"DeleteFeatureChange"===e.typeName}(e))for(const t of e.changes)if(t.parentFeatureId){const e=this.clientStore.getFeature(t.parentFeatureId);e&&(a.add(e.topLevelFeature),c.add(e.topLevelFeature.refSeq))}else{const{refSeq:e,_id:n}=t.deletedFeature;s.push({refSeq:e,featureId:n}),c.add(e)}else for(const e of r){const t=this.clientStore.getFeature(e);t&&(a.add(t.topLevelFeature),c.add(t.refSeq))}const u=[...c].flatMap((e=>[`features-${e}`,`checkresults-${e}`]));u.push("changes");const d=i.transaction(u,"readwrite");for(const{refSeq:e,featureId:t}of s)d.objectStore(`features-${e}`).delete(t);for(const e of a){const t=l.getSnapshot(e);d.objectStore(`features-${e.refSeq}`).put(t,e._id)}for(const{featureId:e,refSeq:t}of s){const n=d.objectStore(`checkresults-${t}`);for await(const t of n.index("featureId").iterate(e))this.clientStore.deleteCheckResult(t.value._id),t.delete()}for(const e of a){const t=d.objectStore(`checkresults-${e.refSeq}`);for await(const n of t.index("featureId").iterate(e._id))this.clientStore.deleteCheckResult(n.value._id),n.delete()}if(d.objectStore("changes").put({...e.toJSON(),createdAt:new Date}),await d.done,a.size>0){const e=[...ne.getChecks().values()],t=[];for(const r of a){const o=l.getSnapshot(r),i=async(e,t)=>(await this.getSequence({assemblyName:n,refName:r.refSeq,start:e,end:t})).seq;for(const n of e){const e=await n.checkFeature(o,i);for(const n of e)t.push({refSeq:r.refSeq,result:n,topLevelFeatureId:r._id})}}if(t.length>0){const e=o.map((e=>`checkresults-${e}`)),n=i.transaction(e,"readwrite");for(const{refSeq:e,result:r,topLevelFeatureId:o}of t)n.objectStore(`checkresults-${e}`).put({...r,featureId:o});await n.done;for(const{result:e}of t)this.clientStore.addCheckResult(e)}}return new Wt}async searchFeatures(e,t){return[]}async getCheckResults(e){const t=(await this.getRegions(e)).map((e=>e.refName)),n=await wl(e,t),r=[],o=t.map((e=>`checkresults-${e}`)),i=n.transaction(o);for(const e of o)for await(const t of i.objectStore(e).iterate())r.push(t.value);return r}async getChanges(e,t={}){const n=(await this.getRegions(e)).map((e=>e.refName)),r=await wl(e,n);let o=[];for await(const e of r.transaction("changes").store.iterate())o.push({sequence:e.key,...e.value});const{filters:i}=t;if(i?.user){const e=new RegExp(i.user,"i");o=o.filter((t=>void 0!==t.user&&e.test(t.user)))}if(i?.typeName&&(o=o.filter((e=>e.typeName===i.typeName))),i?.startTime){const e=new Date(i.startTime).getTime();o=o.filter((t=>new Date(t.createdAt).getTime()>=e))}if(i?.endTime){const e=new Date(i.endTime).getTime();o=o.filter((t=>new Date(t.createdAt).getTime()<=e))}const a=o.length,s=t.sortField??"sequence",l="asc"===(t.sortOrder??"desc")?1:-1;if(o.sort(((e,t)=>{const n=e[s],r=t[s];return n===r?0:void 0===n?1:void 0===r?-1:n<r?-l:l})),void 0!==t.page&&void 0!==t.pageSize){const e=t.page*t.pageSize;o=o.slice(e,e+t.pageSize)}return{changes:o,totalCount:a}}}const Cl={async AddFeatureChange(e,t){const{assembly:n,changes:r}=t;for(const t of r){const{addedFeature:r,parentFeatureId:o}=t;if(o){let t=e.getFeature(o);if(!t&&(await e.loadFeatures([{assemblyName:n,refName:r.refSeq,start:r.min,end:r.max}]),t=e.getFeature(o),!t))throw new Error(`Could not find parent feature "${o}"`);t.attributes.get("_id")||t.setAttribute("_id",[t._id]),t.addChild(r)}else e.addFeature(n,r)}},async DeleteFeatureChange(e,t){for(const n of t.changes){const{deletedFeature:t,parentFeatureId:r}=n;if(r){const n=e.getFeature(r);if(!n)throw new Error(`Could not find parent feature "${r}"`);n.deleteChild(t._id)}else e.getFeature(t._id)&&e.deleteFeature(t._id)}},async FeatureAttributeChange(e,t){for(const[n,r]of t.changedIds.entries()){const o=e.getFeature(r);if(!o)throw new Error(`Could not find feature with identifier "${r}"`);o.setAttributes(new Map(Object.entries(t.changes[n].newAttributes)))}},async LocationEndChange(e,t){for(const n of t.changes){const{featureId:t,newEnd:r}=n,o=e.getFeature(t);if(!o)throw new Error(`Could not find feature with identifier "${t}"`);o.setMax(r)}},async LocationStartChange(e,t){for(const n of t.changes){const{featureId:t,newStart:r}=n,o=e.getFeature(t);if(!o)throw new Error(`Could not find feature with identifier "${t}"`);o.setMin(r)}},async MergeExonsChange(e,t){for(const n of t.changes){const{firstExon:t,secondExon:r}=n,o=e.getFeature(t._id);if(!o)throw new Error(`Could not find feature with identifier "${t._id}"`);o.setMin(Math.min(t.min,r.min)),o.setMax(Math.max(t.max,r.max));const i=o.attributes.get("merged_with")?.slice()??[],a=Lt(Mt(r.attributes));i.includes(a)||i.push(a),o.setAttribute("merged_with",i),o.parent?.deleteChild(r._id)}},async SplitExonChange(e,t){for(const[n]of t.changedIds.entries()){const{exonToBeSplit:r,parentFeatureId:o,upstreamCut:i,downstreamCut:a,leftExonId:s,rightExonId:l}=t.changes[n];if(!o)throw new Error("TODO: Split exon without parent");const[c,u]=t.makeSplitExons(r,i,a,s,l),d=e.getFeature(o);if(!d)throw new Error(`Could not find parent feature "${o}"`);d.addChild(c),d.addChild(u),e.getFeature(r._id)&&e.deleteFeature(r._id)}},async MergeTranscriptsChange(e,t){for(const[n,r]of t.changedIds.entries()){const{firstTranscript:o,secondTranscript:i}=t.changes[n],a=e.getFeature(o._id);if(!a)throw new Error(`Could not find feature with identifier "${r}"`);t.mergeTranscriptsOnClient(a,i),a.parent?.deleteChild(i._id)}},async UndoMergeExonsChange(e,t){for(const n of t.changes){const{exonsToRestore:t,parentFeatureId:r}=n;if(!r)throw new Error("Parent ID is missing");const o=e.getFeature(r);if(!o)throw new Error(`Could not find parent feature "${r}"`);o.attributes.get("_id")||o.setAttribute("_id",[o._id]);for(const e of t)o.addChild(e)}},async UndoSplitExonChange(e,t){for(const n of t.changes){const{exonToRestore:t,parentFeatureId:r,idsToDelete:o}=n;if(!r)throw new Error("Parent ID is missing");const i=e.getFeature(r);if(!i)throw new Error(`Could not find parent feature "${r}"`);i.attributes.get("_id")||i.setAttribute("_id",[i._id]),i.addChild(t),o.map((e=>{i.deleteChild(e)}))}},async UndoMergeTranscriptsChange(e,t){for(const n of t.changes){const{transcriptsToRestore:t,parentFeatureId:r}=n;if(!r)throw new Error("Parent ID is missing");const o=e.getFeature(r);if(!o)throw new Error(`Could not find parent feature "${r}"`);o.attributes.get("_id")||o.setAttribute("_id",[o._id]);for(const e of t)o.addChild(e)}},async StrandChange(e,t){for(const[n,r]of t.changedIds.entries()){const o=e.getFeature(r);if(!o)throw new Error(`Could not find feature with identifier "${r}"`);o.setStrand(t.changes[n].newStrand)}},async TypeChange(e,t){for(const[n,r]of t.changedIds.entries()){const o=e.getFeature(r);if(!o)throw new Error(`Could not find feature with identifier "${r}"`);o.setType(t.changes[n].newType)}}};class Al{dataStore;constructor(e){this.dataStore=e}recentChanges=[];undoneChanges=[];async submit(e,t={}){const{addToRecents:n=!0,submitToBackend:r=!0,updateJobsManager:i=!1}=t,a=o.getSession(this.dataStore),s=new AbortController,{jobsManager:l,isLocked:c,changeInProgress:u,setChangeInProgress:d}=o.getSession(this.dataStore);if(c)return a.notify("Cannot submit changes in locked mode"),void d(!1);if(u)return void a.notify("Could not submit change, there is another change still in progress");d(!0);const f={name:e.typeName,statusMessage:"Pre-validating",progressPct:0,cancelCallback:()=>{s.abort(new DOMException(`Cancelling change "${e.typeName}"`,"AbortError"))}};i&&l.runJob(f);const h=await Kt.frontendPreValidate(e);if(!h.ok){const e=`Pre-validation failed: "${h.resultsMessages}"`;return i&&l.abortJob(f.name,e),a.notify(e,"error"),void d(!1)}const p=e.typeName,g=function(e){return e in Cl}(p)?Cl[p]:void 0;if(g)try{await g(this.dataStore,e)}catch(e){return i&&l.abortJob(f.name,String(e)),console.error(e),a.notify(`Error encountered in client: ${String(e)}. Data may be out of sync, please refresh the page`,"error"),void d(!1)}if((await Kt.frontendPostValidate(e)).ok||await this.undo(e),r){i&&l.update(f.name,"Submitting to driver");const{collaborationServerDriver:r,getBackendDriver:o}=this.dataStore,s=te(e)?o(e.assembly)??r:r;let c;try{c=await s.submitChange(e,t)}catch(t){return i&&l.abortJob(f.name,String(t)),console.error(t),a.notify(String(t),"error"),d(!1),void await this.undo(e,!1)}if(!c.ok){const t=`Post-validation failed: "${h.resultsMessages}"`;return i&&l.abortJob(f.name,t),a.notify(t,"error"),d(!1),void await this.undo(e,!1)}e.notification&&a.notify(e.notification,"success"),n&&(this.recentChanges.push(e),this.undoneChanges=[])}i&&l.done(f),d(!1)}async undo(e,t=!0){const n=e.getInverse();return this.submit(n,{submitToBackend:t,addToRecents:!1})}async redo(e,t=!0){return this.submit(e,{submitToBackend:t,addToRecents:!1})}async undoLastChange(){const e=o.getSession(this.dataStore),t=this.recentChanges.pop();if(t)return this.undoneChanges.push(t),this.undo(t);e.notify("No changes to undo!","info")}async redoLastChange(){const e=o.getSession(this.dataStore),t=this.undoneChanges.pop();if(t)return this.recentChanges.push(t),this.redo(t);e.notify("No changes to redo!","info")}}class kl extends xl{inFlight=new Map;refSeqMaps=new Map;async fetch(e,t,n){return e.getFetcher({locationType:"UriLocation",uri:t.toString()})(t,n)}async searchFeatures(e,t){const n=this.clientStore.getInternetAccount(t[0]),{baseURL:r}=n,o=new URL("features/searchFeatures",r),i=new URLSearchParams({assemblies:t.join(","),term:e});o.search=i.toString();const a=o.toString(),s=await this.fetch(n,a);if(!s.ok){const e=await dl(s,"searchFeatures failed");throw new Error(e)}return s.json()}async getFeatures(e){const{assemblyName:t,end:n,refName:r,start:i}=e,{assemblyManager:a}=o.getSession(this.clientStore);if(!a.get(t))throw new Error(`Could not find assembly with name "${t}"`);const s=(await this.getRefSeqMapping(t)).get(r);if(!s)throw new Error(`Could not find refSeq "${r}"`);const l=s.id,c=this.clientStore.getInternetAccount(t),{baseURL:u}=c,d=new URL("features/getFeatures",u),f=new URLSearchParams({refSeq:l,start:String(i),end:String(n)});d.search=f.toString();const h=d.toString(),p=await this.fetch(c,h);if(!p.ok){const e=await dl(p,"getFeatures failed");throw new Error(e)}return this.checkSocket(t,r,c),p.json()}checkSocket(e,t,n){const{socket:r}=n,o=`${e}-${t}`;r.hasListeners(o)||r.on(o,(async e=>{const t=n.retrieveToken();if(!t)return;const r=sn(t),o=new Al(this.clientStore);if(n.setLastChangeSequenceNumber(e.changeSequence),e.userSessionId===r)return;const i=ee.fromJSON(e.changeInfo);st(i)&&this.haveDataForChange(i)&&await o.submit(i,{submitToBackend:!1})}))}haveDataForChange(e){const{assembly:t,changedIds:n}=e;if(!this.clientStore.assemblies.get(t))return!1;for(const e of n)if(this.clientStore.getFeature(e))return!0;return!1}async getSequence(e){const t=`${e.refName}:${e.start}-${e.end}`,n=this.inFlight.get(t),{assemblyName:r,end:i,refName:a,start:s}=e,{assemblyManager:l}=o.getSession(this.clientStore);if(!l.get(r))throw new Error(`Could not find assembly with name "${r}"`);const c=(await this.getRefSeqMapping(r)).get(a);if(!c)throw new Error(`Could not find refSeq "${a}"`);const u=c.id;if(n)return{seq:await n,refSeq:u};const d=this.clientStore.assemblies.get(r)??this.clientStore.addAssembly(r),f=d.refSeqs.get(u)??d.addRefSeq(u,a),h=f.getSequence(s,i);if(h.length===i-s)return{seq:h,refSeq:u};const p=this.clientStore.getInternetAccount(r),{baseURL:g}=p,m=new URL("sequence",g),y=new URLSearchParams({refSeq:u,start:String(s),end:String(i)});m.search=y.toString();const _=m.toString(),v=this.getSeqFromServer(p,_,f,s,i);this.inFlight.set(t,v);const b=await v;return this.checkSocket(r,a,p),this.inFlight.delete(t),{seq:b,refSeq:u}}async getSeqFromServer(e,t,n,r,o){const i=await this.fetch(e,t);if(!i.ok){let e;try{e=await i.text()}catch{e=""}throw new Error(`getSequence failed: ${i.status} (${i.statusText})${e?` (${e})`:""}`)}const a=await i.text();return n.addSequence({sequence:a,start:r,stop:o}),a}async getRefSeqMapping(e){const t=this.refSeqMaps.get(e);if(t)return t;const{assemblyManager:n}=o.getSession(this.clientStore);if(!n.get(e))throw new Error(`Could not find assembly with name "${e}"`);const r=this.clientStore.getInternetAccount(e),{baseURL:i}=r,a=new URL("refSeqs",i),s=new URLSearchParams({assembly:e});a.search=s.toString();const l=a.toString(),c=await this.fetch(r,l);if(!c.ok){let e;try{e=await c.text()}catch{e=""}throw new Error(`getRefNameAliases failed: ${c.status} (${c.statusText})${e?` (${e})`:""}`)}const u=await c.json(),d=new Map(u.map((e=>[e.name,{refName:e.name,id:e._id,aliases:e.aliases}])));return this.refSeqMaps.set(e,d),d}async getRefNameAliases(e){return[...(await this.getRefSeqMapping(e)).values()].map((e=>({refName:e.refName,aliases:[...new Set([e.id,...e.aliases])],uniqueId:`alias-${e.id}`})))}async getRefSeqId(e,t){const n=await this.getRefSeqMapping(e);if(!n)return;const r=n.get(t);return r?.id}async getRegions(e){const{assemblyManager:t}=o.getSession(this.clientStore);if(!t.get(e))throw new Error(`Could not find assembly with name "${e}"`);const n=this.clientStore.getInternetAccount(e),{baseURL:r}=n,i=new URL("refSeqs",r),a=new URLSearchParams({assembly:e});i.search=a.toString();const s=i.toString(),l=await this.fetch(n,s);if(!l.ok){let e;try{e=await l.text()}catch{e=""}throw new Error(`getRegions failed: ${l.status} (${l.statusText})${e?` (${e})`:""}`)}return(await l.json()).map((e=>({refName:e.name,start:0,end:e.length})))}getAssemblies(e){const{assemblyManager:t}=o.getSession(this.clientStore);return t.assemblies.filter((t=>{const r=n.getConf(t,["sequence","metadata"]);return!(!(r&&r.apollo&&r.internetAccountConfigId)||e&&r.internetAccountConfigId!==e)}))}async getChanges(e,t={}){const n=this.clientStore.getInternetAccount(e),{baseURL:r}=n,o=new URL("changes",r),i={assembly:e};void 0!==t.page&&(i.page=String(t.page)),void 0!==t.pageSize&&(i.pageSize=String(t.pageSize)),t.sortField&&(i.sortField=t.sortField),t.sortOrder&&(i.sortOrder=t.sortOrder),t.filters?.user&&(i.user=t.filters.user),t.filters?.typeName&&(i.typeName=t.filters.typeName),t.filters?.startTime&&(i.startTime=t.filters.startTime),t.filters?.endTime&&(i.endTime=t.filters.endTime),o.search=new URLSearchParams(i).toString();const a=await this.fetch(n,o.toString());if(!a.ok){const e=await dl(a,"getChanges failed");throw new Error(e)}return a.json()}async getCheckResults(e){const t=this.clientStore.getInternetAccount(e),{baseURL:n}=t,r=new URL("checks",n);r.search=new URLSearchParams({assembly:e}).toString();const o=await this.fetch(t,r.toString());if(!o.ok){const e=await dl(o,"getCheckResults failed");throw new Error(e)}return o.json()}async submitChange(e,t={}){const{internetAccountId:n}=t,r=this.clientStore.getInternetAccount("assembly"in e?e.assembly:void 0,n),{baseURL:o}=r,i=new URL("changes",o).href,a=await this.fetch(r,i,{method:"POST",body:JSON.stringify(e.toJSON()),headers:{"Content-Type":"application/json"}});if(!a.ok){const e=await dl(a,"submitChange failed");throw new Error(e)}const s=new Wt;return a.ok||(s.ok=!1),s}}var Nl;function Tl(e,t,n,r){const o={_id:(new at).toHexString(),refSeq:e,type:"CDS",min:n,max:r,strand:t},i={_id:(new at).toHexString(),refSeq:e,type:"exon",min:n,max:r,strand:t},a={};return a[o._id]=o,a[i._id]=i,{_id:(new at).toHexString(),refSeq:e,type:"mRNA",min:n,max:r,strand:t,children:a}}function Rl({changeManager:e,handleClose:t,region:n,session:r}){const[o,a]=u.useState(String(n.end)),[l,c]=u.useState(String(n.start+1)),[d,f]=u.useState(Nl.GENE_AND_SUBFEATURES),[h,p]=u.useState(""),[g,m]=u.useState(),[y,_]=u.useState(""),v=Number(o)<=Number(l);let b=v||!(l&&o&&d);return(d===Nl.CUSTOM&&!h||!g&&d===Nl.GENE_AND_SUBFEATURES||!g&&d===Nl.TRANSCRIPT_AND_SUBFEATURES)&&(b=!0),i.jsxs(Bs,{open:!0,title:"Add new feature",handleClose:t,maxWidth:!1,"data-testid":"add-feature-dialog",children:[i.jsxs("form",{onSubmit:async function(i){i.preventDefault(),_("");const a=r.apolloDataStore.getBackendDriver(n.assemblyName);if(!a)return void _("No backend driver found");let s=n.refName;if(a instanceof kl){const e=await a.getRefSeqId(n.assemblyName,n.refName);if(!e)return void _(`Could not find refSeq for "${n.refName}"`);s=e}if(d===Nl.GENE_AND_SUBFEATURES){const i=Tl(s,g,Number(l)-1,Number(o)),a={};a[i._id]=i;const c=(new at).toHexString(),u=new ht({changedIds:[c],typeName:"AddFeatureChange",assembly:n.assemblyName,addedFeature:{_id:c,refSeq:s,min:Number(l)-1,max:Number(o),type:"gene",strand:g,children:a}});return e.submit(u).then((()=>{r.apolloSetSelectedFeature(c)})),void t()}if(d===Nl.TRANSCRIPT_AND_SUBFEATURES){const i=Tl(s,g,Number(l)-1,Number(o)),a=new ht({changedIds:[i._id],typeName:"AddFeatureChange",assembly:n.assemblyName,addedFeature:i});return e.submit(a).then((()=>{r.apolloSetSelectedFeature(i._id)})),void t()}if(!h)return void _("No type selected");const c=(new at).toHexString(),u=new ht({changedIds:[c],typeName:"AddFeatureChange",assembly:n.assemblyName,addedFeature:{_id:c,refSeq:s,min:Number(l)-1,max:Number(o),type:h,strand:g}});e.submit(u).then((()=>{r.apolloSetSelectedFeature(c)})),t()},"data-testid":"submit-form",children:[i.jsxs(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:[i.jsx(s.TextField,{margin:"dense",id:"start",label:"Start",type:"number",fullWidth:!0,variant:"outlined",value:Number(l),onChange:e=>{c(e.target.value)}}),i.jsx(s.TextField,{margin:"dense",id:"end",label:"End",type:"number",fullWidth:!0,variant:"outlined",value:o,onChange:e=>{a(e.target.value)},error:v,helperText:v?'"End" must be greater than "Start"':null}),i.jsxs(s.FormControl,{children:[i.jsx(s.InputLabel,{id:"demo-simple-select-label",children:"Strand"}),i.jsxs(s.Select,{labelId:"demo-simple-select-label",id:"demo-simple-select",label:"Strand",value:g?.toString(),onChange:function(e){switch(_(""),Number(e.target.value)){case 1:m(1);break;case-1:m(-1);break;default:m(void 0)}},children:[i.jsx(s.MenuItem,{value:void 0}),i.jsx(s.MenuItem,{value:1,children:"+"}),i.jsx(s.MenuItem,{value:-1,children:"-"})]})]}),i.jsx(s.FormControl,{style:{marginTop:20},children:i.jsxs(s.RadioGroup,{"aria-labelledby":"demo-radio-buttons-group-label",defaultValue:Nl.GENE_AND_SUBFEATURES,name:"radio-buttons-group",value:d,onChange:e=>{_("");const{value:t}=e.target;Object.keys(Nl).includes(t)&&f(Nl[t])},children:[i.jsx(s.FormControlLabel,{value:Nl.GENE_AND_SUBFEATURES,control:i.jsx(s.Radio,{}),label:i.jsxs(s.Box,{display:"flex",alignItems:"center",children:["Add gene and sub-features",i.jsx(s.Tooltip,{title:"This is a shortcut to create a gene with a single mRNA, exon, and CDS",children:i.jsx(s.IconButton,{size:"small",children:i.jsx(ya,{sx:{fontSize:18}})})})]})}),i.jsx(s.FormControlLabel,{value:Nl.TRANSCRIPT_AND_SUBFEATURES,control:i.jsx(s.Radio,{}),label:i.jsxs(s.Box,{display:"flex",alignItems:"center",children:["Add transcript and sub-features",i.jsx(s.Tooltip,{title:"This is a shortcut to create a single mRNA with exon and CDS, but without a parent gene",children:i.jsx(s.IconButton,{size:"small",children:i.jsx(ya,{sx:{fontSize:18}})})})]})}),i.jsx(s.FormControlLabel,{value:Nl.CUSTOM,checked:d!==Nl.GENE_AND_SUBFEATURES&&d!==Nl.TRANSCRIPT_AND_SUBFEATURES,control:i.jsx(s.Radio,{}),label:"Add feature with a sequence ontology type"})]})}),d===Nl.CUSTOM?i.jsx(qs,{session:r,ontologyName:"Sequence Ontology",style:{width:170},value:h,filterTerms:Cs,renderInput:e=>i.jsx(s.TextField,{...e,label:"Type",variant:"outlined",fullWidth:!0}),onChange:(e,t)=>{var n;t&&(n=t,_(""),p(n))}}):null]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{variant:"contained",type:"submit",disabled:b,children:"Submit"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:t,children:"Cancel"})]})]}),y?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:y})}):null]})}function El({changeManager:e,handleClose:t,session:n}){const{internetAccounts:r}=l.getRoot(n),[o,a]=u.useState(""),[c,d]=u.useState(!1),[f,h]=u.useState(!1),p=r.filter((e=>"ApolloInternetAccount"===e.type));if(0===p.length)throw new Error("No Apollo internet account found");const[g,m]=u.useState(p[0]),{collaborationServerDriver:y}=n.apolloDataStore,_=y.getAssemblies(),[v,b]=u.useState(_.at(0));return i.jsxs(Bs,{open:!0,title:"Delete Assembly",handleClose:t,maxWidth:!1,"data-testid":"delete-assembly",children:[i.jsxs("form",{onSubmit:async function(n){if(n.preventDefault(),h(!0),a(""),!v)return void a("Must select assembly!");const r=new xt({typeName:"DeleteAssemblyChange",assembly:v.name});await e.submit(r,{internetAccountId:g.internetAccountId}),t(),n.preventDefault()},children:[i.jsxs(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:[p.length>1?i.jsxs(i.Fragment,{children:[i.jsx(s.DialogContentText,{children:"Select account"}),i.jsx(s.Select,{value:g.internetAccountId,onChange:function(e){h(!1);const t=p.find((t=>t.internetAccountId===e.target.value));if(!t)throw new Error(`Could not find internetAccount with ID "${e.target.value}"`);m(t)},disabled:f&&!o,children:r.map((e=>i.jsx(s.MenuItem,{value:e.internetAccountId,children:e.name},e.id)))})]}):null,i.jsx(s.DialogContentText,{children:"Select assembly"}),i.jsx(s.Select,{labelId:"label",value:v?.name??"",onChange:function(e){const t=_.find((t=>t.name===e.target.value));b(t)},disabled:0===_.length,children:_.map((e=>i.jsx(s.MenuItem,{value:e.name,children:e.displayName},e.name)))}),i.jsx(s.DialogContentText,{children:i.jsx("strong",{style:{color:"red"},children:"NOTE: All assembly data will be deleted and this operation cannot be undone!"})}),i.jsx(s.FormGroup,{children:i.jsx(s.FormControlLabel,{control:i.jsx(s.Checkbox,{checked:c,onChange:()=>{d(!c)}}),label:"I understand that all assembly data will be deleted"})})]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{disabled:!v||!c,variant:"contained",type:"submit",children:"Delete"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:t,children:"Cancel"})]})]}),o?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:o})}):null]})}!function(e){e.GENE_AND_SUBFEATURES="GENE_AND_SUBFEATURES",e.TRANSCRIPT_AND_SUBFEATURES="TRANSCRIPT_AND_SUBFEATURES",e.CUSTOM="CUSTOM"}(Nl||(Nl={}));var Il,jl,Dl,Ol,Fl={},Ml={},Ll={},Pl={};function Bl(){if(Il)return Pl;function e(e){return decodeURIComponent(e)}function t(e,t){return String(t).replaceAll(e,(function(e){return encodeURIComponent(e).toUpperCase()}))}function n(e){return t(/[\n;\r\t=%&,\u0000-\u001f\u007f]/g,e)}function r(e){return t(/[\n\r\t%\u0000-\u001f\u007f]/g,e)}function o(t){if(null==t||!t.length||"."===t)return{};var n={};return t.replace(/\r\n|[\r\n]$/,"").split(";").forEach((function(t){var r,o,i=t.split("=",2);if(null!==(r=i[1])&&void 0!==r&&r.length){i[0]=i[0].trim();var a=n[i[0].trim()];a||(n[i[0]]=a=[]),(o=a).push.apply(o,W(i[1].split(",").map((function(e){return e.trim()})).map(e)))}})),n}function i(e){var t=[];return Object.entries(e).forEach((function(e){var r=G(e,2),o=r[0],i=r[1].map(n).join(",");t.push("".concat(n(o),"=").concat(i))})),t.length?t.join(";"):"."}function a(e,t){var n=null==e.attributes?".":i(e.attributes),o=[null===e.seq_id?".":r(e.seq_id),null===e.source?".":r(e.source),null===e.type?".":r(e.type),null===e.start?".":r(e.start),null===e.end?".":r(e.end),null===e.score?".":r(e.score),null===e.strand?".":r(e.strand),null===e.phase?".":r(e.phase),n],a="".concat(o.join("\t"),"\n");return t[a]?"":(t[a]=!0,a)}function s(e,t){if(Array.isArray(e))return e.map((function(e){return s(e,t)})).join("");var n,r=[a(e,t)];return void 0!==(n=e).child_features&&void 0!==n.derived_features&&r.push.apply(r,W(e.child_features.map((function(e){return s(e,t)}))).concat(W(e.derived_features.map((function(e){return s(e,t)}))))),r.join("")}function l(e){return s(e,{})}function c(e){var t="##".concat(e.directive);return e.value&&(t+=" ".concat(e.value)),t+"\n"}function u(e){return"# ".concat(e.comment,"\n")}function d(e){for(var t=">".concat(e.id).concat(e.description?" ".concat(e.description):"","\n"),n=Math.ceil(e.sequence.length/80),r=new Array(n),o=0;o<n;o+=1){var i=80*o;r[o]=e.sequence.slice(i,i+80)}return"".concat(t).concat(r.join("\n"),"\n")}function f(e){return"attributes"in e?l(e):"directive"in e?c(e):"sequence"in e?d(e):"comment"in e?u(e):"# (invalid item found during format)\n"}return Il=1,Object.defineProperty(Pl,"__esModule",{value:!0}),Pl.unescape=e,Pl.escape=n,Pl.escapeColumn=r,Pl.parseAttributes=o,Pl.parseFeature=function(t){var n=t.trim().split("\t").map((function(e){return"."===e||""===e?null:e}));return{seq_id:n[0]&&e(n[0]),source:n[1]&&e(n[1]),type:n[2]&&e(n[2]),start:null===n[3]?null:parseInt(n[3],10),end:null===n[4]?null:parseInt(n[4],10),score:null===n[5]?null:parseFloat(n[5]),strand:n[6],phase:n[7],attributes:null===n[8]?null:o(n[8])}},Pl.parseDirective=function(e){var t=/^\s*##\s*(\S+)\s*(.*)/.exec(e);if(!t)return null;var n=G(t,2)[1],r=G(t,3)[2],o={directive:n};if(r.length&&(r=r.replace(/\r\n|[\r\n]$/,""),o.value=r),"sequence-region"===n){var i,a,s=r.split(/\s+/,3);return B(B({},o),{},{seq_id:s[0],start:null===(i=s[1])||void 0===i?void 0:i.replaceAll(/\D/g,""),end:null===(a=s[2])||void 0===a?void 0:a.replaceAll(/\D/g,"")})}if("genome-build"===n){var l=G(r.split(/\s+/,2),2),c=l[0],u=l[1];return B(B({},o),{},{source:c,buildName:u})}return o},Pl.formatAttributes=i,Pl.formatFeature=l,Pl.formatDirective=c,Pl.formatComment=u,Pl.formatSequence=d,Pl.formatItem=function(e){return Array.isArray(e)?e.map(f):f(e)},Pl}function ql(){if(Dl)return Ml;Dl=1,Object.defineProperty(Ml,"__esModule",{value:!0}),Ml.GFFFormattingTransformer=Ml.GFFTransformer=void 0,Ml.parseStringSync=function(t,r){if(!t)return[];var o=n(null!=r?r:{}),i=[],a=i.push.bind(i),s={errorCallback:o.errorCallback};o.parseFeatures&&(s.featureCallback=a),o.parseDirectives&&(s.directiveCallback=a),o.parseComments&&(s.commentCallback=a),o.parseSequences&&(s.sequenceCallback=a);var l=new e.GFF3Parser({disableDerivesFromReferences:o.disableDerivesFromReferences||!1,bufferSize:Infinity});return t.split(/\r\n|[\r\n]/).forEach((function(e){return l.addLine.bind(l)(e,s)})),l.finish(s),i},Ml.formatSync=function(e){var n=[],r=[];e.forEach((function(e){"sequence"in e?r.push(e):n.push(e)}));var o=n.map((function(e){return Array.isArray(e)?(0,t.formatItem)(e).join(""):(0,t.formatItem)(e)})).join("");return r.length&&(o+="##FASTA\n",o+=r.map(t.formatSequence).join("")),o};var e=function(){if(jl)return Ll;jl=1,Object.defineProperty(Ll,"__esModule",{value:!0}),Ll.GFF3Parser=Ll.FASTAParser=void 0;var e=Bl(),t=function(){return I((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){};R(this,e),D(this,"seqCallback",void 0),D(this,"currentSequence",void 0),this.seqCallback=t,this.currentSequence=void 0}),[{key:"addLine",value:function(e){var t=/^>\s*(\S+)\s*(.*)/.exec(e);t?(this.flush(),this.currentSequence={id:t[1],sequence:""},t[2]&&(this.currentSequence.description=t[2].trim())):this.currentSequence&&/\S/.test(e)&&(this.currentSequence.sequence+=e.replaceAll(/\s/g,""))}},{key:"flush",value:function(){this.currentSequence&&this.seqCallback(this.currentSequence)}},{key:"finish",value:function(){this.flush()}}])}();Ll.FASTAParser=t;var n=function(){return I((function e(t){R(this,e),D(this,"endCallback",void 0),D(this,"disableDerivesFromReferences",void 0),D(this,"bufferSize",void 0),D(this,"fastaParser",void 0),D(this,"eof",!1),D(this,"lineNumber",0),D(this,"underConstructionTopLevel",[]),D(this,"underConstructionById",{}),D(this,"completedReferences",{}),D(this,"underConstructionOrphans",new Map),this.endCallback=t.endCallback||function(){},this.disableDerivesFromReferences=t.disableDerivesFromReferences||!1,this.bufferSize=void 0===t.bufferSize?Infinity:t.bufferSize}),[{key:"addLine",value:function(n,r){if(this.fastaParser)this.fastaParser.addLine(n);else if(!this.eof)if(this.lineNumber+=1,/^\s*[^#\s>]/.test(n))this.bufferLine(n,r);else{var o=/^\s*(#+)(.*)/.exec(n);if(o){var i=G(o,2)[1],a=G(o,3)[2];if(3===i.length)this.emitAllUnderConstructionFeatures(r);else if(2===i.length){var s=(0,e.parseDirective)(n);s&&("FASTA"===s.directive?(this.emitAllUnderConstructionFeatures(r),this.eof=!0,this.fastaParser=new t(r.sequenceCallback)):this.emitItem(s,r))}else a=a.replace(/\s*/,""),this.emitItem({comment:a},r)}else if(/^\s*$/.test(n));else if(/^\s*>/.test(n))this.emitAllUnderConstructionFeatures(r),this.eof=!0,this.fastaParser=new t(r.sequenceCallback),this.fastaParser.addLine(n);else{var l=n.replaceAll(/\r\n|[\r\n]$/g,"");this.parseError("GFF3 parse error. Cannot parse '".concat(l,"'."),r)}}}},{key:"finish",value:function(e){this.emitAllUnderConstructionFeatures(e),this.fastaParser&&this.fastaParser.finish(),this.endCallback()}},{key:"emitItem",value:function(e,t){Array.isArray(e)&&t.featureCallback?t.featureCallback(e):"directive"in e&&t.directiveCallback?t.directiveCallback(e):"comment"in e&&t.commentCallback&&t.commentCallback(e)}},{key:"enforceBufferSizeLimit",value:function(){for(var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=arguments.length>1?arguments[1]:void 0,r=function(t){var n;t&&Array.isArray(t)&&null!==(n=t[0].attributes)&&void 0!==n&&null!==(n=n.ID)&&void 0!==n&&n[0]&&(t[0].attributes.ID.forEach((function(t){delete e.underConstructionById[t],delete e.completedReferences[t]})),t.forEach((function(e){e.child_features&&e.child_features.forEach((function(e){return r(e)})),e.derived_features&&e.derived_features.forEach((function(e){return r(e)}))})))};this.underConstructionTopLevel.length+t>this.bufferSize;){var o=this.underConstructionTopLevel.shift();o&&(this.emitItem(o,n),r(o))}}},{key:"emitAllUnderConstructionFeatures",value:function(e){var t=this;this.underConstructionTopLevel.forEach((function(n){return t.emitItem.bind(t)(n,e)})),this.underConstructionTopLevel=[],this.underConstructionById={},this.completedReferences={},this.underConstructionOrphans.size&&this.parseError("some features reference other features that do not exist in the file (or in the same '###' scope). ".concat(Array.from(this.underConstructionOrphans.keys()).join(",")),e)}},{key:"bufferLine",value:function(t,n){var r,o,i,a=this,s=B(B({},(0,e.parseFeature)(t)),{},{child_features:[],derived_features:[]}),l=(null===(r=s.attributes)||void 0===r?void 0:r.ID)||[],c=(null===(o=s.attributes)||void 0===o?void 0:o.Parent)||[],u=this.disableDerivesFromReferences?[]:(null===(i=s.attributes)||void 0===i?void 0:i.Derives_from)||[];if(l.length||c.length||u.length){var d=void 0;l.forEach((function(e){var t=a.underConstructionById[e];t?(t[t.length-1].type!==s.type&&a.parseError('multi-line feature "'.concat(e,'" has inconsistent types: "').concat(s.type,'", "').concat(t[t.length-1].type,'"'),n),t.push(s),d=t):(d=[s],a.enforceBufferSizeLimit(1,n),c.length||u.length||a.underConstructionTopLevel.push(d),a.underConstructionById[e]=d,a.resolveReferencesTo(d,e))})),this.resolveReferencesFrom(d||[s],{Parent:c,Derives_from:u},l)}else this.emitItem([s],n)}},{key:"resolveReferencesTo",value:function(e,t){var n=this.underConstructionOrphans.get(t);n&&(e.forEach((function(e){var t;(t=e.child_features).push.apply(t,W(n.Parent))})),e.forEach((function(e){var t;(t=e.derived_features).push.apply(t,W(n.Derives_from))})),this.underConstructionOrphans.delete(t))}},{key:"parseError",value:function(e,t){var n;this.eof=!0,null===(n=t.errorCallback)||void 0===n||n.call(t,"".concat(this.lineNumber,": ").concat(e))}},{key:"postSet",value:function(e,t,n){var r=e[t];r||(e[t]=r={});var o=r[n]||!1;return r[n]=!0,o}},{key:"resolveReferencesFrom",value:function(e,t,n){var r=this;t.Parent.forEach((function(t){var o=r.underConstructionById[t];if(o)n.filter((function(e){return r.postSet(r.completedReferences,e,"Parent,".concat(t))})).length||o.forEach((function(t){t.child_features.push(e)}));else{var i=r.underConstructionOrphans.get(t);i||r.underConstructionOrphans.set(t,i={Parent:[],Derives_from:[]}),i.Parent.push(e)}})),t.Derives_from.forEach((function(t){var o=r.underConstructionById[t];if(o)n.filter((function(e){return r.postSet(r.completedReferences,e,"Derives_from,".concat(t))})).length||o.forEach((function(t){t.derived_features.push(e)}));else{var i=r.underConstructionOrphans.get(t);i||r.underConstructionOrphans.set(t,i={Parent:[],Derives_from:[]}),i.Derives_from.push(e)}}))}}])}();return Ll.GFF3Parser=n,Ll}(),t=Bl();function n(e){return B({parseFeatures:!0,parseDirectives:!1,parseSequences:!0,parseComments:!1,bufferSize:Infinity,disableDerivesFromReferences:!1,errorCallback:function(e){throw new Error(e)}},e)}Ml.GFFTransformer=function(){return I((function t(r){R(this,t),D(this,"decoder",void 0),D(this,"parser",void 0),D(this,"lastString",""),D(this,"parseFeatures",void 0),D(this,"parseDirectives",void 0),D(this,"parseComments",void 0),D(this,"parseSequences",void 0),this.decoder=new TextDecoder;var o=n(null!=r?r:{});this.parser=new e.GFF3Parser({bufferSize:o.bufferSize,disableDerivesFromReferences:o.disableDerivesFromReferences}),this.parseFeatures=o.parseFeatures,this.parseDirectives=o.parseDirectives,this.parseComments=o.parseComments,this.parseSequences=o.parseSequences,this.errorCallback=null==r?void 0:r.errorCallback}),[{key:"makeCallbacks",value:function(e){var t={errorCallback:this.emitErrorMessage.bind(this,e)};return this.parseFeatures&&(t.featureCallback=function(t){e.enqueue(t)}),this.parseDirectives&&(t.directiveCallback=function(t){e.enqueue(t)}),this.parseComments&&(t.commentCallback=function(t){e.enqueue(t)}),this.parseSequences&&(t.sequenceCallback=function(t){e.enqueue(t)}),t}},{key:"emitErrorMessage",value:function(e,t){this.errorCallback?this.errorCallback(t):e.error(t)}},{key:"transform",value:function(e,t){var n="".concat(this.lastString).concat(this.decoder.decode(e,{stream:!0})).split(/\r\n|[\r\n]/g);this.lastString=n.pop()||"";var r,o=j(n);try{for(o.s();!(r=o.n()).done;)this.parser.addLine(r.value,this.makeCallbacks(t))}catch(e){o.e(e)}finally{o.f()}}},{key:"flush",value:function(e){var t=this.makeCallbacks(e);this.lastString="".concat(this.lastString).concat(this.decoder.decode()),this.lastString&&(this.parser.addLine(this.lastString,t),this.lastString=""),this.parser.finish(t)}}])}();var r=function(){return I((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};R(this,e),D(this,"linesSinceLastSyncMark",0),D(this,"haveWeEmittedData",!1),D(this,"fastaMode",!1),D(this,"minLinesBetweenSyncMarks",void 0),D(this,"insertVersionDirective",void 0),this.minLinesBetweenSyncMarks=t.minSyncLines||100,this.insertVersionDirective=!1!==t.insertVersionDirective}),[{key:"transform",value:function(e,n){!this.haveWeEmittedData&&this.insertVersionDirective&&(!("directive"in e)||"directive"in e&&"gff-version"!==e.directive)&&n.enqueue("##gff-version 3\n"),"sequence"in e&&!this.fastaMode&&(n.enqueue("##FASTA\n"),this.fastaMode=!0);var r=Array.isArray(e)?e.map((function(e){return(0,t.formatItem)(e)})).join(""):(0,t.formatItem)(e);if(n.enqueue(r),this.linesSinceLastSyncMark>=this.minLinesBetweenSyncMarks)n.enqueue("###\n"),this.linesSinceLastSyncMark=0;else{for(var o=0,i=0;i<r.length;i+=1)"\n"===r[i]&&(o+=1);this.linesSinceLastSyncMark+=o}this.haveWeEmittedData=!0}}])}();return Ml.GFFFormattingTransformer=r,Ml}var Ul,zl=(Ol||(Ol=1,function(e){var t,n=Fl&&Fl.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),r=Fl&&Fl.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=Fl&&Fl.__importStar||(t=function(e){return t=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},t(e)},function(e){if(e&&e.__esModule)return e;var o={};if(null!=e)for(var i=t(e),a=0;a<i.length;a++)"default"!==i[a]&&n(o,e,i[a]);return r(o,e),o}),i=Fl&&Fl.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),e.util=e.defaultExport=void 0;var a=o(ql());i(ql(),e);var s=o(Bl());e.defaultExport=B(B({},a),{},{util:s}),e.default=e.defaultExport,e.util=o(Bl())}(Fl)),Fl),$l={exports:{}},Hl=(Ul||(Ul=1,function(e,t){!function(){function t(e,t,n){var r=new XMLHttpRequest;r.open("GET",e),r.responseType="blob",r.onload=function(){a(r.response,t,n)},r.onerror=function(){console.error("could not download file")},r.send()}function n(e){var t=new XMLHttpRequest;t.open("HEAD",e,!1);try{t.send()}catch(e){}return 200<=t.status&&299>=t.status}function r(e){try{e.dispatchEvent(new MouseEvent("click"))}catch(n){var t=document.createEvent("MouseEvents");t.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),e.dispatchEvent(t)}}var o="object"==("undefined"==typeof window?"undefined":K(window))&&window.window===window?window:"object"==("undefined"==typeof self?"undefined":K(self))&&self.self===self?self:"object"==K(re)&&re.global===re?re:void 0,i=o.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),a=o.saveAs||("object"!=("undefined"==typeof window?"undefined":K(window))||window!==o?function(){}:"download"in HTMLAnchorElement.prototype&&!i?function(e,i,a){var s=o.URL||o.webkitURL,l=document.createElement("a");l.download=i=i||e.name||"download",l.rel="noopener","string"==typeof e?(l.href=e,l.origin===location.origin?r(l):n(l.href)?t(e,i,a):r(l,l.target="_blank")):(l.href=s.createObjectURL(e),setTimeout((function(){s.revokeObjectURL(l.href)}),4e4),setTimeout((function(){r(l)}),0))}:"msSaveOrOpenBlob"in navigator?function(e,o,i){if(o=o||e.name||"download","string"!=typeof e)navigator.msSaveOrOpenBlob(function(e,t){return void 0===t?t={autoBom:!1}:"object"!=K(t)&&(console.warn("Deprecated: Expected third argument to be a object"),t={autoBom:!t}),t.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob(["\ufeff",e],{type:e.type}):e}(e,i),o);else if(n(e))t(e,o,i);else{var a=document.createElement("a");a.href=e,a.target="_blank",setTimeout((function(){r(a)}))}}:function(e,n,r,a){if((a=a||open("","_blank"))&&(a.document.title=a.document.body.innerText="downloading..."),"string"==typeof e)return t(e,n,r);var s="application/octet-stream"===e.type,l=/constructor/i.test(o.HTMLElement)||o.safari,c=/CriOS\/[\d]+/.test(navigator.userAgent);if((c||s&&l||i)&&"undefined"!=typeof FileReader){var u=new FileReader;u.onloadend=function(){var e=u.result;e=c?e:e.replace(/^data:[^;]*;/,"data:attachment/file;"),a?a.location.href=e:location=e,a=null},u.readAsDataURL(e)}else{var d=o.URL||o.webkitURL,f=d.createObjectURL(e);a?a.location=f:location.href=f,a=null,setTimeout((function(){d.revokeObjectURL(f)}),4e4)}});o.saveAs=a.saveAs=a,e.exports=a}()}($l)),$l.exports);function Gl(e){return i.jsx(s.SvgIcon,{viewBox:"0 0 24 24",...e,children:i.jsx("path",{d:"M23,12L19,8V11H10V13H19V16M1,18V6C1,4.89 1.9,4 3,4H15A2,2 0 0,1 17,6V9H15V6H3V18H15V15H17V18A2,2 0 0,1 15,20H3A2,2 0 0,1 1,18Z"})})}function Vl({handleClose:e,session:t,assembly:r}){const[o,a]=u.useState(!1),[l,c]=u.useState(""),{getInternetAccount:d}=t.apolloDataStore,{assemblyManager:f}=t,h=f.get(r);if(!h)return void c(`Assembly "${r}" not found`);const{internetAccountConfigId:p}=n.getConf(h,["sequence","metadata"]);return i.jsxs(Bs,{open:!0,title:"Export annotations",handleClose:e,maxWidth:!1,"data-testid":"download-gff3",children:[i.jsxs("form",{onSubmit:async function(t){t.preventDefault(),c(""),await(p?async function(e){const t=d(r,e),n=new URL("export/getID",t.baseURL),i=new URLSearchParams({assembly:r});n.search=i.toString();const a=n.toString(),s=t.getFetcher({locationType:"UriLocation",uri:a}),l=await s(a,{method:"GET"});if(!l.ok){const e=await dl(l,"Error when exporting ID");return void c(e)}const{exportID:u}=await l.json(),f=new URL("export",t.baseURL),h=new URLSearchParams({exportID:u,includeFASTA:o?"true":"false"});f.search=h.toString();const p=f.toString();window.open(p,"_blank")}(p):async function(e){const t=function(e){const t=new ReadableStream({async start(t){for await(const n of async function*(e){const t=await wl(e,[]);for(const e of t.objectStoreNames){const n=t.transaction(e);for await(const e of n.store.iterate())yield e.value}t.close()}(e)){const e=En(n);t.enqueue(e)}t.close()}});return t.pipeThrough(new TransformStream(new zl.GFFFormattingTransformer))}(e),n=`${e}.gff3`;try{const e=await globalThis.showSaveFilePicker({suggestedName:n}),r=await e.createWritable();await t.pipeTo(r)}catch{const e=await new Response(t).blob();Hl.saveAs(e,n)}}(r)),e()},children:[i.jsxs(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:[i.jsxs(s.DialogContentText,{children:["Exporting annotations for ",r]}),i.jsx(s.FormGroup,{children:i.jsx(s.FormControlLabel,{"data-testid":"include-fasta-checkbox",control:i.jsx(s.Checkbox,{checked:o,onChange:()=>{a(!o)},disabled:!p}),label:"Include fasta sequence in GFF output"})})]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{variant:"contained",type:"submit",children:"Download"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:e,children:"Cancel"})]})]}),l?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:l})}):null]})}function Wl({assemblyName:e,handleClose:t,session:n}){const{changeManager:r}=n.apolloDataStore,[o,a]=u.useState(),[l,c]=u.useState(""),[d,f]=u.useState(!1);return i.jsxs(Bs,{open:!0,title:"Import annotations",handleClose:t,children:[d?i.jsx(s.LinearProgress,{}):null,i.jsxs("form",{onSubmit:async function(n){if(n.preventDefault(),o){f(!0),c("");try{const n=o.stream().pipeThrough(new TransformStream(new zl.GFFTransformer({parseSequences:!1})));for await(const t of n){const n=Fn(t),o=new ht({changedIds:[n._id],typeName:"AddFeatureChange",assembly:e,addedFeature:n});await r.submit(o)}t()}catch(e){c(String(e))}finally{f(!1)}}},children:[i.jsxs(s.DialogContent,{children:[i.jsx(s.DialogContentText,{children:"Import annotations from a GFF3 file into the current Apollo track. Features are parsed and stored locally in the browser, so importing very large GFF3 files is not recommended."}),i.jsx("input",{type:"file",accept:".gff,.gff3",onChange:function(e){e.target.files&&a(e.target.files[0])},disabled:d}),l?i.jsx(s.DialogContentText,{color:"error",children:l}):null]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{variant:"contained",type:"submit",disabled:!o||d,children:"Import"}),i.jsx(s.Button,{variant:"outlined",onClick:t,children:"Cancel"})]})]})]})}function Jl({changeManager:e,handleClose:t,session:r}){const{apolloDataStore:o}=r,[a,l]=u.useState(),[c,d]=u.useState(),[f,h]=u.useState(""),[p,g]=u.useState(!1),[m,y]=u.useState(),[_,v]=u.useState(!1),[b,x]=u.useState(!0),[w,S]=u.useState(!1),{collaborationServerDriver:C,getInternetAccount:A}=o,k=C.getAssemblies();return u.useEffect((()=>{c&&(async()=>{const{internetAccountConfigId:e}=n.getConf(c,["sequence","metadata"]),t=A(c.name,e);if(!t)throw new Error("No Apollo internet account found");const{baseURL:r}=t,o=new URL("features/count",r),i=new URLSearchParams({assemblyId:c.name});o.search=i.toString();const a=t.getFetcher({locationType:"UriLocation",uri:o.toString()});S(!0);const s=await a(o.toString(),{method:"GET"});if(!s.ok)throw new Error(await dl(s));{const e=await s.json();y(e.count)}S(!1)})().catch((e=>{console.error(e),h(e.message??e)}))}),[A,r,c]),i.jsxs(Bs,{open:!0,title:"Import Features from GFF3 file",handleClose:t,maxWidth:!1,"data-testid":"import-features-dialog",children:[w?i.jsx(s.LinearProgress,{}):null,i.jsxs("form",{onSubmit:async function(o){o.preventDefault(),h(""),S(!0),g(!0);let i="";if(!a)return void h("must select a file");if(!c)return void h("Must select assembly to download");const{internetAccountConfigId:s}=n.getConf(c,["sequence","metadata"]),l=A(c.name,s),{baseURL:u}=l,d=new URL("files",u);d.searchParams.set("type","text/x-gff3");const f=d.href,p=new FormData;p.append("file",a),p.append("fileName",a.name),p.append("type","text/x-gff3");const m=l.getFetcher({locationType:"UriLocation",uri:f});t();const{jobsManager:y}=r,v=new AbortController,x={name:`Importing features for ${c.displayName}`,statusMessage:"Uploading file, this may take awhile",progressPct:0,cancelCallback:()=>{v.abort(new DOMException(`Canceling importing of features to ${c.displayName}`,"AbortError")),y.abortJob(x.name)}};if(y.runJob(x),m){const{signal:e}=v,t=await m(f,{method:"POST",body:p,signal:e});if(!t.ok){const e=await dl(t,"Error when inserting new features (while uploading file)");return y.abortJob(x.name,e),void h(e)}i=(await t.json())._id}const w=new vt({typeName:"AddFeaturesFromFileChange",assembly:c.name,fileId:i,parseOptions:{strict:b},deleteExistingFeatures:_});y.done(x),await e.submit(w,{updateJobsManager:!0})},children:[i.jsxs(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:[i.jsx(s.DialogContentText,{children:"Select assembly"}),i.jsx(s.Select,{labelId:"label",value:c?.name??"",onChange:function(e){const t=k.find((t=>t.name===e.target.value));d(t),g(!1)},disabled:p&&!f,children:k.map((e=>i.jsx(s.MenuItem,{value:e.name,children:e.displayName??e.name},e.name)))}),i.jsx(s.DialogContentText,{children:"Upload GFF3 to load features"}),i.jsx("input",{type:"file",onChange:function(e){g(!1),e.target.files&&l(e.target.files[0])},disabled:p&&!f}),i.jsx(s.FormControlLabel,{label:"Strict parsing",disabled:p&&!f,control:i.jsx(s.Checkbox,{checked:b,onChange:function(e){x(e.target.checked)}})}),i.jsx(s.FormHelperText,{children:"Don't import any features if any lines in the GFF3 are unable to be processed"}),m&&m>0?i.jsxs(i.Fragment,{children:[i.jsx(s.FormControlLabel,{label:"Delete existing features",disabled:p&&!f,control:i.jsx(s.Checkbox,{checked:_,onChange:function(e){v(e.target.checked)},slotProps:{input:{"aria-label":"controlled"}},color:"warning"})}),i.jsxs(s.FormHelperText,{children:["This assembly has ",m," features that will be deleted"]})]}):null]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{disabled:!(c&&a&&void 0!==m)||p,variant:"contained",type:"submit",children:p?"Submitting...":"Submit"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:t,children:"Close"})]})]}),f?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:f})}):null]})}function Kl({handleClose:e,session:t}){const{internetAccounts:n}=l.getRoot(t),[r,o]=u.useState(""),a=n.filter((e=>"ApolloInternetAccount"===e.type));if(0===a.length)throw new Error("No Apollo internet account found");const[c,d]=u.useState(a[0]);return i.jsxs(Bs,{open:!0,title:"Log out",handleClose:e,maxWidth:!1,"data-testid":"log-out",children:[i.jsxs("form",{onSubmit:function(e){e.preventDefault(),o(""),c.removeToken(),globalThis.location.reload()},children:[i.jsxs(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:[a.length>1?i.jsxs(i.Fragment,{children:[i.jsx(s.DialogContentText,{children:"Select account"}),i.jsx(s.Select,{value:c.internetAccountId,onChange:function(e){const t=a.find((t=>t.internetAccountId===e.target.value));if(!t)throw new Error(`Could not find internetAccount with ID "${e.target.value}"`);d(t)},children:n.map((e=>i.jsx(s.MenuItem,{value:e.internetAccountId,children:e.name},e.id)))})]}):null,i.jsx(s.DialogContentText,{children:"Are you sure you want to log out?"})]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{disabled:!c,variant:"contained",type:"submit",children:"Log Out"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:e,children:"Cancel"})]})]}),r?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:r})}):null]})}function Yl({handleClose:e,session:t}){const{internetAccounts:n}=l.getRoot(t),[r,o]=u.useState(""),[a,c]=u.useState(!1),d=n.filter((e=>"ApolloInternetAccount"===e.type));if(0===d.length)throw new Error("No Apollo internet account found");const[f,h]=u.useState(d[0]),[p,g]=u.useState([]),[m,y]=u.useState([]),{collaborationServerDriver:_}=t.apolloDataStore,v=_.getAssemblies(),[b,x]=u.useState(v.at(0));function w(e,t){const n=[...m],r=e.target.value;if(t)n.includes(r)||(n.push(r),y(n));else{const e=n.indexOf(r,0);-1!==e&&n.splice(e,1),y(n)}}return u.useEffect((()=>{(async function(){const{baseURL:e,getFetcher:t}=f,n=new URL("checks/types",e).href,r=t({locationType:"UriLocation",uri:n}),i=await r(n,{method:"GET"});if(!i.ok){const e=await dl(i,"Error when retrieving checks from server");return void o(e)}const a=await i.json();g(a)})().catch((e=>{o(String(e))}))}),[f]),u.useEffect((()=>{(async function(){if(!b)return;const{baseURL:e,getFetcher:t}=f,n=new URL(`assemblies/${b.name}`,e).href,r=t({locationType:"UriLocation",uri:n}),i=await r(n,{method:"GET"});if(!i.ok){const e=await dl(i,"Error when retrieving assembly from server");return void o(e)}const a=await i.json();y(a.checks)})().catch((e=>{o(String(e))}))}),[b,f]),i.jsxs(Bs,{open:!0,title:"Manage Checks",handleClose:e,"data-testid":"manage-checks",children:[i.jsxs("form",{onSubmit:async function(n){if(n.preventDefault(),!b)return void o("Must select assembly!");const{notify:r}=t,{baseURL:i,getFetcher:a}=f,s=new URL("assemblies/checks",i).href,l=a({locationType:"UriLocation",uri:s}),c=await l(s,{method:"POST",body:JSON.stringify({_id:b.name,checks:m,name:""}),headers:{"Content-Type":"application/json"}});if(c.ok)r("Assembly checks updated successfully","success"),e();else{const e=await dl(c,"Error when updating assembly checks");o(e)}},children:[i.jsxs(s.DialogContent,{children:[d.length>1?i.jsxs(i.Fragment,{children:[i.jsx(s.DialogContentText,{children:"Select account"}),i.jsx(s.Select,{value:f.internetAccountId,onChange:function(e){c(!1);const t=d.find((t=>t.internetAccountId===e.target.value));if(!t)throw new Error(`Could not find internetAccount with ID "${e.target.value}"`);h(t)},disabled:a&&!r,children:n.map((e=>i.jsx(s.MenuItem,{value:e.internetAccountId,children:e.name},e.id)))})]}):null,i.jsx(s.DialogContentText,{children:"Select assembly"}),i.jsx(s.Select,{style:{width:300},labelId:"label",value:b?.name??"",onChange:function(e){const t=v.find((t=>t.name===e.target.value));x(t)},disabled:0===v.length,children:v.map((e=>i.jsx(s.MenuItem,{value:e.name,children:e.displayName},e.name)))}),i.jsx("br",{}),i.jsx("br",{}),i.jsx(s.TableContainer,{component:s.Paper,children:i.jsxs(s.Table,{children:[i.jsx(s.TableHead,{children:i.jsxs(s.TableRow,{children:[i.jsx(s.TableCell,{children:"Check name"}),i.jsx(s.TableCell,{children:"Use check"})]})}),i.jsx(s.TableBody,{children:p.map((e=>i.jsxs(s.TableRow,{children:[i.jsx(s.TableCell,{children:e.name}),i.jsx(s.TableCell,{children:i.jsx(s.Checkbox,{value:e._id,checked:m.includes(e._id),onChange:w})})]},e._id)))})]})})]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{variant:"contained",type:"submit",children:"Submit"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:e,children:"Cancel"})]})]}),r?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:r})}):null]})}function Xl(e){return"ApolloInternetAccount"===e.type}function Zl({changeManager:e,handleClose:t,session:n}){const{internetAccounts:r}=l.getRoot(n),o=r.filter((e=>Xl(e))).filter((e=>e.role?.includes("admin")));if(0===o.length)throw new Error("No Apollo internet account found");const[a,c]=u.useState(""),[d,f]=u.useState(o[0]),[h,p]=u.useState([]);function g(e){return e===d.getUserId()}u.useEffect((()=>{(async function(){const{baseURL:e}=d,t=new URL("users",e).href,n=d.getFetcher({locationType:"UriLocation",uri:t}),r=await n(t,{method:"GET"});if(!r.ok){const e=await dl(r,"Error when getting user data from db");return void c(e)}const o=await r.json();p(o.map((e=>void 0===e.role?{...e,role:""}:e)))})().catch((e=>{c(String(e))}))}),[d]);const y=[{field:"username",headerName:"User",width:140},{field:"email",headerName:"Email",width:160},{field:"role",headerName:"Role",width:140,type:"singleSelect",valueOptions:["readOnly","user","admin","none"],getOptionLabel(e){switch(e){case"readOnly":return"Read-only";case"user":return"User";case"admin":return"Admin";case"none":return"None";default:return"unknown"}},editable:!0},{field:"actions",type:"actions",getActions:t=>[i.jsx(m.GridActionsCellItem,{icon:i.jsx(co,{}),onClick:async()=>{globalThis.confirm("Delete this user?")&&await async function(t){const n=new wt({typeName:"DeleteUserChange",userId:t});await e.submit(n,{internetAccountId:d.internetAccountId}),p((e=>e.filter((e=>e._id!==t))))}(t.id)},disabled:g(t.id),label:"Delete"},`delete-${t.id}`)]}];return i.jsxs(Bs,{open:!0,fullScreen:!0,title:"Manage users",handleClose:t,"data-testid":"manage-users",children:[i.jsxs(s.DialogContent,{children:[o.length>1?i.jsxs(i.Fragment,{children:[i.jsx(s.DialogContentText,{children:"Select account"}),i.jsx(s.Select,{value:d.internetAccountId,onChange:function(e){const t=o.find((t=>t.internetAccountId===e.target.value));if(!t)throw new Error(`Could not find internetAccount with ID "${e.target.value}"`);f(t)},disabled:!a,children:r.map((e=>i.jsx(s.MenuItem,{value:e.internetAccountId,children:e.name},e.id)))})]}):null,i.jsx("div",{style:{height:"100%",width:"100%"},children:i.jsx(m.DataGrid,{pagination:!0,rows:h,columns:y,getRowId:e=>e._id,showToolbar:!0,getRowHeight:()=>"auto",isCellEditable:e=>!g(e.id),processRowUpdate:async function(t){const n=new Ht({typeName:"UserChange",role:t.role,userId:t._id});return await e.submit(n,{internetAccountId:d.internetAccountId}),t},onProcessRowUpdateError:e=>{c(String(e))}})})]}),i.jsx(s.DialogActions,{children:i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:t,children:"Close"})}),a?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:a})}):null]})}function Ql(e,t){const n=t[e];let r;if("three_prime"===e)r=`3'end (coords: ${n.min+1}-${n.max})`;else{if("five_prime"!==e)throw new Error(`Unexpected direction: "${e}"`);r=`5'end (coords: ${n.min+1}-${n.max})`}return r}function ec({changeManager:e,handleClose:t,selectedFeature:n,setSelectedFeature:r,sourceAssemblyId:o,sourceFeature:a}){const[c,d]=u.useState(""),[f,h]=u.useState(),p=function(e){const t={},n=e.parent;if(!n)throw new Error("Unable to find parent of reference exon");let r=[];if(n.children)for(const[,e]of n.children)"exon"===e.type&&r.push(e);r=r.sort(((e,t)=>e.min===t.min?e.max-t.max:e.min-t.min)),n.strand&&-1===n.strand&&(r=r.reverse());let o=0;for(const n of r){if(n._id===e._id){r.length>o+1&&(t.three_prime=r[o+1]),o>0&&(t.five_prime=r[o-1]);break}o++}return t}(a);return i.jsxs(Bs,{open:!0,title:"Merge exons",handleClose:t,maxWidth:!1,"data-testid":"merge-exons",children:[i.jsxs("form",{onSubmit:function(i){i.preventDefault(),d("");const{parent:s}=a;if(!f||!s)return;n?._id===a._id&&r();const c=new jt({changedIds:[a._id],typeName:"MergeExonsChange",assembly:o,firstExon:l.getSnapshot(a),secondExon:l.getSnapshot(f),parentFeatureId:s._id});e.submit(c),t(),i.preventDefault()},children:[i.jsxs(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:[0===Object.keys(p).length?"There are no neighbouring exons to merge with":"Merge with exon on:",i.jsx(s.FormControl,{style:{marginTop:5},children:i.jsx(s.RadioGroup,{"aria-labelledby":"demo-radio-buttons-group-label",name:"radio-buttons-group",value:f,onChange:e=>{d("");const{value:t}=e.target;h(p[t])},children:Object.keys(p).map((e=>i.jsx(s.FormControlLabel,{value:e,control:i.jsx(s.Radio,{}),label:i.jsx(s.Box,{display:"flex",alignItems:"center",children:Ql(e,p)})},e)))})})]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{variant:"contained",type:"submit",disabled:0===Object.keys(p).length||void 0===f,children:"Submit"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:t,children:"Cancel"})]})]}),c?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:c})}):null]})}function tc(e){let t;return t=e.attributes.get("gff_name")?e.attributes.get("gff_name")?.join(","):e.attributes.get("gff_id")?e.attributes.get("gff_id")?.join(","):e._id,`${t} [${e.min+1}-${e.max}]`}function nc({changeManager:e,handleClose:t,selectedFeature:n,session:r,setSelectedFeature:o,sourceAssemblyId:a,sourceFeature:c}){const[d,f]=u.useState(""),h=function(e,t){const n=e.parent;if(!n)throw new Error("Unable to find parent of reference transcript");const{featureTypeOntology:r}=t.apolloDataStore.ontologyManager;if(!r)throw new Error("featureTypeOntology is undefined");const o={};if(n.children)for(const[,t]of n.children)r.isTypeOf(t.type,"transcript")&&t._id!==e._id&&(o[t._id]=t);return o}(c,r),p=Object.keys(h).at(0),[g,m]=u.useState(p);return i.jsxs(Bs,{open:!0,title:"Merge transcripts",handleClose:t,maxWidth:!1,"data-testid":"merge-transcripts",children:[i.jsxs("form",{onSubmit:function(r){if(r.preventDefault(),f(""),!g)return;const i=h[g];if(n?._id===c._id&&o(),!c.parent)throw new Error("Cannot find parent");const s=new Pt({changedIds:[c._id],typeName:"MergeTranscriptsChange",assembly:a,firstTranscript:l.getSnapshot(c),secondTranscript:l.getSnapshot(i),parentFeatureId:c.parent._id});e.submit(s),t()},children:[i.jsxs(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:[0===Object.keys(h).length?"There are no transcripts to merge with":"Merge with transcript:",i.jsx(s.FormControl,{style:{marginTop:5},children:i.jsx(s.RadioGroup,{"aria-labelledby":"demo-radio-buttons-group-label",name:"radio-buttons-group",value:g,onChange:e=>{f("");const{value:t}=e.target;m(t)},children:Object.keys(h).map((e=>i.jsx(s.FormControlLabel,{value:e,control:i.jsx(s.Radio,{}),label:i.jsx(s.Box,{display:"flex",alignItems:"center",children:tc(h[e])})},e)))})})]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{variant:"contained",type:"submit",disabled:0===Object.keys(h).length||void 0===g,children:"Submit"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:t,children:"Cancel"})]})]}),d?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:d})}):null]})}const rc=ma()((e=>({changeTextarea:{fontFamily:"monospace",width:600,resize:"none",border:`1px solid ${e.palette.divider}`,borderRadius:e.shape.borderRadius}})));function oc(e){const t={};for(const n of e.items)if(void 0!==n.value&&""!==n.value&&null!==n.value)switch(n.field){case"user":t.user=String(n.value);break;case"typeName":t.typeName=String(n.value);break;case"createdAt":{const e=new Date(n.value).toISOString();"after"===n.operator||"onOrAfter"===n.operator?t.startTime=e:"before"!==n.operator&&"onOrBefore"!==n.operator||(t.endTime=e);break}}return t}function ic({handleClose:e,session:t,assembly:n}){const{classes:r}=rc(),[o,a]=u.useState(),[l,c]=u.useState([]),[d,f]=u.useState(0),[h,p]=u.useState(!1),[g,y]=u.useState({page:0,pageSize:15}),[_,v]=u.useState([{field:"sequence",sort:"desc"}]),[b,x]=u.useState({items:[]}),{apolloDataStore:w}=t,{assemblyManager:S}=t,C=S.get(n),A=C?.displayName??n,k=[{field:"sequence"},{field:"typeName",headerName:"Change type",width:200,type:"singleSelect",valueOptions:[...Q.changes.keys()]},{field:"changeData",headerName:"Change JSON",width:600,sortable:!1,filterable:!1,renderCell:({value:e})=>i.jsx("textarea",{className:r.changeTextarea,value:JSON.stringify(e),readOnly:!0})},{field:"user",headerName:"User",width:140},{field:"createdAt",headerName:"Time",width:160,type:"dateTime",valueGetter:e=>e&&new Date(e)}];return u.useEffect((()=>{(async function(){const e=w.getBackendDriver(n);if(!e)return void a(`No driver found for assembly "${n}"`);p(!0);const[t]=_,r=t?.field,o=t?.sort,i="asc"===o||"desc"===o?o:void 0,{changes:s,totalCount:l}=await e.getChanges(n,{page:g.page,pageSize:g.pageSize,sortField:r,sortOrder:i,filters:oc(b)}),u=s.map((e=>{const{sequence:t,typeName:n,changes:r,user:o,createdAt:i,...a}=e;return{sequence:t,typeName:n,changeData:r??{typeName:n,...a},user:o,createdAt:i}}));c(u),f(l)})().catch((e=>{a(String(e))})).finally((()=>{p(!1)}))}),[w,n,g,_,b]),i.jsxs(Bs,{open:!0,fullScreen:!0,title:"View change log",handleClose:e,"data-testid":"view-changelog",children:[i.jsxs(s.DialogContent,{children:[i.jsxs(s.DialogContentText,{children:["Changes for ",A]}),i.jsx(m.DataGrid,{pagination:!0,paginationMode:"server",sortingMode:"server",filterMode:"server",rowCount:d,paginationModel:g,onPaginationModelChange:y,sortModel:_,onSortModelChange:v,filterModel:b,onFilterModelChange:x,loading:h,rows:l,columns:k,getRowId:e=>e.sequence,showToolbar:!0,pageSizeOptions:[5,15,25,50,100],initialState:{columns:{columnVisibilityModel:{sequence:!1}}}})]}),i.jsx(s.DialogActions,{children:i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:e,children:"Close"})}),o?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:o})}):null]})}const ac=[{field:"refName",headerName:"Ref Name"},{field:"aliases",headerName:"Aliases",editable:!0,flex:1}],sc=e=>/^[\da-f]{24}$/i.test(e),lc=p.observer((function({changeManager:e,handleClose:t,session:n}){const r=u.useRef(null),[o,a]=u.useState(""),[l,c]=u.useState(!1),[d,f]=u.useState(),[h,p]=u.useState([]),[g,y]=u.useState((()=>new Map)),{apolloDataStore:_}=n,{collaborationServerDriver:v}=_,b=v.getAssemblies();u.useEffect((()=>{b.length>0&&(f(b[0]),v.getRefNameAliases(b[0].name).then((e=>{x(e)})).catch((()=>{y(new Map),a("Error fetching refName aliases for assembly")})))}),[]);const x=e=>{const t=new Map;for(const n of e){const e=n.refName;sc(e)||t.set(e,n.aliases)}y(t)},w=()=>[...g].map(((e,t)=>({id:t,refName:e[0],aliases:e[1].filter((t=>t!==e[0])).join(", ")})));return i.jsxs(Bs,{open:!0,title:"Add reference sequence aliases",handleClose:t,maxWidth:"sm","data-testid":"add-refseq-alias",fullWidth:!0,children:[i.jsxs(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:[i.jsxs(s.Grid,{container:!0,spacing:2,children:[i.jsx(s.Grid,{children:i.jsxs(s.FormControl,{disabled:l&&!o,fullWidth:!0,children:[i.jsx(s.InputLabel,{id:"demo-simple-select-label",children:"Assembly"}),i.jsx(s.Select,{labelId:"demo-simple-select-label",id:"demo-simple-select",label:"Assembly",value:d?.name??"",onChange:e=>{const t=b.find((t=>t.name===e.target.value));f(t),t?.name&&(v.getRefNameAliases(t.name).then((e=>{x(e),a("")})).catch((()=>{y(new Map),a("Error fetching refName aliases for assembly")})),c(!1),r.current&&(r.current.value=""))},style:{minWidth:150},children:b.map((e=>i.jsx(s.MenuItem,{value:e.name,children:e.displayName},e.name)))})]})}),i.jsxs(s.Grid,{children:[i.jsx(s.InputLabel,{children:"Load RefName alias"}),i.jsx("input",{type:"file",onChange:e=>{(async e=>{if(!e.target.files)return;const t=e.target.files[0],n=(await t.text()).split("\n"),r=new Map(g);a("");for(const e of n){const t=e.split("\t");for(const e of t)r.has(e)&&r.set(e,[...r.get(e)??[],...t])}y(r)})(e).catch((()=>{a("Error reading file")}))},ref:r,disabled:l&&!o||!d})]})]}),d&&g.size>0?i.jsxs("div",{style:{height:200,width:"100%",marginTop:20},children:[i.jsx(s.InputLabel,{children:"Refname aliases found for selected assembly."}),i.jsx(m.DataGrid,{rows:w(),columns:ac,initialState:{pagination:{paginationModel:{page:0,pageSize:5}}},pageSizeOptions:[5,10],onRowSelectionModelChange:e=>{const{ids:t}=e;if(t.size>0){c(!0);const e=[...t.values()].flatMap((e=>w().filter((t=>String(t.id)===String(e)))));p(e)}else c(!1),p([])},processRowUpdate:(e,t)=>{const n=new Map(g);return n.set(e.refName,e.aliases.split(",")),y(n),e},checkboxSelection:!0,disableRowSelectionExcludeModel:!0})]}):null]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{variant:"contained",type:"submit",disabled:!l,onClick:()=>{const n=[];for(const e of h){const{refName:t}=e,r=e.aliases.split(",").map((e=>e.trim())).filter((e=>e.length>0));n.push({refName:t,aliases:r})}if(a(""),!d)return void a("No assembly selected");const r=new bt({typeName:"AddRefSeqAliasesChange",assembly:d.name,refSeqAliases:n});e.submit(r).catch((()=>{a("Error submitting change")})),t()},children:"Submit"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:t,children:"Close"})]}),o?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:o})}):null]})}));function cc({handleClose:e,session:t,assembly:n}){const[r,o]=u.useState(),[a,l]=u.useState([]),{apolloDataStore:c}=t;return u.useEffect((()=>{(async function(){const e=c.getBackendDriver(n);if(!e)return void o(`No driver found for assembly "${n}"`);const t=await e.getCheckResults(n);l(t)})().catch((e=>{o(String(e))}))}),[c,n]),i.jsxs(Bs,{open:!0,fullScreen:!0,title:"View check results",handleClose:e,"data-testid":"view-check-results",children:[i.jsxs(s.DialogContent,{children:[i.jsxs(s.DialogContentText,{children:["Check results for ",n]}),i.jsx(m.DataGrid,{pagination:!0,rows:a,columns:[{field:"_id",headerName:"id",width:50},{field:"name",headerName:"Check name",width:200},{field:"refSeq",headerName:"Reference sequence ID",width:200},{field:"ids",headerName:"Feature IDs",width:200},{field:"message",headerName:"Message",flex:1}],getRowId:e=>e._id,showToolbar:!0,initialState:{sorting:{sortModel:[{field:"name",sort:"asc"}]},columns:{columnVisibilityModel:{name:!0}}}})]}),i.jsx(s.DialogActions,{children:i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:e,children:"Close"})}),r?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:r})}):null]})}function uc(e){return e.max-e.min<2?{isSplittable:!1,comment:"This exon is too short to be split"}:{isSplittable:!0,comment:""}}function dc(e){const t=uc(e);return t.isSplittable?"Are you sure you want to split the selected exon?":t.comment}function fc({changeManager:e,handleClose:t,selectedFeature:n,setSelectedFeature:r,sourceAssemblyId:o,sourceFeature:a}){const[c,d]=u.useState(""),f=l.getSnapshot(a);return i.jsxs(Bs,{open:!0,title:"Split exon",handleClose:t,maxWidth:!1,"data-testid":"split-exon",children:[i.jsxs("form",{onSubmit:function(i){i.preventDefault(),d(""),n?._id===a._id&&r();const s=f.min+(f.max-f.min)/2,l=Math.floor(s),c=Math.ceil(s);if(!a.parent?._id)throw new Error("Splitting an exon without parent is not possible yet");const u=new qt({changedIds:[a._id],typeName:"SplitExonChange",assembly:o,exonToBeSplit:f,parentFeatureId:a.parent._id,upstreamCut:l,downstreamCut:c,leftExonId:(new at).toHexString(),rightExonId:(new at).toHexString()});e.submit(u),t(),i.preventDefault()},children:[i.jsx(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:i.jsx(s.DialogContentText,{children:dc(f)})}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{variant:"contained",type:"submit",disabled:!uc(f).isSplittable,children:"Yes"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:t,children:"Cancel"})]})]}),c?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:c})}):null]})}function hc({changeManager:e,handleClose:t,session:r,sourceAssemblyId:o,sourceFeature:a,setSelectedFeature:c}){const[d,f]=u.useState(""),{notify:h}=r;return i.jsxs(Bs,{open:!0,title:"Duplicate transcript",handleClose:t,maxWidth:!1,"data-testid":"duplicate-transcript",children:[i.jsxs("form",{onSubmit:i=>{!async function(i){i.preventDefault(),f("");try{const i=a.parent;if(!i)return void f("No parent gene found for this transcript");const s=l.getSnapshot(a),u=(new at).toHexString(),d={...s,_id:u};if(d.children){const e={};for(const[,t]of Object.entries(d.children)){const n=(new at).toHexString();e[n]={...t,_id:n}}d.children=e}const p=n.readConfObject(r.getPluginConfiguration(),"skippedAttributesOnCopy");Aa(d,new Set(p??[]));const g=new ht({parentFeatureId:i._id,changedIds:[i._id],typeName:"AddFeatureChange",assembly:o,addedFeature:d});await e.submit(g).then((()=>{c(void 0),r.apolloSetSelectedFeature(u),h("Successfully duplicated transcript","success")})),t()}catch(e){f(e instanceof Error?e.message:"Failed to duplicate transcript")}}(i)},children:[i.jsx(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:i.jsx(s.DialogContentText,{children:"Are you sure you want to create a duplicate of this transcript?"})}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{variant:"contained",type:"submit",children:"Yes"}),i.jsx(s.Button,{variant:"outlined",type:"button",onClick:t,children:"Cancel"})]})]}),d?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:d})}):null]})}var pc=a.createSvgIcon(i.jsx("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 4c1.93 0 3.5 1.57 3.5 3.5S13.93 13 12 13s-3.5-1.57-3.5-3.5S10.07 6 12 6m0 14c-2.03 0-4.43-.82-6.14-2.88C7.55 15.8 9.68 15 12 15s4.45.8 6.14 2.12C16.43 19.18 14.03 20 12 20"}),"AccountCircle"),gc=a.createSvgIcon(i.jsx("path",{d:"M12 7V3H2v18h20V7zM6 19H4v-2h2zm0-4H4v-2h2zm0-4H4V9h2zm0-4H4V5h2zm4 12H8v-2h2zm0-4H8v-2h2zm0-4H8V9h2zm0-4H8V5h2zm10 12h-8v-2h2v-2h-2v-2h2v-2h-2V9h8zm-2-8h-2v2h2zm0 4h-2v2h2z"}),"Business");function mc(e){const{color:t}=e;return i.jsx(s.SvgIcon,{viewBox:"0 0 18 18",style:{fontSize:18,marginRight:4},...e,children:"disabled"===t?i.jsx("path",{d:"M9.001,10.71 l0,-3.348 l8.424,0 c0.126,0.567,0.225,1.098,0.225,1.845 c0,5.139,-3.447,8.793,-8.64,8.793 c-4.968,0,-9,-4.032,-9,-9 c0,-4.968,4.032,-9,9,-9 c2.43,0,4.464,0.891,6.021,2.349 l-2.556,2.484 c-0.648,-0.612,-1.782,-1.332,-3.465,-1.332 c-2.979,0,-5.409,2.475,-5.409,5.508 c0,3.033,2.43,5.508,5.409,5.508 c3.447,0,4.716,-2.385,4.95,-3.798 l-4.959,0 l0,-0.009 z"}):i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M17.64,9.20454545 c0,-0.638,-0.057,-1.252,-0.164,-1.841 l-8.476,0 l0,3.481 l4.844,0 c-0.209,1.125,-0.843,2.079,-1.796,2.717 l0,2.258 l2.908,0 c1.702,-1.567,2.684,-3.874,2.684,-6.615 l0,0 z",fill:"#4285F4"}),i.jsx("path",{d:"M9,18 c2.43,0,4.467,-0.806,5.956,-2.18 l-2.908,-2.259 c-0.806,0.54,-1.837,0.859,-3.048,0.859 c-2.344,0,-4.328,-1.583,-5.036,-3.71 l-3.007,0 l0,2.332 c1.481,2.941,4.525,4.958,8.043,4.958 l0,0 z",fill:"#34A853"}),i.jsx("path",{d:"M3.96409091,10.71 c-0.18,-0.54,-0.282,-1.117,-0.282,-1.71 c0,-0.593,0.102,-1.17,0.282,-1.71 l0,-2.332 l-3.007,0 c-0.609,1.215,-0.957,2.59,-0.957,4.042 c0,1.452,0.348,2.827,0.957,4.042 l3.007,-2.332 l0,0 z",fill:"#FBBC05"}),i.jsx("path",{d:"M9,3.57954545 c1.321,0,2.508,0.454,3.44,1.346 l2.582,-2.581 c-1.559,-1.453,-3.596,-2.345,-6.022,-2.345 c-3.518,0,-6.562,2.017,-8.043,4.959 l3.007,2.331 c0.708,-2.127,2.692,-3.71,5.036,-3.71 l0,0 z",fill:"#EA4335"})]})})}function yc(e){const{color:t}=e;return i.jsxs(s.SvgIcon,{viewBox:"0 0 21 21",style:{fontSize:21},...e,children:[i.jsx("rect",{x:"1",y:"1",width:"9",height:"9",fill:"disabled"===t?"#7B7B7B":"#F25022"}),i.jsx("rect",{x:"1",y:"11",width:"9",height:"9",fill:"disabled"===t?"#7B7B7B":"#00A4EF"}),i.jsx("rect",{x:"11",y:"1",width:"9",height:"9",fill:"disabled"===t?"#939393":"#7FBA00"}),i.jsx("rect",{x:"11",y:"11",width:"9",height:"9",fill:"disabled"===t?"#B9B9B9":"#FFB900"})]})}const _c=ma()((e=>({loginButton:{marginBottom:e.spacing(1),width:"220px",height:"40px",fontSize:"16px",textTransform:"none",justifyContent:"left",padding:"3px 12px"}})));function vc(e){const{classes:t}=_c(),{message:n}=e;return i.jsx(s.Button,{className:t.loginButton,variant:"outlined",startIcon:i.jsx(mc,{}),...e,children:n})}function bc(e){const{classes:t}=_c(),{message:n}=e;return i.jsx(s.Button,{className:t.loginButton,variant:"outlined",startIcon:i.jsx(yc,{}),...e,children:n})}function xc(e){const{classes:t}=_c(),{message:n}=e;return i.jsx(s.Button,{className:t.loginButton,variant:"outlined",startIcon:i.jsx(pc,{fontSize:"small"}),...e,children:n})}function wc(e){const{classes:t}=_c(),{message:n}=e;return i.jsx(s.Button,{className:t.loginButton,variant:"outlined",startIcon:i.jsx(gc,{fontSize:"small"}),...e,children:n})}const Sc=ma()((e=>({divider:{marginTop:e.spacing(4),marginBottom:e.spacing(5)}}))),Cc=({baseURL:e,handleClose:t,name:n})=>{const{classes:r}=Sc(),[o,a]=u.useState(""),[l,c]=u.useState(null);function d(e){t(e)}if(u.useEffect((()=>{const t=new AbortController,{signal:n}=t;return async function(){const t=new URL("auth/types",e).href,r=await fetch(t,{method:"GET",signal:n});if(!r.ok){const e=await dl(r,"Error when retrieving auth types from server");return void a(e)}const o=await r.json();c(o),0===o.length&&a("No login types configured")}().catch((e=>{ts(e)||a(String(e))})),()=>{t.abort(new DOMException("Error retrieving valid authentication types","AbortError"))}}),[e]),null===l)return"Loading…";const f=l.at(0);return f&&1===l.length&&!f.needsPopup&&d(f),i.jsxs(Bs,{open:!0,title:`Log in to ${n}`,handleClose:t,maxWidth:!1,"data-testid":"login-apollo",children:[i.jsx(s.DialogContent,{style:{display:"flex",flexDirection:"column",paddingTop:8},children:l.map((e=>"google"===e.name?i.jsx(vc,{message:e.message,onClick:()=>{d(e)}},e.name):"microsoft"===e.name?i.jsx(bc,{message:e.message,onClick:()=>{d(e)}},e.name):"guest"===e.name?i.jsxs(u.Fragment,{children:[i.jsx(s.Divider,{className:r.divider}),i.jsx(xc,{message:e.message,onClick:()=>{d(e)}})]},e.name):i.jsx(wc,{message:e.message,onClick:()=>{d(e)}},e.name)))}),i.jsx(s.DialogActions,{children:i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:()=>{t()},children:"Cancel"})}),o?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:o})}):null]})},Ac="undefined"==typeof sessionStorage,kc=e=>r.InternetAccount.named("ApolloInternetAccount").props({type:l.types.literal("ApolloInternetAccount"),configuration:n.ConfigurationReference(e)}).views((e=>({get baseURL(){return n.getConf(e,"baseURL")},getUserId(){const t=e.retrieveToken();if(t)return ln(t).id}}))).volatile((()=>({role:void 0,controller:new AbortController,tokenPromise:void 0}))).actions((e=>({setRole(){const t=e.retrieveToken();if(!t)return void(e.role=void 0);const n=ln(t),{role:r,exp:o}=n;if(o<Date.now()/1e3)return e.role=void 0,void e.removeToken();e.role!==r&&(e.role=r)}}))).actions((e=>{const t=e.getFetcher;return{getFetcher(n){const r=t(n);return async(t,n)=>{const o=await r(t,n);return 403===o.status?(e.removeToken(),e.setRole(),r(t,n)):o}}}})).actions((e=>({removeToken(){sessionStorage.removeItem(e.tokenKey),e.tokenPromise=void 0}}))).actions((e=>({async getToken(t){if(e.tokenPromise)return e.tokenPromise;let n=t?.internetAccountPreAuthorization?.authInfo?.token;if(n)return e.tokenPromise=Promise.resolve(n),e.tokenPromise;if(Ac)throw new Error("Did not get internet account pre-authorization info in worker");return n=e.retrieveToken(),n?(e.tokenPromise=Promise.resolve(n),e.tokenPromise):(e.tokenPromise=new Promise(((t,n)=>{e.getTokenFromUser((n=>{e.storeToken(n),t(n)}),(t=>{e.removeToken(),n(t)}))})),e.tokenPromise)}}))).actions((e=>{let t;return{addMessageChannel(e,n){t=t=>{this.finishOAuthWindow(t,e,n)},window.addEventListener("message",t)},deleteMessageChannel(){window.removeEventListener("message",t)},finishOAuthWindow(t,n,r){if(t.data.name!==`JBrowseAuthWindow-${e.internetAccountId}`)return;const o=t.data.redirectUri.replace("#","?"),i=new URL(o),a=new URLSearchParams(i.search).get("access_token");this.deleteMessageChannel(),a?(e.storeToken(a),e.setRole(),n(a)):r(new Error("Error with token endpoint"))},async openAuthWindow(t,n,r){const i=o.isElectron?"http://localhost/auth":globalThis.location.origin+globalThis.location.pathname,a=new URL("auth/login",e.baseURL),s=new URLSearchParams({type:t,redirect_uri:i});a.search=s.toString();const l=`JBrowseAuthWindow-${e.internetAccountId}`;if(o.isElectron){const{ipcRenderer:t}=globalThis.require("electron"),o=await t.invoke("openAuthWindow",{internetAccountId:e.internetAccountId,data:{redirect_uri:i},url:a.toString()}),s=new MessageEvent("message",{data:{name:l,redirectUri:o}});this.finishOAuthWindow(s,n,r)}else this.addMessageChannel(n,r),window.open(a,l,"width=500,height=600")}}})).actions((e=>({async getTokenFromUser(t,n){const{baseURL:r}=e,o=await new Promise(((t,n)=>{const{session:r}=l.getRoot(e),{baseURL:o,name:i}=e;r.queueDialog((e=>[Cc,{name:i,handleClose:r=>{r?r instanceof Error?n(r):t(r):n(new Error("user cancelled entry")),e()},baseURL:o}]))}));if(o.needsPopup)return void e.openAuthWindow(o.name,t,n);const i=new URL("auth/login",r),a=new URLSearchParams({type:o.name});i.search=a.toString();const s=i.toString(),c=await fetch(s,{signal:e.controller.signal});if(!c.ok){const e=await dl(c,"Error when logging in");return void n(new Error(e))}const{token:u}=await c.json();t(u)}}))).volatile((()=>({lastChangeSequenceNumber:void 0}))).actions((e=>({setLastChangeSequenceNumber(t){e.lastChangeSequenceNumber=t}}))).actions((e=>({updateLastChangeSequenceNumber:l.flow((function*(){const{baseURL:t}=e,n=new URL("changes",t),r=new URLSearchParams({limit:"1"});n.search=r.toString();const o=n.toString(),i=e.getFetcher({locationType:"UriLocation",uri:o});let a;try{a=yield i(o,{method:"GET",signal:e.controller.signal})}catch(t){return void(e.controller.signal.aborted||console.error(t))}if(!a.ok){const e=yield dl(a,"Error when fetching server LastChangeSequence");throw new Error(e)}const{changes:s}=yield a.json();e.setLastChangeSequenceNumber(s.length>0?s[0].sequence:0)})),getMissingChanges:l.flow((function*(){const{session:t}=l.getRoot(e),{changeManager:n}=t.apolloDataStore;if(!e.lastChangeSequenceNumber)throw new Error("No LastChangeSequence stored in session. Please, refresh you browser to get last updates from server");const{baseURL:r,lastChangeSequenceNumber:o}=e,i=new URL("changes",r),a=new URLSearchParams({since:String(o),sort:"1"});i.search=a.toString();const s=i.toString(),c=e.getFetcher({locationType:"UriLocation",uri:s});let u;try{u=yield c(s,{method:"GET",signal:e.controller.signal})}catch(t){return void(e.controller.signal.aborted||console.error(t))}if(!u.ok)return void console.error(`Error when fetching the last updates to recover socket connection — ${u.status}`);const{changes:d}=yield u.json();for(const e of d){const t=ee.fromJSON(e);n.submit(t,{submitToBackend:!1})}}))}))).volatile((e=>{const{origin:t,pathname:n}=new URL("socket.io/",e.baseURL);return{socket:so(t,{path:n})}})).actions((e=>({addSocketListeners(){const{session:t}=l.getRoot(e),{notify:n}=t,r=e.retrieveToken();if(!r)throw new Error("No Token found");const o=sn(ln(r)),{socket:i}=e,{addCheckResult:a,changeManager:s,deleteCheckResult:c}=t.apolloDataStore;i.on("connect",(()=>{e.getMissingChanges()})),i.on("connect_error",(e=>{console.error(e),n("Could not connect to the Apollo server.","error")})),i.on("COMMON",(e=>{if("checkResult"in e)return void(e.deleted?c(e.checkResult._id):a(e.checkResult));if(sessionStorage.setItem("LastChangeSequence",String(e.changeSequence)),e.userSessionId===o)return;const t=ee.fromJSON(e.changeInfo);s.submit(t,{submitToBackend:!1})})),i.on("USER_LOCATION",(e=>{const{channel:n,locations:r,userName:i,userSessionId:a}=e;"USER_LOCATION"===n&&a!==o&&t.addOrUpdateCollaborator({name:i,id:a,locations:r})})),i.on("REQUEST_INFORMATION",(e=>{const{channel:n,userSessionId:o}=e;"REQUEST_INFORMATION"===n&&o!==r&&t.broadcastLocations()}))}}))).actions((e=>({postUserLocation:(t=>{let n;return t=>{clearTimeout(n),n=setTimeout((()=>{!async function(t){if(!l.isAlive(e)||"none"===e.role)return;const{baseURL:n,controller:r}=e,o=new URL("users/userLocation",n).href,i=new URLSearchParams(JSON.stringify(t)),a=e.getFetcher({locationType:"UriLocation",uri:o});try{if(!(await a(o,{method:"POST",body:i,signal:r.signal})).ok)throw new Error("ignore")}catch{console.error("Broadcasting user location failed")}}(t)}),300)}})()}))).volatile((()=>({roleNotificationSent:!1}))).actions((e=>{function t(){e.postUserLocation([])}function n(){if("hidden"===document.visibilityState&&e.postUserLocation([]),"visible"===document.visibilityState){const{session:t}=l.getRoot(e);t.broadcastLocations()}}return{initialize:l.flow((function*(r){if("none"===r){if(!e.roleNotificationSent){const{session:t}=l.getRoot(e);t.notify("You have registered as an Apollo user but have not been given access. Ask your administrator to enable access for your account.","warning"),e.roleNotificationSent=!0}return}if("admin"===r){const t=l.getRoot(e);o.isAbstractMenuManager(t)&&function(e){e.appendToMenu("Apollo",{label:"Admin",type:"subMenu",icon:lo,subMenu:[{label:"Add Assembly",icon:Ln,onClick:e=>{e.queueDialog((t=>[gl,{session:e,handleClose:()=>{t()},changeManager:e.apolloDataStore.changeManager}]))}},{label:"Delete Assembly",icon:co,onClick:e=>{e.queueDialog((t=>[El,{session:e,handleClose:()=>{t()},changeManager:e.apolloDataStore.changeManager}]))}},{label:"Import Features",icon:uo,onClick:e=>{e.queueDialog((t=>[Jl,{session:e,handleClose:()=>{t()},changeManager:e.apolloDataStore.changeManager}]))}},{label:"Add reference sequence aliases",onClick:e=>{e.queueDialog((t=>[lc,{session:e,handleClose:()=>{t()},changeManager:e.apolloDataStore.changeManager}]))}},{label:"Add Assembly aliases",onClick:e=>{e.queueDialog((t=>[yl,{session:e,handleClose:()=>{t()},changeManager:e.apolloDataStore.changeManager}]))}},{label:"Manage Users",icon:fo,onClick:e=>{e.queueDialog((t=>[Zl,{session:e,handleClose:()=>{t()},changeManager:e.apolloDataStore.changeManager}]))}},{label:"Manage Checks",icon:ho,onClick:e=>{e.queueDialog((t=>[Yl,{session:e,handleClose:()=>{t()}}]))}}]})}(t)}yield e.updateLastChangeSequenceNumber(),e.addSocketListeners();const{baseURL:i}=e,a=new URL("users/locations",i).href,s=e.getFetcher({locationType:"UriLocation",uri:a});yield s(a,{method:"GET",signal:e.controller.signal}),window.addEventListener("beforeunload",t),document.addEventListener("visibilitychange",n)})),removeBeforeUnloadListener(){window.removeEventListener("beforeunload",t)},removeVisibilityChangeListener(){document.removeEventListener("visibilitychange",n)}}})).actions((e=>({afterAttach(){e.setRole(),c.autorun((async t=>{if(Ac)return;const{session:n}=l.getRoot(e);if(n&&e.role)try{await e.initialize(e.role),t.dispose()}catch{}}),{name:"ApolloInternetAccount"})},beforeDestroy(){e.removeBeforeUnloadListener(),e.removeVisibilityChangeListener(),e.controller.abort(new DOMException("Cleaning up Apollo connection","AbortError")),e.socket.close()}})));var Nc=function(){return crypto.getRandomValues(new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:21)).reduce((function(e,t){return e+((t&=63)<36?t.toString(36):t<62?(t-26).toString(36).toUpperCase():t>62?"-":"_")}),"")};const Tc="undefined"==typeof sessionStorage;class Rc extends _.BaseAdapter{refNameAliasesP;async getRefNameAliases(){if(this.refNameAliasesP)return this.refNameAliasesP;const e=n.readConfObject(this.config,"assemblyId");if(!Tc){const t=this.pluginManager?.rootModel?.session?.apolloDataStore;if(!t)throw new Error("No Apollo data store found");const n=t.getBackendDriver(e);if(!n)throw new Error("No backend driver found");return await n.getRefNameAliases(e)}const t=new Promise(((t,n)=>{const r=setTimeout((()=>{n(new Error("timeout"))}),2e4),o=Nc(),i=e=>{const n=e.data;(function(e){return"object"==typeof e&&null!==e&&"apollo"in e&&!0===e.apollo&&"refNameAliases"in e})(n)&&n.messageId===o&&(clearTimeout(r),removeEventListener("message",i),t(n.refNameAliases))};addEventListener("message",i),rpcServer.emit("apollo",{apollo:!0,method:"getRefNameAliases",assembly:e,messageId:o})}));return this.refNameAliasesP=t,t}freeResources(){}}var Ec=n.ConfigurationSchema("ApolloRefNameAliasAdapter",{assemblyId:{type:"string",defaultValue:""}},{explicitlyTyped:!0});function Ic(e){return"uniqueId"in e&&"object"!==K(e.data)}var jc=function(){function e(t){var n=this;R(this,e),D(this,"data",void 0),D(this,"subfeatures",void 0),D(this,"parentHandle",void 0),D(this,"uniqueId",void 0),Ic(t)?this.data=t:(this.data=t.data,this.parentHandle=t.parent);var r,o=Ic(t)?t.uniqueId:t.id;if(null==o)throw new Error("SimpleFeature requires a unique `id` or `data.uniqueId` attribute");if(this.uniqueId=String(o),!(this.data.aliases||this.data.end-this.data.start>=0))throw new Error("invalid feature data, end less than start. end: ".concat(this.data.end," start: ").concat(this.data.start));this.data.subfeatures&&(this.subfeatures=null===(r=this.data.subfeatures)||void 0===r?void 0:r.map((function(t,r){return"function"!=typeof t.get?new e({id:t.uniqueId||"".concat(o,"-").concat(r),data:B({strand:n.data.strand},t),parent:n}):t})))}return I(e,[{key:"get",value:function(e){return"subfeatures"===e?this.subfeatures:"parent"===e?this.parent():this.data[e]}},{key:"set",value:function(e,t){this.data[e]=t}},{key:"tags",value:function(){return Object.keys(this.data)}},{key:"id",value:function(){return this.uniqueId}},{key:"parent",value:function(){return this.parentHandle}},{key:"children",value:function(){return this.get("subfeatures")}},{key:"toJSON",value:function(){var e=B(B({},this.data),{},{uniqueId:this.id()}),t=this.parent();t&&(e.parentId=t.id());var n=this.children();return n&&(e.subfeatures=n.map((function(e){return e.toJSON()}))),e}}],[{key:"fromJSON",value:function(t){return new e(B({},t))}}])}();function Dc(e){return"object"==typeof e&&null!==e&&"apollo"in e&&!0===e.apollo}const Oc="undefined"==typeof sessionStorage;class Fc extends _.BaseSequenceAdapter{regions;async getRefNames(){return(await this.getRegions()).map((e=>e.refName))}async getRegions(){if(this.regions)return this.regions;const e=n.readConfObject(this.config,"assemblyId");if(!Oc){const t=this.pluginManager?.rootModel?.session?.apolloDataStore;if(!t)throw new Error("No Apollo data store found");const n=t.getBackendDriver(e);if(!n)throw new Error("No backend driver found");const r=await n.getRegions(e);return this.regions=r,r}const t=await new Promise(((t,n)=>{const r=setTimeout((()=>{n("timeout")}),2e4),o=Nc(),i=e=>{const{data:n}=e;Dc(n)&&n.messageId===o&&(clearTimeout(r),removeEventListener("message",i),t(n.regions))};addEventListener("message",i),globalThis.rpcServer.emit("apollo",{apollo:!0,method:"getRegions",assembly:e,messageId:o})}));return this.regions=t,t}getFeatures(e){const{end:t,refName:r,start:o}=e,i=n.readConfObject(this.config,"assemblyId"),a={...e,assemblyName:i};return v.ObservableCreate((async e=>{if(!Oc){const n=this.pluginManager?.rootModel?.session?.apolloDataStore;if(!n)return void e.error("No Apollo data store found");const s=n.getBackendDriver(i);if(!s)return void e.error("No backend driver found");const l=(await s.getRegions(a.assemblyName)).find((e=>e.refName===a.refName));if(!l)return void e.error("Cannot get region");a.end>l.end&&(a.end=l.end);const{seq:c}=await s.getSequence(a);return e.next(new jc({id:`${r} ${o}-${t}`,data:{refName:r,start:o,end:t,seq:c}})),void e.complete()}const n=await new Promise(((e,t)=>{const n=setTimeout((()=>{t("timeout")}),2e4),r=Nc(),o=t=>{const{data:i}=t;Dc(i)&&i.messageId===r&&(clearTimeout(n),removeEventListener("message",o),e(i.sequence))};addEventListener("message",o),globalThis.rpcServer.emit("apollo",{apollo:!0,method:"getSequence",region:a,messageId:r})}));e.next(new jc({id:`${r} ${o}-${t}`,data:{refName:r,start:o,end:t,seq:n}})),e.complete()}))}freeResources(){}}var Mc=n.ConfigurationSchema("ApolloSequenceAdapter",{assemblyId:{type:"string",defaultValue:""}},{explicitlyTyped:!0}),Lc=function(){return I((function e(t){R(this,e),D(this,"label",void 0),D(this,"renderingComponent",void 0),D(this,"displayString",void 0),D(this,"matchedAttribute",void 0),D(this,"matchedObject",void 0),D(this,"textSearchAdapter",void 0),D(this,"relevance",void 0),D(this,"trackId",void 0),D(this,"score",void 0),D(this,"locString",void 0),D(this,"results",void 0),this.label=t.label,this.locString=t.locString,this.renderingComponent=t.renderingComponent,this.displayString=t.displayString,this.matchedAttribute=t.matchedAttribute,this.matchedObject=t.matchedObject,this.textSearchAdapter=t.textSearchAdapter,this.relevance=t.relevance,this.trackId=t.trackId,this.score=t.score||1,this.results=t.results||[]}),[{key:"getLabel",value:function(){return this.label}},{key:"getDisplayString",value:function(){return this.displayString||this.label}},{key:"getRenderingComponent",value:function(){return this.renderingComponent}},{key:"getTrackId",value:function(){return this.trackId}},{key:"getScore",value:function(){return this.score}},{key:"updateScore",value:function(e){return this.score=e,this.score}},{key:"getId",value:function(){return"".concat(this.getLabel(),"-").concat(this.getLocation(),"-").concat(this.getTrackId())}},{key:"hasLocation",value:function(){return!!this.locString}},{key:"getLocation",value:function(){return this.locString}},{key:"getComboResults",value:function(){return this.results}}])}();function Pc(e,t){const{children:n,indexedIds:r,allIds:o,...i}=t;if(JSON.stringify(i).includes(e))return t;if(n)for(const t of Object.values(n)){const n=Pc(e,t);if(n)return n}}class Bc extends _.BaseAdapter{get baseURL(){return n.readConfObject(this.config,"baseURL").uri}get trackId(){return n.readConfObject(this.config,"trackId")}get assemblyNames(){return n.readConfObject(this.config,"assemblyNames")}mapBaseResult(e,t,n){return e.map((e=>{const r=Pc(n,e)??e,o=t.getCanonicalRefName(e.refSeq);return new Lc({label:n,trackId:this.trackId,locString:`${o}:${r.min+1}..${r.max}`,matchedObject:r})}))}async searchIndex(e){const t=e.queryString,n=[],r=this.pluginManager?.rootModel?.session;if(!r)return n;const{apolloDataStore:o}=r,{assemblyManager:i}=r;for(const r of this.assemblyNames){const a=o.getBackendDriver(r),s=i.get(r);if(!a||!s)continue;const l=await a.searchFeatures(e.queryString,[r]);n.push(...this.mapBaseResult(l,s,t))}return n}freeResources(){}}var qc=n.ConfigurationSchema("ApolloTextSearchAdapter",{assemblyNames:{type:"stringArray",defaultValue:[],description:"List of assemblies covered by text search adapter"},trackId:{type:"string",defaultValue:""},baseURL:{type:"fileLocation",defaultValue:{uri:"",locationType:"UriLocation"}}},{explicitlyTyped:!0,explicitIdentifier:"textSearchAdapterId"}),Uc=a.createSvgIcon(i.jsx("path",{d:"M16.59 8.59 12 13.17 7.41 8.59 6 10l6 6 6-6z"}),"ExpandMore"),zc=a.createSvgIcon(i.jsx("path",{d:"M3 17.25V21h3.75L17.81 9.94l-3.75-3.75zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34a.996.996 0 0 0-1.41 0l-1.83 1.83 3.75 3.75z"}),"Edit"),$c=a.createSvgIcon(i.jsx("path",{d:"M6 10c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m12 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m-6 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2"}),"MoreHoriz");const Hc=ma()((e=>({attributeKey:{fontWeight:"bold",marginRight:e.spacing(2)}})));function Gc({attributeKey:e}){const{classes:t}=Hc(),n=/^[A-Z]/.test(e);let r,o=e;return e in Dn?(o=Dn[e],r=`On GFF3 export, this will be assigned to the GFF3's reserved "${o}" attribute`):function(e){return e in On}(e)?(o=On[e],r=`On GFF3 export, this will be placed in the GFF3's "${o}" column`):n&&(r="On GFF3 export, this attribute will be changed to start with a lower-case letter because attributes starting with an upper-case letter are reserved in GFF3"),i.jsxs("div",{style:{display:"flex"},children:[i.jsx(s.Typography,{className:t.attributeKey,children:o}),r?i.jsx(s.Tooltip,{title:r,children:i.jsx(s.Chip,{icon:i.jsx(ya,{}),label:"GFF3",size:"small",variant:"outlined"})}):null]})}const Vc="Custom",Wc={[Vc]:"custom"};for(const[e,t]of Object.entries(jn))Wc[`GFF ${t}`]=e;for(const[e,t]of Object.entries({score:"gff_score",source:"gff_source"}))Wc[`GFF ${t}`]=e;const Jc=p.observer((function({setKey:e,session:t}){const{pluginManager:n}=o.getEnv(t),r=n.evaluateExtensionPoint("Apollo-ReservedAttributeKeys",Wc),a=Object.keys(r).at(0)??Vc,[l,c]=u.useState(a),[d,f]=u.useState(),h=l===Vc;return i.jsxs("form",{onSubmit:function(t){t.preventDefault(),e(h?d:r[l])},children:[i.jsxs("div",{style:{display:"flex",flexDirection:"column",margin:8},children:[i.jsxs(s.FormControl,{variant:"outlined",children:[i.jsx(s.InputLabel,{id:"attribute-key-select-label",children:"Key"}),i.jsx(s.Select,{labelId:"attribute-key-select-label",value:l,label:"Key",onChange:e=>{c(e.target.value)},children:Object.keys(r).map((e=>i.jsx(s.MenuItem,{value:e,children:e},e)))})]}),h?i.jsx(s.TextField,{label:"Attribute key",variant:"outlined",id:"attributeKey",onChange:e=>{f(e.target.value)}}):null]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{color:"primary",variant:"contained",type:"submit",disabled:h&&!d,children:"Add"}),i.jsx(s.Button,{variant:"outlined",onClick:function(){e()},children:"Cancel"})]})]})}));var Kc=a.createSvgIcon(i.jsx("path",{d:"M19 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2m-2 10h-4v4h-2v-4H7v-2h4V7h2v4h4z"}),"AddBox");const Yc=p.observer((function({onChangeCommitted:e,value:t,...n}){const[r,o]=u.useState(String(t)),[a,l]=u.useState(!1),[c,d]=u.useState(null);return u.useEffect((()=>{o(String(t))}),[t]),u.useEffect((()=>{a&&(c?.blur(),l(!1))}),[a,c]),i.jsx(s.TextField,{...n,type:"text",onChange:function(e){o(e.target.value)},value:r,onKeyDown:e=>{"Enter"===e.key?c?.blur():"Escape"===e.key&&(o(String(t)),l(!0))},onBlur:()=>{r!==String(t)&&e(r)},inputRef:e=>{d(e)}})})),Xc=p.observer((function({attributeValues:e,setAttribute:t,isNew:n=!1}){const[r,o]=u.useState(e&&e.length>0?e:[""]);return i.jsxs(i.Fragment,{children:[r.map(((e,t)=>i.jsxs("div",{style:{display:"flex"},children:[i.jsx(Yc,{value:e,onChangeCommitted:e=>{!function(e,t){o((n=>{const r=[...n];return r[e]=t,r}))}(t,e)},variant:"outlined",fullWidth:!0}),i.jsx(s.IconButton,{"aria-label":"delete",size:"medium",edge:"end",onClick:()=>{!function(e){o((t=>{const n=[...t];return n.splice(e,1),n}))}(t)},children:i.jsx(co,{fontSize:"inherit"})})]},`${t}-${e}`))),i.jsx(s.IconButton,{"aria-label":"add",size:"medium",color:"secondary",edge:"start",onClick:function(){o((e=>{const t=[...e];return t.push(""),t}))},children:i.jsx(Kc,{fontSize:"inherit"})}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{color:"primary",variant:"contained",onClick:()=>{t(r.filter(Boolean))},children:n?"Add":"Update"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:()=>{t()},children:"Cancel"})]})]})}));function Zc({values:e}){return i.jsx(i.Fragment,{children:e?.map(((e,t)=>i.jsx(s.Typography,{variant:"body2",color:"textSecondary",children:e},`${t}.${e}`)))})}const Qc=ma()((e=>({list:{"li:nth-of-type(odd)":{backgroundColor:e.palette.action.focus},"li:nth-of-type(even)":{backgroundColor:e.palette.action.hover}}}))),eu=p.observer((function({assembly:e,editable:t,feature:n,session:r}){const{pluginManager:a}=o.getEnv(r),{classes:d}=Qc(),[f,h]=u.useState(null),[p,g]=u.useState(null),[m,y]=u.useState(null),[_,v]=u.useState(!1),[b,x]=u.useState(),w=Boolean(f),{changeManager:S}=r.apolloDataStore,{notify:C}=r;function A(){h(null),g(null)}const{_id:k,attributes:N}=n,T=a.evaluateExtensionPoint("Apollo-AttributeEditorComponent",Xc,{key:b});return i.jsxs(i.Fragment,{children:[i.jsxs(s.List,{className:d.list,children:[c.entries(N).map((([o,c])=>{const u=a.evaluateExtensionPoint("Apollo-AttributeEditorComponent",Xc,{key:o}),d=a.evaluateExtensionPoint("Apollo-AttributeViewerComponent",Zc,{key:o});return i.jsx(s.ListItem,{secondaryAction:t&&!m?i.jsx(s.IconButton,{edge:"end",onClick:e=>{!function(e,t){h(e.currentTarget),g(t)}(e,o)},children:i.jsx($c,{})}):null,children:i.jsx(s.ListItemText,{disableTypography:!0,primary:i.jsx(Gc,{attributeKey:o}),secondary:m===o?i.jsx(u,{session:r,attributeValues:c,setAttribute:t=>{y(null),t&&function(t,r){const o={...l.getSnapshot(N)},i=structuredClone(o);if(!(t in o))return void C(`"${t}" not found in feature attributes`,"error");if(o[t].toString()===r.toString())return;o[t]=r;const a=new St({changedIds:[n._id],typeName:"FeatureAttributeChange",assembly:e,featureId:n._id,oldAttributes:i,newAttributes:o});S.submit(a)}(o,t)}}):i.jsx(d,{values:c})})},o)})),b?i.jsx(s.ListItem,{children:i.jsx(s.ListItemText,{disableTypography:!0,primary:i.jsx(Gc,{attributeKey:b}),secondary:i.jsx(T,{session:r,attributeValues:[],setAttribute:t=>{t&&function(t,r){const o={...l.getSnapshot(N)},i=structuredClone(o);if(t in o)return void C(`Feature already has attribute "${t}"`,"error");o[t]=r;const a=new St({changedIds:[n._id],typeName:"FeatureAttributeChange",assembly:e,featureId:n._id,oldAttributes:i,newAttributes:o});S.submit(a)}(b,t),x(void 0)},isNew:!0})})}):null]}),t?i.jsx(s.Button,{color:"primary",variant:"contained",disabled:_||Boolean(b),onClick:()=>{v(!0)},children:"Add new"}):null,_?i.jsx(s.Paper,{variant:"outlined",style:{marginTop:8},children:i.jsx(Jc,{session:r,setKey:e=>{x(e),v(!1)}})}):null,i.jsxs(s.Menu,{anchorEl:f,open:w,onClose:A,children:[i.jsxs(s.MenuItem,{onClick:function(){p&&function(t){const n=l.getSnapshot(N),{[t]:r,...o}=n,i=new St({changedIds:[k],typeName:"FeatureAttributeChange",assembly:e,featureId:k,oldAttributes:n,newAttributes:o});S.submit(i)}(p),A()},children:[i.jsx(s.ListItemIcon,{children:i.jsx(co,{fontSize:"small"})}),i.jsx(s.Typography,{variant:"inherit",children:"Delete"})]}),i.jsxs(s.MenuItem,{onClick:function(){p&&y(p),A()},children:[i.jsx(s.ListItemIcon,{children:i.jsx(zc,{fontSize:"small"})}),i.jsx(s.Typography,{variant:"inherit",children:"Edit"})]})]})]})})),tu=p.observer((function({onChangeCommitted:e,value:t,...n}){const[r,o]=u.useState(String(t)),[a,l]=u.useState(!1),[c,d]=u.useState(null);u.useEffect((()=>{o(String(t))}),[t]),u.useEffect((()=>{a&&(c?.blur(),l(!1))}),[a,c]);const f=Number.isNaN(Number(r));return i.jsx(s.TextField,{...n,type:"text",onChange:function(e){o(e.target.value)},value:r,onKeyDown:e=>{"Enter"===e.key?c?.blur():"Escape"===e.key&&(o(String(t)),l(!0))},onBlur:()=>{const n=Number(r);r!==String(t)&&(Number.isNaN(n)?o(String(t)):e(n)||o(String(t)))},inputRef:e=>{d(e)},error:f,helperText:f?"Not a valid number":void 0})})),nu=p.observer((function({assembly:e,feature:t,session:n}){const[r,o]=u.useState(""),[a,l]=u.useState(""),{_id:c,assemblyId:d,max:f,min:h,strand:p,type:g}=t,m=e=>{n.notify(e.message,"error")},{changeManager:y}=n.apolloDataStore;function _(t){const{value:n}=t.target,r=n?Number(n):void 0,o=new zt({typeName:"StrandChange",changedIds:[c],featureId:c,oldStrand:p,newStrand:r,assembly:e});return y.submit(o)}return i.jsxs("div",{"data-testid":"basic_information",children:[i.jsx(tu,{margin:"dense",id:"start",label:"Start",fullWidth:!0,variant:"outlined",value:h+1,onChangeCommitted:function(t){t--;const n=new Et({typeName:"LocationStartChange",changedIds:[c],featureId:c,oldStart:h,newStart:t,assembly:e});return y.submit(n),!0}}),i.jsx(tu,{margin:"dense",id:"end",label:"End",fullWidth:!0,variant:"outlined",value:f,onChangeCommitted:function(t){const n=new Tt({typeName:"LocationEndChange",changedIds:[c],featureId:c,oldEnd:f,newEnd:t,assembly:e});return y.submit(n),!0}}),i.jsx(qs,{session:n,ontologyName:"Sequence Ontology",value:g,filterTerms:Cs,fetchValidTerms:async function(e,t,n){const r=await Ms(e,t);if(r)return r;l(`Type "${e?.type}" does not have any children in the ontology`)}.bind(null,t),renderInput:e=>i.jsx(s.TextField,{...e,label:"Type",variant:"outlined",fullWidth:!0,error:Boolean(a),helperText:a}),onChange:(e,t)=>{t&&function(e){o("");const t=new $t({typeName:"TypeChange",changedIds:[c],featureId:c,oldType:g,newType:e,assembly:d});return y.submit(t)}(t).catch(m)}}),i.jsxs("label",{children:[i.jsx("input",{type:"radio",value:"1",checked:1===p,onChange:_}),"Positive Strand (+)"]}),i.jsxs("label",{children:[i.jsx("input",{type:"radio",value:"-1",checked:-1===p,onChange:_}),"Negative Strand (-)"]}),i.jsxs("label",{children:[i.jsx("input",{type:"radio",value:"",checked:void 0===p,onChange:_}),"No Strand Information"]}),r?i.jsx(s.Typography,{color:"error",children:r}):null]})})),ru=p.observer((function(e){const{feature:t,model:n}=e,{children:r,parent:o}=t,a=[];if(r)for(const[,e]of r)a.push(e);return o??a.length>0?i.jsxs("div",{style:{marginTop:10},children:[o&&i.jsxs("div",{children:[i.jsx(s.Typography,{variant:"h6",children:"Parent:"}),i.jsxs(s.Button,{variant:"contained",onClick:()=>{n.setFeature(o)},children:[o.type,Sa(o)," (",o.min,"..",o.max,")"]})]}),a.length>0&&i.jsxs("div",{children:[i.jsxs(s.Typography,{variant:"h6",children:[1===a.length?"Child":"Children",":"]}),a.map((e=>i.jsx("div",{style:{marginBottom:5},children:i.jsxs(s.Button,{variant:"contained",onClick:()=>{n.setFeature(e)},children:[e.type,Sa(e)," (",e.min,"..",e.max,")"]})},e._id)))]})]}):null})),ou=ma()({sequence:{width:"100%",resize:"vertical"}}),iu=p.observer((function({assembly:e,feature:t,refName:n,session:r}){const o=r.apolloDataStore.assemblies.get(e),{classes:a}=ou();if(!t||!o)return null;const s=o.getByRefName(n);if(!s)return null;const{max:l,min:c}=t;let u=s.getSequence(c,l);return u?u=function(e,t,n,r,o){return`>${t}:${n+1}–${r}\n${e}`}(u,n,c,l):r.apolloDataStore.loadRefSeq([{assemblyName:e,refName:n,start:c,end:l}]),i.jsx("div",{children:i.jsx("textarea",{readOnly:!0,rows:20,className:a.sequence,value:u})})})),au=ma()((e=>({root:{padding:e.spacing(2)}}))),su=p.observer((function(e){const{model:t}=e,{assembly:n,feature:r,refName:a}=t,l=o.getSession(t),c=l.apolloDataStore.assemblies.get(n),{classes:d}=au(),[f,h]=u.useState(["attributes"]);if(u.useEffect((()=>{h(["attributes"])}),[r]),!r||!c)return null;const p=c.getByRefName(a);if(!p)return null;const{max:g,min:m}=r;function y(e,t){h(e?[...f,t]:f.filter((e=>e!==t)))}return p.getSequence(m,g)||l.apolloDataStore.loadRefSeq([{assemblyName:n,refName:a,start:m,end:g}]),i.jsxs("div",{className:d.root,children:[i.jsx(nu,{feature:r,session:l,assembly:c._id}),i.jsxs(s.Accordion,{style:{marginTop:10},expanded:f.includes("attributes"),onChange:(e,t)=>{y(t,"attributes")},children:[i.jsx(s.AccordionSummary,{expandIcon:i.jsx(Uc,{style:{color:"white"}}),"aria-controls":"panel1-content",id:"panel1-header",children:i.jsx(s.Typography,{component:"span",children:"Attributes"})}),i.jsx(s.AccordionDetails,{children:i.jsx(eu,{feature:r,session:l,assembly:c._id,editable:!0})})]}),i.jsxs(s.Accordion,{style:{marginTop:10},expanded:f.includes("sequence"),onChange:(e,t)=>{y(t,"sequence")},children:[i.jsx(s.AccordionSummary,{expandIcon:i.jsx(Uc,{style:{color:"white"}}),"aria-controls":"panel2-content",id:"panel2-header",children:i.jsx(s.Typography,{component:"span",children:"Sequence"})}),i.jsx(s.AccordionDetails,{children:f.includes("sequence")&&i.jsx(iu,{feature:r,session:l,assembly:c._id,refName:a})})]}),i.jsxs(s.Accordion,{style:{marginTop:10},expanded:f.includes("related_features"),onChange:(e,t)=>{y(t,"related_features")},children:[i.jsx(s.AccordionSummary,{expandIcon:i.jsx(Uc,{style:{color:"white"}}),"aria-controls":"panel3-content",id:"panel3-header",children:i.jsx(s.Typography,{component:"span",children:"Related features"})}),i.jsx(s.AccordionDetails,{children:i.jsx(ru,{model:t,feature:r})})]})]})}));var lu=l.types.late((function(){return cu})),cu=l.types.model("AnnotationFeatureModel",{_id:l.types.identifier,refSeq:l.types.string,type:l.types.string,min:l.types.number,max:l.types.number,strand:l.types.maybe(l.types.union(l.types.literal(1),l.types.literal(-1))),children:l.types.maybe(l.types.map(lu)),attributes:l.types.map(l.types.array(l.types.string))}).views((function(e){return{get length(){return e.max-e.min},get featureId(){return e.attributes.get("id")},get minWithChildren(){var t=e.min,n=e.children;if(!n)return t;var r,o=j(n);try{for(o.s();!(r=o.n()).done;){var i=G(r.value,2);t=Math.min(t,i[1].min)}}catch(e){o.e(e)}finally{o.f()}return t},get maxWithChildren(){var t=e.max,n=e.children;if(!n)return t;var r,o=j(n);try{for(o.s();!(r=o.n()).done;){var i=G(r.value,2);t=Math.max(t,i[1].max)}}catch(e){o.e(e)}finally{o.f()}return t},hasDescendant:function(t){var n=e.children;if(!n)return!1;var r,o=j(n);try{for(o.s();!(r=o.n()).done;){var i=G(r.value,2);if(i[0]===t)return!0;if(i[1].hasDescendant(t))return!0}}catch(e){o.e(e)}finally{o.f()}return!1},get transcriptExonParts(){var t=o.getSession(e).apolloDataStore.ontologyManager.featureTypeOntology;if(!t.isTypeOf(e.type,"transcript")&&!t.isTypeOf(e.type,"pseudogenic_transcript"))throw new Error("Feature is not a transcript or equivalent, cannot calculate exon locations");var n=e.children;if(!n)throw new Error("No exons in transcript");var r,i=W(n.values()).filter((function(e){return t.isTypeOf(e.type,"exon")})).sort((function(e,t){return e.min-t.min})),a=e.min,s=[],l=j(i);try{for(l.s();!(r=l.n()).done;){var c=r.value;c.min>a&&s.push({min:a,max:c.min,type:"intron"}),s.push({min:c.min,max:c.max,type:"exon"}),a=c.max}}catch(e){l.e(e)}finally{l.f()}return a<e.max&&s.push({min:a,max:e.max,type:"intron"}),-1===e.strand&&s.reverse(),s},get transcriptParts(){var t=o.getSession(e).apolloDataStore.ontologyManager.featureTypeOntology;if(!t.isTypeOf(e.type,"transcript")&&!t.isTypeOf(e.type,"pseudogenic_transcript"))throw new Error('Only features of type "transcript" or equivalent can calculate CDS locations');var n=e.children;if(!n)throw new Error("no CDS or exons in transcript");var r=W(n.values()).filter((function(e){return t.isTypeOf(e.type,"CDS")})),i=[];if(0===r.length)return i.push(this.transcriptExonParts),i;var a,s=j(r);try{var l=function(){var r,s=a.value,l=s.max,c=s.min,u=[],d=!1,f=[],h=j(n);try{for(h.s();!(r=h.n()).done;){var p=G(r.value,2)[1];t.isTypeOf(p.type,"exon")&&f.push({min:p.min,max:p.max})}}catch(e){h.e(e)}finally{h.f()}f.sort((function(e,t){return e.min-t.min}));for(var g=0,m=f;g<m.length;g++){var y=m[g],_=u.at(-1);_&&u.push({min:_.max,max:y.min,type:"intron"});var v,b=G(o.intersection2(c,l,y.min,y.max),2),x=b[0],w=b[1];v=d?1===e.strand?"threePrimeUTR":"fivePrimeUTR":1===e.strand?"fivePrimeUTR":"threePrimeUTR",void 0!==x&&void 0!==w?(d=!0,x===y.min&&w===y.max?u.push({min:x,max:w,phase:0,type:"CDS"}):x===y.min?u.push({min:x,max:w,phase:0,type:"CDS"},{min:w,max:y.max,type:v}):w===y.max?u.push({min:y.min,max:x,type:v},{min:x,max:w,phase:0,type:"CDS"}):u.push({min:y.min,max:x,type:v},{min:x,max:w,phase:0,type:"CDS"},{min:w,max:y.max,type:"fivePrimeUTR"===v?"threePrimeUTR":"fivePrimeUTR"})):u.push({min:y.min,max:y.max,type:v})}u.sort((function(e,t){return e.min-t.min})),-1===e.strand&&u.reverse();var S=0,C=u.map((function(e){if("CDS"!==e.type)return e;var t=S;return S=(3-(e.max-e.min-t+3)%3)%3,B(B({},e),{},{phase:t})}));i.push(C)};for(s.s();!(a=s.n()).done;)l()}catch(e){s.e(e)}finally{s.f()}return i}}})).views((function(e){return{get cdsLocations(){return e.transcriptParts.map((function(e){return e.filter((function(e){return"CDS"===e.type}))}))}}})).actions((function(e){return{setAttributes:function(t){e.attributes.clear();var n,r=j(t.entries());try{for(r.s();!(n=r.n()).done;){var o=G(n.value,2);e.attributes.set(o[0],o[1])}}catch(e){r.e(e)}finally{r.f()}},setAttribute:function(t,n){e.attributes.merge(D({},t,n))},setType:function(t){e.type=t},setRefSeq:function(t){e.refSeq=t},setMin:function(t){if(t>e.max)throw new Error('Min "'.concat(t+1,'" is greater than max "').concat(e.max,'"'));e.min!==t&&(e.min=t)},setMax:function(t){if(t<e.min)throw new Error('Max "'.concat(t,'" is less than Min "').concat(e.min,'"'));e.max!==t&&(e.max=t)},setStrand:function(t){e.strand=t},addChild:function(t){if(e.children&&e.children.size>0){var n=l.getSnapshot(e.children);e.children.clear();var r,o=j(Object.entries(B(B({},n),{},D({},t._id,t))).sort((function(e,t){var n=G(e,2)[1],r=G(t,2);return n.min-r[1].min})));try{for(o.s();!(r=o.n()).done;){var i=G(r.value,2);e.children.put(i[1])}}catch(e){o.e(e)}finally{o.f()}}else{var a;e.children=l.cast({}),null===(a=e.children)||void 0===a||a.put(t)}},deleteChild:function(t){var n;null===(n=e.children)||void 0===n||n.delete(t)}}})).actions((function(e){return{update:function(t){var n=t.children,r=t.max,o=t.min,i=t.strand;e.setRefSeq(t.refSeq),e.setMin(o),e.setMax(r),e.setStrand(i),n&&(e.children=l.cast(n))}}})).views((function(e){return{get parent(){var t;try{t=l.getParentOfType(e,cu)}catch(e){}return t},get topLevelFeature(){var t,n=e;do{try{n=t=l.getParentOfType(n,cu)}catch(e){t=void 0}}while(t);return n},get assemblyId(){for(var t=e;l.hasParent(t);)if("refSeqs"in(t=l.getParent(t))&&"_id"in t)return t._id;throw new Error("AnnotationFeatureModel: could not find parent ApolloAssembly")}}})),uu=l.types.model({start:l.types.number,stop:l.types.number,sequence:l.types.string}),du=l.types.model("ApolloRefSeq",{_id:l.types.identifier,name:l.types.string,description:"",features:l.types.map(cu),sequence:l.types.array(uu)}).actions((function(e){return{addFeature:function(t){e.features.put(t)},deleteFeature:function(t){return e.features.delete(t)},setDescription:function(t){e.description=t},addSequence:function(t){var n;if(t.sequence.length!==t.stop-t.start)throw new Error("sequence does not match declared length: ".concat(JSON.stringify(t)));if(0!==e.sequence.length){var r=e.sequence.map((function(e){return{start:e.start,stop:e.stop,sequence:e.sequence}}));r.push({start:t.start,stop:t.stop,sequence:t.sequence}),r.sort((function(e,t){return e.start===t.start?e.stop-t.stop:e.start-t.start}));var o,i=r.reduce((function(e,t){var n=e.at(-1);if(void 0===n)return[t];if(n.stop>=t.start){if(t.stop>n.stop){var r=n.stop-t.start;n.stop=t.stop,n.sequence+=t.sequence.slice(r)}}else e.push(t);return e}),[]),a=j(i);try{for(a.s();!(o=a.n()).done;){var s=o.value;if(s.sequence.length!==s.stop-s.start)throw new Error("Consolidated sequence does not match declared length")}}catch(e){a.e(e)}finally{a.f()}e.sequence.length===i.length&&e.sequence.every((function(e,t){var n;return e.start===(null===(n=i[t])||void 0===n?void 0:n.start)&&e.stop===i[t].stop}))||(e.sequence.clear(),(n=e.sequence).push.apply(n,W(i)))}else e.sequence.push(t)}}})).views((function(e){return{getSequence:function(t,n){var r,i=j(e.sequence);try{for(i.s();!(r=i.n()).done;){var a=r.value,s=a.sequence,l=a.start;if(o.isContainedWithin(t,n,l,a.stop))return s.slice(t-l,n-l)}}catch(e){i.e(e)}finally{i.f()}return""},getFeatures:function(t,n){var r,i=[],a=j(e.features);try{for(a.s();!(r=a.n()).done;){var s=G(r.value,2)[1];o.doesIntersect2(s.min,s.max,t,n)&&i.push(s)}}catch(e){a.e(e)}finally{a.f()}return i}}})),fu=l.types.model("ApolloAssembly",{_id:l.types.identifier,refSeqs:l.types.map(du),comments:l.types.array(l.types.string),backendDriverType:l.types.optional(l.types.enumeration("backendDriverType",["CollaborationServerDriver","LocalDriver"]),"CollaborationServerDriver")}).views((function(e){return{getByRefName:function(t){return W(e.refSeqs.values()).find((function(e){return e.name===t}))}}})).actions((function(e){return{addRefSeq:function(t,n,r){return e.refSeqs.put({_id:t,name:n,description:r})},addComment:function(t){return e.comments.push(t)}}})),hu=l.types.model("CheckResult",{_id:l.types.identifier,name:l.types.string,cause:l.types.string,ids:l.types.array(l.types.safeReference(cu)),refSeq:l.types.string,start:l.types.number,end:l.types.number,ignored:!1,message:l.types.string});const pu=l.types.model("ApolloFeatureDetailsWidget",{id:d.ElementId,type:l.types.literal("ApolloFeatureDetailsWidget"),feature:l.types.maybe(l.types.reference(cu,{onInvalidated(e){e.parent.setTryReload(e.invalidId),e.removeRef()}})),assembly:l.types.string,refName:l.types.string}).volatile((()=>({tryReload:void 0}))).actions((e=>({setFeature(t){e.feature=t},setTryReload(t){e.tryReload=t}}))).actions((e=>({afterAttach(){l.addDisposer(e,c.autorun((t=>{if(!e.tryReload)return;const n=o.getSession(e),{apolloDataStore:r}=n;if(!r)return;const i=r.getFeature(e.tryReload);i&&(e.setFeature(i),e.setTryReload(),t.dispose())})))}}))),gu=l.types.model("ApolloTranscriptDetails",{id:d.ElementId,type:l.types.literal("ApolloTranscriptDetails"),feature:l.types.maybe(l.types.reference(cu,{onInvalidated(e){e.parent.setTryReload(e.invalidId),e.removeRef()}})),assembly:l.types.string,refName:l.types.string}).volatile((()=>({tryReload:void 0}))).actions((e=>({setFeature(t){e.feature=t},setTryReload(t){e.tryReload=t}}))).actions((e=>({afterAttach(){l.addDisposer(e,c.autorun((t=>{if(!e.tryReload)return;const n=o.getSession(e),{apolloDataStore:r}=n;if(!r)return;const i=r.getFeature(e.tryReload);i&&(e.setFeature(i),e.setTryReload(),t.dispose())})))}})));var mu=/^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|download|draggable|encType|enterKeyHint|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/,yu=li((function(e){return mu.test(e)||111===e.charCodeAt(0)&&110===e.charCodeAt(1)&&e.charCodeAt(2)<91})),_u=function(e){return"theme"!==e},vu=function(e){return"string"==typeof e&&e.charCodeAt(0)>96?yu:_u},bu=function(e,t,n){var r;if(t){var o=t.shouldForwardProp;r=e.__emotion_forwardProp&&o?function(t){return e.__emotion_forwardProp(t)&&o(t)}:o}return"function"!=typeof r&&n&&(r=e.__emotion_forwardProp),r},xu="You have illegal escape sequence in your template literal, most likely inside content's property value.\nBecause you write your CSS inside a JavaScript string you actually have to do double escaping, so for example \"content: '\\00d7';\" should become \"content: '\\\\00d7';\".\nYou can read more about this here:\nhttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#ES2018_revision_of_illegal_escape_sequences",wu=function(e){var t=e.cache,n=e.serialized,r=e.isStringTag;return wi(t,n,r),Hi((function(){return Si(t,n,r)})),null},Su=function e(t,n){if("production"!==ae.env.NODE_ENV&&void 0===t)throw new Error("You are trying to create a styled element with an undefined component.\nYou may have forgotten to import it.");var r,o,i=t.__emotion_real===t,a=i&&t.__emotion_base||t;void 0!==n&&(r=n.label,o=n.target);var s=bu(t,n,i),l=s||vu(a),c=!l("as");return function(){var u=arguments,d=i&&void 0!==t.__emotion_styles?t.__emotion_styles.slice(0):[];if(void 0!==r&&d.push("label:"+r+";"),null==u[0]||void 0===u[0].raw)d.push.apply(d,u);else{"production"!==ae.env.NODE_ENV&&void 0===u[0][0]&&console.error(xu),d.push(u[0][0]);for(var f=u.length,h=1;h<f;h++)"production"!==ae.env.NODE_ENV&&void 0===u[0][h]&&console.error(xu),d.push(u[h],u[0][h])}var p=Wi((function(e,t,n){var r=c&&e.as||a,i="",u=[],f=e;if(null==e.theme){for(var h in f={},e)f[h]=e[h];f.theme=w.useContext(Ji)}"string"==typeof e.className?i=xi(t.registered,u,e.className):null!=e.className&&(i=e.className+" ");var p=$i(d.concat(u),t.registered,f);i+=t.key+"-"+p.name,void 0!==o&&(i+=" "+o);var g=c&&void 0===s?vu(r):l,m={};for(var y in e)c&&"as"===y||g(y)&&(m[y]=e[y]);return m.className=i,m.ref=n,w.createElement(w.Fragment,null,w.createElement(wu,{cache:t,serialized:p,isStringTag:"string"==typeof r}),w.createElement(r,m))}));return p.displayName=void 0!==r?r:"Styled("+("string"==typeof a?a:a.displayName||a.name||"Component")+")",p.defaultProps=t.defaultProps,p.__emotion_real=p,p.__emotion_base=a,p.__emotion_styles=d,p.__emotion_forwardProp=s,Object.defineProperty(p,"toString",{value:function(){return void 0===o&&"production"!==ae.env.NODE_ENV?"NO_COMPONENT_SELECTOR":"."+o}}),p.withComponent=function(t,r){return e(t,bi({},n,r,{shouldForwardProp:bu(p,r,!0)})).apply(void 0,d)},p}}.bind();async function Cu(e){if(isSecureContext){const t=new Blob([e.outerText],{type:"text/plain"}),n=new Blob([e.outerHTML],{type:"text/html"}),r=new ClipboardItem({[t.type]:t,[n.type]:n});return navigator.clipboard.write([r])}const t=t=>{t.clipboardData?.setData("text/plain",e.outerText),t.clipboardData?.setData("text/html",e.outerHTML),t.preventDefault()};document.addEventListener("copy",t),document.execCommand("copy"),document.removeEventListener("copy",t)}function Au(e){let t=0;for(const n of e)t+=n.sequence.length;return t}function ku(e,t,n){const r=[],{cdsLocations:i,strand:a,transcriptParts:s}=t;switch(e){case"genomic":case"cDNA":{const[t]=s;for(const i of t){if("cDNA"===e&&"intron"===i.type)continue;let t=n(i.min,i.max);-1===a&&(t=o.revcom(t));const s="fivePrimeUTR"===i.type||"threePrimeUTR"===i.type?"UTR":i.type,l=r.at(-1);l&&l.type===s?(l.sequence+=t,l.locs.push({min:i.min,max:i.max})):r.push({type:s,sequence:t,locs:[{min:i.min,max:i.max}]})}return r}case"CDS":{let e="";const[t]=i,s=[];for(const r of t){let t=n(r.min,r.max);-1===a&&(t=o.revcom(t)),e+=t,s.push({min:r.min,max:r.max})}return r.push({type:"CDS",sequence:e,locs:s}),r}case"protein":{let e="";const[t]=i,s=[];for(const r of t){let t=n(r.min,r.max);-1===a&&(t=o.revcom(t)),e+=t,s.push({min:r.min,max:r.max})}let l="";for(let t=0;t<e.length;t+=3){const n=e.slice(t,t+3).toUpperCase();l+=o.defaultCodonTable[n]||"&"}return r.push({type:"protein",sequence:l,locs:s}),r}}}function Nu(e){switch(e){case"upOrDownstream":return"rgb(255,255,255)";case"exon":case"UTR":return"rgb(194,106,119)";case"CDS":return"rgb(93,168,153)";case"intron":return"rgb(187,187,187)";case"protein":return"rgb(148,203,236)"}}function Tu(e){const t=[],n=e.flatMap((e=>e.locs));let[r]=n;for(let e=1;e<n.length;e++)r.min===n[e].max||r.max===n[e].min?r={min:Math.min(r.min,n[e].min),max:Math.max(r.max,n[e].max)}:(t.push(r),r=n[e]);return t.push(r),t}["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","marquee","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"].forEach((function(e){Su[e]=Su(e)}));const Ru=p.observer((function({assembly:e,feature:t,refName:n,session:r}){const o=r.apolloDataStore.assemblies.get(e),a=o?.getByRefName(n),{featureTypeOntology:l}=r.apolloDataStore.ontologyManager,c="genomic",d=["genomic","cDNA"],[f,h]=u.useState(d),[p,g]=u.useState(c),[m,y]=u.useState((()=>a?ku(c,t,((e,t)=>a.getSequence(e,t))):[])),[_,v]=u.useState((()=>Tu(m))),b=s.useTheme(),x=u.useRef(null);if(u.useEffect((()=>{const{cdsLocations:e}=t,[n]=e;h(n.length>0?[...d,"CDS","protein"]:d)}),[t]),!o||!a)return null;const w=o.getByRefName(n);if(!w)return null;if(!l)throw new Error("featureTypeOntology is undefined");return l.isTypeOf(t.type,"transcript")?i.jsxs(i.Fragment,{children:[i.jsx(s.Select,{defaultValue:"genomic",value:p,onChange:function(e){const n=e.target.value;g(n);const r=a?ku(n,t,((e,t)=>a.getSequence(e,t))):[],o=Tu(r);y(r),v(o)},size:"small","data-testid":"sequenceOptionSelector",children:f.map((e=>i.jsx(s.MenuItem,{value:e,"data-testid":`sequenceOption-${e}`,children:e},e)))}),i.jsx(s.Button,{variant:"contained",onClick:()=>{const e=x.current;e&&Cu(e)},style:{marginLeft:10},size:"medium",children:"Copy sequence"}),i.jsxs(s.Paper,{style:{fontFamily:"monospace",padding:b.spacing(),overflowX:"auto"},ref:x,children:[">",w.name,":",_.map((e=>1===t.strand?`${e.min+1}-${e.max}`:`${e.max}-${e.min+1}`)).join(";"),"(strand=",1===t.strand?"+":"-",";length=",Au(m),")",i.jsx("br",{}),function(e,t){const n=[];let r=0;for(const[t,o]of e.entries()){const e=r%60,a=r>0&&0===e?"\n":"";r+=o.sequence.length;const s=a+o.sequence.slice(0,60-e),l=[s,...Ot(o.sequence.slice(s.length),60)],c=i.jsx("span",{style:{background:Nu(o.type),color:b.palette.getContrastText(Nu(o.type)),whiteSpace:"pre-line"},children:l.join("\n")},`${o.type}-${t}`);n.push(c)}return n}(m)]})]}):null}));var Eu=a.createSvgIcon(i.jsx("path",{d:"M19 13H5v-2h14z"}),"Remove"),Iu=a.createSvgIcon(i.jsx("path",{d:"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2m0 16H8V7h11z"}),"ContentCopy"),ju=a.createSvgIcon(i.jsx("path",{d:"M9.64 7.64c.23-.5.36-1.05.36-1.64 0-2.21-1.79-4-4-4S2 3.79 2 6s1.79 4 4 4c.59 0 1.14-.13 1.64-.36L10 12l-2.36 2.36C7.14 14.13 6.59 14 6 14c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4c0-.59-.13-1.14-.36-1.64L12 14l7 7h3v-1zM6 8c-1.1 0-2-.89-2-2s.9-2 2-2 2 .89 2 2-.9 2-2 2m0 12c-1.1 0-2-.89-2-2s.9-2 2-2 2 .89 2 2-.9 2-2 2m6-7.5c-.28 0-.5-.22-.5-.5s.22-.5.5-.5.5.22.5.5-.22.5-.5.5M19 3l-6 6 2 2 7-7V3z"}),"ContentCut");const Du=Su("div")({display:"flex",justifyContent:"center",alignItems:"center",textAlign:"left",width:"100%",overflowWrap:"break-word",wordWrap:"break-word",wordBreak:"break-all","& span":{fontSize:12}}),Ou=Su(s.AccordionSummary)((()=>({minHeight:30,maxHeight:30,"&.Mui-expanded":{minHeight:30,maxHeight:30}})));function Fu({changeInProgress:e,cdsLocations:t,refData:n,strand:r,updateCDSLocation:a,cdsMin:l,cdsMax:c,feature:d,session:f}){const h=u.useRef(null),{notify:p}=f,g=[],[m]=t;for(const e of m){const t=n.getSequence(e.min,e.max);g.push(-1===r?o.revcom(t):t)}const y=g.join(""),_=[];for(let e=0;e<y.length;e+=3){const t=y.slice(e,e+3).toUpperCase();_.push(o.defaultCodonTable[t]||"&")}const v=e=>{const[n]=t;let o=0;const i=n.toSorted((({min:e},{min:t})=>e-t));if(1===r)for(const t of i){const n=t.max-t.min;if(o+n>e)return t.min+(e-o);o+=n}else if(-1===r)for(let t=i.length-1;t>=0;t--){const n=i[t],r=n.max-n.min;if(o+r>e)return n.max-(e-o);o+=r}return 1===r?l:c};return i.jsx("div",{children:i.jsxs(s.Accordion,{children:[i.jsx(Ou,{expandIcon:i.jsx(Uc,{style:{color:"white"}}),"aria-controls":"panel1-content",id:"panel1-header",children:i.jsx(s.Typography,{component:"span",fontWeight:"bold",children:"Translation"})}),i.jsxs(s.AccordionDetails,{children:[i.jsx(Du,{children:i.jsx(s.Typography,{component:"span",ref:h,style:{maxHeight:120,overflowY:"scroll"},children:_.map(((t,n)=>{const o=3*n;return i.jsx(s.Typography,"M"===t?{component:"span",style:{backgroundColor:e?"lightgray":"yellow",cursor:"pointer",border:"1px solid black"},onClick:()=>{if(e)return;const t=v(o);t!==l&&1===r&&a(l,t,d,!0),t!==c&&-1===r&&a(c,t,d,!1)},children:t}:"*"===t?{style:{backgroundColor:"red",color:"white"},component:"span",children:t}:{component:"span",children:t},o)}))})}),i.jsxs("div",{style:{marginTop:10,display:"flex",flexDirection:"row",alignItems:"center",gap:10},children:[i.jsx(s.Tooltip,{title:"Copy",children:i.jsx("button",{onClick:()=>{const e=h.current;e&&Cu(e)},style:{border:"none",background:"none",padding:0},disabled:e,children:i.jsx(Iu,{style:{fontSize:15}})})}),i.jsx(s.Tooltip,{title:"Trim",children:i.jsx("button",{onClick:()=>{if("M"===_.at(0)&&"*"===_.at(-1)||0===_.length)return;const e=_.indexOf("M");if(-1===e)return void p("Start codon not found","error");const t=_.indexOf("*",e);if(-1===t)return void p("Stop codon not found","error");const n=3*t,o=v(3*e);let i=v(n);if(1===r){if(o>i)return void p("Start codon genomic location should be less than stop codon genomic location","error");let e;i+=3,o!==l&&(e=new Promise((e=>{a(l,o,d,!0,(()=>{e(!0)}))}))),i!==c&&(e?e.then((()=>{a(c,i,d,!1)})):a(c,i,d,!1))}if(-1===r){if(o<i)return void p("Start codon genomic location should be less than stop codon genomic location","error");let e;i-=3,o!==c&&(e=new Promise((e=>{a(c,o,d,!1,(()=>{e(!0)}))}))),i!==l&&(e?e.then((()=>{a(l,i,d,!0)})):a(l,i,d,!0))}p("Translation sequence trimmed to start and stop codons","success")},style:{border:"none",background:"none",padding:0},disabled:e,children:i.jsx(ju,{style:{fontSize:15}})})})]})]})]})})}const Mu=Su(tu)((()=>({"&.MuiFormControl-root":{marginTop:0,marginBottom:0,width:"100%"},"& .MuiInputBase-input":{fontSize:12,height:20,padding:1,paddingLeft:10}}))),Lu=e=>{const{strand:t}=e;return i.jsx("div",{children:1===t?i.jsx(Ln,{}):-1===t?i.jsx(Eu,{}):i.jsx(s.Typography,{component:"span",children:"N/A"})})},Pu=p.observer((function({assembly:e,feature:t,refName:n,session:r}){const{notify:a}=r,l=r.apolloDataStore.assemblies.get(e),c=l?.getByRefName(n),{changeManager:u}=r.apolloDataStore,{changeInProgress:d}=r;if(!c)return null;const{apolloDataStore:f}=r,{featureTypeOntology:h}=f.ontologyManager;if(!h.isTypeOf(t.type,"transcript")&&!h.isTypeOf(t.type,"pseudogenic_transcript"))throw new Error("Feature is not a transcript or equivalent");const{cdsLocations:p,transcriptExonParts:g,strand:m}=t,[y]=p,[_,v]=((e,t)=>{const{transcriptExonParts:n}=e,r=n.filter((e=>t.isTypeOf(e.type,"exon"))).sort((({min:e},{min:t})=>e-t)),o=r[0]?.min,i=r[r.length-1]?.max;return[o,i]})(t,h);let b=_,x=v;const w=y.length>0;if(w){const e=y.toSorted((({min:e},{min:t})=>e-t));b=e[0].min,x=e[e.length-1].max}const S=(t,n,r,o,i)=>{if(!r.children)throw new Error("Transcript should have child features");if(t===n)return!0;const s=N(r,h,t,o);if(!s)return a("No matching CDS feature found","error"),!1;if(o&&n>=s.max)return a("Start location should be less than CDS end location","error"),!1;if(!o&&n<=s.min)return a("End location should be greater than CDS start location","error"),!1;if(!I(r,h,n,o))return a("There should be an overlapping exon for the new CDS location","error"),!1;const l=o?new Et({typeName:"LocationStartChange",changedIds:[s._id],featureId:s._id,oldStart:s.min,newStart:n,assembly:e}):new Tt({typeName:"LocationEndChange",changedIds:[s._id],featureId:s._id,oldEnd:s.max,newEnd:n,assembly:e});return u.submit(l).then((()=>{i&&i()})).catch((()=>{a("Error updating feature CDS position","error")})),!0};function C(t,n,r,o){if(!r.children)throw new Error("Transcript should have child features");const{matchingExon:i,prevExon:s,nextExon:l}=j(r,h,t,o);if(!i)return a("No matching exon found","error"),!1;if(o&&n>=i.max)return a("Start location should be less than end location","error"),!1;if(!o&&n<=i.min)return a("End location should be greater than start location","error"),!1;if(s&&s.max+2>n)return a("Error while changing start location","error"),!1;if(l&&l.min-2<n)return a("Error while changing end location","error"),!1;const c=R(r,i.min,i.max,h);if(!c)return a("No matching exon feature found","error"),!1;const d=T(r,h);if(o&&n!==i.min){const t=new Et({typeName:"LocationStartChange",changedIds:[],changes:[],assembly:e});if(s)k(c,t,n);else{const e=r.min,i=r.parent;if(n<e)i&&n<i.min&&k(i,t,n),k(r,t,n),k(c,t,n);else if(n>e&&(k(c,t,n),k(r,t,n),i)){const[e]=E(i,r,n,h,o);i.min!=e&&k(i,t,e)}}d&&d.min>=i.min&&d.min<=i.max&&n>d.min&&k(d,t,n),u.submit(t).catch((()=>{a("Error updating feature exon start position","error")}))}if(!o&&n!==i.max){const t=new Tt({typeName:"LocationEndChange",changedIds:[],changes:[],assembly:e});if(l)A(c,t,n);else{const e=r.max,i=r.parent;if(n>e)i&&n>i.max&&A(i,t,n),A(r,t,n),A(c,t,n);else if(n<e&&(A(c,t,n),A(r,t,n),i)){const[,e]=E(i,r,n,h,o);i.max!=e&&A(i,t,e)}}d&&d.max>=i.min&&d.max<=i.max&&n<d.max&&A(d,t,n),u.submit(t).catch((()=>{a("Error updating feature exon end position","error")}))}return!0}const A=(e,t,n)=>{t.changedIds.push(e._id),t.changes.push({featureId:e._id,oldEnd:e.max,newEnd:n})},k=(e,t,n)=>{t.changedIds.push(e._id),t.changes.push({featureId:e._id,oldStart:e.min,newStart:n})},N=(e,t,n,r)=>{let o;for(const[,i]of e.children??[])if(t.isTypeOf(i.type,"CDS")){if(r&&n===i.min){o=i;break}if(!r&&n===i.max){o=i;break}}return o},T=(e,t)=>{let n;for(const[,r]of e.children??[])if(t.isTypeOf(r.type,"CDS")){n=r;break}return n},R=(e,t,n,r)=>{let o;for(const[,i]of e.children??[])if(r.isTypeOf(i.type,"exon")&&t===i.min&&n===i.max){o=i;break}return o},E=(e,t,n,r,o)=>{const i=[],a=[];for(const[,s]of e.children?.entries()??[])r.isTypeOf(s.type,"transcript")&&(s._id===t._id?o?(i.push(n),a.push(s.max)):(a.push(n),i.push(s.min)):(i.push(s.min),a.push(s.max)));return[Math.min(...i),Math.max(...a)]},I=(e,t,n,r)=>{const{transcriptExonParts:o}=e;let i;for(const[,e]of o.entries())if(t.isTypeOf(e.type,"exon")){if(!r&&n>=e.min&&n<=e.max){i=e;break}if(r&&n>=e.min&&n<=e.max){i=e;break}}return i},j=(e,t,n,r)=>{const{transcriptExonParts:o,strand:i}=e;let a,s,l,c;for(const[e,i]of o.entries())if(t.isTypeOf(i.type,"exon")){if(r&&i.min===n){a=i,s=e;break}if(!r&&i.max===n){a=i,s=e;break}}if(a&&void 0!==s){if(1===i&&s>0)for(let e=s-1;e>=0;e--){const n=o[e];if(t.isTypeOf(n.type,"exon")){l=n;break}}if(-1===i&&s<o.length-1)for(let e=s+1;e<o.length;e++){const n=o[e];if(t.isTypeOf(n.type,"exon")){l=n;break}}if(1===i&&s<o.length-1)for(let e=s+1;e<o.length;e++){const n=o[e];if(t.isTypeOf(n.type,"exon")){c=n;break}}if(-1===i&&s>0)for(let e=s-1;e>=0;e--){const n=o[e];if(t.isTypeOf(n.type,"exon")){c=n;break}}}return{matchingExon:a,prevExon:l,nextExon:c}},D=(e,t)=>{let n="";if(t>0){const r=g[t-1];1===m?"intron"===r.type&&(n=c.getSequence(e.min-2,e.min)):"intron"===r.type&&(n=o.revcom(c.getSequence(e.max,e.max+2)))}return n=n.toUpperCase(),[{spliceSite:n,color:"AG"===n?"green":"red"}]},O=(e,t)=>{let n="";if(t<g.length-1){const r=g[t+1];1===m?"intron"===r.type&&(n=c.getSequence(e.max,e.max+2)):"intron"===r.type&&(n=o.revcom(c.getSequence(e.min-2,e.min)))}return n=n.toUpperCase(),[{spliceSite:n,color:"GT"===n?"green":"red"}]};return i.jsxs("div",{children:[w&&i.jsx("div",{children:i.jsxs(s.Grid,{container:!0,justifyContent:"center",alignItems:"center",style:{textAlign:"center"},children:[i.jsx(s.Grid,{size:1}),i.jsx(s.Grid,1===m?{size:4,children:i.jsx(Mu,{margin:"dense",variant:"outlined",value:b+1,onChangeCommitted:e=>S(b,e-1,t,!0),style:{border:"1px solid black",borderRadius:5},disabled:d})}:{size:4,children:i.jsx(Mu,{margin:"dense",variant:"outlined",value:x,onChangeCommitted:e=>S(x,e,t,!1),style:{border:"1px solid black",borderRadius:5},disabled:d})}),i.jsx(s.Grid,{size:2,children:i.jsx(s.Typography,{component:"span",children:"CDS"})}),i.jsx(s.Grid,1===m?{size:4,children:i.jsx(Mu,{margin:"dense",variant:"outlined",value:x,onChangeCommitted:e=>S(x,e,t,!1),style:{border:"1px solid black",borderRadius:5},disabled:d})}:{size:4,children:i.jsx(Mu,{margin:"dense",variant:"outlined",value:b+1,onChangeCommitted:e=>S(b,e-1,t,!0),style:{border:"1px solid black",borderRadius:5},disabled:d})}),i.jsx(s.Grid,{size:1})]})}),i.jsxs("div",{style:{marginTop:5,marginBottom:10},children:[i.jsx("div",{style:{textAlign:"center"},children:i.jsx(s.Typography,{children:"Exons"})}),g.map(((e,n)=>i.jsx("div",{children:"exon"===e.type&&i.jsxs(s.Grid,{container:!0,justifyContent:"center",alignItems:"center",style:{textAlign:"center"},children:[i.jsx(s.Grid,{size:1,children:0!==n&&D(e,n).map(((e,t)=>i.jsx(s.Typography,{component:"span",color:e.color,children:e.spliceSite},t)))}),i.jsx(s.Grid,1===m?{size:4,style:{padding:0},children:i.jsx(Mu,{margin:"dense",variant:"outlined",value:e.min+1,onChangeCommitted:n=>C(e.min,n-1,t,!0),disabled:d})}:{size:4,style:{padding:0},children:i.jsx(Mu,{margin:"dense",variant:"outlined",value:e.max,onChangeCommitted:n=>C(e.max,n,t,!1),disabled:d})}),i.jsx(s.Grid,{size:2,children:i.jsx(Lu,{strand:t.strand})}),i.jsx(s.Grid,1===m?{size:4,style:{padding:0},children:i.jsx(Mu,{margin:"dense",variant:"outlined",value:e.max,onChangeCommitted:n=>C(e.max,n,t,!1),disabled:d})}:{size:4,style:{padding:0},children:i.jsx(Mu,{margin:"dense",variant:"outlined",value:e.min+1,onChangeCommitted:n=>C(e.min,n-1,t,!0),disabled:d})}),i.jsx(s.Grid,{size:1,children:n!==g.length-1&&O(e,n).map(((e,t)=>i.jsx(s.Typography,{component:"span",color:e.color,children:e.spliceSite},t)))})]})},n)))]}),w&&i.jsx(Fu,{changeInProgress:d,cdsLocations:p,refData:c,strand:m,updateCDSLocation:S,cdsMin:b,cdsMax:x,feature:t,session:r})]})})),Bu=Su(s.TableCell)((()=>({fontWeight:"bold"}))),qu=p.observer((function(e){const{feature:t}=e,n=xa(t),r=wa(t);return i.jsx(s.Table,{size:"small",sx:{fontSize:"0.75rem","& .MuiTableCell-root":{padding:"4px"}},children:i.jsxs(s.TableBody,{children:[""!==n&&i.jsxs(s.TableRow,{children:[i.jsx(Bu,{children:"Name"}),i.jsx(s.TableCell,{children:xa(t)})]}),""!==r&&i.jsxs(s.TableRow,{children:[i.jsx(Bu,{children:"ID"}),i.jsx(s.TableCell,{children:wa(t)})]}),i.jsxs(s.TableRow,{children:[i.jsx(Bu,{children:"Type"}),i.jsx(s.TableCell,{children:t.type})]}),i.jsxs(s.TableRow,{children:[i.jsx(Bu,{children:"Location"}),i.jsxs(s.TableCell,{children:[e.refName,":",t.min,"..",t.max]})]}),i.jsxs(s.TableRow,{children:[i.jsx(Bu,{children:"Strand"}),i.jsx(s.TableCell,{children:(o=t.strand,1===o?"Forward":-1===o?"Reverse":"")})]})]})});var o})),Uu=ma()((e=>({root:{padding:e.spacing(2)}}))),zu=Su(s.AccordionSummary)((()=>({minHeight:30,maxHeight:30,"&.Mui-expanded":{minHeight:30,maxHeight:30}})));function $u(e){return null}const Hu=p.observer((function(e){const{classes:t}=Uu(),n=["summary","location"],[r,a]=u.useState(n),{model:c}=e,{assembly:d,feature:f,refName:h}=c;u.useEffect((()=>{a(n)}),[f]);const p=o.getSession(c),{pluginManager:g}=o.getEnv(p),m=o.getSession(c),y=m.apolloDataStore.assemblies.get(d),{internetAccounts:_}=l.getRoot(p),v=_.find((e=>"ApolloInternetAccount"===e.type)),b=["admin","user"].includes((v?v.role:"admin")??"");if(!f||!y)return null;const x=y.getByRefName(h);if(!x)return null;const{max:w,min:S}=f;function C(e,t){a(e?[...r,t]:r.filter((e=>e!==t)))}x.getSequence(S,w)||m.apolloDataStore.loadRefSeq([{assemblyName:d,refName:h,start:S,end:w}]);const A=g.evaluateExtensionPoint("Apollo-TranscriptDetailsCustomComponent-InsideSummary",$u,{feature:f,session:p}),k=g.evaluateExtensionPoint("Apollo-TranscriptDetailsCustomComponent-AfterSummary",$u,{feature:f,session:p}),N=g.evaluateExtensionPoint("Apollo-TranscriptDetailsCustomComponent-InsideLocation",$u,{feature:f,session:p}),T=g.evaluateExtensionPoint("Apollo-TranscriptDetailsCustomComponent-AfterLocation",$u,{feature:f,session:p}),R=g.evaluateExtensionPoint("Apollo-TranscriptDetailsCustomComponent-InsideAttributes",$u,{feature:f,session:p}),E=g.evaluateExtensionPoint("Apollo-TranscriptDetailsCustomComponent-AfterAttributes",$u,{feature:f,session:p}),I=g.evaluateExtensionPoint("Apollo-TranscriptDetailsCustomComponent-InsideSequence",$u,{feature:f,session:p}),j=g.evaluateExtensionPoint("Apollo-TranscriptDetailsCustomComponent-AfterSequence",$u,{feature:f,session:p});return i.jsxs("div",{className:t.root,children:[i.jsxs(s.Accordion,{expanded:r.includes("summary"),onChange:(e,t)=>{C(t,"summary")},children:[i.jsx(zu,{expandIcon:i.jsx(Uc,{style:{color:"white"}}),"aria-controls":"panel1-content",id:"panel1-header",children:i.jsx(s.Typography,{component:"span",fontWeight:"bold",children:"Summary"})}),i.jsxs(s.AccordionDetails,{children:[i.jsx(qu,{feature:f,refName:h}),i.jsx(A,{session:p,feature:f})]})]}),i.jsx(k,{session:p,feature:f}),i.jsxs(s.Accordion,{style:{marginTop:5},expanded:r.includes("location"),onChange:(e,t)=>{C(t,"location")},children:[i.jsx(zu,{expandIcon:i.jsx(Uc,{style:{color:"white"}}),"aria-controls":"panel2-content",id:"panel2-header",children:i.jsx(s.Typography,{component:"span",fontWeight:"bold",children:"Location"})}),i.jsxs(s.AccordionDetails,{children:[i.jsx(Pu,{feature:f,refName:h,session:m,assembly:y._id||""}),i.jsx(N,{session:p,feature:f})]})]}),i.jsx(T,{session:p,feature:f}),i.jsxs(s.Accordion,{style:{marginTop:5},expanded:r.includes("attrs"),onChange:(e,t)=>{C(t,"attrs")},children:[i.jsx(zu,{expandIcon:i.jsx(Uc,{style:{color:"white"}}),"aria-controls":"panel3-content",id:"panel3-header",children:i.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[i.jsxs(s.Typography,{component:"span",fontWeight:"bold",children:["Attributes"," "]}),i.jsx(s.Tooltip,{title:"Separate multiple values for the attribute with commas",children:i.jsx(ya,{style:{color:"white",fontSize:15,marginLeft:10}})})]})}),i.jsxs(s.AccordionDetails,{children:[i.jsx(eu,{feature:f,session:m,assembly:y._id||"",editable:b}),i.jsx(R,{session:p,feature:f})]})]}),i.jsx(E,{session:p,feature:f}),i.jsxs(s.Accordion,{style:{marginTop:5},expanded:r.includes("sequence"),onChange:(e,t)=>{C(t,"sequence")},children:[i.jsx(zu,{expandIcon:i.jsx(Uc,{style:{color:"white"}}),"aria-controls":"panel4-content",id:"panel4-header",children:i.jsx(s.Typography,{component:"span",fontWeight:"bold",children:"Sequence"})}),i.jsxs(s.AccordionDetails,{children:[r.includes("sequence")&&i.jsx(Ru,{feature:f,session:m,assembly:y._id||"",refName:h}),i.jsx(I,{session:p,feature:f})]})]}),i.jsx(j,{feature:f,session:p})]})})),Gu=n.ConfigurationSchema("LinearApolloDisplay",{},{explicitIdentifier:"displayId",explicitlyTyped:!0}),Vu=ma()({highlighted:{background:"orange"}}),Wu=({highlight:e,text:t})=>{const{classes:n}=Vu();if(!e)return i.jsx(i.Fragment,{children:t});const r=t.split(e);if(1===r.length)return i.jsx(i.Fragment,{children:t});const o=[];for(let t=0;t<r.length-1;t++)o.push(r[t],i.jsx("span",{className:n.highlighted,children:e}));return i.jsxs(i.Fragment,{children:[o,r.at(-1)]})},Ju=p.observer((function({feature:e,filterText:t}){const n=[...e.attributes.entries()].map((([e,t])=>{if(e.startsWith("gff_")){const n=e.slice(4);return[n.charAt(0).toUpperCase()+n.slice(1),l.getSnapshot(t)]}return"_id"===e?["ID",l.getSnapshot(t)]:[e,l.getSnapshot(t)]})).filter((([e])=>e)).map((([e,t])=>`${e}=${Array.isArray(t)?t.join(", "):t}`)).join(", ");return i.jsx(Wu,{text:n,highlight:t})})),Ku=ma()((e=>({inputWrapper:{position:"relative"},hiddenWidthSpan:{padding:e.spacing(.5),color:"transparent"},numberTextInput:{border:"none",background:"inherit",font:"inherit",position:"absolute",width:"100%",left:0}}))),Yu=p.observer((function({initialValue:e,notifyError:t,onChangeCommitted:n}){const[r,o]=u.useState(e),[a,s]=u.useState(!1),[l,c]=u.useState(null),{classes:d}=Ku();return u.useEffect((()=>{e!==r&&o(e)}),[e]),u.useEffect((()=>{a&&(l?.blur(),s(!1))}),[a,l]),i.jsxs("span",{className:d.inputWrapper,children:[i.jsx("span",{className:d.hiddenWidthSpan,"aria-hidden":!0,children:r}),i.jsx("input",{type:"text",value:r,className:d.numberTextInput,onChange:function(e){const t=Number(e.target.value);Number.isNaN(t)||o(t)},onKeyDown:t=>{"Enter"===t.key?l?.blur():"Escape"===t.key&&(o(e),s(!0))},onBlur:()=>{r!==e&&n(r).catch(t)},ref:e=>{c(e)}})]})})),Xu=ma()((e=>({typeContent:{display:"inline-block",width:"174px",height:"100%",cursor:"text"},feature:{td:{position:"relative",verticalAlign:"top",paddingLeft:"0.5em"}},arrow:{display:"inline-block",width:"1.6em",textAlign:"center",cursor:"pointer"},arrowExpanded:{transform:"rotate(90deg)"},hoveredFeature:{backgroundColor:e.palette.action.hover},typeInputElement:{border:"none",background:"none"},typeErrorMessage:{color:"red"}})));function Zu(e,t){const{changeManager:n,getAssemblyId:r,regions:i,selectedFeature:a,session:s,setSelectedFeature:c,filteredTranscripts:u,updateFilteredTranscripts:d}=e;return function(e,t,n,r,i,a,s,c,u){const d=function(e){const{internetAccounts:t}=l.getParent(e);return t.find((e=>"ApolloInternetAccount"===e.type))}(a),f=d?d.role:"admin",h=!(f&&["admin","user"].includes(f)),p=[];if(e){const l=e.attributes.get("gff_id")?.toString(),f=n(t.assemblyName),g=n(t.assemblyName);p.push({label:"Edit feature details",onClick:()=>{const n=a.addWidget("ApolloFeatureDetailsWidget","apolloFeatureDetailsWidget",{feature:e,assembly:g,refName:t.refName});a.showWidget(n)}},{label:"Add child feature",disabled:h,onClick:()=>{a.queueDialog((t=>[Us,{session:a,handleClose:()=>{t()},changeManager:s,sourceFeature:e,sourceAssemblyId:f,internetAccount:d}]))}},{label:"Copy features and annotations",disabled:h,onClick:()=>{a.queueDialog((t=>[Gs,{session:a,handleClose:()=>{t()},changeManager:s,sourceFeature:e,sourceAssemblyId:g}]))}},{label:"Delete feature",disabled:h,onClick:()=>{a.queueDialog((t=>[Vs,{session:a,handleClose:()=>{t()},changeManager:s,sourceFeature:e,sourceAssemblyId:g,selectedFeature:r,setSelectedFeature:i}]))}},{label:"Merge transcripts",disabled:h,onClick:()=>{a.queueDialog((t=>[nc,{session:a,handleClose:()=>{t()},changeManager:s,sourceFeature:e,sourceAssemblyId:g,selectedFeature:r,setSelectedFeature:i}]))}},{label:"Merge exons",disabled:h,onClick:()=>{a.queueDialog((t=>[ec,{session:a,handleClose:()=>{t()},changeManager:s,sourceFeature:e,sourceAssemblyId:g,selectedFeature:r,setSelectedFeature:i}]))}},{label:"Split exon",disabled:h,onClick:()=>{a.queueDialog((t=>[fc,{session:a,handleClose:()=>{t()},changeManager:s,sourceFeature:e,sourceAssemblyId:g,selectedFeature:r,setSelectedFeature:i}]))}});const{featureTypeOntology:m}=a.apolloDataStore.ontologyManager;if(!m)throw new Error("featureTypeOntology is undefined");(m.isTypeOf(e.type,"transcript")||m.isTypeOf(e.type,"pseudogenic_transcript"))&&o.isSessionModelWithWidgets(a)&&p.push({label:"Edit transcript details",onClick:()=>{const n=a.addWidget("ApolloTranscriptDetails","apolloTranscriptDetails",{feature:e,assembly:g,changeManager:s,refName:t.refName});a.showWidget(n)}},{label:"Duplicate feature",onClick:()=>{a.queueDialog((t=>[hc,{session:a,handleClose:()=>{t()},changeManager:s,sourceFeature:e,sourceAssemblyId:g,selectedFeature:r,setSelectedFeature:i}]))}},{label:"Visible",type:"checkbox",checked:!l||!c.includes(l),onClick:()=>{if(l){const e=c.includes(l)?c.filter((e=>e!==l)):[...c,l];u(e)}}})}return p}(t,i[0],r,a,c,s,n,u,d)}const Qu=p.observer((function e({depth:t,feature:n,isHovered:r,isSelected:o,model:a,selectedFeatureClass:s,setContextMenu:l}){const{classes:c}=Xu(),{changeManager:u,hoveredFeature:d,selectedFeature:f,session:h,tabularEditor:p}=a,{featureCollapsed:g,filterText:m}=p,{_id:y,children:_,max:v,min:b,strand:x,type:w}=n,S=!g.get(y),C=e=>{h.notify(e.message,"error")};return i.jsxs(i.Fragment,{children:[i.jsxs("tr",{onMouseEnter:e=>{a.setHoveredFeature({feature:n,bp:b})},className:c.feature+(o?` ${s}`:r?` ${c.hoveredFeature}`:""),onClick:e=>{e.stopPropagation(),a.setSelectedFeature(n)},onDoubleClick:()=>{a.setSelectedFeature(n),function(e,t){e.lgv.navTo(al(t,.1,e.lgv.totalBp))}(a,n)},onContextMenu:e=>(e.preventDefault(),l({position:{left:e.clientX+2,top:e.clientY-6},items:Zu(a,n)}),!1),children:[i.jsxs("td",{style:{whiteSpace:"nowrap",borderLeft:2*t+"em solid transparent"},children:[_?.size?i.jsx("div",{onClick:e=>{e.stopPropagation(),p.setFeatureCollapsed(y,S)},className:c.arrow+(S?` ${c.arrowExpanded}`:""),children:"❯"}):null,i.jsx("div",{className:c.typeContent,children:i.jsx(qs,{session:h,ontologyName:"Sequence Ontology",style:{width:170},value:w,filterTerms:Cs,fetchValidTerms:ed.bind(null,n),renderInput:e=>i.jsxs("div",{ref:e.InputProps.ref,children:[i.jsx("input",{type:"text",...e.inputProps,className:c.typeInputElement,style:{width:170}}),e.error?i.jsx("div",{className:c.typeErrorMessage,children:e.errorMessage??"unknown error"}):null]}),onChange:(e,t)=>{t&&function(e,t,n,r){const o=t._id,i=new $t({typeName:"TypeChange",changedIds:[o],featureId:o,oldType:n,newType:r,assembly:t.assemblyId});return e.submit(i)}(u,n,e,t).catch(C)}})})]}),i.jsx("td",{children:i.jsx(Yu,{initialValue:b+1,notifyError:C,onChangeCommitted:e=>function(e,t,n,r){const o=t._id,i=new Et({typeName:"LocationStartChange",changedIds:[o],featureId:o,oldStart:n,newStart:r,assembly:t.assemblyId});return e.submit(i)}(u,n,b,e-1)})}),i.jsx("td",{children:i.jsx(Yu,{initialValue:v,notifyError:C,onChangeCommitted:e=>function(e,t,n,r){const o=t._id,i=new Tt({typeName:"LocationEndChange",changedIds:[o],featureId:o,oldEnd:n,newEnd:r,assembly:t.assemblyId});return e.submit(i)}(u,n,v,e)})}),i.jsx("td",{children:1===x?"+":-1===x?"-":void 0}),i.jsx("td",{children:i.jsx(Ju,{filterText:m,feature:n})})]}),S&&_?[..._.entries()].filter((e=>{if(!m)return!0;const[,t]=e;return JSON.stringify(t).includes(m)})).map((([n,r])=>i.jsx(e,{isHovered:d?.feature._id===r._id,isSelected:f?._id===r._id,selectedFeatureClass:s,depth:(t||0)+1,feature:r,model:a,setContextMenu:l},n))):null]})}));async function ed(e,t,n){const{parent:r}=e;if(r){const e=(await t.getTermsWithLabelOrSynonym(r.type,{includeSubclasses:!1})).filter(Cs);if(e.length>0)return await t.getClassesThat("part_of",e)}}const td=ma()((e=>({scrollableTable:{width:"100%",height:"100%",th:{position:"sticky",top:0,zIndex:2,textAlign:"left",background:e.palette.background.paper,paddingTop:"3.2em"},td:{whiteSpace:"normal"}},selectedFeature:{backgroundColor:e.palette.action.selected}}))),nd=p.observer((function({model:e}){const{hoveredFeature:t,seenFeatures:n,selectedFeature:r,tabularEditor:o}=e,a=s.useTheme(),{classes:l}=td(),c=u.useRef(null),[d,f]=u.useState(null),{filterText:p}=o;return u.useEffect((()=>{const e=c.current;if(e&&r){const t=e.querySelector(`.${l.selectedFeature}`);if(t){const n=e.scrollTop,r=t.offsetTop-25;r>n&&r<n+e.offsetHeight||e.scroll({top:r-40,behavior:"smooth"})}}}),[r,n,l.selectedFeature]),i.jsxs("div",{ref:c,style:{width:"100%",overflowY:"auto",height:"100%"},children:[i.jsxs("table",{className:l.scrollableTable,children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"Type"}),i.jsx("th",{children:"Start"}),i.jsx("th",{children:"End"}),i.jsx("th",{children:"Strand"}),i.jsx("th",{children:"Attributes"})]})}),i.jsx("tbody",{children:[...n.entries()].filter((e=>{if(!p)return!0;const[,t]=e;return JSON.stringify(t).includes(p)})).sort(((e,t)=>e[1].min-t[1].min)).map((([n,o])=>i.jsx(Qu,{isSelected:r?._id===n,isHovered:t?.feature._id===n,selectedFeatureClass:l.selectedFeature,feature:o,model:e,depth:0,setContextMenu:f},n)))})]}),i.jsx(h.Menu,{open:Boolean(d),onMenuItemClick:(e,t)=>{t(),f(null)},onClose:()=>{f(null)},slotProps:{transition:{onExit:()=>{f(null)}}},style:{zIndex:a.zIndex.tooltip},menuItems:d?.items??[],anchorReference:"anchorPosition",anchorPosition:d?.position})]})}));var rd=a.createSvgIcon(i.jsx("path",{d:"M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"}),"Clear"),od=a.createSvgIcon(i.jsx("path",{d:"M7.41 18.59 8.83 20 12 16.83 15.17 20l1.41-1.41L12 14zm9.18-13.18L15.17 4 12 7.17 8.83 4 7.41 5.41 12 10z"}),"UnfoldLess");const id=ma()({toolbar:{width:"100%",display:"flex",paddingRight:"2em",flexDirection:"row",justifyContent:"space-between",position:"absolute",zIndex:4},filterText:{}}),ad=p.observer((function({model:e}){const t=e.tabularEditor,{classes:n}=id();return i.jsxs("div",{className:n.toolbar,children:[i.jsx(s.Tooltip,{title:"Collapse all",children:i.jsx(s.IconButton,{"aria-label":"collapse",sx:{marginTop:0},onClick:t.collapseAllFeatures,children:i.jsx(od,{})})}),i.jsx(s.TextField,{className:n.filterText,label:"Filter features",value:t.filterText,sx:{marginTop:0},variant:"outlined",onChange:e=>{t.setFilterText(e.target.value)},slotProps:{input:{endAdornment:i.jsx(s.InputAdornment,{position:"end",children:i.jsx(s.IconButton,{onClick:()=>{t.clearFilterText()},children:i.jsx(rd,{})})})}}})]})}));function sd(e){e.stopPropagation()}const ld=p.observer((function({model:e}){return e.tabularEditor.isShown?i.jsxs("div",{onMouseDown:sd,onClick:sd,style:{width:"100%",height:"100%",position:"relative"},children:[i.jsx(ad,{model:e}),i.jsx(nd,{model:e})]}):null})),cd=l.types.model("TabularEditor",{isShown:!0,featureCollapsed:l.types.map(l.types.boolean),filterText:""}).actions((e=>({setFeatureCollapsed(t,n){e.featureCollapsed.set(t,n)},setFilterText(t){e.filterText=t},clearFilterText(){e.filterText=""},collapseAllFeatures(){const t=l.getParent(e);for(const[n]of t.seenFeatures.entries())e.featureCollapsed.set(n,!0)},togglePane(){e.isShown=!e.isShown},hidePane(){e.isShown=!1},showPane(){e.isShown=!0}})));function ud(e,t,n){const{lgv:r}=e,{bpPerPx:o,offsetPx:i}=r;return n.offsetPx-i+(n.reversed?n.end-t.max:t.min-n.start)/o}function dd(e,t,n,r){const{apolloRowHeight:o,lgv:i}=e,{bpPerPx:a}=i;return[n*o,Math.round(ud(e,t,r)),Math.round((t.max-t.min)/a),o]}function fd(e,t,n,r,o,i,a,l){const c=function(e,t,n){const{theme:r}=e;switch(n){case"select":return r.palette.action.disabled;case"hover":return r.palette.action.focus;case"highlight":{const{attributes:e}=t,n=e.get("apollo_color");return n?.[0]}}}(e,a,l);c&&(t.fillStyle=s.alpha(c,.3),t.fillRect(n,r,o,i))}function hd(e,t,n,r,o,i){e.strokeStyle=i,e.lineWidth=1,e.strokeRect(t+.5,n+.5,r-1,o-1)}function pd(e,t,n){const{refName:r,regionNumber:o,x:i}=e,{lgv:a}=n,{offsetPx:s}=a,l=a.bpToPx({refName:r,coord:t.min,regionNumber:o}),c=a.bpToPx({refName:r,coord:t.max,regionNumber:o});if(void 0!==l&&void 0!==c){const e=l.offsetPx-s,t=c.offsetPx-s;if(Math.abs(t-e)<8)return;if(Math.abs(e-i)<4)return"min";if(Math.abs(t-i)<4)return"max"}}function gd(e,t,n,r,o,i){const[a,s,l,c]=dd(e,n,r,o);fd(e,t,s,a,l,c,n,i)}const md={draw:function(e,t,n,r,o,i){const{selectedFeature:a,theme:s}=e,[l,c,u,d]=dd(e,n,r,i);u>2&&(t.fillStyle=s.palette.background.default,t.fillRect(c,l,u,d)),hd(t,c,l,u,d,s.palette.text.primary),rl(n,a)&&gd(e,t,n,r,i,"select")},drawDragPreview:function(e,t,n,r,o){const{apolloDragging:i,theme:a}=e;if(!i)return;const{current:l,start:c}=i,u=Math.min(l.bp,c.bp),d=Math.max(l.bp,c.bp),[f,h,p,g]=dd(e,{min:u,max:d},r,o);t.fillStyle=s.alpha(a.palette.info.main,.2),t.fillRect(h,f,p,g),t.setLineDash([6]),hd(t,h,f,p,g,a.palette.info.main)},drawOverlay:gd,getContextMenuItems:function(e){const{hoveredFeature:t}=e;return t?il(e,t.feature):[]},getLayout:function(e,t){return{byFeature:new Map([[t._id,0]]),byRow:[[{feature:t,rowInFeature:0}]],min:t.min,max:t.max}},isDraggable:!0};function yd(e,t,n,r,i,a){const{apolloRowHeight:s,canvasPatterns:l,theme:c}=e,[u,d,f]=dd(e,n,i,a),h=Math.round(s/2);if(f>2){const e=o.getFrame(n.min,n.max,r??1,n.phase),i=c.palette.framesCDS.at(e)?.main;t.fillStyle=i??"black",t.fillRect(d,u,f,s);const p=l.forward,g=l.backward;if(p&&g&&r){const{reversed:e}=a,n=e?-1:1,[o,i]=r*n==1?[p,g]:[g,p];t.fillStyle=o,t.fillRect(d,u,f,h),t.fillStyle=i,t.fillRect(d,u+h,f,h)}}hd(t,d,u,f,s,c.palette.text.primary)}function _d(e,t,n,r,o,i){const{apolloRowHeight:a}=e,[s,l,c]=dd(e,n,r,o);fd(e,t,l,s,c,1*a,n,i)}const{drawDragPreview:vd}=md,bd={draw:function(e,t,n,r,o,i){const a=n.parent;if(!a)return void md.draw(e,t,n,r,0,i);const{cdsLocations:s}=a,l=s.find((e=>{const t=e.at(1===n.strand?0:-1)?.min,r=e.at(1===n.strand?-1:0)?.max;return n.min===t&&n.max===r}));if(!l)return;for(const o of l)yd(e,t,o,n.strand,r,i);const{selectedFeature:c}=e;rl(n,c)&&_d(e,t,n,r,i,"select")},drawDragPreview:vd,drawOverlay:_d,getContextMenuItems:function(){return[]},getLayout:function(e,t){return{byFeature:new Map([[t._id,0]]),byRow:[[{feature:t,rowInFeature:0}]],min:t.min,max:t.max}},isDraggable:!0};function xd(e,t,n,r,o,i){const{apolloRowHeight:a}=e,[,s,l]=dd(e,n,r,o),c=Math.round(.6*a),u=Math.round(c/2);fd(e,t,s,Math.round(u/2)+r*a,l,c,n,i)}const{drawDragPreview:wd}=md,Sd={draw:function(e,t,n,r,o,i){const{apolloRowHeight:a,canvasPatterns:s,selectedFeature:l,theme:c}=e,[,u,d]=dd(e,n,r,i),f=Math.round(.6*a),h=Math.round(f/2),p=Math.round(h/2)+r*a;if(d>2){t.fillStyle="rgb(211,211,211)",t.fillRect(u,p,d,f);const e=s.forward,r=s.backward,{strand:o}=n;if(e&&r&&o){const{reversed:n}=i,a=n?-1:1,[s,l]=o*a==1?[e,r]:[r,e];t.fillStyle=s,t.fillRect(u,p,d,h),t.fillStyle=l,t.fillRect(u,p+h,d,h)}}hd(t,u,p,d,f,c.palette.text.primary),rl(n,l)&&xd(e,t,n,r,i,"select")},drawDragPreview:wd,drawOverlay:xd,getContextMenuItems:function(e,t){const{apolloInternetAccount:n,changeManager:r,regions:i,selectedFeature:a,session:s}=e,[l]=i,c=e.getAssemblyId(l.assemblyName),u="admin"===(n?n.role:"admin"),d=[],f=Qs(t,e),h=o.getContainingView(e);if(f.upstream){const n=f.upstream;d.push({label:"Go to upstream exon",icon:el(t.strand,!0,h.displayedRegions.at(0)?.reversed),onClick:()=>{h.navTo(al(n,.1,h.totalBp)),Ws(e,n)}})}if(f.downstream){const n=f.downstream;d.push({label:"Go to downstream exon",icon:el(t.strand,!1,h.displayedRegions.at(0)?.reversed),onClick:()=>{h.navTo(al(n,.1,h.totalBp)),Ws(e,n)}})}return d.push({label:"Merge exons",disabled:!u,onClick:()=>{s.queueDialog((n=>[ec,{session:s,handleClose:()=>{n()},changeManager:r,sourceFeature:t,sourceAssemblyId:c,selectedFeature:a,setSelectedFeature:t=>{e.setSelectedFeature(t)}}]))}},{label:"Split exon",disabled:!u,onClick:()=>{s.queueDialog((n=>[fc,{session:s,handleClose:()=>{n()},changeManager:r,sourceFeature:t,sourceAssemblyId:c,selectedFeature:a,setSelectedFeature:t=>{e.setSelectedFeature(t)}}]))}}),d},getLayout:function(e,t){return{byFeature:new Map([[t._id,0]]),byRow:[[{feature:t,rowInFeature:0}]],min:t.min,max:t.max}},isDraggable:!0};function Cd(e,t){return kd(e,t).byRow.length}function Ad(e,t,n,r,o,i,a){if(a>0)return;const{apolloRowHeight:s}=e,[l,c,u]=dd(e,n,r,o);fd(e,t,c,l,u,Cd(e,n)*s,n,i)}function kd(e,t){const n={byFeature:new Map([[t._id,0]]),byRow:[[{feature:t,rowInFeature:0}]],min:t.min,max:t.max},{children:r}=t;if(!r)return n;n.byRow=[];const{getGlyph:o}=e;for(const[,i]of r){const r=o(i).getLayout(e,i),a=n.byRow.length;for(const[e,o]of r.byRow.entries())n.byRow.push([{feature:t,rowInFeature:a+e},...o]);for(const e of r.byFeature.entries()){const[t,r]=e;n.byFeature.set(t,r+a)}}return n}const{drawDragPreview:Nd}=md,Td={draw:function(e,t,r,o,i,a){if(i>0)return;const{apolloRowHeight:l,theme:c,selectedFeature:u,session:d}=e,[f,h,p]=dd(e,r,o,a),g=Cd(e,r)*l;if(p>2){const e=n.readConfObject(d.getPluginConfiguration(),"geneBackgroundColor",{featureType:r.type})??s.alpha(c.palette.background.paper,.6);t.fillStyle=e,t.fillRect(h,f,p,g)}hd(t,h,f,p,g,c.palette.text.primary),rl(r,u)&&Ad(e,t,r,o,a,"select",i)},drawDragPreview:Nd,drawOverlay:Ad,getContextMenuItems:function(){return[]},getLayout:kd,isDraggable:!1};function Rd(e,t){return Id(e,t).byRow.length}function Ed(e,t,n,r,o,i){const{apolloRowHeight:a}=e,[s,l,c]=dd(e,n,r,o);fd(e,t,l,s,c,Rd(e,n)*a,n,i)}function Id(e,t){const n={byFeature:new Map([[t._id,0]]),byRow:[[{feature:t,rowInFeature:0}]],min:t.min,max:t.max},{children:r}=t;if(!r)return n;const{getGlyph:o}=e;for(const[,i]of r){const r=o(i).getLayout(e,i),a=n.byRow.length;for(const[e,o]of r.byRow.entries())n.byRow.push([{feature:t,rowInFeature:a+e},...o]);for(const e of r.byFeature.entries()){const[t,r]=e;n.byFeature.set(t,r+a)}}return n}const{drawDragPreview:jd}=md,Dd={draw:function(e,t,n,r,o,i){if(o>0)return;const{apolloRowHeight:a,selectedFeature:l,theme:c}=e,[u,d,f]=dd(e,n,r,i),h=Rd(e,n)*a;f>2&&(t.fillStyle=s.alpha(c.palette.background.paper,.6),t.fillRect(d,u,f,h)),hd(t,d,u,f,h,c.palette.text.primary),md.draw(e,t,n,r,0,i),rl(n,l)&&Ed(e,t,n,r,i,"select")},drawDragPreview:jd,drawOverlay:Ed,getContextMenuItems:function(){return[]},getLayout:Id,isDraggable:!0};function*Od(e,t,n=1){if(e!==t)if(e<t)for(let r=e;r<t;r+=n)yield r;else for(let r=e;r>t;r-=n)yield r}function Fd(e,t,n,r,o,i){const{apolloRowHeight:a}=e,[s,l,c]=dd(e,n,r,o),u=a*function(e,t){return Md(e,t).byRow.length}(e,n);fd(e,t,l,s,c,u,n,i)}function Md(e,t){const n={byFeature:new Map([[t._id,0]]),byRow:[[{feature:t,rowInFeature:0}]],min:t.min,max:t.max},{children:r}=t;if(!r)return n;n.byRow=[];const o=function(e,t){const{children:n}=t;if(!n)return[];const{session:r}=e;return[...n.values()].filter((e=>Ys(e,r)))}(e,t),i=function(e,t){const{children:n}=t;if(!n)return[];const{session:r}=e;return[...n.values()].filter((e=>!Ys(e,r)))}(e,t);if(n.byFeature.set(t._id,0),0===i.length){const e=[];e.push({feature:t,rowInFeature:0});for(const t of o)e.push({feature:t,rowInFeature:0}),n.byFeature.set(t._id,0);return n.byRow.push(e),n}const{getGlyph:a,session:s}=e;let l=0;for(const[r,c]of i.entries()){const i=[];if(i.push({feature:t,rowInFeature:r+l}),Xs(c,s)){for(const e of o)i.push({feature:e,rowInFeature:l}),n.byFeature.set(e._id,l);i.push({feature:c,rowInFeature:l}),n.byFeature.set(c._id,l)}else{const t=a(c).getLayout(e,c).byRow.length;for(let e=0;e<t;e++)i.push({feature:c,rowInFeature:e}),n.byFeature.set(c._id,e);l+=t-1}n.byRow.push(i)}return n}const{drawDragPreview:Ld}=md,Pd={draw:function(e,t,n,r,o,i){!function(e,t,n,r,o){const{apolloRowHeight:i,lgv:a,theme:s}=e,{bpPerPx:l}=a,{reversed:c}=o,u=Math.round(ud(e,n,o)),d=Math.round(n.length/l),f=Math.round(i/2)+r*i;t.strokeStyle=s.palette.text.primary;const{strand:h=1}=n;t.beginPath();const p=h*(c?-1:1);let g=u-(-1===p?5:0),m=u+d+(-1===p?0:5);g=Math.max(g,0),m=Math.min(m,globalThis.innerWidth),t.moveTo(g,f),t.lineTo(m,f);const y=g+(-1===p?0:3),_=m-(-1===p?3:0),v=-1===p?3:-3,b=-1===p?Od(y,_,20):Od(_,y,20);for(const e of b)t.moveTo(e+v,f+v),t.lineTo(e,f),t.lineTo(e+v,f-v);t.stroke()}(e,t,n,r,i);const{selectedFeature:a}=e;rl(n,a)&&Fd(e,t,n,r,i,"select")},drawDragPreview:Ld,drawOverlay:Fd,getContextMenuItems:function(e,t){const{changeManager:n,regions:r,selectedFeature:i,session:a}=e,[s]=r,l=e.getAssemblyId(s.assemblyName),c=[];o.isSessionModelWithWidgets(a)&&c.splice(1,0,{label:"Open transcript editor",onClick:()=>{const e=a.addWidget("ApolloTranscriptDetails","apolloTranscriptDetails",{feature:t,assembly:l,changeManager:n,refName:s.refName});a.showWidget(e)}}),c.push({label:"Merge transcript",onClick:()=>{a.queueDialog((r=>[nc,{session:a,handleClose:()=>{r()},changeManager:n,sourceFeature:t,sourceAssemblyId:l,selectedFeature:i,setSelectedFeature:t=>{e.setSelectedFeature(t)}}]))}},{label:"Duplicate feature",onClick:()=>{a.queueDialog((r=>[hc,{session:a,handleClose:()=>{r()},changeManager:n,sourceFeature:t,sourceAssemblyId:l,selectedFeature:i,setSelectedFeature:t=>{e.setSelectedFeature(t)}}]))}});const{children:u}=t;return u?(0===[...u.values()].filter((e=>Xs(e,a))).length&&c.push({label:"Add coding sequence",onClick:()=>{a.queueDialog((e=>[bl,{session:a,handleClose:()=>{e()},changeManager:n,sourceFeature:t,sourceAssemblyId:l,refName:s.refName}]))}}),c):[]},getLayout:Md,isDraggable:!1};var Bd=a.createSvgIcon(i.jsx("path",{fillRule:"evenodd",d:"M20 3H4c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2M10 17H5v-2h5zm0-4H5v-2h5zm0-4H5V7h5zm4.82 6L12 12.16l1.41-1.41 1.41 1.42L17.99 9l1.42 1.42z"}),"FactCheck"),qd=a.createSvgIcon(i.jsx("path",{d:"m19.07 4.93-1.41 1.41C19.1 7.79 20 9.79 20 12c0 4.42-3.58 8-8 8s-8-3.58-8-8c0-4.08 3.05-7.44 7-7.93v2.02C8.16 6.57 6 9.03 6 12c0 3.31 2.69 6 6 6s6-2.69 6-6c0-1.66-.67-3.16-1.76-4.24l-1.41 1.41C15.55 9.9 16 10.9 16 12c0 2.21-1.79 4-4 4s-4-1.79-4-4c0-1.86 1.28-3.41 3-3.86v2.14c-.6.35-1 .98-1 1.72 0 1.1.9 2 2 2s2-.9 2-2c0-.74-.4-1.38-1-1.72V2h-1C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10c0-2.76-1.12-5.26-2.93-7.07"}),"TrackChanges");const Ud=p.observer((function({featureTypes:e,handleClose:t,onUpdate:n,session:r}){const[o,a]=u.useState(""),[l,c]=u.useState(e);return i.jsx(Bs,{open:!0,maxWidth:!1,"data-testid":"filter-features-dialog",title:"Filter features by type",handleClose:t,children:i.jsxs(s.DialogContent,{children:[i.jsx(s.DialogContentText,{children:"Select the feature types you want to display in the apollo track"}),i.jsxs(s.Grid,{container:!0,spacing:2,children:[i.jsx(s.Grid,{size:8,children:i.jsx(qs,{session:r,ontologyName:"Sequence Ontology",style:{width:"100%"},value:o,filterTerms:Cs,renderInput:e=>i.jsx(s.TextField,{...e,label:"Feature type",variant:"outlined",fullWidth:!0}),onChange:(e,t)=>{t&&(e=>{a(e)})(t)}})}),i.jsx(s.Grid,{size:4,children:i.jsx(s.Button,{variant:"contained",onClick:()=>{if(o){if(l.includes(o))return;n([...l,o]),c([...l,o])}},disabled:!o,style:{marginTop:9},size:"medium",children:"Add"})})]}),l.length>0&&i.jsxs("div",{children:[i.jsx("hr",{}),i.jsxs("div",{style:{width:300},children:[i.jsx(s.DialogContentText,{children:"Selected feature types:"}),i.jsx(s.Box,{sx:{display:"flex",flexWrap:"wrap",gap:.5},children:l.map((e=>i.jsx(s.Chip,{label:e,onDelete:()=>{(e=>{const t=l.filter((t=>t!==e));n(t),c(t)})(e)}},e)))})]})]})]})})})),zd=p.observer((function({model:e,handleClose:t}){const[n,r]=u.useState(`${e.zoomThresholdSetting}`);return i.jsx(h.Dialog,{open:!0,onClose:t,title:"Edit zoom threshold setting",children:i.jsxs(s.DialogContent,{children:[i.jsx(s.Typography,{children:"The zoom level in base pairs (bp) per pixel at which features are rendered in this Annotations track. Increasing the value will allow features to render when zooming out, but might impact performance."}),i.jsx(s.TextField,{label:"Threshold value (bpPerPx)",value:n,onChange:e=>{r(e.target.value)}}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{variant:"contained",onClick:()=>{e.setZoomThresholdSetting({zoomThreshold:+n}),t()},children:"Submit"}),i.jsx(s.Button,{variant:"contained",color:"secondary",onClick:()=>{t()},children:"Cancel"})]})]})})})),$d=ma()((e=>({canvasContainer:{position:"relative",left:0},canvas:{position:"absolute",left:0},center:{display:"flex",justifyContent:"center"},ellipses:{textOverflow:"ellipsis",overflow:"hidden"},avatar:{position:"static",height:"100%",width:"100%",overflow:"visible",color:e.palette.warning.light,backgroundColor:e.palette.warning.contrastText},box:{position:"absolute",overflow:"visible"},badge:{display:"inline-block"},loading:{position:"absolute",right:e.spacing(3),zIndex:10,pointerEvents:"none",textAlign:"right"},locked:{position:"absolute",right:e.spacing(3),top:e.spacing(6),zIndex:1,pointerEvents:"none",textAlign:"right"}})));function Hd(e,t,n){const r=new Map;for(const t of e)(r.get(t.message)??r.set(t.message,[]).get(t.message)).push(t);const o=[];for(const[e,n]of r.entries()){if(0===n.length)continue;n.sort(((e,t)=>e.start-t.start));let r=[n[0]],i=n[0].start,a=n[0].start+t;const s=()=>{const t=r.map((e=>e.start)).sort(((e,t)=>e-t)),n=Math.floor(t.length/2),s=r[0].ids;o.push({_id:r[0]._id,message:e,start:t.length%2?t[n]:(t[n-1]+t[n])/2,count:r.length,members:[...r],range:{min:i,max:a},featureIds:s})};for(let e=1;e<n.length;e++){const o=n[e],l=o.start,c=l+t;l<=a?(r.push(o),l<i&&(i=l),c>a&&(a=c)):(s(),r=[o],i=l,a=c)}s()}return o.sort(((e,t)=>e.message.localeCompare(t.message)||e.start-t.start)),o}function Gd(e,t,n){return"M"===e?t.palette.startCodon:"*"===e?n?t.palette.text.primary:t.palette.stopCodon:void 0}function Vd(e,t){const n=e.toUpperCase();return"A"===n||"C"===n||"G"===n||"T"===n?t.palette.bases[n].main:"lightgray"}function Wd(e,t){return function(e,t){return function(e,t){const i=function(e,t){return function(e,t){const i=function(e,t){return r.BaseDisplay.named("BaseLinearApolloDisplay").props({type:l.types.literal("LinearApolloDisplay"),configuration:n.ConfigurationReference(t),graphical:!0,table:!1,showCheckResults:!0,zoomThreshold:200,heightPreConfig:l.types.maybe(l.types.refinement("displayHeight",l.types.number,(e=>e>=20))),filteredFeatureTypes:l.types.array(l.types.string),loadingState:!1}).views((e=>{const{configuration:t,renderProps:n}=e;return{renderProps:()=>({...n(),...b.getParentRenderProps(e),config:t.renderer})}})).volatile((()=>({scrollTop:0}))).views((e=>({get lgv(){return o.getContainingView(e)},get height(){return e.heightPreConfig?e.heightPreConfig:e.graphical&&e.table?400:e.graphical?100:200},get loading(){return e.loadingState},get zoomThresholdSetting(){return e.zoomThreshold??n.getConf(e,"zoomThreshold")}}))).views((e=>({get rendererTypeName(){return e.configuration.renderer.type},get session(){return o.getSession(e)},get regions(){return e.lgv.dynamicBlocks.contentBlocks.map((({assemblyName:e,end:t,refName:n,start:r})=>({assemblyName:e,refName:n,start:Math.round(r),end:Math.round(t)})))},regionCannotBeRendered(){if(e.lgv&&e.lgv.bpPerPx>=e.zoomThreshold)return"Zoom in to see annotations"}}))).views((e=>({get apolloInternetAccount(){const[t]=e.regions,{internetAccounts:r}=l.getRoot(e),{assemblyName:o}=t,{assemblyManager:i}=e.session,a=i.get(o);if(!a)throw new Error(`No assembly found with name ${o}`);const{internetAccountConfigId:s}=n.getConf(a,["sequence","metadata"]);return r.find((e=>n.getConf(e,"internetAccountId")===s))},get changeManager(){return e.session.apolloDataStore.changeManager},getAssemblyId(t){const{assemblyManager:n}=e.session,r=n.get(t);if(!r)throw new Error(`Could not find assembly named ${t}`);return r.name},get selectedFeature(){return e.session.apolloSelectedFeature},get hoveredFeature(){return e.session.apolloHoveredFeature}}))).actions((e=>({setScrollTop(t){e.scrollTop=t},setHeight:t=>(e.heightPreConfig=Math.max(t,20),e.height),resizeHeight(t){const n=e.height;return this.setHeight(e.height+t)-n},showGraphicalOnly(){e.graphical=!0,e.table=!1},showTableOnly(){e.graphical=!1,e.table=!0},showGraphicalAndTable(){e.graphical=!0,e.table=!0},toggleShowCheckResults(){e.showCheckResults=!e.showCheckResults},updateFilteredFeatureTypes(t){e.filteredFeatureTypes=l.cast(t)},setLoading(t){e.loadingState=t},setZoomThresholdSetting({zoomThreshold:t}){e.zoomThreshold=t}}))).views((e=>{const{filteredFeatureTypes:t,trackMenuItems:n}=e;return{trackMenuItems(){const{graphical:r,table:i,showCheckResults:a,session:s}=e,[c]=e.regions,{assemblyName:u}=c,d=s.apolloDataStore.getBackendDriver(u),f=[...n(),{type:"subMenu",label:"Appearance",subMenu:[{label:"Show graphical display",type:"radio",checked:r&&!i,onClick:()=>{e.showGraphicalOnly()}},{label:"Show table display",type:"radio",checked:i&&!r,onClick:()=>{e.showTableOnly()}},{label:"Show both graphical and table display",type:"radio",checked:i&&r,onClick:()=>{e.showGraphicalAndTable()}},{label:"Check Results",type:"checkbox",checked:a,onClick:()=>{e.toggleShowCheckResults()}},{label:"Change zoom threshold",onClick:()=>{o.getSession(e).queueDialog((t=>[zd,{model:e,handleClose:t}]))}}]},{label:"Filter features by type",onClick:()=>{const{session:n}=e;e.session.queueDialog((r=>[Ud,{session:n,handleClose:()=>{r()},featureTypes:l.getSnapshot(t),onUpdate:t=>{e.updateFilteredFeatureTypes(t)}}]))}}];return d instanceof Sl&&f.push({label:"Import annotations",icon:uo,onClick:()=>{s.queueDialog((e=>[Wl,{session:s,assemblyName:u,handleClose:()=>{e()}}]))}}),f.push({label:"Export annotations",icon:Gl,onClick:()=>{const[t]=e.regions,{assemblyName:n}=t,r=e.getAssemblyId(n);if(!r)return;const{session:o}=e;o.queueDialog((e=>[Vl,{session:o,handleClose:()=>{e()},assembly:r}]))}},{label:"View Change Log",icon:qd,onClick:()=>{const[t]=e.regions,{assemblyName:n}=t,r=e.getAssemblyId(n);if(!r)return;const{session:o}=e;o.queueDialog((e=>[ic,{session:o,handleClose:()=>{e()},assembly:r}]))}},{label:"View Check Results",icon:Bd,onClick:()=>{const[t]=e.regions,{assemblyName:n}=t,r=e.getAssemblyId(n);if(!r)return;const{session:o}=e;o.queueDialog((e=>[cc,{session:o,handleClose:()=>{e()},assembly:r}]))}}),f}}})).actions((e=>({setSelectedFeature(t){e.session.apolloSetSelectedFeature(t)},setHoveredFeature(t){e.session.apolloSetHoveredFeature(t)},showFeatureDetailsWidget(t,n){const[r]=e.regions,{assemblyName:o,refName:i}=r,a=e.getAssemblyId(o);if(!a)return;const{session:s}=e,{changeManager:l}=s.apolloDataStore,[c,u]=n??["ApolloFeatureDetailsWidget","apolloFeatureDetailsWidget"],d=s.addWidget(c,u,{feature:t,assembly:a,refName:i,changeManager:l});s.showWidget(d)},afterAttach(){l.addDisposer(e,c.autorun((()=>{e.lgv.initialized&&!e.regionCannotBeRendered()&&(e.setLoading(!0),e.session.apolloDataStore.loadFeatures(e.regions).then((()=>{setTimeout((()=>{e.setLoading(!1)}),1e3)})))}),{name:"LinearApolloDisplayLoadFeatures",delay:1e3}))}})))}(0,t);return i.named("LinearApolloDisplayLayouts").props({cleanupBoundary:2e5}).volatile((()=>({seenFeatures:c.observable.map()}))).views((e=>({getAnnotationFeatureById:t=>e.seenFeatures.get(t),getGlyph:t=>Js(t,e.session)?Td:Ks(t,e.session)?Pd:Ys(t,e.session)?Sd:Xs(t,e.session)?bd:t.children?.size?Dd:md}))).actions((e=>({addSeenFeature(t){e.seenFeatures.set(t._id,t)},deleteSeenFeature(t){e.seenFeatures.delete(t)}}))).views((e=>({getCanonicalRefName(t,n){const{assemblyManager:r}=e.session,o=r.get(t);if(!o)throw new Error("no assembly in layout");const i=o.getCanonicalRefName(n);if(!i)throw new Error("no canonical refName in layout");return i}}))).views((e=>({isFeatureDisplayed(t){const n=e.getCanonicalRefName(t.assemblyId,t.refSeq);return e.lgv.displayedRegions.some((r=>{const{end:i,refName:a,start:s}=r;return!(e.filteredFeatureTypes.length>0&&!e.filteredFeatureTypes.includes(t.type)||n!==a||!o.doesIntersect2(s,i,t.min,t.max))}))}}))).views((e=>({get layouts(){const t=new Map;for(const[n,r]of e.seenFeatures.entries()){if(!l.isAlive(r)){e.deleteSeenFeature(n);continue}if(!e.isFeatureDisplayed(r))continue;const i=e.getGlyph(r).getLayout(e,r),a=e.getCanonicalRefName(r.assemblyId,r.refSeq);let s=t.get(r.assemblyId);s||(s=new Map,t.set(r.assemblyId,s));const c=s.get(a);if(!c){s.set(a,i);continue}let u=0;e:for(;;){let e=c.byRow.at(u);if(!e){c.byRow.push(...i.byRow);for(const e of i.byFeature.entries()){const[t,n]=e;c.byFeature.set(t,n+u)}c.min=Math.min(c.min,i.min),c.max=Math.max(c.max,i.max);break e}const t=u+i.byRow.length-1;let n=u;for(;e&&u<=t;){for(const t of e.values())if(o.doesIntersect2(i.min,i.max,t.feature.min,t.feature.max)){u+=1;continue e}n+=1,e=c.byRow.at(n)}for(let e=0;e<i.byRow.length;e++){const t=c.byRow.at(u+e);t?t.push(...i.byRow[e]):c.byRow.push(i.byRow[e])}for(const e of i.byFeature.entries()){const[t,n]=e;c.byFeature.set(t,n+u)}c.min=Math.min(c.min,i.min),c.max=Math.max(c.max,i.max);break e}}return t},getRowForFeature(t){const n=e.getCanonicalRefName(t.assemblyId,t.refSeq);return this.layouts.get(t.assemblyId)?.get(n)?.byFeature.get(t._id)},getFeaturesAtPosition(e,t,n,r){const o=this.layouts.get(e);if(!o)return[];const i=o.get(t);if(!i)return[];const a=i.byRow.at(n);return a?a.filter((({feature:e})=>r>=e.min&&r<=e.max)).map((e=>e.feature)):[]}}))).views((e=>({highestRow(t){const n=e.layouts.get(t);return n?Math.max(0,...[...n.values()].map((e=>e.byRow.length))):0}}))).actions((e=>({afterAttach(){l.addDisposer(e,c.autorun((()=>{if(e.lgv.initialized&&!e.regionCannotBeRendered()){for(const[t,n]of e.seenFeatures.entries()){let r=!1;for(const t of e.regions)if(o.doesIntersect2(t.start-e.cleanupBoundary,t.end+e.cleanupBoundary,n.min,n.max)){r=!0;break}r||e.deleteSeenFeature(t)}for(const t of e.regions){const n=e.session.apolloDataStore.assemblies.get(t.assemblyName),r=n?.getByRefName(t.refName),i=r?.features;if(i)for(const[,n]of i)o.doesIntersect2(t.start,t.end,n.min,n.max)&&!e.seenFeatures.has(n._id)&&e.addSeenFeature(n)}}}),{name:"LinearApolloDisplaySetSeenFeatures",delay:1e3}))}})))}(0,t).named("LinearApolloDisplayRendering").props({apolloRowHeight:20,detailsMinHeight:200,detailsHeight:200,isShown:!0,filteredTranscripts:l.types.array(l.types.string)}).volatile((()=>({canvas:null,overlayCanvas:null,collaboratorCanvas:null,theme:s.createTheme()}))).views((e=>({featuresHeight:t=>(e.highestRow(t)+1)*e.apolloRowHeight,get canvasPatterns(){const t={forward:null,backward:null},n=document.createElement("canvas"),r=n?.getContext("2d");if(!r)return t;const o=10;n.width=n.height=o;const{theme:i}=e,a="light"===i.palette.mode?"rgba(0,0,0,0)":"rgba(0,0,0,0.75)",s="light"===i.palette.mode?"rgba(255,255,255,0.25)":"rgba(0,0,0,0.50)",l=["forward","backward"];for(const e of l){const i="forward"===e?r.createLinearGradient(0,o,o,0):r.createLinearGradient(0,0,o,o);i.addColorStop(0,a),i.addColorStop(.25,a),i.addColorStop(.25,s),i.addColorStop(.5,s),i.addColorStop(.5,a),i.addColorStop(.75,a),i.addColorStop(.75,s),i.addColorStop(1,s),r.fillStyle=i,r.clearRect(0,0,o,o),r.fillRect(0,0,o,o),t[e]=r.createPattern(n,"repeat")}return t}}))).actions((e=>({toggleShown(){e.isShown=!e.isShown},setDetailsHeight(t){e.detailsHeight=e.isShown?Math.max(Math.min(t,e.height-100),Math.min(e.height,e.detailsMinHeight)):t},setCanvas(t){e.canvas=t},setOverlayCanvas(t){e.overlayCanvas=t},setCollaboratorCanvas(t){e.collaboratorCanvas=t},setTheme(t){e.theme=t}}))).actions((e=>({afterAttach(){l.addDisposer(e,c.autorun((()=>{if(!e.lgv.initialized||e.regionCannotBeRendered())return;const t=e.collaboratorCanvas?.getContext("2d");if(t){t.clearRect(0,0,e.lgv.dynamicBlocks.totalWidthPx,e.featuresHeight(e.lgv.assemblyNames[0]));for(const n of e.session.collaborators){const{locations:r}=n;if(0===r.length)continue;let o=0;for(const i of e.lgv.displayedRegions){for(const a of r){if(a.refSeq!==i.refName)continue;const{end:r,refSeq:s,start:l}=a,c=e.lgv.bpToPx({refName:s,coord:l,regionNumber:o});if(!c)continue;const u=c.offsetPx-e.lgv.offsetPx,d=(r-l)/e.lgv.bpPerPx;t.fillStyle="rgba(0,255,0,.2)",t.fillRect(u,1,d,100),t.fillStyle="black",t.fillText(n.name,u+1,11,d-2)}o++}}}}),{name:"LinearApolloDisplayRenderCollaborators"})),l.addDisposer(e,c.autorun((()=>{const{canvas:t,layouts:n,lgv:r}=e;if(!r.initialized||e.regionCannotBeRendered()||!t)return;const{dynamicBlocks:i,offsetPx:a}=r,s=t.getContext("2d");if(!s)return;const l=n.get(r.assemblyNames[0]);if(l){s.clearRect(0,0,t.width,t.height);for(const n of i.contentBlocks){const r=n.offsetPx-a;s.save(),s.beginPath(),s.rect(r,0,n.widthPx,t.height),s.clip();const i=l.get(n.refName);if(!i)return;const{byRow:c}=i;for(const[t,r]of c.entries())for(const i of r){const{feature:r,rowInFeature:a}=i;o.doesIntersect2(n.start,n.end,r.min,r.max)&&e.getGlyph(r).draw(e,s,r,t,a,n)}for(const[t,r]of c.entries())for(const i of r){const{feature:r,rowInFeature:a}=i;o.doesIntersect2(n.start,n.end,r.min,r.max)&&e.getGlyph(r).drawOverlay(e,s,r,t,n,"highlight",a)}s.restore()}}}),{name:"LinearApolloDisplayRenderFeatures"}))}})))}(0,t);return i.named("LinearApolloDisplayMouseEvents").volatile((()=>({apolloDragging:null,cursor:void 0}))).views((e=>({getMousePosition:t=>function(e,t){const n=e.currentTarget,{clientX:r,clientY:o}=e,{left:i,top:a}=n.getBoundingClientRect(),s=r-i,l=o-a,{coord:c,index:u,assemblyName:d,refName:f}=t.pxToBp(s);return{x:s,y:l,assemblyName:d,refName:f,bp:c,regionNumber:u}}(t,e.lgv),getFeaturesAtMousePosition(t){const{bp:n,assemblyName:r,refName:o,y:i}=t,a=Math.floor(i/e.apolloRowHeight),s=e.layouts.get(r)?.get(o);return s?e.getFeaturesAtPosition(r,o,a,n):[]}}))).actions((e=>({continueDrag(t,n){if(!e.apolloDragging)throw new Error("continueDrag() called with no current drag in progress");n.stopPropagation(),e.apolloDragging={...e.apolloDragging,current:t}},setDragging(t){e.apolloDragging=t??null}}))).actions((e=>({setCursor(t){e.cursor!==t&&(e.cursor=t)},updateFilteredTranscripts(e){}}))).actions((()=>({onClick(){}})))}(0,t).views((e=>({contextMenuItems(t){const n=e.getMousePosition(t),r=e.getFeaturesAtMousePosition(n);if(1===r.length)return il(e,r[0]);const o=[];for(const t of r){const n=e.getGlyph(t);o.push({label:t.type,subMenu:[...il(e,t),...n.getContextMenuItems(e,t)]})}return o}}))).actions((e=>{function t(t){"Escape"===t.key&&e.setDragging()}return{startDrag(n,r,o,i=!1){globalThis.addEventListener("keydown",t,!0),e.apolloDragging={start:n,current:n,feature:r,edge:o,shrinkParent:i}},endDrag(){if(globalThis.removeEventListener("keydown",t,!0),!e.apolloDragging)throw new Error("endDrag() called with no current drag in progress");const{current:n,edge:r,feature:o,start:i,shrinkParent:a}=e.apolloDragging;if(Math.abs(n.x-i.x)<=4)return e.setDragging(),void e.setCursor();const{displayedRegions:s}=e.lgv,l=e.getAssemblyId(s[i.regionNumber].assemblyName),c=cl(o,n.bp,r,a),u="max"===r?new Tt({typeName:"LocationEndChange",changedIds:c.map((e=>e.featureId)),changes:c.map((e=>({featureId:e.featureId,oldEnd:e.oldLocation,newEnd:e.newLocation}))),assembly:l}):new Et({typeName:"LocationStartChange",changedIds:c.map((e=>e.featureId)),changes:c.map((e=>({featureId:e.featureId,oldStart:e.oldLocation,newStart:e.newLocation}))),assembly:l});e.changeManager.submit(u),e.setDragging(),e.setCursor()}}})).actions((e=>({onMouseDown(t){const n=e.getMousePosition(t),r=e.getFeaturesAtMousePosition(n);for(const o of r.toReversed())if(e.getGlyph(o).isDraggable){const r=pd(n,o,e);if(r)return t.stopPropagation(),void e.startDrag(n,o,r,!0)}},onMouseMove(t){const n=e.getMousePosition(t);if(e.apolloDragging)return e.setCursor("col-resize"),void e.continueDrag(n,t);const r=e.getFeaturesAtMousePosition(n);let o=r.at(-1);if(o&&Xs(o,e.session)){const t=r.at(-2);t&&!Ys(t,e.session)&&(o=t)}o?e.setHoveredFeature({feature:o,bp:n.bp}):e.setHoveredFeature();for(const t of r.toReversed())if(e.getGlyph(t).isDraggable&&pd(n,t,e))return void e.setCursor("col-resize");e.setCursor()},onMouseLeave(t){e.setDragging(),e.setHoveredFeature()},onMouseUp(t){if(e.apolloDragging)return void e.endDrag();const n=e.getMousePosition(t),r=e.getFeaturesAtMousePosition(n);let o=r.at(-1);if(o&&Xs(o,e.session)){const t=r.at(-2);t&&!Ys(t,e.session)&&(o=t)}o?(Ws(e,o),e.setSelectedFeature(o)):e.setSelectedFeature()}}))).actions((e=>({afterAttach(){l.addDisposer(e,c.autorun((()=>{const{lgv:t,overlayCanvas:n}=e;if(!t.initialized||e.regionCannotBeRendered()||!n)return;const{dynamicBlocks:r,offsetPx:i}=t,a=n.getContext("2d");if(!a)return;a.clearRect(0,0,n.width,n.height);const{apolloDragging:s,hoveredFeature:l}=e;if(!l)return;const{feature:c}=l,u=e.getGlyph(c),d=e.getRowForFeature(c);if(void 0!==d)for(const t of r.contentBlocks){const r=t.offsetPx-i;if(a.save(),a.beginPath(),a.rect(r,0,t.widthPx,n.height),a.clip(),t.assemblyName===c.assemblyId&&o.doesIntersect2(t.start,t.end,c.min,c.max)&&u.drawOverlay(e,a,c,d,t,"hover"),s){const{current:n,start:r,feature:i}=s,l=Math.min(n.bp,r.bp),c=Math.max(n.bp,r.bp);if(o.doesIntersect2(t.start,t.end,l,c)){const n=e.getGlyph(i),r=e.getRowForFeature(i);void 0!==r&&n.drawDragPreview(e,a,i,r,t)}}a.restore()}}),{name:"LinearApolloDisplayRenderMouseoverAndDrag"}))}})))}(0,t).props({tabularEditor:l.types.optional(cd,{})}).named("LinearApolloDisplay")}const Jd=n.ConfigurationSchema("LinearApolloReferenceSequenceDisplay",{},{explicitIdentifier:"displayId",explicitlyTyped:!0});function Kd(e,t,n){const r=t<=1?[2,1,0,7,6,5]:[2,1,0,5,4,3];n&&r.reverse(),r.unshift(0);const o=r.at(e);if(void 0===o)throw new Error("could not find row");return o}function Yd(e,t,n,r){return r.offsetPx-n+(r.reversed?r.end-e.max:e.min-r.start)/t}function Xd(e,t,n,r,o,i,a=!1){e.fillStyle=a?i.palette.action.disabled:i.palette.action.focus,e.fillRect(t,n,r,o),e.strokeStyle=a?i.palette.text.secondary:i.palette.text.primary,e.strokeStyle=i.palette.text.primary,e.strokeRect(t,n,r,o)}function Zd(e,t,n,r,o,i,a,s=!1){const l=function(e,t,n){if(!(t>1||void 0===e))return n?1===e?4:3:1===e?3:4}(t.strand,n,i.reversed);void 0!==l&&Xd(e,Yd(t,n,r,i),l*o,t.length/n,o,a,s)}function Qd(e,t,n,r,i,a,s,l=!1){const c=t.parent;if(!c)return;const u=c.cdsLocations.find((e=>{const n=e.at(1===t.strand?0:-1)?.min,r=e.at(1===t.strand?-1:0)?.max;return t.min===n&&t.max===r}));if(u)for(const c of u){const u=Kd(o.getFrame(c.min,c.max,t.strand??1,c.phase),n,a.reversed);Xd(e,Yd(c,n,r,a),u*i,(c.max-c.min)/n,i,s,l)}}function ef(e,t,n,r,o){const i=Math.min(r,10);e.fillStyle="#000",e.font=`${i}px`;const a=e.measureText(o).width,s=Math.round(t+(r-a)/2);e.fillText(o,s,n+10)}function tf(e,t,n,r,o,i,a,s){const l=t<=1?[3,2,1,0,0,-1,-2,-3]:[3,2,1,-1,-2,-3];s&&l.reverse();for(const[t,s]of l.entries()){const l=n.palette.framesCDS.at(s)?.main;if(!l)continue;const c=t*a;e.fillStyle=r?n.palette.background.default:l,e.fillRect(o,c,i,a),r&&hd(e,o,c,i,a,n.palette.grey[200])}}function nf(e,t,n,r,i,a,s){if(1/i<1)return;const l=Math.round(r+n/i),c=Math.round(r+(n+1)/i)-l,u=[-1,1];for(const n of u){const r=(1===n?3:4)*a,u=1===n?t:o.revcom(t);e.fillStyle=Vd(u,s),e.fillRect(l,r,c,a),1/i>=12&&(hd(e,l,r,c,a,s.palette.text.disabled),ef(e,l,r,c,u))}}function rf(e,t,n,r,i,a,s,l,c,u,d){const f=(s<=1?[0,2,1,0,7,6,5]:[0,2,1,0,5,4,3]).map((e=>e*c)),h=[-1,1];for(const p of h){const h=o.getFrame(l,l+3,p,0),g=f.at(h);if(void 0===g)continue;const m=Math.round(n+r/s),y=Math.round(n+(r+3)/s)-m,_=1===p?t:o.revcom(t),v=o.defaultCodonTable[_],b=Gd(v,i,a);b&&(d&&"*"==v||u&&"*"!=v)&&(e.fillStyle=b,e.fillRect(m,g,y,c)),1/s>=4&&(hd(e,m,g,y,c,i.palette.text.disabled),ef(e,m,g,y,v))}}function of(e,t){return function(e,t){const i=function(e,t){return r.BaseDisplay.named("BaseLinearApolloReferenceSequenceDisplay").props({type:l.types.literal("LinearApolloReferenceSequenceDisplay"),configuration:n.ConfigurationReference(t),showStartCodons:!1,showStopCodons:!0,highContrast:!1,heightPreConfig:l.types.maybe(l.types.refinement("displayHeight",l.types.number,(e=>e>=20))),sequenceRowHeight:15}).views((e=>{const{configuration:t,renderProps:n}=e;return{renderProps:()=>({...n(),...b.getParentRenderProps(e),config:t.renderer})}})).views((e=>({get lgv(){return o.getContainingView(e)}}))).views((e=>({get rendererTypeName(){return e.configuration.renderer.type},get session(){return o.getSession(e)},get regions(){return e.lgv.dynamicBlocks.contentBlocks.map((({assemblyName:e,end:t,refName:n,start:r})=>({assemblyName:e,refName:n,start:Math.round(r),end:Math.round(t)})))},regionCannotBeRendered(){if(e.lgv&&e.lgv.bpPerPx>3)return"Zoom in to see sequence"}}))).views((e=>({get expandedRegions(){return e.lgv.dynamicBlocks.contentBlocks.map((e=>{const{assemblyName:t,end:n,refName:r,start:o}=e,{parentRegion:i}=e;return{assemblyName:t,refName:r,start:Math.round(Math.max(o-5,i.start)),end:Math.round(Math.min(n+5,i.end))}}))},get apolloInternetAccount(){const[t]=e.regions,{internetAccounts:r}=l.getRoot(e),{assemblyName:o}=t,{assemblyManager:i}=e.session,a=i.get(o);if(!a)throw new Error(`No assembly found with name ${o}`);const{internetAccountConfigId:s}=n.getConf(a,["sequence","metadata"]);return r.find((e=>n.getConf(e,"internetAccountId")===s))},get changeManager(){return e.session.apolloDataStore.changeManager},getAssemblyId(t){const{assemblyManager:n}=e.session,r=n.get(t);if(!r)throw new Error(`Could not find assembly named ${t}`);return r.name},get selectedFeature(){return e.session.apolloSelectedFeature},get hoveredFeature(){return e.session.apolloHoveredFeature},get height(){const{sequenceRowHeight:t}=e;return e.lgv.bpPerPx<=1?8*t:6*t}}))).volatile((()=>({scrollTop:0}))).actions((e=>({setScrollTop(t){e.scrollTop=t},setHeight:t=>(e.heightPreConfig=Math.max(t,20),e.height),resizeHeight(t){const n=e.height;return this.setHeight(e.height+t)-n},toggleShowStartCodons(){e.showStartCodons=!e.showStartCodons},toggleShowStopCodons(){e.showStopCodons=!e.showStopCodons},toggleHighContrast(){e.highContrast=!e.highContrast}}))).views((e=>{const{trackMenuItems:t}=e;return{trackMenuItems(){const{showStartCodons:n,showStopCodons:r,highContrast:o}=e;return[...t(),{type:"subMenu",label:"Appearance",subMenu:[{label:"Show start codons",type:"checkbox",checked:n,onClick:()=>{e.toggleShowStartCodons()}},{label:"Show stop codons",type:"checkbox",checked:r,onClick:()=>{e.toggleShowStopCodons()}},{label:"Use high contrast colors",type:"checkbox",checked:o,onClick:()=>{e.toggleHighContrast()}}]}]}}})).actions((e=>({afterAttach(){l.addDisposer(e,c.autorun((()=>{e.lgv.initialized&&!e.regionCannotBeRendered()&&e.lgv.bpPerPx<=3&&e.session.apolloDataStore.loadRefSeq(e.expandedRegions)}),{name:"LinearApolloReferenceSequenceDisplayLoadFeatures",delay:1e3}))}})))}(0,t);return i.named("LinearApolloReferenceSequenceDisplayRendering").volatile((()=>({seqTrackCanvas:null,seqTrackOverlayCanvas:null,theme:s.createTheme()}))).actions((e=>({setSeqTrackCanvas(t){e.seqTrackCanvas=t},setSeqTrackOverlayCanvas(t){e.seqTrackOverlayCanvas=t},setTheme(t){e.theme=t},afterAttach(){l.addDisposer(e,c.autorun((()=>{const{lgv:t,seqTrackCanvas:n,theme:r,highContrast:i,showStartCodons:a,showStopCodons:s,sequenceRowHeight:l,session:c}=e;if(!t.initialized||e.regionCannotBeRendered()||!n)return;if(3/t.bpPerPx<1)return;const{bpPerPx:u,offsetPx:d,dynamicBlocks:f}=t;!function(e,t,n,r,i,a,s,l,c,u){const d=e.getContext("2d");if(!d)return;d.clearRect(0,0,e.width,e.height);const{apolloDataStore:f}=u;for(const e of i.contentBlocks){const i=e.offsetPx-r;tf(d,n,t,a,i,e.widthPx,c,e.reversed);const u=f.assemblies.get(e.assemblyName),h=u?.getByRefName(e.refName),p=Math.floor(e.start),g=Math.ceil(e.end);let m=h?.getSequence(p,g);if(!m)return;m=m.toUpperCase(),e.reversed&&(m=o.revcom(m));const y=i-(e.reversed?g-e.end:e.start-p)/n;for(let r=0;r<m.length;r++){const o=e.reversed?g-r:p+r,i=m.slice(r,r+3);nf(d,m[r],r,y,n,c,t),3===i.length&&rf(d,i,y,r,t,a,n,o,c,s,l)}}}(n,r,u,d,f,i,a,s,l,c)}),{name:"LinearApolloReferenceSequenceDisplayRenderSequence"})),l.addDisposer(e,c.autorun((()=>{const{seqTrackOverlayCanvas:t}=e;if(!e.lgv.initialized||e.regionCannotBeRendered()||!t)return;const n=t.getContext("2d");if(!n)return;n.clearRect(0,0,e.lgv.dynamicBlocks.totalWidthPx,e.height);const{hoveredFeature:r,selectedFeature:o,lgv:i,sequenceRowHeight:a,session:s,theme:l}=e;if(!r&&!o)return;const{bpPerPx:c,dynamicBlocks:u,offsetPx:d}=i;!function(e,t,n,r,o,i,a,s,l,c){const{featureTypeOntology:u}=a.apolloDataStore.ontologyManager;if(!u)throw new Error("featureTypeOntology is undefined");for(const a of c.contentBlocks){t.save(),t.beginPath(),t.rect(a.offsetPx-l,0,a.widthPx,e.height),t.clip();for(const e of[r,n?.feature].filter((e=>void 0!==e)))u.isTypeOf(e.type,"CDS")?Qd(t,e,s,l,o,a,i,e._id===r?._id):Zd(t,e,s,l,o,a,i,e._id===r?._id);t.restore()}}(t,n,r,o,a,l,s,c,d,u)}),{name:"LinearApolloReferenceSequenceDisplayRenderSequenceHighlight"}))}})))}(0,t).named("LinearApolloReferenceSequenceDisplay")}const af=p.observer((function(e){const t=s.useTheme(),{model:n}=e,{height:r,regionCannotBeRendered:a,setSeqTrackCanvas:l,setSeqTrackOverlayCanvas:c,setTheme:d}=n,{classes:f}=$d();u.useEffect((()=>{d(t)}),[t,d]);const h=o.getContainingView(n),p=a();return p?i.jsx(s.Alert,{severity:"warning",classes:{message:f.ellipses},slotProps:{root:{className:f.center}},children:i.jsx(s.Tooltip,{title:p,children:i.jsx("div",{children:p})})}):i.jsx(i.Fragment,{children:3/h.bpPerPx>=1?i.jsxs("div",{className:f.canvasContainer,style:{width:h.dynamicBlocks.totalWidthPx,height:r},children:[i.jsx("canvas",{ref:async e=>{await Promise.resolve(),l(e)},width:h.dynamicBlocks.totalWidthPx,height:r,className:f.canvas,"data-testid":"seqTrackCanvas"}),i.jsx("canvas",{ref:async e=>{await Promise.resolve(),c(e)},width:h.dynamicBlocks.totalWidthPx,height:r,className:f.canvas,"data-testid":"seqTrackOverlayCanvas"})]}):null})})),sf=n.ConfigurationSchema("LinearApolloSixFrameDisplay",{},{explicitIdentifier:"displayId",explicitlyTyped:!0}),lf=p.observer((function({sourceFeature:e,filteredTranscripts:t,handleClose:n,onUpdate:r}){const o=[];if(e.children)for(const[,t]of e.children){const e=t.attributes.get("gff_id")?.toString();e&&o.push(e)}const[a,l]=u.useState(t);return i.jsx(Bs,{open:!0,maxWidth:!1,"data-testid":"filter-transcripts-dialog",title:"Filter transcripts by ID",handleClose:n,children:i.jsxs(s.DialogContent,{children:[i.jsx(s.DialogContentText,{children:"Select the alternate transcripts you want to display in the apollo track"}),i.jsx(s.Grid,{container:!0,spacing:2,children:i.jsx(s.Grid,{size:8,children:i.jsx(s.FormGroup,{children:o.map((e=>i.jsx(s.FormControlLabel,{control:i.jsx(s.Checkbox,{checked:!a.includes(e),onChange:()=>{(e=>{const t=a.includes(e)?a.filter((t=>t!==e)):[...a,e];r(t),l(t)})(e)},slotProps:{input:{"aria-label":"controlled"}}}),label:e},e)))})})})]})})}));let cf=null,uf=null,df=null,ff=null;const hf=globalThis.document.createElement("canvas");if(hf?.getContext)for(const e of["forward","backward"])for(const t of["light","dark"]){const n=document.createElement("canvas"),r=10;n.width=n.height=r;const o=n.getContext("2d");if(o){const i="light"===t?"rgba(0,0,0,0)":"rgba(0,0,0,0.75)",a="light"===t?"rgba(255,255,255,0.25)":"rgba(0,0,0,0.50)",s="forward"===e?o.createLinearGradient(0,r,r,0):o.createLinearGradient(0,0,r,r);s.addColorStop(0,i),s.addColorStop(.25,i),s.addColorStop(.25,a),s.addColorStop(.5,a),s.addColorStop(.5,i),s.addColorStop(.75,i),s.addColorStop(.75,a),s.addColorStop(1,a),o.fillStyle=s,o.fillRect(0,0,10,10),"forward"===e?"light"===t?cf=o.createPattern(n,"repeat"):df=o.createPattern(n,"repeat"):"light"===t?uf=o.createPattern(n,"repeat"):ff=o.createPattern(n,"repeat")}}function pf(e,t){for(const n of e)if(Ss(n,t))return!0;return!1}function gf(e,t,n){const{filteredTranscripts:r,session:i}=n,{apolloDataStore:a}=i,{featureTypeOntology:s}=a.ontologyManager;if(!s)throw new Error("featureTypeOntology is undefined");const l=s.isTypeOf(t.type,"transcript"),c=t.attributes.get("gff_id")?.toString();if(c&&r.includes(c))return;const{bp:u,refName:d,regionNumber:f,x:h}=e,{lgv:p}=n;if(l){const e=t;if(!e.children)return;const n=[],r=[];for(const t of e.children.values()){const e=s.isTypeOf(t.type,"exon"),o=s.isTypeOf(t.type,"CDS");e?n.push(t):o&&r.push(t)}const i=n.find((e=>{const[t,n]=o.intersection2(u,u+1,e.min,e.max);return void 0!==t&&void 0!==n}));if(i){const e=tl(i,d,f,p);if(e){const t=nl(i,h,e);if(t)return t}}for(const t of e.cdsLocations)for(const e of t){const t=tl(e,d,f,p);if(t){const e=r.find((e=>{const[t,n]=o.intersection2(u,u+1,e.min,e.max);return void 0!==t&&void 0!==n}));if(e){const n=nl(e,h,t);if(n)return n}}}}}const mf={draw:function(e,t,n,r,i){const{apolloRowHeight:a,lgv:l,session:c,theme:u,highestRow:d,filteredTranscripts:f,selectedFeature:h,showFeatureLabels:p}=r,{bpPerPx:g,displayedRegions:m,offsetPx:y}=l,_=m[i],{refName:v,reversed:b}=_,x=a,w=x,S=x,C=x,A=p?2:1,k=u.palette.text.primary,{attributes:N,children:T,min:R,strand:E}=t;if(!T)return;const{apolloDataStore:I}=c,{featureTypeOntology:j}=I.ontologyManager;if(!j)throw new Error("featureTypeOntology is undefined");const D=[],O=(l.bpToPx({refName:v,coord:R,regionNumber:i})?.offsetPx??0)-y,F=t.length/g,M=b?O-F:O,L=(1==E?3:4)*A*x;e.fillStyle=u.palette.text.primary,e.fillRect(M,L,F,C),e.fillStyle=rl(t,h)?s.alpha("rgb(0,0,0)",.7):s.alpha(u.palette.background.paper,.7),e.fillRect(M+1,L+1,F-2,C-2);const P=rl(t,h),B={x:M,y:L,h:C,text:N.get("gff_id")?.toString(),color:k,isSelected:P};P?D.unshift(B):D.push(B);const q="dark"===u.palette.mode?df:cf,U="dark"===u.palette.mode?ff:uf,z=b?-1:1;let $=null,H=null;E&&([$,H]=E*z==1?[q,U]:[U,q]),$&&H&&(e.fillStyle=$,e.fillRect(M+1,L+1,F-2,(C-2)/2),e.fillStyle=H,e.fillRect(M+1,L+(C-2)/2,F-2,(C-2)/2));const G=new Set;for(const[,t]of T){if(!j.isTypeOf(t.type,"transcript")&&!j.isTypeOf(t.type,"pseudogenic_transcript"))continue;const{children:n,cdsLocations:r}=t;if(!n)continue;const a=t.attributes.get("gff_id")?.toString();if(a&&f.includes(a))continue;for(const[,t]of n){if(!j.isTypeOf(t.type,"exon"))continue;const n=(l.bpToPx({refName:v,coord:t.min,regionNumber:i})?.offsetPx??0)-y,r=t.length/g,o=b?n-r:n,a=L+(C-w)/2,c=rl(t,h);if(e.fillStyle=u.palette.text.primary,e.fillRect(o,a,r,w),r>2){e.clearRect(o+1,a+1,r-2,w-2),e.fillStyle=c?"rgb(0,0,0)":s.alpha("#f5f500",.6),e.fillRect(o+1,a+1,r-2,w-2),$&&H&&(e.fillStyle=$,e.fillRect(o+1,a+1,r-2,(w-2)/2),e.fillStyle=H,e.fillRect(o+1,a+1+(w-2)/2,r-2,(w-2)/2));const n={x:o,y:a,h:w,text:t.attributes.get("gff_id")?.toString(),color:k,isSelected:c};c?D.unshift(n):D.push(n)}}const c=rl(t,h?.parent);let m=0,_=0;for(const n of r){let r=0,a=0,s=1;for(const f of n.toSorted(((e,t)=>e.max-t.max)))if(h&&c&&j.isTypeOf(h.type,"CDS")||!pf(G,f)){const n=(f.max-f.min)/g,w=(l.bpToPx({refName:v,coord:f.min,regionNumber:i})?.offsetPx??0)-y;m=b?w-n:w,e.fillStyle=u.palette.text.primary;const C=o.getFrame(f.min,f.max,t.strand??1,f.phase),k=(p?[0,4,2,0,14,12,10]:[0,2,1,0,7,6,5]).at(C);if(void 0===k)continue;if(_=k*x,e.fillRect(m,_,n,S),s>1){const t=[(m-a)/2+a,Math.max(C<0?x*A*d+1:1,Math.min(r,_)-x/2)];e.strokeStyle="rgb(0, 128, 128)",e.beginPath(),e.moveTo(a,r),e.lineTo(...t),e.stroke(),e.moveTo(...t),e.lineTo(m,_+x/2),e.stroke()}if(a=m+n,r=_+x/2,s+=1,n>2){e.clearRect(m+1,_+1,n-2,S-2);const t=u.palette.framesCDS.at(C)?.main,r=t??"rgb(171,71,188)";e.fillStyle=r,e.fillStyle=h&&c&&j.isTypeOf(h.type,"CDS")?"rgb(0,0,0)":r,e.fillRect(m+1,_+1,n-2,S-2),$&&H&&(e.fillStyle=$,e.fillRect(m+1,_+1,n-2,(S-2)/2),e.fillStyle=H,e.fillRect(m+1,_+(S-2)/2,n-2,(S-2)/2))}G.add(f)}}const N={x:m,y:_,h:S,text:t.attributes.get("gff_id")?.toString(),color:k,isSelected:c};c?D.unshift(N):D.push(N)}p&&function(e,t,n="10px sans-serif"){for(let r=t.length-1;r>=0;--r){const i=t[r];e.fillStyle=i.color;const a=i.x+1,s=i.y+i.h,l=o.measureText(i.text,10);i.isSelected&&(e.font="bold ".concat(n)),i.text&&(e.clearRect(a-5,s,l+10,i.h),e.fillText(i.text,a,s+11,l),e.font=n)}}(e,D)},drawDragPreview:function(e,t){const{apolloDragging:n,apolloRowHeight:r,lgv:o,theme:i}=e,{bpPerPx:a,displayedRegions:l,offsetPx:c}=o;if(!n)return;const{current:u,edge:d,feature:f,start:h}=n,p=Math.floor(h.y/r),g=l[h.regionNumber],m=(g.reversed?g.end-f[d]:f[d]-g.start)/a-c,y=Math.min(u.x,m),_=p*r,v=Math.abs(u.x-m),b=1*r;t.strokeStyle=i.palette.info.main,t.setLineDash([6]),t.strokeRect(y,_,v,b),t.fillStyle=s.alpha(i.palette.info.main,.2),t.fillRect(y,_,v,b)},drawOverlay:function(e,t){const{hoveredFeature:n,apolloRowHeight:r,filteredTranscripts:i,lgv:a,highestRow:s,session:l,showFeatureLabels:c}=e;if(!n)return;const{feature:u}=n,{apolloDataStore:d}=l,{featureTypeOntology:f}=d.ontologyManager;if(!f)throw new Error("featureTypeOntology is undefined");if(!f.isTypeOf(u.type,"transcript"))return;const h=u.attributes.get("gff_id")?.toString();if(h&&i.includes(h))return;const p=e.getFeatureLayoutPosition(u);if(!p)return;const{bpPerPx:g,displayedRegions:m,offsetPx:y}=a,{layoutIndex:_}=p,v=m[_],{refName:b,reversed:x}=v,w=r,S=w,C=c?2:1,{cdsLocations:A,strand:k}=u;for(const e of A){let n=0,r=0,i=1;for(const l of e.toSorted(((e,t)=>e.max-t.max))){const e=(l.max-l.min)/g,u=(a.bpToPx({refName:b,coord:l.min,regionNumber:_})?.offsetPx??0)-y,d=x?u-e:u,f=o.getFrame(l.min,l.max,k??1,l.phase),h=(c?[0,4,2,0,14,12,10]:[0,2,1,0,7,6,5]).at(f);if(void 0===h)continue;const p=h*w;if(i>1){const e=[(d-r)/2+r,Math.max(f<0?w*C*s+1:1,Math.min(n,p)-w/2)];t.strokeStyle="rgb(0, 0, 0)",t.lineWidth=2,t.beginPath(),t.moveTo(r,n),t.lineTo(...e),t.stroke(),t.moveTo(...e),t.lineTo(d,p+w/2),t.stroke()}r=d+e,n=p+w/2,i+=1,e>2&&(t.fillStyle="rgba(255,0,0,0.6)",t.fillRect(d,p,e,S))}}},drawTooltip:function(e,t){const{hoveredFeature:n,apolloRowHeight:r,filteredTranscripts:i,lgv:a,session:l,showFeatureLabels:c,theme:u}=e;if(!n)return;const{feature:d,bp:f}=n,{featureTypeOntology:h}=l.apolloDataStore.ontologyManager;if(!h)throw new Error("featureTypeOntology is undefined");if(!h.isTypeOf(d.type,"transcript"))return;const{attributes:p,strand:g,type:m}=d,y=e.getFeatureLayoutPosition(d);if(!y)return;const _=p.get("gff_id")?.toString();if(_&&i.includes(_))return;const{layoutIndex:v}=y,{bpPerPx:b,displayedRegions:x,offsetPx:w}=a,S=x[v],{refName:C,reversed:A}=S,k=r;let N,T="Loc: ";for(const e of d.cdsLocations)for(const t of e)if(f>=t.min&&f<=t.max){N=t;break}if(!N)return;const{max:R,min:E,phase:I}=N;T+=`${E+1}–${R}`;let j=(a.bpToPx({refName:C,coord:A?R:E,regionNumber:v})?.offsetPx??0)-w;const D=o.getFrame(E,R,g??1,I),O=(c?[0,4,2,0,14,12,10]:[0,2,1,0,7,6,5]).at(D);if(void 0===O)return;const F=O*k,M=(R-E)/b,L=`Type: ${N.type}`,P=p.get("gff_name")?.find((e=>""!==e)),B=[t.measureText(L).width,t.measureText(T).width];P&&B.push(t.measureText(`Parent Type: ${m}`).width,t.measureText(`Parent Name: ${P}`).width);const q=Math.max(...B);j=j+M+5,t.fillStyle=s.alpha(u.palette.text.primary,.7),t.fillRect(j,F,q+4,4===B.length?55:35),t.beginPath(),t.moveTo(j,F),t.lineTo(j-5,F+5),t.lineTo(j,F+10),t.fill(),t.fillStyle=u.palette.background.default;let U=F+12;t.fillText(L,j+2,U),P&&(U+=12,t.fillText(`Parent Type: ${m}`,j+2,U),U+=12,t.fillText(`Parent Name: ${P}`,j+2,U)),U+=12,t.fillText(T,j+2,U)},getContextMenuItems:function(e,t){const{apolloInternetAccount:n,hoveredFeature:r,changeManager:i,filteredTranscripts:a,regions:s,selectedFeature:c,session:u}=e,[d]=s,f=e.getAssemblyId(d.assemblyName),h=[],p=n?n.role:"admin",g=!(p&&["admin","user"].includes(p));if(!r)return h;const{featureTypeOntology:m}=u.apolloDataStore.ontologyManager;if(!m)throw new Error("featureTypeOntology is undefined");if(ul(t)){const{bp:n,feature:r}=t;let s=Ca(r,n);Xs(r,u)&&(s=Ca(r,n,!0));for(const t of s){const n=t.attributes.get("gff_id")?.toString();if(n&&a.includes(n))continue;const r=il(e,t);if(Ys(t,u)){const n=Qs(t,e),a=o.getContainingView(e);if(n.upstream){const o=n.upstream;r.push({label:"Go to upstream exon",icon:el(t.strand,!0,a.displayedRegions.at(0)?.reversed),onClick:()=>{a.navTo(al(o,.1,a.totalBp)),Ws(e,o)}})}if(n.downstream){const o=n.downstream;r.push({label:"Go to downstream exon",icon:el(t.strand,!1,a.displayedRegions.at(0)?.reversed),onClick:()=>{a.navTo(al(o,.1,a.totalBp)),Ws(e,o)}})}r.push({label:"Merge exons",disabled:g,onClick:()=>{u.queueDialog((n=>[ec,{session:u,handleClose:()=>{n()},changeManager:i,sourceFeature:t,sourceAssemblyId:f,selectedFeature:c,setSelectedFeature:t=>{e.setSelectedFeature(t)}}]))}},{label:"Split exon",disabled:g,onClick:()=>{u.queueDialog((n=>[fc,{session:u,handleClose:()=>{n()},changeManager:i,sourceFeature:t,sourceAssemblyId:f,selectedFeature:c,setSelectedFeature:t=>{e.setSelectedFeature(t)}}]))}})}m.isTypeOf(t.type,"gene")&&r.push({label:"Filter alternate transcripts",onClick:()=>{u.queueDialog((n=>[lf,{handleClose:()=>{n()},sourceFeature:t,filteredTranscripts:l.getSnapshot(a),onUpdate:t=>{e.updateFilteredTranscripts(t)}}]))}}),h.push({label:t.type,subMenu:r})}}return h},getContextMenuItemsForFeature:il,onMouseDown:function(e,t,n){const{feature:r}=t,o=gf(t,r,e);o&&(n.stopPropagation(),e.startDrag(t,o.feature,o.edge,!0))},onMouseLeave:function(){},onMouseMove:function(e,t){if(ul(t)){const{feature:n,bp:r}=t;if(e.setHoveredFeature({feature:n,bp:r}),gf(t,n,e))return void e.setCursor("col-resize")}e.setCursor()},onMouseUp:function(e,t){if(!e.apolloDragging&&ul(t)){const{feature:n}=t,{session:r}=e,{apolloDataStore:o}=r,{featureTypeOntology:i}=o.ontologyManager;if(e.setSelectedFeature(n),!i)throw new Error("featureTypeOntology is undefined");let a=!1;for(const[,e]of n.children??[])if(i.isTypeOf(e.type,"CDS")||i.isTypeOf(e.type,"exon")){a=!0;break}(i.isTypeOf(n.type,"transcript")||i.isTypeOf(n.type,"pseudogenic_transcript"))&&a?e.showFeatureDetailsWidget(n,["ApolloTranscriptDetails","apolloTranscriptDetails"]):e.showFeatureDetailsWidget(n)}}};function yf(e,t,n,r,i,a,s,l,c,u,d,f){const h=(u?[0,4,2,0,14,12,10]:[0,2,1,0,7,6,5]).map((e=>e*c)),p=[-1,1];for(const u of p){const p=o.getFrame(l,l+3,u,0),g=h.at(p);if(void 0===g)continue;const m=Math.round(n+r/s),y=0===Math.round(3/s)?1:Math.round(3/s),_=1===u?t:o.revcom(t),v=o.defaultCodonTable[_],b=Gd(v,i,a);b&&(f&&"*"==v||d&&"*"!=v)&&(e.fillStyle=b,e.fillRect(m,g,y,c))}}function _f(e,t){return function(e,t){return function(e,t){const i=function(e,t){return function(e,t){const i=function(e,t){return r.BaseDisplay.named("BaseLinearApolloSixFrameDisplay").props({type:l.types.literal("LinearApolloSixFrameDisplay"),configuration:n.ConfigurationReference(t),graphical:!0,table:!1,showFeatureLabels:!0,showStartCodons:!1,showStopCodons:!0,showCheckResults:!0,zoomThreshold:200,heightPreConfig:l.types.maybe(l.types.refinement("displayHeight",l.types.number,(e=>e>=20))),filteredFeatureTypes:l.types.array(l.types.string)}).views((e=>{const{configuration:t,renderProps:n}=e;return{renderProps:()=>({...n(),...b.getParentRenderProps(e),config:t.renderer})}})).volatile((()=>({scrollTop:0}))).views((e=>({get lgv(){return o.getContainingView(e)},get height(){return e.heightPreConfig?e.heightPreConfig:e.graphical&&e.table?500:e.graphical?e.showFeatureLabels?400:200:300},get zoomThresholdSetting(){return e.zoomThreshold??n.getConf(e,"zoomThreshold")}}))).views((e=>({get rendererTypeName(){return e.configuration.renderer.type},get session(){return o.getSession(e)},get regions(){return e.lgv.dynamicBlocks.contentBlocks.map((({assemblyName:e,end:t,refName:n,start:r})=>({assemblyName:e,refName:n,start:Math.round(r),end:Math.round(t)})))},regionCannotBeRendered(){if(e.lgv&&e.lgv.bpPerPx>=e.zoomThreshold)return"Zoom in to see annotations"}}))).views((e=>({get apolloInternetAccount(){const[t]=e.regions,{internetAccounts:r}=l.getRoot(e),{assemblyName:o}=t,{assemblyManager:i}=e.session,a=i.get(o);if(!a)throw new Error(`No assembly found with name ${o}`);const{internetAccountConfigId:s}=n.getConf(a,["sequence","metadata"]);return r.find((e=>n.getConf(e,"internetAccountId")===s))},get changeManager(){return e.session.apolloDataStore.changeManager},getAssemblyId(t){const{assemblyManager:n}=e.session,r=n.get(t);if(!r)throw new Error(`Could not find assembly named ${t}`);return r.name},get selectedFeature(){return e.session.apolloSelectedFeature},get hoveredFeature(){return e.session.apolloHoveredFeature}}))).actions((e=>({setScrollTop(t){e.scrollTop=t},setHeight:t=>(e.heightPreConfig=Math.max(t,20),e.height),resizeHeight(t){const n=e.height;return this.setHeight(e.height+t)-n},showGraphicalOnly(){e.graphical=!0,e.table=!1},showTableOnly(){e.graphical=!1,e.table=!0},showGraphicalAndTable(){e.graphical=!0,e.table=!0},toggleShowFeatureLabels(){e.showFeatureLabels=!e.showFeatureLabels},toggleShowStartCodons(){e.showStartCodons=!e.showStartCodons},toggleShowStopCodons(){e.showStopCodons=!e.showStopCodons},toggleShowCheckResults(){e.showCheckResults=!e.showCheckResults},updateFilteredFeatureTypes(t){e.filteredFeatureTypes=l.cast(t)},setZoomThresholdSetting({zoomThreshold:t}){e.zoomThreshold=t}}))).views((e=>{const{filteredFeatureTypes:t,trackMenuItems:n}=e;return{trackMenuItems(){const{graphical:r,table:i,showFeatureLabels:a,showStartCodons:s,showStopCodons:c,showCheckResults:u}=e;return[...n(),{type:"subMenu",label:"Appearance",subMenu:[{label:"Show graphical display",type:"radio",checked:r&&!i,onClick:()=>{e.showGraphicalOnly()}},{label:"Show table display",type:"radio",checked:i&&!r,onClick:()=>{e.showTableOnly()}},{label:"Show both graphical and table display",type:"radio",checked:i&&r,onClick:()=>{e.showGraphicalAndTable()}},{label:"Feature Labels",type:"checkbox",checked:a,onClick:()=>{e.toggleShowFeatureLabels()}},{label:"Show start codons",type:"checkbox",checked:s,onClick:()=>{e.toggleShowStartCodons()}},{label:"Show stop codons",type:"checkbox",checked:c,onClick:()=>{e.toggleShowStopCodons()}},{label:"Check Results",type:"checkbox",checked:u,onClick:()=>{e.toggleShowCheckResults()}},{label:"Change zoom threshold",onClick:()=>{o.getSession(e).queueDialog((t=>[zd,{model:e,handleClose:t}]))}}]},{label:"Filter features by type",onClick:()=>{const{session:n}=e;e.session.queueDialog((r=>[Ud,{session:n,handleClose:()=>{r()},featureTypes:l.getSnapshot(t),onUpdate:t=>{e.updateFilteredFeatureTypes(t)}}]))}}]}}})).actions((e=>({setSelectedFeature(t){e.session.apolloSetSelectedFeature(t)},setHoveredFeature(t){e.session.apolloSetHoveredFeature(t)},showFeatureDetailsWidget(t,n){const[r]=e.regions,{assemblyName:o,refName:i}=r,a=e.getAssemblyId(o);if(!a)return;const{session:s}=e,{changeManager:l}=s.apolloDataStore,[c,u]=n??["ApolloFeatureDetailsWidget","apolloFeatureDetailsWidget"],d=s.addWidget(c,u,{feature:t,assembly:a,refName:i,changeManager:l});s.showWidget(d)},afterAttach(){l.addDisposer(e,c.autorun((()=>{e.lgv.initialized&&!e.regionCannotBeRendered()&&(e.session.apolloDataStore.loadFeatures(e.regions),e.lgv.bpPerPx<=e.zoomThreshold&&e.session.apolloDataStore.loadRefSeq(e.regions))}),{name:"LinearApolloSixFrameDisplayLoadFeatures",delay:1e3}))}})))}(0,t);return i.named("LinearApolloSixFrameDisplayLayouts").props({featuresMinMaxLimit:5e5}).volatile((()=>({seenFeatures:c.observable.map()}))).views((e=>({get featuresMinMax(){const{assemblyManager:t}=e.session;return e.lgv.displayedRegions.map((n=>{const r=t.get(n.assemblyName);let i,a;const{end:s,refName:l,start:c}=n;for(const[,t]of e.seenFeatures)l!==r?.getCanonicalRefName(t.refSeq)||!o.doesIntersect2(c,s,t.min,t.max)||t.length>e.featuresMinMaxLimit||(void 0===i&&({min:i}=t),void 0===a&&({max:a}=t),t.minWithChildren<i&&({min:i}=t),t.maxWithChildren>a&&({max:a}=t));if(void 0!==i&&void 0!==a)return[i,a]}))},getGlyph:e=>mf,featureLabelSpacer:t=>e.showFeatureLabels?2*t-1:t}))).actions((e=>({addSeenFeature(t){e.seenFeatures.set(t._id,t)},deleteSeenFeature(t){e.seenFeatures.delete(t)}}))).views((e=>({get geneTrackRowNums(){return[4,5].map((t=>e.featureLabelSpacer(t)))}}))).views((e=>({get featureLayouts(){const{assemblyManager:t}=e.session;return e.lgv.displayedRegions.map(((n,r)=>{const i=t.get(n.assemblyName),a=new Map;if(!e.featuresMinMax[r])return a;const{end:s,refName:c,start:u}=n;for(const[t,n]of e.seenFeatures.entries()){if(!l.isAlive(n)){e.deleteSeenFeature(t);continue}if(c!==i?.getCanonicalRefName(n.refSeq)||!o.doesIntersect2(u,s,n.min,n.max))continue;const{featureTypeOntology:r}=e.session.apolloDataStore.ontologyManager;if(!r)throw new Error("featureTypeOntology is undefined");if(Zs(n,e.session)){const t=1==n.strand?e.geneTrackRowNums[0]:e.geneTrackRowNums[1];a.get(t)||a.set(t,[]);const i=a.get(t);i?.push({rowNum:t,feature:n});const{children:s}=n;if(!s)continue;for(const[,t]of s)if(r.isTypeOf(t.type,"transcript")){const{cdsLocations:n,strand:i,children:s}=t;if(s)for(const[,t]of s){if(!r.isTypeOf(t.type,"exon"))continue;const n=1==t.strand?e.geneTrackRowNums[0]:e.geneTrackRowNums[1],o=a.get(n);o?.push({rowNum:n,feature:t})}for(const r of n)for(const n of r){const r=o.getFrame(n.min,n.max,i??1,n.phase),s=(e.showFeatureLabels?[0,5,3,1,15,13,11]:[0,2,1,0,8,7,6]).at(r);if(void 0===s)continue;a.get(s)||a.set(s,[]);const l=a.get(s);l?.push({rowNum:s,feature:t})}}}}return a}))},getFeatureLayoutPosition(e){const{featureLayouts:t}=this;for(const[n,r]of t.entries())for(const[,t]of r)for(const{feature:r}of t)if(e._id===r._id)return{layoutIndex:n,layoutRow:0,featureRow:0}}}))).views((e=>({get highestRow(){return 5}}))).actions((e=>({afterAttach(){l.addDisposer(e,c.autorun((()=>{if(e.lgv.initialized&&!e.regionCannotBeRendered())for(const t of e.regions){const n=e.session.apolloDataStore.assemblies.get(t.assemblyName),r=n?.getByRefName(t.refName),i=r?.features;if(i)for(const[,n]of i)o.doesIntersect2(t.start,t.end,n.min,n.max)&&!e.seenFeatures.has(n._id)&&e.addSeenFeature(n)}}),{name:"LinearApolloSixFrameDisplaySetSeenFeatures",delay:1e3}))}})))}(0,t).named("LinearApolloSixFrameDisplayRendering").props({apolloRowHeight:20,detailsMinHeight:200,detailsHeight:200,lastRowTooltipBufferHeight:120,isShown:!0,filteredTranscripts:l.types.array(l.types.string)}).volatile((()=>({canvas:null,overlayCanvas:null,collaboratorCanvas:null,theme:s.createTheme()}))).views((e=>({get featuresHeight(){return(e.highestRow+1)*e.apolloRowHeight*(e.showFeatureLabels?2:1)+e.lastRowTooltipBufferHeight}}))).actions((e=>({toggleShown(){e.isShown=!e.isShown},setDetailsHeight(t){e.detailsHeight=e.isShown?Math.max(Math.min(t,e.height-100),Math.min(e.height,e.detailsMinHeight)):t},setCanvas(t){e.canvas=t},setOverlayCanvas(t){e.overlayCanvas=t},setCollaboratorCanvas(t){e.collaboratorCanvas=t},setTheme(t){e.theme=t}}))).actions((e=>({afterAttach(){l.addDisposer(e,c.autorun((()=>{if(!e.lgv.initialized||e.regionCannotBeRendered())return;const t=e.collaboratorCanvas?.getContext("2d");if(t){t.clearRect(0,0,e.lgv.dynamicBlocks.totalWidthPx,e.featuresHeight);for(const n of e.session.collaborators){const{locations:r}=n;if(0===r.length)continue;let o=0;for(const i of e.lgv.displayedRegions){for(const a of r){if(a.refSeq!==i.refName)continue;const{end:r,refSeq:s,start:l}=a,c=e.lgv.bpToPx({refName:s,coord:l,regionNumber:o});if(!c)continue;const u=c.offsetPx-e.lgv.offsetPx,d=(r-l)/e.lgv.bpPerPx;t.fillStyle="rgba(0,255,0,.2)",t.fillRect(u,1,d,100),t.fillStyle="black",t.fillText(n.name,u+1,11,d-2)}o++}}}}),{name:"LinearApolloSixFrameDisplayRenderCollaborators"})),l.addDisposer(e,c.autorun((()=>{const{apolloRowHeight:t,canvas:n,featureLayouts:r,featuresHeight:i,lgv:a,session:s,theme:l,showFeatureLabels:c,showStartCodons:u,showStopCodons:d}=e;if(!a.initialized||e.regionCannotBeRendered())return;const{bpPerPx:f,offsetPx:h,displayedRegions:p,dynamicBlocks:g}=a,m=n?.getContext("2d");if(m){m.clearRect(0,0,g.totalWidthPx,i);for(const[t,n]of r.entries()){const r=p[t];for(const[i,a]of n.entries())for(const{feature:n}of a){if(!Zs(n,e.session))continue;if(!o.doesIntersect2(r.start,r.end,n.min,n.max))continue;const{topLevelFeature:a}=n,s=e.getGlyph(a);void 0!==s&&s.draw(m,a,i,e,t)}}if(u||d){const{apolloDataStore:e}=s;for(const n of g.contentBlocks){const r=e.assemblies.get(n.assemblyName),o=r?.getByRefName(n.refName),i=Math.floor(n.start),a=Math.ceil(n.end);let s=o?.getSequence(i,a);if(!s)break;s=s.toUpperCase();const p=Math.round(n.offsetPx-h-(n.start-i)/f);for(let e=0;e<s.length;e++){const n=i+e;yf(m,s.slice(e,e+3),p,e,l,!0,f,n,t,c,u,d)}}}}}),{name:"LinearApolloSixFrameDisplayRenderFeatures"}))}})))}(0,t);return i.named("LinearApolloSixFrameDisplayMouseEvents").volatile((()=>({apolloDragging:null,cursor:void 0}))).views((e=>({getMousePosition(t){const n=function(e,t){const n=e.currentTarget,{clientX:r,clientY:o}=e,{left:i,top:a}=n.getBoundingClientRect(),s=r-i,l=o-a,{coord:c,index:u,refName:d}=t.pxToBp(s);return{x:s,y:l,refName:d,bp:c,regionNumber:u}}(t,e.lgv),{bp:r,regionNumber:i,y:a}=n,s=Math.floor(a/e.apolloRowHeight)+1,l=e.featureLayouts[i].get(s);if(!l)return n;const{featureTypeOntology:c}=e.session.apolloDataStore.ontologyManager;if(!c)throw new Error("featureTypeOntology is undefined");const u=e.geneTrackRowNums.includes(s)?l.find((e=>"exon"==e.feature.type&&r>=e.feature.min&&r<=e.feature.max))??l.find((e=>r>=e.feature.min&&r<=e.feature.max)):l.find((t=>{const{feature:n}=t,i=n.attributes.get("gff_id")?.toString();if(!c.isTypeOf(n.type,"transcript"))return!1;for(const t of n.cdsLocations)for(const a of t){const t=o.getFrame(a.min,a.max,n.strand??1,a.phase),l=(e.showFeatureLabels?[0,5,3,1,15,13,11]:[0,2,1,0,8,7,6]).at(t);if(s===l&&r>=a.min&&r<=a.max)return void 0===i||!e.filteredTranscripts.includes(i)}return!1}));if(!u)return n;const{feature:d}=u;return{...n,feature:d}}}))).actions((e=>({continueDrag(t,n){if(!e.apolloDragging)throw new Error("continueDrag() called with no current drag in progress");n.stopPropagation(),e.apolloDragging={...e.apolloDragging,current:t}},setDragging(t){e.apolloDragging=t??null}}))).actions((e=>({setCursor(t){e.cursor!==t&&(e.cursor=t)},updateFilteredTranscripts(t){e.filteredTranscripts=l.cast(t)}}))).actions((()=>({onClick(){}})))}(0,t).views((e=>({contextMenuItems(t){const{hoveredFeature:n}=e;if(!n)return[];const r=e.getMousePosition(t),{topLevelFeature:o}=n.feature,i=e.getGlyph(o);return ul(r)?i.getContextMenuItems(e,r):[]}}))).actions((e=>({startDrag(t,n,r,o=!1){e.apolloDragging={start:t,current:t,feature:n,edge:r,shrinkParent:o}},endDrag(){if(!e.apolloDragging)throw new Error("endDrag() called with no current drag in progress");const{current:t,edge:n,feature:r,start:o,shrinkParent:i}=e.apolloDragging;if(Math.abs(t.x-o.x)<=4)return e.setDragging(),void e.setCursor();const{displayedRegions:a}=e.lgv,s=e.getAssemblyId(a[o.regionNumber].assemblyName),l=cl(r,t.bp,n,i),c="max"===n?new Tt({typeName:"LocationEndChange",changedIds:l.map((e=>e.featureId)),changes:l.map((e=>({featureId:e.featureId,oldEnd:e.oldLocation,newEnd:e.newLocation}))),assembly:s}):new Et({typeName:"LocationStartChange",changedIds:l.map((e=>e.featureId)),changes:l.map((e=>({featureId:e.featureId,oldStart:e.oldLocation,newStart:e.newLocation}))),assembly:s});e.changeManager.submit(c),e.setDragging(),e.setCursor()}}))).actions((e=>({onMouseDown(t){const n=e.getMousePosition(t);ul(n)&&e.getGlyph(n.feature).onMouseDown(e,n,t)},onMouseMove(t){const n=e.getMousePosition(t);if(e.apolloDragging)return e.setCursor("col-resize"),void e.continueDrag(n,t);ul(n)?e.getGlyph(n.feature).onMouseMove(e,n,t):(e.setHoveredFeature(),e.setCursor())},onMouseLeave(t){e.setDragging(),e.setHoveredFeature();const n=e.getMousePosition(t);ul(n)&&e.getGlyph(n.feature).onMouseLeave(e,n,t)},onMouseUp(t){const n=e.getMousePosition(t);ul(n)?e.getGlyph(n.feature).onMouseUp(e,n,t):e.setSelectedFeature(),e.apolloDragging&&e.endDrag()}}))).actions((e=>({afterAttach(){l.addDisposer(e,c.autorun((()=>{if(!e.lgv.initialized||e.regionCannotBeRendered())return;const t=e.overlayCanvas?.getContext("2d");if(!t)return;t.clearRect(0,0,e.lgv.dynamicBlocks.totalWidthPx,e.featuresHeight);const{apolloDragging:n,hoveredFeature:r}=e;if(!r)return;const o=e.getGlyph(r.feature);o.drawOverlay(e,t),o.drawTooltip(e,t),n&&e.getGlyph(n.feature.topLevelFeature).drawDragPreview(e,t)}),{name:"LinearApolloSixFrameDisplayRenderMouseoverAndDrag"}))}})))}(0,t).props({tabularEditor:l.types.optional(cd,{})}).named("LinearApolloSixFrameDisplay")}const vf=n.ConfigurationSchema("ApolloPlugin",{ontologies:l.types.array(Fs),featureTypeOntologyName:{description:"Name of the feature type ontology",type:"string",defaultValue:"Sequence Ontology"},hasRole:{description:"Flag used internally by jbrowse-plugin-apollo",type:"boolean",defaultValue:!1},skippedAttributesOnCopy:{description:"Feature attribute keys to skip when copying features",type:"stringArray",defaultValue:[]},geneBackgroundColor:{description:"Color for feature background",type:"string",defaultValue:"jexl:geneBackgroundColor(featureType)",contextVariable:["featureType"]}},{actions:e=>({addOntology(t){e.ontologies.push(t)}})}),bf=(e,t)=>{const{featureTypeOntology:n}=t.apolloDataStore.ontologyManager;if(!n)throw new Error("featureTypeOntology is undefined");return n.isTypeOf(e.type,"gene")||n.isTypeOf(e.type,"transcript")||n.isTypeOf(e.type,"pseudogene")||n.isTypeOf(e.type,"pseudogenic_transcript")},xf=(e,t)=>{const{featureTypeOntology:n}=t.apolloDataStore.ontologyManager;if(!n)throw new Error("featureTypeOntology is undefined");return n.isTypeOf(e.type,"gene")||n.isTypeOf(e.type,"pseudogene")},wf=(e,t)=>{const{featureTypeOntology:n}=t.apolloDataStore.ontologyManager;if(!n)throw new Error("featureTypeOntology is undefined");return n.isTypeOf(e.type,"transcript")||n.isTypeOf(e.type,"pseudogenic_transcript")};function Sf(e){const{attributes:t}=e,n=["gene_name","gene_id","gene_stable_id"];for(const e of n){const n=t?.[e];if(n?.[0])return n[0]}return""}const Cf=e=>{const t=function(e){const{attributes:t}=e,n=["name","gff_name","transcript_name","gene_name"];for(const e of n){const n=t?.[e];if(n?.[0])return n[0]}return""}(e),n=function(e){const{attributes:t}=e,n=["id","gff_id","transcript_id","gene_id","gene_stable_id","stable_id"];for(const e of n){const n=t?.[e];if(n?.[0])return n[0]}return""}(e);return t?`${e.type} - ${t}`:n?`${e.type} - ${n}`:e.type};function Af({annotationFeature:e,assembly:t,handleClose:r,refSeqId:o,session:a,region:c}){const d=a,f=n.readConfObject(d.getPluginConfiguration(),"skippedAttributesOnCopy"),h=new Set(f??[]),{featureTypeOntology:p}=d.apolloDataStore.ontologyManager,g=u.useMemo((()=>Object.keys(e.children??{})),[e]),[m,y]=u.useState(!0),[_,v]=u.useState(g),[b,x]=u.useState(""),[w,S]=u.useState([]),[C,A]=u.useState(!1),[k,N]=u.useState(),T=d.apolloDataStore.assemblies.get(t.name),R=T?.refSeqs.get(o),E=u.useMemo((()=>R?.getFeatures(c.start,c.end)),[R,c.start,c.end]);u.useEffect((()=>{x("");const e=(()=>{const e=[];for(const t of E??[])if(!(t.min>c.end||t.max<c.start)&&p?.isTypeOf(t.type,"gene")){const n=l.getSnapshot(t);e.push(n)}return e})();S(e),N(e[0])}),[_,p,E,m,c]);const I=async e=>{if(k)for(const n of Object.keys(e)){const r={...e[n]};if(Aa(r,h),r.strand=k.strand,r.children)for(const e of Object.keys(r.children))r.children[e].strand=k.strand;const o=new ht({parentFeatureId:k._id,changedIds:[k._id],typeName:"AddFeatureChange",assembly:t.name,addedFeature:r});await O(o,n)}},j=async n=>{const r={};for(const[e,t]of Object.entries(n)){const n={...t};Aa(n,h),r[e]=n}const i=(new at).toHexString(),a=Math.min(...Object.values(r).map((e=>e.min))),s=Math.max(...Object.values(r).map((e=>e.max))),l=new ht({changedIds:[i],typeName:"AddFeatureChange",assembly:t.name,addedFeature:{_id:i,refSeq:o,min:a,max:s,strand:e.strand,type:"gene",children:r,attributes:{name:[Sf(e)],gene_name:[Sf(e)]}}});await O(l,i)},D=async(e,n)=>{if(!k)return;const r=[];e!==k.min&&r.push(new Et({typeName:"LocationStartChange",changedIds:[k._id],featureId:k._id,assembly:t.name,oldStart:k.min,newStart:e})),n!==k.max&&r.push(new Tt({typeName:"LocationEndChange",changedIds:[k._id],featureId:k._id,assembly:t.name,oldEnd:k.max,newEnd:n}));for(const e of r)await O(e)},O=async(e,t)=>{await d.apolloDataStore.changeManager.submit(e).then((()=>{d.apolloSetSelectedFeature(t)}))};return i.jsxs(Bs,{open:!0,title:"Create Apollo Annotation",handleClose:r,fullWidth:!0,maxWidth:"sm",children:[i.jsx(s.DialogTitle,{fontSize:15,children:"Select the feature to be copied to apollo track"}),i.jsxs(s.DialogContent,{children:[i.jsxs(s.Box,{sx:{ml:3},children:[bf(e,d)&&i.jsx(s.FormControlLabel,{control:i.jsx(s.Checkbox,{size:"small",checked:m,onChange:e=>{const t=e.target.checked;y(t),v(t?g:[])}}),label:`${Cf(e)} (${e.min+1}..${e.max})`}),e.children&&i.jsx(s.Box,{sx:{display:"flex",flexDirection:"column",ml:3},children:Object.values(e.children).filter((e=>wf(e,d))).map((e=>i.jsx(s.FormControlLabel,{control:i.jsx(s.Checkbox,{size:"small",checked:_.includes(e._id),onChange:t=>{((e,t)=>{v((n=>e.target.checked?[...n,t._id]:n.filter((e=>e!==t._id))))})(t,e)}}),label:`${Cf(e)} (${e.min+1}..${e.max})`},e._id)))})]}),w.length>0&&(!m&&_.length>0||m&&wf(e,d))&&i.jsxs("div",{style:{border:"1px solid #ccc",marginTop:20,padding:10,borderRadius:5},children:[i.jsxs(s.Box,{sx:{ml:3},children:[i.jsx(s.Typography,{variant:"caption",fontSize:12,children:"Select the destination feature to copy the selected features"}),i.jsx(s.Box,{sx:{mt:1},children:i.jsx(s.Select,{labelId:"label",style:{width:"100%"},value:k?._id??"",onChange:e=>{const t=w.find((t=>t._id===e.target.value));N(t)},disabled:C,children:w.map((e=>i.jsx(s.MenuItem,{value:e._id,children:`${Cf(e)} (${e.min+1}..${e.max})`},e._id)))})})]}),i.jsx(s.Box,{sx:{ml:3},children:i.jsx(s.FormGroup,{children:i.jsx(s.FormControlLabel,{control:i.jsx(s.Checkbox,{checked:C,onChange:e=>{A(e.target.checked)}}),label:"Create new gene"})})})]})]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{variant:"contained",type:"submit",disabled:0===_.length||!m&&_.length>0&&!k,onClick:async()=>{if(m){if(xf(e,d)&&(await(async()=>{const n={...e};let r;if(Aa(n,h),n.children&&_.length!==Object.values(n.children).length){const o={};for(const e of _)o[e]=n.children[e];r=new ht({changedIds:[e._id],typeName:"AddFeatureChange",assembly:t.name,addedFeature:{...n,children:o}})}else r=new ht({changedIds:[e._id],typeName:"AddFeatureChange",assembly:t.name,addedFeature:n});await O(r,e._id)})(),a.notify("Successfully copied selected gene and transcript(s)","success")),wf(e,d))if(k&&!C){const t={};if(t[e._id]=e,k.max<e.max||k.min>e.min){const n=Math.min(k.min,e.min),r=Math.max(k.max,e.max);await D(n,r),await I(t)}else await I(t);a.notify("Successfully copied selected transcripts to destination gene","success")}else{const t={};t[e._id]=e,await j(t),a.notify("Successfully created a new gene with selected transcripts","success")}}else{if(!e.children)return;if(k&&!C){const t={};for(const n of _)t[n]=e.children[n];const n=Math.min(...Object.values(t).map((e=>e.min))),r=Math.max(...Object.values(t).map((e=>e.max)));if(k.min>n||k.max<r){const e=Math.min(k.min,n),o=Math.max(k.max,r);await D(e,o),await I(t)}else await I(t);a.notify("Successfully copied transcript to destination gene","success")}else{const t={};for(const n of _)t[n]=e.children[n];await j(t),a.notify("Successfully created a new gene with selected transcript","success")}}r()},children:"Create"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:r,children:"Cancel"})]}),b?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:b})}):null]})}function kf(e){return i.jsx(s.SvgIcon,{viewBox:"0 0 856 855",style:{fontSize:18,marginRight:4},...e,children:i.jsxs("g",{children:[i.jsx("path",{style:{opacity:.68,fill:"#AEAEAE"},d:"M276.7,656.9l85-148h102.9c23.1,0,16.1-16,11.1-25l-134-238.5l85-148l185,315.6c0,0-15-26.3,0,0\n\t\t\tc53,92.9-24,243.9-132,243.9c-6,0-4,0-6.4,0H276.7z"}),i.jsx("polygon",{style:{opacity:.85,fill:"#717171"},points:"49.7,756.9 219.1,756.9 513.7,246.9 425.7,99.9 \t\t"}),i.jsx("polygon",{style:{opacity:.85,fill:"#717171"},points:"630,756.9 806.4,756.9 513.7,246.9 425.1,400.2 \t\t"}),i.jsx("polygon",{style:{fill:"#C6C6C6"},points:"175.7,657.3 195.6,657.3 277.9,508.9 254.1,508.9 170.6,657.3 \t\t"}),i.jsx("polygon",{style:{fill:"#C6C6C6"},points:"369.7,657.3 389.6,657.3 471.9,508.9 448.1,508.9 364.6,657.3 \t\t"}),i.jsx("polygon",{style:{fill:"#C6C6C6"},points:"321.7,657.3 341.6,657.3 423.9,508.9 400.1,508.9 316.6,657.3 \t\t"}),i.jsx("polygon",{style:{fill:"#C6C6C6"},points:"224.7,657.3 244.6,657.3 326.9,508.9 303.1,508.9 219.6,657.3 \t\t"}),i.jsx("polygon",{style:{fill:"#C6C6C6"},points:"273.7,657.3 293.6,657.3 375.9,508.9 352.1,508.9 268.6,657.3 \t\t"})]})})}function Nf(e){if("LinearPileupDisplay"!==e.name)return e;const{stateModel:t}=e,n=t.views((e=>({getFirstRegion:()=>o.getContainingView(e).dynamicBlocks.contentBlocks[0],getAssembly(){const t=this.getFirstRegion(),n=o.getSession(e),{assemblyManager:r}=n,{assemblyName:i}=t,a=r.get(i);if(!a)throw new Error(`Could not find assembly named ${i}`);return a},getAnnotationFeature(e,t){const n=e.get("start"),r=e.get("end"),o=e.get("name");let i;const a=e.get("tags"),{ts:s,TS:l,XS:c}=a;for(const e of[s,l,c])!i&&e&&([1,"1","+"].includes(e)?i=1:[-1,"-1","-"].includes(e)&&(i=-1));i??=e.get("strand");const u=function(e){const t=/(\d+)([MIDNSHPX=])/g,n=[];let r;for(;null!==(r=t.exec(e));)n.push([r[2],Number.parseInt(r[1],10)]);return n}(e.get("CIGAR"));let d,f=n;const h=[];for(const[e,t]of u)switch(e){case"M":case"=":case"X":d??=f,f+=t;break;case"N":void 0!==d&&(h.push({start:d,end:f}),d=void 0),f+=t;break;case"D":f+=t;break;case"I":case"S":case"H":case"P":break;default:throw new Error(`Unknown CIGAR operation: ${e}`)}void 0!==d&&h.push({start:d,end:f});const p={_id:at().toHexString(),refSeq:t,min:n,max:r,type:"mRNA",strand:i};if(o&&(p.attributes={},p.attributes.gff_name=[o]),0===h.length)return p;p.children={};for(const e of h){const n={_id:at().toHexString(),refSeq:t,min:e.start,max:e.end,type:"exon",strand:i};p.children[n._id]=n}return p}}))).views((e=>{const t=e.contextMenuItems;return{contextMenuItems(){const n=o.getSession(e),r=e.getAssembly(),i=e.getFirstRegion(),a=e.contextMenuFeature;return a?[...t(),{label:"Create Apollo annotation",icon:kf,onClick:async()=>{const t=n.apolloDataStore.getBackendDriver(i.assemblyName);let o=i.refName;if(t instanceof kl){const e=await t.getRefSeqId(i.assemblyName,i.refName);if(!e)throw new Error(`Could not find refSeq for "${i.refName}"`);o=e}n.queueDialog((t=>[Af,{session:n,handleClose:()=>{t()},annotationFeature:e.getAnnotationFeature(a,o),assembly:r,refSeqId:o,region:i}]))}}]:t()}}}));return e.stateModel=n,e}function Tf(e,t){const n=e.get("subfeatures");return[{start:e.get("start")+1,end:e.get("end"),seq_id:t,source:e.get("source")??null,type:e.get("type")??null,score:e.get("score")??null,strand:e.get("strand")?1===e.get("strand")?"+":"-":null,phase:null!==e.get("phase")||void 0!==e.get("phase")?e.get("phase"):null,attributes:jf(e),derived_features:[],child_features:n?n.map((e=>Tf(e,t))):[]}]}function Rf(e,t){return Fn(Tf(e,t))}const Ef=new Set(["start","end","type","strand","refName","subfeatures","derived_features","phase","source","score","parent","__jbrowsefmt","length","position","uniqueId","exonFrames","parentId","thickStart","thickEnd","_lineHash"]),If={id:"gff_id",name:"gff_name",alias:"gff_alias",target:"gff_target",gap:"gff_gap",derives_from:"gff_derives_from",note:"gff_note",dbxref:"gff_dbxref",ontology_term:"gff_ontology_term",is_circular:"gff_is_circular"};function jf(e){const t={};for(const[n,r]of Object.entries(e.toJSON()))Ef.has(n)||(t[If[n]??n]=Array.isArray(r)?r.map(String):[String(r)]);return t}function Df(e){if("LinearBasicDisplay"!==e.name)return e;const{stateModel:t}=e,n=t.views((e=>({getFirstRegion:()=>o.getContainingView(e).dynamicBlocks.contentBlocks[0],getAssembly(){const t=e.getFirstRegion(),n=o.getSession(e),{assemblyManager:r}=n,{assemblyName:i}=t,a=r.get(i);if(!a)throw new Error(`Could not find assembly named ${i}`);return a}}))).views((e=>{const t=e.contextMenuItems;return{contextMenuItems(){const n=o.getSession(e),r=e.getAssembly(),i=e.getFirstRegion(),a=e.contextMenuFeature;if(!a)return t();const s=function(e){let t=e,n=e.get("parent");for(;n;)t=n,n=n.get("parent");return t}(a);return[...t(),{label:"Create Apollo annotation",icon:kf,onClick:async()=>{const e=n.apolloDataStore.getBackendDriver(i.assemblyName);let t=i.refName;if(e instanceof kl){const n=await e.getRefSeqId(i.assemblyName,i.refName);if(!n)throw new Error(`Could not find refSeq for "${i.refName}"`);t=n}const o=Rf(s,t);n.queueDialog((e=>[Af,{session:n,handleClose:()=>{e()},annotationFeature:o,assembly:r,refSeqId:t,region:i}]))}}]}}}));return e.stateModel=n,e}var Of=a.createSvgIcon(i.jsx("path",{d:"m12 8-6 6 1.41 1.41L12 10.83l4.59 4.58L18 14z"}),"ExpandLess"),Ff=a.createSvgIcon(i.jsx("path",{d:"M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2m-6 9c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2m3.1-9H8.9V6c0-1.71 1.39-3.1 3.1-3.1s3.1 1.39 3.1 3.1z"}),"Lock"),Mf=a.createSvgIcon(i.jsx("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m1 15h-2v-2h2zm0-4h-2V7h2z"}),"Error");const Lf=p.observer((function({display:e}){const{classes:t}=$d(),{apolloDragging:n,apolloRowHeight:r,lgv:a,session:l,showCheckResults:c}=e,{assemblyManager:u}=l;return c?a.dynamicBlocks.contentBlocks.map((c=>{const d=a.bpPerPx*r,f=u.get(c.assemblyName);return f?Hd([...l.apolloDataStore.checkResults.values()].filter((e=>f.isValidRefName(e.refSeq)&&f.getCanonicalRefName(e.refSeq)===c.refName&&o.doesIntersect2(c.start,c.end,e.start,e.end))),d).map((o=>{const a=Math.round(ud(e,o.range,c)),[l]=o.featureIds;if(!l)return null;const u=e.getRowForFeature(l)??0;return i.jsx(s.Tooltip,{title:o.message,children:i.jsx(s.Box,{className:t.box,style:{top:u*r,left:a,height:r,width:r,pointerEvents:n?"none":"auto"},children:i.jsx(s.Badge,{className:t.badge,badgeContent:o.count,color:"primary",overlap:"circular",anchorOrigin:{vertical:"bottom",horizontal:"right"},invisible:o.count<=1,children:i.jsx(s.Avatar,{className:t.avatar,children:i.jsx(Mf,{"data-testid":`ErrorIcon-${o.start}`})})})})},o._id)})):null})):null})),Pf=p.observer((function(e){const{mouseCooordinate:t,session:n,dragging:r}=e,{apolloHoveredFeature:o}=n;if(!t||!o||r)return;const[a,s]=t,{feature:l}=o,{attributes:c,min:u,max:d}=l,f=`Loc: ${u+1}..${d}`,p=`Type: ${l.type}`,g=c.get("gff_name")?.find((e=>""!==e));return i.jsxs(h.BaseTooltip,{clientPoint:{x:a,y:s},placement:"top-start",children:[p,i.jsx("br",{}),g?i.jsxs(i.Fragment,{children:[g,i.jsx("br",{})]}):null,f]})})),Bf=p.observer((function(e){const{model:t}=e,{apolloDragging:n,cursor:r,featuresHeight:a,isShown:s,onMouseDown:l,onMouseLeave:c,onMouseMove:d,onMouseUp:f,session:h,setOverlayCanvas:p}=t,{classes:g}=$d(),m=o.getContainingView(t),[y,_]=u.useState();if(!s)return null;const v=a(m.assemblyNames[0]);return i.jsxs(i.Fragment,{children:[i.jsx("canvas",{ref:async e=>{await Promise.resolve(),p(e)},width:m.dynamicBlocks.totalWidthPx,height:v,onMouseMove:(...e)=>{const[t]=e;_([t.clientX,t.clientY]),d(...e)},onMouseLeave:(...e)=>{_(void 0),c(...e)},onMouseDown:l,onMouseUp:f,className:g.canvas,style:{cursor:r??"default"},"data-testid":"overlayCanvas"}),i.jsx(Pf,{mouseCooordinate:y,session:h,dragging:Boolean(n)})]})})),qf=p.observer((function(e){const t=s.useTheme(),{model:n}=e,{loading:r,contextMenuItems:a,featuresHeight:l,isShown:c,regionCannotBeRendered:d,session:f,setCanvas:p,setCollaboratorCanvas:g,setTheme:m}=n,{classes:y}=$d(),_=o.getContainingView(n);u.useEffect((()=>{m(t)}),[t,m]);const[v,b]=u.useState(),[x,w]=u.useState([]),S=d();if(!c)return null;const C=l(_.assemblyNames[0]);return i.jsxs("div",{className:y.canvasContainer,style:{width:_.dynamicBlocks.totalWidthPx,height:C},onContextMenu:e=>{e.preventDefault(),x.length>0?w([]):(b([e.clientX,e.clientY]),w(a(e)))},children:[f.isLocked?i.jsx("div",{className:y.locked,"data-testid":"lock-icon",children:i.jsx(Ff,{})}):null,r?i.jsx("div",{className:y.loading,children:i.jsx(s.CircularProgress,{size:"18px"})}):null,S?i.jsx(s.Alert,{severity:"warning",classes:{message:y.ellipses},slotProps:{root:{className:y.center}},children:i.jsx(s.Tooltip,{title:S,children:i.jsx("div",{children:S})})}):i.jsxs(i.Fragment,{children:[i.jsx("canvas",{ref:async e=>{await Promise.resolve(),g(e)},width:_.dynamicBlocks.totalWidthPx,height:C,className:y.canvas,"data-testid":"collaboratorCanvas"}),i.jsx("canvas",{ref:async e=>{await Promise.resolve(),p(e)},width:_.dynamicBlocks.totalWidthPx,height:C,className:y.canvas,"data-testid":"canvas"}),i.jsx(Bf,{model:n}),i.jsx(Lf,{display:n}),i.jsx(h.Menu,{open:x.length>0,onMenuItemClick:(e,t)=>{t(),w([])},onClose:()=>{w([])},slotProps:{transition:{onExit:()=>{w([])}}},anchorReference:"anchorPosition",anchorPosition:v?{top:v[1],left:v[0]}:void 0,menuItems:x})]})]})})),Uf=p.observer((function({model:e,hrStyle:t={margin:0,top:0,color:"black"},idx:n}){const{apolloRowHeight:r,highestRow:o,showFeatureLabels:a}=e,s=a?2:1;return i.jsx("div",{style:{position:"absolute",left:0,top:r*s*(o+1)/2+n*s*r,width:"100%"},children:i.jsx("hr",{style:t})})})),zf=p.observer((function(e,t){const n=s.useTheme(),{model:r}=e,{apolloRowHeight:a,contextMenuItems:l,cursor:c,featuresHeight:d,geneTrackRowNums:f,isShown:p,onMouseDown:g,onMouseLeave:m,onMouseMove:y,onMouseUp:_,regionCannotBeRendered:v,session:b,setCanvas:x,setCollaboratorCanvas:w,setOverlayCanvas:S,setTheme:C,showCheckResults:A,showFeatureLabels:k}=r,{classes:N}=$d(),T=o.getContainingView(r);u.useEffect((()=>{C(n)}),[n,C]);const[R,E]=u.useState(),[I,j]=u.useState([]),D=v();if(!p)return null;const{assemblyManager:O}=b;return i.jsx(i.Fragment,{children:i.jsxs("div",{className:N.canvasContainer,style:{width:T.dynamicBlocks.totalWidthPx,height:d},onContextMenu:e=>{e.preventDefault(),I.length>0?j([]):(E([e.clientX,e.clientY]),j(l(e)))},children:[b.isLocked?i.jsx("div",{className:N.locked,"data-testid":"lock-icon",children:i.jsx(Ff,{})}):null,D?i.jsx(s.Alert,{severity:"warning",classes:{message:N.ellipses},slotProps:{root:{className:N.center}},children:i.jsx(s.Tooltip,{title:D,children:i.jsx("div",{children:D})})}):i.jsxs(i.Fragment,{children:[i.jsx(Uf,{model:r,idx:0}),i.jsx(Uf,{model:r,hrStyle:{margin:0,top:0,color:"grey",opacity:.4},idx:1}),i.jsx(Uf,{model:r,idx:2}),i.jsx("canvas",{ref:async e=>{await Promise.resolve(),w(e)},width:T.dynamicBlocks.totalWidthPx,height:d,className:N.canvas,"data-testid":"collaboratorCanvas"}),i.jsx("canvas",{ref:async e=>{await Promise.resolve(),x(e)},width:T.dynamicBlocks.totalWidthPx,height:d,className:N.canvas,"data-testid":"canvas"}),i.jsx("canvas",{ref:async e=>{await Promise.resolve(),S(e)},width:T.dynamicBlocks.totalWidthPx,height:d,onMouseMove:y,onMouseLeave:m,onMouseDown:g,onMouseUp:_,className:N.canvas,style:{cursor:c??"default"},"data-testid":"overlayCanvas"}),T.displayedRegions.flatMap(((e,n)=>{const r=T.bpPerPx*a,l=O.get(e.assemblyName);return A?Hd([...b.apolloDataStore.checkResults.values()].filter((t=>l?.isValidRefName(t.refSeq)&&l.getCanonicalRefName(t.refSeq)===e.refName&&o.doesIntersect2(e.start,e.end,t.start,t.end))),r).map((r=>{const l=(T.bpToPx({refName:e.refName,coord:r.start,regionNumber:n})?.offsetPx??0)-T.offsetPx,[c]=r.featureIds;if(!c?.parent||!Zs(c.parent,b))return null;let u;for(const e of c.cdsLocations)for(const t of e){const e=o.getFrame(t.min,t.max,c.strand??1,t.phase),n=(k?[0,5,3,1,15,13,11]:[0,2,1,0,8,7,6]).at(e);if(void 0!==n&&r.start>=t.min&&r.start<=t.max){u=n-1;break}}return void 0===u&&(u=(1==c.strand?f[0]:f[1])-1),i.jsx(s.Tooltip,{title:r.message,children:i.jsx(s.Box,{className:N.box,style:{top:u*a,left:l,height:a,width:a,pointerEvents:t?"none":"auto"},children:i.jsx(s.Badge,{className:N.badge,badgeContent:r.count,color:"primary",overlap:"circular",anchorOrigin:{vertical:"bottom",horizontal:"right"},invisible:r.count<=1,children:i.jsx(s.Avatar,{className:N.avatar,children:i.jsx(Mf,{"data-testid":`ErrorIcon-${r.start}`})})})})},r._id)})):null})),i.jsx(h.Menu,{open:I.length>0,onMenuItemClick:(e,t)=>{t(),j([])},onClose:()=>{j([])},slotProps:{transition:{onExit:()=>{j([])}}},anchorReference:"anchorPosition",anchorPosition:R?{top:R[1],left:R[0]}:void 0,style:{zIndex:n.zIndex.tooltip},menuItems:I})]})]})})})),$f=ma()((e=>({shading:{background:s.alpha(e.palette.primary.main,.2),overflowX:"hidden"},details:{background:e.palette.background.paper},accordionControl:{height:12,width:"100%","&:hover":{background:e.palette.action.hover},display:"flex",alignItems:"center",justifyContent:"center"},accordionRoot:{background:e.palette.divider},resizeHandle:{width:"100%",height:4,position:"absolute",cursor:"row-resize",zIndex:100},expandIcon:{},title:{userSelect:"none"},alertContainer:{display:"flex",alignItems:"center",justifyContent:"center"}})));function Hf(e,t){const{apolloRowHeight:n,selectedFeature:r}=e;if(t.current&&r){let o;if("getFeatureLayoutPosition"in e){const t=e.getFeatureLayoutPosition(r);t&&(o=t.layoutRow+t.featureRow)}else o=e.getRowForFeature(r);void 0!==o&&t.current.scroll({top:o*n,behavior:"smooth"})}}const Gf=({onResize:e})=>{const{classes:t}=$f(),n=u.useCallback((t=>{t.stopPropagation(),t.preventDefault(),e(t.movementY)}),[e]);return i.jsx("div",{onMouseDown:e=>{e.stopPropagation();const t=new AbortController,{signal:r}=t;function o(){t.abort(new DOMException("Canceling drag event listener","AbortError"))}globalThis.addEventListener("mousemove",n,{signal:r}),globalThis.addEventListener("mouseup",o,{signal:r}),globalThis.addEventListener("mouseleave",o,{signal:r})},onClick:e=>{e.stopPropagation(),e.preventDefault()},className:t.resizeHandle})},Vf=p.observer((function({onClick:e,onResize:t,open:n,title:r}){const{classes:o}=$f();return i.jsxs("div",{className:o.accordionRoot,children:[n&&t?i.jsx(Gf,{onResize:t}):null,i.jsxs("div",{className:o.accordionControl,onClick:e,children:[i.jsx(n?Of:Uc,{className:o.expandIcon}),r?i.jsx(s.Typography,{className:o.title,variant:"caption",component:"span",children:r}):null]})]})})),Wf=p.observer((function({model:e,...t}){const n=o.getSession(e),{ontologyManager:r}=n.apolloDataStore,{featureTypeOntology:a}=r,l=a?.dataStore,{classes:c}=$f(),{graphical:d,height:f,isShown:h,selectedFeature:p,table:g,tabularEditor:m,toggleShown:y}=e,_=u.useRef(null);u.useEffect((()=>{Hf(e,_)}),[e,p]);const v=t=>{e.setDetailsHeight(e.detailsHeight-t)};if(!l)return i.jsx("div",{className:c.alertContainer,children:i.jsx(s.Alert,{severity:"error",children:"Could not load feature type ontology."})});if(d&&g){const n=m.isShown?e.detailsHeight:0,r=h?f-e.detailsHeight-24:0;return i.jsxs("div",{style:{height:f},children:[i.jsx(Vf,{open:h,title:"Graphical",onClick:y}),i.jsx("div",{className:c.shading,ref:_,style:{height:r},children:i.jsx(qf,{model:e,...t})}),i.jsx(Vf,{title:"Table",open:m.isShown,onClick:m.togglePane,onResize:v}),i.jsx("div",{className:c.details,style:{height:n},children:i.jsx(ld,{model:e})})]})}return i.jsx("div",d?{className:c.shading,ref:_,style:{height:f},children:i.jsx(qf,{model:e,...t})}:{className:c.details,style:{height:f},children:i.jsx(ld,{model:e})})})),Jf=p.observer((function({model:e,...t}){const n=o.getSession(e),{ontologyManager:r}=n.apolloDataStore,{featureTypeOntology:a}=r,l=a?.dataStore,{classes:c}=$f(),{detailsHeight:d,graphical:f,height:h,isShown:p,selectedFeature:g,table:m,tabularEditor:y,toggleShown:_}=e,v=u.useRef(null);u.useEffect((()=>{Hf(e,v)}),[e,g]);const b=t=>{e.setDetailsHeight(d-t)};if(!l)return i.jsx("div",{className:c.alertContainer,children:i.jsx(s.Alert,{severity:"error",children:"Could not load feature type ontology."})});if(f&&m){const n=y.isShown?d:0,r=p?h-d-24:0;return i.jsxs("div",{style:{height:h},children:[i.jsx(Vf,{open:p,title:"Graphical",onClick:_}),i.jsx("div",{className:c.shading,ref:v,style:{height:r},children:i.jsx(zf,{model:e,...t})}),i.jsx(Vf,{title:"Table",open:y.isShown,onClick:y.togglePane,onResize:b}),i.jsx("div",{className:c.details,style:{height:n},children:i.jsx(ld,{model:e})})]})}return i.jsx("div",f?{className:c.shading,ref:v,style:{height:h},children:i.jsx(zf,{model:e,...t})}:{className:c.details,style:{height:h},children:i.jsx(ld,{model:e})})}));var Kf=a.createSvgIcon(i.jsx("path",{d:"m17 7-1.41 1.41L18.17 11H8v2h10.17l-2.58 2.58L17 17l5-5zM4 5h8V3H4c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h8v-2H4z"}),"Logout"),Yf=a.createSvgIcon(i.jsx("path",{d:"M18.4 10.6C16.55 8.99 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16c1.05-3.19 4.05-5.5 7.6-5.5 1.95 0 3.73.72 5.12 1.88L13 16h9V7z"}),"Redo"),Xf=a.createSvgIcon(i.jsx("path",{d:"M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8"}),"Undo"),Zf=a.createSvgIcon(i.jsx("path",{d:"M17 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V7zm-5 16c-1.66 0-3-1.34-3-3s1.34-3 3-3 3 1.34 3 3-1.34 3-3 3m3-10H5V5h10z"}),"Save");const Qf=l.types.model("JobsManager",{}).views((e=>({get jobStatusWidget(){const{widgets:t}=o.getSession(e);return t.get("JobsList")??o.getSession(e).addWidget("JobsListWidget","JobsList")}}))).actions((e=>({update(t,n,r){e.jobStatusWidget.updateJobStatusMessage(t,n),r&&e.jobStatusWidget.updateJobProgressPct(t,r)},abortJob(t,n){const r=o.getSession(e);if(o.isSessionModelWithWidgets(r)){r.showWidget(e.jobStatusWidget),e.jobStatusWidget.updateJobStatusMessage(t,n??"Aborted unexpectedly");const o=e.jobStatusWidget.jobs.findIndex((e=>e.name===t));e.jobStatusWidget.addAbortedJob({...e.jobStatusWidget.jobs[o]}),e.jobStatusWidget.removeJob(t),r.notify("Job aborted","info")}},runJob(t){const n=o.getSession(e);o.isSessionModelWithWidgets(n)&&(n.showWidget(e.jobStatusWidget),e.jobStatusWidget.addJob(t))},done(t){const n=o.getSession(e);o.isSessionModelWithWidgets(n)&&(n.showWidget(e.jobStatusWidget),e.jobStatusWidget.removeJob(t.name),e.jobStatusWidget.addFinishedJob({name:t.name,statusMessage:"All operations successful",progressPct:100,cancelCallback:t.cancelCallback}))}})));function eh(e){const t={};if(e.children)for(const n of Object.values(e.children)){const e=eh(n);t[e._id]=e}return{...e,_id:(new at).toHexString(),children:e.children?t:void 0}}function th({assemblyName:e,changeManager:t,existingFeature:n,featureSnapshot:r,handleClose:o}){const[a,l]=u.useState("keepExisting"),[c,d]=u.useState(""),[f,h]=u.useState(!1);return i.jsxs(Bs,{open:!0,title:"Duplicate Feature Detected",handleClose:o,maxWidth:"sm",fullWidth:!0,children:[i.jsxs(s.DialogContent,{children:[i.jsxs(s.DialogContentText,{children:["A feature with ID “",r._id,"” already exists. How would you like to resolve this conflict?"]}),i.jsxs(s.FormControl,{component:"fieldset",sx:{mt:2},children:[i.jsx(s.FormLabel,{component:"legend",children:"Resolution"}),i.jsxs(s.RadioGroup,{value:a,onChange:e=>{l(e.target.value)},children:[i.jsx(s.FormControlLabel,{value:"keepExisting",control:i.jsx(s.Radio,{}),label:"Keep the existing feature"}),i.jsx(s.FormControlLabel,{value:"useNew",control:i.jsx(s.Radio,{}),label:"Replace with the new feature"}),i.jsx(s.FormControlLabel,{value:"keepBoth",control:i.jsx(s.Radio,{}),label:"Keep both (assign new IDs to the incoming feature)"})]})]}),c?i.jsx(s.DialogContentText,{color:"error",sx:{mt:1},children:c}):null]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{variant:"contained",onClick:async()=>{d(""),h(!0);try{if("useNew"===a){const o=new pt({typeName:"DeleteFeatureChange",assembly:e,changedIds:[n._id],deletedFeature:n});await t.submit(o);const i=new ht({typeName:"AddFeatureChange",assembly:e,changedIds:[r._id],addedFeature:r});await t.submit(i)}else if("keepBoth"===a){const n=eh(r),o=new ht({typeName:"AddFeatureChange",assembly:e,changedIds:[n._id],addedFeature:n});await t.submit(o)}o()}catch(e){d(String(e)),h(!1)}},disabled:f,children:"Confirm"}),i.jsx(s.Button,{onClick:o,disabled:f,children:"Cancel"})]})]})}function nh(e,t){const r=e.evaluateExtensionPoint("Apollo-extendAnnotationFeature",cu),i=function(e){return l.types.model("ClientDataStore",{typeName:l.types.optional(l.types.literal("Client"),"Client"),assemblies:l.types.map(fu),checkResults:l.types.map(hu),ontologyManager:l.types.optional(Os,{})}).views((t=>({get internetAccounts(){return l.getRoot(t).internetAccounts},get pluginConfiguration(){return l.getRoot(t).jbrowse.configuration.ApolloPlugin},getFeature:n=>l.resolveIdentifier(e,t.assemblies,n)}))).actions((e=>({addAssembly(t,n){const r={_id:t,refSeqs:{}};return n&&(r.backendDriverType=n),e.assemblies.put(r)}}))).actions((e=>({addFeature(t,n){const r=o.getSession(e),{assemblyManager:i}=r;let a=e.assemblies.get(t);if(!a){if(!i.get(t))throw new Error(`Could not find assembly "${t}" to add feature "${n._id}"`);a=e.addAssembly(t)}let s=a.refSeqs.get(n.refSeq);if(!s){const e=i.get(t);if(!e)throw new Error(`Could not find assembly "${t}" to add feature "${n._id}"`);const r=e.getCanonicalRefName(n.refSeq);if(!r)throw new Error(`Could not find refSeq "${n.refSeq}" to add feature "${n._id}"`);s=a.addRefSeq(n.refSeq,r)}s.features.put(n)},deleteFeature(t){const n=e.getFeature(t);if(!n)throw new Error(`Could not find feature "${t}" to delete`);const{_id:r,parent:o}=n;o?o.deleteChild(t):l.getParentOfType(n,du).deleteFeature(r)},deleteAssembly(t){e.assemblies.delete(t)},addCheckResult(t){e.checkResults.put(t)},addCheckResults(t){for(const n of t)e.checkResults.has(n._id)||e.checkResults.put(n)},deleteCheckResult(t){e.checkResults.delete(t)},clearCheckResults(){e.checkResults.clear()}}))).volatile((e=>({changeManager:new Al(e),collaborationServerDriver:new kl(e),localDriver:new Sl(e)}))).actions((e=>({afterCreate(){l.addDisposer(e,c.autorun((()=>{const{ontologyManager:t,pluginConfiguration:r}=e,i=r.ontologies;for(const r of i||[]){const[i,a,s,l]=[n.readConfObject(r,"name"),n.readConfObject(r,"version"),n.readConfObject(r,"source"),n.readConfObject(r,"textIndexFields")];if(!t.findOntology(i)){const n=o.getSession(e),{jobsManager:r}=n,c=new AbortController,u=`Loading ontology "${i}"`,d={name:u,statusMessage:`Loading ontology "${i}", version "${a}", this may take a while`,progressPct:0,cancelCallback:()=>{c.abort(new DOMException(`Canceling loading of ontology "${i}"`,"AbortError")),r.abortJob(d.name)}};t.addOntology(i,a,s,{textIndexing:{indexFields:l},update:(e,t)=>{0!==t?100!==t?r.update(u,e,t):r.done(d):r.runJob(d)}})}}})))}}))).views((e=>({getBackendDriver(t){const r=o.getSession(e),{assemblyManager:i}=r,a=i.get(t);if(!a)return;const{internetAccountConfigId:s}=n.getConf(a,["sequence","metadata"]);return s?e.collaborationServerDriver:e.localDriver},getInternetAccount(t,r){if(!(t??r))throw new Error("Must provide either assemblyName or internetAccountId");let i=r;if(t&&!i){const{assemblyManager:r}=o.getSession(e),a=r.get(t);if(!a)throw new Error(`No assembly found with name ${t}`);({internetAccountConfigId:i}=n.getConf(a,["sequence","metadata"]))}const{internetAccounts:a}=e,s=a.find((e=>e.internetAccountId===i));if(!s)throw new Error(`No InternetAccount found with config id ${r}`);return s}}))).actions((e=>({loadFeatures:l.flow((function*(t){for(const n of t){const t=e.getBackendDriver(n.assemblyName);if(!t)return;const[r,o]=yield t.getFeatures(n);if(0===r.length)continue;const{assemblyName:i,refName:a}=n,s=e.assemblies.get(i)??e.assemblies.put({_id:i,refSeqs:{}}),[l]=r,c=s.refSeqs.get(l.refSeq)??s.refSeqs.put({_id:l.refSeq,name:a,features:{}});for(const e of r)c.features.has(e._id)||c.features.put(e);e.addCheckResults(o)}})),loadRefSeq:l.flow((function*(t){for(const n of t){const t=e.getBackendDriver(n.assemblyName);if(!t)return;const{refSeq:r,seq:o}=yield t.getSequence(n),{assemblyName:i,end:a,refName:s,start:l}=n,c=e.assemblies.get(i)??e.assemblies.put({_id:i,refSeqs:{}});(c.refSeqs.get(r)??c.refSeqs.put({_id:r,name:s,sequence:[]})).addSequence({start:l,stop:a,sequence:o})}}))})))}(r),a=t.props({apolloDataStore:l.types.optional(i,{typeName:"Client"}),apolloSelectedFeature:l.types.safeReference(r),jobsManager:l.types.optional(Qf,{}),isLocked:l.types.optional(l.types.boolean,!1),changeInProgress:l.types.optional(l.types.boolean,!1)}).volatile((()=>({apolloHoveredFeature:void 0,abortController:new AbortController}))).extend((()=>{const e=c.observable.array([]);return{views:{get collaborators(){return e}},actions:{addOrUpdateCollaborator(t){const n=e.find((e=>e.id===t.id));n?n.locations=t.locations:e.push(t)}}}})).actions((e=>({apolloSetSelectedFeature(t){e.apolloSelectedFeature=t},apolloSetHoveredFeature(t){e.apolloHoveredFeature=t},addApolloLocalTrackConfig(t){const n=`apollo_track_${t.name}`;e.tracks.some((e=>e.trackId===n))||l.getRoot(e).jbrowse.addTrackConf({type:"ApolloTrack",trackId:n,name:`Annotations (${t.displayName})`,assemblyNames:[t.name],category:["Apollo"]})},toggleLocked(){e.isLocked=!e.isLocked},setChangeInProgress(t){e.changeInProgress=t},getPluginConfiguration(){const{jbrowse:t}=l.getRoot(e);return t.configuration.ApolloPlugin},broadcastLocations(){const{internetAccounts:t}=l.getRoot(e),n=[];for(const t of e.views){if("LinearGenomeView"!==t.type)return;const r=t;if(r.initialized){const{dynamicBlocks:t}=r;for(const r of t.contentBlocks){const{assemblyName:t,end:o,refName:i,start:a}=r,s=e.apolloDataStore.assemblies.get(t);"CollaborationServerDriver"===s?.backendDriverType&&n.push({assemblyName:t,refName:i,start:a,end:o})}}}if(0===n.length){for(const e of t)Xl(e)&&e.postUserLocation([]);return}const r=[];for(const e of t)if(Xl(e)){for(const e of n)r.push({assemblyId:e.assemblyName,refSeq:e.refName,start:e.start,end:e.end});e.postUserLocation(r)}}}))).actions((e=>({apolloSetEventualSelectedFeature:c.flow((function*(t){yield c.when((()=>Boolean(e.apolloDataStore.getFeature(t)))),e.apolloSetSelectedFeature(t)}))}))).volatile((e=>({previousSnapshot:l.getSnapshot(e)}))).actions((e=>({afterCreate(){l.applySnapshot(e,{name:e.name,id:e.id});const{internetAccounts:t,jbrowse:r,reloadPluginManagerCallback:o}=l.getRoot(e);l.addDisposer(e,c.autorun((()=>{const n=[];for(const t of e.views){if("LinearGenomeView"!==t.type)return;const r=t;if(r.initialized){const{dynamicBlocks:t}=r;for(const r of t.contentBlocks){const{assemblyName:t,end:o,refName:i,start:a}=r,s=e.apolloDataStore.assemblies.get(t);"CollaborationServerDriver"===s?.backendDriverType&&n.push({assemblyName:t,refName:i,start:a,end:o})}}}if(0===n.length){for(const e of t)Xl(e)&&e.postUserLocation([]);return}const r=[];for(const e of t)if(Xl(e)){for(const e of n)r.push({assemblyId:e.assemblyName,refSeq:e.refName,start:e.start,end:e.end});e.postUserLocation(r)}}),{name:"ApolloSessionBroadcastLocations"})),l.addDisposer(e,c.autorun((async i=>{const a=r.configuration.ApolloPlugin,s=n.readConfObject(a,"hasRole"),c=n.readConfObject(a,"featureTypeOntologyName"),u=t.some((e=>Xl(e))),d=e.assemblyManager.assemblies.filter((e=>!n.getConf(e,["sequence","metadata"]).apollo));if(!u||s){const{assemblies:t}=e.assemblyManager;if(0===t.length)return;const{pluginConfiguration:r}=e.apolloDataStore;r.ontologies.find((e=>n.readConfObject(e,"name")===c))||r.addOntology({name:"Sequence Ontology",version:"01c33c6d9b6c8dca12e7d3e37b49ee113093c2fa",source:{uri:"https://raw.githubusercontent.com/The-Sequence-Ontology/SO-Ontologies/01c33c6d9b6c8dca12e7d3e37b49ee113093c2fa/Ontology_Files/so.json",locationType:"UriLocation"}});for(const t of d)e.addApolloLocalTrackConfig(t);return l.applySnapshot(e,e.previousSnapshot),void i.dispose()}const{signal:f}=e.abortController;for(const n of t){if("ApolloInternetAccount"!==n.type)continue;const{baseURL:t}=n,r=new URL("jbrowse/config.json",t).href,a=n.getFetcher({locationType:"UriLocation",uri:r});let s,l;try{s=await a(r,{signal:f})}catch(t){e.abortController.signal.aborted||console.error(t);continue}if(s.ok){try{l=await s.json()}catch(e){console.error(e);continue}l.configuration.ApolloPlugin.hasRole&&(o(l,e.previousSnapshot),i.dispose())}else{const e=await dl(s,"Failed to fetch assemblies");console.error(e)}}}),{name:"ApolloSessionLoadConfig"}))},beforeDestroy(){e.abortController.abort(new DOMException("Clean up Apollo session","AbortError"))}}))).actions((e=>({async afterCreate(){if(o.isElectron)return;const t=new URL(globalThis.location.href).searchParams.get("apolloFeatures");if(!t)return;const{assemblyManager:n}=e;await async function(e,t,n,r){const o=function(e){let t=e.replaceAll("-","+").replaceAll("_","/");const n=t.length%4;return n&&(t+="=".repeat(4-n)),t}(e),i=await async function(e){const t=atob(e),n=Uint8Array.from(t,(e=>e.charCodeAt(0))),r=new Blob([n]).stream(),o=new DecompressionStream("gzip"),i=r.pipeThrough(o),a=new Response(i),s=await a.arrayBuffer();return JSON.parse((new TextDecoder).decode(s))}(o);for(const[e,o]of Object.entries(i)){if(!(t.getBackendDriver(e)instanceof Sl))continue;const i=await n.waitForAssembly(e);if(!i)throw new Error(`Assembly not found: "${e}"`);const{regions:a}=i;if(!a)throw new Error(`Assembly not found: "${e}"`);const s=a.map((e=>e.refName)),l=await wl(e,s);for(const n of o){const o=`features-${n.refSeq}`,i=await l.get(o,n._id);if(void 0===i){const r=new ht({typeName:"AddFeatureChange",assembly:e,changedIds:[n._id],addedFeature:n});await t.changeManager.submit(r)}else{const o=JSON.parse(JSON.stringify(i));Ss(n,o)||await new Promise((i=>{r.queueDialog((r=>[th,{featureSnapshot:n,existingFeature:o,assemblyName:e,changeManager:t.changeManager,handleClose:()=>{r(),i()}}]))}))}}}}(t,e.apolloDataStore,n,e),await new Promise((e=>setTimeout(e,2e3)));const r=new URL(globalThis.location.href);r.searchParams.delete("apolloFeatures"),globalThis.history.replaceState(null,"",r.toString())},afterAttach(){l.addDisposer(e,c.autorun((t=>{const{focusedViewId:n,activeWidgets:r}=e;if(!n||!r)return;const o=r.get("hierarchicalTrackSelector");o?.setView(n),t.dispose()})))}}))).views((e=>{const t=e.getTrackActions;return{getTrackActions(r){if("ApolloTrack"===r.type||"ReferenceSequenceTrack"===r.type)return t?.(r);const o=n.readConfObject(r,"trackId");return o.endsWith("-sessionTrack")?[...t?.(r)??[],{label:"Save track to Apollo",onClick:async()=>{const{internetAccounts:t,jbrowse:n}=l.getRoot(e);let i;i=kt(l.getSnapshot(n)),0===Object.keys(i).length&&(i=void 0);const a={...l.getSnapshot(r),trackId:o.slice(0,o.length-13)};for(const n of t){if("ApolloInternetAccount"!==n.type)continue;const t=new Nt({typeName:"ImportJBrowseConfigChange",oldJBrowseConfig:i,newJBrowseConfig:{...i,tracks:i?.tracks&&[...i.tracks,a]}}),{internetAccountId:r}=n;await e.apolloDataStore.changeManager.submit(t,{internetAccountId:r});const{notify:o}=e;o("Track added","success")}e.deleteTrackConf(r),n.addTrackConf(a)},icon:Zf}]:[...t?.(r)??[],{label:"Remove track from Apollo",onClick:async()=>{const{internetAccounts:t,jbrowse:n}=l.getRoot(e);let i;i=kt(l.getSnapshot(n)),0===Object.keys(i).length&&(i=void 0);const a=i?.tracks?.filter((e=>e.trackId!==o));for(const n of t){if("ApolloInternetAccount"!==n.type)continue;const t=new Nt({typeName:"ImportJBrowseConfigChange",oldJBrowseConfig:i,newJBrowseConfig:{...i,tracks:a}}),{internetAccountId:r}=n;await e.apolloDataStore.changeManager.submit(t,{internetAccountId:r});const{notify:o}=e;o("Track removed","success")}e.deleteTrackConf(r),n.deleteTrackConf(r)},icon:Zf}]}}}));return l.types.snapshotProcessor(a,{postProcessor(e,t){if(e.apolloSelectedFeature=void 0,e.apolloDataStore={typeName:"Client",checkResults:{}},!t)return e;const{apolloDataStore:n}=t,{checkResults:r}=n;for(const[,e]of r){const[t]=e.ids}return e}})}const rh="WorkerGlobalScope"in globalThis;for(const[e,t]of Object.entries(Gt))Q.registerChange(e,t);const oh=new Sn;ne.registerCheck(oh.name,oh);const ih=new Rn;ne.registerCheck(ih.name,ih),Kt.registerValidation(new Xt),Kt.registerValidation(new Zt),e.default=class extends t{name="ApolloPlugin";version="1.1.2";configurationSchema=vf;install(e){!function(e){e.addAdapterType((()=>new y({name:"ApolloSequenceAdapter",configSchema:Mc,adapterMetadata:{category:void 0,hiddenFromGUI:!0,description:void 0},AdapterClass:Fc})))}(e),function(e){e.addAdapterType((()=>new y({name:"ApolloRefNameAliasAdapter",configSchema:Ec,adapterMetadata:{category:void 0,hiddenFromGUI:!0,description:void 0},AdapterClass:Rc})))}(e),function(e){e.addTextSearchAdapterType((()=>new r.TextSearchAdapterType({name:"ApolloTextSearchAdapter",displayName:"Apollo text search adapter",configSchema:qc,AdapterClass:Bc,description:"Apollo Text Search adapter"})))}(e),e.addWidgetType((()=>{const e=n.ConfigurationSchema("ApolloFeatureDetailsWidget",{});return new r.WidgetType({name:"ApolloFeatureDetailsWidget",heading:"Apollo feature details",configSchema:e,stateModel:pu,ReactComponent:su})})),e.addWidgetType((()=>{const e=n.ConfigurationSchema("ApolloTranscriptDetails",{});return new r.WidgetType({name:"ApolloTranscriptDetails",heading:"Apollo transcript details",configSchema:e,stateModel:gu,ReactComponent:Hu})})),e.addTrackType((()=>{const t=n.ConfigurationSchema("ApolloTrack",{adapter:""},{baseConfiguration:r.createBaseTrackConfig(e),explicitIdentifier:"trackId"});return new r.TrackType({name:"ApolloTrack",configSchema:t,stateModel:r.createBaseTrackModel(e,"ApolloTrack",t)})})),e.addInternetAccountType((()=>new r.InternetAccountType({name:"ApolloInternetAccount",configSchema:Pn,stateModel:kc(Pn)}))),e.addDisplayType((()=>new r.DisplayType({name:"LinearApolloDisplay",configSchema:Gu,stateModel:Wd(0,Gu),trackType:"ApolloTrack",viewType:"LinearGenomeView",ReactComponent:Wf}))),e.addDisplayType((()=>new r.DisplayType({name:"LinearApolloSixFrameDisplay",configSchema:sf,stateModel:_f(0,sf),trackType:"ApolloTrack",viewType:"LinearGenomeView",ReactComponent:Jf}))),e.addDisplayType((()=>new r.DisplayType({name:"LinearApolloReferenceSequenceDisplay",configSchema:Jd,stateModel:of(0,Jd),displayName:"Apollo reference sequence display",trackType:"ReferenceSequenceTrack",viewType:"LinearGenomeView",ReactComponent:af}))),e.addToExtensionPoint("Core-extendSession",nh.bind(this,e)),e.addToExtensionPoint("Core-extendPluggableElement",(e=>{if("LinearGenomeView"===e.name){const{stateModel:t}=e,n=t.views((e=>{const t=e.rubberBandMenuItems;return{rubberBandMenuItems:()=>[...t(),{label:"Add new feature",icon:Ln,onClick:()=>{const t=o.getSession(e),{leftOffset:n,rightOffset:r}=e,i=e.getSelectedRegions(n,r);t.queueDialog((e=>[Rl,{session:t,handleClose:()=>{e()},region:i[0],changeManager:t.apolloDataStore.changeManager}]))}}]}}));e.stateModel=n}return e})),e.addToExtensionPoint("Core-extendPluggableElement",Nf),e.addToExtensionPoint("Core-extendPluggableElement",Df),e.addToExtensionPoint("Core-preProcessTrackConfig",(e=>{if("ReferenceSequenceTrack"!==e.type)return e;const t=e.displays??[],n=t.findIndex((e=>"LinearApolloReferenceSequenceDisplay"===e.type));if(0===n)return e;if(-1===n)return{...e,displays:[{type:"LinearApolloReferenceSequenceDisplay",displayId:`${e.trackId}-LinearApolloReferenceSequenceDisplay`},...t]};const r=t.toSpliced(n,1);return r.unshift({type:"LinearApolloReferenceSequenceDisplay",displayId:`${e.trackId}-LinearApolloReferenceSequenceDisplay`}),{...e,displays:r}})),e.addToExtensionPoint("LinearGenomeView-searchResultSelected",((e,t)=>{const{session:n,result:r}=t,o=r.getTrackId(),i=r.matchedObject;return o?.startsWith("apollo_track_")&&i&&n.apolloSetEventualSelectedFeature(i._id),e})),rh||e.addToExtensionPoint("Core-extendWorker",(t=>"on"in t.client&&t.client.on?(t.client.on("apollo",(async n=>{if("object"!=typeof(r=n)||null===r||!("apollo"in r)||!0!==r.apollo)return;var r;const{apollo:o,messageId:i,method:a}=n;switch(a){case"getSequence":{const{region:r}=n,{assemblyName:a}=r,s=e.rootModel?.session?.apolloDataStore;if(!s)break;const l=s.getBackendDriver(a);if(!l)break;const{seq:c}=await l.getSequence(r);t.worker.postMessage({apollo:o,messageId:i,sequence:c});break}case"getRegions":{const{assembly:r}=n,a=e.rootModel?.session?.apolloDataStore;if(!a)break;const s=a.getBackendDriver(r);if(!s)break;const l=await s.getRegions(r);t.worker.postMessage({apollo:o,messageId:i,regions:l});break}case"getRefNameAliases":{const{assembly:r}=n,a=e.rootModel?.session?.apolloDataStore;if(!a)break;const s=a.getBackendDriver(r);if(!s)break;const l=await s.getRefNameAliases(r);t.worker.postMessage({apollo:o,messageId:i,refNameAliases:l});break}}})),t):t))}configure(e){o.isAbstractMenuManager(e.rootModel)&&(e.jexl.addFunction("geneBackgroundColor",(e=>"pseudogene"===e?s.alpha("rgb(148, 203, 236)",.6):"ncRNA_gene"===e?s.alpha("rgb(194, 106, 119)",.6):void 0)),function(e){e.insertInMenu("Apollo",{label:"Redo",icon:Yf,onClick(e){const{apolloDataStore:t}=e;t.changeManager.redoLastChange()}},0),e.insertInMenu("Apollo",{label:"Undo",icon:Xf,onClick(e){const{apolloDataStore:t}=e;t.changeManager.undoLastChange()}},0),e.appendToMenu("Apollo",{label:"Lock/Unlock session",onClick:e=>{e.toggleLocked()}});const{internetAccounts:t}=e;t.some((e=>Xl(e)))&&e.appendToMenu("Apollo",{label:"Log out",icon:Kf,onClick:e=>{e.queueDialog((t=>[Kl,{session:e,handleClose:()=>{t()}}]))}})}(e.rootModel))}},Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
2
2
|
//# sourceMappingURL=jbrowse-plugin-apollo.umd.production.min.js.map
|