dmn-js
Version:
A dmn toolkit and web modeler
17 lines • 529 kB
JavaScript
/*! dmn-js - dmn-navigated-viewer v18.0.1 | Copyright (c) 2014-present, camunda Services GmbH | bpmn.io/license */
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).DmnJS=t()}(this,function(){"use strict";const e=Object.prototype.toString,t=Object.prototype.hasOwnProperty;function n(e){return void 0===e}function i(e){return void 0!==e}function r(e){return null==e}function o(t){return"[object Array]"===e.call(t)}function s(t){return"[object Object]"===e.call(t)}function a(t){return"[object Number]"===e.call(t)}function l(t){const n=e.call(t);return"[object Function]"===n||"[object AsyncFunction]"===n||"[object GeneratorFunction]"===n||"[object AsyncGeneratorFunction]"===n||"[object Proxy]"===n}function c(t){return"[object String]"===e.call(t)}function h(e,n){return!r(e)&&t.call(e,n)}function u(e,t){const n=w(t);let i;return d(e,function(e,t){if(n(e,t))return i=e,!1}),i}function p(e,t){const n=w(t);let i=[];return d(e,function(e,t){n(e,t)&&i.push(e)}),i}function d(e,t){let i,r;if(n(e))return;const s=o(e)?x:b;for(let n in e)if(h(e,n)&&(i=e[n],r=t(i,s(n)),!1===r))return i}function f(e,t,n){return d(e,function(e,i){n=t(n,e,i)}),n}function g(e,t){return!!f(e,function(e,n,i){return e&&t(n,i)},!0)}function m(e,t){let n=[];return d(e,function(e,i){n.push(t(e,i))}),n}function y(e,t){t=function(e){return l(e)?e:t=>t[e]}(t);let n=[];return d(e,function(e,i){let r=t(e,i),o={d:r,v:e};for(var s=0;s<n.length;s++){let{d:e}=n[s];if(r<e)return void n.splice(s,0,o)}n.push(o)}),m(n,e=>e.v)}function v(e){return function(t){return g(e,function(e,n){return t[n]===e})}}function w(e){return l(e)?e:t=>t===e}function b(e){return e}function x(e){return Number(e)}function _(e,t){let n,i,r,o;function s(n){let s=Date.now(),c=n?0:o+t-s;if(c>0)return a(c);e.apply(r,i),l()}function a(e){n=setTimeout(s,e)}function l(){n&&clearTimeout(n),n=o=i=r=void 0}function c(...e){o=Date.now(),i=e,r=this,n||a(t)}return c.flush=function(){n&&s(!0),l()},c.cancel=l,c}function k(e,t){return e.bind(t)}function S(e,...t){return Object.assign(e,...t)}var C="__fn",E=Array.prototype.slice;function M(){this._listeners={},this.on("diagram.destroy",1,this._destroy,this)}function A(){}function T(){}function R(e,t){this.model=e,this.properties=t}M.prototype.on=function(e,t,n,i){if(e=o(e)?e:[e],l(t)&&(i=n,n=t,t=1e3),!a(t))throw new Error("priority must be a number");var r=n;i&&((r=k(n,i))[C]=n[C]||n);var s=this;e.forEach(function(e){s._addListener(e,{priority:t,callback:r,next:null})})},M.prototype.once=function(e,t,n,i){var r=this;if(l(t)&&(i=n,n=t,t=1e3),!a(t))throw new Error("priority must be a number");function o(){o.__isTomb=!0;var t=n.apply(i,arguments);return r.off(e,o),t}o[C]=n,this.on(e,t,o)},M.prototype.off=function(e,t){e=o(e)?e:[e];var n=this;e.forEach(function(e){n._removeListener(e,t)})},M.prototype.createEvent=function(e){var t=new A;return t.init(e),t},M.prototype.fire=function(e,t){var n,i,r,o;if(o=E.call(arguments),"object"==typeof e&&(e=(t=e).type),!e)throw new Error("no event type specified");if(i=this._listeners[e]){n=t instanceof A?t:this.createEvent(t),o[0]=n;var s=n.type;e!==s&&(n.type=e);try{r=this._invokeListeners(n,o,i)}finally{e!==s&&(n.type=s)}return void 0===r&&n.defaultPrevented&&(r=!1),r}},M.prototype.handleError=function(e){return!1===this.fire("error",{error:e})},M.prototype._destroy=function(){this._listeners={}},M.prototype._invokeListeners=function(e,t,n){for(var i;n&&!e.cancelBubble;)i=this._invokeListener(e,t,n),n=n.next;return i},M.prototype._invokeListener=function(e,t,n){var i;if(n.callback.__isTomb)return i;try{i=function(e,t){return e.apply(null,t)}(n.callback,t),void 0!==i&&(e.returnValue=i,e.stopPropagation()),!1===i&&e.preventDefault()}catch(e){if(!this.handleError(e))throw console.error("unhandled error in event listener",e),e}return i},M.prototype._addListener=function(e,t){var n,i=this._getListeners(e);if(i){for(;i;){if(i.priority<t.priority)return t.next=i,void(n?n.next=t:this._setListeners(e,t));n=i,i=i.next}n.next=t}else this._setListeners(e,t)},M.prototype._getListeners=function(e){return this._listeners[e]},M.prototype._setListeners=function(e,t){this._listeners[e]=t},M.prototype._removeListener=function(e,t){var n,i,r,o=this._getListeners(e);if(t)for(;o;)n=o.next,(r=o.callback)!==t&&r[C]!==t||(i?i.next=n:this._setListeners(e,n)),i=o,o=n;else this._setListeners(e,null)},A.prototype.stopPropagation=function(){this.cancelBubble=!0},A.prototype.preventDefault=function(){this.defaultPrevented=!0},A.prototype.init=function(e){S(this,e||{})},T.prototype.get=function(e){return this.$model.properties.get(this,e)},T.prototype.set=function(e,t){this.$model.properties.set(this,e,t)},R.prototype.createType=function(e){var t=this.model,n=this.properties,i=Object.create(T.prototype);d(e.properties,function(e){e.isMany||void 0===e.default||(i[e.name]=e.default)}),n.defineModel(i,t),n.defineDescriptor(i,e);var r=e.ns.name;function o(e){n.define(this,"$type",{value:r,enumerable:!0}),n.define(this,"$attrs",{value:{}}),n.define(this,"$parent",{writable:!0}),d(e,k(function(e,t){this.set(t,e)},this))}return o.prototype=i,o.hasType=i.$instanceOf=this.model.hasType,n.defineModel(o,t),n.defineDescriptor(o,e),o};var O=S(Object.create(null),{String:!0,Boolean:!0,Integer:!0,Real:!0,Element:!0}),D=S(Object.create(null),{String:function(e){return e},Boolean:function(e){return"true"===e},Integer:function(e){return parseInt(e,10)},Real:function(e){return parseFloat(e)}});function q(e,t){var n=D[e];return n?n(t):t}function N(e){return!!O[e]}function B(e){return!!D[e]}function P(e,t){var n,i,r=e.split(/:/);if(1===r.length)n=e,i=t;else{if(2!==r.length)throw new Error("expected <prefix:localName> or <localName>, got "+e);n=r[1],i=r[0]}return{name:e=(i?i+":":"")+n,prefix:i,localName:n}}function L(e){this.ns=e,this.name=e.name,this.allTypes=[],this.allTypesByName=Object.create(null),this.properties=[],this.propertiesByName=Object.create(null)}function I(e,t){this.packageMap=Object.create(null),this.typeMap=Object.create(null),this.packages=[],this.properties=t,d(e,k(this.registerPackage,this))}function j(e,t,n){var i=t[n];if(i in e)throw new Error("package with "+n+" <"+i+"> already defined")}function F(e){this.model=e}function V(e,t,n){Object.defineProperty(e,t.name,{enumerable:!t.isReference,writable:!0,value:n,configurable:!0})}function $(e){return e.replace(/^:/,"")}function z(e,t={}){this.properties=new F(this),this.factory=new R(this,this.properties),this.registry=new I(e,this.properties),this.typeCache=Object.create(null),this.config=t}L.prototype.build=function(){return function(e,t){let n={},i=Object(e);return d(t,function(t){t in i&&(n[t]=e[t])}),n}(this,["ns","name","allTypes","allTypesByName","properties","propertiesByName","bodyProperty","idProperty"])},L.prototype.addProperty=function(e,t,n){"boolean"==typeof t&&(n=t,t=void 0),this.addNamedProperty(e,!1!==n);var i=this.properties;void 0!==t?i.splice(t,0,e):i.push(e)},L.prototype.replaceProperty=function(e,t,n){var i=e.ns,r=this.properties,o=this.propertiesByName,s=e.name!==t.name;if(e.isId){if(!t.isId)throw new Error("property <"+t.ns.name+"> must be id property to refine <"+e.ns.name+">");this.setIdProperty(t,!1)}if(e.isBody){if(!t.isBody)throw new Error("property <"+t.ns.name+"> must be body property to refine <"+e.ns.name+">");this.setBodyProperty(t,!1)}var a=r.indexOf(e);if(-1===a)throw new Error("property <"+i.name+"> not found in property list");r.splice(a,1),this.addProperty(t,n?void 0:a,s),o[i.name]=o[i.localName]=t},L.prototype.redefineProperty=function(e,t,n){var i=e.ns.prefix,r=t.split("#"),o=P(r[0],i),s=P(r[1],o.prefix).name,a=this.propertiesByName[s];if(!a)throw new Error("refined property <"+s+"> not found");this.replaceProperty(a,e,n),delete e.redefines},L.prototype.addNamedProperty=function(e,t){var n=e.ns,i=this.propertiesByName;t&&(this.assertNotDefined(e,n.name),this.assertNotDefined(e,n.localName)),i[n.name]=i[n.localName]=e},L.prototype.removeNamedProperty=function(e){var t=e.ns,n=this.propertiesByName;delete n[t.name],delete n[t.localName]},L.prototype.setBodyProperty=function(e,t){if(t&&this.bodyProperty)throw new Error("body property defined multiple times (<"+this.bodyProperty.ns.name+">, <"+e.ns.name+">)");this.bodyProperty=e},L.prototype.setIdProperty=function(e,t){if(t&&this.idProperty)throw new Error("id property defined multiple times (<"+this.idProperty.ns.name+">, <"+e.ns.name+">)");this.idProperty=e},L.prototype.assertNotTrait=function(e){if((e.extends||[]).length)throw new Error(`cannot create <${e.name}> extending <${e.extends}>`)},L.prototype.assertNotDefined=function(e,t){var n=e.name,i=this.propertiesByName[n];if(i)throw new Error("property <"+n+"> already defined; override of <"+i.definedBy.ns.name+"#"+i.ns.name+"> by <"+e.definedBy.ns.name+"#"+e.ns.name+"> not allowed without redefines")},L.prototype.hasProperty=function(e){return this.propertiesByName[e]},L.prototype.addTrait=function(e,t){t&&this.assertNotTrait(e);var n=this.allTypesByName,i=this.allTypes,r=e.name;r in n||(d(e.properties,k(function(n){n=S({},n,{name:n.ns.localName,inherited:t}),Object.defineProperty(n,"definedBy",{value:e});var i=n.replaces,r=n.redefines;i||r?this.redefineProperty(n,i||r,i):(n.isBody&&this.setBodyProperty(n),n.isId&&this.setIdProperty(n),this.addProperty(n))},this)),i.push(e),n[r]=e)},I.prototype.getPackage=function(e){return this.packageMap[e]},I.prototype.getPackages=function(){return this.packages},I.prototype.registerPackage=function(e){e=S({},e);var t=this.packageMap;j(t,e,"prefix"),j(t,e,"uri"),d(e.types,k(function(t){this.registerType(t,e)},this)),t[e.uri]=t[e.prefix]=e,this.packages.push(e)},I.prototype.registerType=function(e,t){var n=P((e=S({},e,{superClass:(e.superClass||[]).slice(),extends:(e.extends||[]).slice(),properties:(e.properties||[]).slice(),meta:S({},e.meta||{})})).name,t.prefix),i=n.name,r=Object.create(null);d(e.properties,k(function(e){var t=P(e.name,n.prefix),i=t.name;N(e.type)||(e.type=P(e.type,t.prefix).name),S(e,{ns:t,name:i}),r[i]=e},this)),S(e,{ns:n,name:i,propertiesByName:r}),d(e.extends,k(function(e){var t=P(e,n.prefix),r=this.typeMap[t.name];r.traits=r.traits||[],r.traits.push(i)},this)),this.definePackage(e,t),this.typeMap[i]=e},I.prototype.mapTypes=function(e,t,n){var i=N(e.name)?{name:e.name}:this.typeMap[e.name],r=this;function o(n,i){var o=P(n,N(n)?"":e.prefix);r.mapTypes(o,t,i)}function s(e){return o(e,!0)}if(!i)throw new Error("unknown type <"+e.name+">");d(i.superClass,n?s:function(e){return o(e,!1)}),t(i,!n),d(i.traits,s)},I.prototype.getEffectiveDescriptor=function(e){var t=P(e),n=new L(t);this.mapTypes(t,function(e,t){n.addTrait(e,t)});var i=n.build();return this.definePackage(i,i.allTypes[i.allTypes.length-1].$pkg),i},I.prototype.definePackage=function(e,t){this.properties.define(e,"$pkg",{value:t})},F.prototype.set=function(e,t,n){if(!c(t)||!t.length)throw new TypeError("property name must be a non-empty string");var i=this.getProperty(e,t),r=i&&i.name;void 0===n?i?delete e[r]:delete e.$attrs[$(t)]:i?r in e?e[r]=n:V(e,i,n):e.$attrs[$(t)]=n},F.prototype.get=function(e,t){var n=this.getProperty(e,t);if(!n)return e.$attrs[$(t)];var i=n.name;return!e[i]&&n.isMany&&V(e,n,[]),e[i]},F.prototype.define=function(e,t,n){if(!n.writable){var i=n.value;delete(n=S({},n,{get:function(){return i}})).value}Object.defineProperty(e,t,n)},F.prototype.defineDescriptor=function(e,t){this.define(e,"$descriptor",{value:t})},F.prototype.defineModel=function(e,t){this.define(e,"$model",{value:t})},F.prototype.getProperty=function(e,t){var n=this.model,i=n.getPropertyDescriptor(e,t);if(i)return i;if(t.includes(":"))return null;const r=n.config.strict;if(void 0!==r){const n=new TypeError(`unknown property <${t}> on <${e.$type}>`);if(r)throw n;"undefined"!=typeof console&&console.warn(n)}return null},z.prototype.create=function(e,t){var n=this.getType(e);if(!n)throw new Error("unknown type <"+e+">");return new n(t)},z.prototype.getType=function(e){var t=this.typeCache,n=c(e)?e:e.ns.name,i=t[n];return i||(e=this.registry.getEffectiveDescriptor(n),i=t[n]=this.factory.createType(e)),i},z.prototype.createAny=function(e,t,o){var a=P(e),l={$type:e,$instanceOf:function(e){return e===this.$type},get:function(e){return this[e]},set:function(e,t){!function(e,t,o){let s=e;d(t,function(e,a){if("number"!=typeof e&&"string"!=typeof e)throw new Error("illegal key type: "+typeof e+". Key should be of type number or string.");if("constructor"===e)throw new Error("illegal key: constructor");if("__proto__"===e)throw new Error("illegal key: __proto__");let l=t[a+1],c=s[e];i(l)&&r(c)&&(c=s[e]=isNaN(+l)?{}:[]),n(l)?n(o)?delete s[e]:s[e]=o:s=c})}(this,[e],t)}},c={name:e,isGeneric:!0,ns:{prefix:a.prefix,localName:a.localName,uri:t}};return this.properties.defineDescriptor(l,c),this.properties.defineModel(l,this),this.properties.define(l,"get",{enumerable:!1,writable:!0}),this.properties.define(l,"set",{enumerable:!1,writable:!0}),this.properties.define(l,"$parent",{enumerable:!1,writable:!0}),this.properties.define(l,"$instanceOf",{enumerable:!1,writable:!0}),d(o,function(e,t){s(e)&&void 0!==e.value?l[e.name]=e.value:l[t]=e}),l},z.prototype.getPackage=function(e){return this.registry.getPackage(e)},z.prototype.getPackages=function(){return this.registry.getPackages()},z.prototype.getElementDescriptor=function(e){return e.$descriptor},z.prototype.hasType=function(e,t){return void 0===t&&(t=e,e=this),t in e.$model.getElementDescriptor(e).allTypesByName},z.prototype.getPropertyDescriptor=function(e,t){return this.getElementDescriptor(e).propertiesByName[t]},z.prototype.getTypeDescriptor=function(e){return this.registry.typeMap[e]};var W=String.fromCharCode,H=Object.prototype.hasOwnProperty,U=/&#(\d+);|&#x([0-9a-f]+);|&(\w+);/gi,G={amp:"&",apos:"'",gt:">",lt:"<",quot:'"'};function K(e,t,n,i){return i?H.call(G,i)?G[i]:"&"+i+";":W(t||parseInt(n,16))}function X(e){return e.length>3&&-1!==e.indexOf("&")?e.replace(U,K):e}Object.keys(G).forEach(function(e){G[e.toUpperCase()]=G[e]});var Y="non-whitespace outside of root node";function J(e){return new Error(e)}function Q(e){return{get:e,enumerable:!0}}function Z(e,t,n,i){n in t||(t[n]=n in e?e[n]:null),e[n]=i}function ee(e,t){var n,i;for(n in t)null===(i=t[n])?delete e[n]:e[n]=i}function te(e){return e+"$uri"}function ne(){return{line:0,column:0}}function ie(e){throw e}function re(e){if(!this)return new re(e);var t,n,i,r,o,s,a,l,c,h,u,p,d=e&&e.proxy,f=ie,g=ne,m=!1,y=!1,v="",w=!1,b=!1,x=null,_=!1;function k(e){e instanceof Error||(e=J(e)),x=e,f(e,g)}function S(e){o&&(e instanceof Error||(e=J(e)),o(e,g))}function C(){c=b?[]:null,h=b?function(e){var t,n,i=Object.create(null);for(t in e)i[n=e[t]]=n,i[te(n)]=t;return i}(p):null,u=[],g=ne,_=!1,x=null,y=!1,v=""}function E(e,o=!1){var f,m,v,x,C,E,M,A,T,R,O,D,q=null,N=0,B=!1,P=!1,L=0,I=0,j="",F=0;function V(e,t){var n=e.indexOf(":");if(-1===n)return e;var i=h[e.substring(0,n)];return i?t===i?e.substr(n+1):i+e.substr(n):(S(function(e){return"missing namespace for prefix <"+e+">"}(e.substring(0,n))),null)}function $(){if(null!==D)return D;var e,t,n,i,r,o,s,a,l,c=b&&h.xmlns,u=b&&w?[]:null,d=F,g=j,y=g.length,v={},x=new Set;e:for(;d<y;d++)if(s=!1,!(32===(a=g.charCodeAt(d))||a<14&&a>8)){for((a<65||a>122||a>90&&a<97)&&95!==a&&58!==a&&(S("illegal first char attribute name"),s=!0),l=d+1;l<y;l++)if(!((a=g.charCodeAt(l))>96&&a<123||a>64&&a<91||a>47&&a<59||46===a||45===a||95===a)){if(32===a||a<14&&a>8){S("missing attribute value"),d=l;continue e}if(61===a)break;S("illegal attribute name char"),s=!0}if("xmlns:xmlns"===(o=g.substring(d,l))&&(S("illegal declaration of xmlns"),s=!0),34===(a=g.charCodeAt(l+1)))-1===(l=g.indexOf('"',d=l+2))&&-1!==(l=g.indexOf("'",d))&&(S("attribute value quote missmatch"),s=!0);else if(39===a)-1===(l=g.indexOf("'",d=l+2))&&-1!==(l=g.indexOf('"',d))&&(S("attribute value quote missmatch"),s=!0);else for(S("missing attribute value quotes"),s=!0,l+=1;l<y&&!(32===(a=g.charCodeAt(l+1))||a<14&&a>8);l++);for(-1===l&&(S("missing closing quotes"),l=y,s=!0),s||(i=g.substring(d,l)),"xmlns:xml"===o&&"http://www.w3.org/XML/1998/namespace"!==i&&k("illegal value of xmlns:xml"),d=l;l+1<y&&!(32===(a=g.charCodeAt(l+1))||a<14&&a>8);l++)d===l&&(S("illegal character after attribute end"),s=!0);if(d=l+1,!s)if(x.has(o))S("attribute <"+o+"> already defined");else if(x.add(o),b)if(w){if(null!==(n="xmlns"===o?"xmlns":120===o.charCodeAt(0)&&"xmlns:"===o.substr(0,6)?o.substr(6):null)){if(e=X(i),t=te(n),!(r=p[e])){if("xmlns"===n||t in h&&h[t]!==e)do{r="ns"+N++}while(void 0!==h[r]);else r=n;p[e]=r}h[n]!==r&&(f||(f=Object.create(null)),q=null,m=null,Z(h,f,n,r),"xmlns"===n&&(Z(h,f,te(r),e),c=r),Z(h,f,t,e)),v[o]=i;continue}u.push(o,i)}else null!==(o=V(o,c))&&(v[o]=i);else v[o]=i}if(w)for(d=0,y=u.length;d<y;d++)o=V(u[d++],c),i=u[d],null!==o&&(v[o]=i);return D=v}for(g=function(){for(var t,n,i=/(\r\n|\r|\n)/g,r=0,o=0,s=0,a=I;L>=s&&(t=i.exec(e))&&!((a=t[0].length+t.index)>L);)r+=1,s=a;return-1==L?(o=a,n=e.substring(I)):0===I?n=e.substring(I,L):(o=L-s,n=-1==I?e.substring(L):e.substring(L,I+1)),{data:n,line:r,column:o}},d&&(O=Object.create({},{name:Q(function(){return T}),originalName:Q(function(){return R}),attrs:Q($),ns:Q(function(){return m||(m=Object.assign(Object.create(null),h)),m})}));-1!==I;){if(-1===(L=60===e.charCodeAt(I)?I:e.indexOf("<",I)))return o?e.substring(I):u.length?k("unexpected end of file"):y?void(I<e.length&&e.substring(I).trim()&&S(Y)):k("missing start tag");if(y||(y=!0),I!==L)if(u.length){if(t&&(t(e.substring(I,L),X,g),_))return}else if(e.substring(I,L).trim()&&(S(Y),_))return;if(33===(E=e.charCodeAt(L+1))){if(91===(C=e.charCodeAt(L+2))&&"CDATA["===e.substr(L+3,6)){if(-1===(I=e.indexOf("]]>",L)))return o?e.substring(L):k("unclosed cdata");if(r&&(r(e.substring(L+9,I),g),_))return;I+=3;continue}if(45===C&&45===e.charCodeAt(L+3)){if(-1===(I=e.indexOf("--\x3e",L)))return o?e.substring(L):k("unclosed comment");if(s&&(s(e.substring(L+4,I),X,g),_))return;I+=3;continue}}if(63!==E){for(v=L+1;;v++){if(M=e.charCodeAt(v),isNaN(M))return o?e.substring(L):(I=-1,k("unclosed tag"));if(34===M)v=-1!==(C=e.indexOf('"',v+1))?C:v;else if(39===M)v=-1!==(C=e.indexOf("'",v+1))?C:v;else if(62===M){I=v;break}}if(33!==E){if(D={},47===E){if(B=!1,P=!0,!u.length)return k("missing open tag");if(v=T=u.pop(),C=L+2+v.length,e.substring(L+2,C)!==v)return k("closing tag mismatch");for(;C<I;C++)if(!(32===(E=e.charCodeAt(C))||E>8&&E<14))return k("close tag")}else{if(47===e.charCodeAt(I-1)?(v=T=e.substring(L+1,I-1),B=!0,P=!0):(v=T=e.substring(L+1,I),B=!0,P=!1),!(E>96&&E<123||E>64&&E<91||95===E||58===E))return k("illegal first char nodeName");for(C=1,x=v.length;C<x;C++)if(!((E=v.charCodeAt(C))>96&&E<123||E>64&&E<91||E>47&&E<59||45===E||95===E||46==E)){if(32===E||E<14&&E>8){T=v.substring(0,C),D=null;break}return k("invalid nodeName")}P||u.push(T)}if(b){B&&(f=null,null===D&&(w=-1!==v.indexOf("xmlns",C))&&(F=C,j=v,$(),w=!1),P||c.push(f)),R=T,null===q&&(q=Object.create(null));var z=q[T];if(void 0!==z)T=z;else{if(-1!==(E=T.indexOf(":"))){if(!(A=h[T.substring(0,E)]))return k("missing namespace on <"+R+">");T=T.substr(E+1)}else A=h.xmlns;A&&(T=A+":"+T),q[R]=T}}if(B&&(F=C,j=v,n&&(d?n(O,X,P,g):n(T,$,X,P,g),_)))return;if(P){if(i&&(i(d?O:T,X,B,g),_))return;b&&(B||(f=c.pop()),f&&(ee(h,f),f=null,q=null,m=null))}I+=1}else{if(l&&(l(e.substring(L,I+1),X,g),_))return;I+=1}}else{if(-1===(I=e.indexOf("?>",L)))return o?e.substring(L):k("unclosed question");if(a&&(a(e.substring(L,I+2),g),_))return;I+=2}}}this.on=function(e,c){if("function"!=typeof c)throw J("required args <name, cb>");switch(e){case"openTag":n=c;break;case"text":t=c;break;case"closeTag":i=c;break;case"error":f=c;break;case"warn":o=c;break;case"cdata":r=c;break;case"attention":l=c;break;case"question":a=c;break;case"comment":s=c;break;default:throw J("unsupported event: "+e)}return this},this.ns=function(e){if(void 0===e&&(e={}),"object"!=typeof e)throw J("required args <nsMap={}>");var t,n=Object.create(null);for(t in e)n[t]=e[t];return b=!0,p=n,this},this.parse=function(e){if("string"!=typeof e)throw J("required args <xml=string>");if(m)throw J("parse during stream; call end() first");return C(),E(e),g=ne,_=!1,x},this.write=function(e){if("string"!=typeof e)throw J("required args <xml=string>");return m||(C(),m=!0),x||(v=E(v+e,!0)||""),this},this.end=function(){return m||C(),m=!1,x||E(v),v="",g=ne,_=!1,x},this.stop=function(){_=!0}}function oe(e){return e.xml&&"lowerCase"===e.xml.tagAlias}var se={xsi:"http://www.w3.org/2001/XMLSchema-instance",xml:"http://www.w3.org/XML/1998/namespace"},ae="property";function le(e){return e.xml&&e.xml.serialize}function ce(e,t){return oe(t)?e.prefix+":"+((n=e.localName).charAt(0).toUpperCase()+n.slice(1)):e.name;var n}function he(e){return new Error(e)}function ue(e){return e.$descriptor}function pe(e){S(this,e),this.elementsById={},this.references=[],this.warnings=[],this.addReference=function(e){this.references.push(e)},this.addElement=function(e){if(!e)throw he("expected element");var t,n=this.elementsById,i=ue(e).idProperty;if(i&&(t=e.get(i.name))){if(!/^([a-z][\w-.]*:)?[a-z_][\w-.]*$/i.test(t))throw new Error("illegal ID <"+t+">");if(n[t])throw he("duplicate ID <"+t+">");n[t]=e}},this.addWarning=function(e){this.warnings.push(e)}}function de(){}function fe(){}function ge(){}function me(e,t){this.property=e,this.context=t}function ye(e,t){this.element=t,this.propertyDesc=e}function ve(){}function we(e,t,n){this.model=e,this.type=e.getType(t),this.context=n}function be(e,t,n){we.call(this,e,t,n)}function xe(e,t,n){this.model=e,this.context=n}function _e(e){e instanceof z&&(e={model:e}),S(this,{lax:!1},e)}de.prototype.handleEnd=function(){},de.prototype.handleText=function(){},de.prototype.handleNode=function(){},fe.prototype=Object.create(de.prototype),fe.prototype.handleNode=function(){return this},ge.prototype=Object.create(de.prototype),ge.prototype.handleText=function(e){this.body=(this.body||"")+e},me.prototype=Object.create(ge.prototype),me.prototype.handleNode=function(e){if(this.element)throw he("expected no sub nodes");return this.element=this.createReference(e),this},me.prototype.handleEnd=function(){this.element.id=this.body},me.prototype.createReference=function(e){return{property:this.property.ns.name,id:""}},ye.prototype=Object.create(ge.prototype),ye.prototype.handleEnd=function(){var e=this.body||"",t=this.element,n=this.propertyDesc;e=q(n.type,e),n.isMany?t.get(n.name).push(e):t.set(n.name,e)},ve.prototype=Object.create(ge.prototype),ve.prototype.handleNode=function(e){var t=this,n=this.element;return n?t=this.handleChild(e):(n=this.element=this.createElement(e),this.context.addElement(n)),t},we.prototype=Object.create(ve.prototype),we.prototype.addReference=function(e){this.context.addReference(e)},we.prototype.handleText=function(e){if(!ue(this.element).bodyProperty)throw he("unexpected body text <"+e+">");ge.prototype.handleText.call(this,e)},we.prototype.handleEnd=function(){var e=this.body,t=this.element,n=ue(t).bodyProperty;n&&void 0!==e&&(e=q(n.type,e),t.set(n.name,e))},we.prototype.createElement=function(e){var t,n=e.attributes,i=this.type,r=ue(i),o=this.context,s=new i({}),a=this.model;return d(n,function(e,n){var i=r.propertiesByName[n];i&&i.isReference?i.isMany?d(e.split(" "),function(e){o.addReference({element:s,property:i.ns.name,id:e})}):o.addReference({element:s,property:i.ns.name,id:e}):(i?e=q(i.type,e):"xmlns"===n?n=":"+n:(t=P(n,r.ns.prefix),a.getPackage(t.prefix)&&o.addWarning({message:"unknown attribute <"+n+">",element:s,property:n,value:e})),s.set(n,e))}),s},we.prototype.getPropertyForNode=function(e){var t=P(e.name),n=this.type,i=this.model,r=ue(n),o=t.name,s=r.propertiesByName[o];if(s&&!s.isAttr){const t=function(e){const t=le(e);return t!==ae&&(t||null)}(s);if(t){const n=e.attributes[t];if(n){const t=function(e,t,n){const i=P(e,t.xmlns),r=P(`${t[i.prefix]||i.prefix}:${i.localName}`);return function(e,t){var n=e.name,i=e.localName,r=t&&t.xml&&t.xml.typePrefix;return r&&0===i.indexOf(r)?e.prefix+":"+i.slice(r.length):n}(r,n.getPackage(r.prefix))}(n,e.ns,i);return S({},s,{effectiveType:ue(i.getType(t)).name})}}return s}var a=i.getPackage(t.prefix);if(a){const e=ce(t,a),n=i.getType(e);if(s=u(r.properties,function(e){return!e.isVirtual&&!e.isReference&&!e.isAttribute&&n.hasType(e.type)}))return S({},s,{effectiveType:ue(n).name})}else if(s=u(r.properties,function(e){return!e.isReference&&!e.isAttribute&&"Element"===e.type}))return s;throw he("unrecognized element <"+t.name+">")},we.prototype.toString=function(){return"ElementDescriptor["+ue(this.type).name+"]"},we.prototype.valueHandler=function(e,t){return new ye(e,t)},we.prototype.referenceHandler=function(e){return new me(e,this.context)},we.prototype.handler=function(e){return"Element"===e?new xe(this.model,e,this.context):new we(this.model,e,this.context)},we.prototype.handleChild=function(e){var t,n,i,r;if(t=this.getPropertyForNode(e),i=this.element,B(n=t.effectiveType||t.type))return this.valueHandler(t,i);var o=(r=t.isReference?this.referenceHandler(t).handleNode(e):this.handler(n).handleNode(e)).element;return void 0!==o&&(t.isMany?i.get(t.name).push(o):i.set(t.name,o),t.isReference?(S(o,{element:i}),this.context.addReference(o)):o.$parent=i),r},be.prototype=Object.create(we.prototype),be.prototype.createElement=function(e){var t=e.name,n=P(t),i=this.model,r=this.type,o=i.getPackage(n.prefix),s=o&&ce(n,o)||t;if(!r.hasType(s))throw he("unexpected element <"+e.originalName+">");return we.prototype.createElement.call(this,e)},xe.prototype=Object.create(ve.prototype),xe.prototype.createElement=function(e){var t=e.name,n=P(t).prefix,i=e.ns[n+"$uri"],r=e.attributes;return this.model.createAny(t,i,r)},xe.prototype.handleChild=function(e){var t=new xe(this.model,"Element",this.context).handleNode(e),n=this.element,i=t.element;return void 0!==i&&((n.$children=n.$children||[]).push(i),i.$parent=n),t},xe.prototype.handleEnd=function(){this.body&&(this.element.$body=this.body)},_e.prototype.fromXML=function(e,t,n){var i=t.rootHandler;t instanceof we?(i=t,t={}):"string"==typeof t?(i=this.handler(t),t={}):"string"==typeof i&&(i=this.handler(i));var r=this.model,o=this.lax,s=new pe(S({},t,{rootHandler:i})),a=new re({proxy:!0}),l=function(){var e=[];return Object.defineProperty(e,"peek",{value:function(){return this[this.length-1]}}),e}();function c(e,t,n){var i=t(),r=i.line,o=i.column,a=i.data;"<"===a.charAt(0)&&-1!==a.indexOf(" ")&&(a=a.slice(0,a.indexOf(" "))+">");var l="unparsable content "+(a?a+" ":"")+"detected\n\tline: "+r+"\n\tcolumn: "+o+"\n\tnested error: "+e.message;if(n)return s.addWarning({message:l,error:e}),!0;throw he(l)}function h(e,t){return c(e,t,!0)}i.context=s,l.push(i);var u=/^<\?xml /i,p=/ encoding="([^"]+)"/i,d=/^utf-8$/i;function f(e,t){try{l.peek().handleText(e)}catch(e){h(e,t)}}var g=r.getPackages().reduce(function(e,t){return e[t.uri]=t.prefix,e},Object.entries(se).reduce(function(e,[t,n]){return e[n]=t,e},r.config&&r.config.nsMap||{}));return a.ns(g).on("openTag",function(e,t,n,i){var r=e.attrs||{},s=Object.keys(r).reduce(function(e,n){var i=t(r[n]);return e[n]=i,e},{});!function(e,t){var n=l.peek();try{l.push(n.handleNode(e))}catch(e){c(e,t,o)&&l.push(new fe)}}({name:e.name,originalName:e.originalName,attributes:s,ns:e.ns},i)}).on("question",function(e){if(u.test(e)){var t=p.exec(e),n=t&&t[1];n&&!d.test(n)&&s.addWarning({message:"unsupported document encoding <"+n+">, falling back to UTF-8"})}}).on("closeTag",function(){l.pop().handleEnd()}).on("cdata",f).on("text",function(e,t,n){!function(e,t){e.trim()&&f(e,t)}(t(e),n)}).on("error",c).on("warn",h),new Promise(function(t,n){var r;try{a.parse(e),function(){var e,t,n=s.elementsById,i=s.references;for(e=0;t=i[e];e++){var r=t.element,o=n[t.id],a=ue(r).propertiesByName[t.property];if(o||s.addWarning({message:"unresolved reference <"+t.id+">",element:t.element,property:t.property,value:t.id}),a.isMany){var l=r.get(a.name),c=l.indexOf(t);-1===c&&(c=l.length),o?l[c]=o:l.splice(c,1)}else r.set(a.name,o)}}()}catch(e){r=e}var o=i.element;r||o||(r=he("failed to parse document as <"+i.type.$descriptor.name+">"));var l=s.warnings,c=s.references,h=s.elementsById;return r?(r.warnings=l,n(r)):t({rootElement:o,elementsById:h,references:c,warnings:l})})},_e.prototype.handler=function(e){return new be(this.model,e)};var ke=/<|>|'|"|&|\n\r|\n/g,Se=/<|>|&/g;function Ce(e){this.prefixMap={},this.uriMap={},this.used={},this.wellknown=[],this.custom=[],this.parent=e,this.defaultPrefixMap=e&&e.defaultPrefixMap||{}}function Ee(e,t){return oe(t)?function(e){return e.charAt(0).toLowerCase()+e.slice(1)}(e):e}function Me(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}function Ae(e){return c(e)?e:(e.prefix?e.prefix+":":"")+e.localName}Ce.prototype.mapDefaultPrefixes=function(e){this.defaultPrefixMap=e},Ce.prototype.defaultUriByPrefix=function(e){return this.defaultPrefixMap[e]},Ce.prototype.resolve=function(e){for(var t=this;t;){var n=e(t);if(n)return n;t=t.parent}},Ce.prototype.eachScope=function(e){for(var t=this;t;)e(t),t=t.parent},Ce.prototype.byUri=function(e){return this.resolve(function(t){return t.uriMap[e]})},Ce.prototype.add=function(e,t){this.uriMap[e.uri]=e,t?this.wellknown.push(e):this.custom.push(e),this.mapPrefix(e.prefix,e.uri)},Ce.prototype.uriByPrefix=function(e){var t=e||"xmlns";return this.resolve(function(e){return e.prefixMap[t]})},Ce.prototype.mapPrefix=function(e,t){this.prefixMap[e||"xmlns"]=t},Ce.prototype.getNSKey=function(e){return void 0!==e.prefix?e.uri+"|"+e.prefix:e.uri},Ce.prototype.logUsed=function(e){var t=e.uri,n=this.getNSKey(e),i=this.byUri(t);this.eachScope(function(e){e.used[n]=i})},Ce.prototype.getUsed=function(e){return[].concat(this.wellknown,this.custom).filter(e=>{var t=this.getNSKey(e);return this.used[t]})};var Te={"\n":"#10","\n\r":"#10",'"':"#34","'":"#39","<":"#60",">":"#62","&":"#38"},Re={"<":"lt",">":"gt","&":"amp"};function Oe(e,t,n){return(e=c(e)?e:""+e).replace(t,function(e){return"&"+n[e]+";"})}function De(e){this.tagName=e}function qe(){}function Ne(e){this.tagName=e}function Be(e,t){this.body=[],this.attrs=[],this.parent=e,this.propertyDescriptor=t}function Pe(e,t,n){Be.call(this,e,t),this.serialization=n}function Le(){this.value="",this.write=function(e){this.value+=e}}function Ie(e,t){var n=[""];this.append=function(t){return e.write(t),this},this.appendNewLine=function(){return t&&e.write("\n"),this},this.appendIndent=function(){return t&&e.write(n.join(" ")),this},this.indent=function(){return n.push(""),this},this.unindent=function(){return n.pop(),this}}function je(e){return e=S({format:!1,preamble:!0},e||{}),{toXML:function(t,n){var i=n||new Le,r=new Ie(i,e.format);e.preamble&&r.append('<?xml version="1.0" encoding="UTF-8"?>\n');var o=new Be,s=t.$model;if(o.getNamespaces().mapDefaultPrefixes(function(e){const t=e.config&&e.config.nsMap||{},n={};for(const e in se)n[e]=se[e];for(const e in t){n[t[e]]=e}for(const t of e.getPackages())n[t.prefix]=t.uri;return n}(s)),o.build(t).serializeTo(r),!n)return i.value}}}function Fe(e,t){z.call(this,e,t)}De.prototype.build=function(e){return this.element=e,this},De.prototype.serializeTo=function(e){e.appendIndent().append("<"+this.tagName+">"+this.element.id+"</"+this.tagName+">").appendNewLine()},qe.prototype.serializeValue=qe.prototype.serializeTo=function(e){e.append(this.escape?Oe(this.value,Se,Re):this.value)},qe.prototype.build=function(e,t){return this.value=t,"String"===e.type&&-1!==t.search(Se)&&(this.escape=!0),this},Me(Ne,qe),Ne.prototype.serializeTo=function(e){e.appendIndent().append("<"+this.tagName+">"),this.serializeValue(e),e.append("</"+this.tagName+">").appendNewLine()},Be.prototype.build=function(e){return function(e,t){var n=[{serializer:e,children:e.enter(t),index:0}];for(;n.length;){var i=n[n.length-1];if(i.index>=i.children.length)i.serializer.exit(),n.pop();else{var r=i.children[i.index++],o=r.create();i.serializer.body.push(o),r.element&&n.push({serializer:o,children:o.enter(r.element),index:0})}}}(this,e),this},Be.prototype.enter=function(e){this.element=e;var t=e.$descriptor,n=this.propertyDescriptor,i=t.isGeneric;if(this.otherAttrs=i?this.parseGenericNsAttributes(e):this.parseNsAttributes(e),this.ns=n?this.nsPropertyTagName(n):this.nsTagName(t),this.tagName=this.addTagName(this.ns),i)return this.collectGenericContainments(e);var r=function(e){return p(e.$descriptor.properties,function(t){var n=t.name;if(t.isVirtual)return!1;if(!h(e,n))return!1;var i=e[n];return i!==t.default&&null!==i&&(!t.isMany||i.length)})}(e);return this.parseAttributes(p(r,function(e){return e.isAttr})),this.collectContainments(function(e){return p(e,function(e){return!e.isAttr})}(r))},Be.prototype.exit=function(){this.parseGenericAttributes(this.element,this.otherAttrs)},Be.prototype.nsTagName=function(e){return function(e,t){return t.isGeneric?S({localName:t.ns.localName},e):S({localName:Ee(t.ns.localName,t.$pkg)},e)}(this.logNamespaceUsed(e.ns),e)},Be.prototype.nsPropertyTagName=function(e){return function(e,t){return S({localName:t.ns.localName},e)}(this.logNamespaceUsed(e.ns),e)},Be.prototype.isLocalNs=function(e){return e.uri===this.ns.uri},Be.prototype.nsAttributeName=function(e){var t;if(t=c(e)?P(e):e.ns,e.inherited)return{localName:t.localName};var n=this.logNamespaceUsed(t);return this.getNamespaces().logUsed(n),this.isLocalNs(n)?{localName:t.localName}:S({localName:t.localName},n)},Be.prototype.parseGenericNsAttributes=function(e){return Object.entries(e).filter(([t,n])=>!t.startsWith("$")&&this.parseNsAttribute(e,t,n)).map(([e,t])=>({name:e,value:t}))},Be.prototype.collectGenericContainments=function(e){var t=this,n=[],i=e.$body;i&&n.push({create:function(){return(new qe).build({type:"String"},i)}});var r=e.$children;return r&&d(r,function(e){n.push({create:function(){return new Be(t)},element:e})}),n},Be.prototype.parseNsAttribute=function(e,t,n){var i,r=e.$model,o=P(t);if("xmlns"===o.prefix&&(i={prefix:o.localName,uri:n}),o.prefix||"xmlns"!==o.localName||(i={uri:n}),!i)return{name:t,value:n};if(r&&r.getPackage(n))this.logNamespace(i,!0,!0);else{var s=this.logNamespaceUsed(i,!0);this.getNamespaces().logUsed(s)}},Be.prototype.parseNsAttributes=function(e){var t=this,n=e.$attrs,i=[];return d(n,function(n,r){var o=t.parseNsAttribute(e,r,n);o&&i.push(o)}),i},Be.prototype.parseGenericAttributes=function(e,t){var n=this;d(t,function(t){try{n.addAttribute(n.nsAttributeName(t.name),t.value)}catch(n){"undefined"!=typeof console&&console.warn(`missing namespace information for <${t.name}=${t.value}> on`,e,n)}})},Be.prototype.collectContainments=function(e){var t=this,n=this.element,i=[];return d(e,function(e){var r=n.get(e.name),o=e.isReference;if(e.isMany||(r=[r]),e.isBody)i.push({create:function(){return(new qe).build(e,r[0])}});else if(B(e.type))d(r,function(n){i.push({create:function(){return new Ne(t.addTagName(t.nsPropertyTagName(e))).build(e,n)}})});else if(o)d(r,function(n){i.push({create:function(){return new De(t.addTagName(t.nsPropertyTagName(e))).build(n)}})});else{var s=le(e);d(r,function(n){i.push({create:function(){return s?s===ae?new Be(t,e):new Pe(t,e,s):new Be(t)},element:n})})}}),i},Be.prototype.getNamespaces=function(e){var t=this.namespaces;if(!t){var n=this.getParentNamespaces();e||!n?this.namespaces=t=new Ce(n):t=n}return t},Be.prototype.getParentNamespaces=function(){if(void 0!==this.parentNamespaces)return this.parentNamespaces;for(var e=null,t=this.parent;t;){if(t.namespaces){e=t.namespaces;break}if(void 0!==t.parentNamespaces){e=t.parentNamespaces;break}t=t.parent}return this.parentNamespaces=e},Be.prototype.logNamespace=function(e,t,n){var i=this.getNamespaces(n),r=e.uri,o=e.prefix;return i.byUri(r)&&!n||i.add(e,t),i.mapPrefix(o,r),e},Be.prototype.logNamespaceUsed=function(e,t){var n,i,r,o=this.getNamespaces(t),s=e.prefix,a=e.uri;if(!s&&!a)return{localName:e.localName};if(r=o.defaultUriByPrefix(s),!(a=a||r||o.uriByPrefix(s)))throw new Error("no namespace uri given for prefix <"+s+">");if((e=o.byUri(a))||s||(e=this.logNamespace({uri:a},r===a,!0)),!e){for(n=s,i=1;o.uriByPrefix(n);)n=s+"_"+i++;e=this.logNamespace({prefix:n,uri:a},r===a)}return s&&o.mapPrefix(s,a),e},Be.prototype.parseAttributes=function(e){var t=this,n=this.element;d(e,function(e){var i=n.get(e.name);if(e.isReference)if(e.isMany){var r=[];d(i,function(e){r.push(e.id)}),i=r.join(" ")}else i=i.id;t.addAttribute(t.nsAttributeName(e),i)})},Be.prototype.addTagName=function(e){var t=this.logNamespaceUsed(e);return this.getNamespaces().logUsed(t),Ae(e)},Be.prototype.addAttribute=function(e,t){var n=this.attrs;c(t)&&(t=Oe(t,ke,Te));var i=function(e,t){const n=w(t);let i=o(e)?-1:void 0;return d(e,function(e,t){if(n(e,t))return i=t,!1}),i}(n,function(t){return t.name.localName===e.localName&&t.name.uri===e.uri&&t.name.prefix===e.prefix}),r={name:e,value:t};-1!==i?n.splice(i,1,r):n.push(r)},Be.prototype.serializeAttributes=function(e){var t=this.attrs,n=this.namespaces;n&&(t=function(e){return e.getUsed().filter(function(e){return"xml"!==e.prefix}).map(function(e){return{name:"xmlns"+(e.prefix?":"+e.prefix:""),value:e.uri}})}(n).concat(t)),d(t,function(t){e.append(" ").append(Ae(t.name)).append('="').append(t.value).append('"')})},Be.prototype.serializeTo=function(e){!function(e,t){var n=[{serializer:e,index:0,opened:!1,indent:!1}];for(;n.length;){var i=n[n.length-1],r=i.serializer;if(!i.opened){var o=r.body[0];if(i.indent=o&&o.constructor!==qe,t.appendIndent().append("<"+r.tagName),r.serializeAttributes(t),t.append(o?">":" />"),i.opened=!0,!o){t.appendNewLine(),n.pop();continue}i.indent&&t.appendNewLine().indent()}if(i.index<r.body.length){var s=r.body[i.index++];s instanceof Be?n.push({serializer:s,index:0,opened:!1,indent:!1}):s.serializeTo(t)}else i.indent&&t.unindent().appendIndent(),t.append("</"+r.tagName+">").appendNewLine(),n.pop()}}(this,e)},Me(Pe,Be),Pe.prototype.parseNsAttributes=function(e){var t=Be.prototype.parseNsAttributes.call(this,e).filter(e=>e.name!==this.serialization),n=e.$descriptor;if(n.name===this.propertyDescriptor.type)return t;var i=this.typeNs=this.nsTagName(n);this.getNamespaces().logUsed(this.typeNs);var r=e.$model.getPackage(i.uri),o=r.xml&&r.xml.typePrefix||"";return this.addAttribute(this.nsAttributeName(this.serialization),(i.prefix?i.prefix+":":"")+o+n.ns.localName),t},Pe.prototype.isLocalNs=function(e){return e.uri===(this.typeNs||this.ns).uri},Fe.prototype=Object.create(z.prototype),Fe.prototype.fromXML=function(e,t,n){c(t)||(n=t,t="dmn:Definitions");var i=new _e(S({model:this,lax:!0},n)),r=i.handler(t);return i.fromXML(e,r)},Fe.prototype.toXML=function(e,t){var n=new je(t);return new Promise(function(t,i){try{return t({xml:n.toXML(e)})}catch(e){return i(e)}})};var Ve={dc:{name:"DC",prefix:"dc",uri:"http://www.omg.org/spec/DMN/20180521/DC/",types:[{name:"Dimension",properties:[{name:"width",isAttr:!0,type:"Real"},{name:"height",isAttr:!0,type:"Real"}]},{name:"Bounds",properties:[{name:"height",isAttr:!0,type:"Real"},{name:"width",isAttr:!0,type:"Real"},{name:"x",isAttr:!0,type:"Real"},{name:"y",isAttr:!0,type:"Real"}]},{name:"Point",properties:[{name:"x",isAttr:!0,type:"Real"},{name:"y",isAttr:!0,type:"Real"}]},{name:"Color",properties:[{name:"red",type:"UML_Standard_Profile.mdzip:eee_1045467100323_917313_65"},{name:"green",type:"UML_Standard_Profile.mdzip:eee_1045467100323_917313_65"},{name:"blue",type:"UML_Standard_Profile.mdzip:eee_1045467100323_917313_65"}]}],associations:[],enumerations:[{name:"AlignmentKind",literalValues:[{name:"start"},{name:"center"},{name:"end"}]}]},di:{name:"DI",prefix:"di",uri:"http://www.omg.org/spec/DMN/20180521/DI/",types:[{name:"DiagramElement",isAbstract:!0,properties:[{name:"extension",type:"Extension"},{name:"id",isAttr:!0,isId:!0,type:"String"},{name:"style",isReference:!0,type:"Style",xml:{serialize:"property"}},{name:"sharedStyle",isReference:!0,isVirtual:!0,type:"Style"}]},{name:"Diagram",superClass:["DiagramElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"documentation",isAttr:!0,type:"String"},{name:"resolution",isAttr:!0,type:"Real"}]},{name:"Shape",isAbstract:!0,properties:[{name:"bounds",type:"dc:Bounds"}],superClass:["DiagramElement"]},{name:"Edge",isAbstract:!0,properties:[{name:"waypoint",type:"dc:Point",isMany:!0,xml:{serialize:"property"}}],superClass:["DiagramElement"]},{name:"Style",isAbstract:!0,properties:[{name:"id",isAttr:!0,isId:!0,type:"String"}]},{name:"Extension",properties:[{name:"values",isMany:!0,type:"Element"}]}],associations:[],enumerations:[],xml:{tagAlias:"lowerCase"}},dmn:{name:"DMN",prefix:"dmn",uri:"https://www.omg.org/spec/DMN/20191111/MODEL/",types:[{name:"AuthorityRequirement",superClass:["DMNElement"],properties:[{name:"requiredAuthority",type:"DMNElementReference",xml:{serialize:"property"}},{name:"requiredDecision",type:"DMNElementReference",xml:{serialize:"property"}},{name:"requiredInput",type:"DMNElementReference",xml:{serialize:"property"}}]},{name:"ItemDefinition",superClass:["NamedElement"],properties:[{name:"typeRef",type:"String"},{name:"allowedValues",type:"UnaryTests",xml:{serialize:"property"}},{name:"typeLanguage",type:"String",isAttr:!0},{name:"itemComponent",type:"ItemDefinition",isMany:!0,xml:{serialize:"property"}},{name:"functionItem",type:"FunctionItem"},{name:"isCollection",isAttr:!0,type:"Boolean"}]},{name:"Definitions",superClass:["NamedElement"],properties:[{name:"import",type:"Import",isMany:!0},{name:"itemDefinition",type:"ItemDefinition",isMany:!0},{name:"drgElement",type:"DRGElement",isMany:!0},{name:"artifact",type:"Artifact",isMany:!0},{name:"elementCollection",type:"ElementCollection",isMany:!0},{name:"businessContextElement",type:"BusinessContextElement",isMany:!0},{name:"namespace",type:"String",isAttr:!0},{name:"expressionLanguage",type:"String",isAttr:!0},{name:"typeLanguage",type:"String",isAttr:!0},{name:"exporter",isAttr:!0,type:"String"},{name:"exporterVersion",isAttr:!0,type:"String"},{name:"dmnDI",type:"dmndi:DMNDI"}]},{name:"KnowledgeSource",superClass:["DRGElement"],properties:[{name:"authorityRequirement",type:"AuthorityRequirement",isMany:!0},{name:"type",type:"String"},{name:"owner",type:"DMNElementReference",xml:{serialize:"property"}},{name:"locationURI",type:"String",isAttr:!0}]},{name:"DecisionRule",superClass:["DMNElement"],properties:[{name:"inputEntry",type:"UnaryTests",isMany:!0,xml:{serialize:"property"}},{name:"outputEntry",type:"LiteralExpression",isMany:!0,xml:{serialize:"property"}},{name:"annotationEntry",type:"RuleAnnotation",isMany:!0,xml:{serialize:"property"}}]},{name:"Expression",isAbstract:!0,superClass:["DMNElement"],properties:[{name:"typeRef",isAttr:!0,type:"String"}]},{name:"InformationItem",superClass:["NamedElement"],properties:[{name:"typeRef",isAttr:!0,type:"String"}]},{name:"Decision",superClass:["DRGElement"],properties:[{name:"question",type:"String",xml:{serialize:"property"}},{name:"allowedAnswers",type:"String",xml:{serialize:"property"}},{name:"variable",type:"InformationItem",xml:{serialize:"property"}},{name:"informationRequirement",type:"InformationRequirement",isMany:!0},{name:"knowledgeRequirement",type:"KnowledgeRequirement",isMany:!0},{name:"authorityRequirement",type:"AuthorityRequirement",isMany:!0},{name:"supportedObjective",isMany:!0,type:"DMNElementReference",xml:{serialize:"property"}},{name:"impactedPerformanceIndicator",type:"DMNElementReference",isMany:!0,xml:{serialize:"property"}},{name:"decisionMaker",type:"DMNElementReference",isMany:!0,xml:{serialize:"property"}},{name:"decisionOwner",type:"DMNElementReference",isMany:!0,xml:{serialize:"property"}},{name:"usingProcess",isMany:!0,type:"DMNElementReference",xml:{serialize:"property"}},{name:"usingTask",isMany:!0,type:"DMNElementReference",xml:{serialize:"property"}},{name:"decisionLogic",type:"Expression"}]},{name:"Invocation",superClass:["Expression"],properties:[{name:"calledFunction",type:"Expression"},{name:"binding",type:"Binding",isMany:!0}]},{name:"OrganisationalUnit",superClass:["BusinessContextElement"],properties:[{name:"decisionMade",type:"Decision",isReference:!0,isMany:!0},{name:"decisionOwned",type:"Decision",isReference:!0,isMany:!0}]},{name:"Import",superClass:["NamedElement"],properties:[{name:"importType",type:"String",isAttr:!0},{name:"locationURI",type:"String",isAttr:!0},{name:"namespace",type:"String",isAttr:!0}]},{name:"InformationRequirement",superClass:["DMNElement"],properties:[{name:"requiredDecision",type:"DMNElementReference",xml:{serialize:"property"}},{name:"requiredInput",type:"DMNElementReference",xml:{serialize:"property"}}]},{name:"ElementCollection",superClass:["NamedElement"],properties:[{name:"drgElement",type:"DMNElementReference",isMany:!0,xml:{serialize:"property"}}]},{name:"DRGElement",isAbstract:!0,superClass:["NamedElement"],properties:[]},{name:"InputData",superClass:["DRGElement"],properties:[{name:"variable",type:"InformationItem",xml:{serialize:"property"}}]},{name:"DMNElement",isAbstract:!0,properties:[{name:"description",type:"String"},{name:"extensionElements",type:"ExtensionElements"},{name:"id",type:"String",isAttr:!0,isId:!0},{name:"extensionAttribute",type:"ExtensionAttribute",isMany:!0},{name:"label",isAttr:!0,type:"String"}]},{name:"InputClause",superClass:["DMNElement"],properties:[{name:"inputExpression",type:"LiteralExpression",xml:{serialize:"property"}},{name:"inputValues",type:"UnaryTests",xml:{serialize:"property"}}]},{name:"DecisionTable",superClass:["Expression"],properties:[{name:"input",type:"InputClause",isMany:!0,xml:{serialize:"property"}},{name:"output",type:"OutputClause",isMany:!0,xml:{serialize:"property"}},{name:"annotation",type:"RuleAnnotationClause",isMany:!0,xml:{serialize:"property"}},{name:"rule",type:"DecisionRule",isMany:!0,xml:{serialize:"property"}},{name:"hitPolicy",type:"HitPolicy",isAttr:!0,default:"UNIQUE"},{name:"aggregation",type:"BuiltinAggregator",isAttr:!0},{name:"preferredOrientation",type:"DecisionTableOrientation",isAttr:!0},{name:"outputLabel",isAttr:!0,type:"String"}]},{name:"LiteralExpression",superClass:["Expression"],properties:[{name:"expressionLanguage",type:"String",isAttr:!0},{name:"text",type:"String"},{name:"importedValues",type:"ImportedValues"}]},{name:"Binding",properties:[{name:"parameter",type:"InformationItem",xml:{serialize:"property"}},{name:"bindingFormula",type:"Expression"}]},{name:"KnowledgeRequirement",superClass:["DMNElement"],properties:[{name:"requiredKnowledge",type:"DMNElementReference",xml:{serialize:"property"}}]},{name:"BusinessKnowledgeModel",superClass:["Invocable"],properties:[{name:"encapsulatedLogic",type:"FunctionDefinition",xml:{serialize:"property"}},{name:"knowledgeRequirement",type:"KnowledgeRequirement",isMany:!0},{name:"authorityRequirement",type:"AuthorityRequirement",isMany:!0}]},{name:"BusinessContextElement",isAbstract:!0,superClass:["NamedElement"],properties:[{name:"URI",type:"String",isAttr:!0}]},{name:"PerformanceIndicator",superClass:["BusinessContextElement"],properties:[{name:"impactingDecision",type:"DMNElementReference",isMany:!0,xml:{serialize:"property"}}]},{name:"FunctionDefinition",superClass:["Expression"],properties:[{name:"formalParameter",type:"InformationItem",isMany:!0,xml:{serialize:"property"}},{name:"body",type:"Expression"},{name:"kind",type:"FunctionKind",isAttr:!0}]},{name:"Context",superClass:["Expression"],properties:[{name:"contextEntry",type:"ContextEntry",isMany:!0}]},{name:"ContextEntry",superClass:["DMNElement"],properties:[{name:"variable",type:"InformationItem",xml:{serialize:"property"}},{name:"value",type:"Expression"}]},{name:"List",superClass:["Expression"],properties:[{name:"elements",isMany:!0,type:"Expression"}]},{name:"Relation",superClass:["Expression"],properties:[{name:"column",type:"InformationItem",isMany:!0,xml:{serialize:"property"}},{name:"row",type:"List",isMany:!0,xml:{serialize:"property"}}]},{name:"OutputClause",superClass:["DMNElement"],properties:[{name:"outputValues",type:"UnaryTests",xml:{serialize:"property"}},{name:"defaultOutputEntry",type:"LiteralExpression",xml:{serialize:"property"}},{name:"name",isAttr:!0,type:"String"},{name:"typeRef",isAttr:!0,type:"String"}]},{name:"UnaryTests",superClass:["Expression"],properties:[{name:"text",type:"String"},{name:"expressionLanguage",type:"String",isAttr:!0}]},{name:"NamedElement",isAbstract:!0,superClass:["DMNElement"],properties:[{name:"name",isAttr:!0,type:"String"}]},{name:"ImportedValues",superClass:["Import"],properties:[{name:"importedElement",type:"String"},{name:"expressionLanguage",type:"String",isAttr:!0}]},{name:"DecisionService",superClass:["Invocable"],properties:[{name:"outputDecision",type:"DMNElementReference",isMany:!0,xml:{serialize:"property"}},{name:"encapsulatedDecision",type:"DMNElementReference",isMany:!0,xml:{serialize:"property"}},{name:"inputDecision",type:"DMNElementReference",isMany:!0,xml:{serialize:"property"}},{name:"inputData",type:"DMNElementReference",isMany:!0,xml:{serialize:"property"}}]},{name:"ExtensionElements",properties:[{name:"values",type:"Element",isMany:!0}]},{name:"ExtensionAttribute",properties:[{name:"value",type:"Element"},{name:"valueRef",type:"Element",isAttr:!0,isReference:!0},{name:"name",isAttr:!0,type:"String"}]},{name:"Element",isAbstract:!0,properties:[{name:"extensionAttribute",type:"ExtensionAttribute",isAttr:!0,isReference:!0},{name:"elements",type:"ExtensionElements",isAttr:!0,isReference:!0}]},{name:"Artifact",isAbstract:!0,superClass:["DMNElement"],properties:[]},{name:"Association",superClass:["Artifact"],properties:[{name:"sourceRef",type:"DMNElementReference",xml:{serialize:"property"}},{name:"targetRef",type:"DMNElementReference",xml:{serialize:"property"}},{name:"associationDirection",type:"AssociationDirection",isAttr:!0}]},{name:"TextAnnotation",superClass:["Artifact"],properties:[{name:"text",type:"String"},{name:"textFormat",isAttr:!0,type:"String",default:"text/plain"}]},{name:"RuleAnnotationClause",properties:[{name:"name",isAttr:!0,type:"String"}]},{name:"RuleAnnotation",properties:[{name:"text",type:"String"}]},{name:"Invocable",isAbstract:!0,superClass:["DRGElement"],properties:[{name:"variable",type:"InformationItem",xml:{serialize:"property"}}]},{name:"Group",superClass:["Artifact"],properties:[{name:"name",isAttr:!0,type:"String"}]},{name:"FunctionItem",superClass:["DMNElement"],properties:[{name:"parameters",isMany:!0,type:"InformationItem",xml:{serialize:"property"}},{name:"outputTypeRef",isAttr:!0,type:"String"}]},{name:"DMNElementReference",properties:[{isAttr:!0,name:"href",type:"String"}]}],enumerations:[{name:"HitPolicy",literalValues:[{name:"UNIQUE"},{name:"FIRST"},{name:"PRIORITY"},{name:"ANY"},{name:"COLLECT"},{name:"RULE ORDER"},{name:"OUTPUT ORDER"}]},{name:"BuiltinAggregator",literalValues:[{name:"SUM"},{name:"COUNT"},{name:"MIN"},{name:"MAX"}]},{name:"DecisionTableOrientation",literalValues:[{name:"Rule-as-Row"},{name:"Rule-as-Column"},{name:"CrossTable"}]},{name:"AssociationDirection",literalValues:[{name:"None"},{name:"One"},{name:"Both"}]},{name:"FunctionKind",literalValues:[{name:"FEEL"},{name:"Java"},{name:"PMML"}]}],associations:[],xml:{tagAlias:"lowerCase"}},dmndi:{name:"DMNDI",prefix:"dmndi",uri:"https://www.omg.org/spec/DMN/20191111/DMNDI/",types:[{name:"DMNDI",properties:[{name:"diagrams",type:"DMNDiagram",isMany:!0},{name:"styles",type:"DMNStyle",isMany:!0}]},{name:"DMNStyle",superClass:["di:Style"],properties:[{name:"fillColor",type:"dc:Color",isAttr:!0},{name:"strokeColor",type:"dc:Color",isAttr:!0},{name:"fontColor",type:"dc:Color",isAttr:!0},{name:"fontSize",isAttr:!0,type:"Real"},{name:"fontFamily",isAttr:!0,type:"String"},{name:"fontItalic",isAttr:!0,type:"Boolean"},{name:"fontBold",isAttr:!0,type:"Boolean"},{name:"fontUnderline",isAttr:!0,type:"Boolean"},{name:"fontStrikeThrough",isAttr:!0,type:"Boolean"},{name:"labelHorizontalAlignment",type:"dc:AlignmentKind",isAttr:!0},{name:"labelVerticalAlignment",type:"dc:AlignmentKind",isAttr:!0}]},{name:"DMNDiagram",superClass:["di:Diagram"],properties:[{name:"dmnElementRef",type:"dmn:DMNElement",isAttr:!0,isReference:!0},{name:"size",type:"Size"},{name:"localStyle",type:"DMNStyle",isVirtual:!0},{name:"sharedStyle",type:"DMNStyle",isVirtual:!0,isReference:!0,redefines:"di:DiagramElement#sharedStyle"},{name:"diagramElements",type:"DMNDiagramElement",isMany:!0}]},{name:"DMNDiagramElement",isAbstract:!0,superClass:["di:DiagramElement"],properties:[{name:"dmnElementRef",type:"dmn:DMNElement",isAttr:!0,isReference:!0},{name:"sharedStyle",type:"DMNStyle",isVirtual:!0,isReference:!0,redefines:"di:DiagramElement#sharedStyle"},{name:"localStyle",type:"DMNStyle",isVirtual:!0},{name:"label",type:"DMNLabel"}]},{name:"DMNLabel",superClass:["di:Shape"],properties:[{name:"text",type:"Text"}]},{name:"DMNShape",superClass:["di:Shape","DMNDiagramElement"],properties:[{name:"isListedInputData",isAttr:!0,type:"Boolean"},{name:"decisionServiceDividerLine",type:"DMNDecisionServiceDividerLine"},{name:"isCollapsed",isAttr:!0,type:"Boolean"}]},{name:"DMNEdge",superClass:["di:Edge","DMNDiagramElement"],properties:[{name:"sourceElement",type:"DMNDiagramElement",isAttr:!0,isReference:!0},{name:"targetElement",type:"DMNDiagramElement",isAttr:!0,isReference:!0}]},{name:"DMNDecisionServiceDividerLine",superClass:["di:Edge"]},{name:"Text",properties:[{name:"text",isBody:!0,type:"String"}]},{name:"Size",superClass:["dc:Dimension"]}],associations:[],enumerations:[]},biodi:{name:"bpmn.io DI for DMN",uri:"http://bpmn.io/schema/dmn/biodi/2.0",prefix:"biodi",xml:{tagAlias:"lowerCase"},types:[{name:"DecisionTable",isAbstract:!0,extends:["dmn:DecisionTable"],properties:[{name:"annotationsWidth",isAttr:!0,type:"Integer"}]},{name:"OutputClause",isAbstract:!0,extends:["dmn:OutputClause"],properties:[{name:"width",isAttr:!0,type:"Integer"}]},{name:"InputClause",isAbstract:!0,extends:["dmn:InputClause"],properties:[{name:"width",isAttr:!0,type:"Integer"}]}]}};function $e(e,t){return new Fe(S({},Ve,e),t)}const ze={legend:[1,"<fieldset>","</fieldset>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],_default:[0,"",""]};function We(e,t=globalThis.document){if("string"!=typeof e)throw new TypeError("String expected");const n=/^<!--(.*?)-->$/s.exec(e);if(n)return t.createComment(n[1]);const i=/<([\w:]+)/.exec(e)?.[1];if(!i)return t.createTextNode(e);if(e=e.trim(),"body"===i){const n=t.createElement("html");n.innerHTML=e;const{lastChild:i}=n;return i.remove(),i}let[r,o,s]=Object.hasOwn(ze,i)?ze[i]:ze._default,a=t.createElement("div");for(a.innerHTML=o+e+s;r--;)a=a.lastChild;if(a.firstChild===a.lastChild){const{firstChild:e}=a;return e.remove(),e}const l=t.createDocumentFragment();return l.append(...a.childNodes),l}function He(e,t){return t.forEach(function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach(function(n){if("default"!==n&&!(n in e)){var i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,i.get?i:{enumerable:!0,get:function(){return t[n]}})}})}),Object.freeze(e)}function Ue(e,...t){const n=e.style;return d(t,function(e){e&&d(e,function(e,t){n[t]=e})}),e}function Ge(e,t,n){return 2==arguments.length?e.getAttribute(t):null===n?e.removeAttribute(t):(e.setAttribute(t,n),e)}ze.td=ze.th=[3,"<table><tbody><tr>","</tr></tbody></table>"],ze.option=ze.optgroup=[1,'<select multiple="multiple">',"</select>"],ze.thead=ze.tbody=ze.colgroup=ze.caption=ze.tfoot=[1,"<table>","</table>"],ze.polyline=ze.ellipse=ze.polygon=ze.circle=ze.text=ze.line=ze.path=ze.rect=ze.g=[1,'<svg xmlns="http://www.w3.org/2000/svg" version="1.1">',"</svg>"];const Ke=Object.prototype.toString;function Xe(e){return new Ye(e)}function Ye(e){if(!e||!e.nodeType)throw new Error("A DOM element reference is required");this.el=e,this.list=e.classList}function Je(e){for(var t;t=e.firstChild;)e.removeChild(t);return e}function Qe(e,t,n){var i=n?e:e.parentNode;return i&&"function"==typeof i.closest&&i.closest(t)||null}function Ze(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}Ye.prototype.add=function(e){return this.list.add(e),this},Ye.prototype.remove=function(e){return"[object RegExp]"==Ke.call(e)?this.removeMatching(e):(this.list.remove(e),this)},Ye.prototype.removeMatching=function(e){const t=this.array();for(let n=0;n<t.length;n++)e.test(t[n])&&this.remove(t[n]);return this},Ye.prototype.toggle=function(e,t){return void 0!==t?t!==this.list.toggle(e,t)&&this.list.toggle(e):this.list.toggle(e),this},Ye.prototype.array=function(){return Array.from(this.list)},Ye.prototype.has=Ye.prototype.contains=function(e){return this.list.contains(e)};var et,tt={};var nt=function(){if(et)return tt;var e,t,n;function i(){e=window.addEventListener?"addEventListener":"attachEvent",t=window.removeEventListener?"removeEventListener":"detachEvent",n="addEventListener"!==e?"on":""}return et=1,tt.bind=function(t,r,o,s){return e||i(),t[e](n+r,o,s||!1),o},tt.unbind=function(e,r,o,s){return t||i(),e[t](n+r,o,s||!1),o},tt}(),it=He({__proto__:null,default:Ze(nt)},[nt]),rt=["focus","blur"];var ot={bind:function(e,t,n,i,r){return-1!==rt.indexOf(n)&&(r=!0),it.bind(e,n,function(n){var r=n.target||n.srcElement;n.delegateTarget=Qe(r,t,!0),n.delegateTarget&&i.call(e,n)},r)},unbind:function(e,t,n,i){return-1!==rt.indexOf(t)&&(i=!0),it.unbind(e,t,n,i)}};function st(e,t){return(t=t||document).querySelector(e)}function at(e){e.parentNode&&e.parentNode.removeChild(e)}function lt(e){return function(){if(!window.Promise)throw new Error("Promises is not supported in this environment. Please polyfill Promise.");var t=arguments.length;if(!(t>=1&&l(arguments[t-1])))return e.apply(this,arguments);var n=arguments[t-1];console.warn(new Error("Passing callbacks to "+function(e){return e.replace("bound ","")}(e.name)+" is deprecated and will be removed in a future major release. Please switch to promises: https://bpmn.io/l/moving-to-promises.html"));var i=Array.prototype.slice.call(arguments,0,-1);e.apply(this,i).then(function(e){var t=Object.keys(e)[0];return n(null,e[t])},function(e){return n(e,e.warnings)})}}const ct={width:"100%",height:"100%",position:"relative"};class ht{constructor(e={}){this._eventBus=new M,this._viewsChanged=_(this._viewsChanged,0),this._views=[],this._viewers={},this.open=lt(this.open.bind(this)),this.importXML=lt(this.importXML.bind(this)),this.saveXML=lt(this.saveXML.bind(this)),this._init(e)}importXML(e,t){var n=this;return t=t||{open:!0},new Promise(function(r,o){var s=n._activeView;n._clear().then(()=>{var a;e=n._emit("import.parse.start",{xml:e})||e,n._moddle.fromXML(e,"dmn:Definitions").then(e=>{var l=e.rootElement,c=e.references,h=e.elementsById;if(a=e.warnings,l=n._emit("import.parse.complete",i({error:null,definitions:l,elementsById:h,references:c,warnings:a}))||l,n._setDefinitions(l),!t.open)return n._emit("import.done",{error:null,warnings:a}),void r({warnings:a});var u=n._getInitialView(n._views,s);if(!u){var p=new Error("no displayable contents");return n._emit("import.done",{error:p,warnings:a}),p.warnings=a,o(p)}n.open(u).then(e=>({warnings:e.warnings})).catch(e=>({error:e,warnings:e.warnings})).then(e=>{var t=[].concat(a,e.warnings);n._emit("import.done",{error:e.error,warnings:t}),e.error?(e.error.warnings=t,o(e.error)):r({warnings:t})})}).catch(t=>(a=t.warnings,t=function(e,t){if("failed to parse document as <dmn:Definitions>"!==e.message)return null;var n=-1!==t.indexOf('"http://www.omg.org/spec/DMN/20151101/dmn.xsd"')?"1.1":-1!==t.indexOf('"http://www.omg.org/spec/DMN/20180521/MODEL/"')&&"1.2";if(!n)return null;return e=new Error("unsupported DMN "+n+" file detected; only DMN 1.3 files can be opened"),console.error("Cannot open what looks like a DMN "+n+" diagram. Please refer to https://bpmn.io/l/dmn-compatibility.html to learn how to make the toolkit compatible with older DMN files",e),e}(t,e)||function(e){var t=/unparsable content <([^>]+)> detected([\s\S]*)$/.exec(e.message);if(!t)return null;return e.message="unparsable content <"+t[1]+"> detected; this may indicate an invalid DMN 1.3 diagram file"+t[2],e}(t)||t,n._emit("import.parse.complete",i({error:t,warnings:a})),n._emit("import.done",{error:t,warnings:a}),t.warnings=a,o(t)))}).catch(e=>(n._emit("import.done",{error:e,warnings:[]}),e.warnings=[],o(e)))});function i(e){var t=n._eventBus.createEvent(e);return Object.defineProperty(t,"context",{enumerable:!0,get:function(){return console.warn(new Error("import.parse.complete <context> is deprecated and will be removed in future library versions")),{warnings:e.warnings,references:e.references,elementsById:e.elementsById}}}),t}}getDefinitions(){return this._definitions}getActiveView(){return this._activeView}getActiveViewer(){var e=this.getActiveView();return e&&this._getViewer(e)}getView(e){return this._views.filter(function(t){return t.element===e})[0]}getViews(){return this._views}saveXML(e){var t=this;e=e||{};var n=this._definitions;return new Promise(function(i,r){n?(n=t._emit("saveXML.start",{definitions:n})||n,t._moddle.toXML(n,e).then(function(e){var n=e.xml;return{xml:n=t._emit("saveXML.serialized",{xml:n})||n}}).catch(e=>({error:e})).then(e=>{t._emit("saveXML.done",e),e.error?r(e.error):i({xml:e.xml})})):r(new Error("no definitions loaded"))})}on(...e){this._eventBus.on(...e)}off(...e){this._eventBus.off(...e)}once(...e){this._eventBus.once(...e)}attachTo(e){e.get&&e.constructor.prototype.jquery&&(e=e.get(0)),"string"==typeof e&&(e=st(e)),e.appendChild(this._container),this._emit("attach",{})}detach(){this._emit("detach",{}),at(this._container)}destroy(){Object.keys(this._viewers).forEach(e=>{ft(this._viewers[e],"destroy")}),at(this._container)}_init(e){this._options=e,this._moddle=this._createModdle(e),this._viewers={},this._views=[];const t=We('<div class="dmn-js-parent bio-theme-parent"></div>'),n=S({},ct,e);S(t.style,{width:ut(n.width),height:ut(n.height),position:n.position}),this._container=t,e.container&&this.attachTo(e.container)}_clear(){return this._switchView(null)}open(e){return this._switchView(e)}_setDefinitions(e){this._definitions=e,this._updateViews()}_viewsChanged=()=>{this._emit("views.changed",{views:this._views,activeView:this._activeView})};_updateViews(){var e=this._definitions;if(!e)return this._views=[],void this._switchView(null);var t=this._getViewProviders(),n=[e,...e.drgElement||[]],i=this._views,r=[];for(var o of n){var s=u(t,function(e){return"string"==typeof e.opens?e.opens===o.$type:e.opens(o)});if(s){var a={element:o,id:o.id,name:o.name,type:s.id};r.push(a)}}var l,c=this._activeView;if(!c||(l=u(r,function(e){return pt(c,e)})||this._getInitialView(r),l)){var h=!pt(c,l)||dt(c,l),p=i.length!==r.length||!g(r,function(e){return u(i,function(t){return pt(t,e)&&!dt(t,e)})});this._activeView=l,this._views=r,(h||p)&&this._viewsChanged()}else this._switchView(null)}_getInitialView(e,t){var n;return t&&(n=u(e,function(e){return pt(e,t)})||u(e,function(e){return e.type===t})),n||e[0]}_switchView(e){var t=this;return new Promise(function(n,i){var r,o=(e,r)=>{t._viewsChanged(),e?i(e):n(r)},s=t.getActiveView(),a=e&&t._getViewer(e),l=e&&e.element;if(s&&(r=t._getViewer(s))!==a&&(ft(r,"clear"),r.detach()),t._activeView=e,a)return r!==a&&a.attachTo(t._container),t._emit("import.render.start",{view:e,element:l}),void a.open(l).then(n=>{t._emit("import.render.complete",{view:e,error:null,warnings:n.warnings}),o(null,n)}).catch(n=>{t._emit("import.render.complete",{view:e,error:n,warnings:n.warnings}),o(n,null)});o()})}_getViewer(e){var t=e.type,n=this._viewers[t];return n||(n=this._viewers[t]=this._createViewer(e.type),this._emit("viewer.created",{type:t,viewer:n})),n}_createViewer(e){var t=u(this._getViewProviders(),function(t){return t.id===e});if(!t)throw new Error("no provider for view type <"+e+">");var n=t.constructor,i=this._options[e]||{};return new n({...this._options.common||{},...i,additionalModules:[...i.additionalModules||[],{_parent:["value",this],moddle:["value",this._moddle]}]})}_emit(...e){return this._eventBus.fire(...e)}_createModdle(e){return new $e(e.moddleExtensions)}_getViewProviders(){return[]}}function ut(e){return e+(a(e)?"px":"")}function pt(e,t){return i(e)?!!i(t)&&(e.element===t.element||e.id===t.id):!i(t)}function dt(e,t){return!e||!t||e.name!==t.name}function ft(e,t){l(e[t])&&e[t]()}function gt(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}const mt=/^class[ {]/;function yt(e){return Array.isArray(e)}function vt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function wt(...e){1===e.length&&yt(e[0])&&(e=e[0]);const t=(e=[...e]).pop();return t.$inject=e,t}const bt=/constructor\s*[^(]*\(\s*([^)]*)\)/m,xt=/^(?:async\s+)?(?:function\s*[^(]*)?(?:\(\s*([^)]*)\)|(\w+))/m,_t=/\/\*([^*]*)\*\//m;function kt(e){if("function"!=typeof e)throw new Error(`Cannot annotate "${e}". Expected a function!`);const t=e.toString().match(function(e){return mt.test(e.toString())}(e)?bt:xt);if(!t)return[];const n=t[1]||t[2];return n&&n.split(",").map(e=>{const t=e.match(_t);return(t&&t[1]||e).trim()})||[]}function St(e,t){const n=t||{get:function(e,t){if(!1===t)return null;throw i.push(e),a(`No provider for "${e}"!`)}},i=[],r=this._providers=Object.create(n._providers||null),o=this._instances=Object.create(null),s=o.injector=this,a=function(e){const t=i.join(" -> ");return i.length=0,new Error(t?`${e} (Resolving: ${t})`:e)};function l(e,t){if(!r[e]&&e.includes(".")){const t=e.split(".");let n=l(t.shift());for(;t.length;)n=n[t.shift()];return n}if(vt(o,e))return o[e];if(vt(r,e)){if(-1!==i.indexOf(e))throw i.push(e),a("Cannot resolve circular dependency!");return i.push(e),o[e]=r[e][0](r[e][1]),i.pop(),o[e]}return n.get(e,t)}function c(e,t){if(void 0===t&&(t={}),"function"!=typeof e){if(!yt(e))throw a(`Cannot invoke "${e}". Expected a function!`);e=wt(e.slice())}return{fn:e,dependencies:(e.$inject||kt(e)).map(e=>vt(t,e)?t[e]:l(e))}}function h(e){const{fn:t,dependencies:n}=c(e);return new(Function.prototype.bind.call(t,null,...n))}function u(e,t,n){const{fn:i,dependencies:r}=c(e,n);return i.apply(t,r)}function p(e){return wt(t=>e.get(t))}function d(e,t){if(t&&t.length){const n=Object.create(null),i=Object.create(null),o=[],s=[],a=[];let l,c,h,u;for(let e in r)l=r[e],-1!==t.indexOf(e)&&("private"===l[2]?(c=o.indexOf(l[3]),-1===c?(h=l[3].createChild([],t),u=p(h),o.push(l[3]),s.push(h),a.push(u),n[e]=[u,e,"private",h]):n[e]=[a[c],e,"private",s[c]]):n[e]=[l[2],l[1]],i[e]=!0),"factory"!==l[2]&&"type"!==l[2]||!l[1].$scope||t.forEach(t=>{-1!==l[1].$scope.indexOf(t)&&(n[e]=[l[2],l[1]],i[t]=!0)});t.forEach(e=>{if(!i[e])throw new Error('No provider for "'+e+'". Cannot use provider from the parent!')}),e.unshift(n)}return new St(e,s)}const f={factory:u,type:h,value:function(e){return e}};function g(e,t){const n=e.__init__||[];return function(){n.forEach(e=>{"string"==typeof e?t.get(e):t.invoke(e)})}}function m(e){const t=e.__exports__;if(t){const n=e.__modules__,i=Object.keys(e).reduce((t,n)=>("__exports__"!==n&&"__modules__"!==n&&"__init__"!==n&&"__depends__"!==n&&(t[n]=e[n]),t),Object.create(null)),o=d((n||[]).concat(i)),s=wt(function(e){return o.get(e)});t.forEach(function(e){r[e]=[s,e,"private",o]});const a=(e.__init__||[]).slice();return a.unshift(function(){o.init()}),g(e=Object.assign({},e,{__init__:a}),o)}return Object.keys(e).forEach(function(t){if("__init__"===t||"__depends__"===t)return;const n=e[t];if("private"===n[2])return void(r[t]=n);const i=n[0],o=n[1];r[t]=[f[i],Ct(i,o),i]}),g(e,s)}function y(e,t){return-1!==e.indexOf(t)||-1!==(e=(t.__depends__||[]).reduce(y,e)).indexOf(t)?e:e.concat(t)}this.get=l,this.invoke=u,this.instantiate=h,this.createChild=d,this.init=function(e){const t=e.reduce(y,[]).map(m);let n=!1;return function(){n||(n=!0,t.forEach(e=>e()))}}(e)}function Ct(e,t){return"value"!==e&&yt(t)&&(t=wt(t.slice())),t}function Et(e,t){var n=this;t=t||1e3,e.on(["render.shape","render.connection"],t,function(e,t){var i=e.type,r=t.element,o=t.gfx,s=t.attrs;if(n.canRender(r))return"render.shape"===i?n.drawShape(o,r,s):n.drawConnection(o,r,s)}),e.on(["render.getShapePath","render.getConnectionPath"],t,function(e,t){if(n.canRender(t))return"render.getShapePath"===e.type?n.getShapePath(t):n.getConnectionPath(t)})}function Mt(e,t){return function(e,t){t.appendChild(function(e,t){if(e.ownerDocument!==t.ownerDocument)try{return t.ownerDocument.importNode(e,!0)}catch(e){}return e}(e,t))}(t,e),e}Et.prototype.canRender=function(e){},Et.prototype.drawShape=function(e,t){},Et.prototype.drawConnection=function(e,t){},Et.prototype.getShapePath=function(e){},Et.prototype.getConnectionPath=function(e){};var At={"alignment-baseline":1,"baseline-shift":1,clip:1,"clip-path":1,"clip-rule":1,color:1,"color-interpolation":1,"color-interpolation-filters":1,"color-profile":1,"color-rendering":1,cursor:1,direction:1,display:1,"dominant-baseline":1,"enable-background":1,fill:1,"fill-opacity":1,"fill-rule":1,filter:1,"flood-color":1,"flood-opacity":1,font:1,"font-family":1,"font-size":2,"font-size-adjust":1,"font-stretch":1,"font-style":1,"font-variant":1,"font-weight":1,"glyph-orientation-horizontal":1,"glyph-orientation-vertical":1,"image-rendering":1,kerning:1,"letter-spacing":1,"lighting-color":1,marker:1,"marker-end":1,"marker-mid":1,"marker-start":1,mask:1,opacity:1,overflow:1,"pointer-events":1,"shape-rendering":1,"stop-color":1,"stop-opacity":1,stroke:1,"stroke-dasharray":1,"stroke-dashoffset":1,"stroke-linecap":1,"stroke-linejoin":1,"stroke-miterlimit":1,"stroke-opacity":1,"stroke-width":2,"text-anchor":1,"text-decoration":1,"text-rendering":1,"unicode-bidi":1,visibility:1,"word-spacing":1,"writing-mode":1};function Tt(e,t,n){var i=t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),r=At[i];r?(2===r&&"number"==typeof n&&(n=String(n)+"px"),e.style[i]=n):e.setAttributeNS(null,t,n)}function Rt(e,t,n){if("string"==typeof t){if(void 0===n)return function(e,t){return At[t]?e.style[t]:e.getAttributeNS(null,t)}(e,t);Tt(e,t,n)}else!function(e,t){var n,i,r=Object.keys(t);for(n=0;i=r[n];n++)Tt(e,i,t[i])}(e,t);return e}const Ot=Object.prototype.toString;function Dt(e){return new qt(e)}function qt(e){if(!e||!e.nodeType)throw new Error("A DOM element reference is required");this.el=e,this.list=e.classList}qt.prototype.add=function(e){return this.list.add(e),this},qt.prototype.remove=function(e){return"[object RegExp]"==Ot.call(e)?this.removeMatching(e):(this.list.remove(e),this)},qt.prototype.removeMatching=function(e){const t=this.array();for(let n=0;n<t.length;n++)e.test(t[n])&&this.remove(t[n]);return this},qt.prototype.toggle=function(e,t){return void 0!==t?t!==this.list.toggle(e,t)&&this.list.toggle(e):this.list.toggle(e),this},qt.prototype.array=function(){return Array.from(this.list)},qt.prototype.has=qt.prototype.contains=function(e){return this.list.contains(e)};var Nt="http://www.w3.org/2000/svg",Bt='<svg xmlns="'+Nt+'"';function Pt(e){var t=!1;"<svg"===e.substring(0,4)?-1===e.indexOf(Nt)&&(e=Bt+e.substring(4)):(e=Bt+">"+e+"</svg>",t=!0);var n=function(e){var t;return(t=new DOMParser).async=!1,t.parseFromString(e,"text/xml")}(e);if(!t)return n;for(var i=document.createDocumentFragment(),r=n.firstChild;r.firstChild;)i.appendChild(r.firstChild);return i}function Lt(e,t){var n;return"<"===(e=e.trim()).charAt(0)?(n=Pt(e).firstChild,n=document.importNode(n,!0)):n=document.createElementNS(Nt,e),t&&Rt(n,t),n}var It=null;function jt(){return null===It&&(It=Lt("svg")),It}function Ft(e,t){var n,i,r=Object.keys(t);for(n=0;i=r[n];n++)e[i]=t[i];return e}var Vt=/([&<>]{1})/g,$t=/([&<>\n\r"]{1})/g,zt={"&":"&","<":"<",">":">",'"':"'"};function Wt(e,t){return e.replace(t,function(e,t){return zt[t]||t})}function Ht(e,t){var n,i,r,o,s;switch(e.nodeType){case 3:t.push(Wt(e.textContent,Vt));break;case 1:if(t.push("<",e.tagName),e.hasAttributes())for(n=0,i=(r=e.attributes).length;n<i;++n)o=r.item(n),t.push(" ",o.name,'="',Wt(o.value,$t),'"');if(e.hasChildNodes()){for(t.push(">"),n=0,i=(s=e.childNodes).length;n<i;++n)Ht(s.item(n),t);t.push("</",e.tagName,">")}else t.push("/>");break;case 8:t.push("\x3c!--",Wt(e.nodeValue,Vt),"--\x3e");break;case 4:t.push("<![CDATA[",e.nodeValue,"]]>");break;default:throw new Error("unable to handle node "+e.nodeType)}return t}function Ut(e,t){return function(e){for(var t=e.firstChild,n=[];t;)Ht(t,n),t=t.nextSibling;return n.join("")}(e)}function Gt(e){var t=e.parentNode;return t&&t.removeChild(e),e}function Kt(e,t){return t instanceof SVGMatrix?e.createSVGTransformFromMatrix(t):t}function Xt(e,t){var n=e.transform.baseVal;return t&&(Array.isArray(t)||(t=[t]),function(e,t){var n,i;for(e.clear(),n=0;i=t[n];n++)e.appendItem(Kt(e,i))}(n,t)),n.consolidate()}function Yt(e){return e.flat().join(",").replace(/,?([A-Za-z]),?/g,"$1")}function Jt(e){return["L",e.x,e.y]}function Qt(e,t,n){return["C",e.x,e.y,t.x,t.y,n.x,n.y]}function Zt(e,t){const n=e.length,i=[(r=e[0],["M",r.x,r.y])];var r;for(let r=1;r<n;r++){const n=e[r-1],o=e[r],s=e[r+1];if(!s||!t){i.push(Jt(o));continue}const a=Math.min(t,tn(o.x-n.x,o.y-n.y),tn(s.x-o.x,s.y-o.y));if(!a){i.push(Jt(o));continue}const l=en(o,n,a),c=en(o,n,.5*a),h=en(o,s,a),u=en(o,s,.5*a);i.push(Jt(l)),i.push(Qt(c,u,h))}return i}function en(e,t,n){const i=t.x-e.x,r=t.y-e.y,o=n/tn(i,r);return{x:e.x+i*o,y:e.y+r*o}}function tn(e,t){return Math.sqrt(Math.pow(e,2)+Math.pow(t,2))}function nn(e,t,n){a(t)&&(n=t,t=null),t||(t={});const i=Lt("path",t);return a(n)&&(i.dataset.cornerRadius=String(n)),rn(i,e)}function rn(e,t){return Rt(e,{d:Yt(Zt(t,parseInt(e.dataset.cornerRadius,10)||0))}),e}function on(e,t){var n,i,r,s;return t=!!t,o(e)||(e=[e]),d(e,function(e){var o=e;e.waypoints&&!t&&(o=on(e.waypoints,!0));var a=o.x,l=o.y,c=o.height||0,h=o.width||0;(a<n||void 0===n)&&(n=a),(l<i||void 0===i)&&(i=l),(a+h>r||void 0===r)&&(r=a+h),(l+c>s||void 0===s)&&(s=l+c)}),{x:n,y:i,height:s-i,width:r-n}}function sn(e){return!(!e||!e.isFrame)}function an(e,t){Et.call(this,e,1),this.CONNECTION_STYLE=t.style(["no-fill"],{strokeWidth:5,stroke:"fuchsia"}),this.SHAPE_STYLE=t.style({fill:"white",stroke:"fuchsia",strokeWidth:2}),this.FRAME_STYLE=t.style(["no-fill"],{stroke:"fuchsia",strokeDasharray:4,strokeWidth:2})}gt(an,Et),an.prototype.canRender=function(){return!0},an.prototype.drawShape=function(e,t,n){var i=Lt("rect");return Rt(i,{x:0,y:0,width:t.width||0,height:t.height||0}),sn(t)?Rt(i,S({},this.FRAME_STYLE,n||{})):Rt(i,S({},this.SHAPE_STYLE,n||{})),Mt(e,i),i},an.prototype.drawConnection=function(e,t,n){var i=nn(t.waypoints,S({},this.CONNECTION_STYLE,n||{}));return Mt(e,i),i},an.prototype.getShapePath=function(e){var t=e.x,n=e.y,i=e.width;return Yt([["M",t,n],["l",i,0],["l",0,e.height],["l",-i,0],["z"]])},an.prototype.getConnectionPath=function(e){var t,n,i=e.waypoints,r=[];for(t=0;n=i[t];t++)n=n.original||n,r.push([0===t?"M":"L",n.x,n.y]);return Yt(r)},an.$inject=["eventBus","styles"];var ln={__init__:["defaultRenderer"],defaultRenderer:["type",an],styles:["type",function(){var e={"no-fill":{fill:"none"},"no-border":{strokeOpacity:0},"no-events":{pointerEvents:"none"}},t=this;this.cls=function(e,t,n){return S(this.style(t,n),{class:e})},this.style=function(t,n){o(t)||n||(n=t,t=[]);var i=f(t,function(t,n){return S(t,e[n]||{})},{});return n?S(i,n):i},this.computeStyle=function(e,n,i){return o(n)||(i=n,n=[]),t.style(n||[],S({},i,e||{}))}}]};function cn(e){return{top:e.y,right:e.x+(e.width||0),bottom:e.y+(e.height||0),left:e.x}}function hn(e,t){return Math.round(e*t)/t}function un(e){return a(e)?e+"px":e}function pn(e){for(;e.parent;)e=e.parent;return e}function dn(e,t,n){const i=Lt("g");Dt(i).add(t);const r=void 0!==n?n:e.childNodes.length-1;return e.insertBefore(i,e.childNodes[r]||null),i}const fn={shape:["x","y","width","height"],connection:["waypoints"]};function gn(e,t,n,i){this._eventBus=t,this._elementRegistry=i,this._graphicsFactory=n,this._rootsIdx=0,this._layers={},this._planes=[],this._rootElement=null,this._focused=!1,this._init(e||{})}function mn(e,t){const n="matrix("+t.a+","+t.b+","+t.c+","+t.d+","+t.e+","+t.f+")";e.setAttribute("transform",n)}gn.$inject=["config.canvas","eventBus","graphicsFactory","elementRegistry"],gn.prototype._init=function(e){const t=this._eventBus,n=this._container=function(e){const t=(e=S({},{width:"100%",height:"100%"},e)).container||document.body,n=document.createElement("div");return n.setAttribute("class","djs-container djs-parent bio-theme-parent"),Ue(n,{position:"relative",overflow:"hidden",width:un(e.width),height:un(e.height)}),t.appendChild(n),n}(e),i=this._svg=Lt("svg");Rt(i,{width:"100%",height:"100%"}),Ge(i,"tabindex",0),e.autoFocus&&t.on("element.hover",()=>{this.restoreFocus()}),t.on("element.mousedown",500,e=>{this.focus()}),i.addEventListener("focusin",()=>{this._setFocused(!0)}),i.addEventListener("focusout",()=>{this._setFocused(!1)}),i.addEventListener("mouseover",()=>{this._eventBus.fire("canvas.mouseover")}),i.addEventListener("mouseout",()=>{this._eventBus.fire("canvas.mouseout")}),Mt(n,i);const r=this._viewport=dn(i,"viewport");e.deferUpdate&&(this._viewboxChanged=_(this._viewboxChanged,300)),this._restoreFocus=_(this._restoreFocus,0),t.on("diagram.init",()=>{t.fire("canvas.init",{svg:i,viewport:r})}),t.on(["shape.added","connection.added","shape.removed","connection.removed","elements.changed","root.set"],()=>{delete this._cachedViewbox}),t.on("diagram.destroy",500,this._destroy,this),t.on("diagram.clear",500,this._clear,this)},gn.prototype._destroy=function(){this._restoreFocus.cancel(),this._eventBus.fire("canvas.destroy",{svg:this._svg,viewport:this._viewport});const e=this._container.parentNode;e&&e.removeChild(this._container),delete this._svg,delete this._container,delete this._layers,delete this._planes,delete this._rootElement,delete this._viewport},gn.prototype._setFocused=function(e){e!=this._focused&&(this._focused=e,this._eventBus.fire("canvas.focus.changed",{focused:e}))},gn.prototype._clear=function(){this._elementRegistry.getAll().forEach(e=>{const t=function(e){return"waypoints"in e?"connection":"x"in e?"shape":"root"}(e);"root"===t?this.removeRootElement(e):this._removeElement(e,t)}),this._planes=[],this._rootElement=null,delete this._cachedViewbox},gn.prototype.focus=function(){this._svg.focus({preventScroll:!0}),this._setFocused(!0)},gn.prototype.restoreFocus=function(){this._restoreFocus()},gn.prototype._restoreFocus=function(){document.activeElement===document.body&&this.focus()},gn.prototype.isFocused=function(){return this._focused},gn.prototype.getDefaultLayer=function(){return this.getLayer("base",0)},gn.prototype.getLayer=function(e,t){if(!e)throw new Error("must specify a name");let n=this._layers[e];if(n||(n=this._layers[e]=this._createLayer(e,t)),void 0!==t&&n.index!==t)throw new Error("layer <"+e+"> already created at index <"+t+">");return n.group},gn.prototype._getChildIndex=function(e){return f(this._layers,function(t,n){return n.visible&&e>=n.index&&t++,t},0)},gn.prototype._createLayer=function(e,t){void 0===t&&(t=1);const n=this._getChildIndex(t);return{group:dn(this._viewport,"layer-"+e,n),index:t,visible:!0}},gn.prototype.showLayer=function(e){if(!e)throw new Error("must specify a name");const t=this._layers[e];if(!t)throw new Error("layer <"+e+"> does not exist");const n=this._viewport,i=t.group,r=t.index;if(t.visible)return i;const o=this._getChildIndex(r);return n.insertBefore(i,n.childNodes[o]||null),t.visible=!0,i},gn.prototype.hideLayer=function(e){if(!e)throw new Error("must specify a name");const t=this._layers[e];if(!t)throw new Error("layer <"+e+"> does not exist");const n=t.group;return t.visible?(Gt(n),t.visible=!1,n):n},gn.prototype._removeLayer=function(e){const t=this._layers[e];t&&(delete this._layers[e],Gt(t.group))},gn.prototype.getActiveLayer=function(){const e=this._findPlaneForRoot(this.getRootElement());return e?e.layer:null},gn.prototype.findRoot=function(e){const t=this._resolveElements(e);let n;for(const e of t){const t=this._findPlaneForRoot(pn(e));if(!t)return;if(n&&t.rootElement!==n)return;n=t.rootElement}return n},gn.prototype.getRootElements=function(){return this._planes.map(function(e){return e.rootElement})},gn.prototype._findPlaneForRoot=function(e){return u(this._planes,function(t){return t.rootElement===e})},gn.prototype._resolveElement=function(e){return"string"==typeof e?this._elementRegistry.get(e):e},gn.prototype._resolveElements=function(e){return o(e)||(e=[e]),e.map(e=>this._resolveElement(e)).filter(Boolean)},gn.prototype.getContainer=function(){return this._container},gn.prototype._updateMarker=function(e,t,n){let i;(e=this._resolveElement(e)).markers=e.markers||new Set,i=this._elementRegistry._elements[e.id],i&&(d([i.gfx,i.secondaryGfx],function(i){i&&(n?(e.markers.add(t),Dt(i).add(t)):(e.markers.delete(t),Dt(i).remove(t)))}),this._eventBus.fire("element.marker.update",{element:e,gfx:i.gfx,marker:t,add:!!n}))},gn.prototype.addMarker=function(e,t){this._updateMarker(e,t,!0)},gn.prototype.removeMarker=function(e,t){this._updateMarker(e,t,!1)},gn.prototype.hasMarker=function(e,t){return!!(e=this._resolveElement(e)).markers&&e.markers.has(t)},gn.prototype.toggleMarker=function(e,t){this.hasMarker(e,t)?this.removeMarker(e,t):this.addMarker(e,t)},gn.prototype.getRootElement=function(){const e=this._rootElement;return e||this._planes.length?e:this.setRootElement(this.addRootElement(null))},gn.prototype.addRootElement=function(e){const t=this._rootsIdx++;e||(e={id:"__implicitroot_"+t,children:[],isImplicit:!0});const n=e.layer="root-"+t;this._ensureValid("root",e);const i=this.getLayer(n,0);return this.hideLayer(n),this._addRoot(e,i),this._planes.push({rootElement:e,layer:i}),e},gn.prototype.removeRootElement=function(e){e=this._resolveElement(e);if(this._findPlaneForRoot(e))return this._removeRoot(e),this._removeLayer(e.layer),this._planes=this._planes.filter(function(t){return t.rootElement!==e}),this._rootElement===e&&(this._rootElement=null),e},gn.prototype.setRootElement=function(e){if(e===this._rootElement)return e;let t;if(!e)throw new Error("rootElement required");return t=this._findPlaneForRoot(e),t||(e=this.addRootElement(e)),this._setRoot(e),e},gn.prototype._removeRoot=function(e){const t=this._elementRegistry,n=this._eventBus;n.fire("root.remove",{element:e}),n.fire("root.removed",{element:e}),t.remove(e)},gn.prototype._addRoot=function(e,t){const n=this._elementRegistry,i=this._eventBus;i.fire("root.add",{element:e}),n.add(e,t),i.fire("root.added",{element:e,gfx:t})},gn.prototype._setRoot=function(e,t){const n=this._rootElement;n&&(this._elementRegistry.updateGraphics(n,null,!0),this.hideLayer(n.layer)),e&&(t||(t=this._findPlaneForRoot(e).layer),this._elementRegistry.updateGraphics(e,this._svg,!0),this.showLayer(e.layer)),this._rootElement=e,this._eventBus.fire("root.set",{element:e})},gn.prototype._ensureValid=function(e,t){if(!t.id)throw new Error("element must have an id");if(this._elementRegistry.get(t.id))throw new Error("element <"+t.id+"> already exists");const n=fn[e],i=g(n,function(e){return void 0!==t[e]});if(!i)throw new Error("must supply { "+n.join(", ")+" } with "+e)},gn.prototype._setParent=function(e,t,n){!function(e,t,n){if(e&&t){"number"!=typeof n&&(n=-1);var i=e.indexOf(t);if(-1!==i){if(i===n)return;if(-1===n)return;e.splice(i,1)}-1!==n?e.splice(n,0,t):e.push(t)}}(t.children,e,n),e.parent=t},gn.prototype._addElement=function(e,t,n,i){n=n||this.getRootElement();const r=this._eventBus,o=this._graphicsFactory;this._ensureValid(e,t),r.fire(e+".add",{element:t,parent:n}),this._setParent(t,n,i);const s=o.create(e,t,i);return this._elementRegistry.add(t,s),o.update(e,t,s),r.fire(e+".added",{element:t,gfx:s}),t},gn.prototype.addShape=function(e,t,n){return this._addElement("shape",e,t,n)},gn.prototype.addConnection=function(e,t,n){return this._addElement("connection",e,t,n)},gn.prototype._removeElement=function(e,t){const n=this._elementRegistry,i=this._graphicsFactory,r=this._eventBus;if(e=n.get(e.id||e))return r.fire(t+".remove",{element:e}),i.remove(e),function(e,t){if(!e||!t)return-1;var n=e.indexOf(t);-1!==n&&e.splice(n,1)}(e.parent&&e.parent.children,e),e.parent=null,r.fire(t+".removed",{element:e}),n.remove(e),e},gn.prototype.removeShape=function(e){return this._removeElement(e,"shape")},gn.prototype.removeConnection=function(e){return this._removeElement(e,"connection")},gn.prototype.getGraphics=function(e,t){return this._elementRegistry.getGraphics(e,t)},gn.prototype._changeViewbox=function(e){this._eventBus.fire("canvas.viewbox.changing"),e.apply(this),this._cachedViewbox=null,this._viewboxChanged()},gn.prototype._viewboxChanged=function(){this._eventBus.fire("canvas.viewbox.changed",{viewbox:this.viewbox()})},gn.prototype.viewbox=function(e){if(void 0===e&&this._cachedViewbox)return structuredClone(this._cachedViewbox);const t=this._viewport,n=this.getSize();let i,r,o,s,a,l,c;return e?(this._changeViewbox(function(){a=Math.min(n.width/e.width,n.height/e.height);const i=this._svg.createSVGMatrix().scale(a).translate(-e.x,-e.y);Xt(t,i)}),e):(o=this._rootElement?this.getActiveLayer():null,i=o&&o.getBBox()||{},s=Xt(t),r=s?s.matrix:function(e,t,n,i,r,o){var s=jt().createSVGMatrix();switch(arguments.length){case 0:return s;case 1:return Ft(s,e);case 6:return Ft(s,{a:e,b:t,c:n,d:i,e:r,f:o})}}(),a=hn(r.a,1e3),l=hn(-r.e||0,1e3),c=hn(-r.f||0,1e3),e=this._cachedViewbox={x:l?l/a:0,y:c?c/a:0,width:n.width/a,height:n.height/a,scale:a,inner:{width:i.width||0,height:i.height||0,x:i.x||0,y:i.y||0},outer:n})},gn.prototype.scroll=function(e){const t=this._viewport;let n=t.getCTM();return e&&this._changeViewbox(function(){e=S({dx:0,dy:0},e||{}),n=this._svg.createSVGMatrix().translate(e.dx,e.dy).multiply(n),mn(t,n)}),{x:n.e,y:n.f}},gn.prototype.scrollToElement=function(e,t){let n=100;const i=this._resolveElements(e);if(!i.length)return;const r=this.findRoot(i);if(!r)return;r!==this.getRootElement()&&this.setRootElement(r);const o=i.filter(e=>e!=r);if(!o.length)return;t||(t={}),"number"==typeof t&&(n=t),t={top:t.top||n,right:t.right||n,bottom:t.bottom||n,left:t.left||n};const s=on(o),a=cn(s),l=this.viewbox(),c=this.zoom();let h,u;l.y+=t.top/c,l.x+=t.left/c,l.width-=(t.right+t.left)/c,l.height-=(t.bottom+t.top)/c;const p=cn(l);if(s.width<l.width&&s.height<l.height){const e=Math.max(0,a.right-p.right),t=Math.min(0,a.left-p.left),n=Math.max(0,a.bottom-p.bottom),i=Math.min(0,a.top-p.top);h=e||t,u=n||i}else h=s.x-l.x,u=s.y-l.y;this.scroll({dx:-h*c,dy:-u*c})},gn.prototype.zoom=function(e,t){if(!e)return this.viewbox(e).scale;if("fit-viewport"===e)return this._fitViewport(t);let n,i;return this._changeViewbox(function(){"object"!=typeof t&&(n=this.viewbox().outer,t={x:n.width/2,y:n.height/2}),i=this._setZoom(e,t)}),hn(i.a,1e3)},gn.prototype._fitViewport=function(e){const t=this.viewbox(),n=t.outer,i=t.inner;let r,o;return i.x>=0&&i.y>=0&&i.x+i.width<=n.width&&i.y+i.height<=n.height&&!e?o={x:0,y:0,width:Math.max(i.width+i.x,n.width),height:Math.max(i.height+i.y,n.height)}:(r=Math.min(1,n.width/i.width,n.height/i.height),o={x:i.x+(e?i.width/2-n.width/r/2:0),y:i.y+(e?i.height/2-n.height/r/2:0),width:n.width/r,height:n.height/r}),this.viewbox(o),this.viewbox(!1).scale},gn.prototype._setZoom=function(e,t){const n=this._svg,i=this._viewport,r=n.createSVGMatrix(),o=n.createSVGPoint();let s,a,l,c,h;l=i.getCTM();const u=l.a;return t?(s=S(o,t),a=s.matrixTransform(l.inverse()),c=r.translate(a.x,a.y).scale(1/u*e).translate(-a.x,-a.y),h=l.multiply(c)):h=r.scale(e),mn(this._viewport,h),h},gn.prototype.getSize=function(){return{width:this._container.clientWidth,height:this._container.clientHeight}},gn.prototype.getAbsoluteBBox=function(e){const t=this.viewbox();let n;if(e.waypoints){n=this.getGraphics(e).getBBox()}else n=e;return{x:n.x*t.scale-t.x*t.scale,y:n.y*t.scale-t.y*t.scale,width:n.width*t.scale,height:n.height*t.scale}},gn.prototype.resized=function(){delete this._cachedViewbox,this._eventBus.fire("canvas.resized")};var yn="data-element-id";function vn(e){this._elements={},this._eventBus=e}function wn(e,t,n){var i=function(e,t,n,i){var r=n.inverse;return Object.defineProperty(e,"remove",{value:function(e){var n=this.indexOf(e);return-1!==n&&(this.splice(n,1),t.unset(e,r,i)),e}}),Object.defineProperty(e,"contains",{value:function(e){return-1!==this.indexOf(e)}}),Object.defineProperty(e,"add",{value:function(e,n){var o=this.indexOf(e);if(void 0===n){if(-1!==o)return;n=this.length}-1!==o&&this.splice(o,1),this.splice(n,0,e),-1===o&&t.set(e,r,i)}}),Object.defineProperty(e,"__refs_collection",{value:!0}),e}(n[t.name]||[],e,t,n);Object.defineProperty(n,t.name,{enumerable:t.enumerable,value:i}),i.length&&i.forEach(function(i){e.set(i,t.inverse,n)})}function bn(e,t){if(!(this instanceof bn))return new bn(e,t);e.inverse=t,t.inverse=e,this.props={},this.props[e.name]=e,this.props[t.name]=t}vn.$inject=["eventBus"],vn.prototype.add=function(e,t,n){var i=e.id;this._validateId(i),Rt(t,yn,i),n&&Rt(n,yn,i),this._elements[i]={element:e,gfx:t,secondaryGfx:n}},vn.prototype.remove=function(e){var t=this._elements,n=e.id||e,i=n&&t[n];i&&(Rt(i.gfx,yn,""),i.secondaryGfx&&Rt(i.secondaryGfx,yn,""),delete t[n])},vn.prototype.updateId=function(e,t){this._validateId(t),"string"==typeof e&&(e=this.get(e)),this._eventBus.fire("element.updateId",{element:e,newId:t});var n=this.getGraphics(e),i=this.getGraphics(e,!0);this.remove(e),e.id=t,this.add(e,n,i)},vn.prototype.updateGraphics=function(e,t,n){var i=e.id||e,r=this._elements[i];return n?r.secondaryGfx=t:r.gfx=t,t&&Rt(t,yn,i),t},vn.prototype.get=function(e){var t;t="string"==typeof e?e:e&&Rt(e,yn);var n=this._elements[t];return n&&n.element},vn.prototype.filter=function(e){var t=[];return this.forEach(function(n,i){e(n,i)&&t.push(n)}),t},vn.prototype.find=function(e){for(var t=this._elements,n=Object.keys(t),i=0;i<n.length;i++){var r=t[n[i]],o=r.element;if(e(o,r.gfx))return o}},vn.prototype.getAll=function(){return this.filter(function(e){return e})},vn.prototype.forEach=function(e){var t=this._elements;Object.keys(t).forEach(function(n){var i=t[n],r=i.element,o=i.gfx;return e(r,o)})},vn.prototype.getGraphics=function(e,t){var n=e.id||e,i=this._elements[n];return i&&(t?i.secondaryGfx:i.gfx)},vn.prototype._validateId=function(e){if(!e)throw new Error("element must have an id");if(this._elements[e])throw new Error("element with id "+e+" already added")},bn.prototype.bind=function(e,t){if("string"==typeof t){if(!this.props[t])throw new Error("no property <"+t+"> in ref");t=this.props[t]}t.collection?wn(this,t,e):function(e,t,n){var i=t.inverse,r=n[t.name];Object.defineProperty(n,t.name,{configurable:t.configurable,enumerable:t.enumerable,get:function(){return r},set:function(t){if(t!==r){var o=r;r=null,o&&e.unset(o,i,n),r=t,e.set(r,i,n)}}})}(this,t,e)},bn.prototype.ensureRefsCollection=function(e,t){var n=e[t.name];return function(e){return!0===e.__refs_collection}(n)||wn(this,t,e),n},bn.prototype.ensureBound=function(e,t){(function(e,t){return Object.prototype.hasOwnProperty.call(e,t.name||t)})(e,t)||this.bind(e,t)},bn.prototype.unset=function(e,t,n){e&&(this.ensureBound(e,t),t.collection?this.ensureRefsCollection(e,t).remove(n):e[t.name]=void 0)},bn.prototype.set=function(e,t,n){e&&(this.ensureBound(e,t),t.collection?this.ensureRefsCollection(e,t).add(n):e[t.name]=n)};var xn=new bn({name:"children",enumerable:!0,collection:!0},{name:"parent"}),_n=new bn({name:"labels",enumerable:!0,collection:!0},{name:"labelTarget"}),kn=new bn({name:"attachers",collection:!0},{name:"host"}),Sn=new bn({name:"outgoing",collection:!0},{name:"source"}),Cn=new bn({name:"incoming",collection:!0},{name:"target"});function En(){Object.defineProperty(this,"businessObject",{writable:!0}),Object.defineProperty(this,"label",{get:function(){return this.labels[0]},set:function(e){var t=this.label,n=this.labels;!e&&t?n.remove(t):n.add(e,0)}}),xn.bind(this,"parent"),_n.bind(this,"labels"),Sn.bind(this,"outgoing"),Cn.bind(this,"incoming")}function Mn(){En.call(this),xn.bind(this,"children"),kn.bind(this,"host"),kn.bind(this,"attachers")}function An(){En.call(this),xn.bind(this,"children")}function Tn(){Mn.call(this),_n.bind(this,"labelTarget")}function Rn(){En.call(this),Sn.bind(this,"source"),Cn.bind(this,"target")}gt(Mn,En),gt(An,Mn),gt(Tn,Mn),gt(Rn,En);var On={connection:Rn,shape:Mn,label:Tn,root:An};function Dn(){this._uid=12}function qn(e,t,n){var i=jt().createSVGTransform();i.setTranslate(t,n),Xt(e,i)}function Nn(e,t){this._eventBus=e,this._elementRegistry=t}Dn.prototype.createRoot=function(e){return this.create("root",e)},Dn.prototype.createLabel=function(e){return this.create("label",e)},Dn.prototype.createShape=function(e){return this.create("shape",e)},Dn.prototype.createConnection=function(e){return this.create("connection",e)},Dn.prototype.create=function(e,t){return(t=S({},t||{})).id||(t.id=e+"_"+this._uid++),function(e,t){var n=On[e];if(!n)throw new Error("unknown type: <"+e+">");return S(new n,t)}(e,t)},Nn.$inject=["eventBus","elementRegistry"],Nn.prototype._getChildrenContainer=function(e){var t,n=this._elementRegistry.getGraphics(e);return e.parent?(t=function(e){return e.parentNode.childNodes[1]}(n),t||(Dt(t=Lt("g")).add("djs-children"),Mt(n.parentNode,t))):t=n,t},Nn.prototype._clear=function(e){var t=function(e){return e.childNodes[0]}(e);return Je(t),t},Nn.prototype._createContainer=function(e,t,n,i){var r=Lt("g");Dt(r).add("djs-group"),void 0!==n?function(e,t,n){var i=n||t.firstChild;if(e===i)return;t.insertBefore(e,i)}(r,t,t.childNodes[n]):Mt(t,r);var o=Lt("g");Dt(o).add("djs-element"),Dt(o).add("djs-"+e),i&&Dt(o).add("djs-frame"),Mt(r,o);var s=Lt("g");return Dt(s).add("djs-visual"),Mt(o,s),o},Nn.prototype.create=function(e,t,n){var i=this._getChildrenContainer(t.parent);return this._createContainer(e,i,n,sn(t))},Nn.prototype.updateContainments=function(e){var t,n=this,i=this._elementRegistry;t=f(e,function(e,t){return t.parent&&(e[t.parent.id]=t.parent),e},{}),d(t,function(e){var t=e.children;if(t){var r=n._getChildrenContainer(e),o=r.firstChild;d(t,function(e){var t=i.getGraphics(e).parentNode;t===o?o=o.nextSibling:r.insertBefore(t,o)})}})},Nn.prototype.drawShape=function(e,t,n={}){return this._eventBus.fire("render.shape",{gfx:e,element:t,attrs:n})},Nn.prototype.getShapePath=function(e){return this._eventBus.fire("render.getShapePath",e)},Nn.prototype.drawConnection=function(e,t,n={}){return this._eventBus.fire("render.connection",{gfx:e,element:t,attrs:n})},Nn.prototype.getConnectionPath=function(e){return this._eventBus.fire("render.getConnectionPath",e)},Nn.prototype.update=function(e,t,n){if(t.parent){var i=this._clear(n);if("shape"===e)this.drawShape(i,t),qn(n,t.x,t.y);else{if("connection"!==e)throw new Error("unknown type: "+e);this.drawConnection(i,t)}t.hidden?Rt(n,"display","none"):Rt(n,"display","block")}},Nn.prototype.remove=function(e){Gt(this._elementRegistry.getGraphics(e).parentNode)};var Bn={__depends__:[ln],__init__:["canvas"],canvas:["type",gn],elementRegistry:["type",vn],elementFactory:["type",Dn],eventBus:["type",M],graphicsFactory:["type",Nn]};function Pn(e){return function(e){var t=new St(e);return t.init(),t}([{config:["value",e=e||{}]},Bn].concat(e.modules||[]))}function Ln(e,t){this._injector=t||Pn(e),this.get("eventBus").fire("diagram.init")}function In(e,t){var n=jn(e);return n&&"function"==typeof n.$instanceOf&&n.$instanceOf(t)}function jn(e){return e&&e.businessObject||e}function Fn(e){let t=jn(e);for(;t&&!In(t,"dmn:Definitions");)t=t.$parent;return t}function Vn(e){var t=jn(e);if(In(t,"dmn:Decision"))return t.get("decisionLogic");if(In(t,"dmn:BusinessKnowledgeModel")){var n=t.get("encapsulatedLogic");return n&&n.get("body")}}function $n(e){return e.split("#").pop()}Ln.prototype.get=function(e,t){return this._injector.get(e,t)},Ln.prototype.invoke=function(e,t,n){return this._injector.invoke(e,t,n)},Ln.prototype.destroy=function(){this.get("eventBus").fire("diagram.destroy")},Ln.prototype.clear=function(){this.get("eventBus").fire("diagram.clear")};var zn=new bn({name:"dmnElementRef",enumerable:!0},{name:"di",configurable:!0});function Wn(e,t){var n=[],i=new Map;function r(e,t){i.set($n(e.href),t)}function o(t,n){try{var i=t.di&&function(t,n){if(t.gfx)throw new Error("already rendered "+t.id);return e.element(t,n)}(t,n);return i}catch(e){l(e.message,{element:t,error:e})}}function s(e){var t,n;(n=(t=e).dmnElementRef)?n.di?l("multiple DI elements defined for element",{element:n}):(zn.bind(n,"di"),n.di=t):l("no DMN element referenced in element",{element:t})}function a(e){n.push(e)}function l(t,n){e.error(t,n)}return{handleDefinitions:function(t,l){var c=t.dmnDI;if(!c)throw new Error("no dmndi:DMNDI");var h,u,p=c.diagrams||[];if(l&&-1===p.indexOf(l))throw new Error("diagram not part of dmndi:DMNDI");if(!l&&p&&p.length&&(l=p[0]),!l)throw new Error("no diagram to display");t.di=l,function(e){d(e.diagramElements,s)}(l),h=t,e.root(h),d(u=t.get("drgElement"),function(e){In(e,"dmn:DecisionService")?function(e){o(e),d(e.get("encapsulatedDecision"),function(t){r(t,e)}),d(e.get("outputDecision"),function(t){r(t,e)})}(e):In(e,"dmn:Decision")?function(e){a(function(){var t=i.get(e.id);o(e,t)})}(e):o(e)}),d(u,function(e){!function(e){d(["informationRequirement","knowledgeRequirement","authorityRequirement"],function(t){d(e[t],function(e){a(function(){o(e)})})})}(e)}),function(e){d(e,function(e){In(e,"dmn:Association")?function(e){a(function(){o(e)})}(e):o(e)})}(t.get("artifact")),d(n,function(e){e()})}}}var Hn="$NO_OP",Un=Array.isArray;function Gn(e){var t=typeof e;return"string"===t||"number"===t}function Kn(e){return ei(e)||Zn(e)}function Xn(e){return Zn(e)||!1===e||function(e){return!0===e}(e)||ei(e)}function Yn(e){return"function"==typeof e}function Jn(e){return"string"==typeof e}function Qn(e){return"number"==typeof e}function Zn(e){return null===e}function ei(e){return void 0===e}function ti(e,t){var n={};if(e)for(var i in e)n[i]=e[i];if(t)for(var r in t)n[r]=t[r];return n}var ni="$";function ii(e,t,n,i,r,o,s,a){return{childFlags:e,children:t,className:n,dom:null,flags:i,key:void 0===r?null:r,parentVNode:null,props:void 0===o?null:o,ref:void 0===s?null:s,type:a}}function ri(e,t,n,i,r,o,s,a){var l=void 0===r?1:r,c=ii(l,i,n,e,s,o,a,t);return 0===l&&ui(c,c.children),c}function oi(e,t,n,i,r){(2&e)>0&&(e=t.prototype&&Yn(t.prototype.render)?4:8);var o=t.defaultProps;if(!Kn(o))for(var s in n||(n={}),o)ei(n[s])&&(n[s]=o[s]);if((8&e)>0){var a=t.defaultHooks;if(!Kn(a))if(r)for(var l in a)ei(r[l])&&(r[l]=a[l]);else r=a}var c=ii(1,null,null,e,i,n,r,t),h=pi.createVNode;return Yn(h)&&h(c),c}function si(e,t){return ii(1,Kn(e)?"":e,null,16,t,null,null,null)}function ai(e){var t=e.props;if(t){var n=e.flags;481&n&&(void 0!==t.children&&Kn(e.children)&&ui(e,t.children),void 0!==t.className&&(e.className=t.className||null,t.className=void 0)),void 0!==t.key&&(e.key=t.key,t.key=void 0),void 0!==t.ref&&(e.ref=8&n?ti(e.ref,t.ref):t.ref,t.ref=void 0)}return e}function li(e){var t,n=e.flags;if(14&n){var i,r=e.props;if(!Zn(r))for(var o in i={},r)i[o]=r[o];t=oi(n,e.type,i,e.key,e.ref)}else 481&n?t=ri(n,e.type,e.className,e.children,e.childFlags,e.props,e.key,e.ref):16&n?t=si(e.children,e.key):1024&n&&(t=e);return t}function ci(){return si("",null)}function hi(e,t,n,i){for(var r=e.length;n<r;n++){var o=e[n];if(!Xn(o)){var s=i+ni+n;if(Un(o))hi(o,t,0,s);else{if(Gn(o))o=si(o,s);else{var a=o.key,l=Jn(a)&&a[0]===ni;Zn(o.dom)&&!l||(o=li(o)),Zn(a)||l?o.key=s:o.key=i+a}t.push(o)}}}}function ui(e,t){var n,i=1;if(Xn(t))n=t;else if(Jn(t))i=2,n=si(t);else if(Qn(t))i=2,n=si(t+"");else if(Un(t)){var r=t.length;if(0===r)n=null,i=1;else{(Object.isFrozen(t)||!0===t.$)&&(t=t.slice()),i=8;for(var o=0;o<r;o++){var s=t[o];if(Xn(s)||Un(s)){n=n||t.slice(0,o),hi(t,n,o,"");break}if(Gn(s))(n=n||t.slice(0,o)).push(si(s,ni+o));else{var a=s.key,l=Zn(s.dom),c=Zn(a),h=!c&&Jn(a)&&a[0]===ni;!l||c||h?(n=n||t.slice(0,o),l&&!h||(s=li(s)),(c||h)&&(s.key=ni+o),n.push(s)):n&&n.push(s)}}(n=n||t).$=!0}}else n=t,Zn(t.dom)||(n=li(t)),i=2;return e.children=n,e.childFlags=i,e}var pi={afterRender:null,beforeRender:null,createVNode:null,renderComplete:null},di="http://www.w3.org/1999/xlink",fi="http://www.w3.org/XML/1998/namespace",gi={"xlink:actuate":di,"xlink:arcrole":di,"xlink:href":di,"xlink:role":di,"xlink:show":di,"xlink:title":di,"xlink:type":di,"xml:base":fi,"xml:lang":fi,"xml:space":fi},mi={},yi=[];function vi(e,t){e.appendChild(t)}function wi(e,t,n){Kn(n)?vi(e,t):e.insertBefore(t,n)}function bi(e,t,n){e.replaceChild(t,n)}function xi(e){for(var t;void 0!==(t=e.shift());)t()}var _i={},ki={};function Si(e,t,n){var i=_i[e],r=n.$EV;t?(i||(ki[e]=function(e){var t=function(t){var n=t.type,i="click"===n||"dblclick"===n;if(i&&0!==t.button)return t.stopPropagation(),!1;t.stopPropagation=Ei;var r={dom:document};Object.defineProperty(t,"currentTarget",{configurable:!0,get:function(){return r.dom}}),function(e,t,n,i){var r=function(e){return Yn(e.composedPath)?e.composedPath()[0]:e.target}(e);for(;!Zn(r);){if(t&&r.disabled)return;var o=r.$EV;if(o){var s=o[n];if(s&&(i.dom=r,s.event?s.event(s.data,e):s(e),e.cancelBubble))return}r=r.parentNode}}(t,i,e,r)};return document.addEventListener(Ci(e),t),t}(e),_i[e]=0),r||(r=n.$EV={}),r[e]||_i[e]++,r[e]=t):r&&r[e]&&(_i[e]--,1===i&&(document.removeEventListener(Ci(e),ki[e]),ki[e]=null),r[e]=t)}function Ci(e){return e.substr(2).toLowerCase()}function Ei(){this.cancelBubble=!0,this.immediatePropagationStopped||this.stopImmediatePropagation()}function Mi(e,t){var n=document.createElement("i");return n.innerHTML=t,n.innerHTML===e.innerHTML}function Ai(e,t,n){if(e[t]){var i=e[t];i.event?i.event(i.data,n):i(n)}else{var r=t.toLowerCase();e[r]&&e[r](n)}}function Ti(e,t){var n=function(n){n.stopPropagation();var i=this.$V;if(i){var r=i.props||mi,o=i.dom;if(Jn(e))Ai(r,e,n);else for(var s=0;s<e.length;s++)Ai(r,e[s],n);if(Yn(t)){var a=this.$V,l=a.props||mi;t(l,o,!1,a)}}};return Object.defineProperty(n,"wrapped",{configurable:!1,enumerable:!1,value:!0,writable:!1}),n}function Ri(e){return"checkbox"===e||"radio"===e}var Oi=Ti("onInput",Ni),Di=Ti(["onClick","onChange"],Ni);function qi(e){e.stopPropagation()}function Ni(e,t){var n=e.type,i=e.value,r=e.checked,o=e.multiple,s=e.defaultValue,a=!Kn(i);n&&n!==t.type&&t.setAttribute("type",n),Kn(o)||o===t.multiple||(t.multiple=o),Kn(s)||a||(t.defaultValue=s+""),Ri(n)?(a&&(t.value=i),Kn(r)||(t.checked=r)):a&&t.value!==i?(t.defaultValue=i,t.value=i):Kn(r)||(t.checked=r)}function Bi(e,t){if("optgroup"===e.type){var n=e.children,i=e.childFlags;if(12&i)for(var r=0,o=n.length;r<o;r++)Pi(n[r],t);else 2===i&&Pi(n,t)}else Pi(e,t)}function Pi(e,t){var n=e.props||mi,i=e.dom;i.value=n.value,Un(t)&&-1!==t.indexOf(n.value)||n.value===t?i.selected=!0:Kn(t)&&Kn(n.selected)||(i.selected=n.selected||!1)}qi.wrapped=!0;var Li=Ti("onChange",Ii);function Ii(e,t,n,i){var r=Boolean(e.multiple);Kn(e.multiple)||r===t.multiple||(t.multiple=r);var o=i.childFlags;if(!(1&o)){var s=i.children,a=e.value;if(n&&Kn(a)&&(a=e.defaultValue),12&o)for(var l=0,c=s.length;l<c;l++)Bi(s[l],a);else 2===o&&Bi(s,a)}}var ji=Ti("onInput",Vi),Fi=Ti("onChange");function Vi(e,t,n){var i=e.value,r=t.value;if(Kn(i)){if(n){var o=e.defaultValue;Kn(o)||o===r||(t.defaultValue=o,t.value=o)}}else r!==i&&(t.defaultValue=i,t.value=i)}function $i(e,t,n,i,r,o){64&e?Ni(i,n):256&e?Ii(i,n,r,t):128&e&&Vi(i,n,r),o&&(n.$V=t)}function zi(e,t,n){64&e?function(e,t){Ri(t.type)?(e.onchange=Di,e.onclick=qi):e.oninput=Oi}(t,n):256&e?function(e){e.onchange=Li}(t):128&e&&function(e,t){e.oninput=ji,t.onChange&&(e.onchange=Fi)}(t,n)}function Wi(e){return e.type&&Ri(e.type)?!Kn(e.checked):!Kn(e.value)}function Hi(e,t){Ui(e),t&&e.dom&&(!function(e,t){e.removeChild(t)}(t,e.dom),e.dom=null)}function Ui(e){var t=e.flags;if(481&t){var n=e.ref,i=e.props;Yn(n)&&n(null);var r=e.children,o=e.childFlags;if(12&o?Gi(r):2===o&&Ui(r),!Zn(i))for(var s in i)switch(s){case"onClick":case"onDblClick":case"onFocusIn":case"onFocusOut":case"onKeyDown":case"onKeyPress":case"onKeyUp":case"onMouseDown":case"onMouseMove":case"onMouseUp":case"onSubmit":case"onTouchEnd":case"onTouchMove":case"onTouchStart":Si(s,null,e.dom)}}else{var a=e.children;if(a)if(14&t){var l=e.ref;4&t?(Yn(a.componentWillUnmount)&&a.componentWillUnmount(),Yn(l)&&l(null),a.$UN=!0,a.$LI&&Ui(a.$LI)):(!Kn(l)&&Yn(l.onComponentWillUnmount)&&l.onComponentWillUnmount(e.dom,e.props||mi),Ui(a))}else 1024&t&&Hi(a,e.type)}}function Gi(e){for(var t=0,n=e.length;t<n;t++)Ui(e[t])}function Ki(e,t){Gi(t),e.textContent=""}function Xi(e,t){switch(e){case"animationIterationCount":case"borderImageOutset":case"borderImageSlice":case"borderImageWidth":case"boxFlex":case"boxFlexGroup":case"boxOrdinalGroup":case"columnCount":case"fillOpacity":case"flex":case"flexGrow":case"flexNegative":case"flexOrder":case"flexPositive":case"flexShrink":case"floodOpacity":case"fontWeight":case"gridColumn":case"gridRow":case"lineClamp":case"lineHeight":case"opacity":case"order":case"orphans":case"stopOpacity":case"strokeDasharray":case"strokeDashoffset":case"strokeMiterlimit":case"strokeOpacity":case"strokeWidth":case"tabSize":case"widows":case"zIndex":case"zoom":return t;default:return t+"px"}}function Yi(e,t,n,i,r,o,s){switch(e){case"onClick":case"onDblClick":case"onFocusIn":case"onFocusOut":case"onKeyDown":case"onKeyPress":case"onKeyUp":case"onMouseDown":case"onMouseMove":case"onMouseUp":case"onSubmit":case"onTouchEnd":case"onTouchMove":case"onTouchStart":Si(e,n,i);break;case"children":case"childrenType":case"className":case"defaultValue":case"key":case"multiple":case"ref":break;case"autoFocus":i.autofocus=!!n;break;case"allowfullscreen":case"autoplay":case"capture":case"checked":case"controls":case"default":case"disabled":case"hidden":case"indeterminate":case"loop":case"muted":case"novalidate":case"open":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"selected":i[e]=!!n;break;case"defaultChecked":case"value":case"volume":if(o&&"value"===e)return;var a=Kn(n)?"":n;i[e]!==a&&(i[e]=a);break;case"dangerouslySetInnerHTML":var l=t&&t.__html||"",c=n&&n.__html||"";l!==c&&(Kn(c)||Mi(i,c)||(Zn(s)||(12&s.childFlags?Gi(s.children):2===s.childFlags&&Ui(s.children),s.children=null,s.childFlags=1),i.innerHTML=c));break;default:"o"===e[0]&&"n"===e[1]?function(e,t,n){var i=e.toLowerCase();if(Yn(t)||Kn(t)){var r=n[i];r&&r.wrapped||(n[i]=t)}else{var o=t.event;o&&Yn(o)&&(n[i]=function(e,t){return function(n){e(t.data,n)}}(o,t))}}(e,n,i):Kn(n)?i.removeAttribute(e):"style"===e?function(e,t,n){var i,r,o=n.style;if(Jn(t))o.cssText=t;else if(Kn(e)||Jn(e))for(i in t)r=t[i],o[i]=Qn(r)?Xi(i,r):r;else{for(i in t)(r=t[i])!==e[i]&&(o[i]=Qn(r)?Xi(i,r):r);for(i in e)Kn(t[i])&&(o[i]="")}}(t,n,i):r&&gi[e]?i.setAttributeNS(gi[e],e,n):i.setAttribute(e,n)}}function Ji(e,t,n,i,r){var o=!1,s=(448&t)>0;for(var a in s&&(o=Wi(n))&&zi(t,i,n),n)Yi(a,null,n[a],i,r,o,null);s&&$i(t,e,i,n,!0,o)}function Qi(e,t,n,i){var r=new t(n,i);if(e.children=r,r.$V=e,r.$BS=!1,r.context=i,r.props===mi&&(r.props=n),r.$UN=!1,Yn(r.componentWillMount)){if(r.$BR=!0,r.componentWillMount(),r.$PSS){var o=r.state,s=r.$PS;if(Zn(o))r.state=s;else for(var a in s)o[a]=s[a];r.$PSS=!1,r.$PS=null}r.$BR=!1}Yn(pi.beforeRender)&&pi.beforeRender(r);var l,c=Zi(r.render(n,r.state,i),e);return Yn(r.getChildContext)&&(l=r.getChildContext()),Kn(l)?r.$CX=i:r.$CX=ti(i,l),Yn(pi.afterRender)&&pi.afterRender(r),r.$LI=c,r}function Zi(e,t){return Xn(e)?e=ci():Gn(e)?e=si(e,null):(e.dom&&(e=li(e)),14&e.flags&&(e.parentVNode=t)),e}function er(e,t,n,i){var r=e.flags;return 481&r?nr(e,t,n,i):14&r?function(e,t,n,i,r){var o,s=e.type,a=e.props||mi,l=e.ref;if(r){var c=Qi(e,s,a,n);e.dom=o=er(c.$LI,null,c.$CX,i),rr(e,l,c),c.$UPD=!1}else{var h=Zi(s(a,n),e);e.children=h,e.dom=o=er(h,null,n,i),or(a,l,o)}Zn(t)||vi(t,o);return o}(e,t,n,i,(4&r)>0):512&r||16&r?tr(e,t):1024&r?(er(e.children,e.type,n,!1),e.dom=tr(ci(),t)):void 0}function tr(e,t){var n=e.dom=document.createTextNode(e.children);return Zn(t)||vi(t,n),n}function nr(e,t,n,i){var r=e.flags,o=e.children,s=e.props,a=e.className,l=e.ref,c=e.childFlags;i=i||(32&r)>0;var h=function(e,t){return t?document.createElementNS("http://www.w3.org/2000/svg",e):document.createElement(e)}(e.type,i);if(e.dom=h,Kn(a)||""===a||(i?h.setAttribute("class",a):h.className=a),Zn(t)||vi(t,h),!(1&c)){var u=!0===i&&"foreignObject"!==e.type;2===c?er(o,h,n,u):12&c&&ir(o,h,n,u)}return Zn(s)||Ji(e,r,s,h,i),Yn(l)&&sr(h,l),h}function ir(e,t,n,i){for(var r=0,o=e.length;r<o;r++){var s=e[r];Zn(s.dom)||(e[r]=s=li(s)),er(s,t,n,i)}}function rr(e,t,n){Yn(t)&&t(n),Yn(n.componentDidMount)&&yi.push(function(e){return function(){e.$UPD=!0,e.componentDidMount(),e.$UPD=!1}}(n))}function or(e,t,n){Kn(t)||(Yn(t.onComponentWillMount)&&t.onComponentWillMount(e),Yn(t.onComponentDidMount)&&yi.push(function(e,t,n){return function(){return e.onComponentDidMount(t,n)}}(t,n,e)))}function sr(e,t){yi.push(function(){return t(e)})}function ar(e,t,n,i){var r=e.children,o=e.props,s=e.className,a=e.flags,l=e.ref;if(i=i||(32&a)>0,1!==t.nodeType||t.tagName.toLowerCase()!==e.type){var c=nr(e,null,n,i);e.dom=c,bi(t.parentNode,c,t)}else{e.dom=t;var h=t.firstChild,u=e.childFlags;if(1&u)Zn(t.firstChild)||function(e,t){return Boolean(t&&t.dangerouslySetInnerHTML&&t.dangerouslySetInnerHTML.__html&&Mi(e,t.dangerouslySetInnerHTML.__html))}(t,o)||(t.textContent="",448&a&&(t.defaultValue=""));else{for(var p=null;h;)p=h.nextSibling,8===h.nodeType&&("!"===h.data?t.replaceChild(document.createTextNode(""),h):t.removeChild(h)),h=p;if(h=t.firstChild,2===u)Zn(h)?er(r,t,n,i):(p=h.nextSibling,lr(r,h,n,i),h=p);else if(12&u)for(var d=0,f=r.length;d<f;d++){var g=r[d];Zn(h)?er(g,t,n,i):(p=h.nextSibling,lr(g,h,n,i),h=p)}for(;h;)p=h.nextSibling,t.removeChild(h),h=p}Zn(o)||Ji(e,a,o,t,i),Kn(s)?""!==t.className&&t.removeAttribute("class"):i?t.setAttribute("class",s):t.className=s,Yn(l)&&sr(t,l)}}function lr(e,t,n,i){var r=e.flags;14&r?function(e,t,n,i,r){var o=e.type,s=e.ref,a=e.props||mi;if(r){var l=Qi(e,o,a,n),c=l.$LI;lr(c,t,l.$CX,i),e.dom=c.dom,rr(0,s,l),l.$UPD=!1}else{var h=Zi(o(a,n),e);lr(h,t,n,i),e.children=h,e.dom=h.dom,or(a,s,t)}}(e,t,n,i,(4&r)>0):481&r?ar(e,t,n,i):16&r?function(e,t){if(3!==t.nodeType){var n=tr(e,null);e.dom=n,bi(t.parentNode,n,t)}else{var i=e.children;t.nodeValue!==i&&(t.nodeValue=i),e.dom=t}}(e,t):512&r?e.dom=t:function(e){throw e||(e="a runtime error occured! Use Inferno in development environment to find the error."),new Error("Inferno Error: "+e)}()}function cr(e,t,n,i,r){Ui(e),bi(n,er(t,null,i,r),e.dom)}function hr(e,t,n,i,r){var o=0|t.flags;e.flags!==o||2048&o?cr(e,t,n,i,r):481&o?function(e,t,n,i,r,o){var s=t.type;if(e.type!==s)cr(e,t,n,i,r);else{var a,l=e.dom,c=e.props,h=t.props,u=!1,p=!1;if(t.dom=l,r=r||(32&o)>0,c!==h){var d=c||mi;if((a=h||mi)!==mi)for(var f in(u=(448&o)>0)&&(p=Wi(a)),a){var g=d[f],m=a[f];g!==m&&Yi(f,g,m,l,r,p,e)}if(d!==mi)for(var y in d)a.hasOwnProperty(y)||Kn(d[y])||Yi(y,d[y],null,l,r,p,e)}var v=e.children,w=t.children,b=t.ref,x=e.className,_=t.className;4096&o?function(e,t){e.textContent!==t.children&&(e.textContent=t.children)}(l,w):ur(e.childFlags,t.childFlags,v,w,l,i,r&&"foreignObject"!==s),u&&$i(o,t,l,a,!1,p),x!==_&&(Kn(_)?l.removeAttribute("class"):r?l.setAttribute("class",_):l.className=_),Yn(b)&&e.ref!==b&&sr(l,b)}}(e,t,n,i,r,o):14&o?function(e,t,n,i,r,o){var s=t.type,a=e.key,l=t.key;if(e.type!==s||a!==l)cr(e,t,n,i,r);else{var c=t.props||mi;if(o){var h=e.children;h.$UPD=!0,h.$V=t,pr(h,h.state,t,c,n,i,r,!1,!1),h.$UPD=!1}else{var u=!0,p=e.props,d=t.ref,f=!Kn(d),g=e.children;if(t.dom=e.dom,t.children=g,f&&Yn(d.onComponentShouldUpdate)&&(u=d.onComponentShouldUpdate(p,c)),!1!==u){f&&Yn(d.onComponentWillUpdate)&&d.onComponentWillUpdate(p,c);var m=s(c,i);m!==Hn&&(hr(g,m=Zi(m,t),n,i,r),t.children=m,t.dom=m.dom,f&&Yn(d.onComponentDidUpdate)&&d.onComponentDidUpdate(p,c))}else 14&g.flags&&(g.parentVNode=t)}}}(e,t,n,i,r,(4&o)>0):16&o?function(e,t){var n=t.children,i=e.dom;n!==e.children&&(i.nodeValue=n);t.dom=i}(e,t):512&o?t.dom=e.dom:function(e,t,n){var i=e.type,r=t.type,o=t.children;if(ur(e.childFlags,t.childFlags,e.children,o,i,n,!1),t.dom=e.dom,i!==r&&!Xn(o)){var s=o.dom;i.removeChild(s),r.appendChild(s)}}(e,t,i)}function ur(e,t,n,i,r,o,s){switch(e){case 2:switch(t){case 2:hr(n,i,r,o,s);break;case 1:Hi(n,r);break;default:Hi(n,r),ir(i,r,o,s)}break;case 1:switch(t){case 2:er(i,r,o,s);break;case 1:break;default:ir(i,r,o,s)}break;default:if(12&t){var a=n.length,l=i.length;0===a?l>0&&ir(i,r,o,s):0===l?Ki(r,n):8===t&&8===e?function(e,t,n,i,r,o,s){var a,l,c=o-1,h=s-1,u=0,p=e[u],d=t[u];e:{for(;p.key===d.key;){if(d.dom&&(t[u]=d=li(d)),hr(p,d,n,i,r),e[u]=d,++u>c||u>h)break e;p=e[u],d=t[u]}for(p=e[c],d=t[h];p.key===d.key;){if(d.dom&&(t[h]=d=li(d)),hr(p,d,n,i,r),e[c]=d,h--,u>--c||u>h)break e;p=e[c],d=t[h]}}if(u>c){if(u<=h)for(var f=(l=h+1)<s?t[l].dom:null;u<=h;)(d=t[u]).dom&&(t[u]=d=li(d)),u++,wi(n,er(d,null,i,r),f)}else if(u>h)for(;u<=c;)Hi(e[u++],n);else{var g=u,m=u,y=c-u+1,v=h-u+1,w=[];for(a=0;a<v;a++)w.push(0);var b=y===o,x=!1,_=0,k=0;if(s<4||(y|v)<32)for(a=g;a<=c;a++)if(p=e[a],k<v){for(u=m;u<=h;u++)if(d=t[u],p.key===d.key){if(w[u-m]=a+1,b)for(b=!1;a>g;)Hi(e[g++],n);_>u?x=!0:_=u,d.dom&&(t[u]=d=li(d)),hr(p,d,n,i,r),k++;break}!b&&u>h&&Hi(p,n)}else b||Hi(p,n);else{var S={};for(a=m;a<=h;a++)S[t[a].key]=a;for(a=g;a<=c;a++)if(p=e[a],k<v)if(void 0!==(u=S[p.key])){if(b)for(b=!1;a>g;)Hi(e[g++],n);d=t[u],w[u-m]=a+1,_>u?x=!0:_=u,d.dom&&(t[u]=d=li(d)),hr(p,d,n,i,r),k++}else b||Hi(p,n);else b||Hi(p,n)}if(b)Ki(n,e),ir(t,n,i,r);else if(x){var C=function(e){var t,n,i,r,o,s=e.slice(),a=[0],l=e.length;for(t=0;t<l;t++){var c=e[t];if(0!==c){if(e[n=a[a.length-1]]<c){s[t]=n,a.push(t);continue}for(i=0,r=a.length-1;i<r;)e[a[o=(i+r)/2|0]]<c?i=o+1:r=o;c<e[a[i]]&&(i>0&&(s[t]=a[i-1]),a[i]=t)}}i=a.length,r=a[i-1];for(;i-- >0;)a[i]=r,r=s[r];return a}(w);for(u=C.length-1,a=v-1;a>=0;a--)0===w[a]?((d=t[_=a+m]).dom&&(t[_]=d=li(d)),l=_+1,wi(n,er(d,null,i,r),l<s?t[l].dom:null)):u<0||a!==C[u]?(l=(_=a+m)+1,wi(n,(d=t[_]).dom,l<s?t[l].dom:null)):u--}else if(k!==v)for(a=v-1;a>=0;a--)0===w[a]&&((d=t[_=a+m]).dom&&(t[_]=d=li(d)),l=_+1,wi(n,er(d,null,i,r),l<s?t[l].dom:null))}}(n,i,r,o,s,a,l):function(e,t,n,i,r,o,s){for(var a,l,c=o>s?s:o,h=0;h<c;h++)a=t[h],l=e[h],a.dom&&(a=t[h]=li(a)),hr(l,a,n,i,r),e[h]=a;if(o<s)for(h=c;h<s;h++)(a=t[h]).dom&&(a=t[h]=li(a)),er(a,n,i,r);else if(o>s)for(h=c;h<o;h++)Hi(e[h],n)}(n,i,r,o,s,a,l)}else 1===t?Ki(r,n):2===t&&(Ki(r,n),er(i,r,o,s))}}function pr(e,t,n,i,r,o,s,a,l){var c,h=e.state,u=e.props;if(n.children=e,!e.$UN){if(u!==i||i===mi){if(!l&&Yn(e.componentWillReceiveProps)){if(e.$BR=!0,e.componentWillReceiveProps(i,o),e.$UN)return;e.$BR=!1}e.$PSS&&(t=ti(t,e.$PS),e.$PSS=!1,e.$PS=null)}var p=Boolean(e.shouldComponentUpdate);if(a||!p||p&&e.shouldComponentUpdate(i,t,o)){Yn(e.componentWillUpdate)&&(e.$BS=!0,e.componentWillUpdate(i,t,o),e.$BS=!1),e.props=i,e.state=t,e.context=o,Yn(pi.beforeRender)&&pi.beforeRender(e),c=e.render(i,t,o),Yn(pi.afterRender)&&pi.afterRender(e);var d,f=c!==Hn;if(Yn(e.getChildContext)&&(d=e.getChildContext()),d=Kn(d)?o:ti(o,d),e.$CX=d,f){var g=e.$LI,m=Zi(c,n);hr(g,m,r,d,s),e.$LI=m,Yn(e.componentDidUpdate)&&e.componentDidUpdate(u,h)}}else e.props=i,e.state=t,e.context=o;n.dom=e.$LI.dom}}function dr(e,t,n){if(e!==Hn){var i=t.$V;return Kn(i)?Xn(e)||(e.dom&&(e=li(e)),Zn(t.firstChild)?(er(e,t,mi,!1),t.$V=e):function(e,t,n){var i=t.firstChild;if(!Zn(i))for(Xn(e)||lr(e,i,mi,!1),i=t.firstChild;i=i.nextSibling;)t.removeChild(i);yi.length>0&&xi(yi),t.$V=e,Yn(n)&&n()}(e,t),i=e):Kn(e)?(Hi(i,t),t.$V=null):(e.dom&&(e=li(e)),hr(i,e,t,mi,!1),i=t.$V=e),yi.length>0&&xi(yi),Yn(n)&&n(),Yn(pi.renderComplete)&&pi.renderComplete(i),i&&14&i.flags?i.children:void 0}}var fr="undefined"==typeof Promise?null:Promise.resolve(),gr="undefined"==typeof requestAnimationFrame?setTimeout:requestAnimationFrame.bind(window);function mr(e,t,n,i){Yn(t)&&(t=t(e.state,e.props,e.context));var r,o=e.$PS;if(Kn(o))e.$PS=t;else for(var s in t)o[s]=t[s];if(e.$PSS||e.$BR)e.$PSS=!0,e.$BR&&Yn(n)&&yi.push(n.bind(e));else if(e.$UPD){var a=e.$QU;Zn(a)&&(a=e.$QU=[],r=function(e,t){return function(){e.$QU=null,e.$UPD=!0,yr(e,!1,function(){for(var n=0,i=t.length;n<i;n++)t[n].call(e)}),e.$UPD=!1}}(e,a),fr?fr.then(r):gr(r)),Yn(n)&&a.push(n)}else e.$PSS=!0,e.$UPD=!0,yr(e,i,n),e.$UPD=!1}function yr(e,t,n){if(!e.$UN){if(t||!e.$BR){e.$PSS=!1;var i=e.$PS,r=ti(e.state,i),o=e.props,s=e.context;e.$PS=null;var a=e.$V,l=e.$LI;if(pr(e,r,a,o,l.dom&&l.dom.parentNode,s,(32&a.flags)>0,t,!0),e.$UN)return;if(!(1024&e.$LI.flags))for(var c=e.$LI.dom;!Zn(a=a.parentVNode);)(14&a.flags)>0&&(a.dom=c);yi.length>0&&xi(yi)}else e.state=e.$PS,e.$PS=null;Yn(n)&&n.call(e)}}var vr=function(){function e(e,t){this.state=null,this.props=void 0,this.context=void 0,this.refs=void 0,this.$BR=!1,this.$BS=!0,this.$PSS=!1,this.$PS=null,this.$LI=null,this.$V=null,this.$UN=!1,this.$CX=null,this.$UPD=!0,this.$QU=null,this.props=e||mi,this.context=t||mi}var t=e.prototype;return t.forceUpdate=function(e){this.$UN||mr(this,{},e,!0)},t.setState=function(e,t){this.$UN||this.$BS||mr(this,e,t,!1)},t.render=function(e,t,n){},e}();vr.defaultProps=void 0;var wr='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 14.02 5.57" width="53" height="21" style="vertical-align:middle"><path fill="#000000" d="M1.88.92v.14c0 .41-.13.68-.4.8.33.14.46.44.46.86v.33c0 .61-.33.95-.95.95H0V0h.95c.65 0 .93.3.93.92zM.63.57v1.06h.24c.24 0 .38-.1.38-.43V.98c0-.28-.1-.4-.32-.4zm0 1.63v1.22h.36c.2 0 .32-.1.32-.39v-.35c0-.37-.12-.48-.4-.48H.63zM4.18.99v.52c0 .64-.31.98-.94.98h-.3V4h-.62V0h.92c.63 0 .94.35.94.99zM2.94.57v1.35h.3c.2 0 .3-.09.3-.37v-.6c0-.29-.1-.38-.3-.38h-.3zm2.89 2.27L6.25 0h.88v4h-.6V1.12L6.1 3.99h-.6l-.46-2.82v2.82h-.55V0h.87zM8.14 1.1V4h-.56V0h.79L9 2.4V0h.56v4h-.64zm2.49 2.29v.6h-.6v-.6zM12.12 1c0-.63.33-1 .95-1 .61 0 .95.37.95 1v2.04c0 .64-.34 1-.95 1-.62 0-.95-.37-.95-1zm.62 2.08c0 .28.13.39.33.39s.32-.1.32-.4V.98c0-.29-.12-.4-.32-.4s-.33.11-.33.4z"/><path fill="#000000" d="M0 4.53h14.02v1.04H0zM11.08 0h.63v.62h-.63zm.63 4V1h-.63v2.98z"/></svg>';
/**
* Adds the project logo to the diagram container as
* required by the bpmn.io license.
*
* @see http://bpmn.io/license
*
* @param {Element} container
*/function br(e){var t=We('<a href="http://bpmn.io" target="_blank" class="bjs-powered-by" title="Powered by bpmn.io" style="position: absolute; bottom: 15px; right: 15px; z-index: 100;">'+wr+"</a>");e.appendChild(t),it.bind(t,"click",function(e){!function(){kr||(kr=We(Sr),ot.bind(kr,".backdrop","click",function(e){document.body.removeChild(kr)}));document.body.appendChild(kr)}(),e.preventDefault()})}class xr extends vr{constructor(e,t){super(e,t),this.node=null}componentDidMount(){br(this.node)}render(){return ri(1,"div",null,null,1,null,null,e=>this.node=e)}}function _r(e){return e.join(";")}var kr,Sr='<div class="bjs-powered-by-lightbox" style="'+_r(["z-index: 1001","position: fixed","top: 0","left: 0","right: 0","bottom: 0"])+'"><div class="backdrop" style="'+_r(["width: 100%","height: 100%","background: rgba(40,40,40,0.2)"])+'"></div><div class="notice" style="'+_r(["position: absolute","left: 50%","top: 40%","transform: translate(-50%)","width: 260px","padding: 10px","background: white","box-shadow: 0 1px 4px rgba(0,0,0,0.3)","font-family: Helvetica, Arial, sans-serif","font-size: 14px","display: flex","line-height: 1.3"])+'"><a href="https://bpmn.io" target="_blank" rel="noopener" style="margin: 15px 20px 15px 10px; align-self: center;">'+wr+'</a><span>Web-based tooling for BPMN, DMN and CMMN diagrams powered by <a href="https://bpmn.io" target="_blank" rel="noopener">bpmn.io</a>.</span></div></div>';function Cr(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Er,Mr={exports:{}};var Ar=function(){if(Er)return Mr.exports;Er=1;var e=Mr.exports=function(t,n){if(n||(n=16),void 0===t&&(t=128),t<=0)return"0";for(var i=Math.log(Math.pow(2,t))/Math.log(n),r=2;i===1/0;r*=2)i=Math.log(Math.pow(2,t/r))/Math.log(n)*r;var o=i-Math.floor(i),s="";for(r=0;r<Math.floor(i);r++){s=Math.floor(Math.random()*n).toString(n)+s}if(o){var a=Math.pow(n,o);s=Math.floor(Math.random()*a).toString(n)+s}var l=parseInt(s,n);return l!==1/0&&l>=Math.pow(2,t)?e(t,n):s};return e.rack=function(t,n,i){var r=function(r){var s=0;do{if(s++>10){if(!i)throw new Error("too many ID collisions, use more bits");t+=i}var a=e(t,n)}while(Object.hasOwnProperty.call(o,a));return o[a]=r,a},o=r.hats={};return r.get=function(e){return r.hats[e]},r.set=function(e,t){return r.hats[e]=t,r},r.bits=t||128,r.base=n||16,r},Mr.exports}(),Tr=Cr(Ar);function Rr(e){if(!(this instanceof Rr))return new Rr(e);e=e||[128,36,1],this._seed=e.length?Tr.rack(e[0],e[1],e[2]):e}Rr.prototype.next=function(e){return this._seed(e||!0)},Rr.prototype.nextPrefixed=function(e,t){var n;do{n=e+this.next(!0)}while(this.assigned(n));return this.claim(n,t),n},Rr.prototype.claim=function(e,t){this._seed.set(e,t||!0)},Rr.prototype.assigned=function(e){return this._seed.get(e)||!1},Rr.prototype.unclaim=function(e){delete this._seed.hats[e]},Rr.prototype.clear=function(){var e,t=this._seed.hats;for(e in t)this.unclaim(e)};var Or=new Rr,Dr="hsl(225, 10%, 15%)";function qr(e,t,n,i,r,o){Et.call(this,t);var a=Or.next(),l=i.computeStyle,c={},h=e&&e.defaultFillColor||"white",u=e&&e.defaultStrokeColor||Dr,p=e&&e.defaultLabelColor;function d(e,t,n){var i=e+"-"+Br(t)+"-"+Br(n)+"-"+a;return c[i]||function(e,t,n,i){if("association-start"===t){var r=Lt("path");Rt(r,{d:"M 11 5 L 1 10 L 11 15"}),f(e,{element:r,attrs:{fill:"none",stroke:i,strokeWidth:1.5},ref:{x:1,y:10},scale:.5})}else if("association-end"===t){var o=Lt("path");Rt(o,{d:"M 1 5 L 11 10 L 1 15"}),f(e,{element:o,attrs:{fill:"none",stroke:i,strokeWidth:1.5},ref:{x:12,y:10},scale:.5})}else if("information-requirement-end"===t){var s=Lt("path");Rt(s,{d:"M 1 5 L 11 10 L 1 15 Z"}),f(e,{element:s,attrs:{fill:i,stroke:"none"},ref:{x:11,y:10},scale:1})}else if("knowledge-requirement-end"===t){var a=Lt("path");Rt(a,{d:"M 1 3 L 11 10 L 1 17"}),f(e,{element:a,attrs:{fill:"none",stroke:i,strokeWidth:2},ref:{x:11,y:10},scale:.8})}else if("authority-requirement-end"===t){var l=Lt("circle");Rt(l,{cx:3,cy:3,r:3}),f(e,{element:l,attrs:{fill:i,stroke:"none"},ref:{x:3,y:3},scale:.9})}}(i,e,0,n),"url(#"+i+")"}function f(e,t){var n=S({strokeWidth:1,strokeLinecap:"round",strokeDasharray:"none"},t.attrs),i=t.ref||{x:0,y:0},r=t.scale||1;"none"===n.strokeDasharray&&(n.strokeDasharray=[1e4,1]);var s=Lt("marker");Rt(t.element,n),Mt(s,t.element),Rt(s,{id:e,viewBox:"0 0 20 20",refX:i.x,refY:i.y,markerWidth:20*r,markerHeight:20*r,orient:"auto"});var a=st("defs",o._svg);a||(a=Lt("defs"),Mt(o._svg,a)),Mt(a,s),c[e]=s}function g(e,t,n,i,r,o){s(r)&&(o=r,r=0),r=r||0,o=l(o,{stroke:Dr,strokeWidth:2,fill:"white"});var a=Lt("rect");return Rt(a,{x:r,y:r,width:t-2*r,height:n-2*r,rx:i,ry:i}),Rt(a,o),Mt(e,a),a}function m(e,t,n){var i=r.createText(t||"",n);return Ge(i,"class","djs-label"),Mt(e,i),i}function y(e,t,n,i){var r=function(e){return jn(e).name}(t);return m(e,r,i=S({box:t,align:n,padding:5,style:{fill:Ir(t,p,u)}},i))}function v(e,t,n){n=l(n,["no-fill"],{strokeWidth:2,stroke:Dr});var i=Lt("path");return Rt(i,{d:t}),Rt(i,n),Mt(e,i),i}var w={"dmn:Decision":function(e,t){var n=g(e,t.width,t.height,0,{stroke:Pr(t,u),fill:Lr(t,h)});return y(e,t,"center-middle"),n},"dmn:KnowledgeSource":function(e,t){var i=v(e,n.getScaledPath("KNOWLEDGE_SOURCE",{xScaleFactor:1.021,yScaleFactor:1,containerWidth:t.width,containerHeight:t.height,position:{mx:0,my:.075}}),{strokeWidth:2,fill:Lr(t,h),stroke:Pr(t,u)});return y(e,t,"center-middle"),i},"dmn:BusinessKnowledgeModel":function(e,t){var i=v(e,n.getScaledPath("BUSINESS_KNOWLEDGE_MODEL",{xScaleFactor:1,yScaleFactor:1,containerWidth:t.width,containerHeight:t.height,position:{mx:0,my:.3}}),{strokeWidth:2,fill:Lr(t,h),stroke:Pr(t,u)});return y(e,t,"center-middle"),i},"dmn:InputData":function(e,t){var n=g(e,t.width,t.height,22,{stroke:Pr(t,u),fill:Lr(t,h)});return y(e,t,"center-middle"),n},"dmn:DecisionService":function(e,t){var n=g(e,t.width,t.height,12,{stroke:Pr(t,u),strokeWidth:4,fill:Lr(t,h),fillOpacity:.95}),i=t.height*function(e){var t=e&&e.di,n=t&&t.decisionServiceDividerLine,i=t&&t.bounds;if(!(n&&n.waypoint&&2===n.waypoint.length&&i&&i.height))return.5;var r=(n.waypoint[0].y-i.y)/i.height;return Math.max(0,Math.min(1,r))}(t.businessObject),r=Lt("line");Rt(r,{x1:0,y1:i,x2:t.width,y2:i,stroke:Pr(t,u),strokeWidth:2}),Ge(r,"class","dmn-decision-service-divider"),Mt(e,r);var o=Lt("text");Rt(o,{x:t.width/2,y:i-10,fill:Ir(t,p,u),"font-family":"Arial, sans-serif","font-weight":"bold","font-size":"12px","text-anchor":"middle","dominant-baseline":"middle"}),o.textContent="OUTPUT",Ge(o,"class","djs-label dmn-decision-service-label"),Ge(o,"display","none"),Mt(e,o);var s=Lt("text");return Rt(s,{x:t.width/2,y:i+10,fill:Ir(t,p,u),"font-family":"Arial, sans-serif","font-weight":"bold","font-size":"12px","text-anchor":"middle","dominant-baseline":"middle"}),s.textContent="ENCAPSULATED",Ge(s,"class","djs-label dmn-decision-service-label"),Ge(s,"display","none"),Mt(e,s),y(e,t,"center-top",{padding:10}),n},"dmn:TextAnnotation":function(e,t){var i=g(e,t.width,t.height,0,0,{fill:"none",stroke:"none"});return v(e,n.getScaledPath("TEXT_ANNOTATION",{xScaleFactor:1,yScaleFactor:1,containerWidth:t.width,containerHeight:t.height,position:{mx:0,my:0}}),{stroke:Pr(t,u)}),m(e,Nr(t).text||"",{style:{fill:Ir(t,p,u)},box:t,align:"left-top",padding:5}),i},"dmn:Association":function(e,t){var n=Nr(t),i=Lr(t,h),r=Pr(t,u),o={stroke:r,strokeDasharray:"0.5, 5",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"};return"One"!==n.associationDirection&&"Both"!==n.associationDirection||(o.markerEnd=d("association-end",i,r)),"Both"===n.associationDirection&&(o.markerStart=d("association-start",i,r)),b(e,t.waypoints,o)},"dmn:InformationRequirement":function(e,t){var n=Lr(t,h),i=Pr(t,u),r={stroke:i,strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round",markerEnd:d("information-requirement-end",n,i)};return b(e,t.waypoints,r)},"dmn:KnowledgeRequirement":function(e,t){var n=Lr(t,h),i=Pr(t,u),r={stroke:i,strokeWidth:1,strokeDasharray:5,strokeLinecap:"round",strokeLinejoin:"round",markerEnd:d("knowledge-requirement-end",n,i)};return b(e,t.waypoints,r)},"dmn:AuthorityRequirement":function(e,t){var n=Lr(t,h),i=Pr(t,u),r={stroke:i,strokeWidth:1.5,strokeDasharray:5,strokeLinecap:"round",strokeLinejoin:"round",markerEnd:d("authority-requirement-end",n,i)};return b(e,t.waypoints,r)}};function b(e,t,n){var i=nn(t,n=l(n,["no-fill"],{stroke:Dr,strokeWidth:2,fill:"none"}));return Mt(e,i),i}this.canRender=function(e){return In(e,"dmn:DMNElement")||In(e,"dmn:InformationRequirement")||In(e,"dmn:KnowledgeRequirement")||In(e,"dmn:AuthorityRequirement")},this.drawShape=function(e,t){var n=w[t.type];return n?n(e,t):Et.prototype.drawShape.apply(this,[e,t])},this.drawConnection=function(e,t){var n=t.type,i=w[n];return i?i(e,t):Et.prototype.drawConnection.apply(this,[e,t])}}function Nr(e){return e.businessObject}function Br(e){return e.replace(/[^0-9a-zA-z]+/g,"_")}function Pr(e,t){return t}function Lr(e,t){return t}function Ir(e,t,n){return t||Pr(0,n)}gt(qr,Et),qr.$inject=["config.drdRenderer","eventBus","pathMap","styles","textRenderer","canvas"];var jr={width:150,height:50};var Fr=null;function Vr(e){if(null!=e)return"number"==typeof e||/^-?\d+(\.\d+)?$/.test(e)?e+"px":e}function $r(e,t){var n=(Fr||(Fr=document.createElement("canvas").getContext("2d")),Fr);if(!n)return{width:0,height:0};n.font=function(e){var t=[];return e.fontStyle&&t.push(e.fontStyle),e.fontVariant&&t.push(e.fontVariant),e.fontWeight&&t.push(e.fontWeight),e.fontStretch&&t.push(e.fontStretch),t.push(Vr(e.fontSize)||"12px"),t.push(e.fontFamily||"sans-serif"),t.join(" ")}(t),"letterSpacing"in n&&(n.letterSpacing=Vr(t.letterSpacing)||"0px");var i=""===e,r=i?"dummy":e.replace(/\s+$/,""),o=n.measureText(r);return{width:i?0:o.width,height:"fontBoundingBoxAscent"in o?o.fontBoundingBoxAscent+o.fontBoundingBoxDescent:o.actualBoundingBoxAscent+o.actualBoundingBoxDescent}}function zr(e,t,n){for(var i,r=e.shift(),o=r;;){if((i=$r(o,n)).width=o?i.width:0," "===o||""===o||i.width<=t||o.length<2)return Wr(e,o,r,i);o=Ur(o,i.width,t)}}function Wr(e,t,n,i){if(t.length<n.length){var r=n.slice(t.length).trim();e.unshift(r)}return{width:i.width,height:i.height,text:t}}var Hr="";function Ur(e,t,n){var i=Math.max(e.length*(n/t),1),r=function(e,t){var n,i=e.split(/(\s|-|\u00AD)/g),r=[],o=0;if(i.length>1)for(;n=i.shift();){if(!(n.length+o<t)){"-"!==n&&n!==Hr||r.pop();break}r.push(n),o+=n.length}var s=r[r.length-1];return s&&s===Hr&&(r[r.length-1]="-"),r.join("")}(e,i);return r||(r=e.slice(0,Math.max(Math.round(i-1),1))),r}function Gr(e){this._config=S({},{size:jr,padding:0,style:{},align:"center-top"},e||{})}Gr.prototype.createText=function(e,t){return this.layoutText(e,t).element},Gr.prototype.getDimensions=function(e,t){return this.layoutText(e,t).dimensions},Gr.prototype.layoutText=function(e,t){for(var n=S({},this._config.size,t.box),i=S({},this._config.style,t.style),r=function(e){var t=e.split("-");return{horizontal:t[0]||"center",vertical:t[1]||"top"}}(t.align||this._config.align),o=function(e){return s(e)?S({top:0,left:0,right:0,bottom:0},e):{top:e,left:e,right:e,bottom:e}}(void 0!==t.padding?t.padding:this._config.padding),a=t.fitBox||!1,l=function(e){if("fontSize"in e&&"lineHeight"in e)return e.lineHeight*parseInt(e.fontSize,10)}(i),c=e.split(/\u00AD?\r?\n/),h=[],u=n.width-o.left-o.right;c.length;)h.push(zr(c,u,i));"middle"===r.vertical&&(o.top=o.bottom=0);var p=f(h,function(e,t,n){return e+(l||t.height)},0)+o.top+o.bottom,g=f(h,function(e,t,n){return t.width>e?t.width:e},0),m=o.top;"middle"===r.vertical&&(m+=(n.height-p)/2),m-=(l||h[0].height)/4;var y=Lt("text");return Rt(y,i),d(h,function(e){var t;switch(m+=l||e.height,r.horizontal){case"left":t=o.left;break;case"right":t=(a?g:u)-o.right-e.width;break;default:t=Math.max(((a?g:u)-e.width)/2+o.left,0)}var n=Lt("tspan");Rt(n,{x:t,y:m}),n.textContent=e.text,Mt(y,n)}),{dimensions:{width:g,height:p},element:y}};function Kr(e){var t=S({fontFamily:"Arial, sans-serif",fontSize:12,fontWeight:"normal",lineHeight:1.2},e&&e.defaultStyle||{}),n=parseInt(t.fontSize,10)-1,i=S({},t,{fontSize:n},e&&e.externalStyle||{}),r=new Gr({style:t});this.getExternalLabelBounds=function(e,t){var n=r.getDimensions(t,{box:{width:90,height:30,x:e.width/2+e.x,y:e.height/2+e.y},style:i});return{x:Math.round(e.x+e.width/2-n.width/2),y:Math.round(e.y),width:Math.ceil(n.width),height:Math.ceil(n.height)}},this.getTextAnnotationBounds=function(e,n){var i=r.getDimensions(n,{box:e,style:t,align:"left-top",padding:5});return{x:e.x,y:e.y,width:e.width,height:Math.max(30,Math.round(i.height))}},this.createText=function(e,t){return r.createText(e,t||{})},this.getDefaultStyle=function(){return t},this.getExternalStyle=function(){return i}}Kr.$inject=["config.textRenderer"];var Xr=/\{([^{}]+)\}/g,Yr=/(?:(?:^|\.)(.+?)(?=\[|\.|$|\()|\[('|")(.+?)\2\])(\(\))?/g;var Jr={__init__:["drdRenderer"],drdRenderer:["type",qr],textRenderer:["type",Kr],pathMap:["type",function(){this.pathMap={KNOWLEDGE_SOURCE:{d:"m {mx},{my} l 0,{e.y0} c {e.x0},{e.y1} {e.x1},-{e.y2} {e.x2},-{e.y3} c {e.x3},-{e.y4} {e.x4},{e.y5} {e.x5},{e.y6} l 0,-{e.y7}z",width:100,height:65,widthElements:[29.8,48.4,67.2,12.2,19.8,30.8],heightElements:[55.3,19.7,4.2,6.7,2.3,1.6,6.2,54.6]},BUSINESS_KNOWLEDGE_MODEL:{d:"m {mx},{my} l {e.x0},-{e.y0} l {e.x1},0 l 0,{e.y1} l -{e.x2},{e.y2} l -{e.x3},0z",width:125,height:45,widthElements:[13.8,109.2,13.8,109.1],heightElements:[13.2,29.8,13.2]},TEXT_ANNOTATION:{d:"m {mx}, {my} m 10,0 l -10,0 l 0,{e.y0} l 10,0",width:10,height:30,widthElements:[10],heightElements:[30]}},this.getRawPath=function(e){return this.pathMap[e].d},this.getScaledPath=function(e,t){var n,i,r=this.pathMap[e];t.abspos?(n=t.abspos.x,i=t.abspos.y):(n=t.containerWidth*t.position.mx,i=t.containerHeight*t.position.my);var o={};if(t.position){for(var s=t.containerHeight/r.height*t.yScaleFactor,a=t.containerWidth/r.width*t.xScaleFactor,l=0;l<r.heightElements.length;l++)o["y"+l]=r.heightElements[l]*s;for(var c=0;c<r.widthElements.length;c++)o["x"+c]=r.widthElements[c]*a}var h,u,p=(h=r.d,u={mx:n,my:i,e:o},String(h).replace(Xr,function(e,t){return function(e,t,n){var i=n;return t.replace(Yr,function(e,t,n,r,o){t=t||r,i&&(t in i&&(i=i[t]),"function"==typeof i&&o&&(i=i()))}),i=(null==i||i==n?e:i)+""}(e,t,u)}));return p}}]};function Qr(e,t,n,i){this._eventBus=e,this._canvas=t,this._elementRegistry=i,this._elementFactory=n}function Zr(e,t){return S({id:e.id,type:e.$type,businessObject:e},t)}Qr.$inject=["eventBus","canvas","elementFactory","elementRegistry"],Qr.prototype.root=function(e){var t=this._elementFactory.createRoot(Zr(e));return this._canvas.setRootElement(t),t},Qr.prototype.add=function(e,t){var n,i,r,o,s,a,l,c=this._elementFactory,h=this._canvas,u=this._eventBus,p=e.di;if(n=t&&this._getShape(t.id),p.$instanceOf("dmndi:DMNShape"))l=p.bounds,a=Zr(e,{x:Math.round(l.x),y:Math.round(l.y),width:Math.round(l.width),height:Math.round(l.height)}),i=c.createShape(a),h.addShape(i,n),u.fire("drdElement.added",{element:i,di:p});else{if(!p.$instanceOf("dmndi:DMNEdge"))throw new Error("unknown di for element "+e.id);r=function(e){var t=e.waypoint;if(t)return m(t,function(e){var t={x:e.x,y:e.y};return S({original:t},t)})}(p),o=this._getSource(e),s=this._getTarget(e),o&&s&&(a=Zr(e,{hidden:!1,source:o,target:s,waypoints:r}),i=c.createConnection(a),h.addConnection(i),u.fire("drdElement.added",{element:i,di:p}))}return i},Qr.prototype._getSource=function(e){var t,n;if(In(e,"dmn:Association")?n=e.sourceRef:In(e,"dmn:InformationRequirement")?n=e.requiredDecision||e.requiredInput:In(e,"dmn:KnowledgeRequirement")?n=e.requiredKnowledge:In(e,"dmn:AuthorityRequirement")&&(n=e.requiredDecision||e.requiredInput||e.requiredAuthority),n&&(t=n.href),t)return this._getShape($n(t))},Qr.prototype._getTarget=function(e){return In(e,"dmn:Association")?e.targetRef&&this._getShape($n(e.targetRef.href)):this._getShape(e.$parent.id)},Qr.prototype._getShape=function(e){return this._elementRegistry.get(e)};var eo={__depends__:[Jr,{drdImporter:["type",Qr]}]};var to={translate:["value",function(e,t){return t=t||{},e.replace(/{([^}]+)}/g,function(e,n){return t[n]||"{"+n+"}"})}]};function no(e){return e.originalEvent||e.srcEvent}function io(e){return e.pointers&&e.pointers.length&&(e=e.pointers[0]),e.touches&&e.touches.length&&(e=e.touches[0]),e?{x:e.clientX,y:e.clientY}:null}function ro(e,t){return(no(e)||e).button===t}function oo(e){return ro(e,0)}function so(e){return!0}function ao(e){return oo(e)||function(e){return ro(e,1)}(e)}function lo(e,t,n){var i=this;function r(n,i,r){var o,s;(function(e,t){var n=l[e]||oo;return!n(t)})(n,i)||(r?s=t.getGraphics(r):(o=i.delegateTarget||i.target)&&(s=o,r=t.get(s)),s&&r&&!1===e.fire(n,{element:r,gfx:s,originalEvent:i})&&(i.stopPropagation(),i.preventDefault()))}var o={};function s(e){return o[e]}var a={click:"element.click",contextmenu:"element.contextmenu",dblclick:"element.dblclick",mousedown:"element.mousedown",mousemove:"element.mousemove",mouseover:"element.hover",mouseout:"element.out",mouseup:"element.mouseup"},l={"element.contextmenu":so,"element.mousedown":ao,"element.mouseup":ao,"element.click":ao,"element.dblclick":ao};function c(e,t,n,i){var s=o[n]=function(e){r(n,e)};i&&(l[n]=i),s.$delegate=ot.bind(e,"svg, .djs-element",t,s)}function h(e,t,n){var i=s(n);i&&ot.unbind(e,t,i.$delegate)}e.on("canvas.destroy",function(e){!function(e){d(a,function(t,n){h(e,n,t)})}(e.svg)}),e.on("canvas.init",function(e){!function(e){d(a,function(t,n){c(e,n,t)})}(e.svg)}),e.on(["shape.added","connection.added"],function(t){var n=t.element,i=t.gfx;e.fire("interactionEvents.createHit",{element:n,gfx:i})}),e.on(["shape.changed","connection.changed"],500,function(t){var n=t.element,i=t.gfx;e.fire("interactionEvents.updateHit",{element:n,gfx:i})}),e.on("interactionEvents.createHit",500,function(e){var t=e.element,n=e.gfx;i.createDefaultHit(t,n)}),e.on("interactionEvents.updateHit",function(e){var t=e.element,n=e.gfx;i.updateDefaultHit(t,n)});var u=g("djs-hit djs-hit-stroke"),p=g("djs-hit djs-hit-click-stroke"),f={all:g("djs-hit djs-hit-all"),"click-stroke":p,stroke:u,"no-move":g("djs-hit djs-hit-no-move")};function g(e,t){return t=S({stroke:"white",strokeWidth:15},t||{}),n.cls(e,["no-fill","no-border"],t)}function m(e,t){var n=f[t];if(!n)throw new Error("invalid hit type <"+t+">");return Rt(e,n),e}function y(e,t){Mt(e,t)}this.removeHits=function(e){var t;d((t=".djs-hit",(e||document).querySelectorAll(t)),Gt)},this.createDefaultHit=function(e,t){var n,i=e.waypoints,r=e.isFrame;return i?this.createWaypointsHit(t,i):(n=r?"stroke":"all",this.createBoxHit(t,n,{width:e.width,height:e.height}))},this.createWaypointsHit=function(e,t){var n=nn(t);return m(n,"stroke"),y(e,n),n},this.createBoxHit=function(e,t,n){n=S({x:0,y:0},n);var i=Lt("rect");return m(i,t),Rt(i,n),y(e,i),i},this.updateDefaultHit=function(e,t){var n=st(".djs-hit",t);if(n)return e.waypoints?rn(n,e.waypoints):Rt(n,{width:e.width,height:e.height}),n},this.fire=r,this.triggerMouseEvent=function(e,t,n){var i=a[e];if(!i)throw new Error("unmapped DOM event name <"+e+">");return r(i,t,n)},this.mouseHandler=s,this.registerEvent=c,this.unregisterEvent=h}lo.$inject=["eventBus","elementRegistry","styles"];var co={__init__:["interactionEvents"],interactionEvents:["type",lo]};function ho(e,t){this._eventBus=e,this._canvas=t,this._selectedElements=new Set;var n=this;e.on(["shape.remove","connection.remove"],function(e){var t=e.element;n.deselect(t)}),e.on(["diagram.clear","root.set"],function(e){n.select(null)})}ho.$inject=["eventBus","canvas"],ho.prototype.deselect=function(e){if(this._selectedElements.has(e)){var t=this.get();this._selectedElements.delete(e),this._eventBus.fire("selection.changed",{oldSelection:t,newSelection:this.get()})}},ho.prototype.get=function(){return Array.from(this._selectedElements)},ho.prototype.isSelected=function(e){return this._selectedElements.has(e)},ho.prototype.select=function(e,t){var n=this.get();o(e)||(e=e?[e]:[]);var i=this._canvas,r=i.getRootElement();e=e.filter(function(e){var t=i.findRoot(e);return r===t}),t?d(e,e=>{this._selectedElements.add(e)}):this._selectedElements=new Set(e),this._eventBus.fire("selection.changed",{oldSelection:n,newSelection:this.get()})};var uo="hover",po="selected";function fo(e,t){function n(t,n){e.addMarker(t,n)}function i(t,n){e.removeMarker(t,n)}this._canvas=e,t.on("element.hover",function(e){n(e.element,uo)}),t.on("element.out",function(e){i(e.element,uo)}),t.on("selection.changed",function(e){function t(e){i(e,po)}function r(e){n(e,po)}var o=new Set(e.oldSelection),s=new Set(e.newSelection);for(let e of o)s.has(e)||t(e);for(let e of s)o.has(e)||r(e)})}function go(e,t,n,i){e.on("create.end",500,function(e){var n=e.context,i=n.canExecute,r=n.elements,s=(n.hints||{}).autoSelect;if(i){if(!1===s)return;o(s)?t.select(s):t.select(r.filter(mo))}}),e.on("connect.end",500,function(e){var n=e.context.connection;n&&t.select(n)}),e.on("shape.move.end",500,function(e){var n=e.previousSelection||[],r=i.get(e.context.shape.id);u(n,function(e){return r.id===e.id})||t.select(r)}),e.on("element.click",function(e){if(oo(e)){var i=e.element;i===n.getRootElement()&&(i=null);var r=t.isSelected(i),o=t.get().length>1,s=function(e){var t=no(e)||e;return oo(e)&&t.shiftKey}(e);if(r&&o)return s?t.deselect(i):t.select(i);r?t.deselect(i):t.select(i,s)}})}function mo(e){return!e.hidden}fo.$inject=["canvas","eventBus"],go.$inject=["eventBus","selection","canvas","elementRegistry"];var yo={__init__:["selectionVisuals","selectionBehavior"],__depends__:[co],selection:["type",ho],selectionVisuals:["type",fo],selectionBehavior:["type",go]};function vo(e){this._counter=0,this._prefix=(e?e+"-":"")+Math.floor(1e9*Math.random())+"-"}vo.prototype.next=function(){return this._prefix+ ++this._counter};var wo=new vo("ov");function bo(e,t,n,i){var r,o;this._eventBus=t,this._canvas=n,this._elementRegistry=i,this._ids=wo,this._overlayDefaults=S({show:null,scale:!0},e&&e.defaults),this._overlays={},this._overlayContainers=[],this._overlayRoot=(r=n.getContainer(),Ue(o=We('<div class="djs-overlay-container" />'),{position:"absolute",width:0,height:0}),r.insertBefore(o,r.firstChild),o),this._init()}function xo(e,t,n){Ue(e,{left:t+"px",top:n+"px"})}function _o(e,t){e.style.display=!1===t?"none":""}function ko(e,t){e.style["transform-origin"]="top left",["","-ms-","-webkit-"].forEach(function(n){e.style[n+"transform"]=t})}bo.$inject=["config.overlays","eventBus","canvas","elementRegistry"],bo.prototype.get=function(e){if(c(e)&&(e={id:e}),c(e.element)&&(e.element=this._elementRegistry.get(e.element)),e.element){var t=this._getOverlayContainer(e.element,!0);return t?e.type?p(t.overlays,v({type:e.type})):t.overlays.slice():[]}return e.type?p(this._overlays,v({type:e.type})):e.id?this._overlays[e.id]:null},bo.prototype.add=function(e,t,n){if(s(t)&&(n=t,t=null),e.id||(e=this._elementRegistry.get(e)),!n.position)throw new Error("must specifiy overlay position");if(!n.html)throw new Error("must specifiy overlay html");if(!e)throw new Error("invalid element specified");var i=this._ids.next();return n=S({},this._overlayDefaults,n,{id:i,type:t,element:e,html:n.html}),this._addOverlay(n),i},bo.prototype.remove=function(e){var t=this.get(e)||[];o(t)||(t=[t]);var n=this;d(t,function(e){var t=n._getOverlayContainer(e.element,!0);if(e&&(at(e.html),at(e.htmlContainer),delete e.htmlContainer,delete e.element,delete n._overlays[e.id]),t){var i=t.overlays.indexOf(e);-1!==i&&t.overlays.splice(i,1)}})},bo.prototype.isShown=function(){return"none"!==this._overlayRoot.style.display},bo.prototype.show=function(){_o(this._overlayRoot)},bo.prototype.hide=function(){_o(this._overlayRoot,!1)},bo.prototype.clear=function(){this._overlays={},this._overlayContainers=[],Je(this._overlayRoot)},bo.prototype._updateOverlayContainer=function(e){var t=e.element,n=e.html,i=t.x,r=t.y;if(t.waypoints){var o=on(t);i=o.x,r=o.y}xo(n,i,r),Ge(e.html,"data-container-id",t.id)},bo.prototype._updateOverlay=function(e){var t,n,i=e.position,r=e.htmlContainer,o=e.element,s=i.left,a=i.top;void 0!==i.right&&(t=o.waypoints?on(o).width:o.width,s=-1*i.right+t);void 0!==i.bottom&&(n=o.waypoints?on(o).height:o.height,a=-1*i.bottom+n);xo(r,s||0,a||0),this._updateOverlayVisibilty(e,this._canvas.viewbox())},bo.prototype._createOverlayContainer=function(e){var t=We('<div class="djs-overlays" />');Ue(t,{position:"absolute"}),this._overlayRoot.appendChild(t);var n={html:t,element:e,overlays:[]};return this._updateOverlayContainer(n),this._overlayContainers.push(n),n},bo.prototype._updateRoot=function(e){var t=e.scale||1,n="matrix("+[t,0,0,t,-1*e.x*t,-1*e.y*t].join(",")+")";ko(this._overlayRoot,n)},bo.prototype._getOverlayContainer=function(e,t){var n=u(this._overlayContainers,function(t){return t.element===e});return n||t?n:this._createOverlayContainer(e)},bo.prototype._addOverlay=function(e){var t,n,i=e.id,r=e.element,o=e.html;o.get&&o.constructor.prototype.jquery&&(o=o.get(0)),c(o)&&(o=We(o)),n=this._getOverlayContainer(r),Ue(t=We('<div class="djs-overlay" data-overlay-id="'+i+'">'),{position:"absolute"}),t.appendChild(o),e.type&&Xe(t).add("djs-overlay-"+e.type),_o(t,this._canvas.findRoot(r)===this._canvas.getRootElement()),e.htmlContainer=t,n.overlays.push(e),n.html.appendChild(t),this._overlays[i]=e,this._updateOverlay(e),this._updateOverlayVisibilty(e,this._canvas.viewbox())},bo.prototype._updateOverlayVisibilty=function(e,t){var n=e.show,r=this._canvas.findRoot(e.element),o=n&&n.minZoom,s=n&&n.maxZoom,a=e.htmlContainer,l=!0;(r!==this._canvas.getRootElement()||n&&(i(o)&&o>t.scale||i(s)&&s<t.scale))&&(l=!1),_o(a,l),this._updateOverlayScale(e,t)},bo.prototype._updateOverlayScale=function(e,t){var n,r,o,s=e.scale,a=e.htmlContainer,l="";!0!==s&&(!1===s?(n=1,r=1):(n=s.min,r=s.max),i(n)&&t.scale<n&&(o=(1/t.scale||1)*n),i(r)&&t.scale>r&&(o=(1/t.scale||1)*r)),i(o)&&(l="scale("+o+","+o+")"),ko(a,l)},bo.prototype._updateOverlaysVisibilty=function(e){var t=this;d(this._overlays,function(n){t._updateOverlayVisibilty(n,e)})},bo.prototype._init=function(){var e=this._eventBus,t=this;e.on("canvas.viewbox.changing",function(e){t.hide()}),e.on("canvas.viewbox.changed",function(e){var n;n=e.viewbox,t._updateRoot(n),t._updateOverlaysVisibilty(n),t.show()}),e.on(["shape.remove","connection.remove"],function(e){var n=e.element;d(t.get({element:n}),function(e){t.remove(e.id)});var i=t._getOverlayContainer(n);if(i){at(i.html);var r=t._overlayContainers.indexOf(i);-1!==r&&t._overlayContainers.splice(r,1)}}),e.on("element.changed",500,function(e){var n=e.element,i=t._getOverlayContainer(n,!0);i&&(d(i.overlays,function(e){t._updateOverlay(e)}),t._updateOverlayContainer(i))}),e.on("element.marker.update",function(e){var n=t._getOverlayContainer(e.element,!0);n&&Xe(n.html)[e.add?"add":"remove"](e.marker)}),e.on("root.set",function(){t._updateOverlaysVisibilty(t._canvas.viewbox())}),e.on("diagram.clear",this.clear,this)};var So={__init__:["overlays"],overlays:["type",bo]};function Co(e,t,n){this._eventBus=e,this._canvas=t,this._translate=n,e.on("diagram.init",function(){this._init()},this),e.on("import.done",function(e){e.error||this.update()},this),this.HTML_MARKUP='<div class="dmn-definitions"><div class="dmn-definitions-name" title="'+this._translate("Definition name")+'" spellcheck="false"></div><div class="dmn-definitions-id" title="'+this._translate("Definition ID")+'" spellcheck="false"></div></div>'}function Eo(e,t){function n(e,n){Xe(t.getContainer()).toggle(e,n)}e.on("palette.create",function(){n("with-palette",!0)}),e.on("palette.changed",function(e){n("with-palette-two-column",e.twoColumn)})}Co.$inject=["eventBus","canvas","translate"],Co.prototype._init=function(){var e=this._canvas,t=this._eventBus,n=e.getContainer(),i=this._container=We(this.HTML_MARKUP);n.appendChild(i),this.nameElement=st(".dmn-definitions-name",this._container),this.idElement=st(".dmn-definitions-id",this._container),ot.bind(i,".dmn-definitions-name, .dmn-definitions-id","mousedown",function(e){e.stopPropagation()}),t.fire("definitionIdView.create",{html:i})},Co.prototype.update=function(){var e=this._canvas.getRootElement().businessObject;this.nameElement.textContent=e.name,this.idElement.textContent=e.id},Eo.$inject=["eventBus","canvas"];var Mo={__depends__:[to],__init__:["definitionPropertiesView","definitionPropertiesPaletteAdapter"],definitionPropertiesView:["type",Co],definitionPropertiesPaletteAdapter:["type",Eo]},Ao=[{className:"dmn-icon-decision-table",matches:function(e){var t=jn(e);return In(t,"dmn:Decision")&&In(t.decisionLogic,"dmn:DecisionTable")},title:"Open decision table"},{className:"dmn-icon-literal-expression",matches:function(e){return In(Vn(e),"dmn:LiteralExpression")},title:"Open literal expression"}];class To{constructor(e,t,n,i,r){this._injector=e,this._eventBus=t,this._overlays=n,this._translate=r,this._config=i||{enabled:!0},t.on(["shape.added"],({element:e})=>{for(let t=0;t<Ao.length;t++){const{matches:n,className:i,title:r}=Ao[t];n&&n(e)&&this.addOverlay(e,i,r)}})}addOverlay(e,t,n){const i=!1!==this._config.enabled,r=this._getOverlayNode(t,n,i),o=this._overlays.add(e,{position:{top:2,left:2},html:r});i&&(Xe(r).add("interactive"),this.bindEventListener(e,r,o))}_getOverlayNode(e,t,n){const i=document.createElement("div");if(i.className="drill-down-overlay",!n){const t=document.createElement("span");return t.className=e,i.appendChild(t),i}const r=document.createElement("button");return r.type="button",r.className=e,r.title=this._translate(t),i.appendChild(r),i}bindEventListener(e,t,n){const i=this._overlays,r=this._eventBus,o=i._overlayRoot;ot.bind(o,'[data-overlay-id="'+n+'"]',"click",()=>{!1!==r.fire("drillDown.click",{element:e})&&this.drillDown(e)})}drillDown(e){const t=this._injector.get("_parent",!1);if(!t)return!1;const n=t.getView(e.businessObject);return!!n&&(t.open(n),!0)}}To.$inject=["injector","eventBus","overlays","config.drillDown","translate"];var Ro={__depends__:[So,to],__init__:["drillDown"],drillDown:["type",To]};
/**
* The code in the <project-logo></project-logo> area
* must not be changed.
*
* @see http://bpmn.io/license for more information.
*/const Oo="djs-outline-hidden";function Do(e){this._container=this._createContainer(),br(this._container),this._init(this._container,e)}function qo(e,t){return{x:e.x-t.x,y:e.y-t.y}}function No(e){return Math.log(e)/Math.log(10)}function Bo(e,t){var n=No(e.min),i=No(e.max);return(Math.abs(n)+Math.abs(i))/t}gt(Do,Ln),Do.prototype.saveSVG=lt(function(e){var t=this;return new Promise(function(e){var n,i=t.get("canvas"),r=i.getActiveLayer(),o=st("defs",i._svg),s=Ut(r),a=o&&o.outerHTML||"",l=i.getContainer();Xe(l).add(Oo);try{n=r.getBBox()}finally{Xe(l).remove(Oo)}var c=n.x-5,h=n.y-5,u=n.width+10,p=n.height+10;e({svg:'<?xml version="1.0" encoding="utf-8"?>\n\x3c!-- created with dmn-js / http://bpmn.io --\x3e\n<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="'+u+'" height="'+p+'" viewBox="'+c+" "+h+" "+u+" "+p+'" version="1.1">'+a+s+"</svg>"})})}),Do.prototype.getModules=function(){return this._modules},Do.prototype.destroy=function(){Ln.prototype.destroy.call(this),at(this._container)},Do.prototype.on=function(e,t,n,i){return this.get("eventBus").on(e,t,n,i)},Do.prototype.off=function(e,t){this.get("eventBus").off(e,t)},Do.prototype._init=function(e,t){var{additionalModules:n,canvas:i,...r}=t,o={...r,canvas:{...i,container:e},modules:[...[{viewer:["value",this]}],...t.modules||this.getModules(),...n||[]]};Ln.call(this,o),t&&t.container&&this.attachTo(t.container)},Do.prototype._emit=function(e,t){return this.get("eventBus").fire(e,t)},Do.prototype._createContainer=function(){return We('<div class="dmn-drd-container bio-theme-parent"></div>')},Do.prototype.open=function(e){var t=this;return new Promise((n,i)=>{var r;try{return t._definitions&&t.clear(),t._definitions=e,function(e,t,n){var i,r=e.get("drdImporter"),o=e.get("eventBus"),s=[];o.fire("import.start",{definitions:t});try{!function(e){new Wn({root:function(e){return r.root(e)},element:function(e,t){return r.add(e,t)},error:function(e,t){s.push({message:e,context:t})}}).handleDefinitions(e)}(t)}catch(e){i=e}o.fire("import.done",{error:i,warnings:s}),n(i,s)}(t,e,function(e,t){e?(e.warnings=t||[],i(e)):n({warnings:t||[]})})}catch(e){r=e}r?(r.warnings=r.warnings||[],i(r)):n({warnings:[]})})},Do.prototype.getDefinitions=function(){return this._definitions},Do.prototype.attachTo=function(e){if(!e)throw new Error("parentNode required");this.detach();var t=this._container;e.appendChild(t),this._emit("attach",{}),this.get("canvas").resized()},Do.prototype.detach=function(){var e=this._container,t=e.parentNode;t&&(this._emit("detach",{}),t.removeChild(e))},Do.prototype._modules=[eo,to,yo,So,Mo,Ro];var Po=Math.sign||function(e){return e>=0?1:-1},Lo={min:.2,max:4};function Io(e,t,n){e=e||{},this._enabled=!1,this._canvas=n,this._container=n._container,this._handleWheel=k(this._handleWheel,this),this._totalDelta=0,this._scale=e.scale||.75;var i=this;t.on("canvas.mouseover",function(){i._init(!1!==e.enabled)}),t.on("canvas.mouseout",function(){i._init(!1)})}Io.$inject=["config.zoomScroll","eventBus","canvas"],Io.prototype.scroll=function(e){this._canvas.scroll(e)},Io.prototype.reset=function(){this._canvas.zoom("fit-viewport")},Io.prototype.zoom=function(e,t){var n=Bo(Lo,20);this._totalDelta+=e,Math.abs(this._totalDelta)>.1&&(this._zoom(e,t,n),this._totalDelta=0)},Io.prototype._handleWheel=function(e){if(this._enabled){var t=this._container;e.preventDefault();var n,i=e.ctrlKey||/mac/i.test(navigator.platform)&&e.metaKey,r=e.shiftKey,o=-1*this._scale;if(o*=i?0===e.deltaMode?.02:.32:0===e.deltaMode?1:16,i){var s=t.getBoundingClientRect(),a={x:e.clientX-s.left,y:e.clientY-s.top};n=Math.sqrt(Math.pow(e.deltaY,2)+Math.pow(e.deltaX,2))*Po(e.deltaY)*o,this.zoom(n,a)}else n=r?{dx:o*e.deltaY,dy:0}:{dx:o*e.deltaX,dy:o*e.deltaY},this.scroll(n)}},Io.prototype.stepZoom=function(e,t){var n=Bo(Lo,10);this._zoom(e,t,n)},Io.prototype._zoom=function(e,t,n){var i=this._canvas,r=e>0?1:-1,o=No(i.zoom()),s=Math.round(o/n)*n;s+=n*r;var a,l,c=Math.pow(10,s);i.zoom((a=Lo,l=c,Math.max(a.min,Math.min(a.max,l))),t)},Io.prototype.toggle=function(e){var t=this._container,n=this._handleWheel,i=this._enabled;return void 0===e&&(e=!i),i!==e&&it[e?"bind":"unbind"](t,"wheel",n,!1),this._enabled=e,e},Io.prototype._init=function(e){this.toggle(e)};var jo={__init__:["zoomScroll"],zoomScroll:["type",Io]},Fo=/^djs-cursor-.*$/;function Vo(e){var t=Xe(document.body);t.removeMatching(Fo),e&&t.add("djs-cursor-"+e)}function $o(e,t){var n;function i(e){return s(e.originalEvent)}function r(i){var r,o=n.start,s=n.button,a=io(i),l=qo(a,o);(!n.dragging&&(r=l,Math.sqrt(Math.pow(r.x,2)+Math.pow(r.y,2))>15)&&(n.dragging=!0,0===s&&function(e,t){function n(){return!1}t=t||"element.click",e.once(t,5e3,n)}(e),Vo("grab")),n.dragging)&&(l=qo(a,n.last||n.start),t.scroll({dx:l.x,dy:l.y}),n.last=a);i.preventDefault()}function o(e){it.unbind(document,"mousemove",r),it.unbind(document,"mouseup",o),n=null,Vo(null)}function s(e){if(!Qe(e.target,".djs-draggable")){var t=e.button;if(!(t>=2||e.ctrlKey||e.shiftKey||e.altKey))return n={button:t,start:io(e)},it.bind(document,"mousemove",r),it.bind(document,"mouseup",o),!0}}e.on("canvas.focus.changed",function(t){t.focused?e.on("element.mousedown",500,i):e.off("element.mousedown",i)}),e.on("diagram.destroy",function(){n&&o()}),this.isActive=function(){return!!n}}$o.$inject=["eventBus","canvas"];var zo={__init__:["moveCanvas"],moveCanvas:["type",$o]},Wo={"&":"&","<":"<",">":">",'"':""","'":"'"};function Ho(e,t){return-1!==(e=o(e)?e:[e]).indexOf(t.key)||-1!==e.indexOf(t.code)||-1!==e.indexOf(function(e){var t=e.key,n=/^Key([A-Z])$/.exec(e.code||"");if(!n||"string"!=typeof t)return null;var i=n[1];if(Uo.test(t))return e.shiftKey?i:i.toLowerCase();if(e.shiftKey&&Go.test(t)&&e.keyCode===i.charCodeAt(0))return i;return null}(t))}var Uo=/^(?!\p{Script_Extensions=Latin}|\p{Script=Common})\p{Letter}$/u,Go=/^\P{Letter}$/u;function Ko(e,t,n,i){this._open=!1,this._results={},this._eventMaps=[],this._cachedRootElement=null,this._cachedSelection=null,this._cachedViewbox=null,this._canvas=e,this._eventBus=t,this._selection=n,this._translate=i,this._container=this._getBoxHtml(),this._searchInput=st(Ko.INPUT_SELECTOR,this._container),this._resultsContainer=st(Ko.RESULTS_CONTAINER_SELECTOR,this._container),this._canvas.getContainer().appendChild(this._container),t.on(["canvas.destroy","diagram.destroy","drag.init","elements.changed"],this.close,this)}function Xo(e,t,n){var i=function(e){var t="";return e.forEach(function(e){var n,i=(n=""+(n=e.value||e.matched||e.normal))&&n.replace(/[&<>"']/g,function(e){return Wo[e]}),r=e.match||e.matched;t+=r?'<b class="'+Ko.RESULT_HIGHLIGHT_CLASS+'">'+i+"</b>":i}),""!==t?t:null}(t),r=We(n);r.innerHTML=i,e.appendChild(r)}Ko.$inject=["canvas","eventBus","selection","translate"],Ko.prototype._bindEvents=function(){var e=this;function t(t,n,i,r){e._eventMaps.push({el:t,type:i,listener:ot.bind(t,n,i,r)})}t(document,"html","click",function(t){e.close(!1)}),t(this._container,Ko.INPUT_SELECTOR,"click",function(e){e.stopPropagation(),e.delegateTarget.focus()}),t(this._container,Ko.RESULT_SELECTOR,"mouseover",function(t){t.stopPropagation(),e._scrollToNode(t.delegateTarget),e._preselect(t.delegateTarget)}),t(this._container,Ko.RESULT_SELECTOR,"click",function(t){t.stopPropagation(),e._select(t.delegateTarget)}),t(this._container,Ko.INPUT_SELECTOR,"keydown",function(e){Ho("ArrowUp",e)&&e.preventDefault(),Ho("ArrowDown",e)&&e.preventDefault()}),t(this._container,Ko.INPUT_SELECTOR,"keyup",function(t){if(Ho("Escape",t))return e.close();if(Ho("Enter",t)){var n=e._getCurrentResult();return n?e._select(n):e.close(!1)}return Ho("ArrowUp",t)?e._scrollToDirection(!0):Ho("ArrowDown",t)?e._scrollToDirection():void(Ho(["ArrowLeft","ArrowRight"],t)||e._search(t.delegateTarget.value))})},Ko.prototype._unbindEvents=function(){this._eventMaps.forEach(function(e){ot.unbind(e.el,e.type,e.listener)})},Ko.prototype._search=function(e){var t=this;if(this._clearResults(),e.trim()){var n=this._searchProvider.find(e);if((n=n.filter(function(e){return!t._canvas.getRootElements().includes(e.element)})).length){n.forEach(function(e){var n=e.element.id,i=t._createResultNode(e,n);t._results[n]={element:e.element,node:i}});var i=st(Ko.RESULT_SELECTOR,this._resultsContainer);this._scrollToNode(i),this._preselect(i)}else this._selection.select(null)}},Ko.prototype._scrollToDirection=function(e){var t=this._getCurrentResult();if(t){var n=e?t.previousElementSibling:t.nextElementSibling;n&&(this._scrollToNode(n),this._preselect(n))}},Ko.prototype._scrollToNode=function(e){if(e&&e!==this._getCurrentResult()){var t=e.offsetTop,n=this._resultsContainer.scrollTop,i=t-this._resultsContainer.clientHeight+e.clientHeight;t<n?this._resultsContainer.scrollTop=t:n<i&&(this._resultsContainer.scrollTop=i)}},Ko.prototype._clearResults=function(){Je(this._resultsContainer),this._results={},this._eventBus.fire("searchPad.cleared")},Ko.prototype._getCurrentResult=function(){return st(Ko.RESULT_SELECTED_SELECTOR,this._resultsContainer)},Ko.prototype._createResultNode=function(e,t){var n=We(Ko.RESULT_HTML);return e.primaryTokens.length>0&&Xo(n,e.primaryTokens,Ko.RESULT_PRIMARY_HTML),Xo(n,e.secondaryTokens,Ko.RESULT_SECONDARY_HTML),Ge(n,Ko.RESULT_ID_ATTRIBUTE,t),this._resultsContainer.appendChild(n),n},Ko.prototype.registerProvider=function(e){this._searchProvider=e},Ko.prototype.open=function(){if(!this._searchProvider)throw new Error("no search provider registered");this.isOpen()||(this._cachedRootElement=this._canvas.getRootElement(),this._cachedSelection=this._selection.get(),this._cachedViewbox=this._canvas.viewbox(),this._selection.select(null),this._bindEvents(),this._open=!0,Xe(this._canvas.getContainer()).add("djs-search-open"),Xe(this._container).add("open"),this._searchInput.focus(),this._eventBus.fire("searchPad.opened"))},Ko.prototype.close=function(e=!0){this.isOpen()&&(e&&(this._cachedRootElement&&this._canvas.setRootElement(this._cachedRootElement),this._cachedSelection&&this._selection.select(this._cachedSelection),this._cachedViewbox&&this._canvas.viewbox(this._cachedViewbox),this._eventBus.fire("searchPad.restored")),this._cachedRootElement=null,this._cachedSelection=null,this._cachedViewbox=null,this._unbindEvents(),this._open=!1,Xe(this._canvas.getContainer()).remove("djs-search-open"),Xe(this._container).remove("open"),this._clearResults(),this._searchInput.value="",this._searchInput.blur(),this._eventBus.fire("searchPad.closed"),this._canvas.restoreFocus())},Ko.prototype.toggle=function(){this.isOpen()?this.close():this.open()},Ko.prototype.isOpen=function(){return this._open},Ko.prototype._preselect=function(e){var t=this._getCurrentResult();if(e!==t){t&&Xe(t).remove(Ko.RESULT_SELECTED_CLASS);var n=Ge(e,Ko.RESULT_ID_ATTRIBUTE),i=this._results[n].element;Xe(e).add(Ko.RESULT_SELECTED_CLASS),this._canvas.scrollToElement(i,{top:300}),this._selection.select(i),this._eventBus.fire("searchPad.preselected",i)}},Ko.prototype._select=function(e){var t=Ge(e,Ko.RESULT_ID_ATTRIBUTE),n=this._results[t].element;this._cachedSelection=null,this._cachedViewbox=null,this.close(!1),this._canvas.scrollToElement(n,{top:300}),this._selection.select(n),this._eventBus.fire("searchPad.selected",n)},Ko.prototype._getBoxHtml=function(){const e=We(Ko.BOX_HTML),t=st(Ko.INPUT_SELECTOR,e);return t&&t.setAttribute("aria-label",this._translate("Search in diagram")),e},Ko.CONTAINER_SELECTOR=".djs-search-container",Ko.INPUT_SELECTOR=".djs-search-input input",Ko.RESULTS_CONTAINER_SELECTOR=".djs-search-results",Ko.RESULT_SELECTOR=".djs-search-result",Ko.RESULT_SELECTED_CLASS="djs-search-result-selected",Ko.RESULT_SELECTED_SELECTOR="."+Ko.RESULT_SELECTED_CLASS,Ko.RESULT_ID_ATTRIBUTE="data-result-id",Ko.RESULT_HIGHLIGHT_CLASS="djs-search-highlight",Ko.BOX_HTML='<div class="djs-search-container djs-scrollable">\n <div class="djs-search-input">\n <svg class="djs-search-icon" width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path fill-rule="evenodd" clip-rule="evenodd" d="M9.0325 8.5H9.625L13.3675 12.25L12.25 13.3675L8.5 9.625V9.0325L8.2975 8.8225C7.4425 9.5575 6.3325 10 5.125 10C2.4325 10 0.25 7.8175 0.25 5.125C0.25 2.4325 2.4325 0.25 5.125 0.25C7.8175 0.25 10 2.4325 10 5.125C10 6.3325 9.5575 7.4425 8.8225 8.2975L9.0325 8.5ZM1.75 5.125C1.75 6.9925 3.2575 8.5 5.125 8.5C6.9925 8.5 8.5 6.9925 8.5 5.125C8.5 3.2575 6.9925 1.75 5.125 1.75C3.2575 1.75 1.75 3.2575 1.75 5.125Z" fill="#22242A"/>\n </svg>\n <input type="text" spellcheck="false" />\n </div>\n <div class="djs-search-results" />\n</div>',Ko.RESULT_HTML='<div class="djs-search-result"></div>',Ko.RESULT_PRIMARY_HTML='<div class="djs-search-result-primary"></div>',Ko.RESULT_SECONDARY_HTML='<p class="djs-search-result-secondary"></p>';var Yo={__depends__:[to,So,yo],searchPad:["type",Ko]};function Jo(e){var t=e.businessObject,n=function(e){return In(e,"dmn:Decision")||In(e,"dmn:BusinessKnowledgeModel")||In(e,"dmn:InputData")||In(e,"dmn:KnowledgeSource")||In(e,"dmn:DecisionService")?"name":In(e,"dmn:TextAnnotation")?"text":void 0}(t);if(n)return t[n]||""}function Qo(e,t,n){this._elementRegistry=e,this._canvas=n,t.registerProvider(this)}function Zo(e){return p(e,function(e){return!!e.matched}).length>0}function es(e,t){const n=[],i=e;if(!e)return n;e=e.toLowerCase(),t=t.toLowerCase();const r=e.indexOf(t);return r>-1?(0!==r&&n.push({normal:i.substr(0,r)}),n.push({matched:i.substr(r,t.length)}),t.length+r<e.length&&n.push({normal:i.substr(t.length+r,e.length)})):n.push({normal:i}),n}Qo.$inject=["elementRegistry","searchPad","canvas"],Qo.prototype.find=function(e){const t=this._canvas.getRootElement();let n=this._elementRegistry.filter(function(e){return!e.labelTarget});return n=p(n,function(e){return e!==t}),n=m(n,function(t){return{primaryTokens:es(Jo(t),e),secondaryTokens:es(t.id,e),element:t}}),n=p(n,function(e){return Zo(e.primaryTokens)||Zo(e.secondaryTokens)}),n=y(n,function(e){return Jo(e.element)+e.element.id}),n};var ts={__depends__:[Yo],__init__:["dmnSearch"],dmnSearch:["type",Qo]};function ns(e){Do.call(this,e)}gt(ns,Do),ns.prototype._navigationModules=[jo,zo,ts],ns.prototype._modules=[].concat(ns.prototype._modules,ns.prototype._navigationModules);const is=/^class[ {]/;function rs(e){return Array.isArray(e)}function os(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function ss(...e){1===e.length&&rs(e[0])&&(e=e[0]);const t=(e=[...e]).pop();return t.$inject=e,t}const as=/constructor\s*[^(]*\(\s*([^)]*)\)/m,ls=/^(?:async\s+)?(?:function\s*[^(]*)?(?:\(\s*([^)]*)\)|(\w+))/m,cs=/\/\*([^*]*)\*\//m;function hs(e){if("function"!=typeof e)throw new Error(`Cannot annotate "${e}". Expected a function!`);const t=e.toString().match(function(e){return is.test(e.toString())}(e)?as:ls);if(!t)return[];const n=t[1]||t[2];return n&&n.split(",").map(e=>{const t=e.match(cs);return(t&&t[1]||e).trim()})||[]}function us(e,t){const n=t||{get:function(e,t){if(!1===t)return null;throw i.push(e),a(`No provider for "${e}"!`)}},i=[],r=this._providers=Object.create(n._providers||null),o=this._instances=Object.create(null),s=o.injector=this,a=function(e){const t=i.join(" -> ");return i.length=0,new Error(t?`${e} (Resolving: ${t})`:e)};function l(e,t){if(!r[e]&&e.includes(".")){const t=e.split(".");let n=l(t.shift());for(;t.length;)n=n[t.shift()];return n}if(os(o,e))return o[e];if(os(r,e)){if(-1!==i.indexOf(e))throw i.push(e),a("Cannot resolve circular dependency!");return i.push(e),o[e]=r[e][0](r[e][1]),i.pop(),o[e]}return n.get(e,t)}function c(e,t){if(void 0===t&&(t={}),"function"!=typeof e){if(!rs(e))throw a(`Cannot invoke "${e}". Expected a function!`);e=ss(e.slice())}return{fn:e,dependencies:(e.$inject||hs(e)).map(e=>os(t,e)?t[e]:l(e))}}function h(e){const{fn:t,dependencies:n}=c(e);return new(Function.prototype.bind.call(t,null,...n))}function u(e,t,n){const{fn:i,dependencies:r}=c(e,n);return i.apply(t,r)}function p(e){return ss(t=>e.get(t))}function d(e,t){if(t&&t.length){const n=Object.create(null),i=Object.create(null),o=[],s=[],a=[];let l,c,h,u;for(let e in r)l=r[e],-1!==t.indexOf(e)&&("private"===l[2]?(c=o.indexOf(l[3]),-1===c?(h=l[3].createChild([],t),u=p(h),o.push(l[3]),s.push(h),a.push(u),n[e]=[u,e,"private",h]):n[e]=[a[c],e,"private",s[c]]):n[e]=[l[2],l[1]],i[e]=!0),"factory"!==l[2]&&"type"!==l[2]||!l[1].$scope||t.forEach(t=>{-1!==l[1].$scope.indexOf(t)&&(n[e]=[l[2],l[1]],i[t]=!0)});t.forEach(e=>{if(!i[e])throw new Error('No provider for "'+e+'". Cannot use provider from the parent!')}),e.unshift(n)}return new us(e,s)}const f={factory:u,type:h,value:function(e){return e}};function g(e,t){const n=e.__init__||[];return function(){n.forEach(e=>{"string"==typeof e?t.get(e):t.invoke(e)})}}function m(e){const t=e.__exports__;if(t){const n=e.__modules__,i=Object.keys(e).reduce((t,n)=>("__exports__"!==n&&"__modules__"!==n&&"__init__"!==n&&"__depends__"!==n&&(t[n]=e[n]),t),Object.create(null)),o=d((n||[]).concat(i)),s=ss(function(e){return o.get(e)});t.forEach(function(e){r[e]=[s,e,"private",o]});const a=(e.__init__||[]).slice();return a.unshift(function(){o.init()}),g(e=Object.assign({},e,{__init__:a}),o)}return Object.keys(e).forEach(function(t){if("__init__"===t||"__depends__"===t)return;const n=e[t];if("private"===n[2])return void(r[t]=n);const i=n[0],o=n[1];r[t]=[f[i],ps(i,o),i]}),g(e,s)}function y(e,t){return-1!==e.indexOf(t)||-1!==(e=(t.__depends__||[]).reduce(y,e)).indexOf(t)?e:e.concat(t)}this.get=l,this.invoke=u,this.instantiate=h,this.createChild=d,this.init=function(e){const t=e.reduce(y,[]).map(m);let n=!1;return function(){n||(n=!0,t.forEach(e=>e()))}}(e)}function ps(e,t){return"value"!==e&&rs(t)&&(t=ss(t.slice())),t}class ds{constructor(e){S(this,e),gs(this,"businessObject",{writable:!0})}}const fs={root:class extends ds{constructor(e){super(e),gs(this,"rows",{enumerable:!0,value:this.rows||[]}),gs(this,"cols",{enumerable:!0,value:this.cols||[]})}},row:class extends ds{constructor(e){super(e),gs(this,"root",{writable:!0}),gs(this,"cells",{enumerable:!0,value:this.cells||[]})}},col:class extends ds{constructor(e){super(e),gs(this,"root",{writable:!0}),gs(this,"cells",{enumerable:!0,value:this.cells||[]})}},cell:class extends ds{constructor(e){super(e),gs(this,"row",{writable:!0}),gs(this,"col",{writable:!0})}}};function gs(e,t,n){Object.defineProperty(e,t,n)}let ms=class{constructor(e){this._eventBus=e,this._elements={},e.on("table.clear",this.clear.bind(this))}add(e,t){const{id:n}=e;this._elements[n]=e}remove(e){const t=e.id||e;delete this._elements[t]}get(e){return this._elements[e]}getAll(){return ys(this._elements)}forEach(e){ys(this._elements).forEach(t=>e(t))}filter(e){return ys(this._elements).filter(t=>e(t))}clear(){this._elements={}}updateId(e,t){this._validateId(t),"string"==typeof e&&(e=this.get(e)),this._eventBus.fire("element.updateId",{element:e,newId:t}),this.remove(e),e.id=t,this.add(e)}_validateId(e){if(!e)throw new Error("element must have an id");if(this._elements[e])throw new Error("element with id "+e+" already added")}};function ys(e){return Object.keys(e).map(function(t){return e[t]})}ms.$inject=["eventBus"];let vs=class{constructor(e){this._listeners={},e.on("elements.changed",({elements:e})=>{this.elementsChanged(e)}),e.on("root.remove",t=>{const n=t.root.id;this._listeners[n]&&e.once("root.add",e=>{const t=e.root.id;this.updateId(n,t)})}),e.on("element.updateId",({element:e,newId:t})=>{this.updateId(e.id,t)})}elementsChanged(e){const t={},n=e.length;for(let i=0;i<n;i++){const{id:n}=e[i];if(t[n])return;t[n]=!0;const r=this._listeners[n]&&this._listeners[n].length;if(r)for(let e=0;e<r;e++)this._listeners[n][e]&&this._listeners[n][e]()}}onElementsChanged(e,t){this._listeners[e]||(this._listeners[e]=[]),this._listeners[e][this._listeners[e].length]=t}offElementsChanged(e,t){if(this._listeners[e])if(t){const n=this._listeners[e].indexOf(t);-1!==n&&this._listeners[e].splice(n,1)}else this._listeners[e].length=0}updateId(e,t){this._listeners[e]&&(this._listeners[t]=this._listeners[e],delete this._listeners[e])}};vs.$inject=["eventBus"];class ws extends vr{constructor(e){super(e);const t=this._injector=e.injector;this._sheet=t.get("sheet"),this._changeSupport=t.get("changeSupport"),this._components=t.get("components"),this._eventBus=t.get("eventBus");const n=t.get("throttle");this.onElementsChanged=this.onElementsChanged.bind(this),this.onScroll=n(this.onScroll.bind(this))}onElementsChanged(){this.forceUpdate()}onScroll(){this._eventBus.fire("sheet.scroll")}getChildContext(){return{changeSupport:this._changeSupport,components:this._components,injector:this._injector}}componentWillMount(){const{id:e}=this._sheet.getRoot();this._changeSupport.onElementsChanged(e,this.onElementsChanged)}componentWillUnmount(){const{id:e}=this._sheet.getRoot();this._changeSupport.offElementsChanged(e,this.onElementsChanged)}render(){const{rows:e,cols:t}=this._sheet.getRoot(),n=this._components.getComponents("table.before"),i=this._components.getComponents("table.after"),r=this._components.getComponent("table.head"),o=this._components.getComponent("table.body"),s=this._components.getComponent("table.foot");return ri(1,"div","tjs-container",[n&&n.map((e,t)=>oi(2,e,null,t)),ri(1,"div","tjs-table-container",ri(1,"table","tjs-table",[r&&oi(2,r,{rows:e,cols:t}),o&&oi(2,o,{rows:e,cols:t}),s&&oi(2,s,{rows:e,cols:t})],0),2,{onScroll:this.onScroll}),i&&i.map((e,t)=>oi(2,e,null,t))],0)}}let bs=class{constructor(e,t,n,i,r){const{container:o}=n;this._container=o,i.on("root.added",()=>{dr(oi(2,ws,{injector:r}),o)}),i.on("root.remove",()=>{dr(null,o)})}getContainer(){return this._container}};bs.$inject=["changeSupport","components","config.renderer","eventBus","injector"];var xs={__init__:["changeSupport","components","renderer"],changeSupport:["type",vs],components:["type",class{constructor(){this._listeners={}}getComponent(e,t){const n=this._listeners[e];if(!n)return;let i;for(let e=0;e<n.length&&(i=n[e].callback(t),!i);e++);return i}getComponents(e,t){const n=this._listeners[e],i=[];if(!n)return i;for(let e=0;e<n.length;e++){const r=n[e].callback(t);r&&i.push(r)}return i.length,i}onGetComponent(e,t,n){if(l(t)&&(n=t,t=1e3),!a(t))throw new Error("priority must be a number");const i=this._getListeners(e);let r,o;const s={priority:t,callback:n};for(o=0;r=i[o];o++)if(r.priority<t)return void i.splice(o,0,s);i.push(s)}offGetComponent(e,t){const n=this._getListeners(e);let i,r,o;if(t)for(o=n.length-1;i=n[o];o--)r=i.callback,r===t&&n.splice(o,1);else n.length=0}_getListeners(e){let t=this._listeners[e];return t||(this._listeners[e]=t=[]),t}}],renderer:["type",bs]};class _s{constructor(e,t){this._elementRegistry=e,this._eventBus=t,this._root=null,t.on("table.clear",()=>{this.setRoot(null)})}setRoot(e){if(this._root){const e=this._root;this._eventBus.fire("root.remove",{root:e}),this._root=null,this._eventBus.fire("root.removed",{root:e})}e&&this._eventBus.fire("root.add",{root:e}),this._root=e,e&&this._eventBus.fire("root.added",{root:e})}getRoot(){return this._root||this.setRoot({id:"__implicitroot",rows:[],cols:[]}),this._root}addRow(e,t){const n=this.getRoot();if(n.cols.length!=e.cells.length)throw new Error("number of cells is not equal to number of cols");return void 0===t&&(t=n.rows.length),ks(t,n.rows,e),e.root=n,this._elementRegistry.add(e),e.cells.forEach((i,r)=>{this._elementRegistry.add(i),i.row=e,i.col=n.cols[r],ks(t,n.cols[r].cells,i)}),this._eventBus.fire("row.add",{row:e}),e}removeRow(e){const t=this.getRoot();"string"==typeof e&&(e=this._elementRegistry.get(e));const n=t.rows.indexOf(e);-1!==n&&(Ss(n,t.rows),e.root=void 0,this._elementRegistry.remove(e),e.cells.forEach((e,i)=>{this._elementRegistry.remove(e),e.col=void 0,Ss(n,t.cols[i].cells)}),this._eventBus.fire("row.remove",{row:e}))}addCol(e,t){const n=this.getRoot();if(this._elementRegistry.add(e),n.rows.length!=e.cells.length)throw new Error("number of cells is not equal to number of rows");return void 0===t&&(t=n.cols.length),ks(t,n.cols,e),e.root=n,e.cells.forEach((i,r)=>{this._elementRegistry.add(i),i.col=e,i.row=n.rows[r],ks(t,n.rows[r].cells,i)}),this._eventBus.fire("col.add",{col:e}),e}removeCol(e){const t=this.getRoot();"string"==typeof e&&(e=this._elementRegistry.get(e));const n=t.cols.indexOf(e);-1!==n&&(Ss(n,t.cols),e.root=void 0,this._elementRegistry.remove(e),e.cells.forEach((e,i)=>{this._elementRegistry.remove(e),e.row=void 0,Ss(n,t.rows[i].cells)}),this._eventBus.fire("col.remove",{col:e}))}resized(){this._eventBus.fire("sheet.resized")}}function ks(e,t,n){return t.splice(e,0,n)}function Ss(e,t){return t.splice(e,1)}function Cs(e=!0){const t="number"==typeof e?e:e?300:0;return t?e=>function(e,t){let n=!1;return function(...i){n||(e(...i),n=!0,setTimeout(()=>{n=!1},t))}}(e,t):e=>e}_s.$inject=["elementRegistry","eventBus"],Cs.$inject=["config.throttle"];var Es={__depends__:[xs],__init__:["elementFactory","sheet"],elementFactory:["type",class{constructor(){this._uid=12}create(e,t={}){return t.id||(t.id=e+"_"+this._uid++),function(e,t){const n=fs[e];if(!n)throw new Error("unknown type "+e);return new n(t)}(e,t)}createRoot(e){return this.create("root",e)}createRow(e){return this.create("row",e)}createCol(e){return this.create("col",e)}createCell(e){return this.create("cell",e)}}],elementRegistry:["type",ms],eventBus:["type",M],sheet:["type",_s],throttle:["factory",Cs]};class Ms{constructor(e={}){let{injector:t}=e;if(!t){let{modules:n,config:i}=this._init(e);t=function(e,t){const n=[{config:["value",e]},Es].concat(t||[]),i=new us(n);return i.init(),i}(i,n)}this.get=t.get,this.invoke=t.invoke,this.get("eventBus").fire("table.init"),this.get("eventBus").fire("diagram.init")}_init(e){let{modules:t,...n}=e;return{modules:t,config:n}}destroy(){const e=this.get("eventBus");e.fire("table.destroy"),e.fire("diagram.destroy")}clear(){const e=this.get("eventBus");e.fire("table.clear"),e.fire("diagram.clear")}}function As(e){if(!e)return"<null>";const t=e.id?` id="${e.id}"`:"";return`<${e.$type}${t} />`}function Ts(e,t){function n(t,n,i){if(t.gfx)throw new Error(`already rendered ${As(t)}`);return e.element(t,n,i)}function i(e,t,i){d(e,function(e){n(e,t,i)})}function r(e,t,i){d(e,function(e){n(e,t,i)})}return{handleDecision:function(t){t.id||(t.id="decision");const o=t.decisionLogic;if(!o)throw new Error(`no table for ${As(t)}`);{if(!o.output)throw new Error(`missing output for ${As(o)}`);const t=(c=o,e.table(c));o.input&&i(o.input,t,o),i(o.output,t,o),s=o.rule,a=t,l=o,d(s,function(e){n(e,a,l),r(e.inputEntry,e),r(e.outputEntry,e)})}var s,a,l,c}}}function Rs(e,t){const{elements:n,index:i}=e;return i[t]?e:{elements:[...n,t],index:{...i,[t]:!0}}}function Os(...e){let t={elements:[],index:{}};return e.forEach(function(e){const n=typeof e;"string"===n&&e.length>0?t=Rs(t,e):"object"===n&&null!==e&&Object.keys(e).forEach(function(n){e[n]&&(t=Rs(t,n))})}),function(e,t){return e.elements.join(t)}(t," ")}function Ds(e){return qs(e.constructor,e)}function qs(e,t){const n=e.$inject;if(!n)return;const{injector:i}=t.context,r=[...n,function(...e){for(const i in e){const r=n[i],o=e[i];t[r]=o}}];i.invoke(r)}function Ns(e,t){Object.keys(t).forEach(function(n){if("$inject"===n||"__init"===n)return;const i=t[n];"constructor"===n&&i.call(e,e.props,e.context);const r=e[n];if(void 0!==r){if("function"!=typeof r)throw new Error(`failed to mixin <${n}>: cannot combine with non-fn component value`);e[n]=function(e,...t){return function(...n){let i;return t.forEach(function(t){if(i=t.call(e,...n),void 0!==i)return!1}),i}.bind(e)}(e,r,i)}else e[n]=i.bind(e)}),"$inject"in t&&qs(t,e),"__init"in t&&t.__init.call(e,e.props,e.context)}const Bs={getSelectionClasses(){const{selected:e,selectedSecondary:t,focussed:n}=this.state;return Os({selected:e,"selected-secondary":t,focussed:n})},selectionChanged(e){this.setState(e)},componentWillUpdate(e){e.elementId!==this.props.elementId&&this.updateSelectionSubscription(!1)},componentDidUpdate(e){e.elementId!==this.props.elementId&&this.updateSelectionSubscription(!0)},componentDidMount(){this.updateSelectionSubscription(!0)},componentWillUnmount(){this.updateSelectionSubscription(!1)},updateSelectionSubscription(e){const{elementId:t}=this.props;t&&t&&this.eventBus[e?"on":"off"](`selection.${t}.changed`,this.selectionChanged)},$inject:["eventBus"]};class Ps extends vr{constructor(e,t){super(e,t),Ns(this,Bs),Ds(this)}getRenderProps(...e){const{className:t,elementId:n,coords:i,...r}=this.props,o={className:Os(...e,this.getSelectionClasses(),t)};return n&&(o["data-element-id"]=n),i&&(o["data-coords"]=i),{...o,...r}}}class Ls extends Ps{constructor(e,t){super(e,t),this.state={}}render(){const{children:e}=this.props;return ai(ri(1,"td",null,e,0,{...this.getRenderProps("cell")}))}}const Is={slotFill(e,t){const{type:n,context:i,...r}=e,o=this.components.getComponent(n,i)||t;return o?ai(oi(2,o,{...i,...r})):null},slotFills(e){const{type:t,context:n,...i}=e;return this.components.getComponents(t,n).map(e=>ai(oi(2,e,{...n,...i})))},$inject:["components"]};class js extends vr{constructor(e,t){super(e,t),Ns(this,Is),Ds(this)}componentDidMount(){this.changeSupport.onElementsChanged(this.getRoot(),this.onElementsChanged)}componentWillUnmount(){this.changeSupport.offElementsChanged(this.getRoot(),this.onElementsChanged)}onElementsChanged=()=>{this.forceUpdate()};getRoot(){return this.sheet.getRoot()}render(){const e=(this.getRoot().businessObject.get("annotationsWidth")||400)+"px";return ri(1,"th","annotation header",[this.slotFills({type:"cell-inner",context:{cellType:"annotations",col:this.sheet.getRoot(),minWidth:400}}),this.translate("Annotations")],0,{style:{width:e}})}}function Fs(e){const{row:t}=e,{id:n,description:i}=t.businessObject;return oi(2,Ls,{className:"annotation",elementId:n,children:i||"-"})}function Vs(e){e.onGetComponent("cell",({cellType:e})=>"after-label-cells"===e?js:"after-rule-cells"===e?Fs:void 0)}js.$inject=["changeSupport","sheet","translate"],Vs.$inject=["components"];var $s={__init__:["annotationsProvider"],annotationsProvider:["type",Vs]};function zs(e,t){return S({id:e.id,type:e.$type,businessObject:e},t)}class Ws{constructor(e,t,n){this._elementFactory=e,this._eventBus=t,this._sheet=n}add(e){let t;if(In(e,"dmn:DecisionTable"))t=this._elementFactory.createRoot(zs(e)),this._sheet.setRoot(t);else if(In(e,"dmn:InputClause"))t=this._elementFactory.createCol(zs(e)),this._sheet.addCol(t);else if(In(e,"dmn:OutputClause"))t=this._elementFactory.createCol(zs(e)),this._sheet.addCol(t);else if(In(e,"dmn:DecisionRule")){e.inputEntry||(e.inputEntry=[]),e.outputEntry||(e.outputEntry=[]);const n=[...e.inputEntry,...e.outputEntry].map(e=>this._elementFactory.createCell(zs(e)));t=this._elementFactory.createRow(S(zs(e),{cells:n})),this._sheet.addRow(t)}return this._eventBus.fire("dmnElement.added",{element:t}),t}}Ws.$inject=["elementFactory","eventBus","sheet"];var Hs={__depends__:[{__depends__:[to],tableImporter:["type",Ws]},xs]};class Us extends vr{constructor(e,t){super(e,t),Ns(this,Is),this._sheet=t.injector.get("sheet"),this._changeSupport=t.changeSupport}onElementsChanged=()=>{this.forceUpdate()};componentWillMount(){const e=this._sheet.getRoot();this._changeSupport.onElementsChanged(e.id,this.onElementsChanged)}componentWillUnmount(){const e=this._sheet.getRoot();this._changeSupport.offElementsChanged(e.id,this.onElementsChanged)}render(){const e=this._sheet.getRoot();if(!In(e,"dmn:DMNElement"))return null;const t=jn(e),n=t.input,i=t.output;return ri(1,"thead",null,ri(1,"tr",null,[ri(1,"th","index-column"),this.slotFills({type:"cell",context:{cellType:"before-label-cells"}}),n&&n.map((e,t)=>{const i=e.width||"192px";return this.slotFill({type:"cell",context:{cellType:"input-header",input:e,index:t,inputsLength:n.length,width:i},key:e.id},Gs)}),i.map((e,t)=>this.slotFill({type:"cell",context:{cellType:"output-header",output:e,index:t,outputsLength:i.length},key:e.id},Ks)),this.slotFills({type:"cell",context:{cellType:"after-label-cells"}})],0),2)}}function Gs(e,t){const{input:n,className:i,index:r}=e,{label:o,inputExpression:s,inputValues:a}=n,l=t.injector.get("translate");return ri(1,"th",(i||"")+" input-cell",[ri(1,"div","clause",l(0===r?"When":"And"),0),o?ri(1,"div","input-label",o,0,{title:l("Input label: ")+o}):ri(1,"div","input-expression",s.text,0,{title:l("Input expression: ")+s.text}),ri(1,"div","input-variable",a&&a.text||s.typeRef,0,{title:a&&a.text?l("Input values"):l("Input type")})],0,{"data-col-id":n.id},n.id)}function Ks(e,t){const{output:n,className:i,index:r}=e,{label:o,name:s,outputValues:a,typeRef:l}=n,c=t.injector.get("translate");return ri(1,"th",(i||"")+" output-cell",[ri(1,"div","clause",c(0===r?"Then":"And"),0),o?ri(1,"div","output-label",o,0,{title:c("Output label")}):ri(1,"div","output-name",s,0,{title:c("Output name")}),ri(1,"div","output-variable",a&&a.text||l,0,{title:a&&a.text?c("Output values"):c("Output type")})],0,null,n.id)}function Xs(e){e.onGetComponent("table.head",()=>Us)}Xs.$inject=["components"];var Ys={__init__:["decisionTableHeadProvider"],decisionTableHeadProvider:["type",Xs]};class Js extends vr{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),Ds(this)}render(){const e=this.sheet.getRoot();if(!In(e,"dmn:DMNElement"))return null;const{name:t}=e.businessObject.$parent,n=this.components.getComponent("hit-policy")||Qs;return ri(1,"div","decision-table-properties",[ri(1,"div","decision-table-name",t,0,{title:this._translate("Decision name: ")+t}),ri(1,"div","decision-table-header-separator"),oi(2,n)],4)}}function Qs(){return null}Js.$inject=["sheet","components"];class Zs{constructor(e){e.onGetComponent("table.before",500,()=>Js)}}Zs.$inject=["components"];var ea={__init__:["decisionTableProperties"],decisionTableProperties:["type",Zs]};class ta extends vr{render(){const{row:e,rowIndex:t}=this.props,{components:n}=this.context,i=n.getComponents("cell-inner",{cellType:"rule-index",row:e,rowIndex:t});return ri(1,"td","rule-index",[i&&i.map(n=>oi(2,n,{row:e,rowIndex:t})),t+1],0,{"data-element-id":e.id,"data-row-id":e.id})}}class na{constructor(e){e.onGetComponent("cell",({cellType:e})=>{if("before-rule-cells"===e)return ta})}}na.$inject=["components"];var ia={__init__:["decisionRuleIndices"],decisionRuleIndices:["type",na]};const ra=[{label:"FEEL",value:"feel"}];class oa{constructor(e){this._injector=e;const t=e.get("config.expressionLanguages")||{};this._config={options:ra,defaults:{editor:"feel"}},t.options&&(this._config.options=t.options);const n=this._getLegacyDefaults();S(this._config.defaults,n,t.defaults)}getDefault(e){const{defaults:t}=this._config,n=t[e]||t.editor;return this._getLanguageByValue(n)||this.getAll()[0]}getLabel(e){const t=this._getLanguageByValue(e);return t?t.label:e}getAll(){return this._config.options}_getLegacyDefaults(){const e={},t=this._injector,n=t.get("config.defaultInputExpressionLanguage"),i=t.get("config.defaultOutputExpressionLanguage");return n&&(e.inputCell=n),i&&(e.outputCell=i),e}_getLanguageByValue(e){return u(this.getAll(),t=>e===t.value)}}oa.$inject=["injector"];var sa={__init__:["expressionLanguages"],expressionLanguages:["type",oa]};class aa{constructor(e){this._feelLanguageContext=e}getConfig(){return this._feelLanguageContext}}aa.$inject=["config.feelLanguageContext"];var la={__init__:["feelLanguageContext"],feelLanguageContext:["type",aa]};class ca extends vr{render({rows:e,cols:t}){const{components:n}=this.context;return ri(1,"tbody",null,e.map((e,i)=>{const r=n.getComponent("row",{rowType:"rule"});return r&&oi(2,r,{row:e,rowIndex:i,cols:t},e.id)}),0)}}class ha extends vr{constructor(e,t){super(e,t),Ns(this,Is)}render(){const{row:e,rowIndex:t,cols:n}=this.props,{cells:i}=e;return ri(1,"tr",null,[this.slotFills({type:"cell",context:{cellType:"before-rule-cells",row:e,rowIndex:t}}),i.map((i,r)=>this.slotFill({type:"cell",context:{cellType:"rule",cell:i,rowIndex:t,colIndex:r},key:i.id,row:e,col:n[r]})),this.slotFills({type:"cell",context:{cellType:"after-rule-cells",row:e,rowIndex:t}})],0)}}class ua extends vr{render(){const{cell:e,row:t,col:n}=this.props;return In(e,"dmn:UnaryTests")?oi(2,Ls,{className:"input-cell",elementId:e.id,"data-row-id":t.id,"data-col-id":n.id,children:e.businessObject.text}):oi(2,Ls,{className:"output-cell",elementId:e.id,"data-row-id":t.id,"data-col-id":n.id,children:e.businessObject.text})}}class pa{constructor(e){e.onGetComponent("table.body",()=>ca),e.onGetComponent("row",({rowType:e})=>{if("rule"===e)return ha}),e.onGetComponent("cell",({cellType:e})=>{if("rule"===e)return ua})}}pa.$inject=["components"];var da={__depends__:[sa,la],__init__:["decisionRules"],decisionRules:["type",pa]};const fa=[{label:"Unique",value:{hitPolicy:"UNIQUE",aggregation:void 0},explanation:"No overlap is possible and all rules are disjoint. Only a single rule can be matched"},{label:"First",value:{hitPolicy:"FIRST",aggregation:void 0},explanation:"Rules may overlap. The first matching rule will be chosen"},{label:"Priority",value:{hitPolicy:"PRIORITY",aggregation:void 0},explanation:"Rules may overlap. The one with the highest priority will be chosen"},{label:"Any",value:{hitPolicy:"ANY",aggregation:void 0},explanation:"Rules may overlap. Their output have to match"},{label:"Collect",value:{hitPolicy:"COLLECT",aggregation:void 0},explanation:"Collects the values of all matching rules"},{label:"Collect (Sum)",value:{hitPolicy:"COLLECT",aggregation:"SUM"},explanation:"Collects the values of all matching rules and sums up to a single value"},{label:"Collect (Min)",value:{hitPolicy:"COLLECT",aggregation:"MIN"},explanation:"Collects the values of all matching rules and uses the lowest value"},{label:"Collect (Max)",value:{hitPolicy:"COLLECT",aggregation:"MAX"},explanation:"Collects the values of all matching rules and uses the highest value"},{label:"Collect (Count)",value:{hitPolicy:"COLLECT",aggregation:"COUNT"},explanation:"Collects the values of all matching rules and counts the number of them"},{label:"Rule order",value:{hitPolicy:"RULE ORDER",aggregation:void 0},explanation:"Collects the values of all matching rules in rule order"},{label:"Output order",value:{hitPolicy:"OUTPUT ORDER",aggregation:void 0},explanation:"Collects the values of all matching rules in decreasing output priority order"}];class ga extends vr{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),Ds(this)}getRoot(){return this.sheet.getRoot()}render(){const e=this.getRoot().businessObject,{aggregation:t,hitPolicy:n}=e,i=u(fa,e=>{return i=e.value,r={aggregation:t,hitPolicy:n},i.hitPolicy===r.hitPolicy&&i.aggregation===r.aggregation;var i,r});return ri(1,"div","hit-policy header",[ri(1,"label","dms-label",this._translate("Hit policy:"),0),ri(1,"span","hit-policy-value",this._translate(i.label),0)],4,{title:this._translate(i.explanation)})}}function ma(e){e.onGetComponent("hit-policy",()=>ga)}ga.$inject=["sheet"],ma.$inject=["components"];var ya={__init__:["hitPolicyProvider"],hitPolicyProvider:["type",ma]};let va=class extends vr{constructor(e,t){super(e,t);const{injector:n}=t;this._translate=n.get("translate"),this._eventBus=n.get("eventBus")}onClick=()=>{this._eventBus.fire("showDrd")};render(){return ri(1,"div","view-drd",ri(1,"button","view-drd-button",this._translate("View DRD"),0,{type:"button",onClick:this.onClick}),2,null,null,e=>this.node=e)}},wa=class{constructor(e,t,n,i){this._injector=n,this._viewer=i,e.onGetComponent("table.before",()=>{if(this.canViewDrd())return va}),t.on("showDrd",()=>{const e=n.get("_parent",!1),t=i.getDefinitions();if(!t)return;const r=e.getView(t);e.open(r)})}canViewDrd(){const e=this._injector.get("_parent",!1);return!!e&&!!e.getView(this._viewer.getDefinitions())}};wa.$inject=["components","eventBus","injector","viewer"];var ba={__init__:["viewDrd"],viewDrd:["type",wa]};let xa=class{constructor(e){e.onGetComponent("table.before",()=>xr)}};xa.$inject=["components"];var _a={__init__:["poweredBy"],poweredBy:["type",xa]};let ka=class e extends Ms{constructor(t={}){const n=e._createContainer();super(S(t,{renderer:{container:n}})),this._container=n}open(e){var t=this;return new Promise((n,i)=>{var r;try{return t._decision&&t.clear(),t._decision=e,function(e,t,n){const i=e.get("tableImporter"),r=e.get("eventBus"),o=e.get("sheet");e.get("modeling",!1);let s,a=[];r.fire("import.render.start",{decision:t});try{!function(e){new Ts({create:(e,t,n,r)=>i.create(e,t,n,r),table:e=>i.add(e),element:(e,t,n)=>i.add(e,t,n),error(e,t){a.push({message:e,context:t})}}).handleDecision(e)}(t)}catch(e){s=e}r.fire("import.render.complete",{error:s,warnings:a}),r.fire("elements.changed",{elements:[o.getRoot()]}),n(s,a)}(t,e,function(e,t){e?(e.warnings=t||[],i(e)):n({warnings:t||[]})})}catch(e){r=e}r?(r.warnings=r.warnings||[],i(r)):n({warnings:[]})})}getDefinitions(){return Fn(this._decision)}_init(e){let{modules:t,additionalModules:n,...i}=e,r=t||this.getModules();return{modules:[_a,...r,...n||[],...[{viewer:["value",this]}]],config:i}}on(e,t,n,i){return this.get("eventBus").on(e,t,n,i)}off(e,t){this.get("eventBus").off(e,t)}_emit(e,t){return this.get("eventBus").fire(e,t)}attachTo(e){if(!e)throw new Error("parentNode required");this.detach();const t=this._container;e.appendChild(t),this._emit("attach",{})}detach(){const e=this._container;e.parentNode&&(this._emit("detach",{}),at(e))}destroy(){super.destroy(),this.detach()}getModules(){return e._getModules()}static _getModules(){return[$s,Hs,to,Ys,ea,ia,da,ya,ba]}static _createContainer(){return We('<div class="dmn-decision-table-container bio-theme-parent"></div>')}};const Sa=/^class[ {]/;function Ca(e){return Array.isArray(e)}function Ea(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Ma(...e){1===e.length&&Ca(e[0])&&(e=e[0]);const t=(e=[...e]).pop();return t.$inject=e,t}const Aa=/constructor\s*[^(]*\(\s*([^)]*)\)/m,Ta=/^(?:async\s+)?(?:function\s*[^(]*)?(?:\(\s*([^)]*)\)|(\w+))/m,Ra=/\/\*([^*]*)\*\//m;function Oa(e){if("function"!=typeof e)throw new Error(`Cannot annotate "${e}". Expected a function!`);const t=e.toString().match(function(e){return Sa.test(e.toString())}(e)?Aa:Ta);if(!t)return[];const n=t[1]||t[2];return n&&n.split(",").map(e=>{const t=e.match(Ra),[n,i]=e.replace(Ra,"").split("="),r=(t&&t[1]||n).trim();return void 0===i||r.endsWith("?")?r:r+"?"})||[]}function Da(e,t){const n=t||{get:function(e,t){if(!1!==t)throw i.push(e),a(`No provider for "${e}"!`)}},i=[],r=this._providers=Object.create(n._providers||null),o=this._instances=Object.create(null),s=o.injector=this,a=function(e){const t=i.join(" -> ");return i.length=0,new Error(t?`${e} (Resolving: ${t})`:e)};function l(e,t){const s=e.lastIndexOf("?");if(-1!==s){const t=l(e.slice(0,s),!1),n=e.slice(s+2);if(n&&null==t)return;return n?n.split(".").reduce((e,t)=>e[t],t):t}if(!r[e]&&e.includes(".")){const n=e.split(".");let i=l(n.shift(),t);for(;n.length;){const e=n.shift();i=!1===t?i?.[e]:i[e]}return i}if(Ea(o,e))return o[e];if(Ea(r,e)){if(-1!==i.indexOf(e))throw i.push(e),a("Cannot resolve circular dependency!");return i.push(e),o[e]=r[e][0](r[e][1]),i.pop(),o[e]}return n.get(e,t)}function c(e,t){if(void 0===t&&(t={}),"function"!=typeof e){if(!Ca(e))throw a(`Cannot invoke "${e}". Expected a function!`);e=Ma(e.slice())}return{fn:e,dependencies:(e.$inject||Oa(e)).map(e=>{const n=e.replace(/\?$/,"");return Ea(t,n)?t[n]:l(e)})}}function h(e){const{fn:t,dependencies:n}=c(e);return new(Function.prototype.bind.call(t,null,...n))}function u(e,t,n){const{fn:i,dependencies:r}=c(e,n);return i.apply(t,r)}function p(e){return Ma(t=>e.get(t))}function d(e,t){if(t&&t.length){const n=Object.create(null),i=Object.create(null),o=[],s=[],a=[];let l,c,h,u;for(let e in r)l=r[e],-1!==t.indexOf(e)&&("private"===l[2]?(c=o.indexOf(l[3]),-1===c?(h=l[3].createChild([],t),u=p(h),o.push(l[3]),s.push(h),a.push(u),n[e]=[u,e,"private",h]):n[e]=[a[c],e,"private",s[c]]):n[e]=[l[2],l[1]],i[e]=!0),"factory"!==l[2]&&"type"!==l[2]||!l[1].$scope||t.forEach(t=>{-1!==l[1].$scope.indexOf(t)&&(n[e]=[l[2],l[1]],i[t]=!0)});t.forEach(e=>{if(!i[e])throw new Error('No provider for "'+e+'". Cannot use provider from the parent!')}),e.unshift(n)}return new Da(e,s)}const f={factory:u,type:h,value:function(e){return e}};function g(e,t){const n=e.__init__||[];return function(){n.forEach(e=>{"string"==typeof e?t.get(e):t.invoke(e)})}}function m(e){const t=e.__exports__;if(t){const n=e.__modules__,i=Object.keys(e).reduce((t,n)=>("__exports__"!==n&&"__modules__"!==n&&"__init__"!==n&&"__depends__"!==n&&(t[n]=e[n]),t),Object.create(null)),o=d((n||[]).concat(i)),s=Ma(function(e){return o.get(e)});t.forEach(function(e){r[e]=[s,e,"private",o]});const a=(e.__init__||[]).slice();return a.unshift(function(){o.init()}),g(e=Object.assign({},e,{__init__:a}),o)}return Object.keys(e).forEach(function(t){if("__init__"===t||"__depends__"===t)return;const n=e[t];if("private"===n[2])return void(r[t]=n);const i=n[0],o=n[1];r[t]=[f[i],qa(i,o),i]}),g(e,s)}function y(e,t){return-1!==e.indexOf(t)||-1!==(e=(t.__depends__||[]).reduce(y,e)).indexOf(t)?e:e.concat(t)}this.get=l,this.invoke=u,this.instantiate=h,this.createChild=d,this.init=function(e){const t=e.reduce(y,[]).map(m);let n=!1;return function(){n||(n=!0,t.forEach(e=>e()))}}(e)}function qa(e,t){return"value"!==e&&Ca(t)&&(t=Ma(t.slice())),t}class Na{constructor(e){this._listeners={},e.on("elements.changed",({elements:e})=>{this.elementsChanged(e)}),e.on("element.updateId",({element:e,newId:t})=>{this.updateId(e.id,t)})}elementsChanged(e){const t={},n=e.length;for(let i=0;i<n;i++){const{id:n}=e[i];if(t[n])return;t[n]=!0;const r=this._listeners[n]&&this._listeners[n].length;if(r)for(let e=0;e<r;e++)this._listeners[n][e]&&this._listeners[n][e]()}}onElementsChanged(e,t){this._listeners[e]||(this._listeners[e]=[]),this._listeners[e][this._listeners[e].length]=t}offElementsChanged(e,t){if(this._listeners[e])if(t){const n=this._listeners[e].indexOf(t);-1!==n&&this._listeners[e].splice(n,1)}else this._listeners[e].length=0}updateId(e,t){this._listeners[e]&&(this._listeners[t]=this._listeners[e],delete this._listeners[e])}}Na.$inject=["eventBus"];class Ba extends vr{constructor(e){super(e);const t=this._injector=e.injector;this._changeSupport=t.get("changeSupport"),this._components=t.get("components"),this._renderer=t.get("renderer")}getChildContext(){return{changeSupport:this._changeSupport,components:this._components,renderer:this._renderer,injector:this._injector}}render(){const e=this._components.getComponents("viewer");return ri(1,"div","viewer-container",e&&e.map((e,t)=>oi(2,e,null,t)),0)}}class Pa{constructor(e,t,n,i,r){const{container:o}=n;this._container=o,i.on("renderer.mount",()=>{dr(oi(2,Ba,{injector:r}),o)}),i.on("renderer.unmount",()=>{dr(null,o)})}getContainer(){return this._container}}Pa.$inject=["changeSupport","components","config.renderer","eventBus","injector"];var La={__init__:["changeSupport","components","renderer"],changeSupport:["type",Na],components:["type",class{constructor(){this._listeners={}}getComponent(e,t){const n=this._listeners[e];if(!n)return;let i;for(let e=0;e<n.length&&(i=n[e].callback(t),!i);e++);return i}getComponents(e,t){const n=this._listeners[e];if(!n)return;const i=[];for(let e=0;e<n.length;e++){const r=n[e].callback(t);r&&i.push(r)}return i.length?i:void 0}onGetComponent(e,t,n){if(l(t)&&(n=t,t=1e3),!a(t))throw new Error("priority must be a number");const i=this._getListeners(e);let r,o;const s={priority:t,callback:n};for(o=0;r=i[o];o++)if(r.priority<t)return void i.splice(o,0,s);i.push(s)}offGetComponent(e,t){const n=this._getListeners(e);let i,r,o;if(t)for(o=n.length-1;i=n[o];o--)r=i.callback,r===t&&n.splice(o,1);else n.length=0}_getListeners(e){let t=this._listeners[e];return t||(this._listeners[e]=t=[]),t}}],eventBus:["type",M],renderer:["type",Pa]};let Ia=class{constructor(e={}){let{injector:t}=e;if(!t){let{modules:n,config:i}=this._init(e);t=function(e,t){const n=[{config:["value",e]},La].concat(t||[]),i=new Da(n);return i.init(),i}(i,n)}this.get=t.get,this.invoke=t.invoke,this.get("eventBus").fire("viewer.init")}_init(e){let{modules:t,...n}=e;return{modules:t,config:n}}destroy(){this.get("eventBus").fire("viewer.destroy")}clear(){this.get("eventBus").fire("viewer.clear")}};class ja{constructor(e,t){this._eventBus=t,this._viewer=e}getDecision(){return this._viewer.getDecision()}updateId(e,t){if(e!==this.getDecision())throw new Error("element !== decision");this._eventBus.fire("element.updateId",{element:e,newId:t}),e.id=t}}ja.$inject=["viewer","eventBus"];var Fa={__init__:["elementRegistry"],elementRegistry:["type",ja]};class Va extends vr{constructor(e,t){super(e,t),this._viewer=t.injector.get("viewer")}render(){const{name:e}=this._viewer.getDecision();return ri(1,"div","decision-properties",ri(1,"h3","decision-name",e,0),2)}}let $a=class{constructor(e){e.onGetComponent("viewer",1500,()=>Va)}};$a.$inject=["components"];var za={__init__:["decisionProperties"],decisionProperties:["type",$a]};class Wa extends vr{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),this._viewer=t.injector.get("viewer")}render(){const e=this._viewer.getDecision(),t=e.get("decisionLogic"),n=e.get("variable");return ri(1,"div","literal-expression-properties",ri(1,"table",null,[ri(1,"tr",null,[ri(1,"td",null,this._translate("Variable name:"),0),ri(1,"td",null,ri(1,"span",null,n&&n.get("name")||"-",0),2)],4),ri(1,"tr",null,[ri(1,"td",null,this._translate("Variable type:"),0),ri(1,"td",null,ri(1,"span",null,this._translate(n&&n.get("typeRef")||"")||"-",0),2)],4),ri(1,"tr",null,[ri(1,"td",null,this._translate("Expression language:"),0),ri(1,"td",null,ri(1,"span",null,t.expressionLanguage||"-",0),2)],4)],4),2)}}class Ha{constructor(e){e.onGetComponent("viewer",500,()=>Wa)}}Ha.$inject=["components"];var Ua={__depends__:[],__init__:["literalExpressionProperties"],literalExpressionProperties:["type",Ha]};let Ga=class{constructor(e){e.onGetComponent("viewer",2e3,()=>xr)}};Ga.$inject=["components"];var Ka={__init__:["poweredBy"],poweredBy:["type",Ga]};class Xa extends vr{constructor(e,t){super(e,t),this._viewer=t.injector.get("viewer")}render(){const{text:e}=this._viewer.getDecision().decisionLogic;return ri(1,"div","textarea",ri(1,"div","content",e,0),2)}}class Ya{constructor(e){e.onGetComponent("viewer",()=>Xa)}}Ya.$inject=["components"];var Ja={__init__:["textarea"],textarea:["type",Ya]};let Qa=class extends vr{constructor(e,t){super(e,t);const{injector:n}=t;this._translate=n.get("translate"),this._eventBus=n.get("eventBus")}onClick=()=>{this._eventBus.fire("showDrd")};render(){return ri(1,"div","view-drd",ri(1,"button","view-drd-button",this._translate("View DRD"),0,{type:"button",onClick:this.onClick}),2,null,null,e=>this.node=e)}};Qa.$inject=["translate"];let Za=class{constructor(e,t,n,i){this._injector=i,this._viewer=t,e.onGetComponent("viewer",2e3,()=>{if(this.canViewDrd())return Qa}),n.on("showDrd",()=>{const e=i.get("_parent",!1),n=t.getDefinitions(),r=e.getView(n);e.open(r)})}canViewDrd(){const e=this._injector.get("_parent",!1);if(e)return!!e.getView(this._viewer.getDefinitions())}};Za.$inject=["components","viewer","eventBus","injector"];var el={__init__:["viewDrd"],viewDrd:["type",Za]};let tl=class e extends Ia{constructor(t={}){const n=e._createContainer();super(S(t,{renderer:{container:n}})),this._container=n}open(e){var t=this;return new Promise(function(n,i){var r;try{t._decision&&(t.clear(),t.get("eventBus").fire("renderer.unmount")),t._decision=e,t.get("eventBus").fire("import",e),t.get("eventBus").fire("renderer.mount")}catch(e){r=e}r?(r.warnings=r.warnings||[],i(r)):n({warnings:[]})})}_init(e){let{modules:t,additionalModules:n,...i}=e;return{modules:[...t||this.getModules(),...n||[],...[{viewer:["value",this]}]],config:i}}on(e,t,n,i){return this.get("eventBus").on(e,t,n,i)}off(e,t){this.get("eventBus").off(e,t)}_emit(e,t){return this.get("eventBus").fire(e,t)}getDecision(){return this._decision}getDefinitions(){return Fn(this._decision)}attachTo(e){if(!e)throw new Error("parentNode required");this.detach(),e.appendChild(this._container),this._emit("attach",{})}detach(){const e=this._container;e.parentNode&&(this._emit("detach",{}),at(e))}destroy(){super.destroy(),this.detach()}getModules(){return e._getModules()}static _getModules(){return[Fa,to,za,Ua,Ka,Ja,el]}static _createContainer(){return We('<div class="dmn-literal-expression-container bio-theme-parent"></div>')}};function nl(e,{injector:t}){const n=t.get("components").getComponents("header");return ri(1,"div","dmn-boxed-expression-section dmn-boxed-expression-header",n&&n.map((e,t)=>oi(2,e,null,t)),0)}function il(e,{injector:t}){const n=t.get("components").getComponents("body");return ri(1,"div","dmn-boxed-expression-section dmn-boxed-expression-body",n&&n.map((e,t)=>oi(2,e,null,t)),0)}function rl(e,{injector:t}){const n=t.get("components").getComponents("footer");return ri(1,"div","dmn-boxed-expression-section dmn-boxed-expression-footer",n&&n.map((e,t)=>oi(2,e,null,t)),0)}var ol={__init__:["viewRenderer","tableJsSupport"],viewRenderer:["type",class{static $inject=["components"];constructor(e){e.onGetComponent("viewer",()=>nl),e.onGetComponent("viewer",()=>il),e.onGetComponent("viewer",()=>rl)}}],tableJsSupport:["type",class{static $inject=["components"];constructor(e){e.onGetComponent("viewer",()=>{const t=e.getComponents("table.before")||[];return()=>ri(1,"div",null,t.map((e,t)=>oi(2,e,null,t)),0)})}}]};class sl{constructor(e){e.onGetComponent("viewer",2e3,()=>xr)}}sl.$inject=["components"];var al={__init__:["poweredBy"],poweredBy:["type",sl]};function ll({expression:e},t){return ri(1,"div","textarea",ri(1,"div","content",t.injector.get("literalExpression").getText(e),0),2)}class cl{getText(e){return e.get("text")}}var hl={__init__:["literalExpressionComponent"],literalExpressionComponent:["type",class{static $inject=["components"];constructor(e){e.onGetComponent("expression",({expression:e})=>{if(In(e,"dmn:LiteralExpression"))return ll})}}],literalExpression:["type",cl]};function ul({expression:e},t){const n=t.injector.get("functionDefinition"),i=n.getKind(e),r=n.getParameters(e),o=n.getBody(e);return ri(1,"div","function-definition",[oi(2,dl,{kind:i}),oi(2,fl,{parameters:r}),oi(2,ml,{expression:o})],4)}const pl={FEEL:"F",Java:"J",PMML:"P"};function dl({kind:e},t){const n=t.injector.get("translate");return ri(1,"div","function-definition-kind",pl[e],0,{title:n("Function kind: {kind}",{kind:e})})}function fl({parameters:e}){return ri(1,"div","function-definition-parameters",ri(1,"div",null,[si("("),e.reduce((e,t)=>e.concat(oi(2,gl,{parameter:t}),", "),[]).slice(0,-1),si(")")],0),2)}function gl({parameter:e}){const{name:t,typeRef:n}=e,i=t||"<unnamed>";return ri(1,"span",null,n?`${i}: ${n}`:i,0)}function ml({expression:e},t){return ri(1,"div","function-definition-body",oi(2,t.components.getComponent("expression",{expression:e}),{expression:e}),2)}var yl={__init__:["functionDefinitionComponent"],functionDefinition:["type",class{getParameters(e){return e.get("formalParameter")}getBody(e){return e.get("body")}getKind(e){return e.get("kind")||"FEEL"}}],functionDefinitionComponent:["type",class{static $inject=["components"];constructor(e){e.onGetComponent("expression",({expression:e})=>{if(In(e,"dmn:FunctionDefinition"))return ul})}}]};class vl extends vr{constructor(e,t){super(e,t);const{injector:n}=t;this._translate=n.get("translate"),this._eventBus=n.get("eventBus")}onClick=()=>{this._eventBus.fire("showDrd")};render(){return ri(1,"div","view-drd",ri(1,"button","view-drd-button",this._translate("View DRD"),0,{type:"button",onClick:this.onClick}),2,null,null,e=>this.node=e)}}vl.$inject=["translate"];class wl{constructor(e,t,n,i){this._injector=n,this._viewer=i,e.onGetComponent("viewer",2e3,()=>{if(this.canViewDrd())return vl}),t.on("showDrd",()=>{const e=n.get("_parent",!1),t=i.getDefinitions(),r=e.getView(t);e.open(r)})}canViewDrd(){const e=this._injector.get("_parent",!1);if(e)return!!e.getView(this._viewer.getDefinitions())}}wl.$inject=["components","eventBus","injector","viewer"];var bl={__init__:["viewDrd"],viewDrd:["type",wl]};function xl(e,t){const n=t.injector.get("viewer"),{name:i}=n.getRootElement();return ri(1,"div","element-properties",ri(1,"h2","element-name",i,0),2)}class _l{constructor(e){e.onGetComponent("header",()=>xl)}}_l.$inject=["components"];var kl={__init__:["elementProperties"],elementProperties:["type",_l]};function Sl(e,{injector:t}){const n=t.get("components"),i=function(e){if(In(e,"dmn:Decision"))return e.get("decisionLogic");if(In(e,"dmn:BusinessKnowledgeModel"))return e.get("encapsulatedLogic")}(t.get("viewer").getRootElement());return oi(2,n.getComponent("expression",{expression:i}),{expression:i})}function Cl({expression:e}){return ri(1,"div",null,ri(1,"span",null,[si("Expression of type "),e.$type,si(" is not supported.")],0,{style:"color:red;"}),2)}var El={__init__:["elementLogic"],elementLogic:["type",class{static $inject=["components"];constructor(e){e.onGetComponent("body",()=>Sl),e.onGetComponent("expression",100,()=>Cl)}}]};function Ml(e,t){const n=t.injector.get("elementVariable"),i=t.injector.get("translate"),r=n.getName(),o=n.getType();return ri(1,"div","element-variable",[ri(1,"h2",null,si("Result"),2),ri(1,"div","element-variable-name",[ri(1,"span","element-variable-name-label",i("Variable name"),0),ri(1,"span",null,r,0)],4),ri(1,"div","element-variable-type",[ri(1,"span","element-variable-type-label",i("Variable type"),0),ri(1,"span",null,o,0)],4)],4)}var Al={__init__:["elementVariableComponent"],elementVariable:["type",class{static $inject=["viewer"];constructor(e){this._viewer=e}getName(){const e=this.getVariable(),t=this._getElement();return(e?e.get("name"):null)||t.get("name")}getType(){const e=this.getTypeHolder();return e&&e.get("typeRef")||"Any"}getTypeHolder(){const e=this._getElement();return In(e,"dmn:BusinessKnowledgeModel")?Vn(e):this.getVariable()}_getElement(){return this._viewer.getRootElement()}getVariable(){return this._getElement().get("variable")}}],elementVariableComponent:["type",class{static $inject=["components"];constructor(e){e.onGetComponent("footer",()=>Ml)}}]};let Tl=class e extends Ia{constructor(t={}){const n=e._createContainer();super(S(t,{renderer:{container:n}})),this._container=n}open(e){const t=this.get("eventBus");return new Promise((n,i)=>{let r;try{this.getRootElement()&&(this.clear(),t.fire("renderer.unmount")),this._setRootElement(e),t.fire("import",e),t.fire("renderer.mount")}catch(e){r=e}r?(r.warnings=r.warnings||[],i(r)):n({warnings:[]})})}_init(e){let{modules:t,additionalModules:n,...i}=e;return{modules:[...t||this.getModules(),...n||[],...[{viewer:["value",this]}]],config:i}}on(e,t,n,i){return this.get("eventBus").on(e,t,n,i)}off(e,t){this.get("eventBus").off(e,t)}_emit(e,t){return this.get("eventBus").fire(e,t)}getRootElement(){return this._root}getDefinitions(){return Fn(this._root)}_setRootElement(e){this._root=e}attachTo(e){if(!e)throw new Error("parentNode required");this.detach(),e.appendChild(this._container),this._emit("attach",{})}detach(){const e=this._container;e.parentNode&&(this._emit("detach",{}),at(e))}destroy(){super.destroy(),this.detach()}getModules(){return[ol,to,al,bl,kl,El,yl,hl,Al]}static _createContainer(){return We('<div class="dmn-boxed-expression-container bio-theme-parent"></div>')}};var Rl,Ol,Dl,ql,Nl,Bl;function Pl(){if(ql)return Dl;ql=1;var e=/\b(Array|Date|Object|Math|JSON)\b/g;return Dl=function(t,n){var i=function(e){for(var t=[],n=0;n<e.length;n++)~t.indexOf(e[n])||t.push(e[n]);return t}(function(t){return t.replace(/\.\w+|\w+ *\(|"[^"]*"|'[^']*'|\/([^/]+)\//g,"").replace(e,"").match(/[a-zA-Z_]\w*/g)||[]}(t));return n&&"string"==typeof n&&(n=function(e){return function(t){return e+t}}(n)),n?function(e,t,n){var i=/\.\w+|\w+ *\(|"[^"]*"|'[^']*'|\/([^/]+)\/|[a-zA-Z_]\w*/g;return e.replace(i,function(e){return"("==e[e.length-1]||~t.indexOf(e)?n(e):e})}(t,i,n):i},Dl}!function(){if(Bl)return Nl;Bl=1;var e=Ol?Rl:(Ol=1,Rl=function(e,t){return e^t}),t=Pl();function n(e,t){if(!(this instanceof n))return new n(e,t);if(this.node=this.start=this.peeked=e,this.root=t,this.closingTag=!1,this._revisit=!0,this._selects=[],this._rejects=[],e&&this.higher(e))throw new Error("root must be a parent or ancestor to node")}function i(t,n){var i="nextSibling"==t;return function(r,o,s){r=this.compile(r),o=o&&o>0?o:1;for(var a=this.node,l=this.closingTag,c=this._revisit;a;){if(e(i,l)&&a[n])a=a[n],l=!i;else if(1==a.nodeType&&!a[n]&&e(i,l)){if(l=i,!c)continue}else if(a[t])a=a[t],l=!i;else if(a=a.parentNode,l=i,!c)continue;if(!a||this.higher(a,this.root))break;if(r(a)&&this.selects(a,s)&&this.rejects(a,s)){if(--o)continue;return s||(this.node=a),this.closingTag=l,a}}return null}}Nl=n,n.prototype.reset=function(e){return this.node=e||this.start,this},n.prototype.revisit=function(e){return this._revisit=null==e||e,this},n.prototype.opening=function(){return 1==this.node.nodeType&&(this.closingTag=!1),this},n.prototype.atOpening=function(){return!this.closingTag},n.prototype.closing=function(){return 1==this.node.nodeType&&(this.closingTag=!0),this},n.prototype.atClosing=function(){return this.closingTag},n.prototype.next=i("nextSibling","firstChild"),n.prototype.previous=n.prototype.prev=i("previousSibling","lastChild"),n.prototype.select=function(e){return e=this.compile(e),this._selects.push(e),this},n.prototype.selects=function(e,t){var n=this._selects,i=n.length;if(!i)return!0;for(var r=0;r<i;r++)if(n[r].call(this,e,t))return!0;return!1},n.prototype.reject=function(e){return e=this.compile(e),this._rejects.push(e),this},n.prototype.rejects=function(e,t){var n=this._rejects,i=n.length;if(!i)return!0;for(var r=0;r<i;r++)if(n[r].call(this,e,t))return!1;return!0},n.prototype.higher=function(e){var t=this.root;if(!t)return!1;for(e=e.parentNode;e&&e!=t;)e=e.parentNode;return e!=t},n.prototype.compile=function(e){switch(typeof e){case"number":return function(t){return e==t.nodeType};case"string":return new Function("node","Object.freeze(node); return "+t(e,"node."));case"function":return e;default:return function(){return!0}}},n.prototype.peak=n.prototype.peek=function(e,t){return 1==arguments.length&&(t=e,e=!0),(t=null==t?1:t)?t>0?this.next(e,t,!0):this.prev(e,Math.abs(t),!0):this.node},n.prototype.use=function(e){return e(this),this}}(),window.getSelection();let Ll=[],Il=[];function jl(e){if(e<768)return!1;for(let t=0,n=Ll.length;;){let i=t+n>>1;if(e<Ll[i])n=i;else{if(!(e>=Il[i]))return!0;t=i+1}if(t==n)return!1}}function Fl(e){return e>=127462&&e<=127487}(()=>{let e="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let t=0,n=0;t<e.length;t++)(t%2?Il:Ll).push(n+=e[t])})();function Vl(e,t,n=!0,i=!0){return(n?$l:zl)(e,t,i)}function $l(e,t,n){if(t==e.length)return t;t&&Hl(e.charCodeAt(t))&&Ul(e.charCodeAt(t-1))&&t--;let i=Wl(e,t);for(t+=Gl(i);t<e.length;){let r=Wl(e,t);if(8205==i||8205==r||n&&jl(r))t+=Gl(r),i=r;else{if(!Fl(r))break;{let n=0,i=t-2;for(;i>=0&&Fl(Wl(e,i));)n++,i-=2;if(n%2==0)break;t+=2}}}return t}function zl(e,t,n){for(;t>0;){let i=$l(e,t-2,n);if(i<t)return i;t--}return 0}function Wl(e,t){let n=e.charCodeAt(t);if(!Ul(n)||t+1==e.length)return n;let i=e.charCodeAt(t+1);return Hl(i)?i-56320+(n-55296<<10)+65536:n}function Hl(e){return e>=56320&&e<57344}function Ul(e){return e>=55296&&e<56320}function Gl(e){return e<65536?1:2}class Kl{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=ic(this,e,t);let i=[];return this.decompose(0,e,i,2),n.length&&n.decompose(0,n.length,i,3),this.decompose(t,this.length,i,1),Yl.from(i,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=ic(this,e,t);let n=[];return this.decompose(e,t,n,0),Yl.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),i=new Zl(this),r=new Zl(e);for(let e=t,o=t;;){if(i.next(e),r.next(e),e=0,i.lineBreak!=r.lineBreak||i.done!=r.done||i.value!=r.value)return!1;if(o+=i.value.length,i.done||o>=n)return!0}}iter(e=1){return new Zl(this,e)}iterRange(e,t=this.length){return new ec(this,e,t)}iterLines(e,t){let n;if(null==e)n=this.iter();else{null==t&&(t=this.lines+1);let i=this.line(e).from;n=this.iterRange(i,Math.max(i,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new tc(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(0==e.length)throw new RangeError("A document must have at least one line");return 1!=e.length||e[0]?e.length<=32?new Xl(e):Yl.from(Xl.split(e,[])):Kl.empty}}class Xl extends Kl{constructor(e,t=function(e){let t=-1;for(let n of e)t+=n.length+1;return t}(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,i){for(let r=0;;r++){let o=this.text[r],s=i+o.length;if((t?n:s)>=e)return new nc(i,s,n,o);i=s+1,n++}}decompose(e,t,n,i){let r=e<=0&&t>=this.length?this:new Xl(Ql(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(1&i){let e=n.pop(),t=Jl(r.text,e.text.slice(),0,r.length);if(t.length<=32)n.push(new Xl(t,e.length+r.length));else{let e=t.length>>1;n.push(new Xl(t.slice(0,e)),new Xl(t.slice(e)))}}else n.push(r)}replace(e,t,n){if(!(n instanceof Xl))return super.replace(e,t,n);[e,t]=ic(this,e,t);let i=Jl(this.text,Jl(n.text,Ql(this.text,0,e)),t),r=this.length+n.length-(t-e);return i.length<=32?new Xl(i,r):Yl.from(Xl.split(i,[]),r)}sliceString(e,t=this.length,n="\n"){[e,t]=ic(this,e,t);let i="";for(let r=0,o=0;r<=t&&o<this.text.length;o++){let s=this.text[o],a=r+s.length;r>e&&o&&(i+=n),e<a&&t>r&&(i+=s.slice(Math.max(0,e-r),t-r)),r=a+1}return i}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let n=[],i=-1;for(let r of e)n.push(r),i+=r.length+1,32==n.length&&(t.push(new Xl(n,i)),n=[],i=-1);return i>-1&&t.push(new Xl(n,i)),t}}class Yl extends Kl{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let t of e)this.lines+=t.lines}lineInner(e,t,n,i){for(let r=0;;r++){let o=this.children[r],s=i+o.length,a=n+o.lines-1;if((t?a:s)>=e)return o.lineInner(e,t,n,i);i=s+1,n=a+1}}decompose(e,t,n,i){for(let r=0,o=0;o<=t&&r<this.children.length;r++){let s=this.children[r],a=o+s.length;if(e<=a&&t>=o){let r=i&((o<=e?1:0)|(a>=t?2:0));o>=e&&a<=t&&!r?n.push(s):s.decompose(e-o,t-o,n,r)}o=a+1}}replace(e,t,n){if([e,t]=ic(this,e,t),n.lines<this.lines)for(let i=0,r=0;i<this.children.length;i++){let o=this.children[i],s=r+o.length;if(e>=r&&t<=s){let a=o.replace(e-r,t-r,n),l=this.lines-o.lines+a.lines;if(a.lines<l>>4&&a.lines>l>>6){let r=this.children.slice();return r[i]=a,new Yl(r,this.length-(t-e)+n.length)}return super.replace(r,s,a)}r=s+1}return super.replace(e,t,n)}sliceString(e,t=this.length,n="\n"){[e,t]=ic(this,e,t);let i="";for(let r=0,o=0;r<this.children.length&&o<=t;r++){let s=this.children[r],a=o+s.length;o>e&&r&&(i+=n),e<a&&t>o&&(i+=s.sliceString(e-o,t-o,n)),o=a+1}return i}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof Yl))return 0;let n=0,[i,r,o,s]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;i+=t,r+=t){if(i==o||r==s)return n;let a=this.children[i],l=e.children[r];if(a!=l)return n+a.scanIdentical(l,t);n+=a.length+1}}static from(e,t=e.reduce((e,t)=>e+t.length+1,-1)){let n=0;for(let t of e)n+=t.lines;if(n<32){let n=[];for(let t of e)t.flatten(n);return new Xl(n,t)}let i=Math.max(32,n>>5),r=i<<1,o=i>>1,s=[],a=0,l=-1,c=[];function h(e){let t;if(e.lines>r&&e instanceof Yl)for(let t of e.children)h(t);else e.lines>o&&(a>o||!a)?(u(),s.push(e)):e instanceof Xl&&a&&(t=c[c.length-1])instanceof Xl&&e.lines+t.lines<=32?(a+=e.lines,l+=e.length+1,c[c.length-1]=new Xl(t.text.concat(e.text),t.length+1+e.length)):(a+e.lines>i&&u(),a+=e.lines,l+=e.length+1,c.push(e))}function u(){0!=a&&(s.push(1==c.length?c[0]:Yl.from(c,l)),l=-1,a=c.length=0)}for(let t of e)h(t);return u(),1==s.length?s[0]:new Yl(s,t)}}function Jl(e,t,n=0,i=1e9){for(let r=0,o=0,s=!0;o<e.length&&r<=i;o++){let a=e[o],l=r+a.length;l>=n&&(l>i&&(a=a.slice(0,i-r)),r<n&&(a=a.slice(n-r)),s?(t[t.length-1]+=a,s=!1):t.push(a)),r=l+1}return t}function Ql(e,t,n){return Jl(e,[""],t,n)}Kl.empty=new Xl([""],0);class Zl{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof Xl?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,i=this.nodes[n],r=this.offsets[n],o=r>>1,s=i instanceof Xl?i.text.length:i.children.length;if(o==(t>0?s:0)){if(0==n)return this.done=!0,this.value="",this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&r)==(t>0?0:1)){if(this.offsets[n]+=t,0==e)return this.lineBreak=!0,this.value="\n",this;e--}else if(i instanceof Xl){let r=i.text[o+(t<0?-1:0)];if(this.offsets[n]+=t,r.length>Math.max(0,e))return this.value=0==e?r:t>0?r.slice(e):r.slice(0,r.length-e),this;e-=r.length}else{let r=i.children[o+(t<0?-1:0)];e>r.length?(e-=r.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(r),this.offsets.push(t>0?1:(r instanceof Xl?r.text.length:r.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class ec{constructor(e,t,n){this.value="",this.done=!1,this.cursor=new Zl(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:i}=this.cursor.next(e);return this.pos+=(i.length+e)*t,this.value=i.length<=n?i:t<0?i.slice(i.length-n):i.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&""!=this.value}}class tc{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:n,value:i}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):n?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=i,this.afterBreak=!1),this}get lineBreak(){return!1}}"undefined"!=typeof Symbol&&(Kl.prototype[Symbol.iterator]=function(){return this.iter()},Zl.prototype[Symbol.iterator]=ec.prototype[Symbol.iterator]=tc.prototype[Symbol.iterator]=function(){return this});class nc{constructor(e,t,n,i){this.from=e,this.to=t,this.number=n,this.text=i}get length(){return this.to-this.from}}function ic(e,t,n){return[t=Math.max(0,Math.min(e.length,t)),Math.max(t,Math.min(e.length,n))]}function rc(e,t,n=!0,i=!0){return Vl(e,t,n,i)}const oc=/\r\n?|\n/;var sc=function(e){return e[e.Simple=0]="Simple",e[e.TrackDel=1]="TrackDel",e[e.TrackBefore=2]="TrackBefore",e[e.TrackAfter=3]="TrackAfter",e}(sc||(sc={}));class ac{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t+1];e+=n<0?this.sections[t]:n}return e}get empty(){return 0==this.sections.length||2==this.sections.length&&this.sections[1]<0}iterGaps(e){for(let t=0,n=0,i=0;t<this.sections.length;){let r=this.sections[t++],o=this.sections[t++];o<0?(e(n,i,r),i+=r):i+=o,n+=r}}iterChangedRanges(e,t=!1){uc(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let n=this.sections[t++],i=this.sections[t++];i<0?e.push(n,i):e.push(i,n)}return new ac(e)}composeDesc(e){return this.empty?e:e.empty?this:dc(this,e)}mapDesc(e,t=!1){return e.empty?this:pc(this,e,t)}mapPos(e,t=-1,n=sc.Simple){let i=0,r=0;for(let o=0;o<this.sections.length;){let s=this.sections[o++],a=this.sections[o++],l=i+s;if(a<0){if(l>e)return r+(e-i);r+=s}else{if(n!=sc.Simple&&l>=e&&(n==sc.TrackDel&&i<e&&l>e||n==sc.TrackBefore&&i<e||n==sc.TrackAfter&&l>e))return null;if(l>e||l==e&&t<0&&!s)return e==i||t<0?r:r+a;r+=a}i=l}if(e>i)throw new RangeError(`Position ${e} is out of range for changeset of length ${i}`);return r}touchesRange(e,t=e){for(let n=0,i=0;n<this.sections.length&&i<=t;){let r=i+this.sections[n++];if(this.sections[n++]>=0&&i<=t&&r>=e)return!(i<e&&r>t)||"cover";i=r}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let n=this.sections[t++],i=this.sections[t++];e+=(e?" ":"")+n+(i>=0?":"+i:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(e=>"number"!=typeof e))throw new RangeError("Invalid JSON representation of ChangeDesc");return new ac(e)}static create(e){return new ac(e)}}class lc extends ac{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return uc(this,(t,n,i,r,o)=>e=e.replace(i,i+(n-t),o),!1),e}mapDesc(e,t=!1){return pc(this,e,t,!0)}invert(e){let t=this.sections.slice(),n=[];for(let i=0,r=0;i<t.length;i+=2){let o=t[i],s=t[i+1];if(s>=0){t[i]=s,t[i+1]=o;let a=i>>1;for(;n.length<a;)n.push(Kl.empty);n.push(o?e.slice(r,r+o):Kl.empty)}r+=o}return new lc(t,n)}compose(e){return this.empty?e:e.empty?this:dc(this,e,!0)}map(e,t=!1){return e.empty?this:pc(this,e,t,!0)}iterChanges(e,t=!1){uc(this,e,t)}get desc(){return ac.create(this.sections)}filter(e){let t=[],n=[],i=[],r=new fc(this);e:for(let o=0,s=0;;){let a=o==e.length?1e9:e[o++];for(;s<a||s==a&&0==r.len;){if(r.done)break e;let e=Math.min(r.len,a-s);cc(i,e,-1);let o=-1==r.ins?-1:0==r.off?r.ins:0;cc(t,e,o),o>0&&hc(n,t,r.text),r.forward(e),s+=e}let l=e[o++];for(;s<l;){if(r.done)break e;let e=Math.min(r.len,l-s);cc(t,e,-1),cc(i,e,-1==r.ins?-1:0==r.off?r.ins:0),r.forward(e),s+=e}}return{changes:new lc(t,n),filtered:ac.create(i)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t],i=this.sections[t+1];i<0?e.push(n):0==i?e.push([n]):e.push([n].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,n){let i=[],r=[],o=0,s=null;function a(e=!1){if(!e&&!i.length)return;o<t&&cc(i,t-o,-1);let n=new lc(i,r);s=s?s.compose(n.map(s)):n,i=[],r=[],o=0}return function e(l){if(Array.isArray(l))for(let t of l)e(t);else if(l instanceof lc){if(l.length!=t)throw new RangeError(`Mismatched change set length (got ${l.length}, expected ${t})`);a(),s=s?s.compose(l.map(s)):l}else{let{from:e,to:s=e,insert:c}=l;if(e>s||e<0||s>t)throw new RangeError(`Invalid change range ${e} to ${s} (in doc of length ${t})`);let h=c?"string"==typeof c?Kl.of(c.split(n||oc)):c:Kl.empty,u=h.length;if(e==s&&0==u)return;e<o&&a(),e>o&&cc(i,e-o,-1),cc(i,s-e,u),hc(r,i,h),o=s}}(e),a(!s),s}static empty(e){return new lc(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],n=[];for(let i=0;i<e.length;i++){let r=e[i];if("number"==typeof r)t.push(r,-1);else{if(!Array.isArray(r)||"number"!=typeof r[0]||r.some((e,t)=>t&&"string"!=typeof e))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==r.length)t.push(r[0],0);else{for(;n.length<i;)n.push(Kl.empty);n[i]=Kl.of(r.slice(1)),t.push(r[0],n[i].length)}}}return new lc(t,n)}static createSet(e,t){return new lc(e,t)}}function cc(e,t,n,i=!1){if(0==t&&n<=0)return;let r=e.length-2;r>=0&&n<=0&&n==e[r+1]?e[r]+=t:r>=0&&0==t&&0==e[r]?e[r+1]+=n:i?(e[r]+=t,e[r+1]+=n):e.push(t,n)}function hc(e,t,n){if(0==n.length)return;let i=t.length-2>>1;if(i<e.length)e[e.length-1]=e[e.length-1].append(n);else{for(;e.length<i;)e.push(Kl.empty);e.push(n)}}function uc(e,t,n){let i=e.inserted;for(let r=0,o=0,s=0;s<e.sections.length;){let a=e.sections[s++],l=e.sections[s++];if(l<0)r+=a,o+=a;else{let c=r,h=o,u=Kl.empty;for(;c+=a,h+=l,l&&i&&(u=u.append(i[s-2>>1])),!(n||s==e.sections.length||e.sections[s+1]<0);)a=e.sections[s++],l=e.sections[s++];t(r,c,o,h,u),r=c,o=h}}}function pc(e,t,n,i=!1){let r=[],o=i?[]:null,s=new fc(e),a=new fc(t);for(let e=-1;;){if(s.done&&a.len||a.done&&s.len)throw new Error("Mismatched change set lengths");if(-1==s.ins&&-1==a.ins){let e=Math.min(s.len,a.len);cc(r,e,-1),s.forward(e),a.forward(e)}else if(a.ins>=0&&(s.ins<0||e==s.i||0==s.off&&(a.len<s.len||a.len==s.len&&!n))){let t=a.len;for(cc(r,a.ins,-1);t;){let n=Math.min(s.len,t);s.ins>=0&&e<s.i&&s.len<=n&&(cc(r,0,s.ins),o&&hc(o,r,s.text),e=s.i),s.forward(n),t-=n}a.next()}else{if(!(s.ins>=0)){if(s.done&&a.done)return o?lc.createSet(r,o):ac.create(r);throw new Error("Mismatched change set lengths")}{let t=0,n=s.len;for(;n;)if(-1==a.ins){let e=Math.min(n,a.len);t+=e,n-=e,a.forward(e)}else{if(!(0==a.ins&&a.len<n))break;n-=a.len,a.next()}cc(r,t,e<s.i?s.ins:0),o&&e<s.i&&hc(o,r,s.text),e=s.i,s.forward(s.len-n)}}}}function dc(e,t,n=!1){let i=[],r=n?[]:null,o=new fc(e),s=new fc(t);for(let e=!1;;){if(o.done&&s.done)return r?lc.createSet(i,r):ac.create(i);if(0==o.ins)cc(i,o.len,0,e),o.next();else if(0!=s.len||s.done){if(o.done||s.done)throw new Error("Mismatched change set lengths");{let t=Math.min(o.len2,s.len),n=i.length;if(-1==o.ins){let n=-1==s.ins?-1:s.off?0:s.ins;cc(i,t,n,e),r&&n&&hc(r,i,s.text)}else-1==s.ins?(cc(i,o.off?0:o.len,t,e),r&&hc(r,i,o.textBit(t))):(cc(i,o.off?0:o.len,s.off?0:s.ins,e),r&&!s.off&&hc(r,i,s.text));e=(o.ins>t||s.ins>=0&&s.len>t)&&(e||i.length>n),o.forward2(t),s.forward(t)}}else cc(i,0,s.ins,e),r&&hc(r,i,s.text),s.next()}}class fc{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return-2==this.ins}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?Kl.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?Kl.empty:t[n].slice(this.off,null==e?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){-1==this.ins?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class gc{constructor(e,t,n){this.from=e,this.to=t,this.flags=n}get anchor(){return 32&this.flags?this.to:this.from}get head(){return 32&this.flags?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return 8&this.flags?-1:16&this.flags?1:0}get bidiLevel(){let e=7&this.flags;return 7==e?null:e}get goalColumn(){let e=this.flags>>6;return 16777215==e?void 0:e}map(e,t=-1){let n,i;return this.empty?n=i=e.mapPos(this.from,t):(n=e.mapPos(this.from,1),i=e.mapPos(this.to,-1)),n==this.from&&i==this.to?this:new gc(n,i,this.flags)}extend(e,t=e,n=0){if(e<=this.anchor&&t>=this.anchor)return mc.range(e,t,void 0,void 0,n);let i=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return mc.range(this.anchor,i,void 0,void 0,n)}eq(e,t=!1){return!(this.anchor!=e.anchor||this.head!=e.head||this.goalColumn!=e.goalColumn||t&&this.empty&&this.assoc!=e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||"number"!=typeof e.anchor||"number"!=typeof e.head)throw new RangeError("Invalid JSON representation for SelectionRange");return mc.range(e.anchor,e.head)}static create(e,t,n){return new gc(e,t,n)}}class mc{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:mc.create(this.ranges.map(n=>n.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return 1==this.ranges.length?this:new mc([this.main],0)}addRange(e,t=!0){return mc.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let n=this.ranges.slice();return n[t]=e,mc.create(n,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||"number"!=typeof e.main||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new mc(e.ranges.map(e=>gc.fromJSON(e)),e.main)}static single(e,t=e){return new mc([mc.range(e,t)],0)}static create(e,t=0){if(0==e.length)throw new RangeError("A selection needs at least one range");for(let n=0,i=0;i<e.length;i++){let r=e[i];if(r.empty?r.from<=n:r.from<n)return mc.normalized(e.slice(),t);n=r.to}return new mc(e,t)}static cursor(e,t=0,n,i){return gc.create(e,e,(0==t?0:t<0?8:16)|(null==n?7:Math.min(6,n))|(null!=i?i:16777215)<<6)}static range(e,t,n,i,r){let o=(null!=n?n:16777215)<<6|(null==i?7:Math.min(6,i));return r||e==t||(r=t<e?1:-1),t<e?gc.create(t,e,48|o):gc.create(e,t,(r?r<0?8:16:0)|o)}static normalized(e,t=0){let n=e[t];e.sort((e,t)=>e.from-t.from),t=e.indexOf(n);for(let n=1;n<e.length;n++){let i=e[n],r=e[n-1];if(i.empty?i.from<=r.to:i.from<r.to){let o=r.from,s=Math.max(i.to,r.to);n<=t&&t--,e.splice(--n,2,i.anchor>i.head?mc.range(s,o):mc.range(o,s))}}return new mc(e,t)}}function yc(e,t){for(let n of e.ranges)if(n.to>t)throw new RangeError("Selection points outside of document")}let vc=0;class wc{constructor(e,t,n,i,r){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=i,this.id=vc++,this.default=e([]),this.extensions="function"==typeof r?r(this):r}get reader(){return this}static define(e={}){return new wc(e.combine||(e=>e),e.compareInput||((e,t)=>e===t),e.compare||(e.combine?(e,t)=>e===t:bc),!!e.static,e.enables)}of(e){return new xc([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new xc(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new xc(e,this,2,t)}from(e,t){return t||(t=e=>e),this.compute([e],n=>t(n.field(e)))}}function bc(e,t){return e==t||e.length==t.length&&e.every((e,n)=>e===t[n])}class xc{constructor(e,t,n,i){this.dependencies=e,this.facet=t,this.type=n,this.value=i,this.id=vc++}dynamicSlot(e){var t;let n=this.value,i=this.facet.compareInput,r=this.id,o=e[r]>>1,s=2==this.type,a=!1,l=!1,c=[];for(let n of this.dependencies)"doc"==n?a=!0:"selection"==n?l=!0:1&(null!==(t=e[n.id])&&void 0!==t?t:1)||c.push(e[n.id]);return{create:e=>(e.values[o]=n(e),1),update(e,t){if(a&&t.docChanged||l&&(t.docChanged||t.selection)||kc(e,c)){let t=n(e);if(s?!_c(t,e.values[o],i):!i(t,e.values[o]))return e.values[o]=t,1}return 0},reconfigure:(e,t)=>{let a,l=t.config.address[r];if(null!=l){let r=Ic(t,l);if(this.dependencies.every(n=>n instanceof wc?t.facet(n)===e.facet(n):!(n instanceof Ec)||t.field(n,!1)==e.field(n,!1))||(s?_c(a=n(e),r,i):i(a=n(e),r)))return e.values[o]=r,0}else a=n(e);return e.values[o]=a,1}}}}function _c(e,t,n){if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++)if(!n(e[i],t[i]))return!1;return!0}function kc(e,t){let n=!1;for(let i of t)1&Lc(e,i)&&(n=!0);return n}function Sc(e,t,n){let i=n.map(t=>e[t.id]),r=n.map(e=>e.type),o=i.filter(e=>!(1&e)),s=e[t.id]>>1;function a(e){let n=[];for(let t=0;t<i.length;t++){let o=Ic(e,i[t]);if(2==r[t])for(let e of o)n.push(e);else n.push(o)}return t.combine(n)}return{create(e){for(let t of i)Lc(e,t);return e.values[s]=a(e),1},update(e,n){if(!kc(e,o))return 0;let i=a(e);return t.compare(i,e.values[s])?0:(e.values[s]=i,1)},reconfigure(e,r){let o=kc(e,i),l=r.config.facets[t.id],c=r.facet(t);if(l&&!o&&bc(n,l))return e.values[s]=c,0;let h=a(e);return t.compare(h,c)?(e.values[s]=c,0):(e.values[s]=h,1)}}}const Cc=wc.define({static:!0});class Ec{constructor(e,t,n,i,r){this.id=e,this.createF=t,this.updateF=n,this.compareF=i,this.spec=r,this.provides=void 0}static define(e){let t=new Ec(vc++,e.create,e.update,e.compare||((e,t)=>e===t),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(Cc).find(e=>e.field==this);return((null==t?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:e=>(e.values[t]=this.create(e),1),update:(e,n)=>{let i=e.values[t],r=this.updateF(i,n);return this.compareF(i,r)?0:(e.values[t]=r,1)},reconfigure:(e,n)=>{let i,r=e.facet(Cc),o=n.facet(Cc);return(i=r.find(e=>e.field==this))&&i!=o.find(e=>e.field==this)?(e.values[t]=i.create(e),1):null!=n.config.address[this.id]?(e.values[t]=n.field(this),0):(e.values[t]=this.create(e),1)}}}init(e){return[this,Cc.of({field:this,create:e})]}get extension(){return this}}const Mc=4,Ac=3,Tc=2,Rc=1;function Oc(e){return t=>new qc(t,e)}const Dc={highest:Oc(0),high:Oc(Rc),default:Oc(Tc),low:Oc(Ac),lowest:Oc(Mc)};class qc{constructor(e,t){this.inner=e,this.prec=t}}class Nc{of(e){return new Bc(this,e)}reconfigure(e){return Nc.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Bc{constructor(e,t){this.compartment=e,this.inner=t}}class Pc{constructor(e,t,n,i,r,o){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=i,this.staticValues=r,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return null==t?e.default:this.staticValues[t>>1]}static resolve(e,t,n){let i=[],r=Object.create(null),o=new Map;for(let n of function(e,t,n){let i=[[],[],[],[],[]],r=new Map;function o(e,s){let a=r.get(e);if(null!=a){if(a<=s)return;let t=i[a].indexOf(e);t>-1&&i[a].splice(t,1),e instanceof Bc&&n.delete(e.compartment)}if(r.set(e,s),Array.isArray(e))for(let t of e)o(t,s);else if(e instanceof Bc){if(n.has(e.compartment))throw new RangeError("Duplicate use of compartment in extensions");let i=t.get(e.compartment)||e.inner;n.set(e.compartment,i),o(i,s)}else if(e instanceof qc)o(e.inner,e.prec);else if(e instanceof Ec)i[s].push(e),e.provides&&o(e.provides,s);else if(e instanceof xc)i[s].push(e),e.facet.extensions&&o(e.facet.extensions,Tc);else{let t=e.extension;if(!t)throw new Error(`Unrecognized extension value in extension set (${e}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);o(t,s)}}return o(e,Tc),i.reduce((e,t)=>e.concat(t))}(e,t,o))n instanceof Ec?i.push(n):(r[n.facet.id]||(r[n.facet.id]=[])).push(n);let s=Object.create(null),a=[],l=[];for(let e of i)s[e.id]=l.length<<1,l.push(t=>e.slot(t));let c=null==n?void 0:n.config.facets;for(let e in r){let t=r[e],i=t[0].facet,o=c&&c[e]||[];if(t.every(e=>0==e.type))if(s[i.id]=a.length<<1|1,bc(o,t))a.push(n.facet(i));else{let e=i.combine(t.map(e=>e.value));a.push(n&&i.compare(e,n.facet(i))?n.facet(i):e)}else{for(let e of t)0==e.type?(s[e.id]=a.length<<1|1,a.push(e.value)):(s[e.id]=l.length<<1,l.push(t=>e.dynamicSlot(t)));s[i.id]=l.length<<1,l.push(e=>Sc(e,i,t))}}let h=l.map(e=>e(s));return new Pc(e,o,h,s,a,r)}}function Lc(e,t){if(1&t)return 2;let n=t>>1,i=e.status[n];if(4==i)throw new Error("Cyclic dependency between fields and/or facets");if(2&i)return i;e.status[n]=4;let r=e.computeSlot(e,e.config.dynamicSlots[n]);return e.status[n]=2|r}function Ic(e,t){return 1&t?e.config.staticValues[t>>1]:e.values[t>>1]}const jc=wc.define(),Fc=wc.define({combine:e=>e.some(e=>e),static:!0}),Vc=wc.define({combine:e=>e.length?e[0]:void 0,static:!0}),$c=wc.define(),zc=wc.define(),Wc=wc.define(),Hc=wc.define({combine:e=>!!e.length&&e[0]});class Uc{constructor(e,t){this.type=e,this.value=t}static define(){return new Gc}}class Gc{of(e){return new Uc(this,e)}}class Kc{constructor(e){this.map=e}of(e){return new Xc(this,e)}}class Xc{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return void 0===t?void 0:t==this.value?this:new Xc(this.type,t)}is(e){return this.type==e}static define(e={}){return new Kc(e.map||(e=>e))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let i of e){let e=i.map(t);e&&n.push(e)}return n}}Xc.reconfigure=Xc.define(),Xc.appendConfig=Xc.define();class Yc{constructor(e,t,n,i,r,o){this.startState=e,this.changes=t,this.selection=n,this.effects=i,this.annotations=r,this.scrollIntoView=o,this._doc=null,this._state=null,n&&yc(n,t.newLength),r.some(e=>e.type==Yc.time)||(this.annotations=r.concat(Yc.time.of(Date.now())))}static create(e,t,n,i,r,o){return new Yc(e,t,n,i,r,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(Yc.userEvent);return!(!t||!(t==e||t.length>e.length&&t.slice(0,e.length)==e&&"."==t[e.length]))}}function Jc(e,t){let n=[];for(let i=0,r=0;;){let o,s;if(i<e.length&&(r==t.length||t[r]>=e[i]))o=e[i++],s=e[i++];else{if(!(r<t.length))return n;o=t[r++],s=t[r++]}!n.length||n[n.length-1]<o?n.push(o,s):n[n.length-1]<s&&(n[n.length-1]=s)}}function Qc(e,t,n){var i;let r,o,s;return n?(r=t.changes,o=lc.empty(t.changes.length),s=e.changes.compose(t.changes)):(r=t.changes.map(e.changes),o=e.changes.mapDesc(t.changes,!0),s=e.changes.compose(r)),{changes:s,selection:t.selection?t.selection.map(o):null===(i=e.selection)||void 0===i?void 0:i.map(r),effects:Xc.mapEffects(e.effects,r).concat(Xc.mapEffects(t.effects,o)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function Zc(e,t,n){let i=t.selection,r=nh(t.annotations);return t.userEvent&&(r=r.concat(Yc.userEvent.of(t.userEvent))),{changes:t.changes instanceof lc?t.changes:lc.of(t.changes||[],n,e.facet(Vc)),selection:i&&(i instanceof mc?i:mc.single(i.anchor,i.head)),effects:nh(t.effects),annotations:r,scrollIntoView:!!t.scrollIntoView}}function eh(e,t,n){let i=Zc(e,t.length?t[0]:{},e.doc.length);t.length&&!1===t[0].filter&&(n=!1);for(let r=1;r<t.length;r++){!1===t[r].filter&&(n=!1);let o=!!t[r].sequential;i=Qc(i,Zc(e,t[r],o?i.changes.newLength:e.doc.length),o)}let r=Yc.create(e,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return function(e){let t=e.startState,n=t.facet(Wc),i=e;for(let r=n.length-1;r>=0;r--){let o=n[r](e);o&&Object.keys(o).length&&(i=Qc(i,Zc(t,o,e.changes.newLength),!0))}return i==e?e:Yc.create(t,e.changes,e.selection,i.effects,i.annotations,i.scrollIntoView)}(n?function(e){let t=e.startState,n=!0;for(let i of t.facet($c)){let t=i(e);if(!1===t){n=!1;break}Array.isArray(t)&&(n=!0===n?t:Jc(n,t))}if(!0!==n){let i,r;if(!1===n)r=e.changes.invertedDesc,i=lc.empty(t.doc.length);else{let t=e.changes.filter(n);i=t.changes,r=t.filtered.mapDesc(t.changes).invertedDesc}e=Yc.create(t,i,e.selection&&e.selection.map(r),Xc.mapEffects(e.effects,r),e.annotations,e.scrollIntoView)}let i=t.facet(zc);for(let n=i.length-1;n>=0;n--){let r=i[n](e);e=r instanceof Yc?r:Array.isArray(r)&&1==r.length&&r[0]instanceof Yc?r[0]:eh(t,nh(r),!1)}return e}(r):r)}Yc.time=Uc.define(),Yc.userEvent=Uc.define(),Yc.addToHistory=Uc.define(),Yc.remote=Uc.define();const th=[];function nh(e){return null==e?th:Array.isArray(e)?e:[e]}var ih=function(e){return e[e.Word=0]="Word",e[e.Space=1]="Space",e[e.Other=2]="Other",e}(ih||(ih={}));const rh=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let oh;try{oh=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(e){}function sh(e){return t=>{if(!/\S/.test(t))return ih.Space;if(function(e){if(oh)return oh.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>""&&(n.toUpperCase()!=n.toLowerCase()||rh.test(n)))return!0}return!1}(t))return ih.Word;for(let n=0;n<e.length;n++)if(t.indexOf(e[n])>-1)return ih.Word;return ih.Other}}class ah{constructor(e,t,n,i,r,o){this.config=e,this.doc=t,this.selection=n,this.values=i,this.status=e.statusTemplate.slice(),this.computeSlot=r,o&&(o._state=this);for(let e=0;e<this.config.dynamicSlots.length;e++)Lc(this,e<<1);this.computeSlot=null}field(e,t=!0){let n=this.config.address[e.id];if(null!=n)return Lc(this,n),Ic(this,n);if(t)throw new RangeError("Field is not present in this state")}update(...e){return eh(this,e,!0)}applyTransaction(e){let t,n=this.config,{base:i,compartments:r}=n;for(let t of e.effects)t.is(Nc.reconfigure)?(n&&(r=new Map,n.compartments.forEach((e,t)=>r.set(t,e)),n=null),r.set(t.value.compartment,t.value.extension)):t.is(Xc.reconfigure)?(n=null,i=t.value):t.is(Xc.appendConfig)&&(n=null,i=nh(i).concat(t.value));if(n)t=e.startState.values.slice();else{n=Pc.resolve(i,r,this),t=new ah(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(e,t)=>t.reconfigure(e,this),null).values}let o=e.startState.facet(Fc)?e.newSelection:e.newSelection.asSingle();new ah(n,e.newDoc,o,t,(t,n)=>n.update(t,e),e)}replaceSelection(e){return"string"==typeof e&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:mc.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),i=this.changes(n.changes),r=[n.range],o=nh(n.effects);for(let n=1;n<t.ranges.length;n++){let s=e(t.ranges[n]),a=this.changes(s.changes),l=a.map(i);for(let e=0;e<n;e++)r[e]=r[e].map(l);let c=i.mapDesc(a,!0);r.push(s.range.map(c)),i=i.compose(l),o=Xc.mapEffects(o,l).concat(Xc.mapEffects(nh(s.effects),c))}return{changes:i,selection:mc.create(r,t.mainIndex),effects:o}}changes(e=[]){return e instanceof lc?e:lc.of(e,this.doc.length,this.facet(ah.lineSeparator))}toText(e){return Kl.of(e.split(this.facet(ah.lineSeparator)||oc))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return null==t?e.default:(Lc(this,t),Ic(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let i=e[n];i instanceof Ec&&null!=this.config.address[i.id]&&(t[n]=i.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(e,t={},n){if(!e||"string"!=typeof e.doc)throw new RangeError("Invalid JSON representation for EditorState");let i=[];if(n)for(let t in n)if(Object.prototype.hasOwnProperty.call(e,t)){let r=n[t],o=e[t];i.push(r.init(e=>r.spec.fromJSON(o,e)))}return ah.create({doc:e.doc,selection:mc.fromJSON(e.selection),extensions:t.extensions?i.concat([t.extensions]):i})}static create(e={}){let t=Pc.resolve(e.extensions||[],new Map),n=e.doc instanceof Kl?e.doc:Kl.of((e.doc||"").split(t.staticFacet(ah.lineSeparator)||oc)),i=e.selection?e.selection instanceof mc?e.selection:mc.single(e.selection.anchor,e.selection.head):mc.single(0);return yc(i,n.length),t.staticFacet(Fc)||(i=i.asSingle()),new ah(t,n,i,t.dynamicSlots.map(()=>null),(e,t)=>t.create(e),null)}get tabSize(){return this.facet(ah.tabSize)}get lineBreak(){return this.facet(ah.lineSeparator)||"\n"}get readOnly(){return this.facet(Hc)}phrase(e,...t){for(let t of this.facet(ah.phrases))if(Object.prototype.hasOwnProperty.call(t,e)){e=t[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(e,n)=>{if("$"==n)return"$";let i=+(n||1);return!i||i>t.length?e:t[i-1]})),e}languageDataAt(e,t,n=-1){let i=[];for(let r of this.facet(jc))for(let o of r(this,t,n))Object.prototype.hasOwnProperty.call(o,e)&&i.push(o[e]);return i}charCategorizer(e){let t=this.languageDataAt("wordChars",e);return sh(t.length?t[0]:"")}wordAt(e){let{text:t,from:n,length:i}=this.doc.lineAt(e),r=this.charCategorizer(e),o=e-n,s=e-n;for(;o>0;){let e=rc(t,o,!1);if(r(t.slice(e,o))!=ih.Word)break;o=e}for(;s<i;){let e=rc(t,s);if(r(t.slice(s,e))!=ih.Word)break;s=e}return o==s?null:mc.range(o+n,s+n)}}function lh(e,t,n={}){let i={};for(let t of e)for(let e of Object.keys(t)){let r=t[e],o=i[e];if(void 0===o)i[e]=r;else if(o===r||void 0===r);else{if(!Object.hasOwnProperty.call(n,e))throw new Error("Config merge conflict for field "+e);i[e]=n[e](o,r)}}for(let e in t)void 0===i[e]&&(i[e]=t[e]);return i}ah.allowMultipleSelections=Fc,ah.tabSize=wc.define({combine:e=>e.length?e[0]:4}),ah.lineSeparator=Vc,ah.readOnly=Hc,ah.phrases=wc.define({compare(e,t){let n=Object.keys(e),i=Object.keys(t);return n.length==i.length&&n.every(n=>e[n]==t[n])}}),ah.languageData=jc,ah.changeFilter=$c,ah.transactionFilter=zc,ah.transactionExtender=Wc,Nc.reconfigure=Xc.define();class ch{eq(e){return this==e}range(e,t=e){return uh.create(e,t,this)}}function hh(e,t){return e==t||e.constructor==t.constructor&&e.eq(t)}ch.prototype.startSide=ch.prototype.endSide=0,ch.prototype.point=!1,ch.prototype.mapMode=sc.TrackDel;let uh=class e{constructor(e,t,n){this.from=e,this.to=t,this.value=n}static create(t,n,i){return new e(t,n,i)}};function ph(e,t){return e.from-t.from||e.value.startSide-t.value.startSide}class dh{constructor(e,t,n,i){this.from=e,this.to=t,this.value=n,this.maxPoint=i}get length(){return this.to[this.to.length-1]}findIndex(e,t,n,i=0){let r=n?this.to:this.from;for(let o=i,s=r.length;;){if(o==s)return o;let i=o+s>>1,a=r[i]-e||(n?this.value[i].endSide:this.value[i].startSide)-t;if(i==o)return a>=0?o:s;a>=0?s=i:o=i+1}}between(e,t,n,i){for(let r=this.findIndex(t,-1e9,!0),o=this.findIndex(n,1e9,!1,r);r<o;r++)if(!1===i(this.from[r]+e,this.to[r]+e,this.value[r]))return!1}map(e,t){let n=[],i=[],r=[],o=-1,s=-1;for(let a=0;a<this.value.length;a++){let l,c,h=this.value[a],u=this.from[a]+e,p=this.to[a]+e;if(u==p){let e=t.mapPos(u,h.startSide,h.mapMode);if(null==e)continue;if(l=c=e,h.startSide!=h.endSide&&(c=t.mapPos(u,h.endSide),c<l))continue}else if(l=t.mapPos(u,h.startSide),c=t.mapPos(p,h.endSide),l>c||l==c&&h.startSide>0&&h.endSide<=0)continue;(c-l||h.endSide-h.startSide)<0||(o<0&&(o=l),h.point&&(s=Math.max(s,c-l)),n.push(h),i.push(l-o),r.push(c-o))}return{mapped:n.length?new dh(i,r,n,s):null,pos:o}}}class fh{constructor(e,t,n,i){this.chunkPos=e,this.chunk=t,this.nextLayer=n,this.maxPoint=i}static create(e,t,n,i){return new fh(e,t,n,i)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:n=!1,filterFrom:i=0,filterTo:r=this.length}=e,o=e.filter;if(0==t.length&&!o)return this;if(n&&(t=t.slice().sort(ph)),this.isEmpty)return t.length?fh.of(t):this;let s=new yh(this,null,-1).goto(0),a=0,l=[],c=new gh;for(;s.value||a<t.length;)if(a<t.length&&(s.from-t[a].from||s.startSide-t[a].value.startSide)>=0){let e=t[a++];c.addInner(e.from,e.to,e.value)||l.push(e)}else 1==s.rangeIndex&&s.chunkIndex<this.chunk.length&&(a==t.length||this.chunkEnd(s.chunkIndex)<t[a].from)&&(!o||i>this.chunkEnd(s.chunkIndex)||r<this.chunkPos[s.chunkIndex])&&c.addChunk(this.chunkPos[s.chunkIndex],this.chunk[s.chunkIndex])?s.nextChunk():((!o||i>s.to||r<s.from||o(s.from,s.to,s.value))&&(c.addInner(s.from,s.to,s.value)||l.push(uh.create(s.from,s.to,s.value))),s.next());return c.finishInner(this.nextLayer.isEmpty&&!l.length?fh.empty:this.nextLayer.update({add:l,filter:o,filterFrom:i,filterTo:r}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],n=[],i=-1;for(let r=0;r<this.chunk.length;r++){let o=this.chunkPos[r],s=this.chunk[r],a=e.touchesRange(o,o+s.length);if(!1===a)i=Math.max(i,s.maxPoint),t.push(s),n.push(e.mapPos(o));else if(!0===a){let{mapped:r,pos:a}=s.map(o,e);r&&(i=Math.max(i,r.maxPoint),t.push(r),n.push(a))}}let r=this.nextLayer.map(e);return 0==t.length?r:new fh(n,t,r||fh.empty,i)}between(e,t,n){if(!this.isEmpty){for(let i=0;i<this.chunk.length;i++){let r=this.chunkPos[i],o=this.chunk[i];if(t>=r&&e<=r+o.length&&!1===o.between(r,e-r,t-r,n))return}this.nextLayer.between(e,t,n)}}iter(e=0){return vh.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return vh.from(e).goto(t)}static compare(e,t,n,i,r=-1){let o=e.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=r),s=t.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=r),a=mh(o,s,n),l=new bh(o,a,r),c=new bh(s,a,r);n.iterGaps((e,t,n)=>xh(l,e,c,t,n,i)),n.empty&&0==n.length&&xh(l,0,c,0,0,i)}static eq(e,t,n=0,i){null==i&&(i=999999999);let r=e.filter(e=>!e.isEmpty&&t.indexOf(e)<0),o=t.filter(t=>!t.isEmpty&&e.indexOf(t)<0);if(r.length!=o.length)return!1;if(!r.length)return!0;let s=mh(r,o),a=new bh(r,s,0).goto(n),l=new bh(o,s,0).goto(n);for(;;){if(a.to!=l.to||!_h(a.active,l.active)||a.point&&(!l.point||!hh(a.point,l.point)))return!1;if(a.to>i)return!0;a.next(),l.next()}}static spans(e,t,n,i,r=-1){let o=new bh(e,null,r).goto(t),s=t,a=o.openStart;for(;;){let e=Math.min(o.to,n);if(o.point){let n=o.activeForPoint(o.to),r=o.pointFrom<t?n.length+1:o.point.startSide<0?n.length:Math.min(n.length,a);i.point(s,e,o.point,n,r,o.pointRank),a=Math.min(o.openEnd(e),n.length)}else e>s&&(i.span(s,e,o.active,a),a=o.openEnd(e));if(o.to>n)return a+(o.point&&o.to>n?1:0);s=o.to,o.next()}}static of(e,t=!1){let n=new gh;for(let i of e instanceof uh?[e]:t?function(e){if(e.length>1)for(let t=e[0],n=1;n<e.length;n++){let i=e[n];if(ph(t,i)>0)return e.slice().sort(ph);t=i}return e}(e):e)n.add(i.from,i.to,i.value);return n.finish()}static join(e){if(!e.length)return fh.empty;let t=e[e.length-1];for(let n=e.length-2;n>=0;n--)for(let i=e[n];i!=fh.empty;i=i.nextLayer)t=new fh(i.chunkPos,i.chunk,t,Math.max(i.maxPoint,t.maxPoint));return t}}fh.empty=new fh([],[],null,-1),fh.empty.nextLayer=fh.empty;class gh{finishChunk(e){this.chunks.push(new dh(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,n){this.addInner(e,t,n)||(this.nextLayer||(this.nextLayer=new gh)).add(e,t,n)}addInner(e,t,n){let i=e-this.lastTo||n.startSide-this.last.endSide;if(i<=0&&(e-this.lastFrom||n.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return!(i<0)&&(250==this.from.length&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=n,this.lastFrom=e,this.lastTo=t,this.value.push(n),n.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let n=t.value.length-1;return this.last=t.value[n],this.lastFrom=t.from[n]+e,this.lastTo=t.to[n]+e,!0}finish(){return this.finishInner(fh.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return e;let t=fh.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function mh(e,t,n){let i=new Map;for(let t of e)for(let e=0;e<t.chunk.length;e++)t.chunk[e].maxPoint<=0&&i.set(t.chunk[e],t.chunkPos[e]);let r=new Set;for(let e of t)for(let t=0;t<e.chunk.length;t++){let o=i.get(e.chunk[t]);null==o||(n?n.mapPos(o):o)!=e.chunkPos[t]||(null==n?void 0:n.touchesRange(o,o+e.chunk[t].length))||r.add(e.chunk[t])}return r}class yh{constructor(e,t,n,i=0){this.layer=e,this.skip=t,this.minPoint=n,this.rank=i}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,n){for(;this.chunkIndex<this.layer.chunk.length;){let t=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(t)||this.layer.chunkEnd(this.chunkIndex)<e||t.maxPoint<this.minPoint))break;this.chunkIndex++,n=!1}if(this.chunkIndex<this.layer.chunk.length){let i=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!n||this.rangeIndex<i)&&this.setRangeIndex(i)}this.next()}forward(e,t){(this.to-e||this.endSide-t)<0&&this.gotoInner(e,t,!0)}next(){for(;;){if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],n=e+t.from[this.rangeIndex];if(this.from=n,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}}class vh{constructor(e){this.heap=e}static from(e,t=null,n=-1){let i=[];for(let r=0;r<e.length;r++)for(let o=e[r];!o.isEmpty;o=o.nextLayer)o.maxPoint>=n&&i.push(new yh(o,t,n,r));return 1==i.length?i[0]:new vh(i)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let n of this.heap)n.goto(e,t);for(let e=this.heap.length>>1;e>=0;e--)wh(this.heap,e);return this.next(),this}forward(e,t){for(let n of this.heap)n.forward(e,t);for(let e=this.heap.length>>1;e>=0;e--)wh(this.heap,e);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(0==this.heap.length)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),wh(this.heap,0)}}}function wh(e,t){for(let n=e[t];;){let i=1+(t<<1);if(i>=e.length)break;let r=e[i];if(i+1<e.length&&r.compare(e[i+1])>=0&&(r=e[i+1],i++),n.compare(r)<0)break;e[i]=n,e[t]=r,t=i}}class bh{constructor(e,t,n){this.minPoint=n,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=vh.from(e,t,n)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){kh(this.active,e),kh(this.activeTo,e),kh(this.activeRank,e),this.minActive=Ch(this.active,this.activeTo)}addActive(e){let t=0,{value:n,to:i,rank:r}=this.cursor;for(;t<this.activeRank.length&&(r-this.activeRank[t]||i-this.activeTo[t])>0;)t++;Sh(this.active,t,n),Sh(this.activeTo,t,i),Sh(this.activeRank,t,r),e&&Sh(e,t,this.cursor.from),this.minActive=Ch(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let n=this.openStart<0?[]:null;for(;;){let i=this.minActive;if(i>-1&&(this.activeTo[i]-this.cursor.from||this.active[i].endSide-this.cursor.startSide)<0){if(this.activeTo[i]>e){this.to=this.activeTo[i],this.endSide=this.active[i].endSide;break}this.removeActive(i),n&&kh(n,i)}else{if(!this.cursor.value){this.to=this.endSide=1e9;break}if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}{let e=this.cursor.value;if(e.point){if(!(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)){this.point=e,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=e.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}this.cursor.next()}else this.addActive(n),this.cursor.next()}}}if(n){this.openStart=0;for(let t=n.length-1;t>=0&&n[t]<e;t--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let n=this.active.length-1;n>=0&&!(this.activeRank[n]<this.pointRank);n--)(this.activeTo[n]>e||this.activeTo[n]==e&&this.active[n].endSide>=this.point.endSide)&&t.push(this.active[n]);return t.reverse()}openEnd(e){let t=0;for(let n=this.activeTo.length-1;n>=0&&this.activeTo[n]>e;n--)t++;return t}}function xh(e,t,n,i,r,o){e.goto(t),n.goto(i);let s=i+r,a=i,l=i-t,c=!!o.boundChange;for(let t=!1;;){let i=e.to+l-n.to,r=i||e.endSide-n.endSide,h=r<0?e.to+l:n.to,u=Math.min(h,s);if(e.point||n.point?(e.point&&n.point&&hh(e.point,n.point)&&_h(e.activeForPoint(e.to),n.activeForPoint(n.to))||o.comparePoint(a,u,e.point,n.point),t=!1):(t&&o.boundChange(a),u>a&&!_h(e.active,n.active)&&o.compareRange(a,u,e.active,n.active),c&&u<s&&(i||e.openEnd(h)!=n.openEnd(h))&&(t=!0)),h>s)break;a=h,r<=0&&e.next(),r>=0&&n.next()}}function _h(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n]&&!hh(e[n],t[n]))return!1;return!0}function kh(e,t){for(let n=t,i=e.length-1;n<i;n++)e[n]=e[n+1];e.pop()}function Sh(e,t,n){for(let n=e.length-1;n>=t;n--)e[n+1]=e[n];e[t]=n}function Ch(e,t){let n=-1,i=1e9;for(let r=0;r<t.length;r++)(t[r]-i||e[r].endSide-e[n].endSide)<0&&(n=r,i=t[r]);return n}const Eh="undefined"==typeof Symbol?"__ͼ":Symbol.for("ͼ"),Mh="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),Ah="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class Th{constructor(e,t){this.rules=[];let{finish:n}=t||{};function i(e){return/^@/.test(e)?[e]:e.split(/,\s*/)}function r(e,t,o,s){let a=[],l=/^@(\w+)\b/.exec(e[0]),c=l&&"keyframes"==l[1];if(l&&null==t)return o.push(e[0]+";");for(let n in t){let s=t[n];if(/&/.test(n))r(n.split(/,\s*/).map(t=>e.map(e=>t.replace(/&/,e))).reduce((e,t)=>e.concat(t)),s,o);else if(s&&"object"==typeof s){if(!l)throw new RangeError("The value of a property ("+n+") should be a primitive value.");r(i(n),s,a,c)}else null!=s&&a.push(n.replace(/_.*/,"").replace(/[A-Z]/g,e=>"-"+e.toLowerCase())+": "+s+";")}(a.length||c)&&o.push((!n||l||s?e:e.map(n)).join(", ")+" {"+a.join(" ")+"}")}for(let t in e)r(i(t),e[t],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let e=Ah[Eh]||1;return Ah[Eh]=e+1,"ͼ"+e.toString(36)}static mount(e,t,n){let i=e[Mh],r=n&&n.nonce;i?r&&i.setNonce(r):i=new Oh(e,r),i.mount(Array.isArray(t)?t:[t],e)}}let Rh=new Map;class Oh{constructor(e,t){let n=e.ownerDocument||e,i=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&i.CSSStyleSheet){let t=Rh.get(n);if(t)return e[Mh]=t;this.sheet=new i.CSSStyleSheet,Rh.set(n,this)}else this.styleTag=n.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[Mh]=this}mount(e,t){let n=this.sheet,i=0,r=0;for(let t=0;t<e.length;t++){let o=e[t],s=this.modules.indexOf(o);if(s<r&&s>-1&&(this.modules.splice(s,1),r--,s=-1),-1==s){if(this.modules.splice(r++,0,o),n)for(let e=0;e<o.rules.length;e++)n.insertRule(o.rules[e],i++)}else{for(;r<s;)i+=this.modules[r++].rules.length;i+=o.rules.length,r++}}if(n)t.adoptedStyleSheets.indexOf(this.sheet)<0&&(t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets]);else{let e="";for(let t=0;t<this.modules.length;t++)e+=this.modules[t].getRules()+"\n";this.styleTag.textContent=e;let n=t.head||t;this.styleTag.parentNode!=n&&n.insertBefore(this.styleTag,n.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}}for(var Dh={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},qh={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Nh=0;Nh<10;Nh++)Dh[48+Nh]=Dh[96+Nh]=String(Nh);for(Nh=1;Nh<=24;Nh++)Dh[Nh+111]="F"+Nh;for(Nh=65;Nh<=90;Nh++)Dh[Nh]=String.fromCharCode(Nh+32),qh[Nh]=String.fromCharCode(Nh);for(var Bh in Dh)qh.hasOwnProperty(Bh)||(qh[Bh]=Dh[Bh]);let Ph="undefined"!=typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},Lh="undefined"!=typeof document?document:{documentElement:{style:{}}};const Ih=/Edge\/(\d+)/.exec(Ph.userAgent),jh=/MSIE \d/.test(Ph.userAgent),Fh=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ph.userAgent),Vh=!!(jh||Fh||Ih),$h=!Vh&&/gecko\/(\d+)/i.test(Ph.userAgent),zh=!Vh&&/Chrome\/(\d+)/.exec(Ph.userAgent),Wh="webkitFontSmoothing"in Lh.documentElement.style,Hh=!Vh&&/Apple Computer/.test(Ph.vendor),Uh=Hh&&(/Mobile\/\w+/.test(Ph.userAgent)||Ph.maxTouchPoints>2);var Gh={mac:Uh||/Mac/.test(Ph.platform),ie:Vh,ie_version:jh?Lh.documentMode||6:Fh?+Fh[1]:Ih?+Ih[1]:0,gecko:$h,gecko_version:$h?+(/Firefox\/(\d+)/.exec(Ph.userAgent)||[0,0])[1]:0,chrome:!!zh,chrome_version:zh?+zh[1]:0,ios:Uh,android:/Android\b/.test(Ph.userAgent),webkit_version:Wh?+(/\bAppleWebKit\/(\d+)/.exec(Ph.userAgent)||[0,0])[1]:0,safari:Hh,safari_version:Hh?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Ph.userAgent)||[0,0])[1]:0,tabSize:null!=Lh.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};function Kh(e,t){for(let n in e)"class"==n&&t.class?t.class+=" "+e.class:"style"==n&&t.style?t.style+=";"+e.style:t[n]=e[n];return t}const Xh=Object.create(null);function Yh(e,t,n){if(e==t)return!0;e||(e=Xh),t||(t=Xh);let i=Object.keys(e),r=Object.keys(t);if(i.length-0!=r.length-0)return!1;for(let o of i)if(o!=n&&(-1==r.indexOf(o)||e[o]!==t[o]))return!1;return!0}function Jh(e,t,n){let i=!1;if(t)for(let r in t)n&&r in n||(i=!0,"style"==r?e.style.cssText="":e.removeAttribute(r));if(n)for(let r in n)t&&t[r]==n[r]||(i=!0,"style"==r?e.style.cssText=n[r]:e.setAttribute(r,n[r]));return i}function Qh(e){let t=Object.create(null);for(let n=0;n<e.attributes.length;n++){let i=e.attributes[n];t[i.name]=i.value}return t}class Zh{eq(e){return!1}updateDOM(e,t,n){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,n){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}}var eu=function(e){return e[e.Text=0]="Text",e[e.WidgetBefore=1]="WidgetBefore",e[e.WidgetAfter=2]="WidgetAfter",e[e.WidgetRange=3]="WidgetRange",e}(eu||(eu={}));class tu extends ch{constructor(e,t,n,i){super(),this.startSide=e,this.endSide=t,this.widget=n,this.spec=i}get heightRelevant(){return!1}static mark(e){return new nu(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),n=!!e.block;return t+=n&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new ru(e,t,t,n,e.widget||null,!1)}static replace(e){let t,n,i=!!e.block;if(e.isBlockGap)t=-5e8,n=4e8;else{let{start:r,end:o}=ou(e,i);t=(r?i?-3e8:-1:5e8)-1,n=1+(o?i?2e8:1:-6e8)}return new ru(e,t,n,i,e.widget||null,!0)}static line(e){return new iu(e)}static set(e,t=!1){return fh.of(e,t)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}tu.none=fh.empty;class nu extends tu{constructor(e){let{start:t,end:n}=ou(e);super(t?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?Kh(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||Xh}eq(e){return this==e||e instanceof nu&&this.tagName==e.tagName&&Yh(this.attrs,e.attrs)}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}}nu.prototype.point=!1;class iu extends tu{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof iu&&this.spec.class==e.spec.class&&Yh(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}}iu.prototype.mapMode=sc.TrackBefore,iu.prototype.point=!0;class ru extends tu{constructor(e,t,n,i,r,o){super(t,n,r,e),this.block=i,this.isReplace=o,this.mapMode=i?t<=0?sc.TrackBefore:sc.TrackAfter:sc.TrackDel}get type(){return this.startSide!=this.endSide?eu.WidgetRange:this.startSide<=0?eu.WidgetBefore:eu.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof ru&&(t=this.widget,n=e.widget,t==n||!!(t&&n&&t.compare(n)))&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide;var t,n}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}}function ou(e,t=!1){let{inclusiveStart:n,inclusiveEnd:i}=e;return null==n&&(n=e.inclusive),null==i&&(i=e.inclusive),{start:null!=n?n:t,end:null!=i?i:t}}function su(e,t,n,i=0){let r=n.length-1;r>=0&&n[r]+i>=e?n[r]=Math.max(n[r],t):n.push(e,t)}ru.prototype.point=!0;class au extends ch{constructor(e,t,n){super(),this.tagName=e,this.attributes=t,this.rank=n}eq(e){return e==this||e instanceof au&&this.tagName==e.tagName&&Yh(this.attributes,e.attributes)}static create(e){return new au(e.tagName,e.attributes||Xh,null==e.rank?50:Math.max(0,Math.min(e.rank,100)))}static set(e,t=!1){return fh.of(e,t)}}function lu(e){let t;return t=11==e.nodeType?e.getSelection?e:e.ownerDocument:e,t.getSelection()}function cu(e,t){return!!t&&(e==t||e.contains(1!=t.nodeType?t.parentNode:t))}function hu(e,t){if(!t.anchorNode)return!1;try{return cu(e,t.anchorNode)}catch(e){return!1}}function uu(e){return 3==e.nodeType?Cu(e,0,e.nodeValue.length).getClientRects():1==e.nodeType?e.getClientRects():[]}function pu(e,t,n,i){return!!n&&(gu(e,t,n,i,-1)||gu(e,t,n,i,1))}function du(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t}function fu(e){return 1==e.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(e.nodeName)}function gu(e,t,n,i,r){for(;;){if(e==n&&t==i)return!0;if(t==(r<0?0:mu(e))){if("DIV"==e.nodeName)return!1;let n=e.parentNode;if(!n||1!=n.nodeType)return!1;t=du(e)+(r<0?0:1),e=n}else{if(1!=e.nodeType)return!1;if(1==(e=e.childNodes[t+(r<0?-1:0)]).nodeType&&"false"==e.contentEditable)return!1;t=r<0?mu(e):0}}}function mu(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function yu(e,t){let n=t?e.left:e.right;return{left:n,right:n,top:e.top,bottom:e.bottom}}function vu(e){let t=e.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.innerWidth,top:0,bottom:e.innerHeight}}function wu(e,t){let n=t.width/e.offsetWidth,i=t.height/e.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(t.width-e.offsetWidth)<1)&&(n=1),(i>.995&&i<1.005||!isFinite(i)||Math.abs(t.height-e.offsetHeight)<1)&&(i=1),{scaleX:n,scaleY:i}}function bu(e,t=!0){let n=e.ownerDocument,i=null,r=null;for(let o=e.parentNode;o&&(o!=n.body&&(t&&!i||!r));)if(1==o.nodeType)!r&&o.scrollHeight>o.clientHeight&&(r=o),t&&!i&&o.scrollWidth>o.clientWidth&&(i=o),o=o.assignedSlot||o.parentNode;else{if(11!=o.nodeType)break;o=o.host}return{x:i,y:r}}au.prototype.startSide=au.prototype.endSide=-1;class xu{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:n}=e;this.set(t,Math.min(e.anchorOffset,t?mu(t):0),n,Math.min(e.focusOffset,n?mu(n):0))}set(e,t,n,i){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=i}}let _u,ku=null;function Su(e){if(e.setActive)return e.setActive();if(ku)return e.focus(ku);let t=[];for(let n=e;n&&(t.push(n,n.scrollTop,n.scrollLeft),n!=n.ownerDocument);n=n.parentNode);if(e.focus(null==ku?{get preventScroll(){return ku={preventScroll:!0},!0}}:void 0),!ku){ku=!1;for(let e=0;e<t.length;){let n=t[e++],i=t[e++],r=t[e++];n.scrollTop!=i&&(n.scrollTop=i),n.scrollLeft!=r&&(n.scrollLeft=r)}}}function Cu(e,t,n=t){let i=_u||(_u=document.createRange());return i.setEnd(e,n),i.setStart(e,t),i}function Eu(e,t,n,i){let r={key:t,code:t,keyCode:n,which:n,cancelable:!0};i&&({altKey:r.altKey,ctrlKey:r.ctrlKey,shiftKey:r.shiftKey,metaKey:r.metaKey}=i);let o=new KeyboardEvent("keydown",r);o.synthetic=!0,e.dispatchEvent(o);let s=new KeyboardEvent("keyup",r);return s.synthetic=!0,e.dispatchEvent(s),o.defaultPrevented||s.defaultPrevented}function Mu(e){return e instanceof Window?e.pageYOffset>Math.max(0,e.document.documentElement.scrollHeight-e.innerHeight-4):e.scrollTop>Math.max(1,e.scrollHeight-e.clientHeight-4)}function Au(e,t){for(let n=e,i=t;;){if(3==n.nodeType&&i>0)return{node:n,offset:i};if(1==n.nodeType&&i>0){if("false"==n.contentEditable)return null;n=n.childNodes[i-1],i=mu(n)}else{if(!n.parentNode||fu(n))return null;i=du(n),n=n.parentNode}}}function Tu(e,t){for(let n=e,i=t;;){if(3==n.nodeType&&i<n.nodeValue.length)return{node:n,offset:i};if(1==n.nodeType&&i<n.childNodes.length){if("false"==n.contentEditable)return null;n=n.childNodes[i],i=0}else{if(!n.parentNode||fu(n))return null;i=du(n)+1,n=n.parentNode}}}Gh.safari&&Gh.safari_version>=26&&(ku=!1);class Ru{constructor(e,t,n=!0){this.node=e,this.offset=t,this.precise=n}static before(e,t){return new Ru(e.parentNode,du(e),t)}static after(e,t){return new Ru(e.parentNode,du(e)+1,t)}}var Ou=function(e){return e[e.LTR=0]="LTR",e[e.RTL=1]="RTL",e}(Ou||(Ou={}));const Du=Ou.LTR,qu=Ou.RTL;function Nu(e){let t=[];for(let n=0;n<e.length;n++)t.push(1<<+e[n]);return t}const Bu=Nu("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),Pu=Nu("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),Lu=Object.create(null),Iu=[];for(let e of["()","[]","{}"]){let t=e.charCodeAt(0),n=e.charCodeAt(1);Lu[t]=n,Lu[n]=-t}function ju(e){return e<=247?Bu[e]:1424<=e&&e<=1524?2:1536<=e&&e<=1785?Pu[e-1536]:1774<=e&&e<=2220?4:8192<=e&&e<=8204?256:64336<=e&&e<=65023?4:1}const Fu=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class Vu{get dir(){return this.level%2?qu:Du}constructor(e,t,n){this.from=e,this.to=t,this.level=n}side(e,t){return this.dir==t==e?this.to:this.from}forward(e,t){return e==(this.dir==t)}static find(e,t,n,i){let r=-1;for(let o=0;o<e.length;o++){let s=e[o];if(s.from<=t&&s.to>=t){if(s.level==n)return o;(r<0||(0!=i?i<0?s.from<t:s.to>t:e[r].level>s.level))&&(r=o)}}if(r<0)throw new RangeError("Index out of range");return r}}function $u(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let i=e[n],r=t[n];if(i.from!=r.from||i.to!=r.to||i.direction!=r.direction||!$u(i.inner,r.inner))return!1}return!0}const zu=[];function Wu(e,t,n,i,r,o,s){let a=i%2?2:1;if(i%2==r%2)for(let l=t,c=0;l<n;){let t=!0,h=!1;if(c==o.length||l<o[c].from){let e=zu[l];e!=a&&(t=!1,h=16==e)}let u=t||1!=a?null:[],p=t?i:i+1,d=l;e:for(;;)if(c<o.length&&d==o[c].from){if(h)break e;let f=o[c];if(!t)for(let e=f.to,t=c+1;;){if(e==n)break e;if(!(t<o.length&&o[t].from==e)){if(zu[e]==a)break e;break}e=o[t++].to}if(c++,u)u.push(f);else{f.from>l&&s.push(new Vu(l,f.from,p)),Hu(e,f.direction==Du!=!(p%2)?i+1:i,r,f.inner,f.from,f.to,s),l=f.to}d=f.to}else{if(d==n||(t?zu[d]!=a:zu[d]==a))break;d++}u?Wu(e,l,d,i+1,r,u,s):l<d&&s.push(new Vu(l,d,p)),l=d}else for(let l=n,c=o.length;l>t;){let n=!0,h=!1;if(!c||l>o[c-1].to){let e=zu[l-1];e!=a&&(n=!1,h=16==e)}let u=n||1!=a?null:[],p=n?i:i+1,d=l;e:for(;;)if(c&&d==o[c-1].to){if(h)break e;let f=o[--c];if(!n)for(let e=f.from,n=c;;){if(e==t)break e;if(!n||o[n-1].to!=e){if(zu[e-1]==a)break e;break}e=o[--n].from}if(u)u.push(f);else{f.to<l&&s.push(new Vu(f.to,l,p)),Hu(e,f.direction==Du!=!(p%2)?i+1:i,r,f.inner,f.from,f.to,s),l=f.from}d=f.from}else{if(d==t||(n?zu[d-1]!=a:zu[d-1]==a))break;d--}u?Wu(e,d,l,i+1,r,u,s):d<l&&s.push(new Vu(d,l,p)),l=d}}function Hu(e,t,n,i,r,o,s){let a=t%2?2:1;!function(e,t,n,i,r){for(let o=0;o<=i.length;o++){let s=o?i[o-1].to:t,a=o<i.length?i[o].from:n,l=o?256:r;for(let t=s,n=l,i=l;t<a;t++){let r=ju(e.charCodeAt(t));512==r?r=n:8==r&&4==i&&(r=16),zu[t]=4==r?2:r,7&r&&(i=r),n=r}for(let e=s,t=l,i=l;e<a;e++){let r=zu[e];if(128==r)e<a-1&&t==zu[e+1]&&24&t?r=zu[e]=t:zu[e]=256;else if(64==r){let r=e+1;for(;r<a&&64==zu[r];)r++;let o=e&&8==t||r<n&&8==zu[r]?1==i?1:8:256;for(let t=e;t<r;t++)zu[t]=o;e=r-1}else 8==r&&1==i&&(zu[e]=1);t=r,7&r&&(i=r)}}}(e,r,o,i,a),function(e,t,n,i,r){let o=1==r?2:1;for(let s=0,a=0,l=0;s<=i.length;s++){let c=s?i[s-1].to:t,h=s<i.length?i[s].from:n;for(let t,n,i,s=c;s<h;s++)if(n=Lu[t=e.charCodeAt(s)])if(n<0){for(let e=a-3;e>=0;e-=3)if(Iu[e+1]==-n){let t=Iu[e+2],n=2&t?r:4&t?1&t?o:r:0;n&&(zu[s]=zu[Iu[e]]=n),a=e;break}}else{if(189==Iu.length)break;Iu[a++]=s,Iu[a++]=t,Iu[a++]=l}else if(2==(i=zu[s])||1==i){let e=i==r;l=e?0:1;for(let t=a-3;t>=0;t-=3){let n=Iu[t+2];if(2&n)break;if(e)Iu[t+2]|=2;else{if(4&n)break;Iu[t+2]|=4}}}}}(e,r,o,i,a),function(e,t,n,i){for(let r=0,o=i;r<=n.length;r++){let s=r?n[r-1].to:e,a=r<n.length?n[r].from:t;for(let l=s;l<a;){let s=zu[l];if(256==s){let s=l+1;for(;;)if(s==a){if(r==n.length)break;s=n[r++].to,a=r<n.length?n[r].from:t}else{if(256!=zu[s])break;s++}let c=1==o,h=c==(1==(s<t?zu[s]:i))?c?1:2:i;for(let t=s,i=r,o=i?n[i-1].to:e;t>l;)t==o&&(t=n[--i].from,o=i?n[i-1].to:e),zu[--t]=h;l=s}else o=s,l++}}}(r,o,i,a),Wu(e,r,o,t,n,i,s)}function Uu(e){return[new Vu(0,e,0)]}let Gu="";function Ku(e,t,n,i,r){var o;let s=i.head-e.from,a=Vu.find(t,s,null!==(o=i.bidiLevel)&&void 0!==o?o:-1,i.assoc),l=t[a],c=l.side(r,n);if(s==c){let e=a+=r?1:-1;if(e<0||e>=t.length)return null;l=t[a=e],s=l.side(!r,n),c=l.side(r,n)}let h=rc(e.text,s,l.forward(r,n));(h<l.from||h>l.to)&&(h=c),Gu=e.text.slice(Math.min(s,h),Math.max(s,h));let u=a==(r?t.length-1:0)?null:t[a+(r?1:-1)];return u&&h==c&&u.level+(r?0:1)<l.level?mc.cursor(u.side(!r,n)+e.from,u.forward(r,n)?1:-1,u.level):mc.cursor(h+e.from,l.forward(r,n)?-1:1,l.level)}function Xu(e,t,n){for(let i=t;i<n;i++){let t=ju(e.charCodeAt(i));if(1==t)return Du;if(2==t||4==t)return qu}return Du}const Yu=wc.define(),Ju=wc.define(),Qu=wc.define(),Zu=wc.define(),ep=wc.define(),tp=wc.define(),np=wc.define(),ip=wc.define(),rp=wc.define(),op=wc.define({combine:e=>e.some(e=>e)}),sp=wc.define({combine:e=>e.some(e=>e)}),ap=wc.define();class lp{constructor(e,t,n,i,r,o=!1){this.range=e,this.y=t,this.x=n,this.yMargin=i,this.xMargin=r,this.isSnapshot=o}map(e){return e.empty?this:new lp(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new lp(mc.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const cp=Xc.define({map:(e,t)=>e.map(t)}),hp=Xc.define();function up(e,t,n){let i=e.facet(Zu);i.length?i[0](t):window.onerror&&window.onerror(String(t),n,void 0,void 0,t)||(n?console.error(n+":",t):console.error(t))}const pp=wc.define({combine:e=>!e.length||e[0]});let dp=0;const fp=wc.define({combine:e=>e.filter((t,n)=>{for(let i=0;i<n;i++)if(e[i].plugin==t.plugin)return!1;return!0})});class gp{constructor(e,t,n,i,r){this.id=e,this.create=t,this.domEventHandlers=n,this.domEventObservers=i,this.baseExtensions=r(this),this.extension=this.baseExtensions.concat(fp.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(fp.of({plugin:this,arg:e}))}static define(e,t){const{eventHandlers:n,eventObservers:i,provide:r,decorations:o}=t||{};return new gp(dp++,e,n,i,e=>{let t=[];return o&&t.push(wp.of(t=>{let n=t.plugin(e);return n?o(n):tu.none})),r&&t.push(r(e)),t})}static fromClass(e,t){return gp.define((t,n)=>new e(t,n),t)}}class mp{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let e=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(e)}catch(t){if(up(e.state,t,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(e){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){up(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(null===(t=this.value)||void 0===t?void 0:t.destroy)try{this.value.destroy()}catch(t){up(e.state,t,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const yp=wc.define(),vp=wc.define(),wp=wc.define(),bp=wc.define(),xp=wc.define(),_p=wc.define(),kp=wc.define();function Sp(e,t){let n=e.state.facet(kp);if(!n.length)return n;let i=n.map(t=>t instanceof Function?t(e):t),r=[];return fh.spans(i,t.from,t.to,{point(){},span(e,n,i,o){let s=e-t.from,a=n-t.from,l=r;for(let e=i.length-1;e>=0;e--,o--){let n,r=i[e].spec.bidiIsolate;if(null==r&&(r=Xu(t.text,s,a)),o>0&&l.length&&(n=l[l.length-1]).to==s&&n.direction==r)n.to=a,l=n.inner;else{let e={from:s,to:a,direction:r,inner:[]};l.push(e),l=e.inner}}}}),r}const Cp=wc.define();function Ep(e){let t=0,n=0,i=0,r=0;for(let o of e.state.facet(Cp)){let s=o(e);s&&(null!=s.left&&(t=Math.max(t,s.left)),null!=s.right&&(n=Math.max(n,s.right)),null!=s.top&&(i=Math.max(i,s.top)),null!=s.bottom&&(r=Math.max(r,s.bottom)))}return{left:t,right:n,top:i,bottom:r}}const Mp=wc.define();class Ap{constructor(e,t,n,i){this.fromA=e,this.toA=t,this.fromB=n,this.toB=i}join(e){return new Ap(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,n=this;for(;t>0;t--){let i=e[t-1];if(!(i.fromA>n.toA)){if(i.toA<n.fromA)break;n=n.join(i),e.splice(t-1,1)}}return e.splice(t,0,n),e}static extendWithRanges(e,t){if(0==t.length)return e;let n=[];for(let i=0,r=0,o=0;;){let s=i<e.length?e[i].fromB:1e9,a=r<t.length?t[r]:1e9,l=Math.min(s,a);if(1e9==l)break;let c=l+o,h=l,u=c;for(;;)if(r<t.length&&t[r]<=h){let n=t[r+1];r+=2,h=Math.max(h,n);for(let t=i;t<e.length&&e[t].fromB<=h;t++)o=e[t].toA-e[t].toB;u=Math.max(u,n+o)}else{if(!(i<e.length&&e[i].fromB<=h))break;{let t=e[i++];h=Math.max(h,t.toB),u=Math.max(u,t.toA),o=t.toA-t.toB}}n.push(new Ap(c,u,l,h))}return n}}class Tp{constructor(e,t,n){this.view=e,this.state=t,this.transactions=n,this.flags=0,this.startState=e.state,this.changes=lc.empty(this.startState.doc.length);for(let e of n)this.changes=this.changes.compose(e.changes);let i=[];this.changes.iterChangedRanges((e,t,n,r)=>i.push(new Ap(e,t,n,r))),this.changedRanges=i}static create(e,t,n){return new Tp(e,t,n)}get viewportChanged(){return(4&this.flags)>0}get viewportMoved(){return(8&this.flags)>0}get heightChanged(){return(2&this.flags)>0}get geometryChanged(){return this.docChanged||(18&this.flags)>0}get focusChanged(){return(1&this.flags)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return 0==this.flags&&0==this.transactions.length}}const Rp=[];class Op{constructor(e,t,n=0){this.dom=e,this.length=t,this.flags=n,this.parent=null,e.cmTile=this}get breakAfter(){return 1&this.flags}get children(){return Rp}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,4&this.flags){this.flags&=-5;let e=this.domAttrs;e&&function(e,t){for(let n=e.attributes.length-1;n>=0;n--){let i=e.attributes[n].name;null==t[i]&&e.removeAttribute(i)}for(let n in t){let i=t[n];"style"==n?e.style.cssText=i:e.getAttribute(n)!=i&&e.setAttribute(n,i)}}(this.dom,e)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,t=this.posAtStart){let n=t;for(let t of this.children){if(t==e)return n;n+=t.length+t.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,t){return null}domPosFor(e,t){let n=du(this.dom),i=this.length?e>0:t>0;return new Ru(this.parent.dom,n+(i?1:0),0==e||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&2&this.parent.flags&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof Np)return e;return null}static get(e){return e.cmTile}}class Dp extends Op{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(2&this.flags)return;super.sync(e);let t,n=this.dom,i=null,r=(null==e?void 0:e.node)==n?e:null,o=0;for(let s of this.children){if(s.sync(e),o+=s.length+s.breakAfter,t=i?i.nextSibling:n.firstChild,r&&t!=s.dom&&(r.written=!0),s.dom.parentNode==n)for(;t&&t!=s.dom;)t=qp(t);else n.insertBefore(s.dom,t);i=s.dom}for(t=i?i.nextSibling:n.firstChild,r&&t&&(r.written=!0);t;)t=qp(t);this.length=o}}function qp(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}class Np extends Dp{constructor(e,t){super(t),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let t=Op.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],n=this,i=0,r=0;;)if(i==n.children.length){if(!t.length)return;n=n.parent,n.breakAfter&&r++,i=t.pop()}else{let o=n.children[i++];if(o instanceof Bp)t.push(i),n=o,i=0;else{let t=r+o.length,n=e(o,r);if(void 0!==n)return n;r=t+o.breakAfter}}}resolveBlock(e,t){let n,i,r=-1,o=-1;if(this.blockTiles((s,a)=>{let l=a+s.length;if(e>=a&&e<=l){if(s.isWidget()&&t>=-1&&t<=1){if(32&s.flags)return!0;16&s.flags&&(n=void 0)}(a<e||e==l&&(t<-1?s.length:s.covers(1)))&&(!n||!s.isWidget()&&n.isWidget())&&(n=s,r=e-a),(l>e||e==a&&(t>1?s.length:s.covers(-1)))&&(!i||!s.isWidget()&&i.isWidget())&&(i=s,o=e-a)}}),!n&&!i)throw new Error("No tile at position "+e);return n&&t<0||!i?{tile:n,offset:r}:{tile:i,offset:o}}}class Bp extends Dp{constructor(e,t){super(e),this.wrapper=t}isBlock(){return!0}covers(e){return!!this.children.length&&(e<0?this.children[0].covers(-1):this.lastChild.covers(1))}get domAttrs(){return this.wrapper.attributes}static of(e,t){let n=new Bp(t||document.createElement(e.tagName),e);return t||(n.flags|=4),n}}class Pp extends Dp{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(e,t,n){let i=new Pp(t||document.createElement("div"),e);return t&&n||(i.flags|=4),i}get domAttrs(){return this.attrs}resolveInline(e,t,n){let i=null,r=-1,o=null,s=-1;!function e(a,l){for(let c=0,h=0;c<a.children.length&&h<=l;c++){let u=a.children[c],p=h+u.length;p>=l&&(u.isComposite()?e(u,l-h):(!o||o.isHidden&&(t>0||n&&Lp(o,u)))&&(p>l||32&u.flags)?(o=u,s=l-h):(h<l||16&u.flags&&!u.isHidden)&&(i=u,r=l-h)),h=p}}(this,e);let a=(t<0?i:o)||i||o;return a?{tile:a,offset:a==i?r:s}:null}coordsIn(e,t){let n=this.resolveInline(e,t,!0);return n?n.tile.coordsIn(Math.max(0,n.offset),t):function(e){let t=e.dom.lastChild;if(!t)return e.dom.getBoundingClientRect();let n=uu(t);return n[n.length-1]||null}(this)}domIn(e,t){let n=this.resolveInline(e,t);if(n){let{tile:e,offset:i}=n;if(this.dom.contains(e.dom))return e.isText()?new Ru(e.dom,Math.min(e.dom.nodeValue.length,i)):e.domPosFor(i,16&e.flags?1:32&e.flags?-1:t);let r=n.tile.parent,o=!1;for(let e of r.children){if(o)return new Ru(e.dom,0);e==n.tile&&(o=!0)}}return new Ru(this.dom,0)}}function Lp(e,t){let n=e.coordsIn(0,1),i=t.coordsIn(0,1);return n&&i&&i.top<n.bottom}class Ip extends Dp{constructor(e,t){super(e),this.mark=t}get domAttrs(){return this.mark.attrs}static of(e,t){let n=new Ip(t||document.createElement(e.tagName),e);return t||(n.flags|=4),n}}class jp extends Op{constructor(e,t){super(e,t.length),this.text=t}sync(e){2&this.flags||(super.sync(e),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text))}isText(){return!0}toString(){return JSON.stringify(this.text)}coordsIn(e,t){let n=this.dom.nodeValue.length;e>n&&(e=n);let i=e,r=e,o=0;0==e&&t<0||e==n&&t>=0?Gh.chrome||Gh.gecko||(e?(i--,o=1):r<n&&(r++,o=-1)):t<0?i--:r<n&&r++;let s=Cu(this.dom,i,r).getClientRects();if(!s.length)return null;let a=s[(o?o<0:t>=0)?0:s.length-1];return Gh.safari&&!o&&0==a.width&&(a=Array.prototype.find.call(s,e=>e.width)||a),o?yu(a,o<0):a||null}static of(e,t){let n=new jp(t||document.createTextNode(e),e);return t||(n.flags|=2),n}}class Fp extends Op{constructor(e,t,n,i){super(e,t,i),this.widget=n}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return!(48&this.flags)&&(this.flags&(e<0?64:128))>0}coordsIn(e,t){return this.coordsInWidget(e,t,!1)}coordsInWidget(e,t,n){let i=this.widget.coordsAt(this.dom,e,t);if(i)return i;if(n)return yu(this.dom.getBoundingClientRect(),this.length?0==e:t<=0);{let t=this.dom.getClientRects(),n=null;if(!t.length)return null;let i=!!(16&this.flags)||!(32&this.flags)&&e>0;for(let r=i?t.length-1:0;n=t[r],!(e>0?0==r:r==t.length-1||n.top<n.bottom);r+=i?-1:1);return yu(n,!i)}}get overrideDOMText(){if(!this.length)return Kl.empty;let{root:e}=this;if(!e)return Kl.empty;let t=this.posAtStart;return e.view.state.doc.slice(t,t+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(e,t,n,i,r){return r||(r=e.toDOM(t),e.editable||(r.contentEditable="false")),new Fp(r,n,e,i)}}class Vp extends Op{constructor(e){let t=document.createElement("img");t.className="cm-widgetBuffer",t.setAttribute("aria-hidden","true"),super(t,0,e)}get isHidden(){return!0}get overrideDOMText(){return Kl.empty}coordsIn(e){return this.dom.getBoundingClientRect()}}class $p{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,n){let{tile:i,index:r,beforeBreak:o,parents:s}=this;for(;e||t>0;)if(i.isComposite())if(o){if(!e)break;n&&n.break(),e--,o=!1}else if(r==i.children.length){if(!e&&!s.length)break;n&&n.leave(i),o=!!i.breakAfter,({tile:i,index:r}=s.pop()),r++}else{let a=i.children[r],l=a.breakAfter;!(t>0?a.length<=e:a.length<e)||n&&!1===n.skip(a,0,a.length)&&a.isComposite?(s.push({tile:i,index:r}),i=a,r=0,n&&a.isComposite()&&n.enter(a)):(o=!!l,r++,e-=a.length)}else if(r==i.length)o=!!i.breakAfter,({tile:i,index:r}=s.pop()),r++;else{if(!e)break;{let t=Math.min(e,i.length-r);n&&n.skip(i,r,r+t),e-=t,r+=t}}return this.tile=i,this.index=r,this.beforeBreak=o,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}}class zp{constructor(e,t,n,i){this.from=e,this.to=t,this.wrapper=n,this.rank=i}}class Wp{constructor(e,t,n){this.cache=e,this.root=t,this.blockWrappers=n,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(e,t,n,i){var r;this.flushBuffer();let o=this.ensureMarks(t,n),s=o.lastChild;if(s&&s.isText()&&!(8&s.flags)&&s.length+e.length<512){this.cache.reused.set(s,2),(o.children[o.children.length-1]=new jp(s.dom,s.text+e)).parent=o}else o.append(i||jp.of(e,null===(r=this.cache.find(jp))||void 0===r?void 0:r.dom));this.pos+=e.length,this.afterWidget=null}addComposition(e,t){let n=this.curLine;n.dom!=t.line.dom&&(n.setDOM(this.cache.reused.has(t.line)?Jp(t.line.dom):t.line.dom),this.cache.reused.set(t.line,2));let i=n;for(let e=t.marks.length-1;e>=0;e--){let n=t.marks[e],r=i.lastChild;if(r instanceof Ip&&r.mark.eq(n.mark))r.dom!=n.dom&&r.setDOM(Jp(n.dom)),i=r;else{if(this.cache.reused.get(n)){let e=Op.get(n.dom);e&&e.setDOM(Jp(n.dom))}let e=Ip.of(n.mark,n.dom);i.append(e),i=e}this.cache.reused.set(n,2)}let r=Op.get(e.text);r&&this.cache.reused.set(r,2);let o=new jp(e.text,e.text.nodeValue);o.flags|=8,this.pos=e.range.toB,i.append(o)}addInlineWidget(e,t,n){let i=this.afterWidget&&48&e.flags&&(48&this.afterWidget.flags)==(48&e.flags);i||this.flushBuffer();let r=this.ensureMarks(t,n);i||16&e.flags||r.append(this.getBuffer(1)),r.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,n){this.flushBuffer(),this.ensureMarks(t,n).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){(this.afterWidget||this.lastBlock).length+=e,this.pos+=e}addLineStart(e,t){var n;e||(e=Yp);let i=Pp.start(e,t||(null===(n=this.cache.find(Pp))||void 0===n?void 0:n.dom),!!t);this.getBlockPos().append(this.lastBlock=this.curLine=i)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,t){var n;let i=this.curLine;for(let r=e.length-1;r>=0;r--){let o,s=e[r];if(t>0&&(o=i.lastChild)&&o instanceof Ip&&o.mark.eq(s))i=o,t--;else{let e=Ip.of(s,null===(n=this.cache.find(Ip,e=>e.mark.eq(s)))||void 0===n?void 0:n.dom);i.append(e),i=e,t=0}}return i}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;e&&Xp(this.curLine,!1)&&("BR"==e.dom.nodeName||!e.isWidget()||Gh.ios&&Xp(this.curLine,!0))||this.curLine.append(this.cache.findWidget(Zp,0,32)||new Fp(Zp.toDOM(),0,Zp,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to<this.pos&&this.wrappers.splice(e,1);for(let e=this.blockWrappers;e.value&&e.from<=this.pos;e.next())if(e.to>=this.pos){let t=102*e.rank+e.value.rank,n=new zp(e.from,e.to,e.value,t),i=this.wrappers.length;for(;i>0&&(this.wrappers[i-1].rank-n.rank||this.wrappers[i-1].to-n.to)<0;)i--;this.wrappers.splice(i,0,n)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let t=this.root;for(let n of this.wrappers){let i=t.lastChild;if(n.from<this.pos&&i instanceof Bp&&i.wrapper.eq(n.wrapper))t=i;else{let i=Bp.of(n.wrapper,null===(e=this.cache.find(Bp,e=>e.wrapper.eq(n.wrapper)))||void 0===e?void 0:e.dom);t.append(i),t=i}}return t}blockPosCovered(){let e=this.lastBlock;return null!=e&&!e.breakAfter&&(!e.isWidget()||(160&e.flags)>0)}getBuffer(e){let t=2|(e<0?16:32),n=this.cache.find(Vp,void 0,1);return n&&(n.flags=t),n||new Vp(t)}flushBuffer(){!this.afterWidget||32&this.afterWidget.flags||(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class Hp{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:t,lineBreak:n,done:i}=this.cursor.next(this.skipCount);if(this.skipCount=0,i)throw new Error("Ran out of text content when drawing inline views");this.text=t;let r=this.textOff=Math.min(e,t.length);return n?null:t.slice(0,r)}let t=Math.min(this.text.length,this.textOff+e),n=this.text.slice(this.textOff,t);return this.textOff=t,n}}const Up=[Fp,Pp,jp,Ip,Vp,Bp,Np];for(let e=0;e<Up.length;e++)Up[e].bucket=e;class Gp{constructor(e){this.view=e,this.buckets=Up.map(()=>[]),this.index=Up.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,n=this.buckets[t];n.length<6?n.push(e):n[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,n=2){let i=e.bucket,r=this.buckets[i],o=this.index[i];for(let e=r.length-1;e>=0;e--){let s=(e+o)%r.length,a=r[s];if((!t||t(a))&&!this.reused.has(a))return r.splice(s,1),s<o&&this.index[i]--,this.reused.set(a,n),a}return null}findWidget(e,t,n){let i=this.buckets[0];if(i.length)for(let r=0,o=0;;r++){if(r==i.length){if(o)return null;o=1,r=0}let s=i[r];if(!this.reused.has(s)&&(0==o?s.widget.compare(e):s.widget.constructor==e.constructor&&e.updateDOM(s.dom,this.view,s.widget)))return i.splice(r,1),r<this.index[0]&&this.index[0]--,s.widget==e&&s.length==t&&(497&s.flags)==n?(this.reused.set(s,1),s):(this.reused.set(s,2),new Fp(s.dom,t,e,-498&s.flags|n))}}reuse(e){return this.reused.set(e,1),e}maybeReuse(e,t=2){if(!this.reused.has(e))return this.reused.set(e,t),e.dom}clear(){for(let e=0;e<this.buckets.length;e++)this.buckets[e].length=this.index[e]=0}}class Kp{constructor(e,t,n,i,r){this.view=e,this.decorations=i,this.disallowBlockEffectsFor=r,this.openWidget=!1,this.openMarks=0,this.cache=new Gp(e),this.text=new Hp(e.state.doc),this.builder=new Wp(this.cache,new Np(e,e.contentDOM),fh.iter(n)),this.cache.reused.set(t,2),this.old=new $p(t),this.reuseWalker={skip:(e,t,n)=>{if(this.cache.add(e),e.isComposite())return!1},enter:e=>this.cache.add(e),leave:()=>{},break:()=>{}}}run(e,t){let n=t&&this.getCompositionContext(t.text);for(let i=0,r=0,o=0;;){let s=o<e.length?e[o++]:null,a=s?s.fromA:this.old.root.length;if(a>i){let e=a-i;this.preserve(e,!o,!s),i=a,r+=e}if(!s)break;t&&s.fromA<=t.range.fromA&&s.toA>=t.range.toA?(this.forward(s.fromA,t.range.fromA,t.range.fromA<t.range.toA?1:-1),this.emit(r,t.range.fromB),this.builder.flushBuffer(),this.cache.clear(),this.builder.addComposition(t,n),this.text.skip(t.range.toB-t.range.fromB),this.forward(t.range.fromA,s.toA),this.emit(t.range.toB,s.toB)):(this.forward(s.fromA,s.toA),this.emit(r,s.toB)),r=s.toB,i=s.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(e,t,n){let i=function(e){let t=[];for(let n=e.parents.length;n>1;n--){let i=n==e.parents.length?e.tile:e.parents[n].tile;i instanceof Ip&&t.push(i.mark)}return t}(this.old),r=this.openMarks;this.old.advance(e,n?1:-1,{skip:(e,t,n)=>{if(e.isWidget())if(this.openWidget)this.builder.continueWidget(n-t);else{let o=n>0||t<e.length?Fp.of(e.widget,this.view,n-t,496&e.flags,this.cache.maybeReuse(e)):this.cache.reuse(e);256&o.flags?(o.flags&=-2,this.builder.addBlockWidget(o)):(this.builder.ensureLine(null),this.builder.addInlineWidget(o,i,r),r=i.length)}else if(e.isText())this.builder.ensureLine(null),t||n!=e.length||this.cache.reused.has(e)?(this.cache.add(e),this.builder.addText(e.text.slice(t,n),i,r)):this.builder.addText(e.text,i,r,this.cache.reuse(e)),r=i.length;else if(e.isLine())e.flags&=-2,this.cache.reused.set(e,1),this.builder.addLine(e);else if(e instanceof Vp)this.cache.add(e);else{if(!(e instanceof Ip))return!1;this.builder.ensureLine(null),this.builder.addMark(e,i,r),this.cache.reused.set(e,1),r=i.length}this.openWidget=!1},enter:e=>{e.isLine()?this.builder.addLineStart(e.attrs,this.cache.maybeReuse(e)):(this.cache.add(e),e instanceof Ip&&i.unshift(e.mark)),this.openWidget=!1},leave:e=>{e.isLine()?i.length&&(i.length=r=0):e instanceof Ip&&(i.shift(),r=Math.min(r,i.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let n=null,i=this.builder,r=0,o=fh.spans(this.decorations,e,t,{point:(e,t,o,s,a,l)=>{if(o instanceof ru){if(this.disallowBlockEffectsFor[l]){if(o.block)throw new RangeError("Block decorations may not be specified via plugins");if(t>this.view.state.doc.lineAt(e).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(r=s.length,a>s.length)i.continueWidget(t-e);else{let r=o.widget||(o.block?Qp.block:Qp.inline),l=function(e){let t=e.isReplace?(e.startSide<0?64:0)|(e.endSide>0?128:0):e.startSide>0?32:16;e.block&&(t|=256);return t}(o),c=this.cache.findWidget(r,t-e,l)||Fp.of(r,this.view,t-e,l);o.block?(o.startSide>0&&i.addLineStartIfNotCovered(n),i.addBlockWidget(c)):(i.ensureLine(n),i.addInlineWidget(c,s,a))}n=null}else n=function(e,t){let n=t.spec.attributes,i=t.spec.class;if(!n&&!i)return e;e||(e={class:"cm-line"});n&&Kh(n,e);i&&(e.class+=" "+i);return e}(n,o);t>e&&this.text.skip(t-e)},span:(e,t,r,o)=>{for(let s=e;s<t;){let a=this.text.next(Math.min(512,t-s));null==a?(i.addLineStartIfNotCovered(n),i.addBreak(),s++):(i.ensureLine(n),i.addText(a,r,s==e?o:r.length),s+=a.length),n=null}}});i.addLineStartIfNotCovered(n),this.openWidget=o>r,this.openMarks=o}forward(e,t,n=1){t-e<=10?this.old.advance(t-e,n,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,n,this.reuseWalker))}getCompositionContext(e){let t=[],n=null;for(let i=e.parentNode;;i=i.parentNode){let e=Op.get(i);if(i==this.view.contentDOM)break;e instanceof Ip?t.push(e):(null==e?void 0:e.isLine())?n=e:e instanceof Bp||("DIV"!=i.nodeName||n||i==this.view.contentDOM?n||t.push(Ip.of(new nu({tagName:i.nodeName.toLowerCase(),attributes:Qh(i)}),i)):n=new Pp(i,Yp))}return{line:n,marks:t}}}function Xp(e,t){let n=e=>{for(let i of e.children)if((t?i.isText():i.length)||n(i))return!0;return!1};return n(e)}const Yp={class:"cm-line"};function Jp(e){let t=Op.get(e);return t&&t.setDOM(e.cloneNode()),e}class Qp extends Zh{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}Qp.inline=new Qp("span"),Qp.block=new Qp("div");const Zp=new class extends Zh{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class ed{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=tu.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new Np(e,e.contentDOM),this.updateInner([new Ap(0,0,0,e.state.doc.length)],null)}update(e){var t;let n=e.changedRanges;this.minWidth>0&&n.length&&(n.every(({fromA:e,toA:t})=>t<this.minWidthFrom||e>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let i=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&((null===(t=this.domChanged)||void 0===t?void 0:t.newSel)?i=this.domChanged.newSel.head:function(e,t){let n=!1;t&&e.iterChangedRanges((e,i)=>{e<t.to&&i>t.from&&(n=!0)});return n}(e.changes,this.hasComposition)||e.selectionSet||(i=e.state.selection.main.head));let r=i>-1?function(e,t,n){let i=nd(e,n);if(!i)return null;let{node:r,from:o,to:s}=i,a=r.nodeValue;if(/[\n\r]/.test(a))return null;if(e.state.doc.sliceString(i.from,i.to)!=a)return null;let l=t.invertedDesc;return{range:new Ap(l.mapPos(o),l.mapPos(s),o,s),text:r}}(this.view,e.changes,i):null;if(this.domChanged=null,this.hasComposition){let{from:t,to:i}=this.hasComposition;n=new Ap(t,i,e.changes.mapPos(t,-1),e.changes.mapPos(i,1)).addToSet(n.slice())}this.hasComposition=r?{from:r.range.fromB,to:r.range.toB}:null,(Gh.ie||Gh.chrome)&&!r&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,s=this.blockWrappers;this.updateDeco();let a=function(e,t,n){let i=new id;return fh.compare(e,t,n,i),i.changes}(o,this.decorations,e.changes);a.length&&(n=Ap.extendWithRanges(n,a));let l=function(e,t,n){let i=new rd;return fh.compare(e,t,n,i),i.changes}(s,this.blockWrappers,e.changes);return l.length&&(n=Ap.extendWithRanges(n,l)),r&&!n.some(e=>e.fromA<=r.range.fromA&&e.toA>=r.range.toA)&&(n=r.range.addToSet(n.slice())),!(2&this.tile.flags&&0==n.length)&&(this.updateInner(n,r),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:n}=this.view;n.ignore(()=>{if(t||e.length){let n=this.tile,i=new Kp(this.view,n,this.blockWrappers,this.decorations,this.dynamicDecorationMap);t&&Op.get(t.text)&&i.cache.reused.set(Op.get(t.text),2),this.tile=i.run(e,t),td(n,i.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let i=Gh.chrome||Gh.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(i),!i||!i.written&&n.selectionRange.focusNode==i.node&&this.tile.dom.contains(i.node)||(this.forceSelection=!0),this.tile.dom.style.height=""});let i=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let e of this.tile.children)e.isWidget()&&e.widget instanceof od&&i.push(e.dom);n.updateGaps(i)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let t of e.transactions)for(let e of t.effects)e.is(hp)&&(this.editContextFormatting=e.value)}updateSelection(e=!1,t=!1){!e&&this.view.observer.selectionRange.focusNode||this.view.observer.readSelectionRange();let{dom:n}=this.tile,i=this.view.root.activeElement,r=i==n,o=!r&&!(this.view.state.facet(pp)||n.tabIndex>-1)&&hu(n,this.view.observer.selectionRange)&&!(i&&n.contains(i));if(!(r||t||o))return;let s=this.forceSelection;this.forceSelection=!1;let a,l,c=this.view.state.selection.main;if(c.empty?l=a=this.inlineDOMNearPos(c.anchor,c.assoc||1):(l=this.inlineDOMNearPos(c.head,c.head==c.from?1:-1),a=this.inlineDOMNearPos(c.anchor,c.anchor==c.from?1:-1)),Gh.gecko&&c.empty&&!this.hasComposition&&(1==(h=a).node.nodeType&&h.node.firstChild&&(0==h.offset||"false"==h.node.childNodes[h.offset-1].contentEditable)&&(h.offset==h.node.childNodes.length||"false"==h.node.childNodes[h.offset].contentEditable))){let e=document.createTextNode("");this.view.observer.ignore(()=>a.node.insertBefore(e,a.node.childNodes[a.offset]||null)),a=l=new Ru(e,0),s=!0}var h;let u=this.view.observer.selectionRange;!s&&u.focusNode&&(pu(a.node,a.offset,u.anchorNode,u.anchorOffset)&&pu(l.node,l.offset,u.focusNode,u.focusOffset)||this.suppressWidgetCursorChange(u,c))||(this.view.observer.ignore(()=>{Gh.android&&Gh.chrome&&n.contains(u.focusNode)&&function(e,t){for(let n=e;n&&n!=t;n=n.assignedSlot||n.parentNode)if(1==n.nodeType&&"false"==n.contentEditable)return!0;return!1}(u.focusNode,n)&&(n.blur(),n.focus({preventScroll:!0}));let e=lu(this.view.root);if(e)if(c.empty){if(Gh.gecko){let e=function(e,t){return 1!=e.nodeType?0:(t&&"false"==e.childNodes[t-1].contentEditable?1:0)|(t<e.childNodes.length&&"false"==e.childNodes[t].contentEditable?2:0)}(a.node,a.offset);if(e&&3!=e){let t=(1==e?Au:Tu)(a.node,a.offset);t&&(a=new Ru(t.node,t.offset))}}e.collapse(a.node,a.offset),null!=c.bidiLevel&&void 0!==e.caretBidiLevel&&(e.caretBidiLevel=c.bidiLevel)}else if(e.extend){e.collapse(a.node,a.offset);try{e.extend(l.node,l.offset)}catch(e){}}else{let t=document.createRange();c.anchor>c.head&&([a,l]=[l,a]),t.setEnd(l.node,l.offset),t.setStart(a.node,a.offset),e.removeAllRanges(),e.addRange(t)}else;o&&this.view.root.activeElement==n&&(n.blur(),i&&i.focus())}),this.view.observer.setSelectionRange(a,l)),this.impreciseAnchor=a.precise?null:new Ru(u.anchorNode,u.anchorOffset),this.impreciseHead=l.precise?null:new Ru(u.focusNode,u.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&pu(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,n=lu(e.root),{anchorNode:i,anchorOffset:r}=e.observer.selectionRange;if(!(n&&t.empty&&t.assoc&&n.modify))return;let o=this.lineAt(t.head,t.assoc);if(!o)return;let s=o.posAtStart;if(t.head==s||t.head==s+o.length)return;let a=this.coordsAt(t.head,-1),l=this.coordsAt(t.head,1);if(!a||!l||a.bottom>l.top)return;let c=this.domAtPos(t.head+t.assoc,t.assoc);n.collapse(c.node,c.offset),n.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let h=e.observer.selectionRange;e.docView.posFromDOM(h.anchorNode,h.anchorOffset)!=t.from&&n.collapse(i,r)}posFromDOM(e,t){let n=this.tile.nearest(e);if(!n)return 2&this.tile.dom.compareDocumentPosition(e)?0:this.view.state.doc.length;let i=n.posAtStart;if(!n.isComposite())return n.isText()?e==n.dom?i+t:i+(t?n.length:0):i;{let r;if(e==n.dom)r=n.dom.childNodes[t];else{let i=0==mu(e)?0:0==t?-1:1;for(;;){let t=e.parentNode;if(t==n.dom)break;0==i&&t.firstChild!=t.lastChild&&(i=e==t.firstChild?-1:1),e=t}r=i<0?e:e.nextSibling}if(r==n.dom.firstChild)return i;for(;r&&!Op.get(r);)r=r.nextSibling;if(!r)return i+n.length;for(let e=0,t=i;;e++){let i=n.children[e];if(i.dom==r)return t;t+=i.length+i.breakAfter}}}domAtPos(e,t){let{tile:n,offset:i}=this.tile.resolveBlock(e,t);return n.isWidget()?n.domPosFor(e,t):n.domIn(i,t)}inlineDOMNearPos(e,t){let n,i,r=-1,o=!1,s=-1,a=!1;return this.tile.blockTiles((t,l)=>{if(t.isWidget()){if(32&t.flags&&l>=e)return!0;16&t.flags&&(o=!0)}else{let c=l+t.length;if(l<=e&&(n=t,r=e-l,o=c<e),c>=e&&!i&&(i=t,s=e-l,a=l>e),l>e&&i)return!0}}),n||i?(o&&i?n=null:a&&n&&(i=null),n&&t<0||!i?n.domIn(r,t):i.domIn(s,t)):this.domAtPos(e,t)}coordsAt(e,t){let{tile:n,offset:i}=this.tile.resolveBlock(e,t);return n.isWidget()?n.widget instanceof od?null:n.coordsInWidget(i,t,!0):n.coordsIn(i,t)}lineAt(e,t){let{tile:n}=this.tile.resolveBlock(e,t);return n.isLine()?n:null}coordsForChar(e){let{tile:t,offset:n}=this.tile.resolveBlock(e,1);if(!t.isLine())return null;return function e(t,n){if(t.isComposite())for(let i of t.children){if(i.length>=n){let t=e(i,n);if(t)return t}if((n-=i.length)<0)break}else if(t.isText()&&n<t.length){let e=rc(t.text,n);if(e==n)return null;let i=Cu(t.dom,n,e).getClientRects();for(let e=0;e<i.length;e++){let t=i[e];if(e==i.length-1||t.top<t.bottom&&t.left<t.right)return t}}return null}(t,n)}measureVisibleLineHeights(e){let t=[],{from:n,to:i}=e,r=this.view.contentDOM.clientWidth,o=r>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,s=-1,a=this.view.textDirection==Ou.LTR,l=0,c=(e,h,u)=>{for(let p=0;p<e.children.length&&!(h>i);p++){let i=e.children[p],d=h+i.length,f=i.dom.getBoundingClientRect(),{height:g}=f;if(u&&!p&&(l+=f.top-u.top),i instanceof Bp)d>n&&c(i,h,f);else if(h>=n&&(l>0&&t.push(-l),t.push(g+l),l=0,o)){let e=i.dom.lastChild,t=e?uu(e):[];if(t.length){let e=t[t.length-1],n=a?e.right-f.left:f.right-e.left;n>s&&(s=n,this.minWidth=r,this.minWidthFrom=h,this.minWidthTo=d)}}u&&p==e.children.length-1&&(l+=u.bottom-f.bottom),h=d+i.breakAfter}};return c(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return"rtl"==getComputedStyle(t.dom).direction?Ou.RTL:Ou.LTR}measureTextSize(){let e=this.tile.blockTiles(e=>{if(e.isLine()&&e.children.length&&e.length<=20){let t,n=0;for(let i of e.children){if(!i.isText()||/[^ -~]/.test(i.text))return;let e=uu(i.dom);if(1!=e.length)return;n+=e[0].width,t=e[0].height}if(n)return{lineHeight:e.dom.getBoundingClientRect().height,charWidth:n/e.length,textHeight:t}}});if(e)return e;let t,n,i,r=document.createElement("div");return r.className="cm-line",r.style.width="99999px",r.style.position="absolute",r.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(r);let e=uu(r.firstChild)[0];t=r.getBoundingClientRect().height,n=e&&e.width?e.width/27:7,i=e&&e.height?e.height:t,r.remove()}),{lineHeight:t,charWidth:n,textHeight:i}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let n=0,i=0;;i++){let r=i==t.viewports.length?null:t.viewports[i],o=r?r.from-1:this.view.state.doc.length;if(o>n){let i=(t.lineBlockAt(o).bottom-t.lineBlockAt(n).top)/this.view.scaleY;e.push(tu.replace({widget:new od(i),block:!0,inclusive:!0,isBlockGap:!0}).range(n,o))}if(!r)break;n=r.to+1}return tu.set(e)}updateDeco(){let e=1,t=this.view.state.facet(wp).map(t=>(this.dynamicDecorationMap[e++]="function"==typeof t)?t(this.view):t),n=!1,i=this.view.state.facet(xp).map((e,t)=>{let i="function"==typeof e;return i&&(n=!0),i?e(this.view):e});for(i.length&&(this.dynamicDecorationMap[e++]=n,t.push(fh.join(i))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;this.blockWrappers=this.view.state.facet(bp).map(e=>"function"==typeof e?e(this.view):e)}scrollIntoView(e){var t;if(e.isSnapshot){let t=this.view.viewState.lineBlockAt(e.range.head);return this.view.scrollDOM.scrollTop=t.top-e.yMargin,void(this.view.scrollDOM.scrollLeft=e.xMargin)}for(let t of this.view.state.facet(ap))try{if(t(this.view,e.range,e))return!0}catch(e){up(this.view.state,e,"scroll handler")}let n,{range:i}=e,r=this.coordsAt(i.head,null!==(t=i.assoc)&&void 0!==t?t:i.empty?0:i.head>i.anchor?-1:1);if(!r)return;!i.empty&&(n=this.coordsAt(i.anchor,i.anchor>i.head?-1:1))&&(r={left:Math.min(r.left,n.left),top:Math.min(r.top,n.top),right:Math.max(r.right,n.right),bottom:Math.max(r.bottom,n.bottom)});let o=Ep(this.view),s={left:r.left-o.left,top:r.top-o.top,right:r.right+o.right,bottom:r.bottom+o.bottom},{offsetWidth:a,offsetHeight:l}=this.view.scrollDOM;if(function(e,t,n,i,r,o,s,a){let l=e.ownerDocument,c=l.defaultView||window;for(let h=e,u=!1;h&&!u;)if(1==h.nodeType){let e,p=h==l.body,d=1,f=1;if(p)e=vu(c);else{if(/^(fixed|sticky)$/.test(getComputedStyle(h).position)&&(u=!0),h.scrollHeight<=h.clientHeight&&h.scrollWidth<=h.clientWidth){h=h.assignedSlot||h.parentNode;continue}let t=h.getBoundingClientRect();({scaleX:d,scaleY:f}=wu(h,t)),e={left:t.left,right:t.left+h.clientWidth*d,top:t.top,bottom:t.top+h.clientHeight*f}}let g=0,m=0;if("nearest"==r)t.top<e.top+s?(m=t.top-(e.top+s),n>0&&t.bottom>e.bottom+m&&(m=t.bottom-e.bottom+s)):t.bottom>e.bottom-s&&(m=t.bottom-e.bottom+s,n<0&&t.top-m<e.top&&(m=t.top-(e.top+s)));else{let i=t.bottom-t.top,o=e.bottom-e.top;m=("center"==r&&i<=o?t.top+i/2-o/2:"start"==r||"center"==r&&n<0?t.top-s:t.bottom-o+s)-e.top}if("nearest"==i?t.left<e.left+o?(g=t.left-(e.left+o),n>0&&t.right>e.right+g&&(g=t.right-e.right+o)):t.right>e.right-o&&(g=t.right-e.right+o,n<0&&t.left<e.left+g&&(g=t.left-(e.left+o))):g=("center"==i?t.left+(t.right-t.left)/2-(e.right-e.left)/2:"start"==i==a?t.left-o:t.right-(e.right-e.left)+o)-e.left,g||m)if(p)c.scrollBy(g,m);else{let e=0,n=0;if(m){let e=h.scrollTop;h.scrollTop+=m/f,n=(h.scrollTop-e)*f}if(g){let t=h.scrollLeft;h.scrollLeft+=g/d,e=(h.scrollLeft-t)*d}t={left:t.left-e,top:t.top-n,right:t.right-e,bottom:t.bottom-n},e&&Math.abs(e-g)<1&&(i="nearest"),n&&Math.abs(n-m)<1&&(r="nearest")}if(p)break;(t.top<e.top||t.bottom>e.bottom||t.left<e.left||t.right>e.right)&&(t={left:Math.max(t.left,e.left),right:Math.min(t.right,e.right),top:Math.max(t.top,e.top),bottom:Math.min(t.bottom,e.bottom)}),h=h.assignedSlot||h.parentNode}else{if(11!=h.nodeType)break;h=h.host}}(this.view.scrollDOM,s,i.head<i.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,a),-a),Math.max(Math.min(e.yMargin,l),-l),this.view.textDirection==Ou.LTR),window.visualViewport&&window.innerHeight-window.visualViewport.height>1&&(r.top>window.pageYOffset+window.visualViewport.offsetTop+window.visualViewport.height||r.bottom<window.pageYOffset+window.visualViewport.offsetTop)){let e=this.view.docView.lineAt(i.head,1);e&&e.dom.scrollIntoView({block:"nearest"})}}lineHasWidget(e){let t=e=>e.isWidget()||e.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){td(this.tile)}}function td(e,t){let n=null==t?void 0:t.get(e);if(1!=n){null==n&&e.destroy();for(let n of e.children)td(n,t)}}function nd(e,t){let n=e.observer.selectionRange;if(!n.focusNode)return null;let i=Au(n.focusNode,n.focusOffset),r=Tu(n.focusNode,n.focusOffset),o=i||r;if(r&&i&&r.node!=i.node){let t=Op.get(r.node);if(!t||t.isText()&&t.text!=r.node.nodeValue)o=r;else if(e.docView.lastCompositionAfterCursor){let e=Op.get(i.node);!e||e.isText()&&e.text!=i.node.nodeValue||(o=r)}}if(e.docView.lastCompositionAfterCursor=o!=i,!o)return null;let s=t-o.offset;return{from:s,to:s+o.node.nodeValue.length,node:o.node}}let id=class{constructor(){this.changes=[]}compareRange(e,t){su(e,t,this.changes)}comparePoint(e,t){su(e,t,this.changes)}boundChange(e){su(e,e,this.changes)}};class rd{constructor(){this.changes=[]}compareRange(e,t){su(e,t,this.changes)}comparePoint(){}boundChange(e){su(e,e,this.changes)}}class od extends Zh{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function sd(e,t,n,i,r){let o=Math.round((i-t.left)*e.defaultCharacterWidth);if(e.lineWrapping&&n.height>1.5*e.defaultLineHeight){let t=e.viewState.heightOracle.textHeight;o+=Math.floor((r-n.top-.5*(e.defaultLineHeight-t))/t)*e.viewState.heightOracle.lineLength}let s=e.state.sliceDoc(n.from,n.to);return n.from+function(e,t,n){for(let i=0,r=0;;){if(r>=t)return i;if(i==e.length)break;r+=9==e.charCodeAt(i)?n-r%n:1,i=rc(e,i)}return e.length}(s,o,e.state.tabSize)}function ad(e,t,n,i){let r=function(e,t,n){let i=e.lineBlockAt(t);if(Array.isArray(i.type)){let e;for(let r of i.type){if(r.from>t)break;if(!(r.to<t)){if(r.from<t&&r.to>t)return r;e&&(r.type!=eu.Text||e.type==r.type&&!(n<0?r.from<t:r.to>t))||(e=r)}}return e||i}return i}(e,t.head,t.assoc||-1),o=i&&r.type==eu.Text&&(e.lineWrapping||r.widgetLineBreaks)?e.coordsAtPos(t.assoc<0&&t.head>r.from?t.head-1:t.head):null;if(o){let t=e.dom.getBoundingClientRect(),i=e.textDirectionAt(r.from),s=e.posAtCoords({x:n==(i==Ou.LTR)?t.right-1:t.left+1,y:(o.top+o.bottom)/2});if(null!=s)return mc.cursor(s,n?-1:1)}return mc.cursor(n?r.to:r.from,n?-1:1)}function ld(e,t,n,i){let r=e.state.doc.lineAt(t.head),o=e.bidiSpans(r),s=e.textDirectionAt(r.from);for(let a=t,l=null;;){let t=Ku(r,o,s,a,n),c=Gu;if(!t){if(r.number==(n?e.state.doc.lines:1))return a;c="\n",r=e.state.doc.line(r.number+(n?1:-1)),o=e.bidiSpans(r),t=e.visualLineSide(r,!n)}if(l){if(!l(c))return a}else{if(!i)return t;l=i(c)}a=t}}function cd(e,t,n){for(;;){let i=0;for(let r of e)r.between(t-1,t+1,(e,r,o)=>{if(t>e&&t<r){let o=i||n||(t-e<r-t?-1:1);t=o<0?e:r,i=o}});if(!i)return t}}function hd(e,t){let n=null;for(let i=0;i<t.ranges.length;i++){let r=t.ranges[i],o=null;if(r.empty){let t=cd(e,r.from,0);t!=r.from&&(o=mc.cursor(t,-1))}else{let t=cd(e,r.from,-1),n=cd(e,r.to,1);t==r.from&&n==r.to||(o=mc.range(r.from==r.anchor?t:n,r.from==r.head?t:n))}o&&(n||(n=t.ranges.slice()),n[i]=o)}return n?mc.create(n,t.mainIndex):t}function ud(e,t,n){let i=cd(e.state.facet(_p).map(t=>t(e)),n.from,t.head>n.from?-1:1);return i==n.from?n:mc.cursor(i,i<n.from?1:-1)}class pd{constructor(e,t){this.pos=e,this.assoc=t}}function dd(e,t,n,i){let r,o=e.contentDOM.getBoundingClientRect(),s=o.top+e.viewState.paddingTop,{x:a,y:l}=t,c=l-s;for(;;){if(c<0)return new pd(0,1);if(c>e.viewState.docHeight)return new pd(e.state.doc.length,-1);if(r=e.elementAtHeight(c),null==i)break;if(r.type==eu.Text){if(i<0?r.to<e.viewport.from:r.from>e.viewport.to)break;let t=e.docView.coordsAt(i<0?r.from:r.to,i>0?-1:1);if(t&&(i<0?t.top<=c+s:t.bottom>=c+s))break}let t=e.viewState.heightOracle.textHeight/2;c=i>0?r.bottom+t:r.top-t}if(e.viewport.from>=r.to||e.viewport.to<=r.from){if(n)return null;if(r.type==eu.Text){let t=sd(e,o,r,a,l);return new pd(t,t==r.from?1:-1)}}if(r.type!=eu.Text)return c<(r.top+r.bottom)/2?new pd(r.from,1):new pd(r.to,-1);let h=e.docView.lineAt(r.from,2);return h&&h.length==r.length||(h=e.docView.lineAt(r.from,-2)),new fd(e,a,l,e.textDirectionAt(r.from)).scanTile(h,r.from)}class fd{constructor(e,t,n,i){this.view=e,this.x=t,this.y=n,this.baseDir=i,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to<e)&&(this.line=this.view.state.doc.lineAt(e),this.spans=this.view.bidiSpans(this.line)),this}baseDirAt(e,t){let{line:n,spans:i}=this.bidiSpansAt(e);return i[Vu.find(i,e-n.from,-1,t)].level==this.baseDir}dirAt(e,t){let{line:n,spans:i}=this.bidiSpansAt(e);return i[Vu.find(i,e-n.from,-1,t)].dir}bidiIn(e,t){let{spans:n,line:i}=this.bidiSpansAt(e);return n.length>1||n.length&&(n[0].level!=this.baseDir||n[0].to+i.from<t)}scan(e,t,n=!1){let i,r,o,s=0,a=e.length-1,l=new Set,c=this.bidiIn(e[0],e[a]),h=-1,u=1e9;e:for(;s<a;){let n=a-s,p=s+a>>1;t:if(l.has(p)){let e=s+Math.floor(Math.random()*n);for(let t=0;t<n;t++){if(!l.has(e)){p=e;break t}e++,e==a&&(e=s)}break e}l.add(p);let d=t(p);if(d)for(let t=0;t<d.length;t++){let n=d[t],l=0;if(!(0==n.width&&d.length>1)){if(n.bottom<this.y)(!i||i.bottom<n.bottom)&&(i=n),l=1;else if(n.top>this.y)(!r||r.top>n.top)&&(r=n),l=-1;else{let e=n.left>this.x?this.x-n.left:n.right<this.x?this.x-n.right:0,t=Math.abs(e);t<u&&(h=p,u=t,o=n),e&&(l=e<0==(this.baseDir==Ou.LTR)?-1:1)}-1!=l||c&&!this.baseDirAt(e[p],1)?1!=l||c&&!this.baseDirAt(e[p+1],-1)||(s=p+1):a=p}}}if(!o){if(!r&&!i)return{i:e[0],after:!1};let n=i&&(!r||this.y-i.bottom<r.top-this.y)?i:r;return this.y=(n.top+n.bottom)/2,this.scan(e,t,!0)}if(u&&!n){let{top:n,bottom:s}=o;if(i&&i.bottom>(n+n+s)/3)return this.y=i.bottom-1,this.scan(e,t,!0);if(r&&r.top<(n+s+s)/3)return this.y=r.top+1,this.scan(e,t,!0)}let p=(c?this.dirAt(e[h],1):this.baseDir)==Ou.LTR;return{i:h,after:this.x>(o.left+o.right)/2==p}}scanText(e,t){let n=[];for(let i=0;i<e.length;i=rc(e.text,i))n.push(t+i);n.push(t+e.length);let i=this.scan(n,i=>{let r=n[i]-t,o=n[i+1]-t;return Cu(e.dom,r,o).getClientRects()});return i.after?new pd(n[i.i+1],-1):new pd(n[i.i],1)}scanTile(e,t){if(!e.length)return new pd(t,1);if(1==e.children.length){let n=e.children[0];if(n.isText())return this.scanText(n,t);if(n.isComposite())return this.scanTile(n,t)}let n=[t];for(let i=0,r=t;i<e.children.length;i++)n.push(r+=e.children[i].length);let i=this.scan(n,t=>{let n=e.children[t];return 48&n.flags?null:(1==n.dom.nodeType?n.dom:Cu(n.dom,0,n.length)).getClientRects()}),r=e.children[i.i],o=n[i.i];return r.isText()?this.scanText(r,o):r.isComposite()?this.scanTile(r,o):i.after?new pd(n[i.i+1],-1):new pd(o,1)}}const gd="";class md{constructor(e,t){this.points=e,this.view=t,this.text="",this.lineSeparator=t.state.facet(ah.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=gd}readRange(e,t){if(!e)return this;let n=e.parentNode;for(let i=e;;){this.findPointBefore(n,i);let e=this.text.length;this.readNode(i);let r=Op.get(i),o=i.nextSibling;if(o==t){(null==r?void 0:r.breakAfter)&&!o&&n!=this.view.contentDOM&&this.lineBreak();break}let s=Op.get(o);(r&&s?r.breakAfter:(r?r.breakAfter:fu(i))||fu(o)&&("BR"!=i.nodeName||(null==r?void 0:r.isWidget()))&&this.text.length>e)&&!vd(o,t)&&this.lineBreak(),i=o}return this.findPointBefore(n,t),this}readTextNode(e){let t=e.nodeValue;for(let n of this.points)n.node==e&&(n.pos=this.text.length+Math.min(n.offset,t.length));for(let n=0,i=this.lineSeparator?null:/\r\n?|\n/g;;){let r,o=-1,s=1;if(this.lineSeparator?(o=t.indexOf(this.lineSeparator,n),s=this.lineSeparator.length):(r=i.exec(t))&&(o=r.index,s=r[0].length),this.append(t.slice(n,o<0?t.length:o)),o<0)break;if(this.lineBreak(),s>1)for(let t of this.points)t.node==e&&t.pos>this.text.length&&(t.pos-=s-1);n=o+s}}readNode(e){let t=Op.get(e),n=t&&t.overrideDOMText;if(null!=n){this.findPointInside(e,n.length);for(let e=n.iter();!e.next().done;)e.lineBreak?this.lineBreak():this.append(e.value)}else 3==e.nodeType?this.readTextNode(e):"BR"==e.nodeName?e.nextSibling&&this.lineBreak():1==e.nodeType&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let n of this.points)n.node==e&&e.childNodes[n.offset]==t&&(n.pos=this.text.length)}findPointInside(e,t){for(let n of this.points)(3==e.nodeType?n.node==e:e.contains(n.node))&&(n.pos=this.text.length+(yd(e,n.node,n.offset)?t:0))}}function yd(e,t,n){for(;;){if(!t||n<mu(t))return!1;if(t==e)return!0;n=du(t)+1,t=t.parentNode}}function vd(e,t){let n;for(;e!=t&&e;e=e.nextSibling){let t=Op.get(e);if(!(null==t?void 0:t.isWidget()))return!1;t&&(n||(n=[])).push(t)}if(n)for(let e of n){let t=e.overrideDOMText;if(null==t?void 0:t.length)return!1}return!0}class wd{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}}class bd{constructor(e,t,n,i){this.typeOver=i,this.bounds=null,this.text="",this.domChanged=t>-1;let{impreciseHead:r,impreciseAnchor:o}=e.docView,s=e.state.selection;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=xd(e.docView.tile,t,n,0))){let t=r||o?[]:function(e){let t=[];if(e.root.activeElement!=e.contentDOM)return t;let{anchorNode:n,anchorOffset:i,focusNode:r,focusOffset:o}=e.observer.selectionRange;n&&(t.push(new wd(n,i)),r==n&&o==i||t.push(new wd(r,o)));return t}(e),n=new md(t,e);n.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=n.text,this.newSel=function(e,t){if(0==e.length)return null;let n=e[0].pos,i=2==e.length?e[1].pos:n;return n>-1&&i>-1?mc.single(n+t,i+t):null}(t,this.bounds.from)}else{let t=e.observer.selectionRange,n=r&&r.node==t.focusNode&&r.offset==t.focusOffset||!cu(e.contentDOM,t.focusNode)?s.main.head:e.docView.posFromDOM(t.focusNode,t.focusOffset),i=o&&o.node==t.anchorNode&&o.offset==t.anchorOffset||!cu(e.contentDOM,t.anchorNode)?s.main.anchor:e.docView.posFromDOM(t.anchorNode,t.anchorOffset),a=e.viewport;if((Gh.ios||Gh.chrome)&&s.main.empty&&n!=i&&(a.from>0||a.to<e.state.doc.length)){let t=Math.min(n,i),r=Math.max(n,i),o=a.from-t,s=a.to-r;0!=o&&1!=o&&0!=t||0!=s&&-1!=s&&r!=e.state.doc.length||(n=0,i=e.state.doc.length)}if(e.inputState.composing>-1&&s.ranges.length>1)this.newSel=s.replaceRange(mc.range(i,n));else if(e.lineWrapping&&i==n&&(!s.main.empty||s.main.head!=n)&&e.inputState.lastTouchTime>Date.now()-100){let t=e.coordsAtPos(n,-1),i=0;t&&(i=e.inputState.lastTouchY<=t.bottom?-1:1),this.newSel=mc.create([mc.cursor(n,i)])}else this.newSel=mc.single(i,n)}}}function xd(e,t,n,i){if(e.isComposite()){let r=-1,o=-1,s=-1,a=-1;for(let l=0,c=i,h=i;l<e.children.length;l++){let i=e.children[l],u=c+i.length;if(c<t&&u>n)return xd(i,t,n,c);if(u>=t&&-1==r&&(r=l,o=c),c>n&&i.dom.parentNode==e.dom){s=l,a=h;break}h=u,c=u+i.breakAfter}return{from:o,to:a<0?i+e.length:a,startDOM:(r?e.children[r-1].dom.nextSibling:null)||e.dom.firstChild,endDOM:s<e.children.length&&s>=0?e.children[s].dom:null}}return e.isText()?{from:i,to:i+e.length,startDOM:e.dom,endDOM:e.dom.nextSibling}:null}function _d(e,t){let n,{newSel:i}=t,{state:r}=e,o=r.selection.main,s=e.inputState.lastKeyTime>Date.now()-100?e.inputState.lastKeyCode:-1;if(t.bounds){let{from:e,to:i}=t.bounds,a=o.from,l=null;(8===s||Gh.android&&t.text.length<i-e)&&(a=o.to,l="end");let c,h,u=r.doc.sliceString(e,i,gd);!o.empty&&o.from>=e&&o.to<=i&&(t.typeOver||u!=t.text)&&u.slice(0,o.from-e)==t.text.slice(0,o.from-e)&&u.slice(o.to-e)==t.text.slice(c=t.text.length-(u.length-(o.to-e)))?n={from:o.from,to:o.to,insert:Kl.of(t.text.slice(o.from-e,c).split(gd))}:(h=Sd(u,t.text,a-e,l))&&(Gh.chrome&&13==s&&h.toB==h.from+2&&t.text.slice(h.from,h.toB)==gd+gd&&h.toB--,n={from:e+h.from,to:e+h.toA,insert:Kl.of(t.text.slice(h.from,h.toB).split(gd))})}else i&&(!e.hasFocus&&r.facet(pp)||Cd(i,o))&&(i=null);if(!n&&!i)return!1;if((Gh.mac||Gh.android)&&n&&n.from==n.to&&n.from==o.head-1&&/^\. ?$/.test(n.insert.toString())&&"off"==e.contentDOM.getAttribute("autocorrect")?(i&&2==n.insert.length&&(i=mc.single(i.main.anchor-1,i.main.head-1)),n={from:n.from,to:n.to,insert:Kl.of([n.insert.toString().replace("."," ")])}):r.doc.lineAt(o.from).to<o.to&&e.docView.lineHasWidget(o.to)&&e.inputState.insertingTextAt>Date.now()-50?n={from:o.from,to:o.to,insert:r.toText(e.inputState.insertingText)}:Gh.chrome&&n&&n.from==n.to&&n.from==o.head&&"\n "==n.insert.toString()&&e.lineWrapping&&(i&&(i=mc.single(i.main.anchor-1,i.main.head-1)),n={from:o.from,to:o.to,insert:Kl.of([" "])}),n)return kd(e,n,i,s);if(i&&!Cd(i,o)){let t=!1,n="select";return e.inputState.lastSelectionTime>Date.now()-50&&("select"==e.inputState.lastSelectionOrigin&&(t=!0),n=e.inputState.lastSelectionOrigin,"select.pointer"==n&&(i=hd(r.facet(_p).map(t=>t(e)),i))),e.dispatch({selection:i,scrollIntoView:t,userEvent:n}),!0}return!1}function kd(e,t,n,i=-1){if(Gh.ios&&e.inputState.flushIOSKey(t))return!0;let r=e.state.selection.main;if(Gh.android&&(t.to==r.to&&(t.from==r.from||t.from==r.from-1&&" "==e.state.sliceDoc(t.from,r.from))&&1==t.insert.length&&2==t.insert.lines&&Eu(e.contentDOM,"Enter",13)||(t.from==r.from-1&&t.to==r.to&&0==t.insert.length||8==i&&t.insert.length<t.to-t.from&&t.to>r.head)&&Eu(e.contentDOM,"Backspace",8)||t.from==r.from&&t.to==r.to+1&&0==t.insert.length&&Eu(e.contentDOM,"Delete",46)))return!0;let o,s=t.insert.toString();e.inputState.composing>=0&&e.inputState.composing++;let a=()=>o||(o=function(e,t,n){let i,r=e.state,o=r.selection.main,s=-1;if(t.from==t.to&&t.from<o.from||t.from>o.to){let n=t.from<o.from?-1:1,i=n<0?o.from:o.to,a=cd(r.facet(_p).map(t=>t(e)),i,n);t.from==a&&(s=a)}if(s>-1)i={changes:t,selection:mc.cursor(t.from+t.insert.length,-1)};else if(t.from>=o.from&&t.to<=o.to&&t.to-t.from>=(o.to-o.from)/3&&(!n||n.main.empty&&n.main.from==t.from+t.insert.length)&&e.inputState.composing<0){let n=o.from<t.from?r.sliceDoc(o.from,t.from):"",s=o.to>t.to?r.sliceDoc(t.to,o.to):"";i=r.replaceSelection(e.state.toText(n+t.insert.sliceString(0,void 0,e.state.lineBreak)+s))}else{let s=r.changes(t),a=n&&n.main.to<=s.newLength?n.main:void 0;if(r.selection.ranges.length>1&&(e.inputState.composing>=0||e.inputState.compositionPendingChange)&&t.to<=o.to+10&&t.to>=o.to-10){let l,c=e.state.sliceDoc(t.from,t.to),h=n&&nd(e,n.main.head);if(h){let e=t.insert.length-(t.to-t.from);l={from:h.from,to:h.to-e}}else l=e.state.doc.lineAt(o.head);let u=o.to-t.to;i=r.changeByRange(n=>{if(n.from==o.from&&n.to==o.to)return{changes:s,range:a||n.map(s)};let i=n.to-u,h=i-c.length;if(e.state.sliceDoc(h,i)!=c||i>=l.from&&h<=l.to)return{range:n};let p=r.changes({from:h,to:i,insert:t.insert}),d=n.to-o.to;return{changes:p,range:a?mc.range(Math.max(0,a.anchor+d),Math.max(0,a.head+d)):n.map(p)}})}else i={changes:s,selection:a&&r.selection.replaceRange(a)}}let a="input.type";(e.composing||e.inputState.compositionPendingChange&&e.inputState.compositionEndedAt>Date.now()-50)&&(e.inputState.compositionPendingChange=!1,a+=".compose",e.inputState.compositionFirstChange&&(a+=".start",e.inputState.compositionFirstChange=!1));return r.update(i,{userEvent:a,scrollIntoView:!0})}(e,t,n));return e.state.facet(tp).some(n=>n(e,t.from,t.to,s,a))||e.dispatch(a()),!0}function Sd(e,t,n,i){let r=Math.min(e.length,t.length),o=0;for(;o<r&&e.charCodeAt(o)==t.charCodeAt(o);)o++;if(o==r&&e.length==t.length)return null;let s=e.length,a=t.length;for(;s>0&&a>0&&e.charCodeAt(s-1)==t.charCodeAt(a-1);)s--,a--;if("end"==i){n-=s+Math.max(0,o-Math.min(s,a))-o}if(s<o&&e.length<t.length){o-=n<=o&&n>=s?o-n:0,a=o+(a-s),s=o}else if(a<o){o-=n<=o&&n>=a?o-n:0,s=o+(s-a),a=o}return{from:o,toA:s,toB:a}}function Cd(e,t){return t.head==e.main.head&&t.anchor==e.main.anchor}class Ed{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Gh.safari&&e.contentDOM.addEventListener("input",()=>null),Gh.gecko&&function(e){Yd.has(e)||(Yd.add(e),e.addEventListener("copy",()=>{}),e.addEventListener("cut",()=>{}))}(e.contentDOM.ownerDocument)}handleEvent(e){(function(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n,i=t.target;i!=e.contentDOM;i=i.parentNode)if(!i||11==i.nodeType||(n=Op.get(i))&&n.isWidget()&&!n.isHidden&&n.widget.ignoreEvent(t))return!1;return!0})(this.view,e)&&!this.ignoreDuringComposition(e)&&("keydown"==e.type&&this.keydown(e)||(0!=this.view.updateState?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e)))}runHandlers(e,t){let n=this.handlers[e];if(n){for(let e of n.observers)e(this.view,t);for(let e of n.handlers){if(t.defaultPrevented)break;if(e(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=Ad(e),n=this.handlers,i=this.view.contentDOM;for(let e in t)if("scroll"!=e){let r=!t[e].handlers.length,o=n[e];o&&r!=!o.handlers.length&&(i.removeEventListener(e,this.handleEvent),o=null),o||i.addEventListener(e,this.handleEvent,{passive:r})}for(let e in n)"scroll"==e||t[e]||i.removeEventListener(e,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),9==e.keyCode&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&27!=e.keyCode&&Od.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Gh.android&&Gh.chrome&&!e.synthetic&&(13==e.keyCode||8==e.keyCode))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return!Gh.ios||e.synthetic||e.altKey||e.metaKey||e.shiftKey||!((t=Td.find(t=>t.keyCode==e.keyCode))&&!e.ctrlKey||Rd.indexOf(e.key)>-1&&e.ctrlKey)?(229!=e.keyCode&&this.view.observer.forceFlush(),!1):(this.pendingIOSKey=t||e,setTimeout(()=>this.flushIOSKey(),250),!0)}flushIOSKey(e){let t=this.pendingIOSKey;return!!t&&(!("Enter"==t.key&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString()))&&(this.pendingIOSKey=void 0,Eu(this.view.contentDOM,t.key,t.keyCode,t instanceof KeyboardEvent?t:void 0)))}ignoreDuringComposition(e){return!(!/^key/.test(e.type)||e.synthetic)&&(this.composing>0||!!(Gh.safari&&!Gh.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100)&&(this.compositionPendingKey=!1,!0))}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function Md(e,t){return(n,i)=>{try{return t.call(e,i,n)}catch(e){up(n.state,e)}}}function Ad(e){let t=Object.create(null);function n(e){return t[e]||(t[e]={observers:[],handlers:[]})}for(let t of e){let e=t.spec,i=e&&e.plugin.domEventHandlers,r=e&&e.plugin.domEventObservers;if(i)for(let e in i){let r=i[e];r&&n(e).handlers.push(Md(t.value,r))}if(r)for(let e in r){let i=r[e];i&&n(e).observers.push(Md(t.value,i))}}for(let e in Nd)n(e).handlers.push(Nd[e]);for(let e in Bd)n(e).observers.push(Bd[e]);return t}const Td=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],Rd="dthko",Od=[16,17,18,20,91,92,224,225];function Dd(e){return.7*Math.max(0,e)+8}class qd{constructor(e,t,n,i){this.view=e,this.startEvent=t,this.style=n,this.mustSelect=i,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=bu(e.contentDOM),this.atoms=e.state.facet(_p).map(t=>t(e));let r=e.contentDOM.ownerDocument;r.addEventListener("mousemove",this.move=this.move.bind(this)),r.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(ah.allowMultipleSelections)&&function(e,t){let n=e.state.facet(Yu);return n.length?n[0](t):Gh.mac?t.metaKey:t.ctrlKey}(e,t),this.dragging=!(!function(e,t){let{main:n}=e.state.selection;if(n.empty)return!1;let i=lu(e.root);if(!i||0==i.rangeCount)return!0;let r=i.getRangeAt(0).getClientRects();for(let e=0;e<r.length;e++){let n=r[e];if(n.left<=t.clientX&&n.right>=t.clientX&&n.top<=t.clientY&&n.bottom>=t.clientY)return!0}return!1}(e,t)||1!=Wd(t))&&null}start(e){!1===this.dragging&&this.select(e)}move(e){if(0==e.buttons)return this.destroy();if(this.dragging||null==this.dragging&&(t=this.startEvent,n=e,Math.max(Math.abs(t.clientX-n.clientX),Math.abs(t.clientY-n.clientY))<10))return;var t,n;this.select(this.lastEvent=e);let i=0,r=0,o=0,s=0,a=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:o,right:a}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:l}=this.scrollParents.y.getBoundingClientRect());let c=Ep(this.view);e.clientX-c.left<=o+6?i=-Dd(o-e.clientX):e.clientX+c.right>=a-6&&(i=Dd(e.clientX-a)),e.clientY-c.top<=s+6?r=-Dd(s-e.clientY):e.clientY+c.bottom>=l-6&&(r=Dd(e.clientY-l)),this.setScrollSpeed(i,r)}up(e){null==this.dragging&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),!1===this.dragging&&this.select(this.lastEvent)}select(e){let{view:t}=this,n=hd(this.atoms,this.style.get(e,this.extend,this.multiple));!this.mustSelect&&n.eq(t.state.selection,!1===this.dragging)||this.view.dispatch({selection:n,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(e=>e.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}const Nd=Object.create(null),Bd=Object.create(null),Pd=Gh.ie&&Gh.ie_version<15||Gh.ios&&Gh.webkit_version<604;function Ld(e,t,n){for(let i of e.facet(t))n=i(n,e);return n}function Id(e,t){t=Ld(e.state,ip,t);let n,{state:i}=e,r=1,o=i.toText(t),s=o.lines==i.selection.ranges.length;if(null!=Ud&&i.selection.ranges.every(e=>e.empty)&&Ud==o.toString()){let e=-1;n=i.changeByRange(n=>{let a=i.doc.lineAt(n.from);if(a.from==e)return{range:n};e=a.from;let l=i.toText((s?o.line(r++).text:t)+i.lineBreak);return{changes:{from:a.from,insert:l},range:mc.cursor(n.from+l.length)}})}else n=s?i.changeByRange(e=>{let t=o.line(r++);return{changes:{from:e.from,to:e.to,insert:t.text},range:mc.cursor(e.from+t.length)}}):i.replaceSelection(o);e.dispatch(n,{userEvent:"input.paste",scrollIntoView:!0})}function jd(e,t,n,i){if(1==i)return mc.cursor(t,n);if(2==i)return function(e,t,n=1){let i=e.charCategorizer(t),r=e.doc.lineAt(t),o=t-r.from;if(0==r.length)return mc.cursor(t);0==o?n=1:o==r.length&&(n=-1);let s=o,a=o;n<0?s=rc(r.text,o,!1):a=rc(r.text,o);let l=i(r.text.slice(s,a));for(;s>0;){let e=rc(r.text,s,!1);if(i(r.text.slice(e,s))!=l)break;s=e}for(;a<r.length;){let e=rc(r.text,a);if(i(r.text.slice(a,e))!=l)break;a=e}return mc.range(s+r.from,a+r.from)}(e.state,t,n);{let i=e.docView.lineAt(t,n),r=e.state.doc.lineAt(i?i.posAtEnd:t),o=i?i.posAtStart:r.from,s=i?i.posAtEnd:r.to;return s<e.state.doc.length&&s==r.to&&s++,mc.range(o,s)}}Bd.scroll=e=>{e.inputState.lastScrollTop=e.scrollDOM.scrollTop,e.inputState.lastScrollLeft=e.scrollDOM.scrollLeft},Bd.wheel=Bd.mousewheel=e=>{e.inputState.lastWheelEvent=Date.now()},Nd.keydown=(e,t)=>(e.inputState.setSelectionOrigin("select"),27==t.keyCode&&0!=e.inputState.tabFocusMode&&(e.inputState.tabFocusMode=Date.now()+2e3),!1),Bd.touchstart=(e,t)=>{let n=e.inputState,i=t.targetTouches[0];n.lastTouchTime=Date.now(),i&&(n.lastTouchX=i.clientX,n.lastTouchY=i.clientY),n.setSelectionOrigin("select.pointer")},Bd.touchmove=e=>{e.inputState.setSelectionOrigin("select.pointer")},Nd.mousedown=(e,t)=>{if(e.observer.flush(),e.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let i of e.state.facet(Qu))if(n=i(e,t),n)break;if(n||0!=t.button||(n=function(e,t){let n=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),i=Wd(t),r=e.state.selection;return{update(e){e.docChanged&&(n.pos=e.changes.mapPos(n.pos),r=r.map(e.changes))},get(t,o,s){let a,l=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),c=jd(e,l.pos,l.assoc,i);if(n.pos!=l.pos&&!o){let t=jd(e,n.pos,n.assoc,i),r=Math.min(t.from,c.from),o=Math.max(t.to,c.to);c=r<c.from?mc.range(r,o,c.assoc):mc.range(o,r,c.assoc)}return o?r.replaceRange(r.main.extend(c.from,c.to,c.assoc)):s&&1==i&&r.ranges.length>1&&(a=function(e,t){for(let n=0;n<e.ranges.length;n++){let{from:i,to:r}=e.ranges[n];if(i<=t&&r>=t)return mc.create(e.ranges.slice(0,n).concat(e.ranges.slice(n+1)),e.mainIndex==n?0:e.mainIndex-(e.mainIndex>n?1:0))}return null}(r,l.pos))?a:s?r.addRange(c):mc.create([c])}}}(e,t)),n){let i=!e.hasFocus;e.inputState.startMouseSelection(new qd(e,t,n,i)),i&&e.observer.ignore(()=>{Su(e.contentDOM);let t=e.root.activeElement;t&&!t.contains(e.contentDOM)&&t.blur()});let r=e.inputState.mouseSelection;if(r)return r.start(t),!1===r.dragging}else e.inputState.setSelectionOrigin("select.pointer");return!1};const Fd=Gh.ie&&Gh.ie_version<=11;let Vd=null,$d=0,zd=0;function Wd(e){if(!Fd)return e.detail;let t=Vd,n=zd;return Vd=e,zd=Date.now(),$d=!t||n>Date.now()-400&&Math.abs(t.clientX-e.clientX)<2&&Math.abs(t.clientY-e.clientY)<2?($d+1)%3:1}function Hd(e,t,n,i){if(!(n=Ld(e.state,ip,n)))return;let r=e.posAtCoords({x:t.clientX,y:t.clientY},!1),{draggedContent:o}=e.inputState,s=i&&o&&function(e,t){let n=e.state.facet(Ju);return n.length?n[0](t):Gh.mac?!t.altKey:!t.ctrlKey}(e,t)?{from:o.from,to:o.to}:null,a={from:r,insert:n},l=e.state.changes(s?[s,a]:a);e.focus(),e.dispatch({changes:l,selection:{anchor:l.mapPos(r,-1),head:l.mapPos(r,1)},userEvent:s?"move.drop":"input.drop"}),e.inputState.draggedContent=null}Nd.dragstart=(e,t)=>{let{selection:{main:n}}=e.state;if(t.target.draggable){let i=e.docView.tile.nearest(t.target);if(i&&i.isWidget()){let e=i.posAtStart,t=e+i.length;(e>=n.to||t<=n.from)&&(n=mc.range(e,t))}}let{inputState:i}=e;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=n,t.dataTransfer&&(t.dataTransfer.setData("Text",Ld(e.state,rp,e.state.sliceDoc(n.from,n.to))),t.dataTransfer.effectAllowed="copyMove"),!1},Nd.dragend=e=>(e.inputState.draggedContent=null,!1),Nd.drop=(e,t)=>{if(!t.dataTransfer)return!1;if(e.state.readOnly)return!0;let n=t.dataTransfer.files;if(n&&n.length){let i=Array(n.length),r=0,o=()=>{++r==n.length&&Hd(e,t,i.filter(e=>null!=e).join(e.state.lineBreak),!1)};for(let e=0;e<n.length;e++){let t=new FileReader;t.onerror=o,t.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(t.result)||(i[e]=t.result),o()},t.readAsText(n[e])}return!0}{let n=t.dataTransfer.getData("Text");if(n)return Hd(e,t,n,!0),!0}return!1},Nd.paste=(e,t)=>{if(e.state.readOnly)return!0;e.observer.flush();let n=Pd?null:t.clipboardData;return n?(Id(e,n.getData("text/plain")||n.getData("text/uri-list")),!0):(function(e){let t=e.dom.parentNode;if(!t)return;let n=t.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{e.focus(),n.remove(),Id(e,n.value)},50)}(e),!1)};let Ud=null;Nd.copy=Nd.cut=(e,t)=>{if(!hu(e.contentDOM,e.observer.selectionRange))return!1;let{text:n,ranges:i,linewise:r}=function(e){let t=[],n=[],i=!1;for(let i of e.selection.ranges)i.empty||(t.push(e.sliceDoc(i.from,i.to)),n.push(i));if(!t.length){let r=-1;for(let{from:i}of e.selection.ranges){let o=e.doc.lineAt(i);o.number>r&&(t.push(o.text),n.push({from:o.from,to:Math.min(e.doc.length,o.to+1)})),r=o.number}i=!0}return{text:Ld(e,rp,t.join(e.lineBreak)),ranges:n,linewise:i}}(e.state);if(!n&&!r)return!1;Ud=r?n:null,"cut"!=t.type||e.state.readOnly||e.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let o=Pd?null:t.clipboardData;return o?(o.clearData(),o.setData("text/plain",n),!0):(function(e,t){let n=e.dom.parentNode;if(!n)return;let i=n.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=t,i.focus(),i.selectionEnd=t.length,i.selectionStart=0,setTimeout(()=>{i.remove(),e.focus()},50)}(e,n),!1)};const Gd=Uc.define();function Kd(e,t){let n=[];for(let i of e.facet(np)){let r=i(e,t);r&&n.push(r)}return n.length?e.update({effects:n,annotations:Gd.of(!0)}):null}function Xd(e){setTimeout(()=>{let t=e.hasFocus;if(t!=e.inputState.notifiedFocused){let n=Kd(e.state,t);n?e.dispatch(n):e.update([])}},10)}Bd.focus=e=>{e.inputState.lastFocusTime=Date.now(),e.scrollDOM.scrollTop||!e.inputState.lastScrollTop&&!e.inputState.lastScrollLeft||(e.scrollDOM.scrollTop=e.inputState.lastScrollTop,e.scrollDOM.scrollLeft=e.inputState.lastScrollLeft),Xd(e)},Bd.blur=e=>{e.observer.clearSelectionRange(),Xd(e)},Bd.compositionstart=Bd.compositionupdate=e=>{e.observer.editContext||(null==e.inputState.compositionFirstChange&&(e.inputState.compositionFirstChange=!0),e.inputState.composing<0&&(e.inputState.composing=0))},Bd.compositionend=e=>{e.observer.editContext||(e.inputState.composing=-1,e.inputState.compositionEndedAt=Date.now(),e.inputState.compositionPendingKey=!0,e.inputState.compositionPendingChange=e.observer.pendingRecords().length>0,e.inputState.compositionFirstChange=null,Gh.chrome&&Gh.android?e.observer.flushSoon():e.inputState.compositionPendingChange?Promise.resolve().then(()=>e.observer.flush()):setTimeout(()=>{e.inputState.composing<0&&e.docView.hasComposition&&e.update([])},50))},Bd.contextmenu=e=>{e.inputState.lastContextMenu=Date.now()},Nd.beforeinput=(e,t)=>{var n,i;if("insertText"!=t.inputType&&"insertCompositionText"!=t.inputType||(e.inputState.insertingText=t.data,e.inputState.insertingTextAt=Date.now()),"insertReplacementText"==t.inputType&&e.observer.editContext){let i=null===(n=t.dataTransfer)||void 0===n?void 0:n.getData("text/plain"),r=t.getTargetRanges();if(i&&r.length){let t=r[0],n=e.posAtDOM(t.startContainer,t.startOffset),o=e.posAtDOM(t.endContainer,t.endOffset);return kd(e,{from:n,to:o,insert:e.state.toText(i)},null),!0}}let r;if(Gh.chrome&&Gh.android&&(r=Td.find(e=>e.inputType==t.inputType))&&(e.observer.delayAndroidKey(r.key,r.keyCode),"Backspace"==r.key||"Delete"==r.key)){let t=(null===(i=window.visualViewport)||void 0===i?void 0:i.height)||0;setTimeout(()=>{var n;((null===(n=window.visualViewport)||void 0===n?void 0:n.height)||0)>t+10&&e.hasFocus&&(e.contentDOM.blur(),e.focus())},100)}return Gh.ios&&"deleteContentForward"==t.inputType&&e.observer.flushSoon(),Gh.safari&&"insertText"==t.inputType&&e.inputState.composing>=0&&setTimeout(()=>Bd.compositionend(e,t),20),!1};const Yd=new Set;const Jd=["pre-wrap","normal","pre-line","break-spaces"];let Qd=!1;function Zd(){Qd=!1}class ef{constructor(e){this.lineWrapping=e,this.doc=Kl.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let n=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(n+=Math.max(0,Math.ceil((t-e-n*this.lineLength*.5)/this.lineLength))),this.lineHeight*n}heightForLine(e){if(!this.lineWrapping)return this.lineHeight;return(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return Jd.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let n=0;n<e.length;n++){let i=e[n];i<0?n++:this.heightSamples[Math.floor(10*i)]||(t=!0,this.heightSamples[Math.floor(10*i)]=!0)}return t}refresh(e,t,n,i,r,o){let s=Jd.indexOf(e)>-1,a=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=s;if(this.lineWrapping=s,this.lineHeight=t,this.charWidth=n,this.textHeight=i,this.lineLength=r,a){this.heightSamples={};for(let e=0;e<o.length;e++){let t=o[e];t<0?e++:this.heightSamples[Math.floor(10*t)]=!0}}return a}}class tf{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}}class nf{constructor(e,t,n,i,r){this.from=e,this.length=t,this.top=n,this.height=i,this._content=r}get type(){return"number"==typeof this._content?eu.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof ru?this._content.widget:null}get widgetLineBreaks(){return"number"==typeof this._content?this._content:0}join(e){let t=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new nf(this.from,this.length+e.length,this.top,this.height+e.height,t)}}var rf=function(e){return e[e.ByPos=0]="ByPos",e[e.ByHeight=1]="ByHeight",e[e.ByPosNoHeight=2]="ByPosNoHeight",e}(rf||(rf={}));const of=.001;class sf{constructor(e,t,n=2){this.length=e,this.height=t,this.flags=n}get outdated(){return(2&this.flags)>0}set outdated(e){this.flags=(e?2:0)|-3&this.flags}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>of&&(Qd=!0),this.height=e)}replace(e,t,n){return sf.of(n)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,n,i){let r=this,o=n.doc;for(let s=i.length-1;s>=0;s--){let{fromA:a,toA:l,fromB:c,toB:h}=i[s],u=r.lineAt(a,rf.ByPosNoHeight,n.setDoc(t),0,0),p=u.to>=l?u:r.lineAt(l,rf.ByPosNoHeight,n,0,0);for(h+=p.to-l,l=p.to;s>0&&u.from<=i[s-1].toA;)a=i[s-1].fromA,c=i[s-1].fromB,s--,a<u.from&&(u=r.lineAt(a,rf.ByPosNoHeight,n,0,0));c+=u.from-a,a=u.from;let d=ff.build(n.setDoc(o),e,c,h);r=af(r,r.replace(a,l,d))}return r.updateHeight(n,0)}static empty(){return new hf(0,0,0)}static of(e){if(1==e.length)return e[0];let t=0,n=e.length,i=0,r=0;for(;;)if(t==n)if(i>2*r){let r=e[t-1];r.break?e.splice(--t,1,r.left,null,r.right):e.splice(--t,1,r.left,r.right),n+=1+r.break,i-=r.size}else{if(!(r>2*i))break;{let t=e[n];t.break?e.splice(n,1,t.left,null,t.right):e.splice(n,1,t.left,t.right),n+=2+t.break,r-=t.size}}else if(i<r){let n=e[t++];n&&(i+=n.size)}else{let t=e[--n];t&&(r+=t.size)}let o=0;return null==e[t-1]?(o=1,t--):null==e[t]&&(o=1,n++),new pf(sf.of(e.slice(0,t)),o,sf.of(e.slice(n)))}}function af(e,t){return e==t?e:(e.constructor!=t.constructor&&(Qd=!0),t)}sf.prototype.size=1;const lf=tu.replace({});class cf extends sf{constructor(e,t,n){super(e,t),this.deco=n,this.spaceAbove=0}mainBlock(e,t){return new nf(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(e,t,n,i){return this.spaceAbove&&e<n+this.spaceAbove?new nf(i,0,n,this.spaceAbove,lf):this.mainBlock(n,i)}lineAt(e,t,n,i,r){let o=this.mainBlock(i,r);return this.spaceAbove?this.blockAt(0,n,i,r).join(o):o}forEachLine(e,t,n,i,r,o){e<=r+this.length&&t>=r&&o(this.lineAt(0,rf.ByPos,n,i,r))}setMeasuredHeight(e){let t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}updateHeight(e,t=0,n=!1,i){return i&&i.from<=t&&i.more&&this.setMeasuredHeight(i),this.outdated=!1,this}toString(){return`block(${this.length})`}}class hf extends cf{constructor(e,t,n){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=n}mainBlock(e,t){return new nf(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,t,n){let i=n[0];return 1==n.length&&(i instanceof hf||i instanceof uf&&4&i.flags)&&Math.abs(this.length-i.length)<10?(i instanceof uf?i=new hf(i.length,this.height,this.spaceAbove):i.height=this.height,this.outdated||(i.outdated=!1),i):sf.of(n)}updateHeight(e,t=0,n=!1,i){return i&&i.from<=t&&i.more?this.setMeasuredHeight(i):(n||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class uf extends sf{constructor(e){super(e,0)}heightMetrics(e,t){let n,i=e.doc.lineAt(t).number,r=e.doc.lineAt(t+this.length).number,o=r-i+1,s=0;if(e.lineWrapping){let t=Math.min(this.height,e.lineHeight*o);n=t/o,this.length>o+1&&(s=(this.height-t)/(this.length-o-1))}else n=this.height/o;return{firstLine:i,lastLine:r,perLine:n,perChar:s}}blockAt(e,t,n,i){let{firstLine:r,lastLine:o,perLine:s,perChar:a}=this.heightMetrics(t,i);if(t.lineWrapping){let r=i+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-n)/this.height))*this.length)),o=t.doc.lineAt(r),l=s+o.length*a,c=Math.max(n,e-l/2);return new nf(o.from,o.length,c,l,0)}{let i=Math.max(0,Math.min(o-r,Math.floor((e-n)/s))),{from:a,length:l}=t.doc.line(r+i);return new nf(a,l,n+s*i,s,0)}}lineAt(e,t,n,i,r){if(t==rf.ByHeight)return this.blockAt(e,n,i,r);if(t==rf.ByPosNoHeight){let{from:t,to:i}=n.doc.lineAt(e);return new nf(t,i-t,0,0,0)}let{firstLine:o,perLine:s,perChar:a}=this.heightMetrics(n,r),l=n.doc.lineAt(e),c=s+l.length*a,h=l.number-o,u=i+s*h+a*(l.from-r-h);return new nf(l.from,l.length,Math.max(i,Math.min(u,i+this.height-c)),c,0)}forEachLine(e,t,n,i,r,o){e=Math.max(e,r),t=Math.min(t,r+this.length);let{firstLine:s,perLine:a,perChar:l}=this.heightMetrics(n,r);for(let c=e,h=i;c<=t;){let t=n.doc.lineAt(c);if(c==e){let n=t.number-s;h+=a*n+l*(e-r-n)}let i=a+l*t.length;o(new nf(t.from,t.length,h,i,0)),h+=i,c=t.to+1}}replace(e,t,n){let i=this.length-t;if(i>0){let e=n[n.length-1];e instanceof uf?n[n.length-1]=new uf(e.length+i):n.push(null,new uf(i-1))}if(e>0){let t=n[0];t instanceof uf?n[0]=new uf(e+t.length):n.unshift(new uf(e-1),null)}return sf.of(n)}decomposeLeft(e,t){t.push(new uf(e-1),null)}decomposeRight(e,t){t.push(null,new uf(this.length-e-1))}updateHeight(e,t=0,n=!1,i){let r=t+this.length;if(i&&i.from<=t+this.length&&i.more){let n=[],o=Math.max(t,i.from),s=-1;for(i.from>t&&n.push(new uf(i.from-t-1).updateHeight(e,t));o<=r&&i.more;){let t=e.doc.lineAt(o).length;n.length&&n.push(null);let r=i.heights[i.index++],a=0;r<0&&(a=-r,r=i.heights[i.index++]),-1==s?s=r:Math.abs(r-s)>=of&&(s=-2);let l=new hf(t,r,a);l.outdated=!1,n.push(l),o+=t+1}o<=r&&n.push(null,new uf(r-o).updateHeight(e,o));let a=sf.of(n);return(s<0||Math.abs(a.height-this.height)>=of||Math.abs(s-this.heightMetrics(e,t).perLine)>=of)&&(Qd=!0),af(this,a)}return(n||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class pf extends sf{constructor(e,t,n){super(e.length+t+n.length,e.height+n.height,t|(e.outdated||n.outdated?2:0)),this.left=e,this.right=n,this.size=e.size+n.size}get break(){return 1&this.flags}blockAt(e,t,n,i){let r=n+this.left.height;return e<r?this.left.blockAt(e,t,n,i):this.right.blockAt(e,t,r,i+this.left.length+this.break)}lineAt(e,t,n,i,r){let o=i+this.left.height,s=r+this.left.length+this.break,a=t==rf.ByHeight?e<o:e<s,l=a?this.left.lineAt(e,t,n,i,r):this.right.lineAt(e,t,n,o,s);if(this.break||(a?l.to<s:l.from>s))return l;let c=t==rf.ByPosNoHeight?rf.ByPosNoHeight:rf.ByPos;return a?l.join(this.right.lineAt(s,c,n,o,s)):this.left.lineAt(s,c,n,i,r).join(l)}forEachLine(e,t,n,i,r,o){let s=i+this.left.height,a=r+this.left.length+this.break;if(this.break)e<a&&this.left.forEachLine(e,t,n,i,r,o),t>=a&&this.right.forEachLine(e,t,n,s,a,o);else{let l=this.lineAt(a,rf.ByPos,n,i,r);e<l.from&&this.left.forEachLine(e,l.from-1,n,i,r,o),l.to>=e&&l.from<=t&&o(l),t>l.to&&this.right.forEachLine(l.to+1,t,n,s,a,o)}}replace(e,t,n){let i=this.left.length+this.break;if(t<i)return this.balanced(this.left.replace(e,t,n),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-i,t-i,n));let r=[];e>0&&this.decomposeLeft(e,r);let o=r.length;for(let e of n)r.push(e);if(e>0&&df(r,o-1),t<this.length){let e=r.length;this.decomposeRight(t,r),df(r,e)}return sf.of(r)}decomposeLeft(e,t){let n=this.left.length;if(e<=n)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(n++,e>=n&&t.push(null)),e>n&&this.right.decomposeLeft(e-n,t)}decomposeRight(e,t){let n=this.left.length,i=n+this.break;if(e>=i)return this.right.decomposeRight(e-i,t);e<n&&this.left.decomposeRight(e,t),this.break&&e<i&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?sf.of(this.break?[e,null,t]:[e,t]):(this.left=af(this.left,e),this.right=af(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,n=!1,i){let{left:r,right:o}=this,s=t+r.length+this.break,a=null;return i&&i.from<=t+r.length&&i.more?a=r=r.updateHeight(e,t,n,i):r.updateHeight(e,t,n),i&&i.from<=s+o.length&&i.more?a=o=o.updateHeight(e,s,n,i):o.updateHeight(e,s,n),a?this.balanced(r,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function df(e,t){let n,i;null==e[t]&&(n=e[t-1])instanceof uf&&(i=e[t+1])instanceof uf&&e.splice(t-1,3,new uf(n.length+1+i.length))}class ff{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let e=Math.min(t,this.lineEnd),n=this.nodes[this.nodes.length-1];n instanceof hf?n.length+=e-this.pos:(e>this.pos||!this.isCovered)&&this.nodes.push(new hf(e-this.pos,-1,0)),this.writtenTo=e,t>e&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,n){if(e<t||n.heightRelevant){let i=n.widget?n.widget.estimatedHeight:0,r=n.widget?n.widget.lineBreaks:0;i<0&&(i=this.oracle.lineHeight);let o=t-e;n.block?this.addBlock(new cf(o,i,n)):(o||r||i>=5)&&this.addLineDeco(i,r,o)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||null==this.nodes[this.nodes.length-1])&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new hf(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let n=new uf(t-e);return this.oracle.doc.lineAt(e).to==t&&(n.flags|=4),n}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof hf)return e;let t=new hf(0,-1,0);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,n){let i=this.ensureLine();i.length+=n,i.collapsed+=n,i.widgetHeight=Math.max(i.widgetHeight,e),i.breaks+=t,this.writtenTo=this.pos=this.pos+n}finish(e){let t=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||t instanceof hf||this.isCovered?(this.writtenTo<this.pos||null==t)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new hf(0,-1,0));let n=e;for(let e of this.nodes)e instanceof hf&&e.updateHeight(this.oracle,n),n+=e?e.length:1;return this.nodes}static build(e,t,n,i){let r=new ff(n,e);return fh.spans(t,n,i,r,0),r.finish(n)}}class gf{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,n,i){(e<t||n&&n.heightRelevant||i&&i.heightRelevant)&&su(e,t,this.changes,5)}}function mf(e,t){let n=e.getBoundingClientRect(),i=e.ownerDocument,r=i.defaultView||window,o=Math.max(0,n.left),s=Math.min(r.innerWidth,n.right),a=Math.max(0,n.top),l=Math.min(r.innerHeight,n.bottom);for(let t=e.parentNode;t&&t!=i.body;)if(1==t.nodeType){let n=t,i=window.getComputedStyle(n);if((n.scrollHeight>n.clientHeight||n.scrollWidth>n.clientWidth)&&"visible"!=i.overflow){let i=n.getBoundingClientRect();o=Math.max(o,i.left),s=Math.min(s,i.right),a=Math.max(a,i.top),l=Math.min(t==e.parentNode?r.innerHeight:l,i.bottom)}t="absolute"==i.position||"fixed"==i.position?n.offsetParent:n.parentNode}else{if(11!=t.nodeType)break;t=t.host}return{left:o-n.left,right:Math.max(o,s)-n.left,top:a-(n.top+t),bottom:Math.max(a,l)-(n.top+t)}}function yf(e,t){let n=e.getBoundingClientRect();return{left:0,right:n.right-n.left,top:t,bottom:n.bottom-(n.top+t)}}class vf{constructor(e,t,n,i){this.from=e,this.to=t,this.size=n,this.displaySize=i}static same(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let i=e[n],r=t[n];if(i.from!=r.from||i.to!=r.to||i.size!=r.size)return!1}return!0}draw(e,t){return tu.replace({widget:new wf(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}}class wf extends Zh{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}}class bf{constructor(e,t){this.view=e,this.state=t,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scaleX=1,this.scaleY=1,this.scrollOffset=0,this.scrolledToBottom=!1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=Sf,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=Ou.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let n=t.facet(vp).some(e=>"function"!=typeof e&&"cm-lineWrapping"==e.class);this.heightOracle=new ef(n),this.stateDeco=Cf(t),this.heightMap=sf.empty().applyChanges(this.stateDeco,Kl.empty,this.heightOracle.setDoc(t.doc),[new Ap(0,0,0,t.doc.length)]);for(let e=0;e<2&&(this.viewport=this.getViewport(0,null),this.updateForViewport());e++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=tu.set(this.lineGaps.map(e=>e.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let n=0;n<=1;n++){let i=n?t.head:t.anchor;if(!e.some(({from:e,to:t})=>i>=e&&i<=t)){let{from:t,to:n}=this.lineBlockAt(i);e.push(new xf(t,n))}}return this.viewports=e.sort((e,t)=>e.from-t.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?Sf:new Ef(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(Mf(e,this.scaler))})}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=Cf(this.state);let i=e.changedRanges,r=Ap.extendWithRanges(i,function(e,t,n){let i=new gf;return fh.compare(e,t,n,i,0),i.changes}(n,this.stateDeco,e?e.changes:lc.empty(this.state.doc.length))),o=this.heightMap.height,s=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);Zd(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),r),(this.heightMap.height!=o||Qd)&&(e.flags|=2),s?(this.scrollAnchorPos=e.changes.mapPos(s.from,-1),this.scrollAnchorHeight=s.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let a=r.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<a.from||t.range.head>a.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,t));let l=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,e.flags|=this.updateForViewport(),(l||!e.changes.empty||2&e.flags)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(sp)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,t=e.contentDOM,n=window.getComputedStyle(t),i=this.heightOracle,r=n.whiteSpace;this.defaultTextDirection="rtl"==n.direction?Ou.RTL:Ou.LTR;let o=this.heightOracle.mustRefreshForWrapping(r)||"refresh"===this.mustMeasureContent,s=t.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=s.height;this.contentDOMHeight=s.height,this.mustMeasureContent=!1;let l=0,c=0;if(s.width&&s.height){let{scaleX:e,scaleY:n}=wu(t,s);(e>.005&&Math.abs(this.scaleX-e)>.005||n>.005&&Math.abs(this.scaleY-n)>.005)&&(this.scaleX=e,this.scaleY=n,l|=16,o=a=!0)}let h=(parseInt(n.paddingTop)||0)*this.scaleY,u=(parseInt(n.paddingBottom)||0)*this.scaleY;this.paddingTop==h&&this.paddingBottom==u||(this.paddingTop=h,this.paddingBottom=u,l|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(i.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,l|=16);let p=bu(this.view.contentDOM,!1).y;p!=this.scrollParent&&(this.scrollParent=p,this.scrollAnchorHeight=-1,this.scrollOffset=0);let d=this.getScrollOffset();this.scrollOffset!=d&&(this.scrollAnchorHeight=-1,this.scrollOffset=d),this.scrolledToBottom=Mu(this.scrollParent||e.win);let f=(this.printing?yf:mf)(t,this.paddingTop),g=f.top-this.pixelViewport.top,m=f.bottom-this.pixelViewport.bottom;this.pixelViewport=f;let y=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(y!=this.inView&&(this.inView=y,y&&(a=!0)),!this.inView&&!this.scrollTarget&&!function(e){let t=e.getBoundingClientRect(),n=e.ownerDocument.defaultView||window;return t.left<n.innerWidth&&t.right>0&&t.top<n.innerHeight&&t.bottom>0}(e.dom))return 0;let v=s.width;if(this.contentDOMWidth==v&&this.editorHeight==e.scrollDOM.clientHeight||(this.contentDOMWidth=s.width,this.editorHeight=e.scrollDOM.clientHeight,l|=16),a){let t=e.docView.measureVisibleLineHeights(this.viewport);if(i.mustRefreshForHeights(t)&&(o=!0),o||i.lineWrapping&&Math.abs(v-this.contentDOMWidth)>i.charWidth){let{lineHeight:n,charWidth:s,textHeight:a}=e.docView.measureTextSize();o=n>0&&i.refresh(r,n,s,a,Math.max(5,v/s),t),o&&(e.docView.minWidth=0,l|=16)}g>0&&m>0?c=Math.max(g,m):g<0&&m<0&&(c=Math.min(g,m)),Zd();for(let n of this.viewports){let r=n.from==this.viewport.from?t:e.docView.measureVisibleLineHeights(n);this.heightMap=(o?sf.empty().applyChanges(this.stateDeco,Kl.empty,this.heightOracle,[new Ap(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(i,0,o,new tf(n.from,r))}Qd&&(l|=2)}let w=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return w&&(2&l&&(l|=this.updateScaler()),this.viewport=this.getViewport(c,this.scrollTarget),l|=this.updateForViewport()),(2&l||w)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),l|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),l}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let n=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),i=this.heightMap,r=this.heightOracle,{visibleTop:o,visibleBottom:s}=this,a=new xf(i.lineAt(o-1e3*n,rf.ByHeight,r,0,0).from,i.lineAt(s+1e3*(1-n),rf.ByHeight,r,0,0).to);if(t){let{head:e}=t.range;if(e<a.from||e>a.to){let n,o=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),s=i.lineAt(e,rf.ByPos,r,0,0);n="center"==t.y?(s.top+s.bottom)/2-o/2:"start"==t.y||"nearest"==t.y&&e<a.from?s.top:s.bottom-o,a=new xf(i.lineAt(n-500,rf.ByHeight,r,0,0).from,i.lineAt(n+o+500,rf.ByHeight,r,0,0).to)}}return a}mapViewport(e,t){let n=t.mapPos(e.from,-1),i=t.mapPos(e.to,1);return new xf(this.heightMap.lineAt(n,rf.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(i,rf.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},n=0){if(!this.inView)return!0;let{top:i}=this.heightMap.lineAt(e,rf.ByPos,this.heightOracle,0,0),{bottom:r}=this.heightMap.lineAt(t,rf.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:s}=this;return(0==e||i<=o-Math.max(10,Math.min(-n,250)))&&(t==this.state.doc.length||r>=s+Math.max(10,Math.min(n,250)))&&i>o-2e3&&r<s+2e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let n=[];for(let i of e)t.touchesRange(i.from,i.to)||n.push(new vf(t.mapPos(i.from),t.mapPos(i.to),i.size,i.displaySize));return n}ensureLineGaps(e,t){let n=this.heightOracle.lineWrapping,i=n?1e4:2e3,r=i>>1,o=i<<1;if(this.defaultTextDirection!=Ou.LTR&&!n)return[];let s=[],a=(i,o,l,c)=>{if(o-i<r)return;let h=this.state.selection.main,u=[h.from];h.empty||u.push(h.to);for(let e of u)if(e>i&&e<o)return a(i,e-10,l,c),void a(e+10,o,l,c);let p=function(e,t){for(let n of e)if(t(n))return n;return}(e,e=>e.from>=l.from&&e.to<=l.to&&Math.abs(e.from-i)<r&&Math.abs(e.to-o)<r&&!u.some(t=>e.from<t&&e.to>t));if(!p){if(o<l.to&&t&&n&&t.visibleRanges.some(e=>e.from<=o&&e.to>=o)){let e=t.moveToLineBoundary(mc.cursor(o),!1,!0).head;e>i&&(o=e)}let e=this.gapSize(l,i,o,c);p=new vf(i,o,e,n||e<2e6?e:2e6)}s.push(p)},l=t=>{if(t.length<o||t.type!=eu.Text)return;let r=function(e,t,n){let i=[],r=e,o=0;fh.spans(n,e,t,{span(){},point(e,t){e>r&&(i.push({from:r,to:e}),o+=e-r),r=t}},20),r<t&&(i.push({from:r,to:t}),o+=t-r);return{total:o,ranges:i}}(t.from,t.to,this.stateDeco);if(r.total<o)return;let s,l,c=this.scrollTarget?this.scrollTarget.range.head:null;if(n){let e,n,o=i/this.heightOracle.lineLength*this.heightOracle.lineHeight;if(null!=c){let i=kf(r,c),s=((this.visibleBottom-this.visibleTop)/2+o)/t.height;e=i-s,n=i+s}else e=(this.visibleTop-t.top-o)/t.height,n=(this.visibleBottom-t.top+o)/t.height;s=_f(r,e),l=_f(r,n)}else{let n=r.total*this.heightOracle.charWidth,o=i*this.heightOracle.charWidth,a=0;if(n>2e6)for(let n of e)n.from>=t.from&&n.from<t.to&&n.size!=n.displaySize&&n.from*this.heightOracle.charWidth+a<this.pixelViewport.left&&(a=n.size-n.displaySize);let h,u,p=this.pixelViewport.left+a,d=this.pixelViewport.right+a;if(null!=c){let e=kf(r,c),t=((d-p)/2+o)/n;h=e-t,u=e+t}else h=(p-o)/n,u=(d+o)/n;s=_f(r,h),l=_f(r,u)}s>t.from&&a(t.from,s,t,r),l<t.to&&a(l,t.to,t,r)};for(let e of this.viewportLines)Array.isArray(e.type)?e.type.forEach(l):l(e);return s}gapSize(e,t,n,i){let r=kf(i,n)-kf(i,t);return this.heightOracle.lineWrapping?e.height*r:i.total*this.heightOracle.charWidth*r}updateLineGaps(e){vf.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=tu.set(e.map(e=>e.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let n=[];fh.spans(t,this.viewport.from,this.viewport.to,{span(e,t){n.push({from:e,to:t})},point(){}},20);let i=0;if(n.length!=this.visibleRanges.length)i=12;else for(let t=0;t<n.length&&!(8&i);t++){let r=this.visibleRanges[t],o=n[t];r.from==o.from&&r.to==o.to||(i|=4,e&&e.mapPos(r.from,-1)==o.from&&e.mapPos(r.to,1)==o.to||(i|=8))}return this.visibleRanges=n,i}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||Mf(this.heightMap.lineAt(e,rf.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||Mf(this.heightMap.lineAt(this.scaler.fromDOM(e),rf.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return(this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top)*this.scaleY}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return Mf(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class xf{constructor(e,t){this.from=e,this.to=t}}function _f({total:e,ranges:t},n){if(n<=0)return t[0].from;if(n>=1)return t[t.length-1].to;let i=Math.floor(e*n);for(let e=0;;e++){let{from:n,to:r}=t[e],o=r-n;if(i<=o)return n+i;i-=o}}function kf(e,t){let n=0;for(let{from:i,to:r}of e.ranges){if(t<=r){n+=t-i;break}n+=r-i}return n/e.total}const Sf={toDOM:e=>e,fromDOM:e=>e,scale:1,eq(e){return e==this}};function Cf(e){let t=e.facet(wp).filter(e=>"function"!=typeof e),n=e.facet(xp).filter(e=>"function"!=typeof e);return n.length&&t.push(fh.join(n)),t}class Ef{constructor(e,t,n){let i=0,r=0,o=0;this.viewports=n.map(({from:n,to:r})=>{let o=t.lineAt(n,rf.ByPos,e,0,0).top,s=t.lineAt(r,rf.ByPos,e,0,0).bottom;return i+=s-o,{from:n,to:r,top:o,bottom:s,domTop:0,domBottom:0}}),this.scale=(7e6-i)/(t.height-i);for(let e of this.viewports)e.domTop=o+(e.top-r)*this.scale,o=e.domBottom=e.domTop+(e.bottom-e.top),r=e.bottom}toDOM(e){for(let t=0,n=0,i=0;;t++){let r=t<this.viewports.length?this.viewports[t]:null;if(!r||e<r.top)return i+(e-n)*this.scale;if(e<=r.bottom)return r.domTop+(e-r.top);n=r.bottom,i=r.domBottom}}fromDOM(e){for(let t=0,n=0,i=0;;t++){let r=t<this.viewports.length?this.viewports[t]:null;if(!r||e<r.domTop)return n+(e-i)/this.scale;if(e<=r.domBottom)return r.top+(e-r.domTop);n=r.bottom,i=r.domBottom}}eq(e){return e instanceof Ef&&(this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every((t,n)=>t.from==e.viewports[n].from&&t.to==e.viewports[n].to))}}function Mf(e,t){if(1==t.scale)return e;let n=t.toDOM(e.top),i=t.toDOM(e.bottom);return new nf(e.from,e.length,n,i-n,Array.isArray(e._content)?e._content.map(e=>Mf(e,t)):e._content)}const Af=wc.define({combine:e=>e.join(" ")}),Tf=wc.define({combine:e=>e.indexOf(!0)>-1}),Rf=Th.newName(),Of=Th.newName(),Df=Th.newName(),qf={"&light":"."+Of,"&dark":"."+Df};function Nf(e,t,n){return new Th(t,{finish:t=>/&/.test(t)?t.replace(/&\w*/,t=>{if("&"==t)return e;if(!n||!n[t])throw new RangeError(`Unsupported selector: ${t}`);return n[t]}):e+" "+t})}const Bf=Nf("."+Rf,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:'url(\'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>\')',backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},qf),Pf={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Lf=Gh.ie&&Gh.ie_version<=11;class If{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new xu,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let e of t)this.queue.push(e);(Gh.ie&&Gh.ie_version<=11||Gh.ios&&e.composing)&&t.some(e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():this.flush()}),!window.EditContext||!Gh.android||!1===e.constructor.EDIT_CONTEXT||Gh.chrome&&Gh.chrome_version<126||(this.editContext=new Vf(e),e.state.facet(pp)&&(e.contentDOM.editContext=this.editContext.editContext)),Lf&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),"function"==typeof ResizeObserver&&(this.resizeScroll=new ResizeObserver(()=>{var e;(null===(e=this.view.docView)||void 0===e?void 0:e.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),"function"==typeof IntersectionObserver&&(this.intersection=new IntersectionObserver(e=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),e.length>0&&e[e.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(e=>{e.length>0&&e[e.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){("change"!=e.type&&e.type||e.matches)&&(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,n)=>t!=e[n]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:n}=this,i=this.selectionRange;if(n.state.facet(pp)?n.root.activeElement!=this.dom:!hu(this.dom,i))return;let r=i.anchorNode&&n.docView.tile.nearest(i.anchorNode);r&&r.isWidget()&&r.widget.ignoreEvent(e)?t||(this.selectionChanged=!1):(Gh.ie&&Gh.ie_version<=11||Gh.android&&Gh.chrome)&&!n.state.selection.main.empty&&i.focusNode&&pu(i.focusNode,i.focusOffset,i.anchorNode,i.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=lu(e.root);if(!t)return!1;let n=Gh.safari&&11==e.root.nodeType&&e.root.activeElement==this.dom&&function(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return Ff(e,n)}let n=null;function i(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.contentDOM.addEventListener("beforeinput",i,!0),e.dom.ownerDocument.execCommand("indent"),e.contentDOM.removeEventListener("beforeinput",i,!0),n?Ff(e,n):null}(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;let i=hu(this.dom,n);return i&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&function(e,t){let n=t.focusNode,i=t.focusOffset;if(!n||t.anchorNode!=n||t.anchorOffset!=i)return!1;for(i=Math.min(i,mu(n));;)if(i){if(1!=n.nodeType)return!1;let e=n.childNodes[i-1];"false"==e.contentEditable?i--:(n=e,i=mu(n))}else{if(n==e)return!0;i=du(n),n=n.parentNode}}(this.dom,n)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(n),i&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let n=this.dom;n;)if(1==n.nodeType)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==n?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(n),n=n.assignedSlot||n.parentNode;else{if(11!=n.nodeType)break;n=n.host}if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let e of this.scrollTargets)e.removeEventListener("scroll",this.onScroll);for(let e of this.scrollTargets=t)e.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,Pf),Lf&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),Lf&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){var n;if(!this.delayedAndroidKey){let e=()=>{let e=this.delayedAndroidKey;if(e){this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=e.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&e.force&&Eu(this.dom,e.key,e.keyCode)}};this.flushingAndroidKey=this.view.win.requestAnimationFrame(e)}this.delayedAndroidKey&&"Enter"!=e||(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(null===(n=this.delayedAndroidKey)||void 0===n?void 0:n.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,n=-1,i=!1;for(let r of e){let e=this.readMutation(r);e&&(e.typeOver&&(i=!0),-1==t?({from:t,to:n}=e):(t=Math.min(e.from,t),n=Math.max(e.to,n)))}return{from:t,to:n,typeOver:i}}readChange(){let{from:e,to:t,typeOver:n}=this.processRecords(),i=this.selectionChanged&&hu(this.dom,this.selectionRange);if(e<0&&!i)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let r=new bd(this.view,e,t,n);return this.view.docView.domChanged={newSel:r.newSel?r.newSel.main:null},r}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let n=this.view.state,i=_d(this.view,t);return this.view.state==n&&(t.domChanged||t.newSel&&!Cd(this.view.state.selection,t.newSel.main))&&this.view.update([]),i}readMutation(e){let t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty("attributes"==e.type),"childList"==e.type){let n=jf(t,e.previousSibling||e.target.previousSibling,-1),i=jf(t,e.nextSibling||e.target.nextSibling,1);return{from:n?t.posAfter(n):t.posAtStart,to:i?t.posBefore(i):t.posAtEnd,typeOver:!1}}return"characterData"==e.type?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(pp)!=e.state.facet(pp)&&(e.view.contentDOM.editContext=e.state.facet(pp)?this.editContext.editContext:null))}destroy(){var e,t,n;this.stop(),null===(e=this.intersection)||void 0===e||e.disconnect(),null===(t=this.gapIntersection)||void 0===t||t.disconnect(),null===(n=this.resizeScroll)||void 0===n||n.disconnect();for(let e of this.scrollTargets)e.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function jf(e,t,n){for(;t;){let i=Op.get(t);if(i&&i.parent==e)return i;let r=t.parentNode;t=r!=e.dom?r:n>0?t.nextSibling:t.previousSibling}return null}function Ff(e,t){let n=t.startContainer,i=t.startOffset,r=t.endContainer,o=t.endOffset,s=e.docView.domAtPos(e.state.selection.main.anchor,1);return pu(s.node,s.offset,r,o)&&([n,i,r,o]=[r,o,n,i]),{anchorNode:n,anchorOffset:i,focusNode:r,focusOffset:o}}class Vf{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=n=>{let i=e.state.selection.main,{anchor:r,head:o}=i,s=this.toEditorPos(n.updateRangeStart),a=this.toEditorPos(n.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:n.updateRangeStart,editorBase:s,drifted:!1});let l=a-s>n.text.length;s==this.from&&r<this.from?s=r:a==this.to&&r>this.to&&(a=r);let c=Sd(e.state.sliceDoc(s,a),n.text,(l?i.from:i.to)-s,l?"end":null);if(!c){let t=mc.single(this.toEditorPos(n.selectionStart),this.toEditorPos(n.selectionEnd));return void(Cd(t,i)||e.dispatch({selection:t,userEvent:"select"}))}let h={from:c.from+s,to:c.toA+s,insert:Kl.of(n.text.slice(c.from,c.toB).split("\n"))};if((Gh.mac||Gh.android)&&h.from==o-1&&/^\. ?$/.test(n.text)&&"off"==e.contentDOM.getAttribute("autocorrect")&&(h={from:s,to:a,insert:Kl.of([n.text.replace("."," ")])}),this.pendingContextChange=h,!e.state.readOnly){let t=this.to-this.from+(h.to-h.from+h.insert.length);kd(e,h,mc.single(this.toEditorPos(n.selectionStart,t),this.toEditorPos(n.selectionEnd,t)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),h.from<h.to&&!h.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,n.updateRangeStart-1),Math.min(t.text.length,n.updateRangeStart+1)))&&this.handlers.compositionend(n)},this.handlers.characterboundsupdate=n=>{let i=[],r=null;for(let t=this.toEditorPos(n.rangeStart),o=this.toEditorPos(n.rangeEnd);t<o;t++){let n=e.coordsForChar(t);r=n&&new DOMRect(n.left,n.top,n.right-n.left,n.bottom-n.top)||r||new DOMRect,i.push(r)}t.updateCharacterBounds(n.rangeStart,i)},this.handlers.textformatupdate=t=>{let n=[];for(let e of t.getTextFormats()){let t=e.underlineStyle,i=e.underlineThickness;if(!/none/i.test(t)&&!/none/i.test(i)){let r=this.toEditorPos(e.rangeStart),o=this.toEditorPos(e.rangeEnd);if(r<o){let e=`text-decoration: underline ${/^[a-z]/.test(t)?t+" ":"Dashed"==t?"dashed ":"Squiggle"==t?"wavy ":""}${/thin/i.test(i)?1:2}px`;n.push(tu.mark({attributes:{style:e}}).range(r,o))}}}e.dispatch({effects:hp.of(tu.set(n))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:t}=this.composing;this.composing=null,t&&this.reset(e.state)}};for(let e in this.handlers)t.addEventListener(e,this.handlers[e]);this.measureReq={read:e=>{this.editContext.updateControlBounds(e.contentDOM.getBoundingClientRect());let t=lu(e.root);t&&t.rangeCount&&this.editContext.updateSelectionBounds(t.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,n=!1,i=this.pendingContextChange;return e.changes.iterChanges((r,o,s,a,l)=>{if(n)return;let c=l.length-(o-r);if(i&&o>=i.to){if(i.from==r&&i.to==o&&i.insert.eq(l))return i=this.pendingContextChange=null,t+=c,void(this.to+=c);i=null,this.revertPending(e.state)}if(r+=t,(o+=t)<=this.from)this.from+=c,this.to+=c;else if(r<this.to){if(r<this.from||o>this.to||this.to-this.from+l.length>3e4)return void(n=!0);this.editContext.updateText(this.toContextPos(r),this.toContextPos(o),l.toString()),this.to+=c}t+=c}),i&&!n&&this.revertPending(e.state),!n}update(e){let t=this.pendingContextChange,n=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(n.from,n.to)&&e.transactions.some(e=>!e.isUserEvent("input.type")&&e.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):this.applyEdits(e)&&this.rangeIsValid(e.state)?(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state):(this.pendingContextChange=null,this.reset(e.state)),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,n=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),i=this.toContextPos(t.head);this.editContext.selectionStart==n&&this.editContext.selectionEnd==i||this.editContext.updateSelection(n,i)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>3e4)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let n=this.composing;return n&&n.drifted?n.editorBase+(e-n.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class $f{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:n}=e;this.dispatchTransactions=e.dispatchTransactions||n&&(e=>e.forEach(e=>n(e,this)))||(e=>this.update(e)),this.dispatch=this.dispatch.bind(this),this._root=e.root||function(e){for(;e;){if(e&&(9==e.nodeType||11==e.nodeType&&e.host))return e;e=e.assignedSlot||e.parentNode}return null}(e.parent)||document,this.viewState=new bf(this,e.state||ah.create(e)),e.scrollTo&&e.scrollTo.is(cp)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(fp).map(e=>new mp(e));for(let e of this.plugins)e.update(this);this.observer=new If(this),this.inputState=new Ed(this),this.inputState.ensureHandlers(this.plugins),this.docView=new ed(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),(null===(t=document.fonts)||void 0===t?void 0:t.ready)&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let t=1==e.length&&e[0]instanceof Yc?e:1==e.length&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(0!=this.updateState)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t,n=!1,i=!1,r=this.state;for(let t of e){if(t.startState!=r)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");r=t.state}if(this.destroyed)return void(this.viewState.state=r);let o=this.hasFocus,s=0,a=null;e.some(e=>e.annotation(Gd))?(this.inputState.notifiedFocused=o,s=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=Kd(r,o),a||(s=1));let l=this.observer.delayedAndroidKey,c=null;if(l?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(r.doc)||!this.state.selection.eq(r.selection))&&(c=null)):this.observer.clear(),r.facet(ah.phrases)!=this.state.facet(ah.phrases))return this.setState(r);t=Tp.create(this,r,e),t.flags|=s;let h=this.viewState.scrollTarget;try{this.updateState=2;for(let t of e){if(h&&(h=h.map(t.changes)),t.scrollIntoView){let{main:e}=t.state.selection,{x:n,y:i}=this.state.facet($f.cursorScrollMargin);h=new lp(e.empty?e:mc.cursor(e.head,e.head>e.anchor?-1:1),"nearest","nearest",i,n)}for(let e of t.effects)e.is(cp)&&(h=e.value.clip(this.state))}this.viewState.update(t,h),this.bidiCache=Hf.update(this.bidiCache,t.changes),t.empty||(this.updatePlugins(t),this.inputState.update(t)),n=this.docView.update(t),this.state.facet(Mp)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(e=>e.isUserEvent("select.pointer")))}finally{this.updateState=0}if(t.startState.facet(Af)!=t.state.facet(Af)&&(this.viewState.mustMeasureContent=!0),(n||i||h||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!t.empty)for(let e of this.state.facet(ep))try{e(t)}catch(e){up(this.state,e,"update listener")}(a||c)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!_d(this,c)&&l.force&&Eu(this.contentDOM,l.key,l.keyCode)})}setState(e){if(0!=this.updateState)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed)return void(this.viewState.state=e);this.updateState=2;let t=this.hasFocus;try{for(let e of this.plugins)e.destroy(this);this.viewState=new bf(this,e),this.plugins=e.facet(fp).map(e=>new mp(e)),this.pluginMap.clear();for(let e of this.plugins)e.update(this);this.docView.destroy(),this.docView=new ed(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(fp),n=e.state.facet(fp);if(t!=n){let i=[];for(let r of n){let n=t.indexOf(r);if(n<0)i.push(new mp(r));else{let t=this.plugins[n];t.mustUpdate=e,i.push(t)}}for(let t of this.plugins)t.mustUpdate!=e&&t.destroy(this);this.plugins=i,this.pluginMap.clear()}else for(let t of this.plugins)t.mustUpdate=e;for(let e=0;e<this.plugins.length;e++)this.plugins[e].update(this);t!=n&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(e){up(this.state,e,"doc view update listener")}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey)return this.measureScheduled=-1,void this.requestMeasure();this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,n=this.viewState.scrollParent,i=this.viewState.getScrollOffset(),{scrollAnchorPos:r,scrollAnchorHeight:o}=this.viewState;Math.abs(i-this.viewState.scrollOffset)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let e=0;;e++){if(o<0)if(Mu(n||this.win))r=-1,o=this.viewState.heightMap.height;else{let e=this.viewState.scrollAnchorAt(i);r=e.from,o=e.top}this.updateState=1;let s=this.viewState.measure();if(!s&&!this.measureRequests.length&&null==this.viewState.scrollTarget)break;if(e>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let a=[];4&s||([this.measureRequests,a]=[a,this.measureRequests]);let l=a.map(e=>{try{return e.read(this)}catch(e){return up(this.state,e),Wf}}),c=Tp.create(this,this.state,[]),h=!1;c.flags|=s,t?t.flags|=s:t=c,this.updateState=2,c.empty||(this.updatePlugins(c),this.inputState.update(c),this.updateAttrs(),h=this.docView.update(c),h&&this.docViewUpdate());for(let e=0;e<a.length;e++)if(l[e]!=Wf)try{let t=a[e];t.write&&t.write(l[e],this)}catch(e){up(this.state,e)}if(h&&this.docView.updateSelection(!0),!c.viewportChanged&&0==this.measureRequests.length){if(this.viewState.editorHeight){if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}{let e=((r<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(r).top)-o)/this.scaleY;if((e>1||e<-1)&&(n==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){i+=e,n?n.scrollTop+=e:this.win.scrollBy(0,e),o=-1;continue}}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let e of this.state.facet(ep))e(t)}get themeClasses(){return Rf+" "+(this.state.facet(Tf)?Df:Of)+" "+this.state.facet(Af)}updateAttrs(){let e=Uf(this,yp,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(pp)?"true":"false",class:"cm-content",style:`${Gh.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),Uf(this,vp,t);let n=this.observer.ignore(()=>{let n=Jh(this.contentDOM,this.contentAttrs,t),i=Jh(this.dom,this.editorAttrs,e);return n||i});return this.editorAttrs=e,this.contentAttrs=t,n}showAnnouncements(e){let t=!0;for(let n of e)for(let e of n.effects)if(e.is($f.announce)){t&&(this.announceDOM.textContent=""),t=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=e.value}}mountStyles(){this.styleModules=this.state.facet(Mp);let e=this.state.facet($f.cspNonce);Th.mount(this.root,this.styleModules.concat(Bf).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(2==this.updateState)throw new Error("Reading the editor layout isn't allowed during an update");0==this.updateState&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(null!=e.key)for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key)return void(this.measureRequests[t]=e);this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(void 0===t||t&&t.plugin!=e)&&this.pluginMap.set(e,t=this.plugins.find(t=>t.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,n){return ud(this,e,ld(this,e,t,n))}moveByGroup(e,t){return ud(this,e,ld(this,e,t,t=>function(e,t,n){let i=e.state.charCategorizer(t),r=i(n);return e=>{let t=i(e);return r==ih.Space&&(r=t),r==t}}(this,e.head,t)))}visualLineSide(e,t){let n=this.bidiSpans(e),i=this.textDirectionAt(e.from),r=n[t?n.length-1:0];return mc.cursor(r.side(t,i)+e.from,r.forward(!t,i)?1:-1)}moveToLineBoundary(e,t,n=!0){return ad(this,e,t,n)}moveVertically(e,t,n){return ud(this,e,function(e,t,n,i){let r=t.head,o=n?1:-1;if(r==(n?e.state.doc.length:0))return mc.cursor(r,t.assoc);let s,a=t.goalColumn,l=e.contentDOM.getBoundingClientRect(),c=e.coordsAtPos(r,t.assoc||((t.empty?n:t.head==t.from)?1:-1)),h=e.documentTop;if(c)null==a&&(a=c.left-l.left),s=o<0?c.top:c.bottom;else{let t=e.viewState.lineBlockAt(r);null==a&&(a=Math.min(l.right-l.left,e.defaultCharacterWidth*(r-t.from))),s=(o<0?t.top:t.bottom)+h}let u=l.left+a,p=e.viewState.heightOracle.textHeight>>1,d=null!=i?i:p;for(let t=0;;t+=p){let i=s+(d+t)*o,r=dd(e,{x:u,y:i},!1,o);if(n?i>l.bottom:i<l.top)return mc.cursor(r.pos,r.assoc);let c=e.coordsAtPos(r.pos,r.assoc),h=c?(c.top+c.bottom)/2:0;if(!c||(n?h>s:h<s))return mc.cursor(r.pos,r.assoc,void 0,a)}}(this,e,t,n))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let n=dd(this,e,t);return n&&n.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),dd(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let n=this.docView.coordsAt(e,t);if(!n||n.left==n.right)return n;let i=this.state.doc.lineAt(e),r=this.bidiSpans(i);return yu(n,r[Vu.find(r,e-i.from,-1,t)].dir==Ou.LTR==t>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(op)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>zf)return Uu(e.length);let t,n=this.textDirectionAt(e.from);for(let i of this.bidiCache)if(i.from==e.from&&i.dir==n&&(i.fresh||$u(i.isolates,t=Sp(this,e))))return i.order;t||(t=Sp(this,e));let i=function(e,t,n){if(!e)return[new Vu(0,0,t==qu?1:0)];if(t==Du&&!n.length&&!Fu.test(e))return Uu(e.length);if(n.length)for(;e.length>zu.length;)zu[zu.length]=256;let i=[],r=t==Du?0:1;return Hu(e,r,r,n,0,e.length,i),i}(e.text,n,t);return this.bidiCache.push(new Hf(e.from,e.to,n,t,!0,i)),i}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Gh.safari&&(null===(e=this.inputState)||void 0===e?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Su(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((9==e.nodeType?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){var n,i,r,o;return cp.of(new lp("number"==typeof e?mc.cursor(e):e,null!==(n=t.y)&&void 0!==n?n:"nearest",null!==(i=t.x)&&void 0!==i?i:"nearest",null!==(r=t.yMargin)&&void 0!==r?r:5,null!==(o=t.xMargin)&&void 0!==o?o:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,n=this.viewState.scrollAnchorAt(e);return cp.of(new lp(mc.cursor(n.from),"start","start",n.top-e,t,!0))}setTabFocusMode(e){null==e?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:"boolean"==typeof e?this.inputState.tabFocusMode=e?0:-1:0!=this.inputState.tabFocusMode&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return gp.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return gp.define(()=>({}),{eventObservers:e})}static theme(e,t){let n=Th.newName(),i=[Af.of(n),Mp.of(Nf(`.${n}`,e))];return t&&t.dark&&i.push(Tf.of(!0)),i}static baseTheme(e){return Dc.lowest(Mp.of(Nf("."+Rf,e,qf)))}static findFromDOM(e){var t;let n=e.querySelector(".cm-content"),i=n&&Op.get(n)||Op.get(e);return(null===(t=null==i?void 0:i.root)||void 0===t?void 0:t.view)||null}}$f.styleModule=Mp,$f.inputHandler=tp,$f.clipboardInputFilter=ip,$f.clipboardOutputFilter=rp,$f.scrollHandler=ap,$f.focusChangeEffect=np,$f.perLineTextDirection=op,$f.exceptionSink=Zu,$f.updateListener=ep,$f.editable=pp,$f.mouseSelectionStyle=Qu,$f.dragMovesSelection=Ju,$f.clickAddsSelectionRange=Yu,$f.decorations=wp,$f.blockWrappers=bp,$f.outerDecorations=xp,$f.atomicRanges=_p,$f.bidiIsolatedRanges=kp,$f.cursorScrollMargin=wc.define({combine:e=>{let t=5,n=5;for(let i of e)"number"==typeof i?t=n=i:({x:t,y:n}=i);return{x:t,y:n}}}),$f.scrollMargins=Cp,$f.darkTheme=Tf,$f.cspNonce=wc.define({combine:e=>e.length?e[0]:""}),$f.contentAttributes=vp,$f.editorAttributes=yp,$f.lineWrapping=$f.contentAttributes.of({class:"cm-lineWrapping"}),$f.announce=Xc.define();const zf=4096,Wf={};class Hf{constructor(e,t,n,i,r,o){this.from=e,this.to=t,this.dir=n,this.isolates=i,this.fresh=r,this.order=o}static update(e,t){if(t.empty&&!e.some(e=>e.fresh))return e;let n=[],i=e.length?e[e.length-1].dir:Ou.LTR;for(let r=Math.max(0,e.length-10);r<e.length;r++){let o=e[r];o.dir!=i||t.touchesRange(o.from,o.to)||n.push(new Hf(t.mapPos(o.from,1),t.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return n}}function Uf(e,t,n){for(let i=e.state.facet(t),r=i.length-1;r>=0;r--){let t=i[r],o="function"==typeof t?t(e):t;o&&Kh(o,n)}return n}class Gf extends ch{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}Gf.prototype.elementClass="",Gf.prototype.toDOM=void 0,Gf.prototype.mapMode=sc.TrackBefore,Gf.prototype.startSide=Gf.prototype.endSide=-1,Gf.prototype.point=!0;const Kf=1024;let Xf=0;class Yf{constructor(e,t){this.from=e,this.to=t}}class Jf{constructor(e={}){this.id=Xf++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return"function"!=typeof e&&(e=eg.match(e)),t=>{let n=e(t);return void 0===n?null:[this,n]}}}Jf.closedBy=new Jf({deserialize:e=>e.split(" ")}),Jf.openedBy=new Jf({deserialize:e=>e.split(" ")}),Jf.group=new Jf({deserialize:e=>e.split(" ")}),Jf.isolate=new Jf({deserialize:e=>{if(e&&"rtl"!=e&&"ltr"!=e&&"auto"!=e)throw new RangeError("Invalid value for isolate: "+e);return e||"auto"}}),Jf.contextHash=new Jf({perNode:!0}),Jf.lookAhead=new Jf({perNode:!0}),Jf.mounted=new Jf({perNode:!0});class Qf{constructor(e,t,n,i=!1){this.tree=e,this.overlay=t,this.parser=n,this.bracketed=i}static get(e){return e&&e.props&&e.props[Jf.mounted.id]}}const Zf=Object.create(null);class eg{constructor(e,t,n,i=0){this.name=e,this.props=t,this.id=n,this.flags=i}static define(e){let t=e.props&&e.props.length?Object.create(null):Zf,n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(null==e.name?8:0),i=new eg(e.name||"",t,e.id,n);if(e.props)for(let n of e.props)if(Array.isArray(n)||(n=n(i)),n){if(n[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[n[0].id]=n[1]}return i}prop(e){return this.props[e.id]}get isTop(){return(1&this.flags)>0}get isSkipped(){return(2&this.flags)>0}get isError(){return(4&this.flags)>0}get isAnonymous(){return(8&this.flags)>0}is(e){if("string"==typeof e){if(this.name==e)return!0;let t=this.prop(Jf.group);return!!t&&t.indexOf(e)>-1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let i of n.split(" "))t[i]=e[n];return e=>{for(let n=e.prop(Jf.group),i=-1;i<(n?n.length:0);i++){let r=t[i<0?e.name:n[i]];if(r)return r}}}}eg.none=new eg("",Object.create(null),0,8);const tg=new WeakMap,ng=new WeakMap;var ig;!function(e){e[e.ExcludeBuffers=1]="ExcludeBuffers",e[e.IncludeAnonymous=2]="IncludeAnonymous",e[e.IgnoreMounts=4]="IgnoreMounts",e[e.IgnoreOverlays=8]="IgnoreOverlays",e[e.EnterBracketed=16]="EnterBracketed"}(ig||(ig={}));class rg{constructor(e,t,n,i,r){if(this.type=e,this.children=t,this.positions=n,this.length=i,this.props=null,r&&r.length){this.props=Object.create(null);for(let[e,t]of r)this.props["number"==typeof e?e:e.id]=t}}toString(){let e=Qf.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let e of this.children){let n=e.toString();n&&(t&&(t+=","),t+=n)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new yg(this.topNode,e)}cursorAt(e,t=0,n=0){let i=tg.get(this)||this.topNode,r=new yg(i);return r.moveTo(e,t),tg.set(this,r._tree),r}get topNode(){return new hg(this,0,0,null)}resolve(e,t=0){let n=lg(tg.get(this)||this.topNode,e,t,!1);return tg.set(this,n),n}resolveInner(e,t=0){let n=lg(ng.get(this)||this.topNode,e,t,!0);return ng.set(this,n),n}resolveStack(e,t=0){return function(e,t,n){let i=e.resolveInner(t,n),r=null;for(let e=i instanceof hg?i:i.context.parent;e;e=e.parent)if(e.index<0){let o=e.parent;(r||(r=[i])).push(o.resolve(t,n)),e=o}else{let o=Qf.get(e.tree);if(o&&o.overlay&&o.overlay[0].from<=t&&o.overlay[o.overlay.length-1].to>=t){let s=new hg(o.tree,o.overlay[0].from+e.from,-1,e);(r||(r=[i])).push(lg(s,t,n,!1))}}return r?gg(r):i}(this,e,t)}iterate(e){let{enter:t,leave:n,from:i=0,to:r=this.length}=e,o=e.mode||0,s=(o&ig.IncludeAnonymous)>0;for(let e=this.cursor(o|ig.IncludeAnonymous);;){let o=!1;if(e.from<=r&&e.to>=i&&(!s&&e.type.isAnonymous||!1!==t(e))){if(e.firstChild())continue;o=!0}for(;o&&n&&(s||!e.type.isAnonymous)&&n(e),!e.nextSibling();){if(!e.parent())return;o=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:xg(eg.none,this.children,this.positions,0,this.children.length,0,this.length,(e,t,n)=>new rg(this.type,e,t,n,this.propValues),e.makeTree||((e,t,n)=>new rg(eg.none,e,t,n)))}static build(e){return function(e){var t;let{buffer:n,nodeSet:i,maxBufferLength:r=Kf,reused:o=[],minRepeatType:s=i.types.length}=e,a=Array.isArray(n)?new og(n,n.length):n,l=i.types,c=0,h=0;function u(e,t,n,v,w,b){let{id:x,start:_,end:k,size:S}=a,C=h,E=c;if(S<0){if(a.next(),-1==S){let t=o[x];return n.push(t),void v.push(_-e)}if(-3==S)return void(c=x);if(-4==S)return void(h=x);throw new RangeError(`Unrecognized record size: ${S}`)}let M,A,T=l[x],R=_-e;if(k-_<=r&&(A=m(a.pos-t,w))){let t=new Uint16Array(A.size-A.skip),n=a.pos-A.size,r=t.length;for(;a.pos>n;)r=y(A.start,t,r);M=new sg(t,k-A.start,i),R=A.start-e}else{let e=a.pos-S;a.next();let t=[],n=[],i=x>=s?x:-1,o=0,l=k;for(;a.pos>e;)i>=0&&a.id==i&&a.size>=0?(a.end<=l-r&&(f(t,n,_,o,a.end,l,i,C,E),o=t.length,l=a.end),a.next()):b>2500?p(_,e,t,n):u(_,e,t,n,i,b+1);if(i>=0&&o>0&&o<t.length&&f(t,n,_,o,_,l,i,C,E),t.reverse(),n.reverse(),i>-1&&o>0){let e=d(T,E);M=xg(T,t,n,0,t.length,0,k-_,e,e)}else M=g(T,t,n,k-_,C-k,E)}n.push(M),v.push(R)}function p(e,t,n,o){let s=[],l=0,c=-1;for(;a.pos>t;){let{id:e,start:t,end:n,size:i}=a;if(i>4)a.next();else{if(c>-1&&t<c)break;c<0&&(c=n-r),s.push(e,t,n),l++,a.next()}}if(l){let t=new Uint16Array(4*l),r=s[s.length-2];for(let e=s.length-3,n=0;e>=0;e-=3)t[n++]=s[e],t[n++]=s[e+1]-r,t[n++]=s[e+2]-r,t[n++]=n;n.push(new sg(t,s[2]-r,i)),o.push(r-e)}}function d(e,t){return(n,i,r)=>{let o,s,a=0,l=n.length-1;if(l>=0&&(o=n[l])instanceof rg){if(!l&&o.type==e&&o.length==r)return o;(s=o.prop(Jf.lookAhead))&&(a=i[l]+o.length+s)}return g(e,n,i,r,a,t)}}function f(e,t,n,r,o,s,a,l,c){let h=[],u=[];for(;e.length>r;)h.push(e.pop()),u.push(t.pop()+n-o);e.push(g(i.types[a],h,u,s-o,l-s,c)),t.push(o-n)}function g(e,t,n,i,r,o,s){if(o){let e=[Jf.contextHash,o];s=s?[e].concat(s):[e]}if(r>25){let e=[Jf.lookAhead,r];s=s?[e].concat(s):[e]}return new rg(e,t,n,i,s)}function m(e,t){let n=a.fork(),i=0,o=0,l=0,c=n.end-r,h={size:0,start:0,skip:0};e:for(let r=n.pos-e;n.pos>r;){let e=n.size;if(n.id==t&&e>=0){h.size=i,h.start=o,h.skip=l,l+=4,i+=4,n.next();continue}let a=n.pos-e;if(e<0||a<r||n.start<c)break;let u=n.id>=s?4:0,p=n.start;for(n.next();n.pos>a;){if(n.size<0){if(-3!=n.size&&-4!=n.size)break e;u+=4}else n.id>=s&&(u+=4);n.next()}o=p,i+=e,l+=u}return(t<0||i==e)&&(h.size=i,h.start=o,h.skip=l),h.size>4?h:void 0}function y(e,t,n){let{id:i,start:r,end:o,size:l}=a;if(a.next(),l>=0&&i<s){let s=n;if(l>4){let i=a.pos-(l-4);for(;a.pos>i;)n=y(e,t,n)}t[--n]=s,t[--n]=o-e,t[--n]=r-e,t[--n]=i}else-3==l?c=i:-4==l&&(h=i);return n}let v=[],w=[];for(;a.pos>0;)u(e.start||0,e.bufferStart||0,v,w,-1,0);let b=null!==(t=e.length)&&void 0!==t?t:v.length?w[0]+v[0].length:0;return new rg(l[e.topID],v.reverse(),w.reverse(),b)}(e)}}rg.empty=new rg(eg.none,[],[],0);class og{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new og(this.buffer,this.index)}}class sg{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return eg.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],n=this.buffer[e+3],i=this.set.types[t],r=i.name;if(/\W/.test(r)&&!i.isError&&(r=JSON.stringify(r)),n==(e+=4))return r;let o=[];for(;e<n;)o.push(this.childString(e)),e=this.buffer[e+3];return r+"("+o.join(",")+")"}findChild(e,t,n,i,r){let{buffer:o}=this,s=-1;for(let a=e;a!=t&&!(ag(r,i,o[a+1],o[a+2])&&(s=a,n>0));a=o[a+3]);return s}slice(e,t,n){let i=this.buffer,r=new Uint16Array(t-e),o=0;for(let s=e,a=0;s<t;){r[a++]=i[s++],r[a++]=i[s++]-n;let t=r[a++]=i[s++]-n;r[a++]=i[s++]-e,o=Math.max(o,t)}return new sg(r,o,this.set)}}function ag(e,t,n,i){switch(e){case-2:return n<t;case-1:return i>=t&&n<t;case 0:return n<t&&i>t;case 1:return n<=t&&i>t;case 2:return i>t;case 4:return!0}}function lg(e,t,n,i){for(var r;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to<t);){let t=!i&&e instanceof hg&&e.index<0?null:e.parent;if(!t)return e;e=t}let o=i?0:ig.IgnoreOverlays;if(i)for(let i=e,s=i.parent;s;i=s,s=i.parent)i instanceof hg&&i.index<0&&(null===(r=s.enter(t,n,o))||void 0===r?void 0:r.from)!=i.from&&(e=s);for(;;){let i=e.enter(t,n,o);if(!i)return e;e=i}}class cg{cursor(e=0){return new yg(this,e)}getChild(e,t=null,n=null){let i=ug(this,e,t,n);return i.length?i[0]:null}getChildren(e,t=null,n=null){return ug(this,e,t,n)}resolve(e,t=0){return lg(this,e,t,!1)}resolveInner(e,t=0){return lg(this,e,t,!0)}matchContext(e){return pg(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),n=this;for(;t;){let e=t.lastChild;if(!e||e.to!=t.to)break;e.type.isError&&e.from==e.to?(n=t,t=e.prevSibling):t=e}return n}get node(){return this}get next(){return this.parent}}class hg extends cg{constructor(e,t,n,i){super(),this._tree=e,this.from=t,this.index=n,this._parent=i}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,n,i,r=0){for(let o=this;;){for(let{children:s,positions:a}=o._tree,l=t>0?s.length:-1;e!=l;e+=t){let l,c=s[e],h=a[e]+o.from;if(r&ig.EnterBracketed&&c instanceof rg&&(l=Qf.get(c))&&!l.overlay&&l.bracketed&&n>=h&&n<=h+c.length||ag(i,n,h,h+c.length))if(c instanceof sg){if(r&ig.ExcludeBuffers)continue;let s=c.findChild(0,c.buffer.length,t,n-h,i);if(s>-1)return new fg(new dg(o,c,e,h),null,s)}else if(r&ig.IncludeAnonymous||!c.type.isAnonymous||vg(c)){let s;if(!(r&ig.IgnoreMounts)&&(s=Qf.get(c))&&!s.overlay)return new hg(s.tree,h,e,o);let a=new hg(c,h,e,o);return r&ig.IncludeAnonymous||!a.type.isAnonymous?a:a.nextChild(t<0?c.children.length-1:0,t,n,i,r)}}if(r&ig.IncludeAnonymous||!o.type.isAnonymous)return null;if(e=o.index>=0?o.index+t:t<0?-1:o._parent._tree.children.length,o=o._parent,!o)return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,t,n=0){let i;if(!(n&ig.IgnoreOverlays)&&(i=Qf.get(this._tree))&&i.overlay){let r=e-this.from,o=n&ig.EnterBracketed&&i.bracketed;for(let{from:e,to:n}of i.overlay)if((t>0||o?e<=r:e<r)&&(t<0||o?n>=r:n>r))return new hg(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,n)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function ug(e,t,n,i){let r=e.cursor(),o=[];if(!r.firstChild())return o;if(null!=n)for(let e=!1;!e;)if(e=r.type.is(n),!r.nextSibling())return o;for(;;){if(null!=i&&r.type.is(i))return o;if(r.type.is(t)&&o.push(r.node),!r.nextSibling())return null==i?o:[]}}function pg(e,t,n=t.length-1){for(let i=e;n>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(t[n]&&t[n]!=i.name)return!1;n--}}return!0}class dg{constructor(e,t,n,i){this.parent=e,this.buffer=t,this.index=n,this.start=i}}class fg extends cg{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(e,t,n){let{buffer:i}=this.context,r=i.findChild(this.index+4,i.buffer[this.index+3],e,t-this.context.start,n);return r<0?null:new fg(this.context,this,r)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,t,n=0){if(n&ig.ExcludeBuffers)return null;let{buffer:i}=this.context,r=i.findChild(this.index+4,i.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return r<0?null:new fg(this.context,this,r)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new fg(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new fg(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,i=this.index+4,r=n.buffer[this.index+3];if(r>i){let o=n.buffer[this.index+1];e.push(n.slice(i,r,o)),t.push(0)}return new rg(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function gg(e){if(!e.length)return null;let t=0,n=e[0];for(let i=1;i<e.length;i++){let r=e[i];(r.from>n.from||r.to<n.to)&&(n=r,t=i)}let i=n instanceof hg&&n.index<0?null:n.parent,r=e.slice();return i?r[t]=i:r.splice(t,1),new mg(r,n)}class mg{constructor(e,t){this.heads=e,this.node=t}get next(){return gg(this.heads)}}class yg{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~ig.EnterBracketed,e instanceof hg)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return!!e&&(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0)}yieldBuf(e,t){this.index=e;let{start:n,buffer:i}=this.buffer;return this.type=t||i.set.types[i.buffer[e]],this.from=n+i.buffer[e+1],this.to=n+i.buffer[e+2],!0}yield(e){return!!e&&(e instanceof hg?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)))}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:i}=this.buffer,r=i.findChild(this.index+4,i.buffer[this.index+3],e,t-this.buffer.start,n);return!(r<0)&&(this.stack.push(this.index),this.yieldBuf(r))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,n=this.mode){return this.buffer?!(n&ig.ExcludeBuffers)&&this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&ig.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&ig.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return!!this._tree._parent&&this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode));let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let e=n<0?0:this.stack[n]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(e)}return n<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:i}=this;if(i){if(e>0){if(this.index<i.buffer.buffer.length)return!1}else for(let e=0;e<this.index;e++)if(i.buffer.buffer[e+3]<this.index)return!1;({index:t,parent:n}=i)}else({index:t,_parent:n}=this._tree);for(;n;({index:t,_parent:n}=n))if(t>-1)for(let i=t+e,r=e<0?-1:n._tree.children.length;i!=r;i+=e){let e=n._tree.children[i];if(this.mode&ig.IncludeAnonymous||e instanceof sg||!e.type.isAnonymous||vg(e))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,n=0;if(e&&e.context==this.buffer)e:for(let i=this.index,r=this.stack.length;r>=0;){for(let o=e;o;o=o._parent)if(o.index==i){if(i==this.index)return o;t=o,n=r+1;break e}i=this.stack[--r]}for(let e=n;e<this.stack.length;e++)t=new fg(this.buffer,t,this.stack[e]);return this.bufferNode=new fg(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let i=!1;if(this.type.isAnonymous||!1!==e(this)){if(this.firstChild()){n++;continue}this.type.isAnonymous||(i=!0)}for(;;){if(i&&t&&t(this),i=this.type.isAnonymous,!n)return;if(this.nextSibling())break;this.parent(),n--,i=!0}}}matchContext(e){if(!this.buffer)return pg(this.node.parent,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let i=e.length-1,r=this.stack.length-1;i>=0;r--){if(r<0)return pg(this._tree,e,i);let o=n[t.buffer[this.stack[r]]];if(!o.isAnonymous){if(e[i]&&e[i]!=o.name)return!1;i--}}return!0}}function vg(e){return e.children.some(e=>e instanceof sg||!e.type.isAnonymous||vg(e))}const wg=new WeakMap;function bg(e,t){if(!e.isAnonymous||t instanceof sg||t.type!=e)return 1;let n=wg.get(t);if(null==n){n=1;for(let i of t.children){if(i.type!=e||!(i instanceof rg)){n=1;break}n+=bg(e,i)}wg.set(t,n)}return n}function xg(e,t,n,i,r,o,s,a,l){let c=0;for(let n=i;n<r;n++)c+=bg(e,t[n]);let h=Math.ceil(1.5*c/8),u=[],p=[];return function t(n,i,r,s,a){for(let c=r;c<s;){let r=c,d=i[c],f=bg(e,n[c]);for(c++;c<s;c++){let t=bg(e,n[c]);if(f+t>=h)break;f+=t}if(c==r+1){if(f>h){let e=n[r];t(e.children,e.positions,0,e.children.length,i[r]+a);continue}u.push(n[r])}else{let t=i[c-1]+n[c-1].length-d;u.push(xg(e,n,i,r,c,d,t,null,l))}p.push(d+a-o)}}(t,n,i,r,0),(a||l)(u,p,s)}class _g{constructor(e,t,n,i,r=!1,o=!1){this.from=e,this.to=t,this.tree=n,this.offset=i,this.open=(r?1:0)|(o?2:0)}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(e,t=[],n=!1){let i=[new _g(0,e.length,e,0,!1,n)];for(let n of t)n.to>e.length&&i.push(n);return i}static applyChanges(e,t,n=128){if(!t.length)return e;let i=[],r=1,o=e.length?e[0]:null;for(let s=0,a=0,l=0;;s++){let c=s<t.length?t[s]:null,h=c?c.fromA:1e9;if(h-a>=n)for(;o&&o.from<h;){let t=o;if(a>=t.from||h<=t.to||l){let e=Math.max(t.from,a)-l,n=Math.min(t.to,h)-l;t=e>=n?null:new _g(e,n,t.tree,t.offset+l,s>0,!!c)}if(t&&i.push(t),o.to>h)break;o=r<e.length?e[r++]:null}if(!c)break;a=c.toA,l=c.toA-c.toB}return i}}class kg{startParse(e,t,n){return"string"==typeof e&&(e=new Sg(e)),n=n?n.length?n.map(e=>new Yf(e.from,e.to)):[new Yf(0,0)]:[new Yf(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let i=this.startParse(e,t,n);for(;;){let e=i.advance();if(e)return e}}}class Sg{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}new Jf({perNode:!0});let Cg=0;class Eg{constructor(e,t,n,i){this.name=e,this.set=t,this.base=n,this.modified=i,this.id=Cg++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let n="string"==typeof e?e:"?";if(e instanceof Eg&&(t=e),null==t?void 0:t.base)throw new Error("Can not derive from a modified tag");let i=new Eg(n,[],null,[]);if(i.set.push(i),t)for(let e of t.set)i.set.push(e);return i}static defineModifier(e){let t=new Ag(e);return e=>e.modified.indexOf(t)>-1?e:Ag.get(e.base||e,e.modified.concat(t).sort((e,t)=>e.id-t.id))}}let Mg=0;class Ag{constructor(e){this.name=e,this.instances=[],this.id=Mg++}static get(e,t){if(!t.length)return e;let n=t[0].instances.find(n=>{return n.base==e&&(i=t,r=n.modified,i.length==r.length&&i.every((e,t)=>e==r[t]));var i,r});if(n)return n;let i=[],r=new Eg(e.name,i,e,t);for(let e of t)e.instances.push(r);let o=function(e){let t=[[]];for(let n=0;n<e.length;n++)for(let i=0,r=t.length;i<r;i++)t.push(t[i].concat(e[n]));return t.sort((e,t)=>t.length-e.length)}(t);for(let t of e.set)if(!t.modified.length)for(let e of o)i.push(Ag.get(t,e));return r}}function Tg(e){let t=Object.create(null);for(let n in e){let i=e[n];Array.isArray(i)||(i=[i]);for(let e of n.split(" "))if(e){let n=[],r=2,o=e;for(let t=0;;){if("..."==o&&t>0&&t+3==e.length){r=1;break}let i=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(o);if(!i)throw new RangeError("Invalid path: "+e);if(n.push("*"==i[0]?"":'"'==i[0][0]?JSON.parse(i[0]):i[0]),t+=i[0].length,t==e.length)break;let s=e[t++];if(t==e.length&&"!"==s){r=0;break}if("/"!=s)throw new RangeError("Invalid path: "+e);o=e.slice(t)}let s=n.length-1,a=n[s];if(!a)throw new RangeError("Invalid path: "+e);let l=new Og(i,r,s>0?n.slice(0,s):null);t[a]=l.sort(t[a])}}return Rg.add(t)}const Rg=new Jf({combine(e,t){let n,i,r;for(;e||t;){if(!e||t&&e.depth>=t.depth?(r=t,t=t.next):(r=e,e=e.next),n&&n.mode==r.mode&&!r.context&&!n.context)continue;let o=new Og(r.tags,r.mode,r.context);n?n.next=o:i=o,n=o}return i}});class Og{constructor(e,t,n,i){this.tags=e,this.mode=t,this.context=n,this.next=i}get opaque(){return 0==this.mode}get inherit(){return 1==this.mode}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}}function Dg(e,t){let n=Object.create(null);for(let t of e)if(Array.isArray(t.tag))for(let e of t.tag)n[e.id]=t.class;else n[t.tag.id]=t.class;let{scope:i,all:r=null}=t||{};return{style:e=>{let t=r;for(let i of e)for(let e of i.set){let i=n[e.id];if(i){t=t?t+" "+i:i;break}}return t},scope:i}}Og.empty=new Og([],2,null);const qg=Eg.define,Ng=qg(),Bg=qg(),Pg=qg(Bg),Lg=qg(Bg),Ig=qg(),jg=qg(Ig),Fg=qg(Ig),Vg=qg(),$g=qg(Vg),zg=qg(),Wg=qg(),Hg=qg(),Ug=qg(Hg),Gg=qg(),Kg={comment:Ng,lineComment:qg(Ng),blockComment:qg(Ng),docComment:qg(Ng),name:Bg,variableName:qg(Bg),typeName:Pg,tagName:qg(Pg),propertyName:Lg,attributeName:qg(Lg),className:qg(Bg),labelName:qg(Bg),namespace:qg(Bg),macroName:qg(Bg),literal:Ig,string:jg,docString:qg(jg),character:qg(jg),attributeValue:qg(jg),number:Fg,integer:qg(Fg),float:qg(Fg),bool:qg(Ig),regexp:qg(Ig),escape:qg(Ig),color:qg(Ig),url:qg(Ig),keyword:zg,self:qg(zg),null:qg(zg),atom:qg(zg),unit:qg(zg),modifier:qg(zg),operatorKeyword:qg(zg),controlKeyword:qg(zg),definitionKeyword:qg(zg),moduleKeyword:qg(zg),operator:Wg,derefOperator:qg(Wg),arithmeticOperator:qg(Wg),logicOperator:qg(Wg),bitwiseOperator:qg(Wg),compareOperator:qg(Wg),updateOperator:qg(Wg),definitionOperator:qg(Wg),typeOperator:qg(Wg),controlOperator:qg(Wg),punctuation:Hg,separator:qg(Hg),bracket:Ug,angleBracket:qg(Ug),squareBracket:qg(Ug),paren:qg(Ug),brace:qg(Ug),content:Vg,heading:$g,heading1:qg($g),heading2:qg($g),heading3:qg($g),heading4:qg($g),heading5:qg($g),heading6:qg($g),contentSeparator:qg(Vg),list:qg(Vg),quote:qg(Vg),emphasis:qg(Vg),strong:qg(Vg),link:qg(Vg),monospace:qg(Vg),strikethrough:qg(Vg),inserted:qg(),deleted:qg(),changed:qg(),invalid:qg(),meta:Gg,documentMeta:qg(Gg),annotation:qg(Gg),processingInstruction:qg(Gg),definition:Eg.defineModifier("definition"),constant:Eg.defineModifier("constant"),function:Eg.defineModifier("function"),standard:Eg.defineModifier("standard"),local:Eg.defineModifier("local"),special:Eg.defineModifier("special")};for(let e in Kg){let t=Kg[e];t instanceof Eg&&(t.name=e)}var Xg;Dg([{tag:Kg.link,class:"tok-link"},{tag:Kg.heading,class:"tok-heading"},{tag:Kg.emphasis,class:"tok-emphasis"},{tag:Kg.strong,class:"tok-strong"},{tag:Kg.keyword,class:"tok-keyword"},{tag:Kg.atom,class:"tok-atom"},{tag:Kg.bool,class:"tok-bool"},{tag:Kg.url,class:"tok-url"},{tag:Kg.labelName,class:"tok-labelName"},{tag:Kg.inserted,class:"tok-inserted"},{tag:Kg.deleted,class:"tok-deleted"},{tag:Kg.literal,class:"tok-literal"},{tag:Kg.string,class:"tok-string"},{tag:Kg.number,class:"tok-number"},{tag:[Kg.regexp,Kg.escape,Kg.special(Kg.string)],class:"tok-string2"},{tag:Kg.variableName,class:"tok-variableName"},{tag:Kg.local(Kg.variableName),class:"tok-variableName tok-local"},{tag:Kg.definition(Kg.variableName),class:"tok-variableName tok-definition"},{tag:Kg.special(Kg.variableName),class:"tok-variableName2"},{tag:Kg.definition(Kg.propertyName),class:"tok-propertyName tok-definition"},{tag:Kg.typeName,class:"tok-typeName"},{tag:Kg.namespace,class:"tok-namespace"},{tag:Kg.className,class:"tok-className"},{tag:Kg.macroName,class:"tok-macroName"},{tag:Kg.propertyName,class:"tok-propertyName"},{tag:Kg.operator,class:"tok-operator"},{tag:Kg.comment,class:"tok-comment"},{tag:Kg.meta,class:"tok-meta"},{tag:Kg.invalid,class:"tok-invalid"},{tag:Kg.punctuation,class:"tok-punctuation"}]);const Yg=new Jf,Jg=new Jf;class Qg{constructor(e,t,n=[],i=""){this.data=e,this.name=i,ah.prototype.hasOwnProperty("tree")||Object.defineProperty(ah.prototype,"tree",{get(){return em(this)}}),this.parser=t,this.extension=[cm.of(this),ah.languageData.of((e,t,n)=>{let i=Zg(e,t,n),r=i.type.prop(Yg);if(!r)return[];let o=e.facet(r),s=i.type.prop(Jg);if(s){let r=i.resolve(t-i.from,n);for(let t of s)if(t.test(r,e)){let n=e.facet(t.facet);return"replace"==t.type?n:n.concat(o)}}return o})].concat(n)}isActiveAt(e,t,n=-1){return Zg(e,t,n).type.prop(Yg)==this.data}findRegions(e){let t=e.facet(cm);if((null==t?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],i=(e,t)=>{if(e.prop(Yg)==this.data)return void n.push({from:t,to:t+e.length});let r=e.prop(Jf.mounted);if(r){if(r.tree.prop(Yg)==this.data){if(r.overlay)for(let e of r.overlay)n.push({from:e.from+t,to:e.to+t});else n.push({from:t,to:t+e.length});return}if(r.overlay){let e=n.length;if(i(r.tree,r.overlay[0].from+t),n.length>e)return}}for(let n=0;n<e.children.length;n++){let r=e.children[n];r instanceof rg&&i(r,e.positions[n]+t)}};return i(em(e),0),n}get allowsNesting(){return!0}}function Zg(e,t,n){let i=e.facet(cm),r=em(e).topNode;if(!i||i.allowsNesting)for(let e=r;e;e=e.enter(t,n,ig.ExcludeBuffers|ig.EnterBracketed))e.type.isTop&&(r=e);return r}function em(e){let t=e.field(Qg.state,!1);return t?t.tree:rg.empty}Qg.setState=Xc.define();class tm{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let n=this.cursorPos-this.string.length;return e<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}}let nm=null;class im{constructor(e,t,n=[],i,r,o,s,a){this.parser=e,this.state=t,this.fragments=n,this.tree=i,this.treeLen=r,this.viewport=o,this.skipped=s,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,n){return new im(e,t,[],rg.empty,0,n,[],null)}startParse(){return this.parser.startParse(new tm(this.state.doc),this.fragments)}work(e,t){return null!=t&&t>=this.state.doc.length&&(t=void 0),this.tree!=rg.empty&&this.isDone(null!=t?t:this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var n;if("number"==typeof e){let t=Date.now()+e;e=()=>Date.now()>t}for(this.parse||(this.parse=this.startParse()),null!=t&&(null==this.parse.stoppedAt||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let i=this.parse.advance();if(i){if(this.fragments=this.withoutTempSkipped(_g.addTree(i,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!==(n=this.parse.stoppedAt)&&void 0!==n?n:this.state.doc.length,this.tree=i,this.parse=null,!(this.treeLen<(null!=t?t:this.state.doc.length)))return!0;this.parse=this.startParse()}if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((null==this.parse.stoppedAt||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(_g.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=nm;nm=this;try{return e()}finally{nm=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=rm(e,t.from,t.to);return e}changes(e,t){let{fragments:n,tree:i,treeLen:r,viewport:o,skipped:s}=this;if(this.takeTree(),!e.empty){let t=[];if(e.iterChangedRanges((e,n,i,r)=>t.push({fromA:e,toA:n,fromB:i,toB:r})),n=_g.applyChanges(n,t),i=rg.empty,r=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){s=[];for(let t of this.skipped){let n=e.mapPos(t.from,1),i=e.mapPos(t.to,-1);n<i&&s.push({from:n,to:i})}}}return new im(this.parser,t,n,i,r,o,s,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let t=0;t<this.skipped.length;t++){let{from:n,to:i}=this.skipped[t];n<e.to&&i>e.from&&(this.fragments=rm(this.fragments,n,i),this.skipped.splice(t--,1))}return!(this.skipped.length>=t)&&(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends kg{createParse(t,n,i){let r=i[0].from,o=i[i.length-1].to;return{parsedPos:r,advance(){let t=nm;if(t){for(let e of i)t.tempSkipped.push(e);e&&(t.scheduleOn=t.scheduleOn?Promise.all([t.scheduleOn,e]):e)}return this.parsedPos=o,new rg(eg.none,[],[],o-r)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&0==t[0].from&&t[0].to>=e}static get(){return nm}}function rm(e,t,n){return _g.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}class om{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),n=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,n)||t.takeTree(),new om(t)}static init(e){let t=Math.min(3e3,e.doc.length),n=im.create(e.facet(cm).parser,e,{from:0,to:t});return n.work(20,t)||n.takeTree(),new om(n)}}Qg.state=Ec.define({create:om.init,update(e,t){for(let e of t.effects)if(e.is(Qg.setState))return e.value;return t.startState.facet(cm)!=t.state.facet(cm)?om.init(t.state):e.apply(t)}});let sm=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};"undefined"!=typeof requestIdleCallback&&(sm=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});const am="undefined"!=typeof navigator&&(null===(Xg=navigator.scheduling)||void 0===Xg?void 0:Xg.isInputPending)?()=>navigator.scheduling.isInputPending():null,lm=gp.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(Qg.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(Qg.state);t.tree==t.context.tree&&t.context.isDone(e.doc.length)||(this.working=sm(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:i}}=this.view,r=n.field(Qg.state);if(r.tree==r.context.tree&&r.context.isDone(i+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!am?Math.max(25,e.timeRemaining()-5):1e9),s=r.context.treeLen<i&&n.doc.length>i+1e3,a=r.context.work(()=>am&&am()||Date.now()>o,i+(s?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(r.context.takeTree(),this.view.dispatch({effects:Qg.setState.of(new om(r.context))})),this.chunkBudget>0&&(!a||s)&&this.scheduleWork(),this.checkAsyncSchedule(r.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(e=>up(this.view.state,e)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),cm=wc.define({combine:e=>e.length?e[0]:null,enables:e=>[Qg.state,lm,$f.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]});const hm=Object.create(null),um=[eg.none],pm=[],dm=Object.create(null),fm=Object.create(null);for(let[e,t]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])fm[e]=mm(hm,t);function gm(e,t){pm.indexOf(e)>-1||(pm.push(e),console.warn(t))}function mm(e,t){let n=[];for(let i of t.split(" ")){let t=[];for(let n of i.split(".")){let i=e[n]||Kg[n];i?"function"==typeof i?t.length?t=t.map(i):gm(n,`Modifier ${n} used at start of tag`):t.length?gm(n,`Tag ${n} used as modifier`):t=Array.isArray(i)?i:[i]:gm(n,`Unknown highlighting tag ${n}`)}for(let e of t)n.push(e)}if(!n.length)return 0;let i=t.replace(/ /g,"_"),r=i+" "+n.map(e=>e.id),o=dm[r];if(o)return o.id;let s=dm[r]=eg.define({id:um.length,name:i,props:[Tg({[i]:n})]});return um.push(s),s.id}Ou.RTL,Ou.LTR;const ym=wc.define({combine:e=>({sources:e.map(e=>e.source).filter(e=>null!=e),...lh(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:vm,tooltipFilter:vm,needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t,hideOn:(e,t)=>e?t?(n,i,r)=>e(n,i,r)||t(n,i,r):e:t,autoPanel:(e,t)=>e||t})})});function vm(e,t){return e?t?(n,i)=>t(e(n,i),i):e:t}function wm(e){const t=[];return e.iterate({enter:e=>{const n=e.node;if(!n.type.isError)return;const i=n.parent,r=bm(n),o={from:n.from,to:n.to,severity:"error",type:"Syntax Error"};if(n.from!==n.to)o.message=`Unrecognized token in <${i.name}>`;else if(r)o.message=`Unrecognized token <${r.name}> in <${i.name}>`,o.to=r.to;else{const e=i.enterUnfinishedNodesBefore(n.to);o.message=`Incomplete <${(e||i).name}>`}t.push(o)}}),t}function bm(e){return e?e.nextSibling||bm(e.parent):null}var xm={create:e=>({enter(t){if("FilterExpression"!==t.name)return;const n=e.readContent(t.from,t.to);if(/\[\s*0\s*\]$/.test(n)){const{from:i,to:r}=t;e.report({from:i,to:r,message:"First item is accessed via [1]",severity:"warning",type:"first-item",actions:[{name:"fix",apply(t,o=i,s=r){e.updateContent(o,s,n.replace(/\[\s*0\s*\]$/,"[1]"))}}]})}}})};const _m=[xm];function km(e){const{readContent:t,syntaxTree:n,updateContent:i}=e,r=[],o={readContent:t,report:e=>{r.push(e)},updateContent:i},s=_m.map(e=>e.create(o));return n.iterate({enter:e=>{for(const t of s)t.enter&&t.enter(e)},leave:e=>{for(const t of s)t.leave&&t.leave(e)}}),r}const Sm=[{name:"not",type:"function",params:[{name:"negand"}],info:'<p>Returns the logical negation of the given value.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">not(negand: boolean): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">not(true)\n// false\n\nnot(null)\n// null\n</code></pre>\n'},{name:"get value",type:"function",params:[{name:"context"},{name:"key"}],info:'<p>Returns the value of the context entry with the given key.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">get value(context: context, key: string): Any\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">get value({foo: 123}, "foo")\n// 123\n\nget value({a: 1}, "b")\n// null\n</code></pre>\n'},{name:"get entries",type:"function",params:[{name:"context"}],info:'<p>Returns the entries of the context as a list of key-value-pairs.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">get entries(context: context): list<context>\n</code></pre>\n<p>The return value is a list of contexts. Each context contains two entries for "key" and "value".</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">get entries({foo: 123})\n// [{key: "foo", value: 123}]\n</code></pre>\n'},{name:"context put",type:"function",params:[{name:"context"},{name:"keys"},{name:"value"}],info:'<p>Adds a new entry with the given value to the context. The path of the entry is defined by the keys. Returns a new context that includes the entry.</p>\n<p>If <code>keys</code> contains the keys <code>[k1, k2]</code> then it adds the nested entry <code>k1.k2 = value</code> to the context.</p>\n<p>If an entry for the same keys already exists in the context, it overrides the value.</p>\n<p>If <code>keys</code> are empty, it returns <code>null</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">context put(context: context, keys: list<string>, value: Any): context\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">context put({x:1}, ["y"], 2)\n// {x:1, y:2}\n\ncontext put({x:1, y: {z:0}}, ["y", "z"], 2)\n// {x:1, y: {z:2}}\n\ncontext put({x:1}, ["y", "z"], 2)\n// {x:1, y: {z:2}}\n</code></pre>\n'},{name:"string",type:"function",params:[{name:"from"}],info:'<p>Returns the given value as a string representation.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">string(from: Any): string\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">string(1.1)\n// "1.1"\n\nstring(date("2012-12-25"))\n// "2012-12-25"\n</code></pre>\n'},{name:"number",type:"function",params:[{name:"from"}],info:'<p>Parses the given string to a number.</p>\n<p>Returns <code>null</code> if the string is not a number.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">number(from: string): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">number("1500.5")\n// 1500.5\n</code></pre>\n'},{name:"number",type:"function",params:[{name:"from"},{name:"grouping separator"}],info:'<p>Parses the given string to a number using the specified grouping separator.</p>\n<p>Returns <code>null</code> if the string is not a number.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">number(from: string, grouping separator: string): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">number("1,500", ",")\n// 1500\n</code></pre>\n'},{name:"number",type:"function",params:[{name:"from"},{name:"grouping separator"},{name:"decimal separator"}],info:'<p>Parses the given string to a number using the specified grouping and decimal separators.</p>\n<p>Returns <code>null</code> if the string is not a number.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">number(from: string, grouping separator: string, decimal separator: string): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">number("1 500.5", " ", ".")\n// 1500.5\n</code></pre>\n'},{name:"context",type:"function",params:[{name:"entries"}],info:'<p>Constructs a context of the given list of key-value pairs. It is the reverse function to <a href="feel-built-in-functions-context.md#get-entriescontext">get entries()</a>.</p>\n<p>Each key-value pair must be a context with two entries: <code>key</code> and <code>value</code>. The entry with name <code>key</code> must have a value of the type <code>string</code>.</p>\n<p>It might override context entries if the keys are equal. The entries are overridden in the same order as the contexts in the given list.</p>\n<p>Returns <code>null</code> if one of the entries is not a context or if a context doesn't contain the required entries.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">context(entries: list<context>): context\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">context([{"key":"a", "value":1}, {"key":"b", "value":2}])\n// {a:1, b:2}\n</code></pre>\n'},{name:"date",type:"function",params:[{name:"from"}],info:'<p>Returns a date from the given value.</p>\n<p>Returns <code>null</code> if the string is not a valid calendar date. For example, <code>"2024-06-31"</code> is invalid because June has\nonly 30 days.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">date(from: string): date\n</code></pre>\n<p>Parses the given string into a date.</p>\n<pre><code class="language-feel">date(from: date and time): date\n</code></pre>\n<p>Extracts the date component from the given date and time.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">date("2018-04-29")\n// date("2018-04-29")\n\ndate(date and time("2012-12-25T11:00:00"))\n// date("2012-12-25")\n</code></pre>\n'},{name:"date",type:"function",params:[{name:"year"},{name:"month"},{name:"day"}],info:'<p>Returns a date from the given components.</p>\n<p>Returns <code>null</code> if the components don't represent a valid calendar date. For example, <code>2024,6,31</code> is invalid because\nJune has only 30 days.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">date(year: number, month: number, day: number): date\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">date(2012, 12, 25)\n// date("2012-12-25")\n</code></pre>\n'},{name:"time",type:"function",params:[{name:"from"}],info:'<p>Returns a time from the given value.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">time(from: string): time\n</code></pre>\n<p>Parses the given string into a time.</p>\n<pre><code class="language-feel">time(from: date and time): time\n</code></pre>\n<p>Extracts the time component from the given date and time.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">time("12:00:00")\n// time("12:00:00")\n\ntime(date and time("2012-12-25T11:00:00"))\n// time("11:00:00")\n</code></pre>\n'},{name:"time",type:"function",params:[{name:"hour"},{name:"minute"},{name:"second"}],info:'<p>Returns a time from the given components.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">time(hour: number, minute: number, second: number): time\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">time(23, 59, 0)\n// time("23:59:00")\n</code></pre>\n'},{name:"time",type:"function",params:[{name:"hour"},{name:"minute"},{name:"second"},{name:"offset"}],info:'<p>Returns a time from the given components, including a timezone offset.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">time(hour: number, minute: number, second: number, offset: days and time duration): time\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">time(14, 30, 0, duration("PT1H"))\n// time("14:30:00+01:00")\n</code></pre>\n'},{name:"date and time",type:"function",params:[{name:"from"}],info:'<p>Parses the given string into a date and time. The function supports strings in the format <code>YYYY-MM-DDThh:mm:ss</code> with\noptional timezone information either as offset (e.g., <code>+01:00</code> or <code>Z</code>), as IANA timezone ID (e.g., <code>@Europe/Berlin</code>), or\nas a combination of both (e.g., <code>+01:00[Europe/Berlin]</code>).</p>\n<p>Returns <code>null</code> if the string is not a valid calendar date. For example, <code>"2024-06-31T10:00:00"</code> is invalid because\nJune has only 30 days.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">date and time(from: string): date and time\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">date and time("2018-04-29T09:30:00")\n// date and time("2018-04-29T09:30:00")\n\ndate and time("2018-04-29T09:30:00+02:00")\n// date and time("2018-04-29T09:30:00+02:00")\n\ndate and time("2018-04-29T09:30:00@Europe/Berlin")\n// date and time("2018-04-29T09:30:00@Europe/Berlin")\n\ndate and time("2018-04-29T09:30:00+02:00[Europe/Berlin]")\n// date and time("2018-04-29T09:30:00@Europe/Berlin")\n</code></pre>\n'},{name:"date and time",type:"function",params:[{name:"date"},{name:"time"}],info:'<p>Returns a date and time from the given components.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">date and time(date: date, time: time): date and time\n</code></pre>\n<pre><code class="language-feel">date and time(date: date and time, time: time): date and time\n</code></pre>\n<p>Returns a date and time value that consists of the date component of <code>date</code> combined with <code>time</code>.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">date and time(date("2012-12-24"),time("T23:59:00"))\n// date and time("2012-12-24T23:59:00")\n\ndate and time(date and time("2012-12-25T11:00:00"),time("T23:59:00"))\n// date and time("2012-12-25T23:59:00")\n</code></pre>\n'},{name:"duration",type:"function",params:[{name:"from"}],info:'<p>Parses the given string into a duration. The duration is either a days and time duration or a years and months duration.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">duration(from: string): days and time duration\n</code></pre>\n<pre><code class="language-feel">duration(from: string): years and months duration\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">duration("P5D")\n// duration("P5D")\n\nduration("P32Y")\n// duration("P32Y")\n</code></pre>\n'},{name:"years and months duration",type:"function",params:[{name:"from"},{name:"to"}],info:'<p>Returns the years and months duration between <code>from</code> and <code>to</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">years and months duration(from: date, to: date): years and months duration\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">years and months duration(date("2011-12-22"), date("2013-08-24"))\n// duration("P1Y8M")\n</code></pre>\n'},{name:"from json",type:"function",params:[{name:"value"}],info:'<p>Parses a JSON string into a FEEL value. The function converts JSON primitives, objects, and arrays into their corresponding FEEL types.</p>\n<p>Returns <code>null</code> if the string is not a valid JSON value.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">from json(value: string): Any\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">from json("{\\"a\\": 1, \\"b\\": 2}")\n// {a: 1, b: 2}\n\nfrom json("true")\n// true\n\nfrom json("\\"2023-06-14\\"")\n// "2023-06-14"\n</code></pre>\n',engines:{camunda:">=8.9"}},{name:"to json",type:"function",params:[{name:"value"}],info:'<p>Converts a FEEL value into a JSON string. The function converts FEEL primitives, contexts, and lists into their\ncorresponding JSON types. Temporal values are converted to their ISO 8601 string representation, including timezone\ninformation for date and time values (format: <code>2025-11-24T10:00:00+01:00[Europe/Berlin]</code>).</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">to json(value: Any): string\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">to json({a: 1, b: 2})\n// "{\\"a\\":1,\\"b\\":2}"\n\nto json(true)\n// "true"\n\nto json(@"2023-06-14")\n// "\\"2023-06-14\\""\n\nto json(@"2025-11-24T10:00:00@Europe/Berlin")\n// "\\"2025-11-24T10:00:00+01:00[Europe/Berlin]\\""\n\nto json(@"P3Y")\n// "\\"P3Y\\""\n</code></pre>\n',engines:{camunda:">=8.9"}},{name:"list contains",type:"function",params:[{name:"list"},{name:"element"}],info:'<p>Returns <code>true</code> if the given list contains the element. Otherwise, returns <code>false</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">list contains(list: list, element: Any): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">list contains([1,2,3], 2)\n// true\n</code></pre>\n'},{name:"count",type:"function",params:[{name:"list"}],info:'<p>Returns the number of elements of the given list.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">count(list: list): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">count([1,2,3])\n// 3\n</code></pre>\n'},{name:"min",type:"function",params:[{name:"list"}],info:'<p>Returns the minimum of the given list.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">min(list: list): Any\n</code></pre>\n<p>All elements in <code>list</code> should have the same type and be comparable.</p>\n<p>The parameter <code>list</code> can be passed as a list or as a sequence of elements.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">min([1,2,3])\n// 1\n\nmin(1,2,3)\n// 1\n</code></pre>\n'},{name:"max",type:"function",params:[{name:"list"}],info:'<p>Returns the maximum of the given list.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">max(list: list): Any\n</code></pre>\n<p>All elements in <code>list</code> should have the same type and be comparable.</p>\n<p>The parameter <code>list</code> can be passed as a list or as a sequence of elements.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">max([1,2,3])\n// 3\n\nmax(1,2,3)\n// 3\n</code></pre>\n'},{name:"sum",type:"function",params:[{name:"list"}],info:'<p>Returns the sum of the given list of numbers.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">sum(list: list<number>): number\n</code></pre>\n<p>The parameter <code>list</code> can be passed as a list or as a sequence of elements.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">sum([1,2,3])\n// 6\n\nsum(1,2,3)\n// 6\n</code></pre>\n'},{name:"product",type:"function",params:[{name:"list"}],info:'<p>Returns the product of the given list of numbers.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">product(list: list<number>): number\n</code></pre>\n<p>The parameter <code>list</code> can be passed as a list or as a sequence of elements.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">product([2, 3, 4])\n// 24\n\nproduct(2, 3, 4)\n// 24\n</code></pre>\n'},{name:"mean",type:"function",params:[{name:"list"}],info:'<p>Returns the arithmetic mean (i.e. average) of the given list of numbers.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">mean(list: list<number>): number\n</code></pre>\n<p>The parameter <code>list</code> can be passed as a list or as a sequence of elements.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">mean([1,2,3])\n// 2\n\nmean(1,2,3)\n// 2\n</code></pre>\n'},{name:"median",type:"function",params:[{name:"list"}],info:'<p>Returns the median element of the given list of numbers.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">median(list: list<number>): number\n</code></pre>\n<p>The parameter <code>list</code> can be passed as a list or as a sequence of elements.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">median(8, 2, 5, 3, 4)\n// 4\n\nmedian([6, 1, 2, 3])\n// 2.5\n</code></pre>\n'},{name:"stddev",type:"function",params:[{name:"list"}],info:'<p>Returns the standard deviation of the given list of numbers.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">stddev(list: list<number>): number\n</code></pre>\n<p>The parameter <code>list</code> can be passed as a list or as a sequence of elements.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">stddev(2, 4, 7, 5)\n// 2.0816659994661326\n\nstddev([2, 4, 7, 5])\n// 2.0816659994661326\n</code></pre>\n'},{name:"mode",type:"function",params:[{name:"list"}],info:'<p>Returns the mode of the given list of numbers.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">mode(list: list<number>): number\n</code></pre>\n<p>The parameter <code>list</code> can be passed as a list or as a sequence of elements.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">mode(6, 3, 9, 6, 6)\n// [6]\n\nmode([6, 1, 9, 6, 1])\n// [1, 6]\n</code></pre>\n'},{name:"all",type:"function",params:[{name:"list"}],info:'<p>Returns <code>false</code> if any element of the given list is <code>false</code>. Otherwise, returns <code>true</code>.</p>\n<p>If the given list is empty, it returns <code>true</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">all(list: list<boolean>): boolean\n</code></pre>\n<p>The parameter <code>list</code> can be passed as a list or as a sequence of elements.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">all([true,false])\n// false\n\nall(false,null,true)\n// false\n</code></pre>\n<p>:::info\nThe function <code>all()</code> replaced the previous function <code>and()</code>. The previous function is deprecated and\nshould not be used anymore.\n:::</p>\n'},{name:"any",type:"function",params:[{name:"list"}],info:'<p>Returns <code>true</code> if any element of the given list is <code>true</code>. Otherwise, returns <code>false</code>.</p>\n<p>If the given list is empty, it returns <code>false</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">any(list: list<boolean>): boolean\n</code></pre>\n<p>The parameter <code>list</code> can be passed as a list or as a sequence of elements.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">any([false,true])\n// true\n\nany(false,null,true)\n// true\n</code></pre>\n<p>:::info\nThe function <code>any()</code> replaced the previous function <code>or()</code>. The previous function is deprecated and\nshould not be used anymore.\n:::</p>\n'},{name:"sublist",type:"function",params:[{name:"list"},{name:"start position"}],info:'<p>Returns a partial list of the given value starting at <code>start position</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">sublist(list: list, start position: number): list\n</code></pre>\n<p>The <code>start position</code> starts at the index <code>1</code>. The last position is <code>-1</code>.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">sublist([1,2,3], 2)\n// [2,3]\n</code></pre>\n'},{name:"sublist",type:"function",params:[{name:"list"},{name:"start position"},{name:"length"}],info:'<p>Returns a partial list of the given value starting at <code>start position</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">sublist(list: list, start position: number, length: number): list\n</code></pre>\n<p>The <code>start position</code> starts at the index <code>1</code>. The last position is <code>-1</code>.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">sublist([1,2,3], 1, 2)\n// [1,2]\n</code></pre>\n'},{name:"append",type:"function",params:[{name:"list"},{name:"items"}],info:'<p>Returns the given list with all <code>items</code> appended.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">append(list: list, items: Any): list\n</code></pre>\n<p>The parameter <code>items</code> can be a single element or a sequence of elements.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">append([1], 2, 3)\n// [1,2,3]\n</code></pre>\n'},{name:"concatenate",type:"function",params:[{name:"lists"}],info:'<p>Returns a list that includes all elements of the given lists.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">concatenate(lists: list): list\n</code></pre>\n<p>The parameter <code>lists</code> is a sequence of lists.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">concatenate([1,2],[3])\n// [1,2,3]\n\nconcatenate([1],[2],[3])\n// [1,2,3]\n</code></pre>\n'},{name:"insert before",type:"function",params:[{name:"list"},{name:"position"},{name:"newItem"}],info:'<p>Returns the given list with <code>newItem</code> inserted at <code>position</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">insert before(list: list, position: number, newItem: Any): list\n</code></pre>\n<p>The <code>position</code> starts at the index <code>1</code>. The last position is <code>-1</code>.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">insert before([1,3],1,2)\n// [2,1,3]\n</code></pre>\n'},{name:"remove",type:"function",params:[{name:"list"},{name:"position"}],info:'<p>Returns the given list without the element at <code>position</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">remove(list: list, position: number): list\n</code></pre>\n<p>The <code>position</code> starts at the index <code>1</code>. The last position is <code>-1</code>.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">remove([1,2,3], 2)\n// [1,3]\n</code></pre>\n'},{name:"reverse",type:"function",params:[{name:"list"}],info:'<p>Returns the given list in revered order.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">reverse(list: list): list\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">reverse([1,2,3])\n// [3,2,1]\n</code></pre>\n'},{name:"index of",type:"function",params:[{name:"list"},{name:"match"}],info:'<p>Returns an ascending list of positions containing <code>match</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">index of(list: list, match: Any): list<number>\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">index of([1,2,3,2],2)\n// [2,4]\n</code></pre>\n'},{name:"union",type:"function",params:[{name:"list"}],info:'<p>Returns a list that includes all elements of the given lists without duplicates.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">union(list: list): list\n</code></pre>\n<p>The parameter <code>list</code> is a sequence of lists.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">union([1,2],[2,3])\n// [1,2,3]\n</code></pre>\n'},{name:"distinct values",type:"function",params:[{name:"list"}],info:'<p>Returns the given list without duplicates.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">distinct values(list: list): list\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">distinct values([1,2,3,2,1])\n// [1,2,3]\n</code></pre>\n'},{name:"flatten",type:"function",params:[{name:"list"}],info:'<p>Returns a list that includes all elements of the given list without nested lists.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">flatten(list: list): list\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">flatten([[1,2],[[3]], 4])\n// [1,2,3,4]\n</code></pre>\n'},{name:"sort",type:"function",params:[{name:"list"},{name:"precedes"}],info:'<p>Returns the given list sorted by the <code>precedes</code> function.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">sort(list: list, precedes: function<(Any, Any) -> boolean>): list\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">sort(list: [3,1,4,5,2], precedes: function(x,y) x < y)\n// [1,2,3,4,5]\n</code></pre>\n'},{name:"string join",type:"function",params:[{name:"list"}],info:'<p>Joins a list of strings into a single string. This is similar to\nJava's <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/stream/Collectors.html#joining(java.lang.CharSequence,java.lang.CharSequence,java.lang.CharSequence)">joining</a>\nfunction.</p>\n<p>If an item of the list is <code>null</code>, the item is ignored for the result string. If an item is\nneither a string nor <code>null</code>, the function returns <code>null</code> instead of a string.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">string join(list: list<string>): string\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">string join(["a","b","c"])\n// "abc"\n\nstring join(["a",null,"c"])\n// "ac"\n\nstring join([])\n// ""\n</code></pre>\n'},{name:"string join",type:"function",params:[{name:"list"},{name:"delimiter"}],info:'<p>Joins a list of strings into a single string. This is similar to\nJava's <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/stream/Collectors.html#joining(java.lang.CharSequence,java.lang.CharSequence,java.lang.CharSequence)">joining</a>\nfunction.</p>\n<p>If an item of the list is <code>null</code>, the item is ignored for the result string. If an item is\nneither a string nor <code>null</code>, the function returns <code>null</code> instead of a string.</p>\n<p>The resulting string contains a <code>delimiter</code> between each element.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">string join(list: list<string>, delimiter: string): string\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">string join(["a"], "X")\n// "a"\n\nstring join(["a","b","c"], ", ")\n// "a, b, c"\n</code></pre>\n'},{name:"decimal",type:"function",params:[{name:"n"},{name:"scale"}],info:'<p>Rounds the given value at the given scale.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">decimal(n: number, scale: number): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">decimal(1/3, 2)\n// .33\n\ndecimal(1.5, 0)\n// 2\n</code></pre>\n'},{name:"floor",type:"function",params:[{name:"n"}],info:'<p>Rounds the given value with rounding mode flooring.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">floor(n: number): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">floor(1.5)\n// 1\n\nfloor(-1.5)\n// -2\n</code></pre>\n'},{name:"floor",type:"function",params:[{name:"n"},{name:"scale"}],info:'<p>Rounds the given value with rounding mode flooring at the given scale.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">floor(n: number, scale: number): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">floor(-1.56, 1)\n// -1.6\n</code></pre>\n'},{name:"ceiling",type:"function",params:[{name:"n"}],info:'<p>Rounds the given value with rounding mode ceiling.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">ceiling(n: number): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">ceiling(1.5)\n// 2\n\nceiling(-1.5)\n// -1\n</code></pre>\n'},{name:"ceiling",type:"function",params:[{name:"n"},{name:"scale"}],info:'<p>Rounds the given value with rounding mode ceiling at the given scale.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">ceiling(n: number, scale: number): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">ceiling(-1.56, 1)\n// -1.5\n</code></pre>\n'},{name:"round up",type:"function",params:[{name:"n"},{name:"scale"}],info:'<p>Rounds the given value with the rounding mode round-up at the given scale.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">round up(n: number, scale: number): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">round up(5.5)\n// 6\n\nround up(-5.5)\n// -6\n\nround up(1.121, 2)\n// 1.13\n\nround up(-1.126, 2)\n// -1.13\n</code></pre>\n'},{name:"round down",type:"function",params:[{name:"n"},{name:"scale"}],info:'<p>Rounds the given value with the rounding mode round-down at the given scale.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">round down(n: number, scale: number): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">round down(5.5, 0)\n// 5\n\nround down (-5.5, 0)\n// -5\n\nround down (1.121, 2)\n// 1.12\n\nround down (-1.126, 2)\n// -1.12\n</code></pre>\n'},{name:"round half up",type:"function",params:[{name:"n"},{name:"scale"}],info:'<p>Rounds the given value with the rounding mode round-half-up at the given scale.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">round half up(n: number, scale: number): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">round half up(5.5, 0)\n// 6\n\nround half up(-5.5, 0)\n// -6\n\nround half up(1.121, 2)\n// 1.12\n\nround half up(-1.126, 2)\n// -1.13\n</code></pre>\n'},{name:"round half down",type:"function",params:[{name:"n"},{name:"scale"}],info:'<p>Rounds the given value with the rounding mode round-half-down at the given scale.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">round half down(n: number, scale: number): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">round half down (5.5, 0)\n// 5\n\nround half down (-5.5, 0)\n// -5\n\nround half down (1.121, 2)\n// 1.12\n\nround half down (-1.126, 2)\n// -1.13\n</code></pre>\n'},{name:"abs",type:"function",params:[{name:"number"}],info:'<p>Returns the absolute value of the given numeric value.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">abs(number: number): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">abs(10)\n// 10\n\nabs(-10)\n// 10\n</code></pre>\n'},{name:"modulo",type:"function",params:[{name:"dividend"},{name:"divisor"}],info:'<p>Returns the remainder of the division of dividend by divisor.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">modulo(dividend: number, divisor: number): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">modulo(12, 5)\n// 2\n</code></pre>\n'},{name:"sqrt",type:"function",params:[{name:"number"}],info:'<p>Returns the square root of the given value.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">sqrt(number: number): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">sqrt(16)\n// 4\n</code></pre>\n'},{name:"log",type:"function",params:[{name:"number"}],info:'<p>Returns the natural logarithm (base e) of the given value.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">log(number: number): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">log(10)\n// 2.302585092994046\n</code></pre>\n'},{name:"exp",type:"function",params:[{name:"number"}],info:'<p>Returns the Euler’s number e raised to the power of the given number .</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">exp(number: number): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">exp(5)\n// 148.4131591025766\n</code></pre>\n'},{name:"odd",type:"function",params:[{name:"number"}],info:'<p>Returns <code>true</code> if the given value is odd. Otherwise, returns <code>false</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">odd(number: number): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">odd(5)\n// true\n\nodd(2)\n// false\n</code></pre>\n'},{name:"even",type:"function",params:[{name:"number"}],info:'<p>Returns <code>true</code> if the given is even. Otherwise, returns <code>false</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">even(number: number): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">even(5)\n// false\n\neven(2)\n// true\n</code></pre>\n'},{name:"before",type:"function",params:[{name:"point1"},{name:"point2"}],info:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">before(point1: Any, point2: Any): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">before(1, 10)\n// true\n\nbefore(10, 1)\n// false\n</code></pre>\n'},{name:"before",type:"function",params:[{name:"range"},{name:"point"}],info:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">before(range: range, point: Any): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">before([1..5], 10)\n// true\n</code></pre>\n'},{name:"before",type:"function",params:[{name:"point"},{name:"range"}],info:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">before(point: Any, range: range): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">before(1, [2..5])\n// true\n</code></pre>\n'},{name:"before",type:"function",params:[{name:"range1"},{name:"range2"}],info:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">before(range1: range, range2: range): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">before([1..5], [6..10])\n// true\n\nbefore([1..5),[5..10])\n// true\n</code></pre>\n'},{name:"after",type:"function",params:[{name:"point1"},{name:"point2"}],info:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">after(point1: Any, point2: Any): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">after(10, 1)\n// true\n\nafter(1, 10)\n// false\n</code></pre>\n'},{name:"after",type:"function",params:[{name:"range"},{name:"point"}],info:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">after(range: range, point: Any): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">after([1..5], 10)\n// false\n</code></pre>\n'},{name:"after",type:"function",params:[{name:"point"},{name:"range"}],info:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">after(point: Any, range: range): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">after(12, [2..5])\n// true\n</code></pre>\n'},{name:"after",type:"function",params:[{name:"range1"},{name:"range2"}],info:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">after(range1: range, range2: range): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">after([6..10], [1..5])\n// true\n\nafter([5..10], [1..5))\n// true\n</code></pre>\n'},{name:"meets",type:"function",params:[{name:"range1"},{name:"range2"}],info:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">meets(range1: range, range2: range): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">meets([1..5], [5..10])\n// true\n\nmeets([1..3], [4..6])\n// false\n\nmeets([1..3], [3..5])\n// true\n\nmeets([1..5], (5..8])\n// false\n</code></pre>\n'},{name:"met by",type:"function",params:[{name:"range1"},{name:"range2"}],info:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">met by(range1: range, range2: range): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">met by([5..10], [1..5])\n// true\n\nmet by([3..4], [1..2])\n// false\n\nmet by([3..5], [1..3])\n// true\n\nmet by((5..8], [1..5))\n// false\n\nmet by([5..10], [1..5))\n// false\n</code></pre>\n'},{name:"overlaps",type:"function",params:[{name:"range1"},{name:"range2"}],info:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">overlaps(range1: range, range2: range): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">overlaps([5..10], [1..6])\n// true\n\noverlaps((3..7], [1..4])\n// true\n\noverlaps([1..3], (3..6])\n// false\n\noverlaps((5..8], [1..5))\n// false\n\noverlaps([4..10], [1..5))\n// true\n</code></pre>\n'},{name:"overlaps before",type:"function",params:[{name:"range1"},{name:"range2"}],info:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">overlaps before(range1: range, range2: range): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">overlaps before([1..5], [4..10])\n// true\n\noverlaps before([3..4], [1..2])\n// false\n\noverlaps before([1..3], (3..5])\n// false\n\noverlaps before([1..5), (3..8])\n// true\n\noverlaps before([1..5), [5..10])\n// false\n</code></pre>\n'},{name:"overlaps after",type:"function",params:[{name:"range1"},{name:"range2"}],info:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">overlaps after(range1: range, range2: range): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">overlaps after([4..10], [1..5])\n// true\n\noverlaps after([3..4], [1..2])\n// false\n\noverlaps after([3..5], [1..3))\n// false\n\noverlaps after((5..8], [1..5))\n// false\n\noverlaps after([4..10], [1..5))\n// true\n</code></pre>\n'},{name:"finishes",type:"function",params:[{name:"point"},{name:"range"}],info:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">finishes(point: Any, range: range): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">finishes(5, [1..5])\n// true\n\nfinishes(10, [1..7])\n// false\n</code></pre>\n'},{name:"finishes",type:"function",params:[{name:"range1"},{name:"range2"}],info:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">finishes(range1: range, range2: range): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">finishes([3..5], [1..5])\n// true\n\nfinishes((1..5], [1..5))\n// false\n\nfinishes([5..10], [1..10))\n// false\n</code></pre>\n'},{name:"finished by",type:"function",params:[{name:"range"},{name:"point"}],info:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">finished by(range: range, point: Any): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">finished by([5..10], 10)\n// true\n\nfinished by([3..4], 2)\n// false\n</code></pre>\n'},{name:"finished by",type:"function",params:[{name:"range1"},{name:"range2"}],info:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">finished by(range1: range, range2: range): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">finished by([1..5], [3..5])\n// true\n\nfinished by((5..8], [1..5))\n// false\n\nfinished by([5..10], (1..10))\n// false\n</code></pre>\n'},{name:"includes",type:"function",params:[{name:"range"},{name:"point"}],info:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">includes(range: range, point: Any): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">includes([5..10], 6)\n// true\n\nincludes([3..4], 5)\n// false\n</code></pre>\n'},{name:"includes",type:"function",params:[{name:"range1"},{name:"range2"}],info:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">includes(range1: range, range2: range): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">includes([1..10], [4..6])\n// true\n\nincludes((5..8], [1..5))\n// false\n\nincludes([1..10], [1..5))\n// true\n</code></pre>\n'},{name:"during",type:"function",params:[{name:"point"},{name:"range"}],info:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">during(point: Any, range: range): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">during(5, [1..10])\n// true\n\nduring(12, [1..10])\n// false\n\nduring(1, (1..10])\n// false\n</code></pre>\n'},{name:"during",type:"function",params:[{name:"range1"},{name:"range2"}],info:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">during(range1: range, range2: range): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">during([4..6], [1..10))\n// true\n\nduring((1..5], (1..10])\n// true\n</code></pre>\n'},{name:"starts",type:"function",params:[{name:"point"},{name:"range"}],info:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">starts(point: Any, range: range): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">starts(1, [1..5])\n// true\n\nstarts(1, (1..8])\n// false\n</code></pre>\n'},{name:"starts",type:"function",params:[{name:"range1"},{name:"range2"}],info:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">starts(range1: range, range2: range): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">starts((1..5], [1..5])\n// false\n\nstarts([1..10], [1..5])\n// false\n\nstarts((1..5), (1..10))\n// true\n</code></pre>\n'},{name:"started by",type:"function",params:[{name:"range"},{name:"point"}],info:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">started by(range: range, point: Any): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">started by([1..10], 1)\n// true\n\nstarted by((1..10], 1)\n// false\n</code></pre>\n'},{name:"started by",type:"function",params:[{name:"range1"},{name:"range2"}],info:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">started by(range1: range, range2: range): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">started by([1..10], [1..5])\n// true\n\nstarted by((1..10], [1..5))\n// false\n\nstarted by([1..10], [1..10))\n// true\n</code></pre>\n'},{name:"coincides",type:"function",params:[{name:"point1"},{name:"point2"}],info:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">coincides(point1: Any, point2: Any): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">coincides(5, 5)\n// true\n\ncoincides(3, 4)\n// false\n</code></pre>\n'},{name:"coincides",type:"function",params:[{name:"range1"},{name:"range2"}],info:'<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">coincides(range1: range, range2: range): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">coincides([1..5], [1..5])\n// true\n\ncoincides((1..5], [1..5))\n// false\n\ncoincides([1..5], [2..6])\n// false\n</code></pre>\n'},{name:"substring",type:"function",params:[{name:"string"},{name:"start position"}],info:'<p>Returns a substring of the given value starting at <code>start position</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">substring(string: string, start position: number): string\n</code></pre>\n<p>The <code>start position</code> starts at the index <code>1</code>. The last position is <code>-1</code>.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">substring("foobar", 3)\n// "obar"\n\nsubstring("foobar", -2)\n// "ar"\n</code></pre>\n'},{name:"substring",type:"function",params:[{name:"string"},{name:"start position"},{name:"length"}],info:'<p>Returns a substring of the given value, starting at <code>start position</code> with the given <code>length</code>. If <code>length</code> is greater than\nthe remaining characters of the value, it returns all characters from <code>start position</code> until the end.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">substring(string: string, start position: number, length: number): string\n</code></pre>\n<p>The <code>start position</code> starts at the index <code>1</code>. The last position is <code>-1</code>.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">substring("foobar", 3, 3)\n// "oba"\n\nsubstring("foobar", -3, 2)\n// "ba"\n\nsubstring("foobar", 3, 10)\n// "obar"\n</code></pre>\n'},{name:"string length",type:"function",params:[{name:"string"}],info:'<p>Returns the number of characters in the given value.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">string length(string: string): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">string length("foo")\n// 3\n</code></pre>\n'},{name:"upper case",type:"function",params:[{name:"string"}],info:'<p>Returns the given value with all characters are uppercase.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">upper case(string: string): string\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">upper case("aBc4")\n// "ABC4"\n</code></pre>\n'},{name:"lower case",type:"function",params:[{name:"string"}],info:'<p>Returns the given value with all characters are lowercase.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">lower case(string: string): string\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">lower case("aBc4")\n// "abc4"\n</code></pre>\n'},{name:"substring before",type:"function",params:[{name:"string"},{name:"match"}],info:'<p>Returns a substring of the given value that contains all characters before <code>match</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">substring before(string: string, match: string): string\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">substring before("foobar", "bar")\n// "foo"\n</code></pre>\n'},{name:"substring after",type:"function",params:[{name:"string"},{name:"match"}],info:'<p>Returns a substring of the given value that contains all characters after <code>match</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">substring after(string: string, match: string): string\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">substring after("foobar", "ob")\n// "ar"\n</code></pre>\n'},{name:"contains",type:"function",params:[{name:"string"},{name:"match"}],info:'<p>Returns <code>true</code> if the given value contains the substring <code>match</code>. Otherwise, returns <code>false</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">contains(string: string, match: string): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">contains("foobar", "of")\n// false\n</code></pre>\n'},{name:"starts with",type:"function",params:[{name:"string"},{name:"match"}],info:'<p>Returns <code>true</code> if the given value starts with the substring <code>match</code>. Otherwise, returns <code>false</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">starts with(string: string, match: string): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">starts with("foobar", "fo")\n// true\n</code></pre>\n'},{name:"ends with",type:"function",params:[{name:"string"},{name:"match"}],info:'<p>Returns <code>true</code> if the given value ends with the substring <code>match</code>. Otherwise, returns <code>false</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">ends with(string: string, match: string): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">ends with("foobar", "r")\n// true\n</code></pre>\n'},{name:"matches",type:"function",params:[{name:"input"},{name:"pattern"}],info:'<p>Returns <code>true</code> if the given value matches the <code>pattern</code>. Otherwise, returns <code>false</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">matches(input: string, pattern: string): boolean\n</code></pre>\n<p>The <code>pattern</code> is a string that contains a regular expression.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">matches("foobar", "^fo*bar")\n// true\n</code></pre>\n'},{name:"matches",type:"function",params:[{name:"input"},{name:"pattern"},{name:"flags"}],info:'<p>Returns <code>true</code> if the given value matches the <code>pattern</code>. Otherwise, returns <code>false</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">matches(input: string, pattern: string, flags: string): boolean\n</code></pre>\n<p>The <code>pattern</code> is a string that contains a regular expression.</p>\n<p>The <code>flags</code> can contain one or more of the following characters:</p>\n<ul>\n<li><code>s</code> (dot-all)</li>\n<li><code>m</code> (multi-line)</li>\n<li><code>i</code> (case insensitive)</li>\n<li><code>x</code> (comments)</li>\n</ul>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">matches("FooBar", "foo", "i")\n// true\n</code></pre>\n'},{name:"replace",type:"function",params:[{name:"input"},{name:"pattern"},{name:"replacement"}],info:'<p>Returns the resulting string after replacing all occurrences of <code>pattern</code> with <code>replacement</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">replace(input: string, pattern: string, replacement: string): string\n</code></pre>\n<p>The <code>pattern</code> is a string that contains a regular expression.</p>\n<p>The <code>replacement</code> can access the match groups by using <code>$</code> and the number of the group, for example,\n<code>$1</code> to access the first group.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">replace("abcd", "(ab)|(a)", "[1=$1][2=$2]")\n// "[1=ab][2=]cd"\n\nreplace("0123456789", "(\\d{3})(\\d{3})(\\d{4})", "($1) $2-$3")\n// "(012) 345-6789"\n</code></pre>\n'},{name:"replace",type:"function",params:[{name:"input"},{name:"pattern"},{name:"replacement"},{name:"flags"}],info:'<p>Returns the resulting string after replacing all occurrences of <code>pattern</code> with <code>replacement</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">replace(input: string, pattern: string, replacement: string, flags: string): string\n</code></pre>\n<p>The <code>pattern</code> is a string that contains a regular expression.</p>\n<p>The <code>replacement</code> can access the match groups by using <code>$</code> and the number of the group, for example,\n<code>$1</code> to access the first group.</p>\n<p>The <code>flags</code> can contain one or more of the following characters:</p>\n<ul>\n<li><code>s</code> (dot-all)</li>\n<li><code>m</code> (multi-line)</li>\n<li><code>i</code> (case insensitive)</li>\n<li><code>x</code> (comments)</li>\n</ul>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">replace("How do you feel?", "Feel", "FEEL", "i")\n// "How do you FEEL?"\n</code></pre>\n'},{name:"split",type:"function",params:[{name:"string"},{name:"delimiter"}],info:'<p>Splits the given value into a list of substrings, breaking at each occurrence of the <code>delimiter</code> pattern.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">split(string: string, delimiter: string): list<string>\n</code></pre>\n<p>The <code>delimiter</code> is a string that contains a regular expression.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">split("John Doe", "\\s" )\n// ["John", "Doe"]\n\nsplit("a;b;c;;", ";")\n// ["a", "b", "c", "", ""]\n</code></pre>\n'},{name:"now",type:"function",params:[],info:'<p>Returns the current date and time including the timezone.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">now(): date and time\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">now()\n// date and time("2020-07-31T14:27:30@Europe/Berlin")\n</code></pre>\n'},{name:"today",type:"function",params:[],info:'<p>Returns the current date.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">today(): date\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">today()\n// date("2020-07-31")\n</code></pre>\n'},{name:"day of week",type:"function",params:[{name:"date"}],info:'<p>Returns the day of the week according to the Gregorian calendar. Note that it always returns the English name of the day.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">day of week(date: date): string\n</code></pre>\n<pre><code class="language-feel">day of week(date: date and time): string\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">day of week(date("2019-09-17"))\n// "Tuesday"\n\nday of week(date and time("2019-09-17T12:00:00"))\n// "Tuesday"\n</code></pre>\n'},{name:"day of year",type:"function",params:[{name:"date"}],info:'<p>Returns the Gregorian number of the day within the year.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">day of year(date: date): number\n</code></pre>\n<pre><code class="language-feel">day of year(date: date and time): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">day of year(date("2019-09-17"))\n// 260\n\nday of year(date and time("2019-09-17T12:00:00"))\n// 260\n</code></pre>\n'},{name:"week of year",type:"function",params:[{name:"date"}],info:'<p>Returns the Gregorian number of the week within the year, according to ISO 8601.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">week of year(date: date): number\n</code></pre>\n<pre><code class="language-feel">week of year(date: date and time): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">week of year(date("2019-09-17"))\n// 38\n\nweek of year(date and time("2019-09-17T12:00:00"))\n// 38\n</code></pre>\n'},{name:"month of year",type:"function",params:[{name:"date"}],info:'<p>Returns the month of the year according to the Gregorian calendar. Note that it always returns the English name of the month.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">month of year(date: date): string\n</code></pre>\n<pre><code class="language-feel">month of year(date: date and time): string\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">month of year(date("2019-09-17"))\n// "September"\n\nmonth of year(date and time("2019-09-17T12:00:00"))\n// "September"\n</code></pre>\n'},{name:"abs",type:"function",params:[{name:"n"}],info:'<p>Returns the absolute value of a given duration.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">abs(n: days and time duration): days and time duration\n</code></pre>\n<pre><code class="language-feel">abs(n: years and months duration): years and months duration\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">abs(duration("-PT5H"))\n// "duration("PT5H")"\n\nabs(duration("PT5H"))\n// "duration("PT5H")"\n\nabs(duration("-P2M"))\n// duration("P2M")\n</code></pre>\n'},{name:"is defined",type:"function",params:[{name:"value"}],info:'<p><em>Camunda Extension</em></p>\n<p>Checks if a given value is not <code>null</code>. If the value is <code>null</code> then the function returns <code>false</code>.\nOtherwise, the function returns <code>true</code>.</p>\n<p>The function requires one argument. Calling <code>is defined()</code> without an argument is invalid.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">is defined(value: Any): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">is defined(1)\n// true\n\nis defined(null)\n// false\n\nis defined(x)\n// false - if no variable "x" exists\n\nis defined(x.y)\n// false - if no variable "x" exists or it doesn't have a property "y"\n\nis defined()\n// error - expected one argument\n</code></pre>\n<p>:::caution Breaking change</p>\n<p>This function worked differently in previous versions. It returned <code>true</code> if the value was <code>null</code>.\nSince this version, the function returns <code>false</code> if the value is <code>null</code>.</p>\n<p>:::</p>\n'},{name:"get or else",type:"function",params:[{name:"value"},{name:"default"}],info:'<p><em>Camunda Extension</em></p>\n<p>Return the provided value parameter if not <code>null</code>, otherwise return the default parameter</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">get or else(value: Any, default: Any): Any\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">get or else("this", "default")\n// "this"\n\nget or else(null, "default")\n// "default"\n\nget or else(null, null)\n// null\n</code></pre>\n',engines:{camunda:">=8.3"}},{name:"assert",type:"function",params:[{name:"value"},{name:"condition"}],info:'<p><em>Camunda Extension</em></p>\n<p>Verify that the given condition is met. If the condition is <code>true</code>, the function returns the value.\nOtherwise, the evaluation fails with an error.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">assert(value: Any, condition: Any)\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">assert(x, x != null)\n// "value" - if x is "value"\n// error - if x is null or doesn't exist\n\nassert(x, x >= 0)\n// 4 - if x is 4\n// error - if x is less than zero\n</code></pre>\n',engines:{camunda:">=8.3"}},{name:"assert",type:"function",params:[{name:"value"},{name:"condition"},{name:"cause"}],info:'<p><em>Camunda Extension</em></p>\n<p>Verify that the given condition is met. If the condition is <code>true</code>, the function returns the value.\nOtherwise, the evaluation fails with an error containing the given message.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">assert(value: Any, condition: Any, cause: String)\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">assert(x, x != null, "'x' should not be null")\n// "value" - if x is "value"\n// error('x' should not be null) - if x is null or doesn't exist\n\nassert(x, x >= 0, "'x' should be positive")\n// 4 - if x is 4\n// error('x' should be positive) - if x is less than zero\n</code></pre>\n',engines:{camunda:">=8.3"}},{name:"get value",type:"function",params:[{name:"context"},{name:"keys"}],info:'<p><em>Camunda Extension</em></p>\n<p>Returns the value of the context entry for a context path defined by the given keys.</p>\n<p>If <code>keys</code> contains the keys <code>[k1, k2]</code> then it returns the value at the nested entry <code>k1.k2</code> of the context.</p>\n<p>If <code>keys</code> are empty or the nested entry defined by the keys doesn't exist in the context, it returns <code>null</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">get value(context: context, keys: list<string>): Any\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">get value({x:1, y: {z:0}}, ["y", "z"])\n// 0\n\nget value({x: {y: {z:0}}}, ["x", "y"])\n// {z:0}\n\nget value({a: {b: 3}}, ["b"])\n// null\n</code></pre>\n'},{name:"context put",type:"function",params:[{name:"context"},{name:"key"},{name:"value"}],info:'<p>Adds a new entry with the given key and value to the context. Returns a new context that includes the entry.</p>\n<p>If an entry for the same key already exists in the context, it overrides the value.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">context put(context: context, key: string, value: Any): context\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">context put({x:1}, "y", 2)\n// {x:1, y:2}\n</code></pre>\n<p>:::info\nThe function <code>context put()</code> replaced the previous function <code>put()</code> (Camunda Extension). The\nprevious function is deprecated and should not be used anymore.\n:::</p>\n'},{name:"context merge",type:"function",params:[{name:"contexts"}],info:'<p>Union the given contexts. Returns a new context that includes all entries of the given contexts.</p>\n<p>If an entry for the same key already exists in a context, it overrides the value. The entries are overridden in the same order as in the list of contexts.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">context merge(contexts: list<context>): context\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">context merge([{x:1}, {y:2}])\n// {x:1, y:2}\n\ncontext merge([{x:1, y: 0}, {y:2}])\n// {x:1, y:2}\n</code></pre>\n<p>:::info\nThe function <code>context merge()</code> replaced the previous function <code>put all()</code> (Camunda Extension). The\nprevious function is deprecated and should not be used anymore.\n:::</p>\n',engines:{camunda:">=8.2"}},{name:"date and time",type:"function",params:[{name:"date"},{name:"timezone"}],info:'<p><em>Camunda Extension</em></p>\n<p>Returns the given date and time value at the given timezone.</p>\n<p>If <code>date</code> has a different timezone than <code>timezone</code> then it adjusts the time to match the local time of <code>timezone</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">date and time(date: date and time, timezone: string): date and time\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">date and time(@"2020-07-31T14:27:30@Europe/Berlin", "America/Los_Angeles")\n// date and time("2020-07-31T05:27:30@America/Los_Angeles")\n\ndate and time(@"2020-07-31T14:27:30", "Z")\n// date and time("2020-07-31T12:27:30Z")\n</code></pre>\n'},{name:"duplicate values",type:"function",params:[{name:"list"}],info:'<p><em>Camunda Extension</em></p>\n<p>Returns all duplicate values of the given list.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">duplicate values(list: list): list\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">duplicate values([1,2,3,2,1])\n// [1,2]\n</code></pre>\n',engines:{camunda:">=8.3"}},{name:"string join",type:"function",params:[{name:"list"},{name:"delimiter"},{name:"prefix"},{name:"suffix"}],info:'<p><em>Camunda Extension</em></p>\n<p>Joins a list of strings into a single string. This is similar to\nJava's <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/stream/Collectors.html#joining(java.lang.CharSequence,java.lang.CharSequence,java.lang.CharSequence)">joining</a>\nfunction.</p>\n<p>If an item of the list is <code>null</code>, the item is ignored for the result string. If an item is\nneither a string nor <code>null</code>, the function returns <code>null</code> instead of a string.</p>\n<p>The resulting string starts with <code>prefix</code>, contains a <code>delimiter</code> between each element, and ends\nwith <code>suffix</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">string join(list: list<string>, delimiter: string, prefix: string, suffix: string): string\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">string join(["a","b","c"], ", ", "[", "]")\n// "[a, b, c]"\n</code></pre>\n'},{name:"is empty",type:"function",params:[{name:"list"}],info:'<p><em>Camunda Extension</em></p>\n<p>Returns <code>true</code> if the given list is empty. Otherwise, returns <code>false</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">is empty(list: list): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">is empty([])\n// true\n\nis empty([1,2,3])\n// false\n</code></pre>\n',engines:{camunda:">=8.6"}},{name:"partition",type:"function",params:[{name:"list"},{name:"size"}],info:'<p><em>Camunda Extension</em></p>\n<p>Returns consecutive sublists of a list, each of the same size (the final list may be smaller).</p>\n<p>If <code>size</code> is less than <code>0</code>, it returns <code>null</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">partition(list: list, size: number): list\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">partition([1,2,3,4,5], 2)\n// [[1,2], [3,4], [5]]\n\npartition([], 2)\n// []\n\npartition([1,2], 0)\n// null\n</code></pre>\n',engines:{camunda:">=8.7"}},{name:"fromAi",type:"function",params:[{name:"value"}],info:'<p><em>Camunda Extension</em></p>\n<p>Returns the unmodified <code>value</code> parameter.</p>\n<ul>\n<li>The purpose of this function is solely to tag the value as being generated by an AI integration.</li>\n<li>The actual handling is not performed by the FEEL engine, but by a custom integration such as a connector or a job worker.</li>\n</ul>\n<p>The main use case of this function is for <a href="../../../connectors/out-of-the-box-connectors/agentic-ai-aiagent-tool-definitions.md">tool definitions</a> used by the <a href="../../../connectors/out-of-the-box-connectors/agentic-ai-aiagent.md">AI Agent connector</a>.</p>\n<p>See the following function overloads for additional function parameters.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">fromAi(value: Any): Any\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">fromAi(toolCall.searchQuery)\n// toolCall.searchQuery contents\n\nfromAi(toolCall.userId)\n// toolCall.userId contents\n</code></pre>\n',engines:{camunda:">=8.8"}},{name:"fromAi",type:"function",params:[{name:"value"},{name:"description"}],info:'<p><em>Camunda Extension</em></p>\n<p>Returns the unmodified <code>value</code> parameter.</p>\n<p>In addition to the previous overload, it also accepts an optional <code>description</code> parameter to provide a textual description of the value. The description must be <code>null</code> or a string constant.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">fromAi(value: Any, description: string): Any\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">fromAi(toolCall.searchQuery, "The search query used to find the best match.")\n// toolCall.searchQuery contents\n\nfromAi(toolCall.searchQuery, null)\n// toolCall.searchQuery contents\n</code></pre>\n',engines:{camunda:">=8.8"}},{name:"fromAi",type:"function",params:[{name:"value"},{name:"description"},{name:"type"}],info:'<p><em>Camunda Extension</em></p>\n<p>Returns the unmodified <code>value</code> parameter.</p>\n<p>In addition to the previous overload, it also accepts an optional <code>type</code> parameter to provide type information about the value. The type must be <code>null</code> or a string constant.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">fromAi(value: Any, description: string, type: string): Any\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">fromAi(toolCall.searchQuery, "The search query used to find the best match.", "string")\n// toolCall.searchQuery contents\n\nfromAi(toolCall.userId, "The user's ID", "number")\n// toolCall.userId contents\n\nfromAi(toolCall.userId, null, "number")\n// toolCall.userId contents\n\nfromAi(value: toolCall.userId, type: "number")\n// toolCall.userId contents\n</code></pre>\n',engines:{camunda:">=8.8"}},{name:"fromAi",type:"function",params:[{name:"value"},{name:"description"},{name:"type"},{name:"schema"}],info:'<p><em>Camunda Extension</em></p>\n<p>Returns the unmodified <code>value</code> parameter.</p>\n<p>In addition to the previous overload, it also accepts an optional <code>schema</code> parameter to provide a (partial) <a href="https://json-schema.org/">JSON schema</a> for the value.</p>\n<ul>\n<li>The schema must be <code>null</code> or a context (map) containing only constant values. For example, function calls within the schema are not supported.</li>\n<li>The schema is not validated by the FEEL engine but might be by a custom integration consuming the information.</li>\n<li>From the engine side it is possible to specify both a <code>type</code> and a <code>schema</code>, and it depends on the integration as to which value takes precedence. The <a href="../../../connectors/out-of-the-box-connectors/agentic-ai-aiagent.md">AI Agent connector</a> will override any type specified in the schema if the <code>type</code> parameter is also provided.</li>\n</ul>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">fromAi(value: Any, description: string, type: string, schema: context): Any\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">fromAi(toolCall.documentType, "The document type to provide", "string", {\n enum: ["invoice", "receipt", "contract"]\n})\n// toolCall.documentType contents\n\nfromAi(value: toolCall.documentType, description: "The document type to provide", schema: {\n type: "string",\n enum: ["invoice", "receipt", "contract"]\n})\n// toolCall.documentType contents\n\nfromAi(toolCall.tags, "Tags to apply to the blog post", "array", {\n items: {\n type: "string"\n }\n})\n// toolCall.tags contents\n</code></pre>\n',engines:{camunda:">=8.8"}},{name:"fromAi",type:"function",params:[{name:"value"},{name:"description"},{name:"type"},{name:"schema"},{name:"options"}],info:'<p><em>Camunda Extension</em></p>\n<p>Returns the unmodified <code>value</code> parameter.</p>\n<p>In addition to the previous overload, it also accepts an optional <code>options</code> parameter to provide additional options for the integration handling the value definition.</p>\n<ul>\n<li>The options parameter must be <code>null</code> or a context (map) containing only constant values. For example, function calls within options are not supported.</li>\n</ul>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">fromAi(value: Any, description: string, type: string, schema: context, options: context): Any\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">fromAi(toolCall.documentType, "The document type to provide", "string", null, {\n required: false\n})\n// toolCall.documentType contents\n\nfromAi(value: toolCall.documentType, options: {\n required: false\n})\n// toolCall.documentType contents\n</code></pre>\n',engines:{camunda:">=8.8"}},{name:"random number",type:"function",params:[],info:'<p><em>Camunda Extension</em></p>\n<p>Returns a random number between <code>0</code> and <code>1</code>.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">random number(): number\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">random number()\n// 0.9701618132579795\n</code></pre>\n',engines:{camunda:">=8.2"}},{name:"extract",type:"function",params:[{name:"string"},{name:"pattern"}],info:'<p><em>Camunda Extension</em></p>\n<p>Returns all matches of the pattern in the given string. Returns an empty list if the pattern doesn't\nmatch.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">extract(string: string, pattern: string): list<string>\n</code></pre>\n<p>The <code>pattern</code> is a string that contains a regular expression.</p>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">extract("references are 1234, 1256, 1378", "12[0-9]*")\n// ["1234","1256"]\n</code></pre>\n'},{name:"trim",type:"function",params:[{name:"string"}],info:'<p><em>Camunda Extension</em></p>\n<p>Returns the given string without leading and trailing spaces.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">trim(string: string): string\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">trim(" hello world ")\n// "hello world"\n\ntrim("hello world ")\n// "hello world"\n</code></pre>\n',engines:{camunda:">=8.6"}},{name:"uuid",type:"function",params:[],info:'<p><em>Camunda Extension</em></p>\n<p>Returns a UUID (Universally Unique Identifier) with 36 characters.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">uuid(): string\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">uuid()\n// "7793aab1-d761-4d38-916b-b7270e309894"\n</code></pre>\n',engines:{camunda:">=8.6"}},{name:"to base64",type:"function",params:[{name:"value"}],info:'<p><em>Camunda Extension</em></p>\n<p>Returns the given string encoded in Base64 format.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">to base64(value: string): string\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">to base64("FEEL")\n// "RkVFTA=="\n</code></pre>\n',engines:{camunda:">=8.6"}},{name:"from base64",type:"function",params:[{name:"value"}],info:'<p><em>Camunda Extension</em></p>\n<p>Returns the given Base64 encoded string decoded to a plain string.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">from base64(value: string): string\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">from base64("RkVFTA==")\n// "FEEL"\n</code></pre>\n'},{name:"is blank",type:"function",params:[{name:"string"}],info:'<p><em>Camunda Extension</em></p>\n<p>Returns <code>true</code> if the given string is blank (empty or contains only whitespaces).</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">is blank(string: string): boolean\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">is blank("")\n// true\n\nis blank(" ")\n// true\n\nis blank("hello world")\n// false\n</code></pre>\n',engines:{camunda:">=8.8"}},{name:"last day of month",type:"function",params:[{name:"date"}],info:'<p><em>Camunda Extension</em></p>\n<p>Takes the month of the given date or date-time value and returns the last day of this month.</p>\n<p><strong>Function signature</strong></p>\n<pre><code class="language-feel">last day of month(date: date): date\n</code></pre>\n<pre><code class="language-feel">last day of month(date: date and time): date\n</code></pre>\n<p><strong>Examples</strong></p>\n<pre><code class="language-feel">last day of month(date("2022-10-01"))\n// date("2022-10-31"))\n\nlast day of month(date and time("2022-10-16T12:00:00"))\n// date("2022-10-31"))\n</code></pre>\n',engines:{camunda:">=8.2"}}];!function(e,t={}){ym.of({source:e,config:t})}(e=>{if(0===e.state.doc.length)return[];const t=em(e.state),n=(i={syntaxTree:t,readContent:(t,n)=>e.state.sliceDoc(t,n),updateContent:(t,n,i)=>e.dispatch({changes:{from:t,to:n,insert:i}})},[...wm(i.syntaxTree),...km(i)]);var i;return n.map(e=>({...e,source:e.type}))}),$f.theme({"& .cm-content":{padding:"0px"},"& .cm-line":{padding:"0px"},"&.cm-editor.cm-focused":{outline:"none"},"& .cm-completionInfo":{whiteSpace:"pre-wrap",overflow:"hidden",textOverflow:"ellipsis"},"&.cm-editor":{height:"100%"},"& .cm-completionInfo > *":{whiteSpace:"normal"},"& .cm-completionInfo ul":{margin:0,paddingLeft:"15px"},"& .cm-completionInfo pre":{marginBottom:0,whiteSpace:"pre-wrap"},"& .cm-completionInfo p":{marginTop:0},"& .cm-completionInfo p:not(:last-of-type)":{marginBottom:0}}),wc.define(),wc.define(),wc.define(),wc.define(),Sm.map(e=>({...e,info:()=>We(e.info)}));(class extends cl{constructor(e){super(),this._modeling=e}setText(e,t){this._modeling.updateProperties(e,{text:t})}}).$inject=["modeling"];function Cm(e){e.stopPropagation()}function Em(e){return e&&e.id}(class extends vr{constructor(e,t){super(e,t),Ds(this);const{value:n}=e;this.state={value:n,optionsVisible:!1},this._portalEl=null}componentDidMount(){document.addEventListener("mousedown",this.onGlobalClick),document.addEventListener("focusin",this.onFocusChanged),this.keyboard.addListener(this.onKeyboard)}componentWillUnmount(){document.removeEventListener("focusin",this.onFocusChanged),document.removeEventListener("mousedown",this.onGlobalClick),this.keyboard.removeListener(this.onKeyboard),this.removePortalEl()}componentWillReceiveProps(e){const{value:t}=e;this.setState({value:t})}componentWillUpdate(e,t){const{optionsVisible:n}=t;n?this._portalEl||this.addPortalEl():this._portalEl&&this.removePortalEl()}componentDidUpdate(){const{optionsVisible:e}=this.state;if(!e||!this.inputNode)return;const t=this.getOptionsBounds();S(this._portalEl.style,t)}getOptionsBounds(){const e=this.renderer.getContainer(),{top:t,left:n,bottom:i}=e.getBoundingClientRect(),{top:r,left:o,width:s,height:a,bottom:l}=this.inputNode.getBoundingClientRect(),c=r+a-t+e.scrollTop,h={top:`${c}px`,left:`${o-n+e.scrollLeft}px`,width:`${s}px`,"max-height":`calc(100% - ${c}px)`};if(i-l<a){const e=i-r;h.bottom=`${e}px`,h["max-height"]=`calc(100% - ${e})`,delete h.top}return h}addPortalEl(){this._portalEl=We('<div class="dms-select-options"></div>');this.renderer.getContainer().appendChild(this._portalEl),this._portalEl.addEventListener("mousedown",Cm)}removePortalEl(){this._portalEl&&(this._portalEl.removeEventListener("mousedown",Cm),at(this._portalEl),this._portalEl=null)}onChange=e=>{this.setState({value:e});const{onChange:t}=this.props;"function"==typeof t&&t(e)};onInputClick=e=>{e.preventDefault(),e.stopPropagation(),this.setOptionsVisible(!this.state.optionsVisible),this.focusInput()};onInput=e=>{const{value:t}=e.target;this.onChange(t)};onOptionClick=(e,t)=>{t.preventDefault(),t.stopPropagation(),this.setOptionsVisible(!1),this.onChange(e),this.focusInput()};focusInput(){const e=this.inputNode;e.focus(),"selectionStart"in e&&(e.selectionStart=1e5)}checkClose(e){!this._portalEl||this._portalEl.contains(e)||this.parentNode.contains(e)||this.setOptionsVisible(!1)}onFocusChanged=e=>{this.checkClose(e.target)};onGlobalClick=e=>{this.checkClose(e.target)};select(e){const{options:t}=this.props,{value:n}=this.state;if(!t)return;const i=t.filter(e=>e.value===n)[0],r=i?t.indexOf(i):-1,o=-1===r?1===e?0:t.length-1:(r+e)%t.length,s=t[o<0?t.length+o:o];this.onChange(s.value)}setOptionsVisible(e){this.setState({optionsVisible:e})}onKeyDown=e=>{const{optionsVisible:t}=this.state;var n=e.which;40!==n&&38!==n||(e.stopPropagation(),e.preventDefault(),t?this.select(40===n?1:-1):this.setOptionsVisible(!0)),t&&(13!==n&&27!==n||(e.stopPropagation(),e.preventDefault(),this.setOptionsVisible(!1)))};onKeyboard=e=>{const{optionsVisible:t}=this.state;if(t)return 27===e?(this.setOptionsVisible(!1),!0):void 0};renderOptions(e,t){const{label:n}=this.props,i=e=>ri(1,"div",["option",t===e?"active":""].join(" "),e.label,0,{role:"option","aria-selected":t===e,"data-value":e.value,onClick:t=>this.onOptionClick(e.value,t)});return ri(1,"div","options",function(e){const t=[];return e.forEach(e=>{const n=t[t.length-1];if(n&&Em(n.group)===Em(e.group))return n.options.push(e);t.push({group:e.group,options:[e]})}),t}(e).flatMap(({group:e,options:t})=>e&&e.name?ri(1,"div",null,[ri(1,"div","group-label",e.name,0,{"aria-hidden":"true"}),t.map(i)],0,{role:"group","aria-label":e.name}):t.map(i)),0,{role:"listbox","aria-label":n})}render(){const{className:e,label:t,id:n,options:i,noInput:r,title:o}=this.props,{optionsVisible:s,value:a}=this.state,l=!!i&&i.filter(e=>e.value===a)[0],c=l?l.label:a;return ri(1,"div",[e||"","dms-input-select"].join(" "),[r?ri(1,"div","dms-input",c,0,{"aria-label":t,tabIndex:"0",onKeyDown:this.onKeyDown},null,e=>this.inputNode=e):ri(64,"input","dms-input",null,1,{"aria-label":t,onInput:this.onInput,onKeyDown:this.onKeyDown,spellCheck:"false",type:"text",value:a,id:n},null,e=>this.inputNode=e),ri(1,"span",["dms-input-select-icon",s?"dmn-icon-up":"dmn-icon-down"].join(" ")),s&&(h=this.renderOptions(i,l),u=this._portalEl,ri(1024,u,null,h,0,null,Xn(h)?null:h.key,null))],0,{title:o,onClick:this.onInputClick},null,e=>this.parentNode=e);var h,u}}).$inject=["keyboard","renderer"];return class extends ht{_getViewProviders(){return[{id:"drd",constructor:ns,opens(e){return In(e,"dmn:Definitions")&&((t=e).dmnDI&&t.dmnDI.diagrams&&t.dmnDI.diagrams[0]);var t}},{id:"decisionTable",constructor:ka,opens:e=>In(e,"dmn:Decision")&&In(e.decisionLogic,"dmn:DecisionTable")},{id:"literalExpression",constructor:tl,opens:e=>In(e,"dmn:Decision")&&In(e.decisionLogic,"dmn:LiteralExpression")},{id:"boxedExpression",constructor:Tl,opens:e=>In(e,"dmn:BusinessKnowledgeModel")&&Vn(e)}]}}});