/*! dmn-js - 17.8.1 | generated for dokuwiki-plugin-bpmnio | SEE LICENSE IN LICENSE */ (()=>{var qD=Object.create;var Ky=Object.defineProperty;var VD=Object.getOwnPropertyDescriptor;var HD=Object.getOwnPropertyNames;var zD=Object.getPrototypeOf,WD=Object.prototype.hasOwnProperty;var UD=(n,e,t)=>e in n?Ky(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var Mw=(n,e)=>()=>{try{return e||n((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}};var QD=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of HD(e))!WD.call(n,r)&&r!==t&&Ky(n,r,{get:()=>e[r],enumerable:!(i=VD(e,r))||i.enumerable});return n};var Pw=(n,e,t)=>(t=n!=null?qD(zD(n)):{},QD(e||!n||!n.__esModule?Ky(t,"default",{value:n,enumerable:!0}):t,n));var M=(n,e,t)=>UD(n,typeof e!="symbol"?e+"":e,t);var hR=Mw((Qx,fR)=>{/*! https://mths.be/cssescape v1.5.1 by @mathias | MIT license */(function(n,e){typeof Qx=="object"?fR.exports=e(n):typeof define=="function"&&define.amd?define([],e.bind(n,n)):e(n)})(typeof window!="undefined"?window:Qx,function(n){if(n.CSS&&n.CSS.escape)return n.CSS.escape;var e=function(t){if(arguments.length==0)throw new TypeError("`CSS.escape` requires an argument.");for(var i=String(t),r=i.length,o=-1,s,a="",l=i.charCodeAt(0);++o=1&&s<=31||s==127||o==0&&s>=48&&s<=57||o==1&&s>=48&&s<=57&&l==45){a+="\\"+s.toString(16)+" ";continue}if(o==0&&r==1&&s==45){a+="\\"+i.charAt(o);continue}if(s>=128||s==45||s==95||s>=48&&s<=57||s>=65&&s<=90||s>=97&&s<=122){a+=i.charAt(o);continue}a+="\\"+i.charAt(o)}return a};return n.CSS||(n.CSS={}),n.CSS.escape=e,e})});var AR=Mw((zde,TR)=>{"use strict";/*! * escape-html * Copyright(c) 2012-2013 TJ Holowaychuk * Copyright(c) 2015 Andreas Lubbe * Copyright(c) 2015 Tiancheng "Timothy" Gu * MIT Licensed */var R5=/["'&<>]/;TR.exports=T5;function T5(n){var e=""+n,t=R5.exec(e);if(!t)return e;var i,r="",o=0,s=0;for(o=t.index;oe)}function ur(n,e,t={}){return e=Gy(e),k(n,function(i){let r=e(i)||"_",o=t[r];o||(o=t[r]=[]),o.push(i)}),t}function Bw(n,...e){n=Gy(n);let t={};return k(e,r=>ur(r,n,t)),Vt(t,function(r,o){return r[0]})}function Fn(n,e){e=Gy(e);let t=[];return k(n,function(i,r){let o=e(i,r),s={d:o,v:i};for(var a=0;ai.v)}function la(n){return function(e){return kt(n,function(t,i){return e[i]===t})}}function Gy(n){return ge(n)?n:e=>e[n]}function Xy(n){return ge(n)?n:e=>e===n}function GD(n){return n}function XD(n){return Number(n)}function Mi(n,e){let t,i,r,o;function s(f){let h=Date.now(),d=f?0:o+e-h;if(d>0)return a(d);n.apply(r,i),l()}function a(f){t=setTimeout(s,f)}function l(){t&&clearTimeout(t),t=o=i=r=void 0}function c(){t&&s(!0),l()}function u(...f){o=Date.now(),i=f,r=this,t||a(e)}return u.flush=c,u.cancel=l,u}function Nw(n,e){let t=!1;return function(...i){t||(n(...i),t=!0,setTimeout(()=>{t=!1},e))}}function at(n,e){return n.bind(e)}function T(n,...e){return Object.assign(n,...e)}function $w(n,e,t){let i=n;return k(e,function(r,o){if(typeof r!="number"&&typeof r!="string")throw new Error("illegal key type: "+typeof r+". Key should be of type number or string.");if(r==="constructor")throw new Error("illegal key: constructor");if(r==="__proto__")throw new Error("illegal key: __proto__");let s=e[o+1],a=i[r];Me(s)&&Yr(a)&&(a=i[r]=isNaN(+s)?{}:[]),Hu(s)?Hu(t)?delete i[r]:i[r]=t:i=a}),n}function hn(n,e){let t={},i=Object(n);return k(e,function(r){r in i&&(t[r]=n[r])}),t}function Uu(n,e){let t={},i=Object(n);return k(i,function(r,o){e.indexOf(o)===-1&&(t[o]=r)}),t}var Wd="__fn",jw=1e3,YD=Array.prototype.slice;function ut(){this._listeners={},this.on("diagram.destroy",1,this._destroy,this)}ut.prototype.on=function(n,e,t,i){if(n=F(n)?n:[n],ge(e)&&(i=t,t=e,e=jw),!se(e))throw new Error("priority must be a number");var r=t;i&&(r=at(t,i),r[Wd]=t[Wd]||t);var o=this;n.forEach(function(s){o._addListener(s,{priority:e,callback:r,next:null})})};ut.prototype.once=function(n,e,t,i){var r=this;if(ge(e)&&(i=t,t=e,e=jw),!se(e))throw new Error("priority must be a number");function o(){o.__isTomb=!0;var s=t.apply(i,arguments);return r.off(n,o),s}o[Wd]=t,this.on(n,e,o)};ut.prototype.off=function(n,e){n=F(n)?n:[n];var t=this;n.forEach(function(i){t._removeListener(i,e)})};ut.prototype.createEvent=function(n){var e=new Qu;return e.init(n),e};ut.prototype.fire=function(n,e){var t,i,r,o;if(o=YD.call(arguments),typeof n=="object"&&(e=n,n=e.type),!n)throw new Error("no event type specified");if(i=this._listeners[n],!!i){e instanceof Qu?t=e:t=this.createEvent(e),o[0]=t;var s=t.type;n!==s&&(t.type=n);try{r=this._invokeListeners(t,o,i)}finally{n!==s&&(t.type=s)}return r===void 0&&t.defaultPrevented&&(r=!1),r}};ut.prototype.handleError=function(n){return this.fire("error",{error:n})===!1};ut.prototype._destroy=function(){this._listeners={}};ut.prototype._invokeListeners=function(n,e,t){for(var i;t&&!n.cancelBubble;)i=this._invokeListener(n,e,t),t=t.next;return i};ut.prototype._invokeListener=function(n,e,t){var i;if(t.callback.__isTomb)return i;try{i=ZD(t.callback,e),i!==void 0&&(n.returnValue=i,n.stopPropagation()),i===!1&&n.preventDefault()}catch(r){if(!this.handleError(r))throw console.error("unhandled error in event listener",r),r}return i};ut.prototype._addListener=function(n,e){var t=this._getListeners(n),i;if(!t){this._setListeners(n,e);return}for(;t;){if(t.priority or , got "+n);return n=(r?r+":":"")+i,{name:n,prefix:r,localName:i}}function Cn(n){this.ns=n,this.name=n.name,this.allTypes=[],this.allTypesByName={},this.properties=[],this.propertiesByName={}}Cn.prototype.build=function(){return hn(this,["ns","name","allTypes","allTypesByName","properties","propertiesByName","bodyProperty","idProperty"])};Cn.prototype.addProperty=function(n,e,t){typeof e=="boolean"&&(t=e,e=void 0),this.addNamedProperty(n,t!==!1);var i=this.properties;e!==void 0?i.splice(e,0,n):i.push(n)};Cn.prototype.replaceProperty=function(n,e,t){var i=n.ns,r=this.properties,o=this.propertiesByName,s=n.name!==e.name;if(n.isId){if(!e.isId)throw new Error("property <"+e.ns.name+"> must be id property to refine <"+n.ns.name+">");this.setIdProperty(e,!1)}if(n.isBody){if(!e.isBody)throw new Error("property <"+e.ns.name+"> must be body property to refine <"+n.ns.name+">");this.setBodyProperty(e,!1)}var a=r.indexOf(n);if(a===-1)throw new Error("property <"+i.name+"> not found in property list");r.splice(a,1),this.addProperty(e,t?void 0:a,s),o[i.name]=o[i.localName]=e};Cn.prototype.redefineProperty=function(n,e,t){var i=n.ns.prefix,r=e.split("#"),o=Rt(r[0],i),s=Rt(r[1],o.prefix).name,a=this.propertiesByName[s];if(a)this.replaceProperty(a,n,t);else throw new Error("refined property <"+s+"> not found");delete n.redefines};Cn.prototype.addNamedProperty=function(n,e){var t=n.ns,i=this.propertiesByName;e&&(this.assertNotDefined(n,t.name),this.assertNotDefined(n,t.localName)),i[t.name]=i[t.localName]=n};Cn.prototype.removeNamedProperty=function(n){var e=n.ns,t=this.propertiesByName;delete t[e.name],delete t[e.localName]};Cn.prototype.setBodyProperty=function(n,e){if(e&&this.bodyProperty)throw new Error("body property defined multiple times (<"+this.bodyProperty.ns.name+">, <"+n.ns.name+">)");this.bodyProperty=n};Cn.prototype.setIdProperty=function(n,e){if(e&&this.idProperty)throw new Error("id property defined multiple times (<"+this.idProperty.ns.name+">, <"+n.ns.name+">)");this.idProperty=n};Cn.prototype.assertNotTrait=function(n){if((n.extends||[]).length)throw new Error(`cannot create <${n.name}> extending <${n.extends}>`)};Cn.prototype.assertNotDefined=function(n,e){var t=n.name,i=this.propertiesByName[t];if(i)throw new Error("property <"+t+"> already defined; override of <"+i.definedBy.ns.name+"#"+i.ns.name+"> by <"+n.definedBy.ns.name+"#"+n.ns.name+"> not allowed without redefines")};Cn.prototype.hasProperty=function(n){return this.propertiesByName[n]};Cn.prototype.addTrait=function(n,e){e&&this.assertNotTrait(n);var t=this.allTypesByName,i=this.allTypes,r=n.name;r in t||(k(n.properties,at(function(o){o=T({},o,{name:o.ns.localName,inherited:e}),Object.defineProperty(o,"definedBy",{value:n});var s=o.replaces,a=o.redefines;s||a?this.redefineProperty(o,s||a,s):(o.isBody&&this.setBodyProperty(o),o.isId&&this.setIdProperty(o),this.addProperty(o))},this)),i.push(n),t[r]=n)};function Jr(n,e){this.packageMap={},this.typeMap={},this.packages=[],this.properties=e,k(n,at(this.registerPackage,this))}Jr.prototype.getPackage=function(n){return this.packageMap[n]};Jr.prototype.getPackages=function(){return this.packages};Jr.prototype.registerPackage=function(n){n=T({},n);var e=this.packageMap;Fw(e,n,"prefix"),Fw(e,n,"uri"),k(n.types,at(function(t){this.registerType(t,n)},this)),e[n.uri]=e[n.prefix]=n,this.packages.push(n)};Jr.prototype.registerType=function(n,e){n=T({},n,{superClass:(n.superClass||[]).slice(),extends:(n.extends||[]).slice(),properties:(n.properties||[]).slice(),meta:T(n.meta||{})});var t=Rt(n.name,e.prefix),i=t.name,r={};k(n.properties,at(function(o){var s=Rt(o.name,t.prefix),a=s.name;Yy(o.type)||(o.type=Rt(o.type,s.prefix).name),T(o,{ns:s,name:a}),r[a]=o},this)),T(n,{ns:t,name:i,propertiesByName:r}),k(n.extends,at(function(o){var s=Rt(o,t.prefix),a=this.typeMap[s.name];a.traits=a.traits||[],a.traits.push(i)},this)),this.definePackage(n,e),this.typeMap[i]=n};Jr.prototype.mapTypes=function(n,e,t){var i=Yy(n.name)?{name:n.name}:this.typeMap[n.name],r=this;function o(l,c){var u=Rt(l,Yy(l)?"":n.prefix);r.mapTypes(u,e,c)}function s(l){return o(l,!0)}function a(l){return o(l,!1)}if(!i)throw new Error("unknown type <"+n.name+">");k(i.superClass,t?s:a),e(i,!t),k(i.traits,s)};Jr.prototype.getEffectiveDescriptor=function(n){var e=Rt(n),t=new Cn(e);this.mapTypes(e,function(r,o){t.addTrait(r,o)});var i=t.build();return this.definePackage(i,i.allTypes[i.allTypes.length-1].$pkg),i};Jr.prototype.definePackage=function(n,e){this.properties.define(n,"$pkg",{value:e})};function Fw(n,e,t){var i=e[t];if(i in n)throw new Error("package with "+t+" <"+i+"> already defined")}function es(n){this.model=n}es.prototype.set=function(n,e,t){if(!Ie(e)||!e.length)throw new TypeError("property name must be a non-empty string");var i=this.getProperty(n,e),r=i&&i.name;eI(t)?i?delete n[r]:delete n.$attrs[Zy(e)]:i?r in n?n[r]=t:Hw(n,i,t):n.$attrs[Zy(e)]=t};es.prototype.get=function(n,e){var t=this.getProperty(n,e);if(!t)return n.$attrs[Zy(e)];var i=t.name;return!n[i]&&t.isMany&&Hw(n,t,[]),n[i]};es.prototype.define=function(n,e,t){if(!t.writable){var i=t.value;t=T({},t,{get:function(){return i}}),delete t.value}Object.defineProperty(n,e,t)};es.prototype.defineDescriptor=function(n,e){this.define(n,"$descriptor",{value:e})};es.prototype.defineModel=function(n,e){this.define(n,"$model",{value:e})};es.prototype.getProperty=function(n,e){var t=this.model,i=t.getPropertyDescriptor(n,e);if(i)return i;if(e.includes(":"))return null;let r=t.config.strict;if(typeof r!="undefined"){let o=new TypeError(`unknown property <${e}> on <${n.$type}>`);if(r)throw o;typeof console!="undefined"&&console.warn(o)}return null};function eI(n){return typeof n=="undefined"}function Hw(n,e,t){Object.defineProperty(n,e.name,{enumerable:!e.isReference,writable:!0,value:t,configurable:!0})}function Zy(n){return n.replace(/^:/,"")}function dn(n,e={}){this.properties=new es(this),this.factory=new qw(this,this.properties),this.registry=new Jr(n,this.properties),this.typeCache={},this.config=e}dn.prototype.create=function(n,e){var t=this.getType(n);if(!t)throw new Error("unknown type <"+n+">");return new t(e)};dn.prototype.getType=function(n){var e=this.typeCache,t=Ie(n)?n:n.ns.name,i=e[t];return i||(n=this.registry.getEffectiveDescriptor(t),i=e[t]=this.factory.createType(n)),i};dn.prototype.createAny=function(n,e,t){var i=Rt(n),r={$type:n,$instanceOf:function(s){return s===this.$type},get:function(s){return this[s]},set:function(s,a){$w(this,[s],a)}},o={name:n,isGeneric:!0,ns:{prefix:i.prefix,localName:i.localName,uri:e}};return this.properties.defineDescriptor(r,o),this.properties.defineModel(r,this),this.properties.define(r,"get",{enumerable:!1,writable:!0}),this.properties.define(r,"set",{enumerable:!1,writable:!0}),this.properties.define(r,"$parent",{enumerable:!1,writable:!0}),this.properties.define(r,"$instanceOf",{enumerable:!1,writable:!0}),k(t,function(s,a){Pe(s)&&s.value!==void 0?r[s.name]=s.value:r[a]=s}),r};dn.prototype.getPackage=function(n){return this.registry.getPackage(n)};dn.prototype.getPackages=function(){return this.registry.getPackages()};dn.prototype.getElementDescriptor=function(n){return n.$descriptor};dn.prototype.hasType=function(n,e){e===void 0&&(e=n,n=this);var t=n.$model.getElementDescriptor(n);return e in t.allTypesByName};dn.prototype.getPropertyDescriptor=function(n,e){return this.getElementDescriptor(n).propertiesByName[e]};dn.prototype.getTypeDescriptor=function(n){return this.registry.typeMap[n]};var zw=String.fromCharCode,tI=Object.prototype.hasOwnProperty,nI=/&#(\d+);|&#x([0-9a-f]+);|&(\w+);/ig,Ku={amp:"&",apos:"'",gt:">",lt:"<",quot:'"'};Object.keys(Ku).forEach(function(n){Ku[n.toUpperCase()]=Ku[n]});function iI(n,e,t,i){return i?tI.call(Ku,i)?Ku[i]:"&"+i+";":zw(e||parseInt(t,16))}function ts(n){return n.length>3&&n.indexOf("&")!==-1?n.replace(nI,iI):n}var Ww="non-whitespace outside of root node";function ca(n){return new Error(n)}function Uw(n){return"missing namespace for prefix <"+n+">"}function Qd(n){return{get:n,enumerable:!0}}function rI(n){var e={},t;for(t in n)e[t]=n[t];return e}function tv(n){return n+"$uri"}function oI(n){var e={},t,i;for(t in n)i=n[t],e[i]=i,e[tv(i)]=t;return e}function Qw(){return{line:0,column:0}}function sI(n){throw n}function nv(n){if(!this)return new nv(n);var e=n&&n.proxy,t,i,r,o,s=sI,a,l,c,u,f=Qw,h=!1,d=!1,p=null,m=!1,g;function b(x){x instanceof Error||(x=ca(x)),p=x,s(x,f)}function _(x){a&&(x instanceof Error||(x=ca(x)),a(x,f))}this.on=function(x,C){if(typeof C!="function")throw ca("required args ");switch(x){case"openTag":i=C;break;case"text":t=C;break;case"closeTag":r=C;break;case"error":s=C;break;case"warn":a=C;break;case"cdata":o=C;break;case"attention":u=C;break;case"question":c=C;break;case"comment":l=C;break;default:throw ca("unsupported event: "+x)}return this},this.ns=function(x){if(typeof x=="undefined"&&(x={}),typeof x!="object")throw ca("required args ");var C={},E;for(E in x)C[E]=x[E];return d=!0,g=C,this},this.parse=function(x){if(typeof x!="string")throw ca("required args ");return p=null,v(x),f=Qw,m=!1,p},this.stop=function(){m=!0};function v(x){var C=d?[]:null,E=d?oI(g):null,S,w=[],R=0,A=!1,I=!1,D=0,N=0,W,Re,_e,ue,re,me,Ue,$e,Ct,Nt="",fn=0,ct;function Ti(){if(ct!==null)return ct;var fi,$n,jn,ar=d&&E.xmlns,lr=d&&h?[]:null,Je=fn,$t=Nt,Jo=$t.length,Tw,Xr,cr,Ai,Ae,aa={},Aw={},hi,oe,Oe;e:for(;Je8)){for((oe<65||oe>122||oe>90&&oe<97)&&oe!==95&&oe!==58&&(_("illegal first char attribute name"),hi=!0),Oe=Je+1;Oe96&&oe<123||oe>64&&oe<91||oe>47&&oe<59||oe===46||oe===45||oe===95)){if(oe===32||oe<14&&oe>8){_("missing attribute value"),Je=Oe;continue e}if(oe===61)break;_("illegal attribute name char"),hi=!0}if(Ae=$t.substring(Je,Oe),Ae==="xmlns:xmlns"&&(_("illegal declaration of xmlns"),hi=!0),oe=$t.charCodeAt(Oe+1),oe===34)Oe=$t.indexOf('"',Je=Oe+2),Oe===-1&&(Oe=$t.indexOf("'",Je),Oe!==-1&&(_("attribute value quote missmatch"),hi=!0));else if(oe===39)Oe=$t.indexOf("'",Je=Oe+2),Oe===-1&&(Oe=$t.indexOf('"',Je),Oe!==-1&&(_("attribute value quote missmatch"),hi=!0));else for(_("missing attribute value quotes"),hi=!0,Oe=Oe+1;Oe8));Oe++);for(Oe===-1&&(_("missing closing quotes"),Oe=Jo,hi=!0),hi||(cr=$t.substring(Je,Oe)),Je=Oe;Oe+18));Oe++)Je===Oe&&(_("illegal character after attribute end"),hi=!0);if(Je=Oe+1,hi)continue e;if(Ae in Aw){_("attribute <"+Ae+"> already defined");continue}if(Aw[Ae]=!0,!d){aa[Ae]=cr;continue}if(h){if(Xr=Ae==="xmlns"?"xmlns":Ae.charCodeAt(0)===120&&Ae.substr(0,6)==="xmlns:"?Ae.substr(6):null,Xr!==null){if(fi=ts(cr),$n=tv(Xr),Ai=g[fi],!Ai){if(Xr==="xmlns"||$n in E&&E[$n]!==fi)do Ai="ns"+R++;while(typeof E[Ai]!="undefined");else Ai=Xr;g[fi]=Ai}E[Xr]!==Ai&&(Tw||(E=rI(E),Tw=!0),E[Xr]=Ai,Xr==="xmlns"&&(E[tv(Ai)]=fi,ar=Ai),E[$n]=fi),aa[Ae]=cr;continue}lr.push(Ae,cr);continue}if(oe=Ae.indexOf(":"),oe===-1){aa[Ae]=cr;continue}if(!(jn=E[Ae.substring(0,oe)])){_(Uw(Ae.substring(0,oe)));continue}Ae=ar===jn?Ae.substr(oe+1):jn+Ae.substr(oe),aa[Ae]=cr}if(h)for(Je=0,Jo=lr.length;Je=ar&&(Je=fi.exec(x),!(!Je||(lr=Je[0].length+Je.index,lr>D)));)$n+=1,ar=lr;return D==-1?(jn=lr,$t=x.substring(N)):N===0?$t=x.substring(N,D):(jn=D-ar,$t=N==-1?x.substring(D):x.substring(D,N+1)),{data:$t,line:$n,column:jn}}for(f=Zo,e&&(Ct=Object.create({},{name:Qd(function(){return Ue}),originalName:Qd(function(){return $e}),attrs:Qd(Ti),ns:Qd(function(){return E})}));N!==-1;){if(x.charCodeAt(N)===60?D=N:D=x.indexOf("<",N),D===-1){if(w.length)return b("unexpected end of file");if(N===0)return b("missing start tag");N",D),N===-1)return b("unclosed cdata");if(o&&(o(x.substring(D+9,N),f),m))return;N+=3;continue}if(_e===45&&x.charCodeAt(D+3)===45){if(N=x.indexOf("-->",D),N===-1)return b("unclosed comment");if(l&&(l(x.substring(D+4,N),ts,f),m))return;N+=3;continue}}if(ue===63){if(N=x.indexOf("?>",D),N===-1)return b("unclosed question");if(c&&(c(x.substring(D,N+2),f),m))return;N+=2;continue}for(W=D+1;;W++){if(re=x.charCodeAt(W),isNaN(re))return N=-1,b("unclosed tag");if(re===34)_e=x.indexOf('"',W+1),W=_e!==-1?_e:W;else if(re===39)_e=x.indexOf("'",W+1),W=_e!==-1?_e:W;else if(re===62){N=W;break}}if(ue===33){if(u&&(u(x.substring(D,N+1),ts,f),m))return;N+=1;continue}if(ct={},ue===47){if(A=!1,I=!0,!w.length)return b("missing open tag");if(W=Ue=w.pop(),_e=D+2+W.length,x.substring(D+2,_e)!==W)return b("closing tag mismatch");for(;_e8&&ue<14))return b("close tag")}else{if(x.charCodeAt(N-1)===47?(W=Ue=x.substring(D+1,N-1),A=!0,I=!0):(W=Ue=x.substring(D+1,N),A=!0,I=!1),!(ue>96&&ue<123||ue>64&&ue<91||ue===95||ue===58))return b("illegal first char nodeName");for(_e=1,Re=W.length;_e96&&ue<123||ue>64&&ue<91||ue>47&&ue<59||ue===45||ue===95||ue==46)){if(ue===32||ue<14&&ue>8){Ue=W.substring(0,_e),ct=null;break}return b("invalid nodeName")}I||w.push(Ue)}if(d){if(S=E,A&&(I||C.push(S),ct===null&&(h=W.indexOf("xmlns",_e)!==-1)&&(fn=_e,Nt=W,Ti(),h=!1)),$e=Ue,ue=Ue.indexOf(":"),ue!==-1){if(me=E[Ue.substring(0,ue)],!me)return b("missing namespace on <"+$e+">");Ue=Ue.substr(ue+1)}else me=E.xmlns;me&&(Ue=me+":"+Ue)}if(A&&(fn=_e,Nt=W,i&&(e?i(Ct,ts,I,f):i(Ue,Ti,ts,I,f),m)))return;if(I){if(r&&(r(e?Ct:Ue,ts,A,f),m))return;d&&(A?E=S:E=C.pop())}N+=1}}}function Kw(n){return n.xml&&n.xml.tagAlias==="lowerCase"}var iv={xsi:"http://www.w3.org/2001/XMLSchema-instance",xml:"http://www.w3.org/XML/1998/namespace"},Gw="property";function Xw(n){return n.xml&&n.xml.serialize}function aI(n){let e=Xw(n);return e!==Gw&&(e||null)}function lI(n){return n.charAt(0).toUpperCase()+n.slice(1)}function Yw(n,e){return Kw(e)?n.prefix+":"+lI(n.localName):n.name}function cI(n,e){var t=n.name,i=n.localName,r=e&&e.xml&&e.xml.typePrefix;return r&&i.indexOf(r)===0?n.prefix+":"+i.slice(r.length):t}function uI(n,e,t){let i=Rt(n,e.xmlns),r=`${e[i.prefix]||i.prefix}:${i.localName}`,o=Rt(r);var s=t.getPackage(o.prefix);return cI(o,s)}function eo(n){return new Error(n)}function fr(n){return n.$descriptor}function fI(n){T(this,n),this.elementsById={},this.references=[],this.warnings=[],this.addReference=function(e){this.references.push(e)},this.addElement=function(e){if(!e)throw eo("expected element");var t=this.elementsById,i=fr(e),r=i.idProperty,o;if(r&&(o=e.get(r.name),o)){if(!/^([a-z][\w-.]*:)?[a-z_][\w-.]*$/i.test(o))throw new Error("illegal ID <"+o+">");if(t[o])throw eo("duplicate ID <"+o+">");t[o]=e}},this.addWarning=function(e){this.warnings.push(e)}}function Gu(){}Gu.prototype.handleEnd=function(){};Gu.prototype.handleText=function(){};Gu.prototype.handleNode=function(){};function rv(){}rv.prototype=Object.create(Gu.prototype);rv.prototype.handleNode=function(){return this};function fa(){}fa.prototype=Object.create(Gu.prototype);fa.prototype.handleText=function(n){this.body=(this.body||"")+n};function Xu(n,e){this.property=n,this.context=e}Xu.prototype=Object.create(fa.prototype);Xu.prototype.handleNode=function(n){if(this.element)throw eo("expected no sub nodes");return this.element=this.createReference(n),this};Xu.prototype.handleEnd=function(){this.element.id=this.body};Xu.prototype.createReference=function(n){return{property:this.property.ns.name,id:""}};function ov(n,e){this.element=e,this.propertyDesc=n}ov.prototype=Object.create(fa.prototype);ov.prototype.handleEnd=function(){var n=this.body||"",e=this.element,t=this.propertyDesc;n=Ud(t.type,n),t.isMany?e.get(t.name).push(n):e.set(t.name,n)};function Kd(){}Kd.prototype=Object.create(fa.prototype);Kd.prototype.handleNode=function(n){var e=this,t=this.element;return t?e=this.handleChild(n):(t=this.element=this.createElement(n),this.context.addElement(t)),e};function Ht(n,e,t){this.model=n,this.type=n.getType(e),this.context=t}Ht.prototype=Object.create(Kd.prototype);Ht.prototype.addReference=function(n){this.context.addReference(n)};Ht.prototype.handleText=function(n){var e=this.element,t=fr(e),i=t.bodyProperty;if(!i)throw eo("unexpected body text <"+n+">");fa.prototype.handleText.call(this,n)};Ht.prototype.handleEnd=function(){var n=this.body,e=this.element,t=fr(e),i=t.bodyProperty;i&&n!==void 0&&(n=Ud(i.type,n),e.set(i.name,n))};Ht.prototype.createElement=function(n){var e=n.attributes,t=this.type,i=fr(t),r=this.context,o=new t({}),s=this.model,a;return k(e,function(l,c){var u=i.propertiesByName[c],f;u&&u.isReference?u.isMany?(f=l.split(" "),k(f,function(h){r.addReference({element:o,property:u.ns.name,id:h})})):r.addReference({element:o,property:u.ns.name,id:l}):(u?l=Ud(u.type,l):c==="xmlns"?c=":"+c:(a=Rt(c,i.ns.prefix),s.getPackage(a.prefix)&&r.addWarning({message:"unknown attribute <"+c+">",element:o,property:c,value:l})),o.set(c,l))}),o};Ht.prototype.getPropertyForNode=function(n){var e=n.name,t=Rt(e),i=this.type,r=this.model,o=fr(i),s=t.name,a=o.propertiesByName[s];if(a&&!a.isAttr){let c=aI(a);if(c){let u=n.attributes[c];if(u){let f=uI(u,n.ns,r),h=r.getType(f);return T({},a,{effectiveType:fr(h).name})}}return a}var l=r.getPackage(t.prefix);if(l){let c=Yw(t,l),u=r.getType(c);if(a=ye(o.properties,function(f){return!f.isVirtual&&!f.isReference&&!f.isAttribute&&u.hasType(f.type)}),a)return T({},a,{effectiveType:fr(u).name})}else if(a=ye(o.properties,function(c){return!c.isReference&&!c.isAttribute&&c.type==="Element"}),a)return a;throw eo("unrecognized element <"+t.name+">")};Ht.prototype.toString=function(){return"ElementDescriptor["+fr(this.type).name+"]"};Ht.prototype.valueHandler=function(n,e){return new ov(n,e)};Ht.prototype.referenceHandler=function(n){return new Xu(n,this.context)};Ht.prototype.handler=function(n){return n==="Element"?new ua(this.model,n,this.context):new Ht(this.model,n,this.context)};Ht.prototype.handleChild=function(n){var e,t,i,r;if(e=this.getPropertyForNode(n),i=this.element,t=e.effectiveType||e.type,ev(t))return this.valueHandler(e,i);e.isReference?r=this.referenceHandler(e).handleNode(n):r=this.handler(t).handleNode(n);var o=r.element;return o!==void 0&&(e.isMany?i.get(e.name).push(o):i.set(e.name,o),e.isReference?(T(o,{element:i}),this.context.addReference(o)):o.$parent=i),r};function sv(n,e,t){Ht.call(this,n,e,t)}sv.prototype=Object.create(Ht.prototype);sv.prototype.createElement=function(n){var e=n.name,t=Rt(e),i=this.model,r=this.type,o=i.getPackage(t.prefix),s=o&&Yw(t,o)||e;if(!r.hasType(s))throw eo("unexpected element <"+n.originalName+">");return Ht.prototype.createElement.call(this,n)};function ua(n,e,t){this.model=n,this.context=t}ua.prototype=Object.create(Kd.prototype);ua.prototype.createElement=function(n){var e=n.name,t=Rt(e),i=t.prefix,r=n.ns[i+"$uri"],o=n.attributes;return this.model.createAny(e,r,o)};ua.prototype.handleChild=function(n){var e=new ua(this.model,"Element",this.context).handleNode(n),t=this.element,i=e.element,r;return i!==void 0&&(r=t.$children=t.$children||[],r.push(i),i.$parent=t),e};ua.prototype.handleEnd=function(){this.body&&(this.element.$body=this.body)};function Gd(n){n instanceof dn&&(n={model:n}),T(this,{lax:!1},n)}Gd.prototype.fromXML=function(n,e,t){var i=e.rootHandler;e instanceof Ht?(i=e,e={}):typeof e=="string"?(i=this.handler(e),e={}):typeof i=="string"&&(i=this.handler(i));var r=this.model,o=this.lax,s=new fI(T({},e,{rootHandler:i})),a=new nv({proxy:!0}),l=hI();i.context=s,l.push(i);function c(C,E,S){var w=E(),R=w.line,A=w.column,I=w.data;I.charAt(0)==="<"&&I.indexOf(" ")!==-1&&(I=I.slice(0,I.indexOf(" "))+">");var D="unparsable content "+(I?I+" ":"")+`detected line: `+R+` column: `+A+` nested error: `+C.message;if(S)return s.addWarning({message:D,error:C}),!0;throw eo(D)}function u(C,E){return c(C,E,!0)}function f(){var C=s.elementsById,E=s.references,S,w;for(S=0;w=E[S];S++){var R=w.element,A=C[w.id],I=fr(R).propertiesByName[w.property];if(A||s.addWarning({message:"unresolved reference <"+w.id+">",element:w.element,property:w.property,value:w.id}),I.isMany){var D=R.get(I.name),N=D.indexOf(w);N===-1&&(N=D.length),A?D[N]=A:D.splice(N,1)}else R.set(I.name,A)}}function h(){l.pop().handleEnd()}var d=/^<\?xml /i,p=/ encoding="([^"]+)"/i,m=/^utf-8$/i;function g(C){if(d.test(C)){var E=p.exec(C),S=E&&E[1];!S||m.test(S)||s.addWarning({message:"unsupported document encoding <"+S+">, falling back to UTF-8"})}}function b(C,E){var S=l.peek();try{l.push(S.handleNode(C))}catch(w){c(w,E,o)&&l.push(new rv)}}function _(C,E){try{l.peek().handleText(C)}catch(S){u(S,E)}}function v(C,E){C.trim()&&_(C,E)}var x=r.getPackages().reduce(function(C,E){return C[E.uri]=E.prefix,C},Object.entries(iv).reduce(function(C,[E,S]){return C[S]=E,C},r.config&&r.config.nsMap||{}));return a.ns(x).on("openTag",function(C,E,S,w){var R=C.attrs||{},A=Object.keys(R).reduce(function(D,N){var W=E(R[N]);return D[N]=W,D},{}),I={name:C.name,originalName:C.originalName,attributes:A,ns:C.ns};b(I,w)}).on("question",g).on("closeTag",h).on("cdata",_).on("text",function(C,E,S){v(E(C),S)}).on("error",c).on("warn",u),new Promise(function(C,E){var S;try{a.parse(n),f()}catch(D){S=D}var w=i.element;!S&&!w&&(S=eo("failed to parse document as <"+i.type.$descriptor.name+">"));var R=s.warnings,A=s.references,I=s.elementsById;return S?(S.warnings=R,E(S)):C({rootElement:w,elementsById:I,references:A,warnings:R})})};Gd.prototype.handler=function(n){return new sv(this.model,n)};function hI(){var n=[];return Object.defineProperty(n,"peek",{value:function(){return this[this.length-1]}}),n}var dI=` `,pI=/<|>|'|"|&|\n\r|\n/g,Zw=/<|>|&/g;function Pi(n){this.prefixMap={},this.uriMap={},this.used={},this.wellknown=[],this.custom=[],this.parent=n,this.defaultPrefixMap=n&&n.defaultPrefixMap||{}}Pi.prototype.mapDefaultPrefixes=function(n){this.defaultPrefixMap=n};Pi.prototype.defaultUriByPrefix=function(n){return this.defaultPrefixMap[n]};Pi.prototype.byUri=function(n){return this.uriMap[n]||this.parent&&this.parent.byUri(n)};Pi.prototype.add=function(n,e){this.uriMap[n.uri]=n,e?this.wellknown.push(n):this.custom.push(n),this.mapPrefix(n.prefix,n.uri)};Pi.prototype.uriByPrefix=function(n){return this.prefixMap[n||"xmlns"]||this.parent&&this.parent.uriByPrefix(n)};Pi.prototype.mapPrefix=function(n,e){this.prefixMap[n||"xmlns"]=e};Pi.prototype.getNSKey=function(n){return n.prefix!==void 0?n.uri+"|"+n.prefix:n.uri};Pi.prototype.logUsed=function(n){var e=n.uri,t=this.getNSKey(n);this.used[t]=this.byUri(e),this.parent&&this.parent.logUsed(n)};Pi.prototype.getUsed=function(n){var e=[].concat(this.wellknown,this.custom);return e.filter(t=>{var i=this.getNSKey(t);return this.used[i]})};function mI(n){return n.charAt(0).toLowerCase()+n.slice(1)}function gI(n,e){return Kw(e)?mI(n):n}function Jw(n,e){n.super_=e,n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}})}function e1(n){return Ie(n)?n:(n.prefix?n.prefix+":":"")+n.localName}function yI(n){return n.getUsed().filter(function(e){return e.prefix!=="xml"}).map(function(e){var t="xmlns"+(e.prefix?":"+e.prefix:"");return{name:t,value:e.uri}})}function vI(n,e){return e.isGeneric?T({localName:e.ns.localName},n):T({localName:gI(e.ns.localName,e.$pkg)},n)}function xI(n,e){return T({localName:e.ns.localName},n)}function bI(n){var e=n.$descriptor;return Ee(e.properties,function(t){var i=t.name;if(t.isVirtual||!Zr(n,i))return!1;var r=n[i];return r===t.default||r===null?!1:t.isMany?r.length:!0})}var _I={"\n":"#10","\n\r":"#10",'"':"#34","'":"#39","<":"#60",">":"#62","&":"#38"},wI={"<":"lt",">":"gt","&":"amp"};function t1(n,e,t){return n=Ie(n)?n:""+n,n.replace(e,function(i){return"&"+t[i]+";"})}function CI(n){return t1(n,pI,_I)}function EI(n){return t1(n,Zw,wI)}function SI(n){return Ee(n,function(e){return e.isAttr})}function OI(n){return Ee(n,function(e){return!e.isAttr})}function av(n){this.tagName=n}av.prototype.build=function(n){return this.element=n,this};av.prototype.serializeTo=function(n){n.appendIndent().append("<"+this.tagName+">"+this.element.id+"").appendNewLine()};function ns(){}ns.prototype.serializeValue=ns.prototype.serializeTo=function(n){n.append(this.escape?EI(this.value):this.value)};ns.prototype.build=function(n,e){return this.value=e,n.type==="String"&&e.search(Zw)!==-1&&(this.escape=!0),this};function lv(n){this.tagName=n}Jw(lv,ns);lv.prototype.serializeTo=function(n){n.appendIndent().append("<"+this.tagName+">"),this.serializeValue(n),n.append("").appendNewLine()};function je(n,e){this.body=[],this.attrs=[],this.parent=n,this.propertyDescriptor=e}je.prototype.build=function(n){this.element=n;var e=n.$descriptor,t=this.propertyDescriptor,i,r,o=e.isGeneric;return o?i=this.parseGenericNsAttributes(n):i=this.parseNsAttributes(n),t?this.ns=this.nsPropertyTagName(t):this.ns=this.nsTagName(e),this.tagName=this.addTagName(this.ns),o?this.parseGenericContainments(n):(r=bI(n),this.parseAttributes(SI(r)),this.parseContainments(OI(r))),this.parseGenericAttributes(n,i),this};je.prototype.nsTagName=function(n){var e=this.logNamespaceUsed(n.ns);return vI(e,n)};je.prototype.nsPropertyTagName=function(n){var e=this.logNamespaceUsed(n.ns);return xI(e,n)};je.prototype.isLocalNs=function(n){return n.uri===this.ns.uri};je.prototype.nsAttributeName=function(n){var e;if(Ie(n)?e=Rt(n):e=n.ns,n.inherited)return{localName:e.localName};var t=this.logNamespaceUsed(e);return this.getNamespaces().logUsed(t),this.isLocalNs(t)?{localName:e.localName}:T({localName:e.localName},t)};je.prototype.parseGenericNsAttributes=function(n){return Object.entries(n).filter(([e,t])=>!e.startsWith("$")&&this.parseNsAttribute(n,e,t)).map(([e,t])=>({name:e,value:t}))};je.prototype.parseGenericContainments=function(n){var e=n.$body;e&&this.body.push(new ns().build({type:"String"},e));var t=n.$children;t&&k(t,i=>{this.body.push(new je(this).build(i))})};je.prototype.parseNsAttribute=function(n,e,t){var i=n.$model,r=Rt(e),o;if(r.prefix==="xmlns"&&(o={prefix:r.localName,uri:t}),!r.prefix&&r.localName==="xmlns"&&(o={uri:t}),!o)return{name:e,value:t};if(i&&i.getPackage(t))this.logNamespace(o,!0,!0);else{var s=this.logNamespaceUsed(o,!0);this.getNamespaces().logUsed(s)}};je.prototype.parseNsAttributes=function(n){var e=this,t=n.$attrs,i=[];return k(t,function(r,o){var s=e.parseNsAttribute(n,o,r);s&&i.push(s)}),i};je.prototype.parseGenericAttributes=function(n,e){var t=this;k(e,function(i){try{t.addAttribute(t.nsAttributeName(i.name),i.value)}catch(r){typeof console!="undefined"&&console.warn(`missing namespace information for <${i.name}=${i.value}> on`,n,r)}})};je.prototype.parseContainments=function(n){var e=this,t=this.body,i=this.element;k(n,function(r){var o=i.get(r.name),s=r.isReference,a=r.isMany;if(a||(o=[o]),r.isBody)t.push(new ns().build(r,o[0]));else if(ev(r.type))k(o,function(c){t.push(new lv(e.addTagName(e.nsPropertyTagName(r))).build(r,c))});else if(s)k(o,function(c){t.push(new av(e.addTagName(e.nsPropertyTagName(r))).build(c))});else{var l=Xw(r);k(o,function(c){var u;l?l===Gw?u=new je(e,r):u=new Xd(e,r,l):u=new je(e),t.push(u.build(c))})}})};je.prototype.getNamespaces=function(n){var e=this.namespaces,t=this.parent,i;return e||(i=t&&t.getNamespaces(),n||!i?this.namespaces=e=new Pi(i):e=i),e};je.prototype.logNamespace=function(n,e,t){var i=this.getNamespaces(t),r=n.uri,o=n.prefix,s=i.byUri(r);return(!s||t)&&i.add(n,e),i.mapPrefix(o,r),n};je.prototype.logNamespaceUsed=function(n,e){var t=this.getNamespaces(e),i=n.prefix,r=n.uri,o,s,a;if(!i&&!r)return{localName:n.localName};if(a=t.defaultUriByPrefix(i),r=r||a||t.uriByPrefix(i),!r)throw new Error("no namespace uri given for prefix <"+i+">");if(n=t.byUri(r),!n&&!i&&(n=this.logNamespace({uri:r},a===r,!0)),!n){for(o=i,s=1;t.uriByPrefix(o);)o=i+"_"+s++;n=this.logNamespace({prefix:o,uri:r},a===r)}return i&&t.mapPrefix(i,r),n};je.prototype.parseAttributes=function(n){var e=this,t=this.element;k(n,function(i){var r=t.get(i.name);if(i.isReference)if(!i.isMany)r=r.id;else{var o=[];k(r,function(s){o.push(s.id)}),r=o.join(" ")}e.addAttribute(e.nsAttributeName(i),r)})};je.prototype.addTagName=function(n){var e=this.logNamespaceUsed(n);return this.getNamespaces().logUsed(e),e1(n)};je.prototype.addAttribute=function(n,e){var t=this.attrs;Ie(e)&&(e=CI(e));var i=Iw(t,function(o){return o.name.localName===n.localName&&o.name.uri===n.uri&&o.name.prefix===n.prefix}),r={name:n,value:e};i!==-1?t.splice(i,1,r):t.push(r)};je.prototype.serializeAttributes=function(n){var e=this.attrs,t=this.namespaces;t&&(e=yI(t).concat(e)),k(e,function(i){n.append(" ").append(e1(i.name)).append('="').append(i.value).append('"')})};je.prototype.serializeTo=function(n){var e=this.body[0],t=e&&e.constructor!==ns;n.appendIndent().append("<"+this.tagName),this.serializeAttributes(n),n.append(e?">":" />"),e&&(t&&n.appendNewLine().indent(),k(this.body,function(i){i.serializeTo(n)}),t&&n.unindent().appendIndent(),n.append("")),n.appendNewLine()};function Xd(n,e,t){je.call(this,n,e),this.serialization=t}Jw(Xd,je);Xd.prototype.parseNsAttributes=function(n){var e=je.prototype.parseNsAttributes.call(this,n).filter(s=>s.name!==this.serialization),t=n.$descriptor;if(t.name===this.propertyDescriptor.type)return e;var i=this.typeNs=this.nsTagName(t);this.getNamespaces().logUsed(this.typeNs);var r=n.$model.getPackage(i.uri),o=r.xml&&r.xml.typePrefix||"";return this.addAttribute(this.nsAttributeName(this.serialization),(i.prefix?i.prefix+":":"")+o+t.ns.localName),e};Xd.prototype.isLocalNs=function(n){return n.uri===(this.typeNs||this.ns).uri};function kI(){this.value="",this.write=function(n){this.value+=n}}function RI(n,e){var t=[""];this.append=function(i){return n.write(i),this},this.appendNewLine=function(){return e&&n.write(` `),this},this.appendIndent=function(){return e&&n.write(t.join(" ")),this},this.indent=function(){return t.push(""),this},this.unindent=function(){return t.pop(),this}}function n1(n){n=T({format:!1,preamble:!0},n||{});function e(t,i){var r=i||new kI,o=new RI(r,n.format);n.preamble&&o.append(dI);var s=new je,a=t.$model;if(s.getNamespaces().mapDefaultPrefixes(TI(a)),s.build(t).serializeTo(o),!i)return r.value}return{toXML:e}}function TI(n){let e=n.config&&n.config.nsMap||{},t={};for(let i in iv)t[i]=iv[i];for(let i in e){let r=e[i];t[r]=i}for(let i of n.getPackages())t[i.prefix]=i.uri;return t}function Yd(n,e){dn.call(this,n,e)}Yd.prototype=Object.create(dn.prototype);Yd.prototype.fromXML=function(n,e,t){Ie(e)||(t=e,e="dmn:Definitions");var i=new Gd(T({model:this,lax:!0},t)),r=i.handler(e);return i.fromXML(n,r)};Yd.prototype.toXML=function(n,e){var t=new n1(e);return new Promise(function(i,r){try{var o=t.toXML(n);return i({xml:o})}catch(s){return r(s)}})};var AI="DC",MI="dc",PI="http://www.omg.org/spec/DMN/20180521/DC/",DI=[{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"}]}],II=[],LI=[{name:"AlignmentKind",literalValues:[{name:"start"},{name:"center"},{name:"end"}]}],BI={name:AI,prefix:MI,uri:PI,types:DI,associations:II,enumerations:LI},NI="DI",$I="di",jI="http://www.omg.org/spec/DMN/20180521/DI/",FI=[{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"}]}],qI=[],VI=[],HI={tagAlias:"lowerCase"},zI={name:NI,prefix:$I,uri:jI,types:FI,associations:qI,enumerations:VI,xml:HI},WI="DMN",UI="dmn",QI="https://www.omg.org/spec/DMN/20191111/MODEL/",KI=[{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"}]}],GI=[{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"}]}],XI=[],YI={tagAlias:"lowerCase"},ZI={name:WI,prefix:UI,uri:QI,types:KI,enumerations:GI,associations:XI,xml:YI},JI="DMNDI",eL="dmndi",tL="https://www.omg.org/spec/DMN/20191111/DMNDI/",nL=[{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"]}],iL=[],rL=[],oL={name:JI,prefix:eL,uri:tL,types:nL,associations:iL,enumerations:rL},sL="bpmn.io DI for DMN",aL="http://bpmn.io/schema/dmn/biodi/2.0",lL="biodi",cL={tagAlias:"lowerCase"},uL=[{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"}]}],fL={name:sL,uri:aL,prefix:lL,xml:cL,types:uL},hL={dc:BI,di:zI,dmn:ZI,dmndi:oL,biodi:fL};function i1(n,e){var t=T({},hL,n);return new Yd(t,e)}var yt={legend:[1,"
","
"],tr:[2,"","
"],col:[2,"","
"],_default:[0,"",""]};yt.td=yt.th=[3,"","
"];yt.option=yt.optgroup=[1,'"];yt.thead=yt.tbody=yt.colgroup=yt.caption=yt.tfoot=[1,"","
"];yt.polyline=yt.ellipse=yt.polygon=yt.circle=yt.text=yt.line=yt.path=yt.rect=yt.g=[1,'',""];function te(n,e=globalThis.document){var c;if(typeof n!="string")throw new TypeError("String expected");let t=/^$/s.exec(n);if(t)return e.createComment(t[1]);let i=(c=/<([\w:]+)/.exec(n))==null?void 0:c[1];if(!i)return e.createTextNode(n);if(n=n.trim(),i==="body"){let u=e.createElement("html");u.innerHTML=n;let{lastChild:f}=u;return f.remove(),f}let[r,o,s]=Object.hasOwn(yt,i)?yt[i]:yt._default,a=e.createElement("div");for(a.innerHTML=o+n+s;r--;)a=a.lastChild;if(a.firstChild===a.lastChild){let{firstChild:u}=a;return u.remove(),u}let l=e.createDocumentFragment();return l.append(...a.childNodes),l}function dL(n,e){return e.forEach(function(t){t&&typeof t!="string"&&!Array.isArray(t)&&Object.keys(t).forEach(function(i){if(i!=="default"&&!(i in n)){var r=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(n,i,r.get?r:{enumerable:!0,get:function(){return t[i]}})}})}),Object.freeze(n)}function is(n,...e){let t=n.style;return k(e,function(i){i&&k(i,function(r,o){t[o]=r})}),n}function et(n,e,t){return arguments.length==2?n.getAttribute(e):t===null?n.removeAttribute(e):(n.setAttribute(e,t),n)}var pL=Object.prototype.toString;function ee(n){return new to(n)}function to(n){if(!n||!n.nodeType)throw new Error("A DOM element reference is required");this.el=n,this.list=n.classList}to.prototype.add=function(n){return this.list.add(n),this};to.prototype.remove=function(n){return pL.call(n)=="[object RegExp]"?this.removeMatching(n):(this.list.remove(n),this)};to.prototype.removeMatching=function(n){let e=this.array();for(let t=0;t=1&&ge(arguments[e-1])){var t=arguments[e-1];console.warn(new Error("Passing callbacks to "+bL(n.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);n.apply(this,i).then(function(r){var o=Object.keys(r)[0];return t(null,r[o])},function(r){return t(r,r.warnings)})}else return n.apply(this,arguments)}}function bL(n){return n.replace("bound ","")}var _L={width:"100%",height:"100%",position:"relative"},rs=class{constructor(e={}){M(this,"_viewsChanged",()=>{this._emit("views.changed",{views:this._views,activeView:this._activeView})});this._eventBus=new ut,this._viewsChanged=Mi(this._viewsChanged,0),this._views=[],this._viewers={},this.open=ha(this.open.bind(this)),this.importXML=ha(this.importXML.bind(this)),this.saveXML=ha(this.saveXML.bind(this)),this._init(e)}importXML(e,t){var i=this;return t=t||{open:!0},new Promise(function(o,s){var a=i._activeView;i._clear().then(()=>{e=i._emit("import.parse.start",{xml:e})||e;var l;i._moddle.fromXML(e,"dmn:Definitions").then(c=>{var u=c.rootElement,f=c.references,h=c.elementsById;if(l=c.warnings,u=i._emit("import.parse.complete",r({error:null,definitions:u,elementsById:h,references:f,warnings:l}))||u,i._setDefinitions(u),!t.open){i._emit("import.done",{error:null,warnings:l}),o({warnings:l});return}var d=i._getInitialView(i._views,a);if(!d){var p=new Error("no displayable contents");return i._emit("import.done",{error:p,warnings:l}),p.warnings=l,s(p)}i.open(d).then(m=>({warnings:m.warnings})).catch(m=>({error:m,warnings:m.warnings})).then(m=>{var g=[].concat(l,m.warnings);i._emit("import.done",{error:m.error,warnings:g}),m.error?(m.error.warnings=g,s(m.error)):o({warnings:g})})}).catch(c=>(l=c.warnings,c=wL(c,e)||CL(c)||c,i._emit("import.parse.complete",r({error:c,warnings:l})),i._emit("import.done",{error:c,warnings:l}),c.warnings=l,s(c)))}).catch(l=>(i._emit("import.done",{error:l,warnings:[]}),l.warnings=[],s(l)))});function r(o){var s=i._eventBus.createEvent(o);return Object.defineProperty(s,"context",{enumerable:!0,get:function(){return console.warn(new Error("import.parse.complete is deprecated and will be removed in future library versions")),{warnings:o.warnings,references:o.references,elementsById:o.elementsById}}}),s}}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 i=this._definitions;return new Promise(function(r,o){if(!i){o(new Error("no definitions loaded"));return}i=t._emit("saveXML.start",{definitions:i})||i,t._moddle.toXML(i,e).then(function(s){var a=s.xml;return a=t._emit("saveXML.serialized",{xml:a})||a,{xml:a}}).catch(s=>({error:s})).then(s=>{t._emit("saveXML.done",s),s.error?o(s.error):r({xml:s.xml})})})}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)),typeof e=="string"&&(e=X(e)),e.appendChild(this._container),this._emit("attach",{})}detach(){this._emit("detach",{}),Qe(this._container)}destroy(){Object.keys(this._viewers).forEach(e=>{var t=this._viewers[e];c1(t,"destroy")}),Qe(this._container)}_init(e){this._options=e,this._moddle=this._createModdle(e),this._viewers={},this._views=[];let t=te('
'),i=T({},_L,e);T(t.style,{width:a1(i.width),height:a1(i.height),position:i.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()}_updateViews(){var e=this._definitions;if(!e){this._views=[],this._switchView(null);return}var t=this._getViewProviders(),i=[e,...e.drgElement||[]],r=this._views,o=[];for(var s of i){var a=ye(t,function(d){return typeof d.opens=="string"?d.opens===s.$type:d.opens(s)});if(a){var l={element:s,id:s.id,name:s.name,type:a.id};o.push(l)}}var c=this._activeView,u;if(c&&(u=ye(o,function(d){return Jd(c,d)})||this._getInitialView(o),!u)){this._switchView(null);return}var f=!Jd(c,u)||l1(c,u),h=r.length!==o.length||!kt(o,function(d){return ye(r,function(p){return Jd(p,d)&&!l1(p,d)})});this._activeView=u,this._views=o,(f||h)&&this._viewsChanged()}_getInitialView(e,t){var i;return t&&(i=ye(e,function(r){return Jd(r,t)})||ye(e,function(r){return r.type===t})),i||e[0]}_switchView(e){var t=this;return new Promise(function(i,r){var o=(u,f)=>{t._viewsChanged(),u?r(u):i(f)},s=t.getActiveView(),a,l=e&&t._getViewer(e),c=e&&e.element;if(s&&(a=t._getViewer(s),a!==l&&(c1(a,"clear"),a.detach())),t._activeView=e,l){a!==l&&l.attachTo(t._container),t._emit("import.render.start",{view:e,element:c}),l.open(c).then(u=>{t._emit("import.render.complete",{view:e,error:null,warnings:u.warnings}),o(null,u)}).catch(u=>{t._emit("import.render.complete",{view:e,error:u,warnings:u.warnings}),o(u,null)});return}o()})}_getViewer(e){var t=e.type,i=this._viewers[t];return i||(i=this._viewers[t]=this._createViewer(e.type),this._emit("viewer.created",{type:t,viewer:i})),i}_createViewer(e){var t=ye(this._getViewProviders(),function(s){return s.id===e});if(!t)throw new Error("no provider for view type <"+e+">");var i=t.constructor,r=this._options[e]||{},o=this._options.common||{};return new i({...o,...r,additionalModules:[...r.additionalModules||[],{_parent:["value",this],moddle:["value",this._moddle]}]})}_emit(...e){return this._eventBus.fire(...e)}_createModdle(e){return new i1(e.moddleExtensions)}_getViewProviders(){return[]}};function a1(n){return n+(se(n)?"px":"")}function wL(n,e){if(n.message!=="failed to parse document as ")return null;var t=e.indexOf('"http://www.omg.org/spec/DMN/20151101/dmn.xsd"')!==-1&&"1.1"||e.indexOf('"http://www.omg.org/spec/DMN/20180521/MODEL/"')!==-1&&"1.2";return t?(n=new Error("unsupported DMN "+t+" file detected; only DMN 1.3 files can be opened"),console.error("Cannot open what looks like a DMN "+t+" diagram. Please refer to https://bpmn.io/l/dmn-compatibility.html to learn how to make the toolkit compatible with older DMN files",n),n):null}function CL(n){var e=/unparsable content <([^>]+)> detected([\s\S]*)$/,t=e.exec(n.message);return t?(n.message="unparsable content <"+t[1]+"> detected; this may indicate an invalid DMN 1.3 diagram file"+t[2],n):null}function Jd(n,e){return Me(n)?Me(e)?n.element===e.element||n.id===e.id:!1:!Me(e)}function l1(n,e){return!n||!e||n.name!==e.name}function c1(n,e){ge(n[e])&&n[e]()}function EL(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var cv={exports:{}},u1;function SL(){if(u1)return cv.exports;u1=1;var n=cv.exports=function(e,t){if(t||(t=16),e===void 0&&(e=128),e<=0)return"0";for(var i=Math.log(Math.pow(2,e))/Math.log(t),r=2;i===1/0;r*=2)i=Math.log(Math.pow(2,e/r))/Math.log(t)*r;for(var o=i-Math.floor(i),s="",r=0;r=Math.pow(2,e)?n(e,t):s};return n.rack=function(e,t,i){var r=function(s){var a=0;do{if(a++>10)if(i)e+=i;else throw new Error("too many ID collisions, use more bits");var l=n(e,t)}while(Object.hasOwnProperty.call(o,l));return o[l]=s,l},o=r.hats={};return r.get=function(s){return r.hats[s]},r.set=function(s,a){return r.hats[s]=a,r},r.bits=e||128,r.base=t||16,r},cv.exports}var OL=SL(),kL=EL(OL);function qn(n){if(!(this instanceof qn))return new qn(n);n=n||[128,36,1],this._seed=n.length?kL.rack(n[0],n[1],n[2]):n}qn.prototype.next=function(n){return this._seed(n||!0)};qn.prototype.nextPrefixed=function(n,e){var t;do t=n+this.next(!0);while(this.assigned(t));return this.claim(t,e),t};qn.prototype.claim=function(n,e){this._seed.set(n,e||!0)};qn.prototype.assigned=function(n){return this._seed.get(n)||!1};qn.prototype.unclaim=function(n){delete this._seed.hats[n]};qn.prototype.clear=function(){var n=this._seed.hats,e;for(e in n)this.unclaim(e)};function O(n,e){var t=Ke(n);return t&&typeof t.$instanceOf=="function"&&t.$instanceOf(e)}function ie(n){return O(n,"dmn:InputClause")}function Te(n){return O(n,"dmn:OutputClause")}function Ke(n){return n&&n.businessObject||n}function f1(n){return Ke(n).name}function Ge(n,e){return zd(e,function(t){return O(n,t)})}function dr(n){var e=Ke(n);if(O(e,"dmn:Decision"))return e.get("decisionLogic");if(O(e,"dmn:BusinessKnowledgeModel")){var t=e.get("encapsulatedLogic");return t&&t.get("body")}}var RL="https://www.omg.org/spec/DMN/20191111/FEEL/";function h1(n){for(let e=n;e;e=e.$parent){let t=e.get("expressionLanguage");if(t)return!!(t===RL||/feel/i.test(t));if(O(e,"dmn:FunctionDefinition"))return(e.get("kind")||"FEEL")==="FEEL"}return!0}var Yu=class extends rs{_init(e){super._init(e),this.on("import.parse.complete",t=>{t.error||this._collectIds(t.definitions,t.elementsById)}),this.on("destroy",()=>{this._moddle.ids.clear()}),this.on("viewer.created",({viewer:t})=>{t.on("elements.changed",({elements:i})=>{var r=i.some(function(o){return Ge(o,["dmn:Decision","dmn:Definitions","dmn:BusinessKnowledgeModel"])});r&&this._updateViews()})})}_collectIds(e,t){var i=e.$model,r=i.ids,o;r.clear();for(o in t)r.claim(o,t[o])}_createModdle(e){var t=super._createModdle(e);return t.ids=new qn([32,36,1]),t}};function fe(n,e){e&&(n.super_=e,n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}))}var TL=/^class[ {]/;function AL(n){return TL.test(n.toString())}function fv(n){return Array.isArray(n)}function uv(n,e){return Object.prototype.hasOwnProperty.call(n,e)}function ep(...n){n.length===1&&fv(n[0])&&(n=n[0]),n=[...n];let e=n.pop();return e.$inject=n,e}var ML=/constructor\s*[^(]*\(\s*([^)]*)\)/m,PL=/^(?:async\s+)?(?:function\s*[^(]*)?(?:\(\s*([^)]*)\)|(\w+))/m,DL=/\/\*([^*]*)\*\//m;function IL(n){if(typeof n!="function")throw new Error(`Cannot annotate "${n}". Expected a function!`);let e=n.toString().match(AL(n)?ML:PL);if(!e)return[];let t=e[1]||e[2];return t&&t.split(",").map(i=>{let r=i.match(DL);return(r&&r[1]||i).trim()})||[]}function os(n,e){let t=e||{get:function(v,x){if(i.push(v),x===!1)return null;throw a(`No provider for "${v}"!`)}},i=[],r=this._providers=Object.create(t._providers||null),o=this._instances=Object.create(null),s=o.injector=this,a=function(v){let x=i.join(" -> ");return i.length=0,new Error(x?`${v} (Resolving: ${x})`:v)};function l(v,x){if(!r[v]&&v.includes(".")){let C=v.split("."),E=l(C.shift());for(;C.length;)E=E[C.shift()];return E}if(uv(o,v))return o[v];if(uv(r,v)){if(i.indexOf(v)!==-1)throw i.push(v),a("Cannot resolve circular dependency!");return i.push(v),o[v]=r[v][0](r[v][1]),i.pop(),o[v]}return t.get(v,x)}function c(v,x){if(typeof x=="undefined"&&(x={}),typeof v!="function")if(fv(v))v=ep(v.slice());else throw a(`Cannot invoke "${v}". Expected a function!`);let E=(v.$inject||IL(v)).map(S=>uv(x,S)?x[S]:l(S));return{fn:v,dependencies:E}}function u(v){let{fn:x,dependencies:C}=c(v),E=Function.prototype.bind.call(x,null,...C);return new E}function f(v,x,C){let{fn:E,dependencies:S}=c(v,C);return E.apply(x,S)}function h(v){return ep(x=>v.get(x))}function d(v,x){if(x&&x.length){let C=Object.create(null),E=Object.create(null),S=[],w=[],R=[],A,I,D,N;for(let W in r)A=r[W],x.indexOf(W)!==-1&&(A[2]==="private"?(I=S.indexOf(A[3]),I===-1?(D=A[3].createChild([],x),N=h(D),S.push(A[3]),w.push(D),R.push(N),C[W]=[N,W,"private",D]):C[W]=[R[I],W,"private",w[I]]):C[W]=[A[2],A[1]],E[W]=!0),(A[2]==="factory"||A[2]==="type")&&A[1].$scope&&x.forEach(Re=>{A[1].$scope.indexOf(Re)!==-1&&(C[W]=[A[2],A[1]],E[Re]=!0)});x.forEach(W=>{if(!E[W])throw new Error('No provider for "'+W+'". Cannot use provider from the parent!')}),v.unshift(C)}return new os(v,s)}let p={factory:f,type:u,value:function(v){return v}};function m(v,x){let C=v.__init__||[];return function(){C.forEach(E=>{typeof E=="string"?x.get(E):x.invoke(E)})}}function g(v){let x=v.__exports__;if(x){let C=v.__modules__,E=Object.keys(v).reduce((I,D)=>(D!=="__exports__"&&D!=="__modules__"&&D!=="__init__"&&D!=="__depends__"&&(I[D]=v[D]),I),Object.create(null)),S=(C||[]).concat(E),w=d(S),R=ep(function(I){return w.get(I)});x.forEach(function(I){r[I]=[R,I,"private",w]});let A=(v.__init__||[]).slice();return A.unshift(function(){w.init()}),v=Object.assign({},v,{__init__:A}),m(v,w)}return Object.keys(v).forEach(function(C){if(C==="__init__"||C==="__depends__")return;let E=v[C];if(E[2]==="private"){r[C]=E;return}let S=E[0],w=E[1];r[C]=[p[S],LL(S,w),S]}),m(v,s)}function b(v,x){return v.indexOf(x)!==-1||(v=(x.__depends__||[]).reduce(b,v),v.indexOf(x)!==-1)?v:v.concat(x)}function _(v){let x=v.reduce(b,[]).map(g),C=!1;return function(){C||(C=!0,x.forEach(E=>E()))}}this.get=l,this.invoke=f,this.instantiate=u,this.createChild=d,this.init=_(n)}function LL(n,e){return n!=="value"&&fv(e)&&(e=ep(e.slice())),e}var BL=1e3;function mn(n,e){var t=this;e=e||BL,n.on(["render.shape","render.connection"],e,function(i,r){var o=i.type,s=r.element,a=r.gfx,l=r.attrs;if(t.canRender(s))return o==="render.shape"?t.drawShape(a,s,l):t.drawConnection(a,s,l)}),n.on(["render.getShapePath","render.getConnectionPath"],e,function(i,r){if(t.canRender(r))return i.type==="render.getShapePath"?t.getShapePath(r):t.getConnectionPath(r)})}mn.prototype.canRender=function(n){};mn.prototype.drawShape=function(n,e){};mn.prototype.drawConnection=function(n,e){};mn.prototype.getShapePath=function(n){};mn.prototype.getConnectionPath=function(n){};function NL(n,e){if(n.ownerDocument!==e.ownerDocument)try{return e.ownerDocument.importNode(n,!0)}catch{}return n}function g1(n,e){return e.appendChild(NL(n,e))}function K(n,e){return g1(e,n),n}var pv=2,y1={"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":pv,"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":pv,"text-anchor":1,"text-decoration":1,"text-rendering":1,"unicode-bidi":1,visibility:1,"word-spacing":1,"writing-mode":1};function $L(n,e){return y1[e]?n.style[e]:n.getAttributeNS(null,e)}function v1(n,e,t){var i=e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),r=y1[i];r?(r===pv&&typeof t=="number"&&(t=String(t)+"px"),n.style[i]=t):n.setAttributeNS(null,e,t)}function jL(n,e){var t=Object.keys(e),i,r;for(i=0,r;r=t[i];i++)v1(n,r,e[r])}function j(n,e,t){if(typeof e=="string")if(t!==void 0)v1(n,e,t);else return $L(n,e);else jL(n,e);return n}var FL=Object.prototype.toString;function ne(n){return new io(n)}function io(n){if(!n||!n.nodeType)throw new Error("A DOM element reference is required");this.el=n,this.list=n.classList}io.prototype.add=function(n){return this.list.add(n),this};io.prototype.remove=function(n){return FL.call(n)=="[object RegExp]"?this.removeMatching(n):(this.list.remove(n),this)};io.prototype.removeMatching=function(n){let e=this.array();for(let t=0;t"+n+"",e=!0);var t=qL(n);if(!e)return t;for(var i=document.createDocumentFragment(),r=t.firstChild;r.firstChild;)i.appendChild(r.firstChild);return i}function qL(n){var e;return e=new DOMParser,e.async=!1,e.parseFromString(n,"text/xml")}function Q(n,e){var t;return n=n.trim(),n.charAt(0)==="<"?(t=x1(n).firstChild,t=document.importNode(t,!0)):t=document.createElementNS(yv.svg,n),e&&j(t,e),t}var hv=null;function mv(){return hv===null&&(hv=Q("svg")),hv}function p1(n,e){var t,i,r=Object.keys(e);for(t=0;i=r[t];t++)n[i]=e[i];return n}function b1(n,e,t,i,r,o){var s=mv().createSVGMatrix();switch(arguments.length){case 0:return s;case 1:return p1(s,n);case 6:return p1(s,{a:n,b:e,c:t,d:i,e:r,f:o})}}function da(n){return n?mv().createSVGTransformFromMatrix(n):mv().createSVGTransform()}var m1=/([&<>]{1})/g,VL=/([&<>\n\r"]{1})/g,HL={"&":"&","<":"<",">":">",'"':"'"};function dv(n,e){function t(i,r){return HL[r]||r}return n.replace(e,t)}function _1(n,e){var t,i,r,o,s;switch(n.nodeType){case 3:e.push(dv(n.textContent,m1));break;case 1:if(e.push("<",n.tagName),n.hasAttributes())for(r=n.attributes,t=0,i=r.length;t"),s=n.childNodes,t=0,i=s.length;t")}else e.push("/>");break;case 8:e.push("");break;case 4:e.push("");break;default:throw new Error("unable to handle node "+n.nodeType)}return e}function zL(n,e){var t=x1(e);if(ss(n),!!e){UL(t)||(t=t.documentElement);for(var i=QL(t.childNodes),r=0;rr||r===void 0)&&(r=l+f),(c+u>o||o===void 0)&&(o=c+u)}),{x:t,y:i,height:o-i,width:r-t}}function wv(n,e){var t={};return k(n,function(i){var r=i;r.waypoints&&(r=Tt(r)),!se(e.y)&&r.x>e.x&&(t[i.id]=i),!se(e.x)&&r.y>e.y&&(t[i.id]=i),r.x>e.x&&r.y>e.y&&(se(e.width)&&se(e.height)&&r.width+r.x=1e3&&delete r[o.shift()],o.push(i),r[i]=n(...arguments),r[i])}return e}function cB(n){if(!n)return null;var e={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},t=[];return String(n).replace(rB,function(i,r,o){var s=[],a=r.toLowerCase();for(o.replace(oB,function(l,c){c&&s.push(+c)}),a=="m"&&s.length>2&&(t.push([r,...s.splice(0,2)]),a="l",r=r=="m"?"l":"L");s.length>=e[a]&&(t.push([r,...s.splice(0,e[a])]),!!e[a]););}),t.toString=Sv,t}function uB(n){for(var e=0,t=n.length;e=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height}function dB(n,e){return n=Ev(n),e=Ev(e),so(e,n.x,n.y)||so(e,n.x2,n.y)||so(e,n.x,n.y2)||so(e,n.x2,n.y2)||so(n,e.x,e.y)||so(n,e.x2,e.y)||so(n,e.x,e.y2)||so(n,e.x2,e.y2)||(n.xe.x||e.xn.x)&&(n.ye.y||e.yn.y)}function I1(n,e,t,i,r){var o=-3*e+9*t-9*i+3*r,s=n*o+6*e-12*t+6*i;return n*s-3*e+3*t}function L1(n,e,t,i,r,o,s,a,l){l==null&&(l=1),l=l>1?1:l<0?0:l;for(var c=l/2,u=12,f=[-.1252,.1252,-.3678,.3678,-.5873,.5873,-.7699,.7699,-.9041,.9041,-.9816,.9816],h=[.2491,.2491,.2335,.2335,.2032,.2032,.1601,.1601,.1069,.1069,.0472,.0472],d=0,p=0;pLi(r,s)||Li(e,i)Li(o,a))){var l=(n*i-e*t)*(r-s)-(n-t)*(r*a-o*s),c=(n*i-e*t)*(o-a)-(e-i)*(r*a-o*s),u=(n-t)*(o-a)-(e-i)*(r-s);if(u){var f=lp(l/u),h=lp(c/u),d=+f.toFixed(2),p=+h.toFixed(2);if(!(d<+Ii(n,t).toFixed(2)||d>+Li(n,t).toFixed(2)||d<+Ii(r,s).toFixed(2)||d>+Li(r,s).toFixed(2)||p<+Ii(e,i).toFixed(2)||p>+Li(e,i).toFixed(2)||p<+Ii(o,a).toFixed(2)||p>+Li(o,a).toFixed(2)))return{x:f,y:h}}}}function lp(n){return Math.round(n*1e11)/1e11}function mB(n,e,t){var i=D1(n),r=D1(e);if(!dB(i,r))return t?0:[];var o=L1(...n),s=L1(...e),a=B1(n)?1:~~(o/5)||1,l=B1(e)?1:~~(s/5)||1,c=new Array(a+1),u=new Array(l+1),f={},h=t?0:[],d,p;for(d=0;d=0&&w<=1&&R>=0&&R<=1&&(t?h++:h.push({x:E.x,y:E.y,t1:w,t2:R}))}}return h}function ef(n,e,t){n=$1(n),e=$1(e);for(var i,r,o,s,a,l,c,u,f,h,d=t?0:[],p=0,m=n.length;p1&&(b=ft.sqrt(b),t=b*t,i=b*i);var _=t*t,v=i*i,x=(o==s?-1:1)*ft.sqrt(ao((_*v-_*g*g-v*m*m)/(_*g*g+v*m*m))),C=x*t*g/i+(n+a)/2,E=x*-i*m/t+(e+l)/2,S=ft.asin(((e-E)/i).toFixed(9)),w=ft.asin(((l-E)/i).toFixed(9));S=nw&&(S=S-oo*2),!s&&w>S&&(w=w-oo*2)}var R=w-S;if(ao(R)>u){var A=w,I=a,D=l;w=S+u*(s&&w>S?1:-1),a=C+t*ft.cos(w),l=E+i*ft.sin(w),h=j1(a,l,t,i,r,0,s,I,D,[w,A,C,E])}R=w-S;var N=ft.cos(S),W=ft.sin(S),Re=ft.cos(w),_e=ft.sin(w),ue=ft.tan(R/4),re=4/3*t*ue,me=4/3*i*ue,Ue=[n,e],$e=[n+re*W,e-me*N],Ct=[a+re*_e,l-me*Re],Nt=[a,l];if($e[0]=2*Ue[0]-$e[0],$e[1]=2*Ue[1]-$e[1],c)return[$e,Ct,Nt].concat(h);h=[$e,Ct,Nt].concat(h).join().split(",");for(var fn=[],ct=0,Ti=h.length;ct7){h[d].shift();for(var p=h[d];p.length;)o[d]="A",h.splice(d++,0,["C",...p.splice(0,6)]);h.splice(d,1),c=e.length}},o=[],s="",a="",l=0,c=e.length;l=r.right,a=i.top-t.y>=r.bottom,l=i.right+t.x<=r.left,c=o?"top":a?"bottom":null,u=l?"left":s?"right":null;return u&&c?c+"-"+u:u||c||"intersect"}function tf(n,e,t){var i=_B(n,e);return i.length===1||i.length===2&&pa(i[0],i[1])<1?ma(i[0]):i.length>1?(i=Fn(i,function(r){var o=Math.floor(r.t2*100)||1;return o=100-o,o=(o<10?"0":"")+o,r.segment2+"#"+o}),ma(i[t?0:i.length-1])):null}function _B(n,e){return ef(n,e)}function q1(n){n=n.slice();for(var e=0,t,i,r;n[e];)t=n[e],i=n[e-1],r=n[e+1],pa(t,r)===0||sp(i,r,t)?n.splice(e,1):e++;return n}function wB(n,e){return Math.sqrt(Math.pow(n.x-e.x,2)+Math.pow(n.y-e.y,2))}function cp(n,e){return Math.round(n*e)/e}function V1(n){return se(n)?n+"px":n}function CB(n){for(;n.parent;)n=n.parent;return n}function EB(n){n=T({},{width:"100%",height:"100%"},n);let e=n.container||document.body,t=document.createElement("div");return t.setAttribute("class","djs-container djs-parent"),is(t,{position:"relative",overflow:"hidden",width:V1(n.width),height:V1(n.height)}),e.appendChild(t),t}function H1(n,e,t){let i=Q("g");ne(i).add(e);let r=t!==void 0?t:n.childNodes.length-1;return n.insertBefore(i,n.childNodes[r]||null),i}var SB="base",z1=0,OB=1,kB={shape:["x","y","width","height"],connection:["waypoints"]};function Y(n,e,t,i){this._eventBus=e,this._elementRegistry=i,this._graphicsFactory=t,this._rootsIdx=0,this._layers={},this._planes=[],this._rootElement=null,this._focused=!1,this._init(n||{})}Y.$inject=["config.canvas","eventBus","graphicsFactory","elementRegistry"];Y.prototype._init=function(n){let e=this._eventBus,t=this._container=EB(n),i=this._svg=Q("svg");j(i,{width:"100%",height:"100%"}),et(i,"tabindex",0),n.autoFocus&&e.on("element.hover",()=>{this.restoreFocus()}),e.on("element.mousedown",500,o=>{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")}),K(t,i);let r=this._viewport=H1(i,"viewport");n.deferUpdate&&(this._viewboxChanged=Mi(at(this._viewboxChanged,this),300)),e.on("diagram.init",()=>{e.fire("canvas.init",{svg:i,viewport:r})}),e.on(["shape.added","connection.added","shape.removed","connection.removed","elements.changed","root.set"],()=>{delete this._cachedViewbox}),e.on("diagram.destroy",500,this._destroy,this),e.on("diagram.clear",500,this._clear,this)};Y.prototype._destroy=function(){this._eventBus.fire("canvas.destroy",{svg:this._svg,viewport:this._viewport});let n=this._container.parentNode;n&&n.removeChild(this._container),delete this._svg,delete this._container,delete this._layers,delete this._planes,delete this._rootElement,delete this._viewport};Y.prototype._setFocused=function(n){n!=this._focused&&(this._focused=n,this._eventBus.fire("canvas.focus.changed",{focused:n}))};Y.prototype._clear=function(){this._elementRegistry.getAll().forEach(e=>{let t=ip(e);t==="root"?this.removeRootElement(e):this._removeElement(e,t)}),this._planes=[],this._rootElement=null,delete this._cachedViewbox};Y.prototype.focus=function(){this._svg.focus({preventScroll:!0}),this._setFocused(!0)};Y.prototype.restoreFocus=function(){document.activeElement===document.body&&this.focus()};Y.prototype.isFocused=function(){return this._focused};Y.prototype.getDefaultLayer=function(){return this.getLayer(SB,z1)};Y.prototype.getLayer=function(n,e){if(!n)throw new Error("must specify a name");let t=this._layers[n];if(t||(t=this._layers[n]=this._createLayer(n,e)),typeof e!="undefined"&&t.index!==e)throw new Error("layer <"+n+"> already created at index <"+e+">");return t.group};Y.prototype._getChildIndex=function(n){return st(this._layers,function(e,t){return t.visible&&n>=t.index&&e++,e},0)};Y.prototype._createLayer=function(n,e){typeof e=="undefined"&&(e=OB);let t=this._getChildIndex(e);return{group:H1(this._viewport,"layer-"+n,t),index:e,visible:!0}};Y.prototype.showLayer=function(n){if(!n)throw new Error("must specify a name");let e=this._layers[n];if(!e)throw new Error("layer <"+n+"> does not exist");let t=this._viewport,i=e.group,r=e.index;if(e.visible)return i;let o=this._getChildIndex(r);return t.insertBefore(i,t.childNodes[o]||null),e.visible=!0,i};Y.prototype.hideLayer=function(n){if(!n)throw new Error("must specify a name");let e=this._layers[n];if(!e)throw new Error("layer <"+n+"> does not exist");let t=e.group;return e.visible&&(Fe(t),e.visible=!1),t};Y.prototype._removeLayer=function(n){let e=this._layers[n];e&&(delete this._layers[n],Fe(e.group))};Y.prototype.getActiveLayer=function(){let n=this._findPlaneForRoot(this.getRootElement());return n?n.layer:null};Y.prototype.findRoot=function(n){return typeof n=="string"&&(n=this._elementRegistry.get(n)),n?(this._findPlaneForRoot(CB(n))||{}).rootElement:void 0};Y.prototype.getRootElements=function(){return this._planes.map(function(n){return n.rootElement})};Y.prototype._findPlaneForRoot=function(n){return ye(this._planes,function(e){return e.rootElement===n})};Y.prototype.getContainer=function(){return this._container};Y.prototype._updateMarker=function(n,e,t){let i;n.id||(n=this._elementRegistry.get(n)),n.markers=n.markers||new Set,i=this._elementRegistry._elements[n.id],i&&(k([i.gfx,i.secondaryGfx],function(r){r&&(t?(n.markers.add(e),ne(r).add(e)):(n.markers.delete(e),ne(r).remove(e)))}),this._eventBus.fire("element.marker.update",{element:n,gfx:i.gfx,marker:e,add:!!t}))};Y.prototype.addMarker=function(n,e){this._updateMarker(n,e,!0)};Y.prototype.removeMarker=function(n,e){this._updateMarker(n,e,!1)};Y.prototype.hasMarker=function(n,e){return n.id||(n=this._elementRegistry.get(n)),n.markers?n.markers.has(e):!1};Y.prototype.toggleMarker=function(n,e){this.hasMarker(n,e)?this.removeMarker(n,e):this.addMarker(n,e)};Y.prototype.getRootElement=function(){let n=this._rootElement;return n||this._planes.length?n:this.setRootElement(this.addRootElement(null))};Y.prototype.addRootElement=function(n){let e=this._rootsIdx++;n||(n={id:"__implicitroot_"+e,children:[],isImplicit:!0});let t=n.layer="root-"+e;this._ensureValid("root",n);let i=this.getLayer(t,z1);return this.hideLayer(t),this._addRoot(n,i),this._planes.push({rootElement:n,layer:i}),n};Y.prototype.removeRootElement=function(n){if(typeof n=="string"&&(n=this._elementRegistry.get(n)),!!this._findPlaneForRoot(n))return this._removeRoot(n),this._removeLayer(n.layer),this._planes=this._planes.filter(function(t){return t.rootElement!==n}),this._rootElement===n&&(this._rootElement=null),n};Y.prototype.setRootElement=function(n){if(n===this._rootElement)return n;let e;if(!n)throw new Error("rootElement required");return e=this._findPlaneForRoot(n),e||(n=this.addRootElement(n)),this._setRoot(n),n};Y.prototype._removeRoot=function(n){let e=this._elementRegistry,t=this._eventBus;t.fire("root.remove",{element:n}),t.fire("root.removed",{element:n}),e.remove(n)};Y.prototype._addRoot=function(n,e){let t=this._elementRegistry,i=this._eventBus;i.fire("root.add",{element:n}),t.add(n,e),i.fire("root.added",{element:n,gfx:e})};Y.prototype._setRoot=function(n,e){let t=this._rootElement;t&&(this._elementRegistry.updateGraphics(t,null,!0),this.hideLayer(t.layer)),n&&(e||(e=this._findPlaneForRoot(n).layer),this._elementRegistry.updateGraphics(n,this._svg,!0),this.showLayer(n.layer)),this._rootElement=n,this._eventBus.fire("root.set",{element:n})};Y.prototype._ensureValid=function(n,e){if(!e.id)throw new Error("element must have an id");if(this._elementRegistry.get(e.id))throw new Error("element <"+e.id+"> already exists");let t=kB[n];if(!kt(t,function(r){return typeof e[r]!="undefined"}))throw new Error("must supply { "+t.join(", ")+" } with "+n)};Y.prototype._setParent=function(n,e,t){zt(e.children,n,t),n.parent=e};Y.prototype._addElement=function(n,e,t,i){t=t||this.getRootElement();let r=this._eventBus,o=this._graphicsFactory;this._ensureValid(n,e),r.fire(n+".add",{element:e,parent:t}),this._setParent(e,t,i);let s=o.create(n,e,i);return this._elementRegistry.add(e,s),o.update(n,e,s),r.fire(n+".added",{element:e,gfx:s}),e};Y.prototype.addShape=function(n,e,t){return this._addElement("shape",n,e,t)};Y.prototype.addConnection=function(n,e,t){return this._addElement("connection",n,e,t)};Y.prototype._removeElement=function(n,e){let t=this._elementRegistry,i=this._graphicsFactory,r=this._eventBus;if(n=t.get(n.id||n),!!n)return r.fire(e+".remove",{element:n}),i.remove(n),Vn(n.parent&&n.parent.children,n),n.parent=null,r.fire(e+".removed",{element:n}),t.remove(n),n};Y.prototype.removeShape=function(n){return this._removeElement(n,"shape")};Y.prototype.removeConnection=function(n){return this._removeElement(n,"connection")};Y.prototype.getGraphics=function(n,e){return this._elementRegistry.getGraphics(n,e)};Y.prototype._changeViewbox=function(n){this._eventBus.fire("canvas.viewbox.changing"),n.apply(this),this._cachedViewbox=null,this._viewboxChanged()};Y.prototype._viewboxChanged=function(){this._eventBus.fire("canvas.viewbox.changed",{viewbox:this.viewbox()})};Y.prototype.viewbox=function(n){if(n===void 0&&this._cachedViewbox)return structuredClone(this._cachedViewbox);let e=this._viewport,t=this.getSize(),i,r,o,s,a,l,c;if(n)this._changeViewbox(function(){a=Math.min(t.width/n.width,t.height/n.height);let u=this._svg.createSVGMatrix().scale(a).translate(-n.x,-n.y);as(e,u)});else return o=this._rootElement?this.getActiveLayer():null,i=o&&o.getBBox()||{},s=as(e),r=s?s.matrix:b1(),a=cp(r.a,1e3),l=cp(-r.e||0,1e3),c=cp(-r.f||0,1e3),n=this._cachedViewbox={x:l?l/a:0,y:c?c/a:0,width:t.width/a,height:t.height/a,scale:a,inner:{width:i.width||0,height:i.height||0,x:i.x||0,y:i.y||0},outer:t},n;return n};Y.prototype.scroll=function(n){let e=this._viewport,t=e.getCTM();return n&&this._changeViewbox(function(){n=T({dx:0,dy:0},n||{}),t=this._svg.createSVGMatrix().translate(n.dx,n.dy).multiply(t),W1(e,t)}),{x:t.e,y:t.f}};Y.prototype.scrollToElement=function(n,e){let t=100;typeof n=="string"&&(n=this._elementRegistry.get(n));let i=this.findRoot(n);if(i!==this.getRootElement()&&this.setRootElement(i),i===n)return;e||(e={}),typeof e=="number"&&(t=e),e={top:e.top||t,right:e.right||t,bottom:e.bottom||t,left:e.left||t};let r=Tt(n),o=G(r),s=this.viewbox(),a=this.zoom(),l,c;s.y+=e.top/a,s.x+=e.left/a,s.width-=(e.right+e.left)/a,s.height-=(e.bottom+e.top)/a;let u=G(s);if(!(r.width=0&&i.y>=0&&i.x+i.width<=t.width&&i.y+i.height<=t.height&&!n?o={x:0,y:0,width:Math.max(i.width+i.x,t.width),height:Math.max(i.height+i.y,t.height)}:(r=Math.min(1,t.width/i.width,t.height/i.height),o={x:i.x+(n?i.width/2-t.width/r/2:0),y:i.y+(n?i.height/2-t.height/r/2:0),width:t.width/r,height:t.height/r}),this.viewbox(o),this.viewbox(!1).scale};Y.prototype._setZoom=function(n,e){let t=this._svg,i=this._viewport,r=t.createSVGMatrix(),o=t.createSVGPoint(),s,a,l,c,u;l=i.getCTM();let f=l.a;return e?(s=T(o,e),a=s.matrixTransform(l.inverse()),c=r.translate(a.x,a.y).scale(1/f*n).translate(-a.x,-a.y),u=l.multiply(c)):u=r.scale(n),W1(this._viewport,u),u};Y.prototype.getSize=function(){return{width:this._container.clientWidth,height:this._container.clientHeight}};Y.prototype.getAbsoluteBBox=function(n){let e=this.viewbox(),t;n.waypoints?t=this.getGraphics(n).getBBox():t=n;let i=t.x*e.scale-e.x*e.scale,r=t.y*e.scale-e.y*e.scale,o=t.width*e.scale,s=t.height*e.scale;return{x:i,y:r,width:o,height:s}};Y.prototype.resized=function(){delete this._cachedViewbox,this._eventBus.fire("canvas.resized")};var ga="data-element-id";function tn(n){this._elements={},this._eventBus=n}tn.$inject=["eventBus"];tn.prototype.add=function(n,e,t){var i=n.id;this._validateId(i),j(e,ga,i),t&&j(t,ga,i),this._elements[i]={element:n,gfx:e,secondaryGfx:t}};tn.prototype.remove=function(n){var e=this._elements,t=n.id||n,i=t&&e[t];i&&(j(i.gfx,ga,""),i.secondaryGfx&&j(i.secondaryGfx,ga,""),delete e[t])};tn.prototype.updateId=function(n,e){this._validateId(e),typeof n=="string"&&(n=this.get(n)),this._eventBus.fire("element.updateId",{element:n,newId:e});var t=this.getGraphics(n),i=this.getGraphics(n,!0);this.remove(n),n.id=e,this.add(n,t,i)};tn.prototype.updateGraphics=function(n,e,t){var i=n.id||n,r=this._elements[i];return t?r.secondaryGfx=e:r.gfx=e,e&&j(e,ga,i),e};tn.prototype.get=function(n){var e;typeof n=="string"?e=n:e=n&&j(n,ga);var t=this._elements[e];return t&&t.element};tn.prototype.filter=function(n){var e=[];return this.forEach(function(t,i){n(t,i)&&e.push(t)}),e};tn.prototype.find=function(n){for(var e=this._elements,t=Object.keys(e),i=0;i in ref");e=this.props[e]}e.collection?U1(this,e,n):MB(this,e,n)};nn.prototype.ensureRefsCollection=function(n,e){var t=n[e.name];return TB(t)||U1(this,e,n),t};nn.prototype.ensureBound=function(n,e){AB(n,e)||this.bind(n,e)};nn.prototype.unset=function(n,e,t){n&&(this.ensureBound(n,e),e.collection?this.ensureRefsCollection(n,e).remove(t):n[e.name]=void 0)};nn.prototype.set=function(n,e,t){n&&(this.ensureBound(n,e),e.collection?this.ensureRefsCollection(n,e).add(t):n[e.name]=t)};var kv=new nn({name:"children",enumerable:!0,collection:!0},{name:"parent"}),K1=new nn({name:"labels",enumerable:!0,collection:!0},{name:"labelTarget"}),Q1=new nn({name:"attachers",collection:!0},{name:"host"}),G1=new nn({name:"outgoing",collection:!0},{name:"source"}),X1=new nn({name:"incoming",collection:!0},{name:"target"});function ya(){Object.defineProperty(this,"businessObject",{writable:!0}),Object.defineProperty(this,"label",{get:function(){return this.labels[0]},set:function(n){var e=this.label,t=this.labels;!n&&e?t.remove(e):t.add(n,0)}}),kv.bind(this,"parent"),K1.bind(this,"labels"),G1.bind(this,"outgoing"),X1.bind(this,"incoming")}function nf(){ya.call(this),kv.bind(this,"children"),Q1.bind(this,"host"),Q1.bind(this,"attachers")}fe(nf,ya);function Y1(){ya.call(this),kv.bind(this,"children")}fe(Y1,nf);function Z1(){nf.call(this),K1.bind(this,"labelTarget")}fe(Z1,nf);function J1(){ya.call(this),G1.bind(this,"source"),X1.bind(this,"target")}fe(J1,ya);var PB={connection:J1,shape:nf,label:Z1,root:Y1};function eC(n,e){var t=PB[n];if(!t)throw new Error("unknown type: <"+n+">");return T(new t,e)}function tC(n){return n instanceof ya}function Hn(){this._uid=12}Hn.prototype.createRoot=function(n){return this.create("root",n)};Hn.prototype.createLabel=function(n){return this.create("label",n)};Hn.prototype.createShape=function(n){return this.create("shape",n)};Hn.prototype.createConnection=function(n){return this.create("connection",n)};Hn.prototype.create=function(n,e){return e=T({},e||{}),e.id||(e.id=n+"_"+this._uid++),eC(n,e)};function ls(n){return n.childNodes[0]}function nC(n){return n.parentNode.childNodes[1]}function iC(n,e,t,i,r){var o=da();o.setTranslate(e,t);var s=da();s.setRotate(i||0,0,0);var a=da();a.setScale(r||1,r||1),as(n,[o,s,a])}function jt(n,e,t){var i=da();i.setTranslate(e,t),as(n,i)}function rC(n,e){var t=da();t.setRotate(e,0,0),as(n,t)}function rn(n,e){this._eventBus=n,this._elementRegistry=e}rn.$inject=["eventBus","elementRegistry"];rn.prototype._getChildrenContainer=function(n){var e=this._elementRegistry.getGraphics(n),t;return n.parent?(t=nC(e),t||(t=Q("g"),ne(t).add("djs-children"),K(e.parentNode,t))):t=e,t};rn.prototype._clear=function(n){var e=ls(n);return no(e),e};rn.prototype._createContainer=function(n,e,t,i){var r=Q("g");ne(r).add("djs-group"),typeof t!="undefined"?oC(r,e,e.childNodes[t]):K(e,r);var o=Q("g");ne(o).add("djs-element"),ne(o).add("djs-"+n),i&&ne(o).add("djs-frame"),K(r,o);var s=Q("g");return ne(s).add("djs-visual"),K(o,s),o};rn.prototype.create=function(n,e,t){var i=this._getChildrenContainer(e.parent);return this._createContainer(n,i,t,rp(e))};rn.prototype.updateContainments=function(n){var e=this,t=this._elementRegistry,i;i=st(n,function(r,o){return o.parent&&(r[o.parent.id]=o.parent),r},{}),k(i,function(r){var o=r.children;if(o){var s=e._getChildrenContainer(r);k(o.slice().reverse(),function(a){var l=t.getGraphics(a);oC(l.parentNode,s)})}})};rn.prototype.drawShape=function(n,e,t={}){var i=this._eventBus;return i.fire("render.shape",{gfx:n,element:e,attrs:t})};rn.prototype.getShapePath=function(n){var e=this._eventBus;return e.fire("render.getShapePath",n)};rn.prototype.drawConnection=function(n,e,t={}){var i=this._eventBus;return i.fire("render.connection",{gfx:n,element:e,attrs:t})};rn.prototype.getConnectionPath=function(n){var e=this._eventBus;return e.fire("render.getConnectionPath",n)};rn.prototype.update=function(n,e,t){if(e.parent){var i=this._clear(t);if(n==="shape")this.drawShape(i,e),jt(t,e.x,e.y);else if(n==="connection")this.drawConnection(i,e);else throw new Error("unknown type: "+n);e.hidden?j(t,"display","none"):j(t,"display","block")}};rn.prototype.remove=function(n){var e=this._elementRegistry.getGraphics(n);Fe(e.parentNode)};function oC(n,e,t){var i=t||e.firstChild;n!==i&&e.insertBefore(n,i)}var sC={__depends__:[R1],__init__:["canvas"],canvas:["type",Y],elementRegistry:["type",tn],elementFactory:["type",Hn],eventBus:["type",ut],graphicsFactory:["type",rn]};function DB(n){var e=new os(n);return e.init(),e}function IB(n){n=n||{};var e={config:["value",n]},t=[e,sC].concat(n.modules||[]);return DB(t)}function mr(n,e){this._injector=e||IB(n),this.get("eventBus").fire("diagram.init")}mr.prototype.get=function(n,e){return this._injector.get(n,e)};mr.prototype.invoke=function(n,e,t){return this._injector.invoke(n,e,t)};mr.prototype.destroy=function(){this.get("eventBus").fire("diagram.destroy")};mr.prototype.clear=function(){this.get("eventBus").fire("diagram.clear")};var LB=new nn({name:"dmnElementRef",enumerable:!0},{name:"di",configurable:!0});function Rv(n,e){var t=[];function i(b){var _=b.gfx;if(_)throw new Error("already rendered "+b.id);return n.element(b)}function r(b){return n.root(b)}function o(b){try{var _=b.di&&i(b);return _}catch(v){g(v.message,{element:b,error:v})}}function s(b,_){var v=b.dmnDI;if(!v)throw new Error("no dmndi:DMNDI");var x=v.diagrams||[];if(_&&x.indexOf(_)===-1)throw new Error("diagram not part of dmndi:DMNDI");if(!_&&x&&x.length&&(_=x[0]),!_)throw new Error("no diagram to display");b.di=_,f(_),r(b),a(b.get("drgElement")),l(b.get("artifact")),m()}function a(b){k(b,function(_){o(_),u(_)})}function l(b){k(b,function(_){O(_,"dmn:Association")?c(_):o(_)})}function c(b){p(function(){o(b)})}function u(b){k(["informationRequirement","knowledgeRequirement","authorityRequirement"],function(_){k(b[_],function(v){p(function(){o(v)})})})}function f(b){k(b.diagramElements,h)}function h(b){d(b)}function d(b){var _=b.dmnElementRef;_?_.di?g("multiple DI elements defined for element",{element:_}):(LB.bind(_,"di"),_.di=b):g("no DMN element referenced in element",{element:b})}function p(b){t.push(b)}function m(){k(t,function(b){b()})}function g(b,_){n.error(b,_)}return{handleDefinitions:s}}function aC(n,e,t){var i=n.get("drdImporter"),r=n.get("eventBus"),o,s=[];function a(l){var c={root:function(f){return i.root(f)},element:function(f,h){return i.add(f,h)},error:function(f,h){s.push({message:f,context:h})}},u=new Rv(c);u.handleDefinitions(l)}r.fire("import.start",{definitions:e});try{a(e)}catch(l){o=l}r.fire("import.done",{error:o,warnings:s}),t(o,s)}var Lv="$NO_OP",BB="a runtime error occured! Use Inferno in development environment to find the error.",dp=Array.isArray;function Bv(n){var e=typeof n;return e==="string"||e==="number"}function we(n){return pp(n)||Ye(n)}function lo(n){return Ye(n)||n===!1||NB(n)||pp(n)}function ve(n){return typeof n=="function"}function va(n){return typeof n=="string"}function Pv(n){return typeof n=="number"}function Ye(n){return n===null}function NB(n){return n===!0}function pp(n){return n===void 0}function $B(n){throw n||(n=BB),new Error("Inferno Error: "+n)}function sf(n,e){var t={};if(n)for(var i in n)t[i]=n[i];if(e)for(var r in e)t[r]=e[r];return t}var rf="$";function Nv(n,e,t,i,r,o,s,a){return{childFlags:n,children:e,className:t,dom:null,flags:i,key:r===void 0?null:r,parentVNode:null,props:o===void 0?null:o,ref:s===void 0?null:s,type:a}}function y(n,e,t,i,r,o,s,a){var l=r===void 0?1:r,c=Nv(l,i,t,n,s,o,a,e),u=Wn.createVNode;return typeof u=="function"&&u(c),l===0&&gC(c,c.children),c}function P(n,e,t,i,r){(n&2)>0&&(n=e.prototype&&ve(e.prototype.render)?4:8);var o=e.defaultProps;if(!we(o)){t||(t={});for(var s in o)pp(t[s])&&(t[s]=o[s])}if((n&8)>0){var a=e.defaultHooks;if(!we(a))if(!r)r=a;else for(var l in a)pp(r[l])&&(r[l]=a[l])}var c=Nv(1,null,null,n,i,t,r,e),u=Wn.createVNode;return ve(u)&&u(c),c}function Z(n,e){return Nv(1,we(n)?"":n,null,16,e,null,null,null)}function En(n){var e=n.props;if(e){var t=n.flags;t&481&&(e.children!==void 0&&we(n.children)&&gC(n,e.children),e.className!==void 0&&(n.className=e.className||null,e.className=void 0)),e.key!==void 0&&(n.key=e.key,e.key=void 0),e.ref!==void 0&&(t&8?n.ref=sf(n.ref,e.ref):n.ref=e.ref,e.ref=void 0)}return n}function Wt(n){var e,t=n.flags;if(t&14){var i,r=n.props;if(!Ye(r)){i={};for(var o in r)i[o]=r[o]}e=P(t,n.type,i,n.key,n.ref)}else t&481?e=y(t,n.type,n.className,n.children,n.childFlags,n.props,n.key,n.ref):t&16?e=Z(n.children,n.key):t&1024&&(e=n);return e}function pC(){return Z("",null)}function mC(n,e,t,i){for(var r=n.length;t0;s&&(o=EC(t),o&&tN(e,i,t));for(var a in t)Dv(a,null,t[a],i,r,o,null);s&&CC(e,n,i,t,!0,o)}function OC(n,e,t,i){var r=new e(t,i);if(n.children=r,r.$V=n,r.$BS=!1,r.context=i,r.props===At&&(r.props=t),r.$UN=!1,ve(r.componentWillMount)){if(r.$BR=!0,r.componentWillMount(),r.$PSS){var o=r.state,s=r.$PS;if(Ye(o))r.state=s;else for(var a in s)o[a]=s[a];r.$PSS=!1,r.$PS=null}r.$BR=!1}ve(Wn.beforeRender)&&Wn.beforeRender(r);var l=cf(r.render(t,r.state,i),n),c;return ve(r.getChildContext)&&(c=r.getChildContext()),we(c)?r.$CX=i:r.$CX=sf(i,c),ve(Wn.afterRender)&&Wn.afterRender(r),r.$LI=l,r}function cf(n,e){return lo(n)?n=pC():Bv(n)?n=Z(n,null):(n.dom&&(n=Wt(n)),n.flags&14&&(n.parentVNode=e)),n}function on(n,e,t,i){var r=n.flags;if(r&481)return kC(n,e,t,i);if(r&14)return oN(n,e,t,i,(r&4)>0);if(r&512||r&16)return Iv(n,e);if(r&1024)return on(n.children,n.type,t,!1),n.dom=Iv(pC(),e)}function Iv(n,e){var t=n.dom=document.createTextNode(n.children);return Ye(e)||mp(e,t),t}function kC(n,e,t,i){var r=n.flags,o=n.children,s=n.props,a=n.className,l=n.ref,c=n.childFlags;i=i||(r&32)>0;var u=FB(n.type,i);if(n.dom=u,!we(a)&&a!==""&&(i?u.setAttribute("class",a):u.className=a),Ye(e)||mp(e,u),(c&1)===0){var f=i===!0&&n.type!=="foreignObject";c===2?on(o,u,t,f):c&12&&of(o,u,t,f)}return Ye(s)||SC(n,r,s,u,i),ve(l)&&Hv(u,l),u}function of(n,e,t,i){for(var r=0,o=n.length;r0,e.nodeType!==1||e.tagName.toLowerCase()!==n.type){var c=kC(n,null,t,i);n.dom=c,$v(e.parentNode,c,e)}else{n.dom=e;var u=e.firstChild,f=n.childFlags;if((f&1)===0){for(var h=null;u;)h=u.nextSibling,u.nodeType===8&&(u.data==="!"?e.replaceChild(document.createTextNode(""),u):e.removeChild(u)),u=h;if(u=e.firstChild,f===2)Ye(u)?on(r,e,t,i):(h=u.nextSibling,af(r,u,t,i),u=h);else if(f&12)for(var d=0,p=r.length;d0):r&481?cN(n,e,t,i):r&16?uN(n,e):r&512?n.dom=e:$B()}function fN(n,e,t){var i=e.firstChild;if(!Ye(i))for(lo(n)||af(n,i,At,!1),i=e.firstChild;i=i.nextSibling;)e.removeChild(i);Ni.length>0&&jv(Ni),e.$V=n,ve(t)&&t()}function zv(n,e,t,i,r){us(n),$v(t,on(e,null,i,r),n.dom)}function gr(n,e,t,i,r){var o=e.flags|0;n.flags!==o||o&2048?zv(n,e,t,i,r):o&481?pN(n,e,t,i,r,o):o&14?mN(n,e,t,i,r,(o&4)>0):o&16?gN(n,e):o&512?e.dom=n.dom:dN(n,e,i)}function hN(n,e){n.textContent!==e.children&&(n.textContent=e.children)}function dN(n,e,t){var i=n.type,r=e.type,o=e.children;if(AC(n.childFlags,e.childFlags,n.children,o,i,t,!1),e.dom=n.dom,i!==r&&!lo(o)){var s=o.dom;i.removeChild(s),r.appendChild(s)}}function pN(n,e,t,i,r,o){var s=e.type;if(n.type!==s)zv(n,e,t,i,r);else{var a=n.dom,l=n.props,c=e.props,u=!1,f=!1,h;if(e.dom=a,r=r||(o&32)>0,l!==c){var d=l||At;if(h=c||At,h!==At){u=(o&448)>0,u&&(f=EC(h));for(var p in h){var m=d[p],g=h[p];m!==g&&Dv(p,m,g,a,r,f,n)}}if(d!==At)for(var b in d)!h.hasOwnProperty(b)&&!we(d[b])&&Dv(b,d[b],null,a,r,f,n)}var _=n.children,v=e.children,x=e.ref,C=n.className,E=e.className;o&4096?hN(a,v):AC(n.childFlags,e.childFlags,_,v,a,i,r&&s!=="foreignObject"),u&&CC(o,e,a,h,!1,f),C!==E&&(we(E)?a.removeAttribute("class"):r?a.setAttribute("class",E):a.className=E),ve(x)&&n.ref!==x&&Hv(a,x)}}function AC(n,e,t,i,r,o,s){switch(n){case 2:switch(e){case 2:gr(t,i,r,o,s);break;case 1:zn(t,r);break;default:zn(t,r),of(i,r,o,s);break}break;case 1:switch(e){case 2:on(i,r,o,s);break;case 1:break;default:of(i,r,o,s);break}break;default:if(e&12){var a=t.length,l=i.length;a===0?l>0&&of(i,r,o,s):l===0?hp(r,t):e===8&&n===8?vN(t,i,r,o,s,a,l):yN(t,i,r,o,s,a,l)}else e===1?hp(r,t):e===2&&(hp(r,t),on(i,r,o,s));break}}function MC(n,e,t,i,r,o,s,a,l){var c=n.state,u=n.props;t.children=n;var f;if(!n.$UN){if(u!==i||i===At){if(!l&&ve(n.componentWillReceiveProps)){if(n.$BR=!0,n.componentWillReceiveProps(i,o),n.$UN)return;n.$BR=!1}n.$PSS&&(e=sf(e,n.$PS),n.$PSS=!1,n.$PS=null)}var h=!!n.shouldComponentUpdate;if(a||!h||h&&n.shouldComponentUpdate(i,e,o)){ve(n.componentWillUpdate)&&(n.$BS=!0,n.componentWillUpdate(i,e,o),n.$BS=!1),n.props=i,n.state=e,n.context=o,ve(Wn.beforeRender)&&Wn.beforeRender(n),f=n.render(i,e,o),ve(Wn.afterRender)&&Wn.afterRender(n);var d=f!==Lv,p;if(ve(n.getChildContext)&&(p=n.getChildContext()),we(p)?p=o:p=sf(o,p),n.$CX=p,d){var m=n.$LI,g=cf(f,t);gr(m,g,r,p,s),n.$LI=g,ve(n.componentDidUpdate)&&n.componentDidUpdate(u,c)}}else n.props=i,n.state=e,n.context=o;t.dom=n.$LI.dom}}function mN(n,e,t,i,r,o){var s=e.type,a=n.key,l=e.key;if(n.type!==s||a!==l)zv(n,e,t,i,r);else{var c=e.props||At;if(o){var u=n.children;u.$UPD=!0,u.$V=e,MC(u,u.state,e,c,t,i,r,!1,!1),u.$UPD=!1}else{var f=!0,h=n.props,d=e.ref,p=!we(d),m=n.children;if(e.dom=n.dom,e.children=m,p&&ve(d.onComponentShouldUpdate)&&(f=d.onComponentShouldUpdate(h,c)),f!==!1){p&&ve(d.onComponentWillUpdate)&&d.onComponentWillUpdate(h,c);var g=s(c,i);g!==Lv&&(g=cf(g,e),gr(m,g,t,i,r),e.children=g,e.dom=g.dom,p&&ve(d.onComponentDidUpdate)&&d.onComponentDidUpdate(h,c))}else m.flags&14&&(m.parentVNode=e)}}}function gN(n,e){var t=e.children,i=n.dom;t!==n.children&&(i.nodeValue=t),e.dom=i}function yN(n,e,t,i,r,o,s){for(var a=o>s?s:o,l=0,c,u;ls)for(l=a;la||u>l)break e;f=n[u],h=e[u]}for(f=n[a],h=e[l];f.key===h.key;){if(h.dom&&(e[l]=h=Wt(h)),gr(f,h,t,i,r),n[a]=h,a--,l--,u>a||u>l)break e;f=n[a],h=e[l]}}if(u>a){if(u<=l){d=l+1;for(var p=dl)for(;u<=a;)zn(n[u++],t);else{var m=u,g=u,b=a-u+1,_=l-u+1,v=[];for(c=0;c<_;c++)v.push(0);var x=b===o,C=!1,E=0,S=0;if(s<4||(b|_)<32)for(c=m;c<=a;c++)if(f=n[c],S<_){for(u=g;u<=l;u++)if(h=e[u],f.key===h.key){if(v[u-g]=c+1,x)for(x=!1;c>m;)zn(n[m++],t);E>u?C=!0:E=u,h.dom&&(e[u]=h=Wt(h)),gr(f,h,t,i,r),S++;break}!x&&u>l&&zn(f,t)}else x||zn(f,t);else{var w={};for(c=g;c<=l;c++)w[e[c].key]=c;for(c=m;c<=a;c++)if(f=n[c],S<_)if(u=w[f.key],u!==void 0){if(x)for(x=!1;c>m;)zn(n[m++],t);h=e[u],v[u-g]=c+1,E>u?C=!0:E=u,h.dom&&(e[u]=h=Wt(h)),gr(f,h,t,i,r),S++}else x||zn(f,t);else x||zn(f,t)}if(x)hp(t,n),of(e,t,i,r);else if(C){var R=xN(v);for(u=R.length-1,c=_-1;c>=0;c--)v[c]===0?(E=c+g,h=e[E],h.dom&&(e[E]=h=Wt(h)),d=E+1,up(t,on(h,null,i,r),d=0;c--)v[c]===0&&(E=c+g,h=e[E],h.dom&&(e[E]=h=Wt(h)),d=E+1,up(t,on(h,null,i,r),d0&&(e[i]=t[o-1]),t[o]=i)}}for(o=t.length,s=t[o-1];o-- >0;)t[o]=s,s=e[s];return t}function xa(n,e,t){if(n!==Lv){var i=e.$V;if(we(i)?lo(n)||(n.dom&&(n=Wt(n)),Ye(e.firstChild)?(on(n,e,At,!1),e.$V=n):fN(n,e),i=n):we(n)?(zn(i,e),e.$V=null):(n.dom&&(n=Wt(n)),gr(i,n,e,At,!1),i=e.$V=n),Ni.length>0&&jv(Ni),ve(t)&&t(),ve(Wn.renderComplete)&&Wn.renderComplete(i),i&&i.flags&14)return i.children}}function PC(n,e){return y(1024,e,null,n,0,null,lo(n)?null:n.key,null)}var hC=typeof Promise=="undefined"?null:Promise.resolve(),bN=typeof requestAnimationFrame=="undefined"?setTimeout:requestAnimationFrame.bind(window);function _N(n){return hC?hC.then(n):bN(n)}function dC(n,e,t,i){ve(e)&&(e=e(n.state,n.props,n.context));var r=n.$PS;if(we(r))n.$PS=e;else for(var o in e)r[o]=e[o];if(!n.$PSS&&!n.$BR)if(!n.$UPD)n.$PSS=!0,n.$UPD=!0,DC(n,i,t),n.$UPD=!1;else{var s=n.$QU;Ye(s)&&(s=n.$QU=[],_N(wN(n,s))),ve(t)&&s.push(t)}else n.$PSS=!0,n.$BR&&ve(t)&&Ni.push(t.bind(n))}function wN(n,e){return function(){n.$QU=null,n.$UPD=!0,DC(n,!1,function(){for(var t=0,i=e.length;t0,e,!0),n.$UN)return;if((n.$LI.flags&1024)===0)for(var f=n.$LI.dom;!Ye(l=l.parentVNode);)(l.flags&14)>0&&(l.dom=f);Ni.length>0&&jv(Ni)}else n.state=n.$PS,n.$PS=null;ve(t)&&t.call(n)}}var L=(function(){function n(t,i){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=t||At,this.context=i||At}var e=n.prototype;return e.forceUpdate=function(i){this.$UN||dC(this,{},i,!0)},e.setState=function(i,r){if(!this.$UN)if(!this.$BS)dC(this,i,r,!1);else return},e.render=function(i,r,o){},n})();L.defaultProps=void 0;var IC='';function Wv(n){var e=''+IC+"",t=te(e);n.appendChild(t),q.bind(t,"click",function(i){kN(),i.preventDefault()})}var co=class extends L{constructor(e,t){super(e,t),this.node=null}componentDidMount(){Wv(this.node)}render(){return y(1,"div",null,null,1,null,null,e=>this.node=e)}};function Uv(n){return n.join(";")}var CN=Uv(["z-index: 1001","position: fixed","top: 0","left: 0","right: 0","bottom: 0"]),EN=Uv(["width: 100%","height: 100%","background: rgba(40,40,40,0.2)"]),SN=Uv(["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"]),ON='
'+IC+'Web-based tooling for BPMN, DMN and CMMN diagrams powered by bpmn.io.
',uf;function kN(){uf||(uf=te(ON),_t.bind(uf,".backdrop","click",function(n){document.body.removeChild(uf)})),document.body.appendChild(uf)}var RN=new qn,gp="hsl(225, 10%, 15%)";function ff(n,e,t,i,r,o){mn.call(this,e);var s=RN.next(),a=i.computeStyle,l={},c=n&&n.defaultFillColor||"white",u=n&&n.defaultStrokeColor||gp,f=n&&n.defaultLabelColor;function h(S,w,R){var A=S+"-"+BC(w)+"-"+BC(R)+"-"+s;return l[A]||p(A,S,w,R),"url(#"+A+")"}function d(S,w){var R=T({strokeWidth:1,strokeLinecap:"round",strokeDasharray:"none"},w.attrs),A=w.ref||{x:0,y:0},I=w.scale||1;R.strokeDasharray==="none"&&(R.strokeDasharray=[1e4,1]);var D=Q("marker");j(w.element,R),K(D,w.element),j(D,{id:S,viewBox:"0 0 20 20",refX:A.x,refY:A.y,markerWidth:20*I,markerHeight:20*I,orient:"auto"});var N=X("defs",o._svg);N||(N=Q("defs"),K(o._svg,N)),K(N,D),l[S]=D}function p(S,w,R,A){if(w==="association-start"){var I=Q("path");j(I,{d:"M 11 5 L 1 10 L 11 15"}),d(S,{element:I,attrs:{fill:"none",stroke:A,strokeWidth:1.5},ref:{x:1,y:10},scale:.5})}else if(w==="association-end"){var D=Q("path");j(D,{d:"M 1 5 L 11 10 L 1 15"}),d(S,{element:D,attrs:{fill:"none",stroke:A,strokeWidth:1.5},ref:{x:12,y:10},scale:.5})}else if(w==="information-requirement-end"){var N=Q("path");j(N,{d:"M 1 5 L 11 10 L 1 15 Z"}),d(S,{element:N,attrs:{fill:A,stroke:"none"},ref:{x:11,y:10},scale:1})}else if(w==="knowledge-requirement-end"){var W=Q("path");j(W,{d:"M 1 3 L 11 10 L 1 17"}),d(S,{element:W,attrs:{fill:"none",stroke:A,strokeWidth:2},ref:{x:11,y:10},scale:.8})}else if(w==="authority-requirement-end"){var Re=Q("circle");j(Re,{cx:3,cy:3,r:3}),d(S,{element:Re,attrs:{fill:A,stroke:"none"},ref:{x:3,y:3},scale:.9})}}function m(S,w,R,A,I,D){Pe(I)&&(D=I,I=0),I=I||0,D=a(D,{stroke:gp,strokeWidth:2,fill:"white"});var N=Q("rect");return j(N,{x:I,y:I,width:w-I*2,height:R-I*2,rx:A,ry:A}),j(N,D),K(S,N),N}function g(S,w,R){var A=r.createText(w||"",R);return et(A,"class","djs-label"),K(S,A),A}function b(S,w,R,A){var I=f1(w);return A=T({box:w,align:R,padding:5,style:{fill:NC(w,f,u)}},A),g(S,I,A)}function _(S,w,R){R=a(R,["no-fill"],{strokeWidth:2,stroke:gp});var A=Q("path");return j(A,{d:w}),j(A,R),K(S,A),A}var v={"dmn:Decision":function(S,w){var R=m(S,w.width,w.height,0,{stroke:$i(w,u),fill:uo(w,c)});return b(S,w,"center-middle"),R},"dmn:KnowledgeSource":function(S,w){var R=t.getScaledPath("KNOWLEDGE_SOURCE",{xScaleFactor:1.021,yScaleFactor:1,containerWidth:w.width,containerHeight:w.height,position:{mx:0,my:.075}}),A=_(S,R,{strokeWidth:2,fill:uo(w,c),stroke:$i(w,u)});return b(S,w,"center-middle"),A},"dmn:BusinessKnowledgeModel":function(S,w){var R=t.getScaledPath("BUSINESS_KNOWLEDGE_MODEL",{xScaleFactor:1,yScaleFactor:1,containerWidth:w.width,containerHeight:w.height,position:{mx:0,my:.3}}),A=_(S,R,{strokeWidth:2,fill:uo(w,c),stroke:$i(w,u)});return b(S,w,"center-middle"),A},"dmn:InputData":function(S,w){var R=m(S,w.width,w.height,22,{stroke:$i(w,u),fill:uo(w,c)});return b(S,w,"center-middle"),R},"dmn:TextAnnotation":function(S,w){var R={fill:"none",stroke:"none"},A=m(S,w.width,w.height,0,0,R),I=t.getScaledPath("TEXT_ANNOTATION",{xScaleFactor:1,yScaleFactor:1,containerWidth:w.width,containerHeight:w.height,position:{mx:0,my:0}});_(S,I,{stroke:$i(w,u)});var D=LC(w).text||"";return g(S,D,{style:{fill:NC(w,f,u)},box:w,align:"left-top",padding:5}),A},"dmn:Association":function(S,w){var R=LC(w),A=uo(w,c),I=$i(w,u),D={stroke:I,strokeDasharray:"0.5, 5",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"};return(R.associationDirection==="One"||R.associationDirection==="Both")&&(D.markerEnd=h("association-end",A,I)),R.associationDirection==="Both"&&(D.markerStart=h("association-start",A,I)),E(S,w.waypoints,D)},"dmn:InformationRequirement":function(S,w){var R=uo(w,c),A=$i(w,u),I={stroke:A,strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round",markerEnd:h("information-requirement-end",R,A)};return E(S,w.waypoints,I)},"dmn:KnowledgeRequirement":function(S,w){var R=uo(w,c),A=$i(w,u),I={stroke:A,strokeWidth:1,strokeDasharray:5,strokeLinecap:"round",strokeLinejoin:"round",markerEnd:h("knowledge-requirement-end",R,A)};return E(S,w.waypoints,I)},"dmn:AuthorityRequirement":function(S,w){var R=uo(w,c),A=$i(w,u),I={stroke:A,strokeWidth:1.5,strokeDasharray:5,strokeLinecap:"round",strokeLinejoin:"round",markerEnd:h("authority-requirement-end",R,A)};return E(S,w.waypoints,I)}};function x(S,w){var R=v[w.type];return R?R(S,w):mn.prototype.drawShape.apply(this,[S,w])}function C(S,w){var R=w.type,A=v[R];return A?A(S,w):mn.prototype.drawConnection.apply(this,[S,w])}function E(S,w,R){R=a(R,["no-fill"],{stroke:gp,strokeWidth:2,fill:"none"});var A=ro(w,R);return K(S,A),A}this.canRender=function(S){return O(S,"dmn:DMNElement")||O(S,"dmn:InformationRequirement")||O(S,"dmn:KnowledgeRequirement")||O(S,"dmn:AuthorityRequirement")},this.drawShape=x,this.drawConnection=C}fe(ff,mn);ff.$inject=["config.drdRenderer","eventBus","pathMap","styles","textRenderer","canvas"];function LC(n){return n.businessObject}function BC(n){return n.replace(/[^0-9a-zA-z]+/g,"_")}function $i(n,e){return e}function uo(n,e){return e}function NC(n,e,t){return e||$i(n,t)}var TN=0,AN={width:150,height:50};function MN(n){var e=n.split("-");return{horizontal:e[0]||"center",vertical:e[1]||"top"}}function PN(n){return Pe(n)?T({top:0,left:0,right:0,bottom:0},n):{top:n,left:n,right:n,bottom:n}}var Qv=null;function DN(){return Qv||(Qv=document.createElement("canvas").getContext("2d")),Qv}function IN(n){var e=[];return n.fontStyle&&e.push(n.fontStyle),n.fontVariant&&e.push(n.fontVariant),n.fontWeight&&e.push(n.fontWeight),n.fontStretch&&e.push(n.fontStretch),e.push(jC(n.fontSize)||"12px"),e.push(n.fontFamily||"sans-serif"),e.join(" ")}function jC(n){if(n!=null)return typeof n=="number"||/^-?\d+(\.\d+)?$/.test(n)?n+"px":n}function LN(n,e){var t=DN();if(!t)return{width:0,height:0};t.font=IN(e),"letterSpacing"in t&&(t.letterSpacing=jC(e.letterSpacing)||"0px");var i=n==="",r=i?"dummy":n.replace(/\s+$/,""),o=t.measureText(r);return{width:i?0:o.width,height:"fontBoundingBoxAscent"in o?o.fontBoundingBoxAscent+o.fontBoundingBoxDescent:o.actualBoundingBoxAscent+o.actualBoundingBoxDescent}}function BN(n,e,t){for(var i=n.shift(),r=i,o;;){if(o=LN(r,t),o.width=r?o.width:0,r===" "||r===""||o.width1)for(;i=t.shift();)if(i.length+og?b.width:g},0),d=o.top;r.vertical==="middle"&&(d+=(t.height-f)/2),d-=(a||c[0].height)/4;var p=Q("text");j(p,i),k(c,function(g){var b;switch(d+=a||g.height,r.horizontal){case"left":b=o.left;break;case"right":b=(s?h:u)-o.right-g.width;break;default:b=Math.max(((s?h:u)-g.width)/2+o.left,0)}var _=Q("tspan");j(_,{x:b,y:d}),_.textContent=g.text,K(p,_)});var m={width:h,height:f};return{dimensions:m,element:p}};function FN(n){if("fontSize"in n&&"lineHeight"in n)return n.lineHeight*parseInt(n.fontSize,10)}var qN=12,VN=1.2,HN=30;function yp(n){var e=T({fontFamily:"Arial, sans-serif",fontSize:qN,fontWeight:"normal",lineHeight:VN},n&&n.defaultStyle||{}),t=parseInt(e.fontSize,10)-1,i=T({},e,{fontSize:t},n&&n.externalStyle||{}),r=new ba({style:e});this.getExternalLabelBounds=function(o,s){var a=r.getDimensions(s,{box:{width:90,height:30,x:o.width/2+o.x,y:o.height/2+o.y},style:i});return{x:Math.round(o.x+o.width/2-a.width/2),y:Math.round(o.y),width:Math.ceil(a.width),height:Math.ceil(a.height)}},this.getTextAnnotationBounds=function(o,s){var a=r.getDimensions(s,{box:o,style:e,align:"left-top",padding:5});return{x:o.x,y:o.y,width:o.width,height:Math.max(HN,Math.round(a.height))}},this.createText=function(o,s){return r.createText(o,s||{})},this.getDefaultStyle=function(){return e},this.getExternalStyle=function(){return i}}yp.$inject=["config.textRenderer"];function Kv(){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 i=this.pathMap[e],r,o;t.abspos?(r=t.abspos.x,o=t.abspos.y):(r=t.containerWidth*t.position.mx,o=t.containerHeight*t.position.my);var s={};if(t.position){for(var a=t.containerHeight/i.height*t.yScaleFactor,l=t.containerWidth/i.width*t.xScaleFactor,c=0;c");return r(I,R,A)}var f="svg, .djs-element";function h(w,R,A,I){var D=o[A]=function(N){r(A,N)};I&&(c[A]=I),D.$delegate=_t.bind(w,f,R,D)}function d(w,R,A){var I=s(A);I&&_t.unbind(w,R,I.$delegate)}function p(w){k(l,function(R,A){h(w,A,R)})}function m(w){k(l,function(R,A){d(w,A,R)})}n.on("canvas.destroy",function(w){m(w.svg)}),n.on("canvas.init",function(w){p(w.svg)}),n.on(["shape.added","connection.added"],function(w){var R=w.element,A=w.gfx;n.fire("interactionEvents.createHit",{element:R,gfx:A})}),n.on(["shape.changed","connection.changed"],QC,function(w){var R=w.element,A=w.gfx;n.fire("interactionEvents.updateHit",{element:R,gfx:A})}),n.on("interactionEvents.createHit",QC,function(w){var R=w.element,A=w.gfx;i.createDefaultHit(R,A)}),n.on("interactionEvents.updateHit",function(w){var R=w.element,A=w.gfx;i.updateDefaultHit(R,A)});var g=C("djs-hit djs-hit-stroke"),b=C("djs-hit djs-hit-click-stroke"),_=C("djs-hit djs-hit-all"),v=C("djs-hit djs-hit-no-move"),x={all:_,"click-stroke":b,stroke:g,"no-move":v};function C(w,R){return R=T({stroke:"white",strokeWidth:15},R||{}),t.cls(w,["no-fill","no-border"],R)}function E(w,R){var A=x[R];if(!A)throw new Error("invalid hit type <"+R+">");return j(w,A),w}function S(w,R){K(w,R)}this.removeHits=function(w){var R=pn(".djs-hit",w);k(R,Fe)},this.createDefaultHit=function(w,R){var A=w.waypoints,I=w.isFrame,D;return A?this.createWaypointsHit(R,A):(D=I?"stroke":"all",this.createBoxHit(R,D,{width:w.width,height:w.height}))},this.createWaypointsHit=function(w,R){var A=ro(R);return E(A,"stroke"),S(w,A),A},this.createBoxHit=function(w,R,A){A=T({x:0,y:0},A);var I=Q("rect");return E(I,R),j(I,A),S(w,I),I},this.updateDefaultHit=function(w,R){var A=X(".djs-hit",R);if(A)return w.waypoints?bv(A,w.waypoints):j(A,{width:w.width,height:w.height}),A},this.fire=r,this.triggerMouseEvent=u,this.mouseHandler=s,this.registerEvent=h,this.unregisterEvent=d}_p.$inject=["eventBus","elementRegistry","styles"];var fo={__init__:["interactionEvents"],interactionEvents:["type",_p]};function ho(n,e){this._eventBus=n,this._canvas=e,this._selectedElements=[];var t=this;n.on(["shape.remove","connection.remove"],function(i){var r=i.element;t.deselect(r)}),n.on(["diagram.clear","root.set"],function(i){t.select(null)})}ho.$inject=["eventBus","canvas"];ho.prototype.deselect=function(n){var e=this._selectedElements,t=e.indexOf(n);if(t!==-1){var i=e.slice();e.splice(t,1),this._eventBus.fire("selection.changed",{oldSelection:i,newSelection:e})}};ho.prototype.get=function(){return this._selectedElements};ho.prototype.isSelected=function(n){return this._selectedElements.indexOf(n)!==-1};ho.prototype.select=function(n,e){var t=this._selectedElements,i=t.slice();F(n)||(n=n?[n]:[]);var r=this._canvas,o=r.getRootElement();n=n.filter(function(s){var a=r.findRoot(s);return o===a}),e?k(n,function(s){t.indexOf(s)===-1&&t.push(s)}):this._selectedElements=t=n.slice(),this._eventBus.fire("selection.changed",{oldSelection:i,newSelection:t})};var KC="hover",GC="selected";function wp(n,e){this._canvas=n;function t(r,o){n.addMarker(r,o)}function i(r,o){n.removeMarker(r,o)}e.on("element.hover",function(r){t(r.element,KC)}),e.on("element.out",function(r){i(r.element,KC)}),e.on("selection.changed",function(r){function o(c){i(c,GC)}function s(c){t(c,GC)}var a=r.oldSelection,l=r.newSelection;k(a,function(c){l.indexOf(c)===-1&&o(c)}),k(l,function(c){a.indexOf(c)===-1&&s(c)})})}wp.$inject=["canvas","eventBus"];function Cp(n,e,t,i){n.on("create.end",500,function(r){var o=r.context,s=o.canExecute,a=o.elements,l=o.hints||{},c=l.autoSelect;if(s){if(c===!1)return;F(c)?e.select(c):e.select(a.filter(XN))}}),n.on("connect.end",500,function(r){var o=r.context,s=o.connection;s&&e.select(s)}),n.on("shape.move.end",500,function(r){var o=r.previousSelection||[],s=i.get(r.context.shape.id),a=ye(o,function(l){return s.id===l.id});a||e.select(s)}),n.on("element.click",function(r){if(Sn(r)){var o=r.element;o===t.getRootElement()&&(o=null);var s=e.isSelected(o),a=e.get().length>1,l=df(r);if(s&&a)return l?e.deselect(o):e.select(o);s?e.deselect(o):e.select(o,l)}})}Cp.$inject=["eventBus","selection","canvas","elementRegistry"];function XN(n){return!n.hidden}var ht={__init__:["selectionVisuals","selectionBehavior"],__depends__:[fo],selection:["type",ho],selectionVisuals:["type",wp],selectionBehavior:["type",Cp]};function po(n){this._counter=0,this._prefix=(n?n+"-":"")+Math.floor(Math.random()*1e9)+"-"}po.prototype.next=function(){return this._prefix+ ++this._counter};var YN=new po("ov"),ZN=500;function xt(n,e,t,i){this._eventBus=e,this._canvas=t,this._elementRegistry=i,this._ids=YN,this._overlayDefaults=T({show:null,scale:!0},n&&n.defaults),this._overlays={},this._overlayContainers=[],this._overlayRoot=JN(t.getContainer()),this._init()}xt.$inject=["config.overlays","eventBus","canvas","elementRegistry"];xt.prototype.get=function(n){if(Ie(n)&&(n={id:n}),Ie(n.element)&&(n.element=this._elementRegistry.get(n.element)),n.element){var e=this._getOverlayContainer(n.element,!0);return e?n.type?Ee(e.overlays,la({type:n.type})):e.overlays.slice():[]}else return n.type?Ee(this._overlays,la({type:n.type})):n.id?this._overlays[n.id]:null};xt.prototype.add=function(n,e,t){if(Pe(e)&&(t=e,e=null),n.id||(n=this._elementRegistry.get(n)),!t.position)throw new Error("must specifiy overlay position");if(!t.html)throw new Error("must specifiy overlay html");if(!n)throw new Error("invalid element specified");var i=this._ids.next();return t=T({},this._overlayDefaults,t,{id:i,type:e,element:n,html:t.html}),this._addOverlay(t),i};xt.prototype.remove=function(n){var e=this.get(n)||[];F(e)||(e=[e]);var t=this;k(e,function(i){var r=t._getOverlayContainer(i.element,!0);if(i&&(Qe(i.html),Qe(i.htmlContainer),delete i.htmlContainer,delete i.element,delete t._overlays[i.id]),r){var o=r.overlays.indexOf(i);o!==-1&&r.overlays.splice(o,1)}})};xt.prototype.isShown=function(){return this._overlayRoot.style.display!=="none"};xt.prototype.show=function(){Ep(this._overlayRoot)};xt.prototype.hide=function(){Ep(this._overlayRoot,!1)};xt.prototype.clear=function(){this._overlays={},this._overlayContainers=[],no(this._overlayRoot)};xt.prototype._updateOverlayContainer=function(n){var e=n.element,t=n.html,i=e.x,r=e.y;if(e.waypoints){var o=Tt(e);i=o.x,r=o.y}XC(t,i,r),et(n.html,"data-container-id",e.id)};xt.prototype._updateOverlay=function(n){var e=n.position,t=n.htmlContainer,i=n.element,r=e.left,o=e.top;if(e.right!==void 0){var s;i.waypoints?s=Tt(i).width:s=i.width,r=e.right*-1+s}if(e.bottom!==void 0){var a;i.waypoints?a=Tt(i).height:a=i.height,o=e.bottom*-1+a}XC(t,r||0,o||0),this._updateOverlayVisibilty(n,this._canvas.viewbox())};xt.prototype._createOverlayContainer=function(n){var e=te('
');is(e,{position:"absolute"}),this._overlayRoot.appendChild(e);var t={html:e,element:n,overlays:[]};return this._updateOverlayContainer(t),this._overlayContainers.push(t),t};xt.prototype._updateRoot=function(n){var e=n.scale||1,t="matrix("+[e,0,0,e,-1*n.x*e,-1*n.y*e].join(",")+")";YC(this._overlayRoot,t)};xt.prototype._getOverlayContainer=function(n,e){var t=ye(this._overlayContainers,function(i){return i.element===n});return!t&&!e?this._createOverlayContainer(n):t};xt.prototype._addOverlay=function(n){var e=n.id,t=n.element,i=n.html,r,o;i.get&&i.constructor.prototype.jquery&&(i=i.get(0)),Ie(i)&&(i=te(i)),o=this._getOverlayContainer(t),r=te('
'),is(r,{position:"absolute"}),r.appendChild(i),n.type&&ee(r).add("djs-overlay-"+n.type);var s=this._canvas.findRoot(t),a=this._canvas.getRootElement();Ep(r,s===a),n.htmlContainer=r,o.overlays.push(n),o.html.appendChild(r),this._overlays[e]=n,this._updateOverlay(n),this._updateOverlayVisibilty(n,this._canvas.viewbox())};xt.prototype._updateOverlayVisibilty=function(n,e){var t=n.show,i=this._canvas.findRoot(n.element),r=t&&t.minZoom,o=t&&t.maxZoom,s=n.htmlContainer,a=this._canvas.getRootElement(),l=!0;(i!==a||t&&(Me(r)&&r>e.scale||Me(o)&&or&&(s=(1/e.scale||1)*r)),Me(s)&&(a="scale("+s+","+s+")"),YC(o,a)};xt.prototype._updateOverlaysVisibilty=function(n){var e=this;k(this._overlays,function(t){e._updateOverlayVisibilty(t,n)})};xt.prototype._init=function(){var n=this._eventBus,e=this;function t(i){e._updateRoot(i),e._updateOverlaysVisibilty(i),e.show()}n.on("canvas.viewbox.changing",function(i){e.hide()}),n.on("canvas.viewbox.changed",function(i){t(i.viewbox)}),n.on(["shape.remove","connection.remove"],function(i){var r=i.element,o=e.get({element:r});k(o,function(l){e.remove(l.id)});var s=e._getOverlayContainer(r);if(s){Qe(s.html);var a=e._overlayContainers.indexOf(s);a!==-1&&e._overlayContainers.splice(a,1)}}),n.on("element.changed",ZN,function(i){var r=i.element,o=e._getOverlayContainer(r,!0);o&&(k(o.overlays,function(s){e._updateOverlay(s)}),e._updateOverlayContainer(o))}),n.on("element.marker.update",function(i){var r=e._getOverlayContainer(i.element,!0);r&&ee(r.html)[i.add?"add":"remove"](i.marker)}),n.on("root.set",function(){e._updateOverlaysVisibilty(e._canvas.viewbox())}),n.on("diagram.clear",this.clear,this)};function JN(n){var e=te('
');return is(e,{position:"absolute",width:0,height:0}),n.insertBefore(e,n.firstChild),e}function XC(n,e,t){is(n,{left:e+"px",top:t+"px"})}function Ep(n,e){n.style.display=e===!1?"none":""}function YC(n,e){n.style["transform-origin"]="top left",["","-ms-","-webkit-"].forEach(function(t){n.style[t+"transform"]=e})}var mo={__init__:["overlays"],overlays:["type",xt]};function _a(n,e,t){this._eventBus=n,this._canvas=e,this._translate=t,n.on("diagram.init",function(){this._init()},this),n.on("import.done",function(i){i.error||this.update()},this),this.HTML_MARKUP='
'}_a.$inject=["eventBus","canvas","translate"];_a.prototype._init=function(){var n=this._canvas,e=this._eventBus,t=n.getContainer(),i=this._container=te(this.HTML_MARKUP);t.appendChild(i),this.nameElement=X(".dmn-definitions-name",this._container),this.idElement=X(".dmn-definitions-id",this._container),_t.bind(i,".dmn-definitions-name, .dmn-definitions-id","mousedown",function(r){r.stopPropagation()}),e.fire("definitionIdView.create",{html:i})};_a.prototype.update=function(){var n=this._canvas.getRootElement().businessObject;this.nameElement.textContent=n.name,this.idElement.textContent=n.id};function wa(n,e){function t(i,r){var o=e.getContainer();ee(o).toggle(i,r)}n.on("palette.create",function(){t("with-palette",!0)}),n.on("palette.changed",function(i){t("with-palette-two-column",i.twoColumn)})}wa.$inject=["eventBus","canvas"];var Ca={__depends__:[qe],__init__:["definitionPropertiesView","definitionPropertiesPaletteAdapter"],definitionPropertiesView:["type",_a],definitionPropertiesPaletteAdapter:["type",wa]};var ZC=[{className:"dmn-icon-decision-table",matches:function(n){var e=Ke(n);return O(e,"dmn:Decision")&&O(e.decisionLogic,"dmn:DecisionTable")},title:"Open decision table"},{className:"dmn-icon-literal-expression",matches:function(n){var e=dr(n);return O(e,"dmn:LiteralExpression")},title:"Open literal expression"}],Ea=class{constructor(e,t,i,r,o){this._injector=e,this._eventBus=t,this._overlays=i,this._translate=o,this._config=r||{enabled:!0},t.on(["shape.added"],({element:s})=>{for(let l=0;l{o.fire("drillDown.click",{element:e})!==!1&&this.drillDown(e)})}drillDown(e){let t=this._injector.get("_parent",!1);if(!t)return!1;let i=t.getView(e.businessObject);return i?(t.open(i),!0):!1}};Ea.$inject=["injector","eventBus","overlays","config.drillDown","translate"];var JC={__depends__:[mo,qe],__init__:["drillDown"],drillDown:["type",Ea]};function Et(n){this._container=this._createContainer(),Wv(this._container),this._init(this._container,n)}fe(Et,mr);Et.prototype.saveSVG=ha(function(n){var e=this;return new Promise(function(t){var i=e.get("canvas"),r=i.getActiveLayer(),o=X("defs",i._svg),s=w1(r),a=o&&o.outerHTML||"",l=r.getBBox(),c=` '+a+s+"";t({svg:c})})});Et.prototype.getModules=function(){return this._modules};Et.prototype.destroy=function(){mr.prototype.destroy.call(this),Qe(this._container)};Et.prototype.on=function(n,e,t,i){return this.get("eventBus").on(n,e,t,i)};Et.prototype.off=function(n,e){this.get("eventBus").off(n,e)};Et.prototype._init=function(n,e){var{additionalModules:t,canvas:i,...r}=e,o=e.modules||this.getModules(),s=[{drd:["value",this]}],a=[...s,...o,...t||[]],l={...r,canvas:{...i,container:n},modules:a};mr.call(this,l),e&&e.container&&this.attachTo(e.container)};Et.prototype._emit=function(n,e){return this.get("eventBus").fire(n,e)};Et.prototype._createContainer=function(){return te('
')};Et.prototype.open=function(n){var e=this;return new Promise((t,i)=>{var r;try{return e._definitions&&e.clear(),e._definitions=n,aC(e,n,function(o,s){o?(o.warnings=s||[],i(o)):t({warnings:s||[]})})}catch(o){r=o}r?(r.warnings=r.warnings||[],i(r)):t({warnings:[]})})};Et.prototype.attachTo=function(n){if(!n)throw new Error("parentNode required");this.detach();var e=this._container;n.appendChild(e),this._emit("attach",{}),this.get("canvas").resized()};Et.prototype.detach=function(){var n=this._container,e=n.parentNode;e&&(this._emit("detach",{}),e.removeChild(n))};Et.prototype._modules=[HC,qe,ht,mo,Ca,JC];function Yv(n){return{x:n.x+n.width/2,y:n.y+n.height/2}}function xr(n,e){return{x:n.x-e.x,y:n.y-e.y}}function pf(n){return Math.log(n)/Math.log(10)}function Zv(n,e){var t=pf(n.min),i=pf(n.max),r=Math.abs(t)+Math.abs(i);return r/e}function eE(n,e){return Math.max(n.min,Math.min(n.max,e))}var e$=Math.sign||function(n){return n>=0?1:-1},Jv={min:.2,max:4},tE=10,t$=.1,n$=.75;function Qn(n,e,t){n=n||{},this._enabled=!1,this._canvas=t,this._container=t._container,this._handleWheel=at(this._handleWheel,this),this._totalDelta=0,this._scale=n.scale||n$;var i=this;e.on("canvas.mouseover",function(){i._init(n.enabled!==!1)}),e.on("canvas.mouseout",function(){i._init(!1)})}Qn.$inject=["config.zoomScroll","eventBus","canvas"];Qn.prototype.scroll=function(e){this._canvas.scroll(e)};Qn.prototype.reset=function(){this._canvas.zoom("fit-viewport")};Qn.prototype.zoom=function(e,t){var i=Zv(Jv,tE*2);this._totalDelta+=e,Math.abs(this._totalDelta)>t$&&(this._zoom(e,t,i),this._totalDelta=0)};Qn.prototype._handleWheel=function(e){if(this._enabled){var t=this._container;e.preventDefault();var i=e.ctrlKey||xp()&&e.metaKey,r=e.shiftKey,o=-1*this._scale,s;if(i?o*=e.deltaMode===0?.02:.32:o*=e.deltaMode===0?1:16,i){var a=t.getBoundingClientRect(),l={x:e.clientX-a.left,y:e.clientY-a.top};s=Math.sqrt(Math.pow(e.deltaY,2)+Math.pow(e.deltaX,2))*e$(e.deltaY)*o,this.zoom(s,l)}else r?s={dx:o*e.deltaY,dy:0}:s={dx:o*e.deltaX,dy:o*e.deltaY},this.scroll(s)}};Qn.prototype.stepZoom=function(e,t){var i=Zv(Jv,tE);this._zoom(e,t,i)};Qn.prototype._zoom=function(n,e,t){var i=this._canvas,r=n>0?1:-1,o=pf(i.zoom()),s=Math.round(o/t)*t;s+=t*r;var a=Math.pow(10,s);i.zoom(eE(Jv,a),e)};Qn.prototype.toggle=function(e){var t=this._container,i=this._handleWheel,r=this._enabled;return typeof e=="undefined"&&(e=!r),r!==e&&q[e?"bind":"unbind"](t,"wheel",i,!1),this._enabled=e,e};Qn.prototype._init=function(n){this.toggle(n)};var nE={__init__:["zoomScroll"],zoomScroll:["type",Qn]};var i$=/^djs-cursor-.*$/;function mf(n){var e=ee(document.body);e.removeMatching(i$),n&&e.add("djs-cursor-"+n)}function Sp(){mf(null)}var r$=5e3;function Op(n,e){e=e||"element.click";function t(){return!1}return n.once(e,r$,t),function(){n.off(e,t)}}var o$=15;function kp(n,e){var t;function i(a){return s(a.originalEvent)}n.on("canvas.focus.changed",function(a){a.focused?n.on("element.mousedown",500,i):n.off("element.mousedown",i)});function r(a){var l=t.start,c=t.button,u=Un(a),f=xr(u,l);if(!t.dragging&&s$(f)>o$&&(t.dragging=!0,c===0&&Op(n),mf("grab")),t.dragging){var h=t.last||t.start;f=xr(u,h),e.scroll({dx:f.x,dy:f.y}),t.last=u}a.preventDefault()}function o(a){q.unbind(document,"mousemove",r),q.unbind(document,"mouseup",o),t=null,Sp()}function s(a){if(!De(a.target,".djs-draggable")){var l=a.button;if(!(l>=2||a.ctrlKey||a.shiftKey||a.altKey))return t={button:l,start:Un(a)},q.bind(document,"mousemove",r),q.bind(document,"mouseup",o),!0}}this.isActive=function(){return!!t}}kp.$inject=["eventBus","canvas"];function s$(n){return Math.sqrt(Math.pow(n.x,2)+Math.pow(n.y,2))}var iE={__init__:["moveCanvas"],moveCanvas:["type",kp]};function Sa(n){return CSS.escape(n)}var a$={"&":"&","<":"<",">":">",'"':""","'":"'"};function rE(n){return n=""+n,n&&n.replace(/[&<>"']/g,function(e){return a$[e]})}var oE=["c","C"],sE=["v","V"],l$=["d","D"],c$=["x","X"],aE=["y","Y"],ex=["z","Z"];function lE(n){return n.ctrlKey||n.metaKey||n.shiftKey||n.altKey}function Mt(n){return n.altKey?!1:n.ctrlKey||n.metaKey}function Ve(n,e){return n=F(n)?n:[n],n.indexOf(e.key)!==-1||n.indexOf(e.code)!==-1}function Rp(n){return n.shiftKey}function cE(n){return Mt(n)&&Ve(oE,n)}function uE(n){return Mt(n)&&Ve(sE,n)}function fE(n){return Mt(n)&&Ve(l$,n)}function hE(n){return Mt(n)&&Ve(c$,n)}function Tp(n){return Mt(n)&&!Rp(n)&&Ve(ex,n)}function Ap(n){return Mt(n)&&(Ve(aE,n)||Ve(ex,n)&&Rp(n))}var pE=300;function J(n,e,t,i){this._open=!1,this._results={},this._eventMaps=[],this._cachedRootElement=null,this._cachedSelection=null,this._cachedViewbox=null,this._canvas=n,this._eventBus=e,this._selection=t,this._translate=i,this._container=this._getBoxHtml(),this._searchInput=X(J.INPUT_SELECTOR,this._container),this._resultsContainer=X(J.RESULTS_CONTAINER_SELECTOR,this._container),this._canvas.getContainer().appendChild(this._container),e.on(["canvas.destroy","diagram.destroy","drag.init","elements.changed"],this.close,this)}J.$inject=["canvas","eventBus","selection","translate"];J.prototype._bindEvents=function(){var n=this;function e(t,i,r,o){n._eventMaps.push({el:t,type:r,listener:_t.bind(t,i,r,o)})}e(document,"html","click",function(t){n.close(!1)}),e(this._container,J.INPUT_SELECTOR,"click",function(t){t.stopPropagation(),t.delegateTarget.focus()}),e(this._container,J.RESULT_SELECTOR,"mouseover",function(t){t.stopPropagation(),n._scrollToNode(t.delegateTarget),n._preselect(t.delegateTarget)}),e(this._container,J.RESULT_SELECTOR,"click",function(t){t.stopPropagation(),n._select(t.delegateTarget)}),e(this._container,J.INPUT_SELECTOR,"keydown",function(t){Ve("ArrowUp",t)&&t.preventDefault(),Ve("ArrowDown",t)&&t.preventDefault()}),e(this._container,J.INPUT_SELECTOR,"keyup",function(t){if(Ve("Escape",t))return n.close();if(Ve("Enter",t)){var i=n._getCurrentResult();return i?n._select(i):n.close(!1)}if(Ve("ArrowUp",t))return n._scrollToDirection(!0);if(Ve("ArrowDown",t))return n._scrollToDirection();Ve(["ArrowLeft","ArrowRight"],t)||n._search(t.delegateTarget.value)})};J.prototype._unbindEvents=function(){this._eventMaps.forEach(function(n){_t.unbind(n.el,n.type,n.listener)})};J.prototype._search=function(n){var e=this;if(this._clearResults(),!!n.trim()){var t=this._searchProvider.find(n);if(t=t.filter(function(r){return!e._canvas.getRootElements().includes(r.element)}),!t.length){this._selection.select(null);return}t.forEach(function(r){var o=r.element.id,s=e._createResultNode(r,o);e._results[o]={element:r.element,node:s}});var i=X(J.RESULT_SELECTOR,this._resultsContainer);this._scrollToNode(i),this._preselect(i)}};J.prototype._scrollToDirection=function(n){var e=this._getCurrentResult();if(e){var t=n?e.previousElementSibling:e.nextElementSibling;t&&(this._scrollToNode(t),this._preselect(t))}};J.prototype._scrollToNode=function(n){if(!(!n||n===this._getCurrentResult())){var e=n.offsetTop,t=this._resultsContainer.scrollTop,i=e-this._resultsContainer.clientHeight+n.clientHeight;e0&&dE(t,n.primaryTokens,J.RESULT_PRIMARY_HTML),dE(t,n.secondaryTokens,J.RESULT_SECONDARY_HTML),et(t,J.RESULT_ID_ATTRIBUTE,e),this._resultsContainer.appendChild(t),t};J.prototype.registerProvider=function(n){this._searchProvider=n};J.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,ee(this._canvas.getContainer()).add("djs-search-open"),ee(this._container).add("open"),this._searchInput.focus(),this._eventBus.fire("searchPad.opened"))};J.prototype.close=function(n=!0){this.isOpen()&&(n&&(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,ee(this._canvas.getContainer()).remove("djs-search-open"),ee(this._container).remove("open"),this._clearResults(),this._searchInput.value="",this._searchInput.blur(),this._eventBus.fire("searchPad.closed"),this._canvas.restoreFocus())};J.prototype.toggle=function(){this.isOpen()?this.close():this.open()};J.prototype.isOpen=function(){return this._open};J.prototype._preselect=function(n){var e=this._getCurrentResult();if(n!==e){e&&ee(e).remove(J.RESULT_SELECTED_CLASS);var t=et(n,J.RESULT_ID_ATTRIBUTE),i=this._results[t].element;ee(n).add(J.RESULT_SELECTED_CLASS),this._canvas.scrollToElement(i,{top:pE}),this._selection.select(i),this._eventBus.fire("searchPad.preselected",i)}};J.prototype._select=function(n){var e=et(n,J.RESULT_ID_ATTRIBUTE),t=this._results[e].element;this._cachedSelection=null,this._cachedViewbox=null,this.close(!1),this._canvas.scrollToElement(t,{top:pE}),this._selection.select(t),this._eventBus.fire("searchPad.selected",t)};J.prototype._getBoxHtml=function(){let n=te(J.BOX_HTML),e=X(J.INPUT_SELECTOR,n);return e&&e.setAttribute("aria-label",this._translate("Search in diagram")),n};function dE(n,e,t){var i=u$(e),r=te(t);r.innerHTML=i,n.appendChild(r)}function u$(n){var e="";return n.forEach(function(t){var i=rE(t.value||t.matched||t.normal),r=t.match||t.matched;r?e+=''+i+"":e+=i}),e!==""?e:null}J.CONTAINER_SELECTOR=".djs-search-container";J.INPUT_SELECTOR=".djs-search-input input";J.RESULTS_CONTAINER_SELECTOR=".djs-search-results";J.RESULT_SELECTOR=".djs-search-result";J.RESULT_SELECTED_CLASS="djs-search-result-selected";J.RESULT_SELECTED_SELECTOR="."+J.RESULT_SELECTED_CLASS;J.RESULT_ID_ATTRIBUTE="data-result-id";J.RESULT_HIGHLIGHT_CLASS="djs-search-highlight";J.BOX_HTML=`
`;J.RESULT_HTML='
';J.RESULT_PRIMARY_HTML='
';J.RESULT_SECONDARY_HTML='

';var mE={__depends__:[qe,mo,ht],searchPad:["type",J]};function gE(n){if(O(n,"dmn:Decision")||O(n,"dmn:BusinessKnowledgeModel")||O(n,"dmn:InputData")||O(n,"dmn:KnowledgeSource"))return"name";if(O(n,"dmn:TextAnnotation"))return"text"}function fs(n){var e=n.businessObject,t=gE(e);if(t)return e[t]||""}function yE(n,e,t){var i=n.businessObject,r=gE(i);return r&&(i[r]=e),t&&(n.hidden=!e),n}function gf(n,e,t){this._elementRegistry=n,this._canvas=t,e.registerProvider(this)}gf.$inject=["elementRegistry","searchPad","canvas"];gf.prototype.find=function(n){let e=this._canvas.getRootElement(),t=this._elementRegistry.filter(function(i){return!i.labelTarget});return t=Ee(t,function(i){return i!==e}),t=Vt(t,function(i){return{primaryTokens:xE(fs(i),n),secondaryTokens:xE(i.id,n),element:i}}),t=Ee(t,function(i){return vE(i.primaryTokens)||vE(i.secondaryTokens)}),t=Fn(t,function(i){return fs(i.element)+i.element.id}),t};function vE(n){return Ee(n,function(t){return!!t.matched}).length>0}function xE(n,e){let t=[],i=n;if(!n)return t;n=n.toLowerCase(),e=e.toLowerCase();let r=n.indexOf(e);return r>-1?(r!==0&&t.push({normal:i.substr(0,r)}),t.push({matched:i.substr(r,e.length)}),e.length+r1&&(a=!0),h.elements.length}),a)return o[n]=tx(l).center,o;c=e[0],e=Fn(e,function(h){return h[i]+h[r]}),u=tx(e),o[n]=f(c,u)}return o};go.prototype.trigger=function(n,e){var t=this._modeling,i,r=Ee(n,function(l){return!(l.waypoints||l.host||l.labelTarget)});if(i=this._rules.allowed("elements.align",{elements:r}),F(i)&&(r=i),!(r.length<2||!i)){var o=f$[e],s=Fn(r,o),a=this._alignmentPosition(e,s);t.alignElements(s,a)}};var CE={__init__:["alignElements"],alignElements:["type",go]};var h$=10,ix=50,d$=250;function rx(n,e,t,i){for(var r;r=p$(n,t,e);)t=i(e,t,r);return t}function EE(n){return function(e,t,i){var r={x:t.x,y:t.y};return["x","y"].forEach(function(o){var s=n[o];if(s){var a=o==="x"?"width":"height",l=s.margin,c=s.minDistance;l<0?r[o]=Math.min(i[o]+l-e[a]/2,t[o]-c+l):r[o]=Math.max(i[o]+i[a]+l+e[a]/2,t[o]+c+l)}}),r}}function p$(n,e,t){var i={x:e.x-t.width/2,y:e.y-t.height/2,width:t.width,height:t.height},r=m$(n);return ye(r,function(o){if(o===t)return!1;var s=vt(o,i,h$);return s==="intersect"})}function SE(n,e){e||(e={});function t(p){return p.source===n?1:-1}var i=e.defaultDistance||ix,r=e.direction||"e",o=e.filter,s=e.getWeight||t,a=e.maxDistance||d$,l=e.reference||"start";o||(o=v$);function c(p,m){return r==="n"?l==="start"?G(p).top-G(m).bottom:l==="center"?G(p).top-le(m).y:G(p).top-G(m).top:r==="w"?l==="start"?G(p).left-G(m).right:l==="center"?G(p).left-le(m).x:G(p).left-G(m).left:r==="s"?l==="start"?G(m).top-G(p).bottom:l==="center"?le(m).y-G(p).bottom:G(m).bottom-G(p).bottom:l==="start"?G(m).left-G(p).right:l==="center"?le(m).x-G(p).right:G(m).right-G(p).right}var u=n.incoming.filter(o).map(function(p){var m=s(p),g=m<0?c(p.source,n):c(n,p.source);return{id:p.source.id,distance:g,weight:m}}),f=n.outgoing.filter(o).map(function(p){var m=s(p),g=m>0?c(n,p.target):c(p.target,n);return{id:p.target.id,distance:g,weight:m}}),h=u.concat(f).reduce(function(p,m){return p[m.id+"__weight_"+m.weight]=m,p},{}),d=st(h,function(p,m){var g=m.distance,b=m.weight;return g<0||g>a||(p[String(g)]||(p[String(g)]=0),p[String(g)]+=1*b,(!p.distance||p[p.distance]0?a=sx:a=kE),a===sx?{x:Math.min(le(t).x-RE-Dp,G(t).left-Dp-r.width/2),y:o.y}:{x:Math.max(le(i).x+RE+Dp,G(i).right+Dp+r.width/2),y:o.y}}}function Ip(n){n.on("autoPlace",function(e){var t=e.shape,i=e.source;return AE(i,t)})}Ip.$inject=["eventBus"];var ME={__depends__:[OE],__init__:["dmnAutoPlace"],dmnAutoPlace:["type",Ip]};var PE=1500;function Lp(n,e,t){var i=this,r=t.get("dragging",!1);function o(s){if(!s.hover){var a=s.originalEvent,l=i._findTargetGfx(a),c=l&&n.get(l);l&&c&&(s.stopPropagation(),r.hover({element:c,gfx:l}),r.move(a))}}r&&e.on("drag.start",function(s){e.once("drag.move",PE,function(a){o(a)})}),(function(){var s,a;e.on("element.hover",function(l){s=l.gfx,a=l.element}),e.on("element.hover",PE,function(l){a&&e.fire("element.out",{element:a,gfx:s})}),e.on("element.out",function(){s=null,a=null})})(),this._findTargetGfx=function(s){var a,l;if(s instanceof MouseEvent)return a=Un(s),l=document.elementFromPoint(a.x,a.y),R$(l)}}Lp.$inject=["elementRegistry","eventBus","injector"];function R$(n){return De(n,"svg, .djs-element",!0)}var DE={__init__:["hoverFix"],hoverFix:["type",Lp]};var Oa=Math.round,IE="djs-drag-active";function hs(n){n.preventDefault()}function T$(n){return typeof TouchEvent!="undefined"&&n instanceof TouchEvent}function A$(n){return Math.sqrt(Math.pow(n.x,2)+Math.pow(n.y,2))}function Bp(n,e,t,i){var r={threshold:5,trapClick:!0},o;function s(v){var x=e.viewbox(),C=e._container.getBoundingClientRect();return{x:x.x+(v.x-C.left)/x.scale,y:x.y+(v.y-C.top)/x.scale}}function a(v,x){x=x||o;var C=n.createEvent(T({},x.payload,x.data,{isTouch:x.isTouch}));return n.fire("drag."+v,C)===!1?!1:n.fire(x.prefix+"."+v,C)}function l(v){var x=v.filter(function(C){return i.get(C.id)});x.length&&t.select(x)}function c(v,x){var C=o.payload,E=o.displacement,S=o.globalStart,w=Un(v),R=xr(w,S),A=o.localStart,I=s(w),D=xr(I,A);if(!o.active&&(x||A$(R)>o.threshold)){if(T(C,{x:Oa(A.x+E.x),y:Oa(A.y+E.y),dx:0,dy:0},{originalEvent:v}),a("start")===!1)return g();o.active=!0,o.keepSelection||(C.previousSelection=t.get(),t.select(null)),o.cursor&&mf(o.cursor),e.addMarker(e.getRootElement(),IE)}vp(v),o.active&&(T(C,{x:Oa(I.x+E.x),y:Oa(I.y+E.y),dx:Oa(D.x),dy:Oa(D.y)},{originalEvent:v}),a("move"))}function u(v){var x,C=!0;o.active&&(v&&(o.payload.originalEvent=v,vp(v)),C=a("end")),C===!1&&a("rejected"),x=b(C!==!0),a("ended",x)}function f(v){Ve("Escape",v)&&(hs(v),g())}function h(v){var x;o.active&&(x=Op(n),setTimeout(x,400),hs(v)),u(v)}function d(v){c(v)}function p(v){var x=o.payload;x.hoverGfx=v.gfx,x.hover=v.element,a("hover")}function m(v){a("out");var x=o.payload;x.hoverGfx=null,x.hover=null}function g(v){var x;if(o){var C=o.active;C&&a("cancel"),x=b(v),C&&a("canceled",x)}}function b(v){var x,C;a("cleanup"),Sp(),o.trapClick?C=h:C=u,q.unbind(document,"mousemove",c),q.unbind(document,"dragstart",hs),q.unbind(document,"selectstart",hs),q.unbind(document,"mousedown",C,!0),q.unbind(document,"mouseup",C,!0),q.unbind(document,"keyup",f),q.unbind(document,"touchstart",d,!0),q.unbind(document,"touchcancel",g,!0),q.unbind(document,"touchmove",c,!0),q.unbind(document,"touchend",u,!0),n.off("element.hover",p),n.off("element.out",m),e.removeMarker(e.getRootElement(),IE);var E=o.payload.previousSelection;return v!==!1&&E&&!t.get().length&&l(E),x=o,o=null,x}function _(v,x,C,E){o&&g(!1),typeof x=="string"&&(E=C,C=x,x=null),E=T({},r,E||{});var S=E.data||{},w,R,A,I,D;if(E.trapClick?I=h:I=u,v?(w=vr(v)||v,R=Un(v),vp(v),w.type==="dragstart"&&hs(w)):(w=null,R={x:0,y:0}),A=s(R),x||(x=A),D=T$(w),o=T({prefix:C,data:S,payload:{},globalStart:R,displacement:xr(x,A),localStart:A,isTouch:D},E),E.manual||(D?(q.bind(document,"touchstart",d,!0),q.bind(document,"touchcancel",g,!0),q.bind(document,"touchmove",c,!0),q.bind(document,"touchend",u,!0)):(q.bind(document,"mousemove",c),q.bind(document,"dragstart",hs),q.bind(document,"selectstart",hs),q.bind(document,"mousedown",I,!0),q.bind(document,"mouseup",I,!0)),q.bind(document,"keyup",f),n.on("element.hover",p),n.on("element.out",m)),a("init")===!1)return g(),!1;E.autoActivate&&c(v,!0)}n.on("diagram.destroy",g),this.init=_,this.move=c,this.hover=p,this.out=m,this.end=u,this.cancel=g,this.context=function(){return o},this.setOptions=function(v){T(r,v)}}Bp.$inject=["eventBus","canvas","selection","elementRegistry"];var gn={__depends__:[DE,ht],dragging:["type",Bp]};function yo(n,e,t){this._canvas=t,this._opts=T({scrollThresholdIn:[20,20,20,20],scrollThresholdOut:[0,0,0,0],scrollRepeatTimeout:15,scrollStep:10},n);var i=this;e.on("drag.move",function(r){var o=i._toBorderPoint(r);i.startScroll(o)}),e.on(["drag.cleanup"],function(){i.stopScroll()})}yo.$inject=["config.autoScroll","eventBus","canvas"];yo.prototype.startScroll=function(n){var e=this._canvas,t=this._opts,i=this,r=e.getContainer().getBoundingClientRect(),o=[n.x,n.y,r.width-n.x,r.height-n.y];this.stopScroll();for(var s=0,a=0,l=0;l<4;l++)M$(o[l],t.scrollThresholdOut[l],t.scrollThresholdIn[l])&&(l===0?s=t.scrollStep:l==1?a=t.scrollStep:l==2?s=-t.scrollStep:l==3&&(a=-t.scrollStep));(s!==0||a!==0)&&(e.scroll({dx:s,dy:a}),this._scrolling=setTimeout(function(){i.startScroll(n)},t.scrollRepeatTimeout))};function M$(n,e,t){return eE-3&&(R=vt(d.target,C),m===E-2?R==="intersect"&&(v.pop(),v[v.length-1]=C):R!=="intersect"&&v.push(b)),h.newWaypoints=d.waypoints=a(d,v),c(h,S,f),h.newSegmentStartIndex=p+S,l(f)}),e.on("connectionSegment.move.hover",function(f){f.context.hover=f.hover,t.addMarker(f.hover,UE)}),e.on(["connectionSegment.move.out","connectionSegment.move.cleanup"],function(f){var h=f.context.hover;h&&t.removeMarker(h,UE)}),e.on("connectionSegment.move.cleanup",function(f){var h=f.context,d=h.connection;h.draggerGfx&&Fe(h.draggerGfx),t.removeMarker(d,QE)}),e.on(["connectionSegment.move.cancel","connectionSegment.move.end"],function(f){var h=f.context,d=h.connection;d.waypoints=h.originalWaypoints,l(f)}),e.on("connectionSegment.move.end",function(f){var h=f.context,d=h.connection,p=h.newWaypoints,m=h.newSegmentStartIndex;p=p.map(function(C){return{original:C.original,x:Math.round(C.x),y:Math.round(C.y)}});var g=u(p,m),b=g.waypoints,_=a(d,b),v=g.segmentOffset,x={segmentMove:{segmentStartIndex:h.segmentStartIndex,newSegmentStartIndex:m+v}};o.updateWaypoints(d,_,x)})}Hp.$inject=["injector","eventBus","canvas","dragging","graphicsFactory","modeling"];var Q$=Math.abs,YE=Math.round;function ZE(n,e,t){t=t===void 0?10:t;var i,r;for(i=0;io-fx)return s-l+o}return s}function t(o,s){if(o.waypoints)return jE(s,o);if(o.width)return{x:tS(o.width/2+o.x),y:tS(o.height/2+o.y)}}function i(o){var s=o.context,a=s.snapPoints,l=s.connection,c=l.waypoints,u=s.segmentStart,f=s.segmentStartIndex,h=s.segmentEnd,d=s.segmentEndIndex,p=s.axis;if(a)return a;var m=[c[f-1],u,h,c[d+1]];return f<2&&m.unshift(t(l.source,o)),d>c.length-3&&m.unshift(t(l.target,o)),s.snapPoints=a={horizontal:[],vertical:[]},k(m,function(g){g&&(g=g.original||g,p==="y"&&a.horizontal.push(g.y),p==="x"&&a.vertical.push(g.x))}),a}n.on("connectionSegment.move.move",1500,function(o){var s=i(o),a=o.x,l=o.y,c,u;if(s){c=e(s.vertical,a),u=e(s.horizontal,l);var f=a-c,h=l-u;T(o,{dx:o.dx-f,dy:o.dy-h,x:c,y:u}),(f||s.vertical.indexOf(a)!==-1)&&vn(o,"x",c),(h||s.horizontal.indexOf(l)!==-1)&&vn(o,"y",u)}});function r(o){var s=o.snapPoints,a=o.connection.waypoints,l=o.bendpointIndex;if(s)return s;var c=[a[l-1],a[l+1]];return o.snapPoints=s={horizontal:[],vertical:[]},k(c,function(u){u&&(u=u.original||u,s.horizontal.push(u.y),s.vertical.push(u.x))}),s}n.on(["connect.hover","connect.move","connect.end"],1500,function(o){var s=o.context,a=s.hover,l=a&&t(a,o);!Xe(a)||!l||!l.x||!l.y||(vn(o,"x",l.x),vn(o,"y",l.y))}),n.on(["bendpoint.move.move","bendpoint.move.end"],1500,function(o){var s=o.context,a=r(s),l=s.hover,c=l&&t(l,o),u=o.x,f=o.y,h,d;if(a){h=e(c?a.vertical.concat([c.x]):a.vertical,u),d=e(c?a.horizontal.concat([c.y]):a.horizontal,f);var p=u-h,m=f-d;T(o,{dx:o.dx-p,dy:o.dy-m,x:o.x-p,y:o.y-m}),(p||a.vertical.indexOf(u)!==-1)&&vn(o,"x",h),(m||a.horizontal.indexOf(f)!==-1)&&vn(o,"y",d)}})}Wp.$inject=["eventBus"];var nS={__depends__:[gn,yn],__init__:["bendpoints","bendpointSnapping","bendpointMovePreview"],bendpoints:["type",Fp],bendpointMove:["type",wf],bendpointMovePreview:["type",Vp],connectionSegmentMove:["type",Hp],bendpointSnapping:["type",Wp]};var G$=new po;function vo(n){this._scheduled={},n.on("diagram.destroy",()=>{Object.keys(this._scheduled).forEach(e=>{this.cancel(e)})})}vo.$inject=["eventBus"];vo.prototype.schedule=function(n,e=G$.next()){this.cancel(e);let t=this._schedule(n,e);return this._scheduled[e]=t,t.promise};vo.prototype._schedule=function(n,e){let t=X$();return{executionId:setTimeout(()=>{try{this._scheduled[e]=null;try{t.resolve(n())}catch(r){t.reject(r)}}catch(r){console.error("Scheduler#_schedule execution failed",r)}}),promise:t.promise}};vo.prototype.cancel=function(n){let e=this._scheduled[n];e&&(this._cancel(e),this._scheduled[n]=null)};vo.prototype._cancel=function(n){clearTimeout(n.executionId)};function X$(){let n={};return n.promise=new Promise((e,t)=>{n.resolve=e,n.reject=t}),n}var iS={scheduler:["type",vo]};var Y$="djs-element-hidden",Up=".entry",Z$=1e3,rS=8,J$=300;function tt(n,e,t,i){this._canvas=n,this._elementRegistry=e,this._eventBus=t,this._scheduler=i,this._current=null,this._init()}tt.$inject=["canvas","elementRegistry","eventBus","scheduler"];tt.prototype._init=function(){var n=this;this._eventBus.on("selection.changed",function(e){var t=e.newSelection,i=t.length?t.length===1?t[0]:t:null;i?n.open(i,!0):n.close()}),this._eventBus.on("elements.changed",function(e){var t=e.elements,i=n._current;if(i){var r=i.target,o=F(r)?r:[r],s=o.filter(function(l){return t.includes(l)});if(s.length){n.close();var a=o.filter(function(l){return n._elementRegistry.get(l.id)});a.length&&n._updateAndOpen(a.length>1?a:a[0])}}}),this._eventBus.on("canvas.viewbox.changed",function(){n._updatePosition()}),this._eventBus.on("element.marker.update",function(e){if(n.isOpen()){var t=e.element,i=n._current,r=F(i.target)?i.target:[i.target];r.includes(t)&&n._updateVisibility()}}),this._container=this._createContainer()};tt.prototype._createContainer=function(){var n=te('
');return this._canvas.getContainer().appendChild(n),n};tt.prototype.registerProvider=function(n,e){e||(e=n,n=Z$),this._eventBus.on("contextPad.getProviders",n,function(t){t.providers.push(e)})};tt.prototype.getEntries=function(n){var e=this._getProviders(),t=F(n)?"getMultiElementContextPadEntries":"getContextPadEntries",i={};return k(e,function(r){if(ge(r[t])){var o=r[t](n);ge(o)?i=o(i):k(o,function(s,a){i[a]=s})}}),i};tt.prototype.trigger=function(n,e,t){var i=this,r,o,s=e.delegateTarget||e.target;if(!s)return e.preventDefault();if(r=et(s,"data-action"),o=e.originalEvent||e,n==="mouseover"){this._timeout=setTimeout(function(){i._mouseout=i.triggerEntry(r,"hover",o,t)},J$);return}else if(n==="mouseout"){clearTimeout(this._timeout),this._mouseout&&(this._mouseout(),this._mouseout=null);return}return this.triggerEntry(r,n,o,t)};tt.prototype.triggerEntry=function(n,e,t,i){if(this.isShown()){var r=this._current.target,o=this._current.entries,s=o[n];if(s){var a=s.action;if(this._eventBus.fire("contextPad.trigger",{entry:s,event:t})!==!1){if(ge(a)){if(e==="click")return a(t,r,i)}else if(a[e])return a[e](t,r,i);t.preventDefault()}}}};tt.prototype.open=function(n,e){if(!(!e&&this.isOpen(n))){var t=this._eventBus.fire("contextPad.open.allowed",{target:n});t!==!1&&(this.close(),this._updateAndOpen(n))}};tt.prototype._getProviders=function(){var n=this._eventBus.createEvent({type:"contextPad.getProviders",providers:[]});return this._eventBus.fire(n),n.providers};tt.prototype._updateAndOpen=function(n){var e=this.getEntries(n),t=this._createHtml(n),i;k(e,function(r,o){var s=r.group||"default",a=te(r.html||'
'),l;et(a,"data-action",o),l=X("[data-group="+Sa(s)+"]",t),l||(l=te('
'),et(l,"data-group",s),t.appendChild(l)),l.appendChild(a),r.className&&ej(a,r.className),r.title&&et(a,"title",r.title),r.imageUrl&&(i=te(""),et(i,"src",r.imageUrl),i.style.width="100%",i.style.height="100%",a.appendChild(i))}),ee(t).add("open"),this._current={entries:e,html:t,target:n},this._updatePosition(),this._updateVisibility(),this._eventBus.fire("contextPad.open",{current:this._current})};tt.prototype._createHtml=function(n){var e=this,t=te('
');return _t.bind(t,Up,"click",function(i){e.trigger("click",i)}),_t.bind(t,Up,"dragstart",function(i){e.trigger("dragstart",i)}),_t.bind(t,Up,"mouseover",function(i){e.trigger("mouseover",i)}),_t.bind(t,Up,"mouseout",function(i){e.trigger("mouseout",i)}),q.bind(t,"mousedown",function(i){i.stopPropagation()}),this._container.appendChild(t),this._eventBus.fire("contextPad.create",{target:n,pad:t}),t};tt.prototype.getPad=function(n){console.warn(new Error("ContextPad#getPad is deprecated and will be removed in future library versions, cf. https://github.com/bpmn-io/diagram-js/pull/888"));let e;return this.isOpen()&&nj(this._current.target,n)?e=this._current.html:e=this._createHtml(n),{html:e}};tt.prototype.close=function(){this.isOpen()&&(clearTimeout(this._timeout),this._container.innerHTML="",this._eventBus.fire("contextPad.close",{current:this._current}),this._current=null)};tt.prototype.isOpen=function(n){var e=this._current;if(!e)return!1;if(!n)return!0;var t=e.target;return F(n)!==F(t)?!1:F(n)?n.length===t.length&&kt(n,function(i){return t.includes(i)}):t===n};tt.prototype.isShown=function(){return this.isOpen()&&ee(this._current.html).has("open")};tt.prototype.show=function(){this.isOpen()&&(ee(this._current.html).add("open"),this._updatePosition(),this._eventBus.fire("contextPad.show",{current:this._current}))};tt.prototype.hide=function(){this.isOpen()&&(ee(this._current.html).remove("open"),this._eventBus.fire("contextPad.hide",{current:this._current}))};tt.prototype._getPosition=function(n){if(!F(n)&&Xe(n)){var e=this._canvas.viewbox(),t=tj(n),i=t.x*e.scale-e.x*e.scale,r=t.y*e.scale-e.y*e.scale;return{left:i+rS*this._canvas.zoom(),top:r}}var o=this._canvas.getContainer(),s=o.getBoundingClientRect(),a=this._getTargetBounds(n);return{left:a.right-s.left+rS*this._canvas.zoom(),top:a.top-s.top}};tt.prototype._updatePosition=function(){let n=()=>{if(this.isOpen()){var e=this._current.html,t=this._getPosition(this._current.target);"x"in t&&"y"in t?(e.style.left=t.x+"px",e.style.top=t.y+"px"):["top","right","bottom","left"].forEach(function(i){i in t&&(e.style[i]=t[i]+"px")})}};this._scheduler.schedule(n,"ContextPad#_updatePosition")};tt.prototype._updateVisibility=function(){let n=()=>{if(this.isOpen()){var e=this,t=this._current.target,i=F(t)?t:[t],r=i.some(function(o){return e._canvas.hasMarker(o,Y$)});r?e.hide():e.show()}};this._scheduler.schedule(n,"ContextPad#_updateVisibility")};tt.prototype._getTargetBounds=function(n){var e=this,t=F(n)?n:[n],i=t.map(function(r){return e._canvas.getGraphics(r)});return i.reduce(function(r,o){let s=o.getBoundingClientRect();return r.top=Math.min(r.top,s.top),r.right=Math.max(r.right,s.right),r.bottom=Math.max(r.bottom,s.bottom),r.left=Math.min(r.left,s.left),r.x=r.left,r.y=r.top,r.width=r.right-r.left,r.height=r.bottom-r.top,r},{top:1/0,right:-1/0,bottom:-1/0,left:1/0})};function ej(n,e){var t=ee(n);e=F(e)?e:e.split(/\s+/g),e.forEach(function(i){t.add(i)})}function tj(n){return n.waypoints[n.waypoints.length-1]}function nj(n,e){return n=F(n)?n:[n],e=F(e)?e:[e],n.length===e.length&&kt(n,function(t){return e.includes(t)})}var oS={__depends__:[fo,iS,mo],contextPad:["type",tt]};function Kp(n,e,t,i){function r(s,a){return i.allowed("connection.create",{source:s,target:a})}function o(s,a){return r(a,s)}n.on("connect.hover",function(s){var a=s.context,l=a.start,c=s.hover,u;if(a.hover=c,u=a.canExecute=r(l,c),!Yr(u)){if(u!==!1){a.source=l,a.target=c;return}u=a.canExecute=o(l,c),!Yr(u)&&u!==!1&&(a.source=c,a.target=l)}}),n.on(["connect.out","connect.cleanup"],function(s){var a=s.context;a.hover=null,a.source=null,a.target=null,a.canExecute=!1}),n.on("connect.end",function(s){var a=s.context,l=a.canExecute,c=a.connectionStart,u={x:s.x,y:s.y},f=a.source,h=a.target;if(!l)return!1;var d=null,p={connectionStart:Qp(a)?u:c,connectionEnd:Qp(a)?c:u};Pe(l)&&(d=l),a.connection=t.connect(f,h,d,p)}),this.start=function(s,a,l,c){Pe(l)||(c=l,l=le(a)),e.init(s,"connect",{autoActivate:c,data:{shape:a,context:{start:a,connectionStart:l}}})}}Kp.$inject=["eventBus","dragging","modeling","rules"];function Qp(n){var e=n.hover,t=n.source,i=n.target;return e&&t&&e===t&&t!==i}var ij=1100,rj=900,sS="connect-ok",aS="connect-not-ok";function Gp(n,e,t){var i=n.get("connectionPreview",!1);i&&e.on("connect.move",function(r){var o=r.context,s=o.canExecute,a=o.hover,l=o.source,c=o.start,u=o.startPosition,f=o.target,h=o.connectionStart||u,d=o.connectionEnd||{x:r.x,y:r.y},p=h,m=d;Qp(o)&&(p=d,m=h),i.drawPreview(o,s,{source:l||c,target:f||a,connectionStart:p,connectionEnd:m})}),e.on("connect.hover",rj,function(r){var o=r.context,s=r.hover,a=o.canExecute;a!==null&&t.addMarker(s,a?sS:aS)}),e.on(["connect.out","connect.cleanup"],ij,function(r){var o=r.hover;o&&(t.removeMarker(o,sS),t.removeMarker(o,aS))}),i&&e.on("connect.cleanup",function(r){i.cleanUp(r.context)})}Gp.$inject=["injector","eventBus","canvas"];var lS={__depends__:[ht,yn,gn],__init__:["connectPreview"],connect:["type",Kp],connectPreview:["type",Gp]};var oj=new po("ps"),sj=["marker-start","marker-mid","marker-end"],aj=["circle","ellipse","line","path","polygon","polyline","path","rect"];function ji(n,e,t,i){this._elementRegistry=n,this._canvas=t,this._styles=i}ji.$inject=["elementRegistry","eventBus","canvas","styles"];ji.prototype.cleanUp=function(){console.warn("PreviewSupport#cleanUp is deprecated and will be removed in future versions. You do not need to manually clean up previews anymore. cf. https://github.com/bpmn-io/diagram-js/pull/906")};ji.prototype.getGfx=function(n){return this._elementRegistry.getGraphics(n)};ji.prototype.addDragger=function(n,e,t,i="djs-dragger"){t=t||this.getGfx(n);var r=gv(t),o=t.getBoundingClientRect();return this._cloneMarkers(ls(r),i),j(r,this._styles.cls(i,[],{x:o.top,y:o.left})),K(e,r),j(r,"data-preview-support-element-id",n.id),r};ji.prototype.addFrame=function(n,e){var t=Q("rect",{class:"djs-resize-overlay",width:n.width,height:n.height,x:n.x,y:n.y});return K(e,t),j(t,"data-preview-support-element-id",n.id),t};ji.prototype._cloneMarkers=function(n,e="djs-dragger",t=n){var i=this;n.childNodes&&n.childNodes.forEach(r=>{i._cloneMarkers(r,e,t)}),fj(n)&&sj.forEach(function(r){if(j(n,r)){var o=lj(n,r,i._canvas.getContainer());o&&i._cloneMarker(t,n,o,r,e)}})};ji.prototype._cloneMarker=function(n,e,t,i,r="djs-dragger"){var o=[t.id,r,oj.next()].join("-"),s=X("marker#"+t.id,n);n=n||this._canvas._svg;var a=s||gv(t);a.id=o,ne(a).add(r);var l=X(":scope > defs",n);l||(l=Q("defs"),K(n,l)),K(l,a);var c=uj(a.id);j(e,i,c)};function lj(n,e,t){var i=cj(j(n,e));return X("marker#"+i,t||document)}function cj(n){return n.match(/url\(['"]?#([^'"]*)['"]?\)/)[1]}function uj(n){return"url(#"+n+")"}function fj(n){return aj.indexOf(n.nodeName)!==-1}var ka={__init__:["previewSupport"],previewSupport:["type",ji]};var hj="drop-ok",cS="drop-not-ok",uS="attach-ok",fS="new-parent",hS="create",dj=2e3;function Xp(n,e,t,i,r){function o(l,c,u,f,h){if(!c)return!1;l=Ee(l,function(_){var v=_.labelTarget;return!_.parent&&!(Bi(_)&&l.indexOf(v)!==-1)});var d=ye(l,function(_){return!Xe(_)}),p=!1,m=!1,g=!1;pS(l)&&(p=r.allowed("shape.attach",{position:u,shape:d,target:c})),p||(pS(l)?g=r.allowed("shape.create",{position:u,shape:d,source:f,target:c}):g=r.allowed("elements.create",{elements:l,position:u,target:c}));var b=h.connectionTarget;return g||p?(d&&f&&(m=r.allowed("connection.create",{source:b===f?d:f,target:b===f?f:d,hints:{targetParent:c,targetAttach:p}})),{attach:p,connect:m}):g===null||p===null?null:!1}function s(l,c){[uS,hj,cS,fS].forEach(function(u){u===c?n.addMarker(l,u):n.removeMarker(l,u)})}t.on(["create.move","create.hover"],function(l){var c=l.context,u=c.elements,f=l.hover,h=c.source,d=c.hints||{};if(!f){c.canExecute=!1,c.target=null;return}dS(l);var p={x:l.x,y:l.y},m=c.canExecute=f&&o(u,f,p,h,d);f&&m!==null&&(c.target=f,m&&m.attach?s(f,uS):s(f,m?fS:cS))}),t.on(["create.end","create.out","create.cleanup"],function(l){var c=l.hover;c&&s(c,null)}),t.on("create.end",function(l){var c=l.context,u=c.source,f=c.shape,h=c.elements,d=c.target,p=c.canExecute,m=p&&p.attach,g=p&&p.connect,b=c.hints||{};if(p===!1||!d)return!1;dS(l);var _={x:l.x,y:l.y};g?f=i.appendShape(u,f,_,d,{attach:m,connection:g===!0?{}:g,connectionTarget:b.connectionTarget}):(h=i.createElements(h,_,d,T({},b,{attach:m})),f=ye(h,function(v){return!Xe(v)})),T(c,{elements:h,shape:f}),T(l,{elements:h,shape:f})});function a(){var l=e.context();l&&l.prefix===hS&&e.cancel()}t.on("create.init",function(){t.on("elements.changed",a),t.once(["create.cancel","create.end"],dj,function(){t.off("elements.changed",a)})}),this.start=function(l,c,u){F(c)||(c=[c]);var f=ye(c,function(p){return!Xe(p)});if(f){u=T({elements:c,hints:{},shape:f},u||{}),k(c,function(p){se(p.x)||(p.x=0),se(p.y)||(p.y=0)});var h=Ee(c,function(p){return!p.hidden}),d=Tt(h);k(c,function(p){Xe(p)&&(p.waypoints=Vt(p.waypoints,function(m){return{x:m.x-d.x-d.width/2,y:m.y-d.y-d.height/2}})),T(p,{x:p.x-d.x-d.width/2,y:p.y-d.y-d.height/2})}),e.init(l,hS,{cursor:"grabbing",autoActivate:!0,data:{shape:f,elements:c,context:u}})}}}Xp.$inject=["canvas","dragging","eventBus","modeling","rules"];function dS(n){var e=n.context,t=e.createConstraints;t&&(t.left&&(n.x=Math.max(n.x,t.left)),t.right&&(n.x=Math.min(n.x,t.right)),t.top&&(n.y=Math.max(n.y,t.top)),t.bottom&&(n.y=Math.min(n.y,t.bottom)))}function pS(n){return n&&n.length===1&&!Xe(n[0])}var pj=750;function Yp(n,e,t,i,r){function o(s){var a=Q("g");j(a,r.cls("djs-drag-group",["no-events"]));var l=Q("g");return s.forEach(function(c){var u;c.hidden||(c.waypoints?(u=t._createContainer("connection",l),t.drawConnection(ls(u),c)):(u=t._createContainer("shape",l),t.drawShape(ls(u),c),jt(u,c.x,c.y)),i.addDragger(c,a,u))}),a}e.on("create.move",pj,function(s){var a=s.hover,l=s.context,c=l.elements,u=l.dragGroup;u||(u=l.dragGroup=o(c));var f;a?(u.parentNode||(f=n.getActiveLayer(),K(f,u)),jt(u,s.x,s.y)):Fe(u)}),e.on("create.cleanup",function(s){var a=s.context,l=a.dragGroup;l&&Fe(l)})}Yp.$inject=["canvas","eventBus","graphicsFactory","previewSupport","styles"];var Zp={__depends__:[gn,ka,yn,ht],__init__:["create","createPreview"],create:["type",Xp],createPreview:["type",Yp]};var om,He,xS,mj,xo,mS,bS,_S,hx,em,Ef,wS,gx,dx,px,gj,nm={},im=[],yj=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,sm=Array.isArray;function Cr(n,e){for(var t in e)n[t]=e[t];return n}function yx(n){n&&n.parentNode&&n.parentNode.removeChild(n)}function am(n,e,t){var i,r,o,s={};for(o in e)o=="key"?i=e[o]:o=="ref"?r=e[o]:s[o]=e[o];if(arguments.length>2&&(s.children=arguments.length>3?om.call(arguments,2):t),typeof n=="function"&&n.defaultProps!=null)for(o in n.defaultProps)s[o]===void 0&&(s[o]=n.defaultProps[o]);return tm(n,s,i,r,null)}function tm(n,e,t,i,r){var o={type:n,props:e,key:t,ref:i,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:r==null?++xS:r,__i:-1,__u:0};return r==null&&He.vnode!=null&&He.vnode(o),o}function lm(n){return n.children}function Sf(n,e){this.props=n,this.context=e}function Ra(n,e){if(e==null)return n.__?Ra(n.__,n.__i+1):null;for(var t;ee&&xo.sort(_S),n=xo.shift(),e=xo.length,vj(n)}finally{xo.length=rm.__r=0}}function ES(n,e,t,i,r,o,s,a,l,c,u){var f,h,d,p,m,g,b,_=i&&i.__k||im,v=e.length;for(l=xj(t,e,_,l,v),f=0;f0?s=n.__k[o]=tm(s.type,s.props,s.key,s.ref?s.ref:null,s.__v):n.__k[o]=s,l=o+h,s.__=n,s.__b=n.__b+1,a=null,(c=s.__i=bj(s,t,l,f))!=-1&&(f--,(a=t[c])&&(a.__u|=2)),a==null||a.__v==null?(c==-1&&(r>u?h--:rl?h--:h++,s.__u|=4))):n.__k[o]=null;if(f)for(o=0;o(u?1:0)){for(r=t-1,o=t+1;r>=0||o=0?r--:o++])!=null&&(2&c.__u)==0&&a==c.key&&l==c.type)return s}return-1}function yS(n,e,t){e[0]=="-"?n.setProperty(e,t==null?"":t):n[e]=t==null?"":typeof t!="number"||yj.test(e)?t:t+"px"}function Jp(n,e,t,i,r){var o,s;e:if(e=="style")if(typeof t=="string")n.style.cssText=t;else{if(typeof i=="string"&&(n.style.cssText=i=""),i)for(e in i)t&&e in t||yS(n.style,e,"");if(t)for(e in t)i&&t[e]==i[e]||yS(n.style,e,t[e])}else if(e[0]=="o"&&e[1]=="n")o=e!=(e=e.replace(wS,"$1")),s=e.toLowerCase(),e=s in n||e=="onFocusOut"||e=="onFocusIn"?s.slice(2):e.slice(2),n.l||(n.l={}),n.l[e+o]=t,t?i?t[Ef]=i[Ef]:(t[Ef]=gx,n.addEventListener(e,o?px:dx,o)):n.removeEventListener(e,o?px:dx,o);else{if(r=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in n)try{n[e]=t==null?"":t;break e}catch{}typeof t=="function"||(t==null||t===!1&&e[4]!="-"?n.removeAttribute(e):n.setAttribute(e,e=="popover"&&t==1?"":t))}}function vS(n){return function(e){if(this.l){var t=this.l[e.type+n];if(e[em]==null)e[em]=gx++;else if(e[em]0?n:sm(n)?n.map(kS):n.constructor!==void 0?null:Cr({},n)}function _j(n,e,t,i,r,o,s,a,l){var c,u,f,h,d,p,m,g=t.props||nm,b=e.props,_=e.type;if(_=="svg"?r="http://www.w3.org/2000/svg":_=="math"?r="http://www.w3.org/1998/Math/MathML":r||(r="http://www.w3.org/1999/xhtml"),o!=null){for(c=0;c=5&&((s||!h&&o===5)&&(l.push(o,0,s,r),o=6),h&&(l.push(o,h,0,r),o=6)),s=""},u=0;u"?(o=1,s=""):s=i+s[0]:a?i===a?a="":s+=i:i==='"'||i==="'"?a=i:i===">"?(c(),o=1):o&&(i==="="?(o=5,r=s,s=""):i==="/"&&(o<5||t[u][f+1]===">")?(c(),o===3&&(l=l[0]),o=l,(l=l[0]).push(2,0,o),o=0):i===" "||i===" "||i===` `||i==="\r"?(c(),o=2):s+=i),o===3&&s==="!--"&&(o=4,l=l[0])}return c(),l})(n)),e),arguments,[])).length>1?e:e[0]}var xe=MS.bind(am);var Ta,dt,bx,PS,Of=0,FS=[],bt=He,DS=bt.__b,IS=bt.__r,LS=bt.diffed,BS=bt.__c,NS=bt.unmount,$S=bt.__;function fm(n,e){bt.__h&&bt.__h(dt,n,Of||e),Of=0;var t=dt.__H||(dt.__H={__:[],__h:[]});return n>=t.__.length&&t.__.push({}),t.__[n]}function kf(n){return Of=1,qS(VS,n)}function qS(n,e,t){var i=fm(Ta++,2);if(i.t=n,!i.__c&&(i.__=[t?t(e):VS(void 0,e),function(a){var l=i.__N?i.__N[0]:i.__[0],c=i.t(l,a);l!==c&&(i.__N=[c,i.__[1]],i.__c.setState({}))}],i.__c=dt,!dt.__f)){var r=function(a,l,c){if(!i.__c.__H)return!0;var u=i.__c.__H.__.filter(function(h){return h.__c});if(u.every(function(h){return!h.__N}))return!o||o.call(this,a,l,c);var f=i.__c.props!==a;return u.some(function(h){if(h.__N){var d=h.__[0];h.__=h.__N,h.__N=void 0,d!==h.__[0]&&(f=!0)}}),o&&o.call(this,a,l,c)||f};dt.__f=!0;var o=dt.shouldComponentUpdate,s=dt.componentWillUpdate;dt.componentWillUpdate=function(a,l,c){if(this.__e){var u=o;o=void 0,r(a,l,c),o=u}s&&s.call(this,a,l,c)},dt.shouldComponentUpdate=r}return i.__N||i.__}function Aa(n,e){var t=fm(Ta++,3);!bt.__s&&wx(t.__H,e)&&(t.__=n,t.u=e,dt.__H.__h.push(t))}function Ma(n,e){var t=fm(Ta++,4);!bt.__s&&wx(t.__H,e)&&(t.__=n,t.u=e,dt.__h.push(t))}function Pa(n){return Of=5,Kn(function(){return{current:n}},[])}function Kn(n,e){var t=fm(Ta++,7);return wx(t.__H,e)&&(t.__=n(),t.__H=e,t.__h=n),t.__}function gs(n,e){return Of=8,Kn(function(){return n},e)}function Cj(){for(var n;n=FS.shift();){var e=n.__H;if(n.__P&&e)try{e.__h.some(um),e.__h.some(_x),e.__h=[]}catch(t){e.__h=[],bt.__e(t,n.__v)}}}bt.__b=function(n){dt=null,DS&&DS(n)},bt.__=function(n,e){n&&e.__k&&e.__k.__m&&(n.__m=e.__k.__m),$S&&$S(n,e)},bt.__r=function(n){IS&&IS(n),Ta=0;var e=(dt=n.__c).__H;e&&(bx===dt?(e.__h=[],dt.__h=[],e.__.some(function(t){t.__N&&(t.__=t.__N),t.u=t.__N=void 0})):(e.__h.some(um),e.__h.some(_x),e.__h=[],Ta=0)),bx=dt},bt.diffed=function(n){LS&&LS(n);var e=n.__c;e&&e.__H&&(e.__H.__h.length&&(FS.push(e)!==1&&PS===bt.requestAnimationFrame||((PS=bt.requestAnimationFrame)||Ej)(Cj)),e.__H.__.some(function(t){t.u&&(t.__H=t.u),t.u=void 0})),bx=dt=null},bt.__c=function(n,e){e.some(function(t){try{t.__h.some(um),t.__h=t.__h.filter(function(i){return!i.__||_x(i)})}catch(i){e.some(function(r){r.__h&&(r.__h=[])}),e=[],bt.__e(i,t.__v)}}),BS&&BS(n,e)},bt.unmount=function(n){NS&&NS(n);var e,t=n.__c;t&&t.__H&&(t.__H.__.some(function(i){try{um(i)}catch(r){e=r}}),t.__H=void 0,e&&bt.__e(e,t.__v))};var jS=typeof requestAnimationFrame=="function";function Ej(n){var e,t=function(){clearTimeout(i),jS&&cancelAnimationFrame(e),setTimeout(n)},i=setTimeout(t,35);jS&&(e=requestAnimationFrame(t))}function um(n){var e=dt,t=n.__c;typeof t=="function"&&(n.__c=void 0,t()),dt=e}function _x(n){var e=dt;n.__c=n.__(),dt=e}function wx(n,e){return!n||n.length!==e.length||e.some(function(t,i){return t!==n[i]})}function VS(n,e){return typeof e=="function"?e(n):e}function Cx(n){let{navigationStack:e,setNavigationStack:t}=n,i=Kn(()=>e.length<=1?[]:e.slice(0,-1).map((s,a)=>({label:s.label,onClick:()=>t(l=>l.slice(0,a+1))})),[e,t]),r=e.length>0?()=>t([]):null,o=e.length>0?e[e.length-1].label:null;return xe`
${r&&xe` `} ${i.map((s,a)=>xe` `)} ${o&&xe` ${o} `}
`}function HS(n){var e,t,i="";if(typeof n=="string"||typeof n=="number")i+=n;else if(typeof n=="object")if(Array.isArray(n)){var r=n.length;for(e=0;eOj(e),[e]),a=c=>c.action&&!c.disabled,l=(c,u)=>{if(a(u))return t(c,u)};return xe`

${o}

${s.map(c=>xe`
    ${c.entries.map(u=>xe`
  • <${a(u)?"button":"span"} class=${kj(u,u===i)} onClick=${f=>l(f,u)} title=${u.title||u.label} data-id=${u.id} aria-disabled=${u.disabled||void 0} onMouseEnter=${()=>a(u)&&r(u)} onMouseLeave=${()=>a(u)&&r(null)} onFocus=${()=>a(u)&&r(u)} onBlur=${()=>a(u)&&r(null)} > ${u.imageUrl&&xe``||u.imageHtml&&xe`
    `} ${u.label?xe` ${u.label} `:null}
  • `)}
`)}
`}function Oj(n){return n.reduce((e,t)=>{let i=t.group||"default",r=e.find(o=>o.id===i);return r?r.entries.push(t):e.push({id:i,entries:[t]}),e},[])}function kj(n,e){return ys("entry",n.className,n.active?"active":"",n.disabled?"disabled":"",e?"selected":"")}function Sx(n){let{entry:e,selected:t,onMouseEnter:i,onMouseLeave:r,onAction:o}=n,s=(l,c)=>{if(!e.disabled)return o(l,e,c)},a=!e.entries;return xe`
  • a&&s(l,"dragstart")} draggable=${a} >
    ${e.imageUrl&&xe``||e.imageHtml&&xe`
    `} ${e.label?xe` ${e.label} `:null} ${e.documentationRef&&xe` l.stopPropagation()} title="Open element documentation" aria-label="Open element documentation" target="_blank" rel="noopener" > `} ${e.description&&xe` ${e.description} `}
    ${e.entries&&xe` `}
  • `}function Ox(n){let{selectedEntry:e,setSelectedEntry:t,groupedEntries:i,...r}=n,o=Pa();return Ma(()=>{let s=o.current;if(!s)return;let a=s.querySelector(".selected");a&&Rj(a)},[e]),xe`
    ${i.map(s=>xe` ${s.name&&xe`
    ${s.name}
    `}
      ${s.entries.map(a=>xe` <${Sx} key=${a.id} entry=${a} selected=${a===e} onMouseEnter=${()=>t(a)} onMouseLeave=${()=>t(null)} ...${r} /> `)}
    `)}
    `}function Rj(n){typeof n.scrollIntoViewIfNeeded=="function"?n.scrollIntoViewIfNeeded():n.scrollIntoView({scrollMode:"if-needed",block:"nearest"})}function kx(n){let{onClose:e,onSelect:t,className:i,headerEntries:r,position:o,title:s,width:a,scale:l,search:c,emptyPlaceholder:u,searchFn:f,entries:h,onOpened:d,onClosed:p}=n,[m,g]=kf([]);Aa(()=>{g([])},[h]);let[b,_]=kf(""),v=b.trim().length>0,x=Kn(()=>Mj(h),[h]),C=Kn(()=>Me(c)?x.length>5:!1,[c,x]),E=Kn(()=>{let re=m.length?m[m.length-1].entries:h;return C?v?f(x.filter(({searchable:me})=>me!==!1),b,{keys:["label","search","description"]}).map(({item:me})=>me):re.filter(({rank:me=0})=>me>=0):re},[C,v,x,b,f,m,h]),S=Kn(()=>v?E.length?[{id:"default",entries:E}]:[]:Pj(E),[E,v]),[w,R]=kf(E[0]),A=Pa(null);Aa(()=>{let re=A.current;re&&E.includes(re)?R(re):R(E[0]),A.current=null},[E]);let I=gs(re=>{let me=Aj(S),$e=me.indexOf(w)+re;$e<0&&($e=me.length-1),$e>=me.length&&($e=0),R(me[$e])},[S,w]),D=gs(re=>{re>0&&w&&w.entries&&g(me=>[...me,w]),re<0&&m.length>0&&(A.current=m[m.length+re],g(me=>me.slice(0,re)))},[w,m]),N=gs((re,me,Ue)=>{if(!(!me||me.disabled))return me.entries?(re.preventDefault(),D(1)):t(re,me,Ue)},[t,D]),W=gs(re=>{if(re.key==="Enter"&&w)return w.disabled?void 0:N(re,w);if(re.key==="Backspace"){let me=re.target;if(!(hr(me,"input")&&me.value!==""))return D(-1),re.preventDefault()}if(re.key==="ArrowUp")return I(-1),re.preventDefault();if(re.key==="ArrowDown")return I(1),re.preventDefault();if(re.key==="ArrowRight")return D(1),re.preventDefault();if(re.key==="ArrowLeft")return D(-1),re.preventDefault()},[w,I,D,N]),Re=gs(re=>{hr(re.target,"input")&&_(()=>re.target.value)},[_]);Aa(()=>(d(),()=>{p()}),[]);let _e=!v&&m.length>0,ue=(s||r.length>0)&&!_e;return xe` <${zS} onClose=${e} onKeyup=${Re} onKeydown=${W} className=${i} position=${o} width=${a} scale=${l} > ${ue&&xe` <${Ex} headerEntries=${r} onSelect=${t} selectedEntry=${w} setSelectedEntry=${R} title=${s} /> `} ${_e&&xe` <${Cx} navigationStack=${m} setNavigationStack=${g} /> `} ${h.length>0&&xe`
    ${C&&xe` `} ${v&&xe`
    ${E.length} ${E.length===1?"result":"results"} found
    `} <${Ox} groupedEntries=${S} selectedEntry=${w} setSelectedEntry=${R} onAction=${N} />
    `} ${u&&E.length===0&&xe`
    ${ge(u)?u(b):u}
    `} `}function zS(n){let{onClose:e,onKeydown:t,onKeyup:i,className:r,children:o,position:s}=n,a=Pa();return Ma(()=>{if(typeof s!="function")return;let l=a.current,c=s(l);l.style.left=`${c.x}px`,l.style.top=`${c.y}px`},[a.current,s]),Ma(()=>{let l=a.current;if(!l)return;(l.querySelector("input")||l).focus()},[]),Aa(()=>{let l=u=>{if(u.key==="Escape")return u.preventDefault(),e()},c=u=>{if(!De(u.target,".djs-popup",!0))return e()};return document.documentElement.addEventListener("keydown",l),document.body.addEventListener("click",c,!0),()=>{document.documentElement.removeEventListener("keydown",l),document.body.removeEventListener("click",c,!0)}},[]),xe`
    ${o}
    `}function Tj(n){return{transform:`scale(${n.scale})`,width:`${n.width}px`,"transform-origin":"top left"}}function Aj(n){let e=[];return n.forEach(t=>{t.entries.forEach(i=>{e.push(i)})}),e}function Mj(n){let e=[];function t(i){i.forEach(r=>{if(r.entries){t(r.entries);return}e.push(r)})}return t(n),e}function Pj(n){let e=[],t=o=>e.find(s=>o.id===s.id),i=o=>!!t(o),r=o=>typeof o=="string"?{id:o}:o;return n.forEach(o=>{let s=o.group?r(o.group):{id:"default"};i(s)?t(s).entries.push(o):e.push({...s,entries:[o]})}),e}var Dj="data-id",WS=["contextPad.close","canvas.viewbox.changing","commandStack.changed"],Ij=1e3;function Le(n,e,t,i){this._eventBus=e,this._canvas=t,this._search=i,this._current=null;var r=Me(n&&n.scale)?n.scale:{min:1,max:1};this._config={scale:r},e.on("diagram.destroy",()=>{this.close()}),e.on("element.changed",o=>{let s=this.isOpen()&&this._current.target;o.element===s&&this.refresh()})}Le.$inject=["config.popupMenu","eventBus","canvas","search"];Le.prototype._render=function(){let{position:n,providerId:e,entries:t,headerEntries:i,emptyPlaceholder:r,options:o}=this._current,s=US(t),a=Object.entries(i).map(([h,d])=>({id:h,...d})),l=n&&(h=>this._ensureVisible(h,n)),c=this._updateScale(this._current.container);cm(xe` <${kx} onClose=${h=>this.close(h)} onSelect=${(h,d,p)=>this.trigger(h,d,p)} position=${l} className=${e} entries=${s} headerEntries=${a} emptyPlaceholder=${r} scale=${c} onOpened=${this._onOpened.bind(this)} onClosed=${this._onClosed.bind(this)} searchFn=${this._search} ...${{...o}} /> `,this._current.container)};Le.prototype.open=function(n,e,t,i){if(!n)throw new Error("target is missing");if(!e)throw new Error("providers for <"+e+"> not found");if(!t)throw new Error("position is missing");var r=this._eventBus.fire("popupMenu.open.allowed",{target:n,providerId:e});if(r===!1)return;this.isOpen()&&this.close();let{entries:o,headerEntries:s,emptyPlaceholder:a}=this._getContext(n,e);this._current={position:t,providerId:e,target:n,entries:o,headerEntries:s,emptyPlaceholder:a,container:this._createContainer({provider:e}),options:i},this._emit("open"),this._bindAutoClose(),this._render()};Le.prototype.refresh=function(){if(!this.isOpen())return;let{target:n,providerId:e}=this._current,{entries:t,headerEntries:i,emptyPlaceholder:r}=this._getContext(n,e);this._current={...this._current,entries:t,headerEntries:i,emptyPlaceholder:r},this._emit("refresh"),this._render()};Le.prototype._getContext=function(n,e){let t=this._getProviders(e);if(!t||!t.length)throw new Error("provider for <"+e+"> not found");let i=this._getEntries(n,t),r=this._getHeaderEntries(n,t),o=this._getEmptyPlaceholder(t);return{entries:i,headerEntries:r,emptyPlaceholder:o,empty:!(Object.keys(i).length||Object.keys(r).length)}};Le.prototype.close=function(){this.isOpen()&&(this._emit("close"),this.reset(),this._canvas.restoreFocus(),this._current=null)};Le.prototype.reset=function(){let n=this._current.container;cm(null,n),Qe(n)};Le.prototype._emit=function(n,e){this._eventBus.fire(`popupMenu.${n}`,e)};Le.prototype._onOpened=function(){this._emit("opened")};Le.prototype._onClosed=function(){this._emit("closed")};Le.prototype._createContainer=function(n){var e=this._canvas,t=e.getContainer();let i=te(`
    `);return t.appendChild(i),i};Le.prototype._bindAutoClose=function(){this._eventBus.once(WS,this.close,this)};Le.prototype._unbindAutoClose=function(){this._eventBus.off(WS,this.close,this)};Le.prototype._updateScale=function(){var n=this._canvas.zoom(),e=this._config.scale,t,i,r=n;return e!==!0&&(e===!1?(t=1,i=1):(t=e.min,i=e.max),Me(t)&&ni&&(r=i)),r};Le.prototype._ensureVisible=function(n,e){var t=document.documentElement.getBoundingClientRect(),i=n.getBoundingClientRect(),r={},o=e.x,s=e.y;return e.x+i.width>t.width&&(r.x=!0),e.y+i.height>t.height&&(r.y=!0),r.x&&r.y?(o=e.x-i.width,s=e.y-i.height):r.x?(o=e.x-i.width,s=e.y):r.y&&e.yge(t.getEmptyPlaceholder));return e&&e.getEmptyPlaceholder()};Le.prototype.isOpen=function(){return!!this._current};Le.prototype.trigger=function(n,e,t="click"){if(n.preventDefault(),!e){let r=De(n.delegateTarget||n.target,".entry",!0),o=et(r,Dj);e={id:o,...this._getEntry(o)}}let i=e.action;if(this._emit("trigger",{entry:e,event:n})!==!1){if(ge(i)){if(t==="click")return i(n,e)}else if(i[t])return i[t](n,e)}};Le.prototype._getEntry=function(n){var e=this._current.entries[n]||this._current.headerEntries[n];if(!e)throw new Error("entry not found");return e};function US(n){return Object.entries(n).map(([e,t])=>{let i={id:e,...t};return i.entries&&(i.entries=US(i.entries)),i})}function Rx(n,e,t){let{keys:i}=t;if(e=e.trim().toLowerCase(),!e)throw new Error(" must not be empty");let r=e.trim().toLowerCase().split(/\s+/);return n.flatMap(o=>{let s=Lj(o,r,i);return s?{item:o,tokens:s}:[]}).sort(Bj(i))}function Lj(n,e,t){let{matchedWords:i,tokens:r}=t.reduce((o,s)=>{let a=n[s],{tokens:l,matchedWords:c}=F(a)?a.reduce((u,f)=>{let{tokens:h,matchedWords:d}=XS(f,e);return{tokens:[...u.tokens,h],matchedWords:{...u.matchedWords,...d}}},{matchedWords:{},tokens:[]}):XS(a,e);return{tokens:{...o.tokens,[s]:l},matchedWords:{...o.matchedWords,...c}}},{matchedWords:{},tokens:{}});return Object.keys(i).length!==e.length?null:r}function Bj(n){return(e,t)=>{let i=0,r=1;for(let o of n){let s=Nj(e.tokens[o],t.tokens[o]);if(s!==0){i+=s*r,r*=QS;continue}let a=$j(e.item[o],t.item[o]);if(a!==0){i+=a*r,r*=QS;continue}}return i}}function Nj(n,e){return KS(e)-KS(n)}var QS=.5,Da={FULL:131.9,START_FULL_WORD:8,START_WORD_PART:7.87,WORD_START:2.19,WORD_PART:1,NO_MATCH:-.07};function KS(n){let e=n.reduce((a,l)=>a+YS(l),0),t=n.flat(),i=t.reduce((a,l)=>a+l.value.length,0),r=t.reduce((a,l)=>a+(l.match?l.value.length:0),0),o=i?r/i:0;return e*(1+o)}function YS(n){if(F(n))return Math.max(...n.map(YS));let e=Math.log(n.value.length);return n.match?(n.start?n.end?Da.FULL:n.wordEnd?Da.START_FULL_WORD:Da.START_WORD_PART:n.wordStart?Da.WORD_START:Da.WORD_PART)*e:Da.NO_MATCH*e}function GS(n=""){return F(n)?n.join(", "):n}function $j(n,e){return GS(n).localeCompare(GS(e))}function XS(n,e){var c;if(!n)return{tokens:[],matchedWords:{}};let t=[],i={},r=e.map(jj),o=[`(?${r.join("\\s+")})`,...r].join("|"),s=new RegExp(o,"ig"),a,l=0;for(;a=s.exec(n);){let[u]=a,f=a.index,h=a.index+u.length,d=f===0,p=h===n.length,m=!!((c=a.groups)!=null&&c.all),g=d||/\s/.test(n.charAt(f-1)),b=p||/\s/.test(n.charAt(h));a.index>l&&t.push({value:n.slice(l,a.index),index:l}),t.push({value:u,index:a.index,match:!0,wordStart:g,wordEnd:b,start:d,end:p,all:m});let _=m?e:[u];for(let v of _)i[v.toLowerCase()]=!0;l=a.index+u.length}return le.removeElements(o.slice())}}}),i};vs.prototype._isDeleteAllowed=function(n){var e=this._rules.allowed("elements.delete",{elements:n});return F(e)?kt(n,t=>e.includes(t)):e};var oO={__depends__:[qe,oS,ht,lS,Zp,rO],__init__:["contextPadProvider"],contextPadProvider:["type",vs]};var Fj="djs-dragger";function pi(n,e,t,i){this._canvas=e,this._graphicsFactory=t,this._elementFactory=i,this._connectionDocking=n.get("connectionDocking",!1),this._layouter=n.get("layouter",!1)}pi.$inject=["injector","canvas","graphicsFactory","elementFactory"];pi.prototype.drawPreview=function(n,e,t){t=t||{};var i=n.connectionPreviewGfx,r=n.getConnection,o=t.source,s=t.target,a=t.waypoints,l=t.connectionStart,c=t.connectionEnd,u=t.noLayout,f=t.noCropping,h=t.noNoop,d,p=this;if(i||(i=n.connectionPreviewGfx=this.createConnectionPreviewGfx()),ss(i),r||(r=n.getConnection=qj(function(m,g,b){return p.getConnection(m,g,b)})),e&&(d=r(e,o,s)),!d){!h&&this.drawNoopPreview(i,t);return}d.waypoints=a||[],this._layouter&&!u&&(d.waypoints=this._layouter.layoutConnection(d,{source:o,target:s,connectionStart:l,connectionEnd:c,waypoints:t.waypoints||d.waypoints})),(!d.waypoints||!d.waypoints.length)&&(d.waypoints=[o?le(o):l,s?le(s):c]),this._connectionDocking&&(o||s)&&!f&&(d.waypoints=this._connectionDocking.getCroppedWaypoints(d,o,s)),this._graphicsFactory.drawConnection(i,d,{stroke:"var(--element-dragger-color)"})};pi.prototype.drawNoopPreview=function(n,e){var t=e.source,i=e.target,r=e.connectionStart||le(t),o=e.connectionEnd||le(i),s=this.cropWaypoints(r,o,t,i),a=this.createNoopConnection(s[0],s[1]);K(n,a)};pi.prototype.cropWaypoints=function(n,e,t,i){var r=this._graphicsFactory,o=t&&r.getShapePath(t),s=i&&r.getShapePath(i),a=r.getConnectionPath({waypoints:[n,e]});return n=t&&tf(o,a,!0)||n,e=i&&tf(s,a,!1)||e,[n,e]};pi.prototype.cleanUp=function(n){n&&n.connectionPreviewGfx&&Fe(n.connectionPreviewGfx)};pi.prototype.getConnection=function(n){var e=Vj(n);return this._elementFactory.createConnection(e)};pi.prototype.createConnectionPreviewGfx=function(){var n=Q("g");return j(n,{pointerEvents:"none"}),ne(n).add(Fj),K(this._canvas.getActiveLayer(),n),n};pi.prototype.createNoopConnection=function(n,e){return ro([n,e],{stroke:"#333",strokeDasharray:[1],strokeWidth:2,"pointer-events":"none"})};function qj(n){var e={};return function(t){var i=JSON.stringify(t),r=e[i];return r||(r=e[i]=n.apply(null,arguments)),r}}function Vj(n){return Pe(n)?n:{}}var sO={__init__:["connectionPreview"],connectionPreview:["type",pi]};var Hj=/\s/,zj=/^([a-z][\w-.]*:)?[a-z_][\w-.]*$/i,Wj=/^[a-z_][\w-.]*$/i,Uj=/\$\{([^}]*)\}/g;function aO(n,e){let t=n.$model.ids.assigned(e),i=t&&t!==n;return e?i?"Element must have unique ID.":Qj(e):"Element must have ID."}function Qj(n){if(n=Gj(n),Kj(n))return"Id must not contain spaces.";if(!Wj.test(n))return zj.test(n)?"Id must not contain prefix.":"Id must be a valid QName."}function Kj(n){return Hj.test(n)}function Gj(n){return n.replace(Uj,"$1")}var Xj=300;function bo(n,e,t,i,r){this._eventBus=n,this._modeling=e,this._canvas=t,this._definitionPropertiesView=i,this._translate=r,n.on("definitionIdView.create",function(o){this._container=o.html;var s=X(".dmn-definitions-name",this._container),a=X(".dmn-definitions-id",this._container);this._setup(s,"name"),this._setup(a,"id")},this)}bo.$inject=["eventBus","modeling","canvas","definitionPropertiesView","translate"];bo.prototype.update=function(n,e){var t=this._canvas.getRootElement(),i={};if(i[n]=e,n==="id"){var r=aO(Ke(t),e);if(r){this._addErrorMessage(r);return}this._clearErrorMessage()}this._modeling.updateProperties(t,i)};bo.prototype._setup=function(n,e){var t=this;n.setAttribute("contenteditable",!0),n.addEventListener("input",Mi(function(i){var r=i.target.value||i.target.textContent;t.update(e,r.trim())},Xj)),n.addEventListener("keydown",function(i){i.keyCode===13&&(n.blur(),window.getSelection().removeAllRanges())}),n.addEventListener("blur",function(){t._clearErrorMessage(),t._definitionPropertiesView.update()})};bo.prototype._addErrorMessage=function(n){let e=''+this._translate(n)+"";var t=X(".dmn-definitions-id",this._container);this._clearErrorMessage(),ee(t).add("dmn-definitions-error"),t.parentElement.appendChild(te(e))};bo.prototype._clearErrorMessage=function(){var n=X(".dmn-definitions-id",this._container);if(ee(n).has("dmn-definitions-error")){ee(n).remove("dmn-definitions-error");let e=X(".dmn-definitions-error-message",this._container);n.parentNode.removeChild(e)}};var lO={__depends__:[Ca],__init__:["definitionPropertiesEdit","definitionPropertiesPaletteAdapter"],definitionPropertiesEdit:["type",bo],definitionPropertiesPaletteAdapter:["type",wa]};var Yj={horizontal:["x","width"],vertical:["y","height"]},cO=5;function mi(n,e){this._modeling=n,this._filters=[],this.registerFilter(function(t){var i=e.allowed("elements.distribute",{elements:t});return F(i)?i:i?t:[]})}mi.$inject=["modeling","rules"];mi.prototype.registerFilter=function(n){if(typeof n!="function")throw new Error("the filter has to be a function");this._filters.push(n)};mi.prototype.trigger=function(n,e){var t=this._modeling,i,r;if(!(n.length<3)&&(this._setOrientation(e),r=this._filterElements(n),i=this._createGroups(r),!(i.length<=2)))return t.distributeElements(i,this._axis,this._dimension),i};mi.prototype._filterElements=function(n){var e=this._filters,t=this._axis,i=this._dimension,r=[].concat(n);return e.length?(k(e,function(o){r=o(r,t,i)}),r):n};mi.prototype._createGroups=function(n){var e=[],t=this,i=this._axis,r=this._dimension;if(!i)throw new Error('must have a defined "axis" and "dimension"');var o=Fn(n,i);return k(o,function(s,a){var l=t._findRange(s,i,r),c,u=e[e.length-1];u&&t._hasIntersection(u.range,l)?e[e.length-1].elements.push(s):(c={range:l,elements:[s]},e.push(c))}),e};mi.prototype._setOrientation=function(n){var e=Yj[n];this._axis=e[0],this._dimension=e[1]};mi.prototype._hasIntersection=function(n,e){return Math.max(n.min,n.max)>=Math.min(e.min,e.max)&&Math.min(n.min,n.max)<=Math.max(e.min,e.max)};mi.prototype._findRange=function(n){var e=n[this._axis],t=n[this._dimension];return{min:e+cO,max:e+t-cO}};var uO={__init__:["distributeElements"],distributeElements:["type",mi]};function pm(n){n.registerFilter(function(e){return Ee(e,function(t){var i=Ge(t,["dmn:AuthorityRequirement","dmn:InformationRequirement","dmn:KnowledgeRequirement","dmn:Association","dmn:TextAnnotation"]);return!(t.labelTarget||i)})})}pm.$inject=["distributeElements"];var fO={__depends__:[uO],__init__:["drdDistributeElements"],drdDistributeElements:["type",pm]};var hO="is not a registered action",Zj="is already registered";function sn(n,e){this._eventBus=n,this._actions={};var t=this;n.on("diagram.init",function(){t._registerDefaultActions(e),n.fire("editorActions.init",{editorActions:t})})}sn.$inject=["eventBus","injector"];sn.prototype._registerDefaultActions=function(n){var e=n.get("commandStack",!1),t=n.get("modeling",!1),i=n.get("selection",!1),r=n.get("zoomScroll",!1),o=n.get("copyPaste",!1),s=n.get("canvas",!1),a=n.get("rules",!1),l=n.get("keyboardMove",!1),c=n.get("keyboardMoveSelection",!1);e&&(this.register("undo",function(){e.undo()}),this.register("redo",function(){e.redo()})),o&&i&&this.register("copy",function(){var u=i.get();if(u.length)return o.copy(u)}),o&&i&&this.register("duplicate",function(){var u=i.get();if(u.length)return o.duplicate(u)}),o&&this.register("paste",function(){o.paste()}),o&&i&&a&&this.register("cut",function(){var u=i.get();if(u.length){var f=a.allowed("elements.delete",{elements:u});if(f!==!1){var h=F(f)?f:u;return o.cut(h.slice())}}}),r&&this.register("stepZoom",function(u){r.stepZoom(u.value)}),s&&this.register("zoom",function(u){s.zoom(u.value)}),t&&i&&a&&this.register("removeSelection",function(){var u=i.get();if(u.length){var f=a.allowed("elements.delete",{elements:u}),h;f!==!1&&(F(f)?h=f:h=u,h.length&&t.removeElements(h.slice()))}}),l&&this.register("moveCanvas",function(u){l.moveCanvas(u)}),c&&this.register("moveSelection",function(u){c.moveSelection(u.direction,u.accelerated)})};sn.prototype.trigger=function(n,e){if(!this._actions[n])throw Ax(n,hO);var t=this._eventBus.fire("editorActions.allowed",{action:n,opts:e});if(t!==!1)return this._actions[n](e)};sn.prototype.register=function(n,e){var t=this;if(typeof n=="string")return this._registerAction(n,e);k(n,function(i,r){t._registerAction(r,i)})};sn.prototype._registerAction=function(n,e){if(this.isRegistered(n))throw Ax(n,Zj);this._actions[n]=e};sn.prototype.unregister=function(n){if(!this.isRegistered(n))throw Ax(n,hO);this._actions[n]=void 0};sn.prototype.getActions=function(){return Object.keys(this._actions)};sn.prototype.isRegistered=function(n){return!!this._actions[n]};function Ax(n,e){return new Error(n+" "+e)}var dO={__init__:["editorActions"],editorActions:["type",sn]};function Ia(n){n.invoke(sn,this)}fe(Ia,sn);Ia.$inject=["injector"];Ia.prototype._registerDefaultActions=function(n){sn.prototype._registerDefaultActions.call(this,n);let e=n.get("canvas",!1),t=n.get("elementRegistry",!1),i=n.get("selection",!1),r=n.get("lassoTool",!1),o=n.get("handTool",!1),s=n.get("directEditing",!1),a=n.get("distributeElements",!1),l=n.get("alignElements",!1),c=n.get("searchPad",!1);e&&t&&i&&this._registerAction("selectElements",function(){var u=e.getRootElement(),f=t.filter(function(h){return h!==u});return i.select(f),f}),i&&a&&this._registerAction("distributeElements",function(u){var f=i.get(),h=u.type;f.length>2&&a.trigger(f,h)}),i&&l&&this._registerAction("alignElements",function(u){var f=i.get(),h=u.type;f.length>1&&l.trigger(f,h)}),r&&this._registerAction("lassoTool",function(){r.toggle()}),o&&this._registerAction("handTool",function(){o.toggle()}),i&&s&&this._registerAction("directEditing",function(){var u=i.get();u.length&&s.activate(u[0])}),i&&c&&this._registerAction("find",function(){c.toggle()})};var pO={__depends__:[dO],editorActions:["type",Ia]};function La(n){return n.dmnDI&&n.dmnDI.diagrams&&n.dmnDI.diagrams[0]}function mm(n,e,t,i){function r(o){var s=o.dmnDI;s||(s=n.create("dmndi:DMNDI"),o.set("dmnDI",s));var a=n.create("dmndi:DMNDiagram");s.set("diagrams",[a]);var l=0;k(o.get("drgElement"),function(c){if(O(c,"dmn:Decision")){var u=e._getDefaultSize(c),f=n.createDiShape(c,{x:150+l*30,y:150+l*30,width:u.width,height:u.height});i.updateDiParent(f,a),l++}})}t.on("import.start",({definitions:o})=>{La(o)||r(o)})}mm.$inject=["drdFactory","elementFactory","eventBus","drdUpdater"];var mO={__init__:["diGenerator"],diGenerator:["type",mm]};var Jj=1e3;function ae(n){this._eventBus=n}ae.$inject=["eventBus"];function eF(n,e){return function(t){return n.call(e||null,t.context,t.command,t)}}ae.prototype.on=function(n,e,t,i,r,o){if((ge(e)||se(e))&&(o=r,r=i,i=t,t=e,e=null),ge(t)&&(o=r,r=i,i=t,t=Jj),Pe(r)&&(o=r,r=!1),!ge(i))throw new Error("handlerFn must be a function");F(n)||(n=[n]);var s=this._eventBus;k(n,function(a){var l=["commandStack",a,e].filter(function(c){return c}).join(".");s.on(l,t,r?eF(i,o):i,o)})};ae.prototype.canExecute=Sr("canExecute");ae.prototype.preExecute=Sr("preExecute");ae.prototype.preExecuted=Sr("preExecuted");ae.prototype.execute=Sr("execute");ae.prototype.executed=Sr("executed");ae.prototype.postExecute=Sr("postExecute");ae.prototype.postExecuted=Sr("postExecuted");ae.prototype.revert=Sr("revert");ae.prototype.reverted=Sr("reverted");function Sr(n){return function(t,i,r,o,s){(ge(t)||se(t))&&(s=o,o=r,r=i,i=t,t=null),this.on(t,n,i,r,o,s)}}function Or(n,e){ae.call(this,n),this._gridSnapping=e;var t=this;this.preExecute("shape.resize",function(i){var r=i.context,o=r.hints||{},s=o.autoResize;if(s){var a=r.shape,l=r.newBounds;Ie(s)?r.newBounds=t.snapComplex(l,s):r.newBounds=t.snapSimple(a,l)}})}Or.$inject=["eventBus","gridSnapping","modeling"];fe(Or,ae);Or.prototype.snapSimple=function(n,e){var t=this._gridSnapping;return e.width=t.snapValue(e.width,{min:e.width}),e.height=t.snapValue(e.height,{min:e.height}),e.x=n.x+n.width/2-e.width/2,e.y=n.y+n.height/2-e.height/2,e};Or.prototype.snapComplex=function(n,e){return/w|e/.test(e)&&(n=this.snapHorizontally(n,e)),/n|s/.test(e)&&(n=this.snapVertically(n,e)),n};Or.prototype.snapHorizontally=function(n,e){var t=this._gridSnapping,i=/w/.test(e),r=/e/.test(e),o={};return o.width=t.snapValue(n.width,{min:n.width}),r&&(i?(o.x=t.snapValue(n.x,{max:n.x}),o.width+=t.snapValue(n.x-o.x,{min:n.x-o.x})):n.x=n.x+n.width-o.width),T(n,o),n};Or.prototype.snapVertically=function(n,e){var t=this._gridSnapping,i=/n/.test(e),r=/s/.test(e),o={};return o.height=t.snapValue(n.height,{min:n.height}),i&&(r?(o.y=t.snapValue(n.y,{max:n.y}),o.height+=t.snapValue(n.y-o.y,{min:n.y-o.y})):n.y=n.y+n.height-o.height),T(n,o),n};var tF=2e3;function gm(n,e){n.on(["spaceTool.move","spaceTool.end"],tF,function(t){var i=t.context;if(i.initialized){var r=i.axis,o;r==="x"?(o=e.snapValue(t.dx),t.x=t.x+o-t.dx,t.dx=o):(o=e.snapValue(t.dy),t.y=t.y+o-t.dy,t.dy=o)}})}gm.$inject=["eventBus","gridSnapping"];var gO={__init__:["gridSnappingResizeBehavior","gridSnappingSpaceToolBehavior"],gridSnappingResizeBehavior:["type",Or],gridSnappingSpaceToolBehavior:["type",gm]};var Tf=10;function ym(n,e,t){return t||(t="round"),Math[t](n/e)*e}var nF=1200,iF=800;function Fi(n,e,t){var i=!t||t.active!==!1;this._eventBus=e;var r=this;e.on("diagram.init",iF,function(){r.setActive(i)}),e.on(["create.move","create.end","bendpoint.move.move","bendpoint.move.end","connect.move","connect.end","connectionSegment.move.move","connectionSegment.move.end","resize.move","resize.end","shape.move.move","shape.move.end"],nF,function(o){var s=o.originalEvent;if(!(!r.active||s&&Mt(s))){var a=o.context,l=a.gridSnappingContext;l||(l=a.gridSnappingContext={}),["x","y"].forEach(function(c){var u={},f=oF(o,c,n);f&&(u.offset=f);var h=rF(o,c);h&&T(u,h),wr(o,c)||r.snapEvent(o,c,u)})}})}Fi.prototype.snapEvent=function(n,e,t){var i=this.snapValue(n[e],t);vn(n,e,i)};Fi.prototype.getGridSpacing=function(){return Tf};Fi.prototype.snapValue=function(n,e){var t=0;e&&e.offset&&(t=e.offset),n+=t,n=ym(n,Tf);var i,r;return e&&e.min&&(i=e.min,se(i)&&(i=ym(i+t,Tf,"ceil"),n=Math.max(n,i))),e&&e.max&&(r=e.max,se(r)&&(r=ym(r+t,Tf,"floor"),n=Math.min(n,r))),n-=t,n};Fi.prototype.isActive=function(){return this.active};Fi.prototype.setActive=function(n){this.active=n,this._eventBus.fire("gridSnapping.toggle",{active:n})};Fi.prototype.toggleActive=function(){this.setActive(!this.active)};Fi.$inject=["elementRegistry","eventBus","config.gridSnapping"];function rF(n,e){var t=n.context,i=t.createConstraints,r=t.resizeConstraints||{},o=t.gridSnappingContext,s=o.snapConstraints;if(s&&s[e])return s[e];s||(s=o.snapConstraints={}),s[e]||(s[e]={});var a=t.direction;i&&(vm(e)?(s.x.min=i.left,s.x.max=i.right):(s.y.min=i.top,s.y.max=i.bottom));var l=r.min,c=r.max;return l&&(vm(e)?vO(a)?s.x.max=l.left:s.x.min=l.right:yO(a)?s.y.max=l.top:s.y.min=l.bottom),c&&(vm(e)?vO(a)?s.x.min=c.left:s.x.max=c.right:yO(a)?s.y.min=c.top:s.y.max=c.bottom),s[e]}function oF(n,e,t){var i=n.context,r=n.shape,o=i.gridSnappingContext,s=o.snapLocation,a=o.snapOffset;return a&&se(a[e])||(a||(a=o.snapOffset={}),se(a[e])||(a[e]=0),!r)||(t.get(r.id)||(vm(e)?a[e]+=r[e]+r.width/2:a[e]+=r[e]+r.height/2),!s)||(e==="x"?/left/.test(s)?a[e]-=r.width/2:/right/.test(s)&&(a[e]+=r.width/2):/top/.test(s)?a[e]-=r.height/2:/bottom/.test(s)&&(a[e]+=r.height/2)),a[e]}function vm(n){return n==="x"}function yO(n){return n.indexOf("n")!==-1}function vO(n){return n.indexOf("w")!==-1}var xO={__depends__:[gO],__init__:["gridSnapping"],gridSnapping:["type",Fi]};var xm="keyboard.keydown",sF="keyboard.keyup",aF=1e3,bO="Keyboard binding is now implicit; explicit binding to an element got removed. For more information, see https://github.com/bpmn-io/diagram-js/issues/661";function Pt(n,e){var t=this;this._config=n=n||{},this._eventBus=e,this._keydownHandler=this._keydownHandler.bind(this),this._keyupHandler=this._keyupHandler.bind(this),e.on("diagram.destroy",function(){t._fire("destroy"),t.unbind()}),n.bindTo&&console.error("unsupported configuration ",new Error(bO));var i=n&&n.bind!==!1;e.on("canvas.init",function(r){t._target=r.svg,i&&t.bind(),t._fire("init")})}Pt.$inject=["config.keyboard","eventBus"];Pt.prototype._keydownHandler=function(n){this._keyHandler(n,xm)};Pt.prototype._keyupHandler=function(n){this._keyHandler(n,sF)};Pt.prototype._keyHandler=function(n,e){var t;if(!this._isEventIgnored(n)){var i={keyEvent:n};t=this._eventBus.fire(e||xm,i),t&&n.preventDefault()}};Pt.prototype._isEventIgnored=function(n){return!1};Pt.prototype.bind=function(n){n&&console.error("unsupported argument ",new Error(bO)),this.unbind(),n=this._node=this._target,q.bind(n,"keydown",this._keydownHandler),q.bind(n,"keyup",this._keyupHandler),this._fire("bind")};Pt.prototype.getBinding=function(){return this._node};Pt.prototype.unbind=function(){var n=this._node;n&&(this._fire("unbind"),q.unbind(n,"keydown",this._keydownHandler),q.unbind(n,"keyup",this._keyupHandler)),this._node=null};Pt.prototype._fire=function(n){this._eventBus.fire("keyboard."+n,{node:this._node})};Pt.prototype.addListener=function(n,e,t){ge(n)&&(t=e,e=n,n=aF),this._eventBus.on(t||xm,n,e)};Pt.prototype.removeListener=function(n,e){this._eventBus.off(e||xm,n)};Pt.prototype.hasModifier=lE;Pt.prototype.isCmd=Mt;Pt.prototype.isShift=Rp;Pt.prototype.isKey=Ve;var lF=500;function kr(n,e){var t=this;n.on("editorActions.init",lF,function(i){var r=i.editorActions;t.registerBindings(e,r)})}kr.$inject=["eventBus","keyboard"];kr.prototype.registerBindings=function(n,e){function t(i,r){e.isRegistered(i)&&n.addListener(r)}t("undo",function(i){var r=i.keyEvent;if(Tp(r))return e.trigger("undo"),!0}),t("redo",function(i){var r=i.keyEvent;if(Ap(r))return e.trigger("redo"),!0}),t("copy",function(i){var r=i.keyEvent;if(cE(r))return e.trigger("copy"),!0}),t("paste",function(i){var r=i.keyEvent;if(uE(r))return e.trigger("paste"),!0}),t("duplicate",function(i){var r=i.keyEvent;if(fE(r))return e.trigger("duplicate"),!0}),t("cut",function(i){var r=i.keyEvent;if(hE(r))return e.trigger("cut"),!0}),t("stepZoom",function(i){var r=i.keyEvent;if(Ve(["+","Add","="],r)&&Mt(r))return e.trigger("stepZoom",{value:1}),!0}),t("stepZoom",function(i){var r=i.keyEvent;if(Ve(["-","Subtract"],r)&&Mt(r))return e.trigger("stepZoom",{value:-1}),!0}),t("zoom",function(i){var r=i.keyEvent;if(Ve("0",r)&&Mt(r))return e.trigger("zoom",{value:1}),!0}),t("removeSelection",function(i){var r=i.keyEvent;if(Ve(["Backspace","Delete","Del"],r))return e.trigger("removeSelection"),!0})};var _o={__init__:["keyboard","keyboardBindings"],keyboard:["type",Pt],keyboardBindings:["type",kr]};function Ba(n){n.invoke(kr,this)}fe(Ba,kr);Ba.$inject=["injector"];Ba.prototype.registerBindings=function(n,e){kr.prototype.registerBindings.call(this,n,e);function t(i,r){e.isRegistered(i)&&n.addListener(r)}t("selectElements",function(i){var r=i.keyEvent;if(n.isKey(["a","A"],r)&&n.isCmd(r))return e.trigger("selectElements"),!0}),t("lassoTool",function(i){var r=i.keyEvent;if(!n.hasModifier(r)&&n.isKey(["l","L"],r))return e.trigger("lassoTool"),!0}),t("handTool",function(i){var r=i.keyEvent;if(!n.hasModifier(r)&&n.isKey(["h","H"],r))return e.trigger("handTool"),!0}),t("directEditing",function(i){var r=i.keyEvent;if(!n.hasModifier(r)&&n.isKey(["e","E"],r))return e.trigger("directEditing"),!0}),t("find",function(i){var r=i.keyEvent;if(n.isKey(["f","F"],r)&&n.isCmd(r))return e.trigger("find"),!0})};var _O={__depends__:[_o],__init__:["keyboardBindings"],keyboardBindings:["type",Ba]};var cF={moveSpeed:50,moveSpeedAccelerated:200};function bm(n,e,t){var i=this;this._config=T({},cF,n||{}),e.addListener(r);function r(o){var s=o.keyEvent,a=i._config;if(e.isCmd(s)&&e.isKey(["ArrowLeft","Left","ArrowUp","Up","ArrowDown","Down","ArrowRight","Right"],s)){var l=e.isShift(s)?a.moveSpeedAccelerated:a.moveSpeed,c;switch(s.key){case"ArrowLeft":case"Left":c="left";break;case"ArrowUp":case"Up":c="up";break;case"ArrowRight":case"Right":c="right";break;case"ArrowDown":case"Down":c="down";break}return i.moveCanvas({speed:l,direction:c}),!0}}this.moveCanvas=function(o){var s=0,a=0,l=o.speed,c=l/Math.min(Math.sqrt(t.viewbox().scale),1);switch(o.direction){case"left":s=c;break;case"up":a=c;break;case"right":s=-c;break;case"down":a=-c;break}t.scroll({dx:s,dy:a})}}bm.$inject=["config.keyboardMove","keyboard","canvas"];var wO={__depends__:[_o],__init__:["keyboardMove"],keyboardMove:["type",bm]};var uF={moveSpeed:1,moveSpeedAccelerated:10},fF=1500,CO="left",EO="up",SO="right",OO="down",hF={ArrowLeft:CO,Left:CO,ArrowUp:EO,Up:EO,ArrowRight:SO,Right:SO,ArrowDown:OO,Down:OO},dF={left:function(n){return{x:-n,y:0}},up:function(n){return{x:0,y:-n}},right:function(n){return{x:n,y:0}},down:function(n){return{x:0,y:n}}};function _m(n,e,t,i,r){var o=this;this._config=T({},uF,n||{}),e.addListener(fF,function(s){var a=s.keyEvent,l=hF[a.key];if(l&&!e.isCmd(a)){var c=e.isShift(a);return o.moveSelection(l,c),!0}}),this.moveSelection=function(s,a){var l=r.get();if(l.length){var c=this._config[a?"moveSpeedAccelerated":"moveSpeed"],u=dF[s](c),f=i.allowed("elements.move",{shapes:l,hints:{keyboardMove:!0}});f&&t.moveElements(l,u)}}}_m.$inject=["config.keyboardMoveSelection","keyboard","modeling","rules","selection"];var kO={__depends__:[_o,ht],__init__:["keyboardMoveSelection"],keyboardMoveSelection:["type",_m]};function ke(n,e){this._handlerMap={},this._stack=[],this._stackIdx=-1,this._currentExecution={actions:[],dirty:[],trigger:null},this._injector=e,this._eventBus=n,this._uid=1,n.on(["diagram.destroy","diagram.clear"],function(){this.clear(!1)},this)}ke.$inject=["eventBus","injector"];ke.prototype.execute=function(n,e){if(!n)throw new Error("command required");this._currentExecution.trigger="execute";let t={command:n,context:e};this._pushAction(t),this._internalExecute(t),this._popAction()};ke.prototype.canExecute=function(n,e){let t={command:n,context:e},i=this._getHandler(n),r=this._fire(n,"canExecute",t);if(r===void 0){if(!i)return!1;i.canExecute&&(r=i.canExecute(e))}return r};ke.prototype.clear=function(n){this._stack.length=0,this._stackIdx=-1,n!==!1&&this._fire("changed",{trigger:"clear"})};ke.prototype.undo=function(){let n=this._getUndoAction(),e;if(n){for(this._currentExecution.trigger="undo",this._pushAction(n);n&&(this._internalUndo(n),e=this._getUndoAction(),!(!e||e.id!==n.id));)n=e;this._popAction()}};ke.prototype.redo=function(){let n=this._getRedoAction(),e;if(n){for(this._currentExecution.trigger="redo",this._pushAction(n);n&&(this._internalExecute(n,!0),e=this._getRedoAction(),!(!e||e.id!==n.id));)n=e;this._popAction()}};ke.prototype.register=function(n,e){this._setHandler(n,e)};ke.prototype.registerHandler=function(n,e){if(!n||!e)throw new Error("command and handlerCls must be defined");let t=this._injector.instantiate(e);this.register(n,t)};ke.prototype.canUndo=function(){return!!this._getUndoAction()};ke.prototype.canRedo=function(){return!!this._getRedoAction()};ke.prototype._getRedoAction=function(){return this._stack[this._stackIdx+1]};ke.prototype._getUndoAction=function(){return this._stack[this._stackIdx]};ke.prototype._internalUndo=function(n){let e=n.command,t=n.context,i=this._getHandler(e);this._atomicDo(()=>{this._fire(e,"revert",n),i.revert&&this._markDirty(i.revert(t)),this._revertedAction(n),this._fire(e,"reverted",n)})};ke.prototype._fire=function(n,e,t){arguments.length<3&&(t=e,e=null);let i=e?[n+"."+e,e]:[n],r;t=this._eventBus.createEvent(t);for(let o of i)if(r=this._eventBus.fire("commandStack."+o,t),t.cancelBubble)break;return r};ke.prototype._createId=function(){return this._uid++};ke.prototype._atomicDo=function(n){let e=this._currentExecution;e.atomic=!0;try{n()}finally{e.atomic=!1}};ke.prototype._internalExecute=function(n,e){let t=n.command,i=n.context,r=this._getHandler(t);if(!r)throw new Error("no command handler registered for <"+t+">");this._pushAction(n),e||(this._fire(t,"preExecute",n),r.preExecute&&r.preExecute(i),this._fire(t,"preExecuted",n)),this._atomicDo(()=>{this._fire(t,"execute",n),r.execute&&this._markDirty(r.execute(i)),this._executedAction(n,e),this._fire(t,"executed",n)}),e||(this._fire(t,"postExecute",n),r.postExecute&&r.postExecute(i),this._fire(t,"postExecuted",n)),this._popAction()};ke.prototype._pushAction=function(n){let e=this._currentExecution,t=e.actions,i=t[0];if(e.atomic)throw new Error("illegal invocation in or phase (action: "+n.command+")");n.id||(n.id=i&&i.id||this._createId()),t.push(n)};ke.prototype._popAction=function(){let n=this._currentExecution,e=n.trigger,t=n.actions,i=n.dirty;t.pop(),t.length||(this._eventBus.fire("elements.changed",{elements:Bw("id",i.reverse())}),i.length=0,this._fire("changed",{trigger:e}),n.trigger=null)};ke.prototype._markDirty=function(n){let e=this._currentExecution;n&&(n=F(n)?n:[n],e.dirty=e.dirty.concat(n))};ke.prototype._executedAction=function(n,e){let t=++this._stackIdx;e||this._stack.splice(t,this._stack.length,n)};ke.prototype._revertedAction=function(n){this._stackIdx--};ke.prototype._getHandler=function(n){return this._handlerMap[n]};ke.prototype._setHandler=function(n,e){if(!n||!e)throw new Error("command and handler required");if(this._handlerMap[n])throw new Error("overriding handler for command <"+n+">");this._handlerMap[n]=e};var xs={commandStack:["type",ke]};function wm(n,e,t,i){n.on("element.changed",function(r){var o=r.element;(o.parent||o===e.getRootElement())&&(r.gfx=t.getGraphics(o)),r.gfx&&n.fire(ip(o)+".changed",r)}),n.on("elements.changed",function(r){var o=r.elements;o.forEach(function(s){n.fire("element.changed",{element:s})}),i.updateContainments(o)}),n.on("shape.changed",function(r){i.update("shape",r.element,r.gfx)}),n.on("connection.changed",function(r){i.update("connection",r.element,r.gfx)})}wm.$inject=["eventBus","canvas","elementRegistry","graphicsFactory"];var Cm={__init__:["changeSupport"],changeSupport:["type",wm]};var RO=Math.min,TO=Math.max;function Mx(n){n.preventDefault()}function Af(n){n.stopPropagation()}function pF(n){return n.nodeType===Node.TEXT_NODE}function mF(n){return[].slice.call(n)}function On(n){this.container=n.container,this.parent=te('
    '),this.content=X("[contenteditable]",this.parent),this.keyHandler=n.keyHandler||function(){},this.resizeHandler=n.resizeHandler||function(){},this.autoResize=at(this.autoResize,this),this.handlePaste=at(this.handlePaste,this)}On.prototype.create=function(n,e,t,i){var r=this,o=this.parent,s=this.content,a=this.container;i=this.options=i||{},e=this.style=e||{};var l=hn(e,["width","height","maxWidth","maxHeight","minWidth","minHeight","left","top","backgroundColor","position","overflow","border","wordWrap","textAlign","outline","transform"]);T(o.style,{width:n.width+"px",height:n.height+"px",maxWidth:n.maxWidth+"px",maxHeight:n.maxHeight+"px",minWidth:n.minWidth+"px",minHeight:n.minHeight+"px",left:n.x+"px",top:n.y+"px",backgroundColor:"#ffffff",position:"absolute",overflow:"visible",border:"1px solid #ccc",boxSizing:"border-box",wordWrap:"normal",textAlign:"center",outline:"none"},l);var c=hn(e,["fontFamily","fontSize","fontWeight","lineHeight","padding","paddingTop","paddingRight","paddingBottom","paddingLeft"]);return T(s.style,{boxSizing:"border-box",width:"100%",outline:"none",wordWrap:"break-word"},c),i.centerVertically&&T(s.style,{position:"absolute",top:"50%",transform:"translate(0, -50%)"},c),s.innerText=t,q.bind(s,"keydown",this.keyHandler),q.bind(s,"mousedown",Af),q.bind(s,"paste",r.handlePaste),i.autoResize&&q.bind(s,"input",this.autoResize),i.resizable&&this.resizable(e),a.appendChild(o),this.setSelection(s.lastChild,s.lastChild&&s.lastChild.length),o};On.prototype.handlePaste=function(n){var e=this.options,t=this.style;n.preventDefault();var i;if(n.clipboardData?i=n.clipboardData.getData("text/plain"):i=window.clipboardData.getData("Text"),this.insertText(i),e.autoResize){var r=this.autoResize(t);r&&this.resizeHandler(r)}};On.prototype.insertText=function(n){n=gF(n);var e=document.execCommand("insertText",!1,n);e||this._insertTextIE(n)};On.prototype._insertTextIE=function(n){var e=this.getSelection(),t=e.startContainer,i=e.endContainer,r=e.startOffset,o=e.endOffset,s=e.commonAncestorContainer,a=mF(s.childNodes),l,c;if(pF(s)){var u=t.textContent;t.textContent=u.substring(0,r)+n+u.substring(o),l=t,c=r+n.length}else if(t===this.content&&i===this.content){var f=document.createTextNode(n);this.content.insertBefore(f,a[r]),l=f,c=f.textContent.length}else{var h=a.indexOf(t),d=a.indexOf(i);a.forEach(function(p,m){m===h?p.textContent=t.textContent.substring(0,r)+n+i.textContent.substring(o):m>h&&m<=d&&Qe(p)}),l=t,c=r+n.length}l&&c!==void 0&&setTimeout(function(){self.setSelection(l,c)})};On.prototype.autoResize=function(){var n=this.parent,e=this.content,t=parseInt(this.style.fontSize)||12;if(e.scrollHeight>n.offsetHeight||e.scrollHeight
    ');var a,l,c,u,f=function(p){Mx(p),Af(p),a=p.clientX,l=p.clientY;var m=e.getBoundingClientRect();c=m.width,u=m.height,q.bind(document,"mousemove",h),q.bind(document,"mouseup",d)},h=function(p){Mx(p),Af(p);var m=RO(TO(c+p.clientX-a,i),o),g=RO(TO(u+p.clientY-l,r),s);e.style.width=m+"px",e.style.height=g+"px",n.resizeHandler({width:c,height:u,dx:p.clientX-a,dy:p.clientY-l})},d=function(p){Mx(p),Af(p),q.unbind(document,"mousemove",h,!1),q.unbind(document,"mouseup",d,!1)};q.bind(t,"mousedown",f)}T(t.style,{position:"absolute",bottom:"0px",right:"0px",cursor:"nwse-resize",width:"0",height:"0",borderTop:(parseInt(this.style.fontSize)/4||3)+"px solid transparent",borderRight:(parseInt(this.style.fontSize)/4||3)+"px solid #ccc",borderBottom:(parseInt(this.style.fontSize)/4||3)+"px solid #ccc",borderLeft:(parseInt(this.style.fontSize)/4||3)+"px solid transparent"}),e.appendChild(t)};On.prototype.destroy=function(){var n=this.parent,e=this.content,t=this.resizeHandle;e.innerText="",n.removeAttribute("style"),e.removeAttribute("style"),q.unbind(e,"keydown",this.keyHandler),q.unbind(e,"mousedown",Af),q.unbind(e,"input",this.autoResize),q.unbind(e,"paste",this.handlePaste),t&&(t.removeAttribute("style"),Qe(t)),Qe(n)};On.prototype.getValue=function(){return this.content.innerText.trim()};On.prototype.getSelection=function(){var n=window.getSelection(),e=n.getRangeAt(0);return e};On.prototype.setSelection=function(n,e){var t=document.createRange();n===null?t.selectNodeContents(this.content):(t.setStart(n,e),t.setEnd(n,e));var i=window.getSelection();i.removeAllRanges(),i.addRange(t)};function gF(n){return n.replace(/\r\n|\r|\n/g,` `)}function xn(n,e){this._eventBus=n,this._canvas=e,this._providers=[],this._textbox=new On({container:e.getContainer(),keyHandler:at(this._handleKey,this),resizeHandler:at(this._handleResize,this)})}xn.$inject=["eventBus","canvas"];xn.prototype.registerProvider=function(n){this._providers.push(n)};xn.prototype.isActive=function(n){return!!(this._active&&(!n||this._active.element===n))};xn.prototype.cancel=function(){this._active&&(this._fire("cancel"),this.close())};xn.prototype._fire=function(n,e){this._eventBus.fire("directEditing."+n,e||{active:this._active})};xn.prototype.close=function(){this._textbox.destroy(),this._fire("deactivate"),this._active=null,this.resizable=void 0,this._canvas.restoreFocus&&this._canvas.restoreFocus()};xn.prototype.complete=function(){var n=this._active;if(n){var e,t=n.context.bounds,i=this.$textbox.getBoundingClientRect(),r=this.getValue(),o=n.context.text;(r!==o||i.height!==t.height||i.width!==t.width)&&(e=this._textbox.container.getBoundingClientRect(),n.provider.update(n.element,r,n.context.text,{x:i.left-e.left,y:i.top-e.top,width:i.width,height:i.height})),this._fire("complete"),this.close()}};xn.prototype.getValue=function(){return this._textbox.getValue()};xn.prototype._handleKey=function(n){n.stopPropagation();var e=n.keyCode||n.charCode;if(e===27)return n.preventDefault(),this.cancel();if(e===13&&!n.shiftKey)return n.preventDefault(),this.complete()};xn.prototype._handleResize=function(n){this._fire("resize",n)};xn.prototype.activate=function(n){if(this.isActive()&&this.cancel(),this._eventBus.fire("directEditing.activate.allowed",{element:n})===!1)return!1;var e,t=ye(this._providers,function(i){return(e=i.activate(n))?i:null});return e&&(this.$textbox=this._textbox.create(e.bounds,e.style,e.text,e.options),this._active={element:n,context:e,provider:t},e.options&&e.options.resizable&&(this.resizable=!0),this._fire("activate")),!!e};var AO={__depends__:[fo],__init__:["directEditing"],directEditing:["type",xn]};var MO="djs-label-hidden";function bs(n,e,t,i,r){this._canvas=n,this._modeling=i,this._textRenderer=r,this._eventBus=t,e.registerProvider(this),t.on("element.dblclick",function(o){e.activate(o.element)}),t.on(["autoPlace.start","canvas.viewbox.changing","drag.init","drillDown.click","element.mousedown","popupMenu.open","selection.changed"],function(){e.complete()}),t.on(["commandStack.changed"],function(){e.cancel()}),t.on("create.end",500,function(o){var s=o.shape;(O(s,"dmn:Decision")||O(s,"dmn:InputData")||O(s,"dmn:BusinessKnowledgeModel")||O(s,"dmn:KnowledgeSource")||O(s,"dmn:TextAnnotation"))&&e.activate(s)}),t.on("autoPlace.end",500,function(o){e.activate(o.shape)}),this._eventBus.on(["directEditing.complete","directEditing.cancel"],function(o){var s=o.active;if(s){var a=s.element.label||s.element;n.removeMarker(a,MO)}})}bs.$inject=["canvas","directEditing","eventBus","modeling","textRenderer"];bs.prototype.activate=function(n){var e=fs(n);if(Me(e)){var t={text:e},i=this.getEditingBBox(n);T(t,i);var r={},o=t.style||{};return O(n,"dmn:DRGElement")&&(T(r,{centerVertically:!0}),T(o,{backgroundColor:null,border:null})),O(n,"dmn:TextAnnotation")&&T(r,{resizable:!0}),T(t,{options:r,style:o}),this._canvas.addMarker(n,MO),t}};bs.prototype.getEditingBBox=function(n){var e=this._canvas,t=n.label||n,i=e.getAbsoluteBBox(t),r={x:i.x,y:i.y},o=e.zoom(),s=this._textRenderer.getDefaultStyle(),a=s.fontSize*o,l=s.lineHeight,c={fontFamily:this._textRenderer.getDefaultStyle().fontFamily,fontWeight:this._textRenderer.getDefaultStyle().fontWeight};return O(n,"dmn:DRGElement")&&(T(r,{width:i.width,height:i.height}),T(c,{fontSize:a+"px",lineHeight:l,paddingTop:7*o+"px",paddingBottom:7*o+"px",paddingLeft:5*o+"px",paddingRight:5*o+"px"})),O(n,"dmn:TextAnnotation")&&(T(r,{width:i.width,height:i.height,minWidth:30*o,minHeight:10*o}),T(c,{textAlign:"left",paddingTop:5*o+"px",paddingBottom:7*o+"px",paddingLeft:7*o+"px",paddingRight:5*o+"px",fontSize:a+"px",lineHeight:l})),{bounds:r,style:c}};bs.prototype.update=function(n,e,t,i){var r,o;O(n,"dmn:TextAnnotation")&&(o=this._canvas.getAbsoluteBBox(n),r={x:n.x,y:n.y,width:n.width/o.width*i.width,height:n.height/o.height*i.height}),yF(e)&&(e=null),this._modeling.updateLabel(n,e,r)};function yF(n){return!n||!n.trim()}var PO={__depends__:[xs,Cm,AO],__init__:["labelEditingProvider"],labelEditingProvider:["type",bs]};function Mf(n,e){e.invoke(ae,this),this.preExecute("connection.create",function(t){var i=t.connection,r=i.businessObject,o=t.source,s=t.target,a,l,c;O(i,"dmn:Association")?(l=r.sourceRef=n.create("dmn:DMNElementReference",{href:"#"+o.id}),l.$parent=r,c=r.targetRef=n.create("dmn:DMNElementReference",{href:"#"+s.id}),c.$parent=r):(a=r["required"+vF(o)]=n.create("dmn:DMNElementReference",{href:"#"+o.id}),a.$parent=r)},!0)}Mf.$inject=["drdFactory","injector"];fe(Mf,ae);function vF(n){if(O(n,"dmn:BusinessKnowledgeModel"))return"Knowledge";if(O(n,"dmn:Decision"))return"Decision";if(O(n,"dmn:InputData"))return"Input";if(O(n,"dmn:KnowledgeSource"))return"Authority"}var xF=500;function Pf(n,e,t,i){n.invoke(ae,this),this.preExecute(["connection.create","connection.reconnect"],function(o){var s=o.connection,a=o.newSource||o.source,l=o.newTarget||o.target;if(!(O(s,"dmn:InformationRequirement")&&!i.allowed("connection.connect",{connection:s,source:a,target:l}))&&O(s,"dmn:InformationRequirement")){var c=vt(a,l);o.hints||(o.hints={}),T(o.hints,bF(a,l,c))}},!0);function r(o,s,a){s||(s=o.incoming.filter(function(c){return O(c,"dmn:InformationRequirement")}));var l={};a?l[a]=s:l=wF(o,s),k(l,function(c,u){c=CF(c,u);var f=_F(c,o,u);c.forEach((h,d)=>{var p=f[d].start,m=f[d].end,g=e.layoutConnection(h,{connectionStart:p,connectionEnd:m});t.updateWaypoints(h,g)})})}this.postExecuted(["connection.create","connection.delete","connection.reconnect"],function(o){var s=o.connection,a=s.source||o.source,l=s.target||o.target;if(O(s,"dmn:InformationRequirement")){var c=vt(a,l),u=l.incoming.filter(f=>{var h=vt(f.source,f.target);return O(f,"dmn:InformationRequirement")&&DO(h,c)});u.length&&r(l,u,c)}},!0),this.preExecute("connection.reconnect",function(o){var s=o.connection,a=s.source,l=s.target;if(O(s,"dmn:InformationRequirement")){var c=vt(a,l),u=l.incoming.filter(f=>{var h=vt(f.source,f.target);return f!==s&&O(f,"dmn:InformationRequirement")&&DO(h,c)});u.length&&r(l,u,c)}},!0),this.postExecuted("elements.move",xF,function(o){var s=o.shapes,a=o.closure,l=a.enclosedConnections;s.forEach(function(c){if(Ge(c,["dmn:Decision","dmn:InputData"])){var u=c.incoming.filter(function(f){return O(f,"dmn:InformationRequirement")&&!l[f.id]});u.length&&r(c,u),c.outgoing.forEach(function(f){!O(f,"dmn:InformationRequirement")||l[f.id]||r(f.target)})}})},!0)}Pf.$inject=["injector","layouter","modeling","rules"];fe(Pf,ae);function bF(n,e,t){var i=le(n),r=le(e);return t.includes("bottom")?(i.y=n.y,r.y=e.y+e.height):t.includes("top")?(i.y=n.y+n.height,r.y=e.y):t.includes("right")?(i.x=n.x,r.x=e.x+e.width):(i.x=n.x+n.width,r.x=e.x),{connectionStart:i,connectionEnd:r}}function _F(n,e,t){return n.map(function(i,r){var o=i.source,s=le(o),a=G(o),l=G(e),c=n.length;return t.includes("bottom")?{start:{x:s.x,y:a.top},end:{x:l.left+e.width/(c+1)*(r+1),y:l.bottom}}:t.includes("top")?{start:{x:s.x,y:a.bottom},end:{x:l.left+e.width/(c+1)*(r+1),y:l.top}}:t.includes("right")?{start:{x:a.left,y:s.y},end:{x:l.right,y:l.top+e.height/(c+1)*(r+1)}}:{start:{x:a.right,y:s.y},end:{x:l.left,y:l.top+e.height/(c+1)*(r+1)}}})}function wF(n,e){var t={};return e.forEach(function(i){var r=vt(i.source,n).split("-").shift();t[r]||(t[r]=[]),t[r].push(i)}),t}function DO(n,e){return n&&e&&n.split("-").shift()===e.split("-").shift()}function CF(n,e){var t;return e.includes("top")||e.includes("bottom")?t="x":t="y",n.sort(function(i,r){return le(i.source)[t]-le(r.source)[t]})}function Df(n,e,t){n.invoke(ae,this),this.preExecute("connection.reconnect",function(i){var r=i.connection,o=i.newSource||r.source,s=i.newTarget||r.target,a=r.waypoints.slice(),l=t.allowed("connection.reconnect",{connection:r,source:o,target:s});!l||l.type===r.type||(i.connection=e.connect(o,s,{type:l.type,waypoints:a}),e.removeConnection(r))},!0)}fe(Df,ae);Df.$inject=["injector","modeling","rules"];function If(n,e,t){ae.call(this,n),this._modeling=e,this.postExecuted(["shape.replace"],1500,function(i){var r=i.context,o=r.oldShape,s=r.newShape;e.unclaimId(o.businessObject.id,o.businessObject),e.updateProperties(s,{id:o.id}),t.select(s)})}fe(If,ae);If.$inject=["eventBus","modeling","selection"];var IO="id",Gn=class extends ae{constructor(e){super(e),this.executed("element.updateProperties",this.updateIds.bind(this))}updateIds({context:e}){let{element:t,oldProperties:i,properties:r}=e,o=Ke(t);if(this.shouldSkipUpdate(o,i,r))return;let s=SF(o);s.get("drgElement").forEach(c=>{OF(c,i.id,r.id)}),s.get("artifact").forEach(c=>{kF(c,i.id,r.id)})}shouldSkipUpdate(e,t,i){return!EF(t,i)||!O(e,"dmn:DRGElement")&&!O(e,"dmn:TextAnnotation")}};Gn.$inject=["eventBus"];function EF(n,e){return IO in n&&IO in e}function SF(n){let e=n;for(;!O(e,"dmn:Definitions");)e=e.$parent;return e}function OF(n,e,t){k({authorityRequirement:()=>{n.authorityRequirement.forEach(r=>{let{requiredAuthority:o,requiredDecision:s,requiredInput:a}=r;o&&o.href===`#${e}`&&(o.href=`#${t}`),s&&s.href===`#${e}`&&(s.href=`#${t}`),a&&a.href===`#${e}`&&(a.href=`#${t}`)})},informationRequirement:()=>{n.informationRequirement.forEach(r=>{let{requiredDecision:o,requiredInput:s}=r;o&&o.href===`#${e}`&&(o.href=`#${t}`),s&&s.href===`#${e}`&&(s.href=`#${t}`)})},knowledgeRequirement:()=>{n.knowledgeRequirement.forEach(r=>{let{requiredKnowledge:o}=r;o&&o.href===`#${e}`&&(o.href=`#${t}`)})}},(r,o)=>{n[o]&&r()})}function kF(n,e,t){k({sourceRef:()=>{let{sourceRef:r}=n;r.href===`#${e}`&&(r.href=`#${t}`)},targetRef:()=>{let{targetRef:r}=n;r.href===`#${e}`&&(r.href=`#${t}`)}},(r,o)=>{n[o]&&r()})}var qi=class extends ae{constructor(t,i){super(t);M(this,"updateVariableFromLabel",({context:t})=>{let{element:i,newLabel:r}=t,o=Ke(i),s=o.variable;s&&this._modeling.updateProperties(s,{name:r})});M(this,"updateVariableFromElement",({context:t})=>{let{element:i,properties:r}=t,o=Ke(i);o.variable&&(O(i,"dmn:Decision")||O(i,"dmn:BusinessKnowledgeModel"))&&this.isNameChanged(r)&&(this.isVariable(i)||this.shouldSyncVariable(i)||this.syncElementVariableChange(o))});this._modeling=i,this.postExecuted("element.updateProperties",this.updateVariableFromElement),this.postExecuted("element.updateLabel",this.updateVariableFromLabel)}isNameChanged(t){return"name"in t}isVariable(t){let i=RF(t);return O(t,"dmn:InformationItem")&&i&&i.get("variable")===t}shouldSyncVariable(t){let i=Ke(t),r=i.get("variable");return r&&i.name===r.name}syncElementVariableChange(t){let i=t.get("name"),r=t.variable;this._modeling.updateProperties(r,{name:i})}};M(qi,"$inject",["eventBus","modeling"]);function RF(n){return n.$parent}var LO={__init__:["createConnectionBehavior","idChangeBehavior","nameChangeBehavior","layoutConnectionBehavior","replaceConnectionBehavior","replaceElementBehavior"],createConnectionBehavior:["type",Mf],idChangeBehavior:["type",Gn],nameChangeBehavior:["type",qi],layoutConnectionBehavior:["type",Pf],replaceConnectionBehavior:["type",Df],replaceElementBehavior:["type",If]};function Vi(n){ae.call(this,n),this.init()}Vi.$inject=["eventBus"];fe(Vi,ae);Vi.prototype.addRule=function(n,e,t){var i=this;typeof n=="string"&&(n=[n]),n.forEach(function(r){i.canExecute(r,e,function(o,s,a){return t(o)},!0)})};Vi.prototype.init=function(){};function Rr(n){n.invoke(Vi,this)}fe(Rr,Vi);Rr.$inject=["injector"];Rr.prototype.init=function(){this.addRule("connection.create",function(n){var e=n.source,t=n.target;return Px(e,t)}),this.addRule("connection.reconnect",function(n){var e=n.connection,t=n.source,i=n.target;return Px(t,i,e)}),this.addRule("connection.updateWaypoints",function(n){let e=n.connection;return{type:e.type,businessObject:e.businessObject}}),this.addRule("elements.move",function(n){var e=n.target,t=n.shapes,i=n.position;return $O(t,e,i)}),this.addRule("shape.create",function(n){var e=n.shape,t=n.target;return NO(e,t)}),this.addRule("shape.resize",function(n){var e=n.shape;return O(e,"dmn:TextAnnotation")})};Rr.prototype.canConnect=Px;Rr.prototype.canCreate=NO;Rr.prototype.canMove=$O;function Px(n,e){if(!n||BO(n)||!e||BO(e))return null;if(n===e)return!1;if(O(n,"dmn:BusinessKnowledgeModel")&&Ge(e,["dmn:BusinessKnowledgeModel","dmn:Decision"]))return{type:"dmn:KnowledgeRequirement"};if(O(n,"dmn:Decision")){if(O(e,"dmn:Decision"))return{type:"dmn:InformationRequirement"};if(O(e,"dmn:KnowledgeSource"))return{type:"dmn:AuthorityRequirement"}}if(O(n,"dmn:Definitions")||O(e,"dmn:Definitions"))return!1;if(O(n,"dmn:InputData")){if(O(e,"dmn:Decision"))return{type:"dmn:InformationRequirement"};if(O(e,"dmn:KnowledgeSource"))return{type:"dmn:AuthorityRequirement"}}return O(n,"dmn:KnowledgeSource")&&Ge(e,["dmn:BusinessKnowledgeModel","dmn:Decision","dmn:KnowledgeSource"])?{type:"dmn:AuthorityRequirement"}:O(n,"dmn:TextAnnotation")&&!O(e,"dmn:TextAnnotation")||!O(n,"dmn:TextAnnotation")&&O(e,"dmn:TextAnnotation")?{type:"dmn:Association"}:!1}function NO(n,e){return Ge(n,["dmn:BusinessKnowledgeModel","dmn:Decision","dmn:InputData","dmn:KnowledgeSource","dmn:TextAnnotation"])&&O(e,"dmn:Definitions")}function $O(n,e){return F(n)||(n=[n]),!!(!e||kt(n,function(t){return Ge(t,["dmn:BusinessKnowledgeModel","dmn:Decision","dmn:InputData","dmn:KnowledgeSource","dmn:TextAnnotation","dmn:InformationRequirement","dmn:AuthorityRequirement","dmn:KnowledgeRequirement","dmn:Association"])})&&O(e,"dmn:Definitions"))}function BO(n){return!!n.labelTarget}var jO={__depends__:[yn],__init__:["drdRules"],drdRules:["type",Rr]};function kn(n){this._model=n}kn.$inject=["moddle"];kn.prototype._needsId=function(n){return Ge(n,["dmn:Artifact","dmn:DMNElement","dmn:DRGElement","dmndi:DMNDiagram","dmndi:DMNDiagramElement"])};kn.prototype._ensureId=function(n){var e=(n.$type||"").replace(/^[^:]*:/g,"")+"_";!n.id&&this._needsId(n)&&(n.id=this._model.ids.nextPrefixed(e,n))};kn.prototype.create=function(n,e){var t=this._model.create(n,e||{});return this._ensureId(t),t};kn.prototype.createDiShape=function(n,e,t){return this.create("dmndi:DMNShape",T({dmnElementRef:n,bounds:this.createDiBounds(e)},t))};kn.prototype.createDiBounds=function(n){return this.create("dc:Bounds",n)};kn.prototype.createDiEdge=function(n,e,t){return this.create("dmndi:DMNEdge",{dmnElementRef:n,waypoint:this.createDiWaypoints(e)},t)};kn.prototype.createDiWaypoints=function(n){var e=this;return n.map(function(t){return e.createDiWaypoint(t)})};kn.prototype.createDiWaypoint=function(n){return this.create("dc:Point",hn(n,["x","y"]))};kn.prototype.createExtensionElements=function(){return this.create("dmn:ExtensionElements",{values:[]})};function Hi(n,e,t,i,r){r.invoke(ae,this),this._definitionPropertiesView=e,this._drdFactory=t,this._drdRules=i;var o=this;function s(f){var h=f.connection,d=f.cropped;d||(h.waypoints=n.getCroppedWaypoints(h),f.cropped=!0)}this.executed(["connection.create","connection.layout"],s,!0),this.reverted(["connection.layout"],function(f){delete f.cropped},!0);function a(f){var h=f.connection,d=f.parent,p=f.shape;h&&!O(h,"dmn:Association")&&(d=h.target),o.updateParent(p||h,d)}function l(f){var h=f.connection,d=f.shape,p=f.parent||f.newParent;h&&!O(h,"dmn:Association")&&(p=h.target),o.updateParent(d||h,p)}this.executed(["connection.create","connection.delete","connection.move","shape.create","shape.delete"],a,!0),this.reverted(["connection.create","connection.delete","connection.move","shape.create","shape.delete"],l,!0);function c(f){var h=f.shape;(O(h,"dmn:DRGElement")||O(h,"dmn:TextAnnotation"))&&o.updateBounds(h)}this.executed(["shape.create","shape.move","shape.resize"],c,!0),this.reverted(["shape.create","shape.move","shape.resize"],c,!0);function u(f){o.updateConnectionWaypoints(f)}this.executed(["connection.create","connection.layout","connection.move","connection.updateWaypoints"],u,!0),this.reverted(["connection.create","connection.layout","connection.move","connection.updateWaypoints"],u,!0),this.executed("connection.create",function(f){var h=f.connection,d=h.businessObject,p=f.target,m=p.businessObject;O(h,"dmn:Association")?a(f):o.updateSemanticParent(d,m)},!0),this.reverted("connection.create",function(f){l(f)},!0),this.executed("connection.reconnect",function(f){var h=f.connection,d=h.businessObject,p=f.newTarget,m=p.businessObject;O(d,"dmn:Association")||o.updateSemanticParent(d,m)},!0),this.reverted("connection.reconnect",function(f){var h=f.connection,d=h.businessObject,p=f.oldTarget,m=p.businessObject;O(d,"dmn:Association")||o.updateSemanticParent(d,m)},!0),this.executed("element.updateProperties",function(f){e.update()},!0),this.reverted("element.updateProperties",function(f){e.update()},!0)}fe(Hi,ae);Hi.$inject=["connectionDocking","definitionPropertiesView","drdFactory","drdRules","injector"];Hi.prototype.updateBounds=function(n){var e=n.businessObject,t=e.di.bounds;T(t,{x:n.x,y:n.y,width:n.width,height:n.height})};Hi.prototype.updateConnectionWaypoints=function(n){var e=this._drdFactory,t=n.connection,i=t.businessObject,r=i.di;r.waypoint=e.createDiWaypoints(t.waypoints).map(function(o){return o.$parent=r,o})};Hi.prototype.updateParent=function(n,e){var t=n.parent;!O(n,"dmn:DRGElement")&&!O(n,"dmn:Artifact")&&(t=e);var i=n.businessObject,r=t&&t.businessObject;this.updateSemanticParent(i,r),this.updateDiParent(i.di,r&&r.di)};Hi.prototype.updateSemanticParent=function(n,e){var t,i;n.$parent!==e&&(O(n,"dmn:DRGElement")?i="drgElement":O(n,"dmn:Artifact")?i="artifact":O(n,"dmn:InformationRequirement")?i="informationRequirement":O(n,"dmn:AuthorityRequirement")?i="authorityRequirement":O(n,"dmn:KnowledgeRequirement")&&(i="knowledgeRequirement"),n.$parent&&(t=n.$parent.get(i),Vn(t,n)),e?(t=e.get(i),t&&(t.push(n),n.$parent=e)):n.$parent=null)};Hi.prototype.updateDiParent=function(n,e){if(n.$parent!==e)if(Ge(n,["dmndi:DMNEdge","dmndi:DMNShape"])){for(var t=e||n;!O(t,"dmndi:DMNDiagram");)t=t.$parent;var i=t.get("diagramElements");e?(n.$parent=t,zt(i,n)):(n.$parent=null,Vn(i,n))}else throw new Error("unsupported")};function Na(n,e){this._modeling=n,this._canvas=e}Na.$inject=["modeling","canvas"];Na.prototype.preExecute=function(n){var e=this._modeling,t=n.elements,i=n.alignment;k(t,function(r){var o={x:0,y:0};Me(i.left)?o.x=i.left-r.x:Me(i.right)?o.x=i.right-r.width-r.x:Me(i.center)?o.x=i.center-Math.round(r.width/2)-r.x:Me(i.top)?o.y=i.top-r.y:Me(i.bottom)?o.y=i.bottom-r.height-r.y:Me(i.middle)&&(o.y=i.middle-Math.round(r.height/2)-r.y),e.moveElements([r],o,r.parent)})};Na.prototype.postExecute=function(n){};function $a(n){this._modeling=n}$a.$inject=["modeling"];$a.prototype.preExecute=function(n){var e=n.source;if(!e)throw new Error("source required");var t=n.target||e.parent,i=n.shape,r=n.hints||{};i=n.shape=this._modeling.createShape(i,n.position,t,{attach:r.attach}),n.shape=i};$a.prototype.postExecute=function(n){var e=n.hints||{};TF(n.source,n.shape)||(e.connectionTarget===n.source?this._modeling.connect(n.shape,n.source,n.connection):this._modeling.connect(n.source,n.shape,n.connection))};function TF(n,e){return zd(n.outgoing,function(t){return t.target===e})}function ja(n,e){this._canvas=n,this._layouter=e}ja.$inject=["canvas","layouter"];ja.prototype.execute=function(n){var e=n.connection,t=n.source,i=n.target,r=n.parent,o=n.parentIndex,s=n.hints;if(!t||!i)throw new Error("source and target required");if(!r)throw new Error("parent required");return e.source=t,e.target=i,e.waypoints||(e.waypoints=this._layouter.layoutConnection(e,s)),this._canvas.addConnection(e,r,o),e};ja.prototype.revert=function(n){var e=n.connection;return this._canvas.removeConnection(e),e.source=null,e.target=null,e};var Em=Math.round;function Lf(n){this._modeling=n}Lf.$inject=["modeling"];Lf.prototype.preExecute=function(n){var e=n.elements,t=n.parent,i=n.parentIndex,r=n.position,o=n.hints,s=this._modeling;k(e,function(f){se(f.x)||(f.x=0),se(f.y)||(f.y=0)});var a=Ee(e,function(f){return!f.hidden}),l=Tt(a);k(e,function(f){Xe(f)&&(f.waypoints=Vt(f.waypoints,function(h){return{x:Em(h.x-l.x-l.width/2+r.x),y:Em(h.y-l.y-l.height/2+r.y)}})),T(f,{x:Em(f.x-l.x-l.width/2+r.x),y:Em(f.y-l.y-l.height/2+r.y)})});var c=E1(e),u={};k(e,function(f){if(Xe(f)){u[f.id]=se(i)?s.createConnection(u[f.source.id],u[f.target.id],i,f,f.parent||t,o):s.createConnection(u[f.source.id],u[f.target.id],f,f.parent||t,o);return}var h=T({},o);c.indexOf(f)===-1&&(h.autoResize=!1),Bi(f)&&(h=Uu(h,["attach"])),u[f.id]=se(i)?s.createShape(f,hn(f,["x","y","width","height"]),f.parent||t,i,h):s.createShape(f,hn(f,["x","y","width","height"]),f.parent||t,h)}),n.elements=Wu(u)};var FO=Math.round;function gi(n){this._canvas=n}gi.$inject=["canvas"];gi.prototype.execute=function(n){var e=n.shape,t=n.position,i=n.parent,r=n.parentIndex;if(!i)throw new Error("parent required");if(!t)throw new Error("position required");return t.width!==void 0?T(e,t):T(e,{x:t.x-FO(e.width/2),y:t.y-FO(e.height/2)}),this._canvas.addShape(e,i,r),e};gi.prototype.revert=function(n){var e=n.shape;return this._canvas.removeShape(e),e};function _s(n){gi.call(this,n)}fe(_s,gi);_s.$inject=["canvas"];var AF=gi.prototype.execute;_s.prototype.execute=function(n){var e=n.shape;return PF(e),e.labelTarget=n.labelTarget,AF.call(this,n)};var MF=gi.prototype.revert;_s.prototype.revert=function(n){return n.shape.labelTarget=null,MF.call(this,n)};function PF(n){["width","height"].forEach(function(e){typeof n[e]=="undefined"&&(n[e]=0)})}function ws(n,e){if(typeof e!="function")throw new Error("removeFn iterator must be a function");if(!n)return[];for(var t;t=n[0];)e(t);return n}function Cs(n,e){this._canvas=n,this._modeling=e}Cs.$inject=["canvas","modeling"];Cs.prototype.preExecute=function(n){var e=this._modeling,t=n.connection;ws(t.incoming,function(i){e.removeConnection(i,{nested:!0})}),ws(t.outgoing,function(i){e.removeConnection(i,{nested:!0})})};Cs.prototype.execute=function(n){var e=n.connection,t=e.parent;return n.parent=t,n.parentIndex=op(t.children,e),n.source=e.source,n.target=e.target,this._canvas.removeConnection(e),e.source=null,e.target=null,e};Cs.prototype.revert=function(n){var e=n.connection,t=n.parent,i=n.parentIndex;return e.source=n.source,e.target=n.target,zt(t.children,e,i),this._canvas.addConnection(e,t),e};function Bf(n,e){this._modeling=n,this._elementRegistry=e}Bf.$inject=["modeling","elementRegistry"];Bf.prototype.postExecute=function(n){var e=this._modeling,t=this._elementRegistry,i=n.elements;k(i,function(r){t.get(r.id)&&(r.waypoints?e.removeConnection(r):e.removeShape(r))})};function Es(n,e){this._canvas=n,this._modeling=e}Es.$inject=["canvas","modeling"];Es.prototype.preExecute=function(n){var e=this._modeling,t=n.shape;ws(t.incoming,function(i){e.removeConnection(i,{nested:!0})}),ws(t.outgoing,function(i){e.removeConnection(i,{nested:!0})}),ws(t.children,function(i){Xe(i)?e.removeConnection(i,{nested:!0}):e.removeShape(i,{nested:!0})})};Es.prototype.execute=function(n){var e=this._canvas,t=n.shape,i=t.parent;return n.oldParent=i,n.oldParentIndex=op(i.children,t),e.removeShape(t),t};Es.prototype.revert=function(n){var e=this._canvas,t=n.shape,i=n.oldParent,r=n.oldParentIndex;return zt(i.children,t,r),e.addShape(t,i),t};function Fa(n){this._modeling=n}Fa.$inject=["modeling"];var qO={x:"y",y:"x"};Fa.prototype.preExecute=function(n){var e=this._modeling,t=n.groups,i=n.axis,r=n.dimension;function o(g,b){g.range.min=Math.min(b[i],g.range.min),g.range.max=Math.max(b[i]+b[r],g.range.max)}function s(g){return g[i]+g[r]/2}function a(g){return g.length-1}function l(g){return g.max-g.min}function c(g,b){var _={y:0};_[i]=g-s(b),_[i]&&(_[qO[i]]=0,e.moveElements([b],_,b.parent))}var u=t[0],f=a(t),h=t[f],d,p,m=0;k(t,function(g,b){var _,v,x;if(g.elements.length<2){b&&b!==t.length-1&&(o(g,g.elements[0]),m+=l(g.range));return}_=Fn(g.elements,i),v=_[0],b===f&&(v=_[a(_)]),x=s(v),g.range=null,k(_,function(C){if(c(x,C),g.range===null){g.range={min:C[i],max:C[i]+C[r]};return}o(g,C)}),b&&b!==t.length-1&&(m+=l(g.range))}),p=Math.abs(h.range.min-u.range.max),d=Math.round((p-m)/(t.length-1)),!(de;if(/n|w/.test(t))return n[i] required");var r=n.changed||[e],o=n.oldProperties||jF(t,di(i));return ik(t,i),n.oldProperties=o,n.changed=r,r};Ya.prototype.revert=function(n){var e=n.oldProperties,t=n.moddleElement,i=n.changed;return ik(t,e),i};function jF(n,e){return st(e,function(t,i){return t[i]=n.get(i),t},{})}function ik(n,e){k(e,function(t,i){n.set(i,t)})}function Xn(n,e,t){this._canvas=n,this._drdRules=e,t.invoke(Se,this)}fe(Xn,Se);Xn.$inject=["canvas","drdRules","injector"];Xn.prototype.claimId=function(n,e){this._commandStack.execute("id.updateClaim",{id:n,element:e,claiming:!0})};Xn.prototype.connect=function(n,e,t,i){var r=this._drdRules,o=this._canvas.getRootElement();return t||(t=r.canConnect(n,e)||{type:"dmn:Association"}),this.createConnection(n,e,t,o,i)};Xn.prototype.getHandlers=function(){var n=Se.prototype.getHandlers.call(this);return n["id.updateClaim"]=Ga,n["element.updateLabel"]=Dx,n["element.updateProperties"]=Xa,n["element.updateModdleProperties"]=Ya,n};Xn.prototype.unclaimId=function(n,e){this._commandStack.execute("id.updateClaim",{id:n,element:e})};Xn.prototype.updateModdleProperties=function(n,e,t){this._commandStack.execute("element.updateModdleProperties",{element:n,moddleElement:e,properties:t})};Xn.prototype.updateProperties=function(n,e){this._commandStack.execute("element.updateProperties",{element:n,properties:e})};Xn.prototype.updateLabel=function(n,e,t,i){this._commandStack.execute("element.updateLabel",{element:n,newLabel:e,newBounds:t,hints:i||{}})};function Om(){}Om.prototype.layoutConnection=function(n,e){return e=e||{},[e.connectionStart||le(e.source||n.source),e.connectionEnd||le(e.target||n.target)]};var km=20;function Za(n){this._connectionDocking=n}fe(Za,Om);Za.$inject=["connectionDocking"];Za.prototype.layoutConnection=function(n,e){var t=this._connectionDocking;e||(e={});var i=e.source||n.source,r=e.target||n.target,o=e.waypoints||n.waypoints||[],s=e.connectionStart,a=e.connectionEnd,l=vt(i,r);if(s||(s=rk(o[0],i)),a||(a=rk(o[o.length-1],r)),O(n,"dmn:InformationRequirement")){o=[s,a];var c=t.getCroppedWaypoints(T({},n,{waypoints:o}),i,r);a=c.pop();var u={x:a.x,y:a.y};return l.includes("bottom")?u.y+=km:l.includes("top")?u.y-=km:l.includes("right")?u.x+=km:u.x-=km,o=c.concat([u,a]),o}return[s,a]};function rk(n,e){return n?n.original||n:le(e)}function ok(n){return T({original:n.point.original||n.point},n.actual)}function Wi(n,e){this._elementRegistry=n,this._graphicsFactory=e}Wi.$inject=["elementRegistry","graphicsFactory"];Wi.prototype.getCroppedWaypoints=function(n,e,t){e=e||n.source,t=t||n.target;var i=this.getDockingPoint(n,e,!0),r=this.getDockingPoint(n,t),o=n.waypoints.slice(i.idx+1,r.idx);return o.unshift(ok(i)),o.push(ok(r)),o};Wi.prototype.getDockingPoint=function(n,e,t){var i=n.waypoints,r,o,s;return r=t?0:i.length-1,o=i[r],s=this._getIntersection(e,n,t),{point:o,actual:s||o,idx:r}};Wi.prototype._getIntersection=function(n,e,t){var i=this._getShapePath(n),r=this._getConnectionPath(e);return tf(i,r,t)};Wi.prototype._getConnectionPath=function(n){return this._graphicsFactory.getConnectionPath(n)};Wi.prototype._getShapePath=function(n){return this._graphicsFactory.getShapePath(n)};Wi.prototype._getGfx=function(n){return this._elementRegistry.getGraphics(n)};var sk={__init__:["modeling","drdUpdater"],__depends__:[LO,jO,Ca,xs,ht,Cm],drdFactory:["type",kn],drdUpdater:["type",Hi],elementFactory:["type",_r],modeling:["type",Xn],layouter:["type",Za],connectionDocking:["type",Wi]};var FF=500,qF=1e3;function Mr(n,e){this._eventBus=n,this.offset=5;var t=e.cls("djs-outline",["no-fill"]),i=this;function r(o){var s=Q("rect");return j(s,T({x:0,y:0,rx:4,width:100,height:100},t)),s}n.on(["shape.added","shape.changed"],FF,function(o){var s=o.element,a=o.gfx,l=X(".djs-outline",a);l||(l=i.getOutline(s)||r(a),K(a,l)),i.updateShapeOutline(l,s)}),n.on(["connection.added","connection.changed"],function(o){var s=o.element,a=o.gfx,l=X(".djs-outline",a);l||(l=r(a),K(a,l)),i.updateConnectionOutline(l,s)})}Mr.prototype.updateShapeOutline=function(n,e){var t=!1,i=this._getProviders();i.length&&k(i,function(r){t=t||r.updateOutline(e,n)}),t||j(n,{x:-this.offset,y:-this.offset,width:e.width+this.offset*2,height:e.height+this.offset*2})};Mr.prototype.updateConnectionOutline=function(n,e){var t=Tt(e);j(n,{x:t.x-this.offset,y:t.y-this.offset,width:t.width+this.offset*2,height:t.height+this.offset*2})};Mr.prototype.registerProvider=function(n,e){e||(e=n,n=qF),this._eventBus.on("outline.getProviders",n,function(t){t.providers.push(e)})};Mr.prototype._getProviders=function(){var n=this._eventBus.createEvent({type:"outline.getProviders",providers:[]});return this._eventBus.fire(n),n.providers};Mr.prototype.getOutline=function(n){var e,t=this._getProviders();return k(t,function(i){ge(i.getOutline)&&(e=e||i.getOutline(n))}),e};Mr.$inject=["eventBus","styles","elementRegistry"];var Rm=6;function Vf(n,e,t){this._canvas=e;var i=this;n.on("element.changed",function(r){t.isSelected(r.element)&&i._updateMultiSelectionOutline(t.get())}),n.on("selection.changed",function(r){var o=r.newSelection;i._updateMultiSelectionOutline(o)})}Vf.prototype._updateMultiSelectionOutline=function(n){var e=this._canvas.getLayer("selectionOutline");ss(e);var t=n.length>1,i=this._canvas.getContainer();if(ne(i)[t?"add":"remove"]("djs-multi-select"),!!t){var r=VF(Tt(n)),o=Q("rect");j(o,T({rx:3},r)),ne(o).add("djs-selection-outline"),K(e,o)}};Vf.$inject=["eventBus","canvas","selection"];function VF(n){return{x:n.x-Rm,y:n.y-Rm,width:n.width+Rm*2,height:n.height+Rm*2}}var Tm={__depends__:[ht],__init__:["outline","multiSelectionOutline"],outline:["type",Mr],multiSelectionOutline:["type",Vf]};var HF=500,zF=1250,WF=1500,Am=Math.round;function UF(n){return{x:n.x+Am(n.width/2),y:n.y+Am(n.height/2)}}function Mm(n,e,t,i,r){function o(a,l,c,u){return r.allowed("elements.move",{shapes:a,delta:l,position:c,target:u})}n.on("shape.move.start",WF,function(a){var l=a.context,c=a.shape,u=i.get().slice();u.indexOf(c)===-1&&(u=[c]),u=QF(u),T(l,{shapes:u,validatedShapes:u,shape:c})}),n.on("shape.move.start",zF,function(a){var l=a.context,c=l.validatedShapes,u;if(u=l.canExecute=o(c),!u)return!1}),n.on("shape.move.move",HF,function(a){var l=a.context,c=l.validatedShapes,u=a.hover,f={x:a.dx,y:a.dy},h={x:a.x,y:a.y},d;if(d=o(c,f,h,u),l.delta=f,l.canExecute=d,d===null){l.target=null;return}l.target=u}),n.on("shape.move.end",function(a){var l=a.context,c=l.delta,u=l.canExecute,f=u==="attach",h=l.shapes;if(u===!1)return!1;c.x=Am(c.x),c.y=Am(c.y),!(c.x===0&&c.y===0)&&t.moveElements(h,c,l.target,{primaryShape:l.shape,attach:f})}),n.on("element.mousedown",function(a){if(Sn(a)){var l=vr(a);if(!l)throw new Error("must supply DOM mousedown event");return s(l,a.element)}});function s(a,l,c,u){if(Pe(c)&&(u=c,c=!1),!(l.waypoints||!l.parent)&&!ne(a.target).has("djs-hit-no-move")){var f=UF(l),h=e.init(a,f,"shape.move",{cursor:"grabbing",autoActivate:c,data:{shape:l,context:u||{}}});if(h!==!1)return!0}}this.start=s}Mm.$inject=["eventBus","dragging","modeling","selection","rules"];function QF(n){var e=ur(n,"id");return Ee(n,function(t){for(;t=t.parent;)if(e[t.id])return!1;return!0})}var ak=499,Ix="djs-dragging",lk="drop-ok",ck="drop-not-ok",uk="new-parent",fk="attach-ok";function Pm(n,e,t,i){function r(l){var c=o(l),u=KF(c);return u}function o(l){var c=O1(l,!0),u=c.flatMap(d=>(d.incoming||[]).concat(d.outgoing||[])),f=c.concat(u),h=[...new Set(f)];return h}function s(l,c){[fk,lk,ck,uk].forEach(function(u){u===c?e.addMarker(l,u):e.removeMarker(l,u)})}function a(l,c,u){i.addDragger(c,l.dragGroup),u&&e.addMarker(c,Ix),l.allDraggedElements?l.allDraggedElements.push(c):l.allDraggedElements=[c]}n.on("shape.move.start",ak,function(l){var c=l.context,u=c.shapes,f=c.allDraggedElements,h=r(u);if(!c.dragGroup){var d=Q("g");j(d,t.cls("djs-drag-group",["no-events"]));var p=e.getActiveLayer();K(p,d),c.dragGroup=d}h.forEach(function(m){i.addDragger(m,c.dragGroup)}),f?f=Dw([f,o(u)]):f=o(u),k(f,function(m){e.addMarker(m,Ix)}),c.allDraggedElements=f,c.differentParents=GF(u)}),n.on("shape.move.move",ak,function(l){var c=l.context,u=c.dragGroup,f=c.target,h=c.shape.parent,d=c.canExecute;f&&(d==="attach"?s(f,fk):c.canExecute&&h&&f.id!==h.id?s(f,uk):s(f,c.canExecute?lk:ck)),jt(u,l.dx,l.dy)}),n.on(["shape.move.out","shape.move.cleanup"],function(l){var c=l.context,u=c.target;u&&s(u,null)}),n.on("shape.move.cleanup",function(l){var c=l.context,u=c.allDraggedElements,f=c.dragGroup;k(u,function(h){e.removeMarker(h,Ix)}),f&&Fe(f)}),this.makeDraggable=a}Pm.$inject=["eventBus","canvas","styles","previewSupport"];function KF(n){var e=Ee(n,function(t){return Xe(t)?ye(n,la({id:t.source.id}))&&ye(n,la({id:t.target.id})):!0});return e}function GF(n){return Lw(ur(n,function(e){return e.parent&&e.parent.id}))!==1}var hk={__depends__:[fo,ht,Tm,yn,gn,ka],__init__:["move","movePreview"],move:["type",Mm],movePreview:["type",Pm]};var dk=` M2.45221 16.0068L18.7175 1.74436L18.0615 0.996331L18.7175 1.74436C19.2646 1.26455 19.9676 1 20.6953 1H140.926C142.583 1 143.926 2.34295 143.926 3.99967L143.93 37.5457C143.93 38.3668 143.593 39.152 142.999 39.7183L143.689 40.4424L142.999 39.7183L127.299 54.6723C126.741 55.2036 126 55.5 125.23 55.5H4.53787C2.88599 55.5 1.54491 54.1646 1.5379 52.5127L1.43066 27.229L1.43065 27.2248L1.4301 18.2626C1.43005 17.3986 1.80255 16.5765 2.45221 16.0068Z `,pk=` M1.79494 63.0032L1.2941 63.6423L1.79493 63.0032C1.71778 62.9427 1.6428 62.8741 1.57288 62.8L1.01736 63.3241L1.57288 62.8C1.20495 62.41 1 61.8941 1 61.3579V2.65067C1 1.74066 1.73867 1.00345 2.64868 1.00526L108.006 1.2145C109.66 1.21778 111 2.55996 111 4.21449V21.7015V61.6762C111 63.3188 109.679 64.656 108.037 64.676L107.06 64.6879C106.66 64.6927 106.26 64.6165 105.89 64.4652C105.04 64.1176 104.222 63.78 103.43 63.4531C93.4866 59.3517 87.6891 56.9603 76.3991 58.1057C71.7035 58.5821 66.8747 60.74 61.5721 63.1744C61.3243 63.2881 61.0753 63.4026 60.825 63.5177C55.6712 65.8868 49.9696 68.5077 43.2365 70.3468C31.101 73.6617 15.2135 73.5179 1.79494 63.0032Z `,mk={width:135,height:46},gk={width:100,height:63};function Lx(n,e,t){return Q("path",{d:n,strokeWidth:2,transform:`translate(${e.x}, ${e.y})`,...t})}var Dm=5;function Ja(n,e){this._styles=e,n.registerProvider(this)}Ja.$inject=["outline","styles"];Ja.prototype.getOutline=function(n){let e=this._styles.cls("djs-outline",["no-fill"]);var t;return O(n,"dmn:InputData")?(t=Q("rect"),j(t,T({x:-Dm,y:-Dm,rx:27,width:n.width+Dm*2,height:n.height+Dm*2},e))):O(n,"dmn:BusinessKnowledgeModel")&&yk(n,"dmn:BusinessKnowledgeModel")?t=Lx(dk,{x:-6,y:-6},e):O(n,"dmn:KnowledgeSource")&&yk(n,"dmn:KnowledgeSource")&&(t=Lx(pk,{x:-6,y:-1.5},e)),t};Ja.prototype.updateOutline=function(n){return!!Ge(n,["dmn:InputData","dmn:BusinessKnowledgeModel","dmn:KnowledgeSource"])};function yk(n,e){var t;return e==="dmn:BusinessKnowledgeModel"?t=mk:e==="dmn:KnowledgeSource"&&(t=gk),n.width===t.width&&n.height===t.height}var vk={__depends__:[Tm],__init__:["outlineProvider"],outlineProvider:["type",Ja]};var bk=".djs-palette-toggle",_k=".entry",XF=bk+", "+_k,Bx="djs-palette-",YF="shown",Nx="open",xk="two-column",ZF=1e3;function nt(n,e){this._eventBus=n,this._canvas=e;var t=this;n.on("tool-manager.update",function(i){var r=i.tool;t.updateToolHighlight(r)}),n.on("i18n.changed",function(){t._update()}),n.on("diagram.init",function(){t._diagramInitialized=!0,t._rebuild()})}nt.$inject=["eventBus","canvas"];nt.prototype.registerProvider=function(n,e){e||(e=n,n=ZF),this._eventBus.on("palette.getProviders",n,function(t){t.providers.push(e)}),this._rebuild()};nt.prototype.getEntries=function(){var n=this._getProviders();return n.reduce(e3,{})};nt.prototype._rebuild=function(){if(this._diagramInitialized){var n=this._getProviders();n.length&&(this._container||this._init(),this._update())}};nt.prototype._init=function(){var n=this,e=this._eventBus,t=this._getParentContainer(),i=this._container=te(nt.HTML_MARKUP);t.appendChild(i),ee(t).add(Bx+YF),_t.bind(i,XF,"click",function(r){var o=r.delegateTarget;if(hr(o,bk))return n.toggle();n.trigger("click",r)}),q.bind(i,"mousedown",function(r){r.stopPropagation()}),_t.bind(i,_k,"dragstart",function(r){n.trigger("dragstart",r)}),e.on("canvas.resized",this._layoutChanged,this),e.fire("palette.create",{container:i})};nt.prototype._getProviders=function(n){var e=this._eventBus.createEvent({type:"palette.getProviders",providers:[]});return this._eventBus.fire(e),e.providers};nt.prototype._toggleState=function(n){n=n||{};var e=this._getParentContainer(),t=this._container,i=this._eventBus,r,o=ee(t),s=ee(e);"twoColumn"in n?r=n.twoColumn:r=this._needsCollapse(e.clientHeight,this._entries||{}),o.toggle(xk,r),s.toggle(Bx+xk,r),"open"in n&&(o.toggle(Nx,n.open),s.toggle(Bx+Nx,n.open)),i.fire("palette.changed",{twoColumn:r,open:this.isOpen()})};nt.prototype._update=function(){var n=X(".djs-palette-entries",this._container),e=this._entries=this.getEntries();no(n),k(e,function(t,i){var r=t.group||"default",o=X("[data-group="+Sa(r)+"]",n);o||(o=te('
    '),et(o,"data-group",r),n.appendChild(o));var s=t.html||(t.separator?'
    ':'
    '),a=te(s);if(o.appendChild(a),!t.separator&&(et(a,"data-action",i),t.title&&et(a,"title",t.title),t.className&&JF(a,t.className),t.imageUrl)){var l=te("");et(l,"src",t.imageUrl),a.appendChild(l)}}),this.open()};nt.prototype.trigger=function(n,e,t){var i,r,o=e.delegateTarget||e.target;return o?(i=et(o,"data-action"),r=e.originalEvent||e,this.triggerEntry(i,n,r,t)):e.preventDefault()};nt.prototype.triggerEntry=function(n,e,t,i){var r=this._entries,o,s;if(o=r[n],!!o&&(s=o.action,this._eventBus.fire("palette.trigger",{entry:o,event:t})!==!1)){if(ge(s)){if(e==="click")return s(t,i)}else if(s[e])return s[e](t,i);t.preventDefault()}};nt.prototype._layoutChanged=function(){this._toggleState({})};nt.prototype._needsCollapse=function(n,e){var t=50,i=Object.keys(e).length*46;return n=t.x&&e.yt.x&&e.y<=t.y?i={x:t.x,y:e.y,width:e.x-t.x,height:t.y-e.y}:e.x<=t.x&&e.y>t.y||e.x=t.y?i={x:e.x,y:t.y,width:t.x-e.x,height:e.y-t.y}:e.x>=t.x&&e.y>t.y||e.x>t.x&&e.y>=t.y?i={x:t.x,y:t.y,width:e.x-t.x,height:e.y-t.y}:i={x:t.x,y:t.y,width:0,height:0},i}var Ok={__depends__:[Im,Lm],__init__:["lassoTool"],lassoTool:["type",Ui]};var $x=1500,Rk="grab";function Eo(n,e,t,i,r,o){this._dragging=t,this._mouse=o;var s=this,a=i.get("keyboard",!1);r.registerTool("hand",{tool:"hand",dragging:"hand.move"}),n.on("element.mousedown",$x,function(l){if(hf(l))return s.activateMove(l.originalEvent,!0),!1}),a&&a.addListener($x,function(l){if(!(!kk(l.keyEvent)||s.isActive())){var c=s._mouse.getLastMoveEvent();s.activateMove(c,!!c)}},"keyboard.keydown"),a&&a.addListener($x,function(l){!kk(l.keyEvent)||!s.isActive()||s.toggle()},"keyboard.keyup"),n.on("hand.end",function(l){var c=l.originalEvent.target;if(!l.hover&&!(c instanceof SVGElement))return!1;n.once("hand.ended",function(){s.activateMove(l.originalEvent,{reactivate:!0})})}),n.on("hand.move.move",function(l){var c=e.viewbox().scale;e.scroll({dx:l.dx*c,dy:l.dy*c})}),n.on("hand.move.end",function(l){var c=l.context,u=c.reactivate;return!hf(l)&&u&&n.once("hand.move.ended",function(f){s.activateHand(f.originalEvent,!0,!0)}),!1})}Eo.$inject=["eventBus","canvas","dragging","injector","toolManager","mouse"];Eo.prototype.activateMove=function(n,e,t){typeof e=="object"&&(t=e,e=!1),this._dragging.init(n,"hand.move",{autoActivate:e,cursor:Rk,data:{context:t||{}}})};Eo.prototype.activateHand=function(n,e,t){this._dragging.init(n,"hand",{trapClick:!1,autoActivate:e,cursor:Rk,data:{context:{reactivate:t}}})};Eo.prototype.toggle=function(){if(this.isActive())return this._dragging.cancel();var n=this._mouse.getLastMoveEvent();this.activateHand(n,!!n)};Eo.prototype.isActive=function(){var n=this._dragging.context();return n?/^(hand|hand\.move)$/.test(n.prefix):!1};function kk(n){return Ve("Space",n)}var Tk={__depends__:[Im,Lm],__init__:["handTool"],handTool:["type",Eo]};function zf(n,e,t,i,r,o){this._palette=n,this._create=e,this._elementFactory=t,this._handTool=i,this._lassoTool=r,this._translate=o,n.registerProvider(this)}zf.$inject=["palette","create","elementFactory","handTool","lassoTool","translate"];zf.prototype.getPaletteEntries=function(n){var e={},t=this._create,i=this._elementFactory,r=this._handTool,o=this._lassoTool,s=this._translate;function a(l,c,u,f,h){function d(p){var m=i.createShape(T({type:l},h));t.start(p,m)}return{group:c,className:u,title:f,action:{dragstart:d,click:d}}}return T(e,{"hand-tool":{group:"tools",className:"dmn-icon-hand-tool",title:s("Activate hand tool"),action:{click:function(l){r.activateHand(l)}}},"lasso-tool":{group:"tools",className:"dmn-icon-lasso-tool",title:s("Activate lasso tool"),action:{click:function(l){o.activateSelection(l)}}},"tool-separator":{group:"tools",separator:!0},"create.decision":a("dmn:Decision","drd","dmn-icon-decision",s("Create decision")),"create.input-data":a("dmn:InputData","drd","dmn-icon-input-data",s("Create input data")),"create.knowledge-source":a("dmn:KnowledgeSource","drd","dmn-icon-knowledge-source",s("Create knowledge source")),"create.business-knowledge-model":a("dmn:BusinessKnowledgeModel","drd","dmn-icon-business-knowledge",s("Create knowledge model"))}),e};var Ak={__depends__:[qe,wk,Zp,Ok,Tk],__init__:["paletteProvider"],paletteProvider:["type",zf]};var Nm=Math.max,$m=Math.min,o3=20;function Mk(n,e,t){var i=t.x,r=t.y,o={x:n.x,y:n.y,width:n.width,height:n.height};return e.indexOf("n")!==-1?(o.y=n.y+r,o.height=n.height-r):e.indexOf("s")!==-1&&(o.height=n.height+r),e.indexOf("e")!==-1?o.width=n.width+i:e.indexOf("w")!==-1&&(o.x=n.x+i,o.width=n.width-i),o}function Bm(n,e,t){var i=e[n],r=t.min&&t.min[n],o=t.max&&t.max[n];return se(r)&&(i=(/top|left/.test(n)?$m:Nm)(i,r)),se(o)&&(i=(/top|left/.test(n)?Nm:$m)(i,o)),i}function Pk(n,e){if(!e)return n;var t=G(n);return Ov({top:Bm("top",t,e),right:Bm("right",t,e),bottom:Bm("bottom",t,e),left:Bm("left",t,e)})}function Dk(n,e,t,i){var r=G(e),o={top:/n/.test(n)?r.bottom-t.height:r.top,left:/w/.test(n)?r.right-t.width:r.left,bottom:/s/.test(n)?r.top+t.height:r.bottom,right:/e/.test(n)?r.left+t.width:r.right},s=i?G(i):o,a={top:$m(o.top,s.top),left:$m(o.left,s.left),bottom:Nm(o.bottom,s.bottom),right:Nm(o.right,s.right)};return Ov(a)}function Wf(n,e){return typeof n!="undefined"?n:o3}function s3(n,e){var t,i,r,o;return typeof e=="object"?(t=Wf(e.left),i=Wf(e.right),r=Wf(e.top),o=Wf(e.bottom)):t=i=r=o=Wf(e),{x:n.x-t,y:n.y-r,width:n.width+t+i,height:n.height+r+o}}function a3(n){return!(n.waypoints||n.type==="label")}function Ik(n,e){var t;if(n.length===void 0?t=Ee(n.children,a3):t=n,t.length)return s3(Tt(t),e)}var Lk=10;function ks(n,e,t,i){this._dragging=i,this._rules=e;var r=this;function o(l,c){var u=l.shape,f=l.direction,h=l.resizeConstraints,d;l.delta=c,d=Mk(u,f,c),l.newBounds=Pk(d,h),l.canExecute=r.canResize(l)}function s(l){var c=l.resizeConstraints,u=l.minBounds;c===void 0&&(u===void 0&&(u=r.computeMinResizeBox(l)),l.resizeConstraints={min:G(u)})}function a(l){var c=l.shape,u=l.canExecute,f=l.newBounds;if(u){if(f=F1(f),!l3(c,f))return;t.resizeShape(c,f)}}n.on("resize.start",function(l){s(l.context)}),n.on("resize.move",function(l){var c={x:l.dx,y:l.dy};o(l.context,c)}),n.on("resize.end",function(l){a(l.context)})}ks.prototype.canResize=function(n){var e=this._rules,t=hn(n,["newBounds","shape","delta","direction"]);return e.allowed("shape.resize",t)};ks.prototype.activate=function(n,e,t){var i=this._dragging,r,o;if(typeof t=="string"&&(t={direction:t}),r=T({shape:e},t),o=r.direction,!o)throw new Error("must provide a direction (n|w|s|e|nw|se|ne|sw)");i.init(n,jx(e,o),"resize",{autoActivate:!0,cursor:c3(o),data:{shape:e,context:r}})};ks.prototype.computeMinResizeBox=function(n){var e=n.shape,t=n.direction,i,r;return i=n.minDimensions||{width:Lk,height:Lk},r=Ik(e,n.childrenBoxPadding),Dk(t,e,i,r)};ks.$inject=["eventBus","rules","modeling","dragging"];function l3(n,e){return n.x!==e.x||n.y!==e.y||n.width!==e.width||n.height!==e.height}function jx(n,e){var t=le(n),i=G(n),r={x:t.x,y:t.y};return e.indexOf("n")!==-1?r.y=i.top:e.indexOf("s")!==-1&&(r.y=i.bottom),e.indexOf("e")!==-1?r.x=i.right:e.indexOf("w")!==-1&&(r.x=i.left),r}function c3(n){var e="resize-";return n==="n"||n==="s"?e+"ns":n==="e"||n==="w"?e+"ew":n==="nw"||n==="se"?e+"nwse":e+"nesw"}var Bk="djs-resizing",Nk="resize-not-ok",u3=500;function jm(n,e,t){function i(o){var s=o.shape,a=o.newBounds,l=o.frame;l||(l=o.frame=t.addFrame(s,e.getActiveLayer()),e.addMarker(s,Bk)),a.width>5&&j(l,{x:a.x,width:a.width}),a.height>5&&j(l,{y:a.y,height:a.height}),o.canExecute?ne(l).remove(Nk):ne(l).add(Nk)}function r(o){var s=o.shape,a=o.frame;a&&Fe(o.frame),e.removeMarker(s,Bk)}n.on("resize.move",u3,function(o){i(o.context)}),n.on("resize.cleanup",function(o){r(o.context)})}jm.$inject=["eventBus","canvas","previewSupport"];var Fm=-6,qm=8,Vm=20,Uf="djs-resizer",f3=["n","w","s","e","nw","ne","se","sw"];function Qi(n,e,t,i){this._resize=i,this._canvas=e;var r=this;n.on("selection.changed",function(o){var s=o.newSelection;r.removeResizers(),s.length===1&&k(s,at(r.addResizer,r))}),n.on("shape.changed",function(o){var s=o.element;t.isSelected(s)&&(r.removeResizers(),r.addResizer(s))})}Qi.prototype.makeDraggable=function(n,e,t){var i=this._resize;function r(o){Sn(o)&&i.activate(o,n,t)}q.bind(e,"mousedown",r),q.bind(e,"touchstart",r)};Qi.prototype._createResizer=function(n,e,t,i){var r=this._getResizersParent(),o=h3(i),s=Q("g");ne(s).add(Uf),ne(s).add(Uf+"-"+n.id),ne(s).add(Uf+"-"+i),K(r,s);var a=Q("rect");j(a,{x:-qm/2+o.x,y:-qm/2+o.y,width:qm,height:qm}),ne(a).add(Uf+"-visual"),K(s,a);var l=Q("rect");return j(l,{x:-Vm/2+o.x,y:-Vm/2+o.y,width:Vm,height:Vm}),ne(l).add(Uf+"-hit"),K(s,l),iC(s,e,t),s};Qi.prototype.createResizer=function(n,e){var t=jx(n,e),i=this._createResizer(n,t.x,t.y,e);this.makeDraggable(n,i,e)};Qi.prototype.addResizer=function(n){var e=this;Xe(n)||k(f3,function(t){e._resize.canResize({shape:n,direction:t})&&e.createResizer(n,t)})};Qi.prototype.removeResizers=function(){var n=this._getResizersParent();ss(n)};Qi.prototype._getResizersParent=function(){return this._canvas.getLayer("resizers")};Qi.$inject=["eventBus","canvas","selection","resize"];function h3(n){var e={x:0,y:0};return n.indexOf("e")!==-1?e.x=-Fm:n.indexOf("w")!==-1&&(e.x=Fm),n.indexOf("s")!==-1?e.y=-Fm:n.indexOf("n")!==-1&&(e.y=Fm),e}var $k={__depends__:[yn,gn,ka],__init__:["resize","resizePreview","resizeHandles"],resize:["type",ks],resizePreview:["type",jm],resizeHandles:["type",Qi]};var d3="reconnectStart",p3="reconnectEnd",m3=2e3;function Hm(n){n.on(["bendpoint.move.move","bendpoint.move.end"],m3,function(e){var t=e.context,i=t.allowed,r=t.hover,o=t.source,s=t.target,a=t.type;if(t.hints||(t.hints={}),delete t.hints.connectionStart,delete t.hints.connectionEnd,!(i&&i.type!=="dmn:InformationRequirement")&&!(!r||!Ge(r,["dmn:Decision","dmn:InputData"]))&&o!==s){var l=a===d3||a===p3,c=vt(o,s);l&&r===o?(g3(e,c),t.hints.connectionEnd=Fk(s,c)):l&&r===s&&(t.hints.connectionStart=jk(o,c),y3(e,c))}})}Hm.$inject=["eventBus"];function jk(n,e){var t=G(n),i=le(n);return e.includes("bottom")?i.y=t.top:e.includes("top")?i.y=t.bottom:e.includes("right")?i.x=t.left:i.x=t.right,i}function Fk(n,e){var t=G(n),i=le(n);return e.includes("bottom")?i.y=t.bottom:e.includes("top")?i.y=t.top:e.includes("right")?i.x=t.right:i.x=t.left,i}function g3(n,e){var t=n.context,i=t.source,r=jk(i,e),o=n.x-r.x,s=n.y-r.y;n.x-=o,n.y-=s,n.dx-=o,n.dy-=s}function y3(n,e){var t=n.context,i=t.target,r=Fk(i,e),o=0,s=0;e.includes("top")||e.includes("bottom")?s=n.y-r.y:o=n.x-r.x,n.x-=o,n.y-=s,n.dx-=o,n.dy-=s}var v3=250;function zm(n){n.on(["connect.hover","connect.move","connect.end"],v3,function(e){var t=e.context,i=t.canExecute,r=t.hover,o=t.source,s=t.target;if(i&&i.type==="dmn:InformationRequirement"){var a=vt(o,s);t.connectionStart=le(o),r===o?t.connectionEnd=le(s):t.connectionEnd={x:e.x,y:e.y},a.includes("bottom")?(t.connectionStart.y=G(o).top,t.connectionEnd.y=G(s).bottom):a.includes("top")?(t.connectionStart.y=G(o).bottom,t.connectionEnd.y=G(s).top):a.includes("right")?(t.connectionStart.x=G(o).left,t.connectionEnd.x=G(s).right):(t.connectionStart.x=G(o).right,t.connectionEnd.x=G(s).left)}else delete t.connectionStart,delete t.connectionEnd})}zm.$inject=["eventBus"];function vi(){this._targets={},this._snapOrigins={},this._snapLocations=[],this._defaultSnaps={}}vi.prototype.getSnapOrigin=function(n){return this._snapOrigins[n]};vi.prototype.setSnapOrigin=function(n,e){this._snapOrigins[n]=e,this._snapLocations.indexOf(n)===-1&&this._snapLocations.push(n)};vi.prototype.addDefaultSnap=function(n,e){var t=this._defaultSnaps[n];t||(t=this._defaultSnaps[n]=[]),t.push(e)};vi.prototype.getSnapLocations=function(){return this._snapLocations};vi.prototype.setSnapLocations=function(n){this._snapLocations=n};vi.prototype.pointsForTarget=function(n){var e=n.id||n,t=this._targets[e];return t||(t=this._targets[e]=new Wm,t.initDefaults(this._defaultSnaps)),t};function Wm(){this._snapValues={}}Wm.prototype.add=function(n,e){var t=this._snapValues[n];t||(t=this._snapValues[n]={x:[],y:[]}),t.x.indexOf(e.x)===-1&&t.x.push(e.x),t.y.indexOf(e.y)===-1&&t.y.push(e.y)};Wm.prototype.snap=function(n,e,t,i){var r=this._snapValues[e];return r&&ZE(n[t],r[t],i)};Wm.prototype.initDefaults=function(n){var e=this;k(n||{},function(t,i){k(t,function(r){e.add(i,r)})})};var x3=1250;function Rs(n,e,t){var i=this;this._elementRegistry=n,e.on(["create.start","shape.move.start"],function(r){i.initSnap(r)}),e.on(["create.move","create.end","shape.move.move","shape.move.end"],x3,function(r){var o=r.context,s=o.shape,a=o.snapContext,l=o.target;if(!(r.originalEvent&&Mt(r.originalEvent))&&!(wr(r)||!l)){var c=a.pointsForTarget(l);c.initialized||(c=i.addSnapTargetPoints(c,s,l),c.initialized=!0),t.snap(r,c)}}),e.on(["create.cleanup","shape.move.cleanup"],function(){t.hide()})}Rs.$inject=["elementRegistry","eventBus","snapping"];Rs.prototype.initSnap=function(n){var e=this._elementRegistry,t=n.context,i=t.shape,r=t.snapContext;r||(r=t.snapContext=new vi);var o;e.get(i.id)?o=ms(i,n):o={x:n.x+ms(i).x,y:n.y+ms(i).y};var s={x:o.x-i.width/2,y:o.y-i.height/2},a={x:o.x+i.width/2,y:o.y+i.height/2};return r.setSnapOrigin("mid",{x:o.x-n.x,y:o.y-n.y}),Bi(i)||(r.setSnapOrigin("top-left",{x:s.x-n.x,y:s.y-n.y}),r.setSnapOrigin("bottom-right",{x:a.x-n.x,y:a.y-n.y})),r};Rs.prototype.addSnapTargetPoints=function(n,e,t){var i=this.getSnapTargets(e,t);return k(i,function(r){if(Bi(r)){Bi(e)&&n.add("mid",ms(r));return}if(Xe(r)){if(r.waypoints.length<3)return;var o=r.waypoints.slice(1,-1);k(o,function(s){n.add("mid",s)});return}n.add("mid",ms(r))}),!se(e.x)||!se(e.y)||this._elementRegistry.get(e.id)&&n.add("mid",ms(e)),n};Rs.prototype.getSnapTargets=function(n,e){return zp(e).filter(function(t){return!b3(t)})};function b3(n){return!!n.hidden}var _3=1250;function Ts(n,e){var t=this;n.on(["resize.start"],function(i){t.initSnap(i)}),n.on(["resize.move","resize.end"],_3,function(i){var r=i.context,o=r.shape,s=o.parent,a=r.direction,l=r.snapContext;if(!(i.originalEvent&&Mt(i.originalEvent))&&!wr(i)){var c=l.pointsForTarget(s);c.initialized||(c=t.addSnapTargetPoints(c,o,s,a),c.initialized=!0),E3(a)&&vn(i,"x",i.x),S3(a)&&vn(i,"y",i.y),e.snap(i,c)}}),n.on(["resize.cleanup"],function(){e.hide()})}Ts.prototype.initSnap=function(n){var e=n.context,t=e.shape,i=e.direction,r=e.snapContext;r||(r=e.snapContext=new vi);var o=qk(t,i);return r.setSnapOrigin("corner",{x:o.x-n.x,y:o.y-n.y}),r};Ts.prototype.addSnapTargetPoints=function(n,e,t,i){var r=this.getSnapTargets(e,t);return k(r,function(o){n.add("corner",eS(o)),n.add("corner",JE(o))}),n.add("corner",qk(e,i)),n};Ts.$inject=["eventBus","snapping"];Ts.prototype.getSnapTargets=function(n,e){return zp(e).filter(function(t){return!w3(t,n)&&!Xe(t)&&!C3(t)&&!Bi(t)})};function qk(n,e){var t=le(n),i=G(n),r={x:t.x,y:t.y};return e.indexOf("n")!==-1?r.y=i.top:e.indexOf("s")!==-1&&(r.y=i.bottom),e.indexOf("e")!==-1?r.x=i.right:e.indexOf("w")!==-1&&(r.x=i.left),r}function w3(n,e){return n.host===e}function C3(n){return!!n.hidden}function E3(n){return n==="n"||n==="s"}function S3(n){return n==="e"||n==="w"}var O3=7,k3=1e3;function Ki(n){this._canvas=n,this._asyncHide=Mi(at(this.hide,this),k3)}Ki.$inject=["canvas"];Ki.prototype.snap=function(n,e){var t=n.context,i=t.snapContext,r=i.getSnapLocations(),o={x:wr(n,"x"),y:wr(n,"y")};k(r,function(s){var a=i.getSnapOrigin(s),l={x:n.x+a.x,y:n.y+a.y};if(k(["x","y"],function(c){var u;o[c]||(u=e.snap(l,s,c,O3),u!==void 0&&(o[c]={value:u,originValue:u-a[c]}))}),o.x&&o.y)return!1}),this.showSnapLine("vertical",o.x&&o.x.value),this.showSnapLine("horizontal",o.y&&o.y.value),k(["x","y"],function(s){var a=o[s];Pe(a)&&vn(n,s,a.originValue)})};Ki.prototype._createLine=function(n){var e=this._canvas.getLayer("snap"),t=Q("path");return j(t,{d:"M0,0 L0,0"}),ne(t).add("djs-snap-line"),K(e,t),{update:function(i){se(i)?n==="horizontal"?j(t,{d:"M-100000,"+i+" L+100000,"+i,display:""}):j(t,{d:"M "+i+",-100000 L "+i+", +100000",display:""}):j(t,{display:"none"})}}};Ki.prototype._createSnapLines=function(){this._snapLines={horizontal:this._createLine("horizontal"),vertical:this._createLine("vertical")}};Ki.prototype.showSnapLine=function(n,e){var t=this.getSnapLine(n);t&&t.update(e),this._asyncHide()};Ki.prototype.getSnapLine=function(n){return this._snapLines||this._createSnapLines(),this._snapLines[n]};Ki.prototype.hide=function(){k(this._snapLines,function(n){n.update()})};var Vk={__init__:["createMoveSnapping","resizeSnapping","snapping"],createMoveSnapping:["type",Rs],resizeSnapping:["type",Ts],snapping:["type",Ki]};var Hk={__depends__:[Vk],__init__:["bendpointSnapping","connectSnapping"],bendpointSnapping:["type",Hm],connectSnapping:["type",zm]};function So(n){br.call(this,n)}fe(So,br);So.prototype._modelingModules=[CE,ME,LE,nS,oO,sO,lO,fO,pO,mO,xO,_O,wO,kO,PO,sk,hk,vk,Ak,$k,Hk];So.prototype._modules=[].concat(So.prototype._modules,So.prototype._modelingModules);function Fx(n){let e={variables:[],rootElement:V3(n)};for(let t=n;t;t=t.$parent)R3(t,e);return e.variables}function R3(n,e){el(n,"dmn:Decision")?T3(n,e):el(n,"dmn:BusinessKnowledgeModel")?A3(n,e):el(n,"dmn:Expression")&&j3(n,e)}function T3(n,e){for(let t of n.get("informationRequirement"))M3(t,e);for(let t of n.get("knowledgeRequirement"))Wk(t,e)}function A3(n,e){for(let t of n.get("knowledgeRequirement"))Wk(t,e)}function M3(n,e){let t=n.get("requiredInput");t&&P3(t,e);let i=n.get("requiredDecision");i&&D3(i,e)}function P3(n,e){let t=qx(n,e.rootElement);if(!t)return;let i=t.get("name");i&&e.variables.push({name:i,origin:t})}function D3(n,e){let t=qx(n,e.rootElement);if(!t)return;let i=t.get("name");if(!i)return;let r={name:i,origin:t},o=t.get("decisionLogic");o&&I3(o,r,e),e.variables.push(r)}function I3(n,e,t){if(el(n,"dmn:DecisionTable")){let i=n.get("output");L3(i,e,t)}}function L3(n,e,t){if(n.length===1){let r={...zk(n[0]),name:e.name};Object.assign(e,r);return}let i=n.map(zk);e.entries=i.filter(r=>!!r.name)}function zk(n){let e={name:n.name};return n.typeRef&&(e.detail=n.typeRef),e}function Wk(n,e){let t=n.get("requiredKnowledge");t&&B3(t,e)}function B3(n,e){let t=qx(n,e.rootElement);t&&el(t,"dmn:BusinessKnowledgeModel")&&N3(t,e)}function N3(n,e){let t=n.get("name");if(!t)return;let i={name:t,origin:n},r=n.get("encapsulatedLogic");r&&$3(r,i),e.variables.push(i)}function $3(n,e,t){let r=n.get("formalParameter").map((o,s)=>{let a={name:o.get("name")||`param ${s+1}`,type:o.get("typeRef")};return a.type||delete a.type,a});Object.assign(e,{type:"function",params:r})}function j3(n,e){el(n,"dmn:FunctionDefinition")&&F3(n,e)}function F3(n,e){let t=n.get("formalParameter");for(let i of t)q3(i,e)}function q3(n,e){let t=n.get("name");if(!t)return;let i={name:t,origin:n};n.get("typeRef")&&(i.detail=n.get("typeRef")),e.variables.push(i)}function V3(n){let e=n;for(;e.$parent;)e=e.$parent;return e}function qx(n,e){let t=n.get("href");if(!t||!t.startsWith("#"))return;let i=t.slice(1);return e.get("drgElement").find(o=>o.get("id")===i)}function el(n,e){return n.$instanceOf(e)}var Qf=class{constructor(e){e.registerProvider(this)}getVariables(e,t){return e.concat(Fx(t))}};Qf.$inject=["variableResolver"];var Um=class{constructor(){this._providers=[]}registerProvider(e){this._providers.push(e)}getVariables(e){return this._providers.reduce((t,i)=>i.getVariables(t,e),[])}};var tl={__init__:["dmnVariableProvider"],dmnVariableProvider:["type",Qf],variableResolver:["type",Um]};var Oo=class{constructor(e){T(this,e),Dr(this,"businessObject",{writable:!0})}},Vx=class extends Oo{constructor(e){super(e),Dr(this,"rows",{enumerable:!0,value:this.rows||[]}),Dr(this,"cols",{enumerable:!0,value:this.cols||[]})}},pt=class extends Oo{constructor(e){super(e),Dr(this,"root",{writable:!0}),Dr(this,"cells",{enumerable:!0,value:this.cells||[]})}},mt=class extends Oo{constructor(e){super(e),Dr(this,"root",{writable:!0}),Dr(this,"cells",{enumerable:!0,value:this.cells||[]})}},ko=class extends Oo{constructor(e){super(e),Dr(this,"row",{writable:!0}),Dr(this,"col",{writable:!0})}},H3={root:Vx,row:pt,col:mt,cell:ko};function Uk(n,e){let t=H3[n];if(!t)throw new Error("unknown type "+n);return new t(e)}function Dr(n,e,t){Object.defineProperty(n,e,t)}var As=class{constructor(){this._uid=12}create(e,t={}){return t.id||(t.id=e+"_"+this._uid++),Uk(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)}};var nl=class{constructor(e){this._eventBus=e,this._elements={},e.on("table.clear",this.clear.bind(this))}add(e,t){let{id:i}=e;this._elements[i]=e}remove(e){let t=e.id||e;delete this._elements[t]}get(e){return this._elements[e]}getAll(){return Hx(this._elements)}forEach(e){Hx(this._elements).forEach(t=>e(t))}filter(e){return Hx(this._elements).filter(t=>e(t))}clear(){this._elements={}}updateId(e,t){this._validateId(t),typeof e=="string"&&(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")}};nl.$inject=["eventBus"];function Hx(n){return Object.keys(n).map(function(e){return n[e]})}var il=class{constructor(e){this._listeners={},e.on("elements.changed",({elements:t})=>{this.elementsChanged(t)}),e.on("root.remove",t=>{let i=t.root.id;this._listeners[i]&&e.once("root.add",r=>{let o=r.root.id;this.updateId(i,o)})}),e.on("element.updateId",({element:t,newId:i})=>{this.updateId(t.id,i)})}elementsChanged(e){let t={},i=e.length;for(let r=0;rP(2,l,null,c)),y(1,"div","tjs-table-container",y(1,"table","tjs-table",[o&&P(2,o,{rows:e,cols:t}),s&&P(2,s,{rows:e,cols:t}),a&&P(2,a,{rows:e,cols:t})],0),2,{onScroll:this.onScroll}),r&&r.map((l,c)=>P(2,l,null,c))],0)}};var rl=class{constructor(e,t,i,r,o){let{container:s}=i;this._container=s,r.on("root.added",()=>{xa(P(2,Gf,{injector:o}),s)}),r.on("root.remove",()=>{xa(null,s)})}getContainer(){return this._container}};rl.$inject=["changeSupport","components","config.renderer","eventBus","injector"];var Qm={__init__:["changeSupport","components","renderer"],changeSupport:["type",il],components:["type",Kf],renderer:["type",rl]};var ol=class{constructor(e,t){this._elementRegistry=e,this._eventBus=t,this._root=null,t.on("table.clear",()=>{this.setRoot(null)})}setRoot(e){if(this._root){let t=this._root;this._eventBus.fire("root.remove",{root:t}),this._root=null,this._eventBus.fire("root.removed",{root:t})}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){let i=this.getRoot();if(i.cols.length!=e.cells.length)throw new Error("number of cells is not equal to number of cols");return typeof t=="undefined"&&(t=i.rows.length),Km(t,i.rows,e),e.root=i,this._elementRegistry.add(e),e.cells.forEach((r,o)=>{this._elementRegistry.add(r),r.row=e,r.col=i.cols[o],Km(t,i.cols[o].cells,r)}),this._eventBus.fire("row.add",{row:e}),e}removeRow(e){let t=this.getRoot();typeof e=="string"&&(e=this._elementRegistry.get(e));let i=t.rows.indexOf(e);i!==-1&&(Gm(i,t.rows),e.root=void 0,this._elementRegistry.remove(e),e.cells.forEach((r,o)=>{this._elementRegistry.remove(r),r.col=void 0,Gm(i,t.cols[o].cells)}),this._eventBus.fire("row.remove",{row:e}))}addCol(e,t){let i=this.getRoot();if(this._elementRegistry.add(e),i.rows.length!=e.cells.length)throw new Error("number of cells is not equal to number of rows");return typeof t=="undefined"&&(t=i.cols.length),Km(t,i.cols,e),e.root=i,e.cells.forEach((r,o)=>{this._elementRegistry.add(r),r.col=e,r.row=i.rows[o],Km(t,i.rows[o].cells,r)}),this._eventBus.fire("col.add",{col:e}),e}removeCol(e){let t=this.getRoot();typeof e=="string"&&(e=this._elementRegistry.get(e));let i=t.cols.indexOf(e);i!==-1&&(Gm(i,t.cols),e.root=void 0,this._elementRegistry.remove(e),e.cells.forEach((r,o)=>{this._elementRegistry.remove(r),r.row=void 0,Gm(i,t.rows[o].cells)}),this._eventBus.fire("col.remove",{col:e}))}resized(){this._eventBus.fire("sheet.resized")}};ol.$inject=["elementRegistry","eventBus"];function Km(n,e,t){return e.splice(n,0,t)}function Gm(n,e){return e.splice(n,1)}function Xm(n=!0){let e=typeof n=="number"?n:n?300:0;return e?t=>Nw(t,e):t=>t}Xm.$inject=["config.throttle"];var Qk={__depends__:[Qm],__init__:["elementFactory","sheet"],elementFactory:["type",As],elementRegistry:["type",nl],eventBus:["type",ut],sheet:["type",ol],throttle:["factory",Xm]};var Xf=class{constructor(e={}){let{injector:t}=e;if(!t){let{modules:i,config:r}=this._init(e);t=W3(r,i)}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,...i}=e;return{modules:t,config:i}}destroy(){let e=this.get("eventBus");e.fire("table.destroy"),e.fire("diagram.destroy")}clear(){let e=this.get("eventBus");e.fire("table.clear"),e.fire("diagram.clear")}};function W3(n,e){let t=[{config:["value",n]},Qk].concat(e||[]),i=new os(t);return i.init(),i}var Kk=Xf;function Ym(n){if(!n)return"";let e=n.id?` id="${n.id}"`:"";return`<${n.$type}${e} />`}function zx(n,e){function t(l,c,u){var f=l.gfx;if(f)throw new Error(`already rendered ${Ym(l)}`);return n.element(l,c,u)}function i(l){return n.table(l)}function r(l){l.id||(l.id="decision");let c=l.decisionLogic;if(c){if(!c.output)throw new Error(`missing output for ${Ym(c)}`);let u=i(c);c.input&&o(c.input,u,c),o(c.output,u,c),s(c.rule,u,c)}else throw new Error(`no table for ${Ym(l)}`)}function o(l,c,u){k(l,function(f){t(f,c,u)})}function s(l,c,u){k(l,function(f){t(f,c,u),a(f.inputEntry,f),a(f.outputEntry,f)})}function a(l,c,u){k(l,function(f){t(f,c,u)})}return{handleDecision:r}}function Gk(n,e,t){let i=n.get("tableImporter"),r=n.get("eventBus"),o=n.get("sheet"),s=n.get("modeling",!1),a,l=[];function c(u){let f={create(d,p,m,g){return i.create(d,p,m,g)},table(d){return i.add(d)},element(d,p,m){return i.add(d,p,m)},error(d,p){l.push({message:d,context:p})}};new zx(f,{canAddMissingEntries:s}).handleDecision(u)}r.fire("import.render.start",{decision:e});try{c(e)}catch(u){a=u}r.fire("import.render.complete",{error:a,warnings:l}),r.fire("elements.changed",{elements:[o.getRoot()]}),t(a,l)}function U3(){return{elements:[],index:{}}}function Xk(n,e){let{elements:t,index:i}=n;return i[e]?n:{elements:[...t,e],index:{...i,[e]:!0}}}function Q3(n,e){return n.elements.join(e)}function Ro(...n){let e=U3();return n.forEach(function(t){let i=typeof t;i==="string"&&t.length>0?e=Xk(e,t):i==="object"&&t!==null&&Object.keys(t).forEach(function(r){t[r]&&(e=Xk(e,r))})}),Q3(e," ")}function Ce(n){let e=n.constructor;return Zm(e,n)}function Zm(n,e){let t=n.$inject;if(!t)return;let{injector:i}=e.context,r=[...t,function(...o){for(let s in o){let a=t[s],l=o[s];e[a]=l}}];i.invoke(r)}function Wx(n,...e){return function(...t){let i;return e.forEach(function(r){if(i=r.call(n,...t),typeof i!="undefined")return!1}),i}.bind(n)}function Ut(n,e){Object.keys(e).forEach(function(t){if(t==="$inject"||t==="__init")return;let i=e[t];t==="constructor"&&i.call(n,n.props,n.context);let r=n[t];if(typeof r!="undefined"){if(typeof r!="function")throw new Error(`failed to mixin <${t}>: cannot combine with non-fn component value`);n[t]=Wx(n,r,i)}else n[t]=i.bind(n)}),"$inject"in e&&Zm(e,n),"__init"in e&&e.__init.call(n,n.props,n.context)}var Yk={getSelectionClasses(){let{selected:n,selectedSecondary:e,focussed:t}=this.state;return Ro({selected:n,"selected-secondary":e,focussed:t})},selectionChanged(n){this.setState(n)},componentWillUpdate(n){n.elementId!==this.props.elementId&&this.updateSelectionSubscription(!1)},componentDidUpdate(n){n.elementId!==this.props.elementId&&this.updateSelectionSubscription(!0)},componentDidMount(){this.updateSelectionSubscription(!0)},componentWillUnmount(){this.updateSelectionSubscription(!1)},updateSelectionSubscription(n){let{elementId:e}=this.props;e&&e&&this.eventBus[n?"on":"off"](`selection.${e}.changed`,this.selectionChanged)}},Yf=Yk;Yk.$inject=["eventBus"];var Zf=class extends L{constructor(e,t){super(e,t),Ut(this,Yf),Ce(this)}getRenderProps(...e){let{className:t,elementId:i,coords:r,...o}=this.props,s={className:Ro(...e,this.getSelectionClasses(),t)};return i&&(s["data-element-id"]=i),r&&(s["data-coords"]=r),{...s,...o}}};var Rn=class extends Zf{constructor(e,t){super(e,t),this.state={}}render(){let{children:e}=this.props,t=this.getRenderProps("cell");return En(y(1,"td",null,e,0,{...t}))}};var Zk={slotFill(n,e){let{type:t,context:i,...r}=n,o=this.components.getComponent(t,i)||e;return o?En(P(2,o,{...i,...r})):null},slotFills(n){let{type:e,context:t,...i}=n;return this.components.getComponents(e,t).map(o=>En(P(2,o,{...t,...i})))}},xi=Zk;Zk.$inject=["components"];var Jk=400,To=class extends L{constructor(t,i){super(t,i);M(this,"onElementsChanged",()=>{this.forceUpdate()});Ut(this,xi),Ce(this)}componentDidMount(){this.changeSupport.onElementsChanged(this.getRoot(),this.onElementsChanged)}componentWillUnmount(){this.changeSupport.offElementsChanged(this.getRoot(),this.onElementsChanged)}getRoot(){return this.sheet.getRoot()}render(){let r=(this.getRoot().businessObject.get("annotationsWidth")||Jk)+"px";return y(1,"th","annotation header",[this.slotFills({type:"cell-inner",context:{cellType:"annotations",col:this.sheet.getRoot(),minWidth:Jk}}),this.translate("Annotations")],0,{style:{width:r}})}};To.$inject=["changeSupport","sheet","translate"];function Ux(n){let{row:e}=n,{id:t,description:i}=e.businessObject;return P(2,Rn,{className:"annotation",elementId:t,children:i||"-"})}function Jm(n){n.onGetComponent("cell",({cellType:e})=>{if(e==="after-label-cells")return To;if(e==="after-rule-cells")return Ux})}Jm.$inject=["components"];var eR={__init__:["annotationsProvider"],annotationsProvider:["type",Jm]};function Jf(n,e){return T({id:n.id,type:n.$type,businessObject:n},e)}var sl=class{constructor(e,t,i){this._elementFactory=e,this._eventBus=t,this._sheet=i}add(e){let t;if(O(e,"dmn:DecisionTable"))t=this._elementFactory.createRoot(Jf(e)),this._sheet.setRoot(t);else if(O(e,"dmn:InputClause"))t=this._elementFactory.createCol(Jf(e)),this._sheet.addCol(t);else if(O(e,"dmn:OutputClause"))t=this._elementFactory.createCol(Jf(e)),this._sheet.addCol(t);else if(O(e,"dmn:DecisionRule")){e.inputEntry||(e.inputEntry=[]),e.outputEntry||(e.outputEntry=[]);let i=[...e.inputEntry,...e.outputEntry].map(r=>this._elementFactory.createCell(Jf(r)));t=this._elementFactory.createRow(T(Jf(e),{cells:i})),this._sheet.addRow(t)}return this._eventBus.fire("dmnElement.added",{element:t}),t}};sl.$inject=["elementFactory","eventBus","sheet"];var tR={__depends__:[qe],tableImporter:["type",sl]};var nR={__depends__:[tR,Qm]};var eh=class extends L{constructor(t,i){super(t,i);M(this,"onElementsChanged",()=>{this.forceUpdate()});Ut(this,xi),this._sheet=i.injector.get("sheet"),this._changeSupport=i.changeSupport}componentWillMount(){let t=this._sheet.getRoot();this._changeSupport.onElementsChanged(t.id,this.onElementsChanged)}componentWillUnmount(){let t=this._sheet.getRoot();this._changeSupport.offElementsChanged(t.id,this.onElementsChanged)}render(){let t=this._sheet.getRoot();if(!O(t,"dmn:DMNElement"))return null;let i=Ke(t),r=i.input,o=i.output;return y(1,"thead",null,y(1,"tr",null,[y(1,"th","index-column"),this.slotFills({type:"cell",context:{cellType:"before-label-cells"}}),r&&r.map((s,a)=>{let l=s.width||"192px";return this.slotFill({type:"cell",context:{cellType:"input-header",input:s,index:a,inputsLength:r.length,width:l},key:s.id},K3)}),o.map((s,a)=>this.slotFill({type:"cell",context:{cellType:"output-header",output:s,index:a,outputsLength:o.length},key:s.id},G3)),this.slotFills({type:"cell",context:{cellType:"after-label-cells"}})],0),2)}};function K3(n,e){let{input:t,className:i,index:r}=n,{label:o,inputExpression:s,inputValues:a}=t,l=e.injector.get("translate"),c=(i||"")+" input-cell";return y(1,"th",c,[y(1,"div","clause",l(r===0?"When":"And"),0),o?y(1,"div","input-label",o,0,{title:l("Input label: ")+o}):y(1,"div","input-expression",s.text,0,{title:l("Input expression: ")+s.text}),y(1,"div","input-variable",a&&a.text||s.typeRef,0,{title:a&&a.text?l("Input values"):l("Input type")})],0,{"data-col-id":t.id},t.id)}function G3(n,e){let{output:t,className:i,index:r}=n,{label:o,name:s,outputValues:a,typeRef:l}=t,c=e.injector.get("translate"),u=(i||"")+" output-cell";return y(1,"th",u,[y(1,"div","clause",c(r===0?"Then":"And"),0),o?y(1,"div","output-label",o,0,{title:c("Output label")}):y(1,"div","output-name",s,0,{title:c("Output name")}),y(1,"div","output-variable",a&&a.text||l,0,{title:a&&a.text?c("Output values"):c("Output type")})],0,null,t.id)}function eg(n){n.onGetComponent("table.head",()=>eh)}eg.$inject=["components"];var iR={__init__:["decisionTableHeadProvider"],decisionTableHeadProvider:["type",eg]};var al=class extends L{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),Ce(this)}render(){let e=this.sheet.getRoot();if(!O(e,"dmn:DMNElement"))return null;let{name:t}=e.businessObject.$parent,i=this.components.getComponent("hit-policy")||X3;return y(1,"div","decision-table-properties",[y(1,"div","decision-table-name",t,0,{title:this._translate("Decision name: ")+t}),y(1,"div","decision-table-header-separator"),P(2,i)],4)}};al.$inject=["sheet","components"];function X3(){return null}var Y3=500,ll=class{constructor(e){e.onGetComponent("table.before",Y3,()=>al)}};ll.$inject=["components"];var rR={__init__:["decisionTableProperties"],decisionTableProperties:["type",ll]};var th=class extends L{render(){let{row:e,rowIndex:t}=this.props,{components:i}=this.context,r=i.getComponents("cell-inner",{cellType:"rule-index",row:e,rowIndex:t});return y(1,"td","rule-index",[r&&r.map(o=>P(2,o,{row:e,rowIndex:t})),t+1],0,{"data-element-id":e.id,"data-row-id":e.id})}};var cl=class{constructor(e){e.onGetComponent("cell",({cellType:t})=>{if(t==="before-rule-cells")return th})}};cl.$inject=["components"];var oR={__init__:["decisionRuleIndices"],decisionRuleIndices:["type",cl]};var Z3=[{label:"FEEL",value:"feel"}],ul=class{constructor(e){this._injector=e;let t=e.get("config.expressionLanguages")||{};this._config={options:Z3,defaults:{editor:"feel"}},t.options&&(this._config.options=t.options);let i=this._getLegacyDefaults();T(this._config.defaults,i,t.defaults)}getDefault(e){let{defaults:t}=this._config,i=t[e]||t.editor;return this._getLanguageByValue(i)||this.getAll()[0]}getLabel(e){let t=this._getLanguageByValue(e);return t?t.label:e}getAll(){return this._config.options}_getLegacyDefaults(){let e={},t=this._injector,i=t.get("config.defaultInputExpressionLanguage"),r=t.get("config.defaultOutputExpressionLanguage");return i&&(e.inputCell=i),r&&(e.outputCell=r),e}_getLanguageByValue(e){return ye(this.getAll(),t=>e===t.value)}};ul.$inject=["injector"];var Qt={__init__:["expressionLanguages"],expressionLanguages:["type",ul]};var fl=class{constructor(e){this._feelLanguageContext=e}getConfig(){return this._feelLanguageContext}};fl.$inject=["config.feelLanguageContext"];var Yn={__init__:["feelLanguageContext"],feelLanguageContext:["type",fl]};var nh=class extends L{render({rows:e,cols:t}){let{components:i}=this.context;return y(1,"tbody",null,e.map((r,o)=>{let s=i.getComponent("row",{rowType:"rule"});return s&&P(2,s,{row:r,rowIndex:o,cols:t},r.id)}),0)}};var ih=class extends L{constructor(e,t){super(e,t),Ut(this,xi)}render(){let{row:e,rowIndex:t,cols:i}=this.props,{cells:r}=e;return y(1,"tr",null,[this.slotFills({type:"cell",context:{cellType:"before-rule-cells",row:e,rowIndex:t}}),r.map((o,s)=>this.slotFill({type:"cell",context:{cellType:"rule",cell:o,rowIndex:t,colIndex:s},key:o.id,row:e,col:i[s]})),this.slotFills({type:"cell",context:{cellType:"after-rule-cells",row:e,rowIndex:t}})],0)}};var rh=class extends L{render(){let{cell:e,row:t,col:i}=this.props;return O(e,"dmn:UnaryTests")?P(2,Rn,{className:"input-cell",elementId:e.id,"data-row-id":t.id,"data-col-id":i.id,children:e.businessObject.text}):P(2,Rn,{className:"output-cell",elementId:e.id,"data-row-id":t.id,"data-col-id":i.id,children:e.businessObject.text})}};var hl=class{constructor(e){e.onGetComponent("table.body",()=>nh),e.onGetComponent("row",({rowType:t})=>{if(t==="rule")return ih}),e.onGetComponent("cell",({cellType:t})=>{if(t==="rule")return rh})}};hl.$inject=["components"];var tg={__depends__:[Qt,Yn],__init__:["decisionRules"],decisionRules:["type",hl]};var oh=[{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"}];var dl=class extends L{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),Ce(this)}getRoot(){return this.sheet.getRoot()}render(){let e=this.getRoot(),t=e.businessObject,{aggregation:i,hitPolicy:r}=t,o=ye(oh,s=>J3(s.value,{aggregation:i,hitPolicy:r}));return y(1,"div","hit-policy header",[y(1,"label","dms-label",this._translate("Hit policy:"),0),y(1,"span","hit-policy-value",this._translate(o.label),0)],4,{title:this._translate(o.explanation)})}};dl.$inject=["sheet"];function J3(n,e){return n.hitPolicy===e.hitPolicy&&n.aggregation===e.aggregation}function ng(n){n.onGetComponent("hit-policy",()=>dl)}ng.$inject=["components"];var sR={__init__:["hitPolicyProvider"],hitPolicyProvider:["type",ng]};var sh=class extends L{constructor(t,i){super(t,i);M(this,"onClick",()=>{this._eventBus.fire("showDrd")});let{injector:r}=i;this._translate=r.get("translate"),this._eventBus=r.get("eventBus")}render(){return y(1,"div","view-drd",y(1,"button","view-drd-button",this._translate("View DRD"),0,{type:"button",onClick:this.onClick}),2,null,null,t=>this.node=t)}};var pl=class{constructor(e,t,i,r){this._injector=i,this._sheet=r,e.onGetComponent("table.before",()=>{if(this.canViewDrd())return sh}),t.on("showDrd",()=>{let o=i.get("_parent",!1),s=r.getRoot(),a=aR(s);if(!a)return;let l=o.getView(a);o.open(l)})}canViewDrd(){let e=this._injector.get("_parent",!1);if(!e)return!1;let t=this._sheet.getRoot(),i=aR(t);return!!e.getView(i)}};pl.$inject=["components","eventBus","injector","sheet"];function aR(n){let{businessObject:e}=n;return e?e.$parent.$parent:void 0}var lR={__init__:["viewDrd"],viewDrd:["type",pl]};var ml=class{constructor(e){e.onGetComponent("table.before",()=>co)}};ml.$inject=["components"];var cR={__init__:["poweredBy"],poweredBy:["type",ml]};var Ao=class n extends Kk{constructor(e={}){let t=n._createContainer();super(T(e,{renderer:{container:t}})),this._container=t}open(e){var t=this;return new Promise((i,r)=>{var o;try{return t._decision&&t.clear(),t._decision=e,Gk(t,e,function(s,a){s?(s.warnings=a||[],r(s)):i({warnings:a||[]})})}catch(s){o=s}o?(o.warnings=o.warnings||[],r(o)):i({warnings:[]})})}_init(e){let{modules:t,additionalModules:i,...r}=e,o=t||this.getModules(),s=i||[],a=[{decisionTable:["value",this]}];return{modules:[cR,...o,...s,...a],config:r}}on(e,t,i,r){return this.get("eventBus").on(e,t,i,r)}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();let t=this._container;e.appendChild(t),this._emit("attach",{})}detach(){let e=this._container;e.parentNode&&(this._emit("detach",{}),Qe(e))}destroy(){super.destroy(),this.detach()}getModules(){return n._getModules()}static _getModules(){return[eR,nR,qe,iR,rR,oR,tg,sR,lR]}static _createContainer(){return te('
    ')}};var gl=class extends L{constructor(t,i){super(t,i);M(this,"handleClick",t=>{t.stopPropagation(),this.addRule(t.target.dataset.colIndex)});Ce(this),this.addRule=this.addRule.bind(this)}componentWillMount(){this._eventBus=this.context.injector.get("eventBus")}addRule(t){this._eventBus.fire("addRule",{colIndex:t})}render(){let{cols:t}=this.props,i=[y(1,"td","add-rule-add",y(1,"button","dmn-icon-plus action-icon",null,1,{title:this.translate("Add rule")}),2)],{businessObject:r}=this.sheet.getRoot();(!r.input||!r.input.length)&&i.push(y(1,"td","input-cell",Z("-"),2));for(let o=0;ogl),i.on("addRule",(o,s)=>{let a=t.trigger("addRule"),l=s.colIndex;a.cells[l]?r.select(a.cells[l]):r.select(a.cells[0])})}};yl.$inject=["components","editorActions","eventBus","selection"];var vl=class{constructor(e,t,i){this._elementRegistry=e,this._eventBus=t,this._renderer=i,this._selection=void 0,t.on("diagram.clear",()=>{this._selection=void 0})}select(e){Ie(e)&&(e=this._elementRegistry.get(e));let t=this._selection;t!==e&&(this._selection=e,this._eventBus.fire("selection.changed",{oldSelection:t,selection:e}))}deselect(){let e=this._selection;this._selection=void 0,this._eventBus.fire("selection.changed",{oldSelection:e,selection:this._selection})}get(){return this._selection}hasSelection(){return!!this._selection}};vl.$inject=["elementRegistry","eventBus","renderer"];var xl=class{constructor(e,t,i,r){this._elementRegistry=e,this._renderer=i,this._selection=r,t.on(["cell.click","cell.contextmenu"],({id:o})=>{let s=e.get(o);s&&r.select(s)}),t.on("row.remove",({row:o})=>{let s=r.get();s&&o===s.row&&r.deselect()}),t.on("col.remove",({col:o})=>{let s=r.get();s&&o===s.col&&r.deselect()})}};xl.$inject=["elementRegistry","eventBus","renderer","selection"];var Mo={__init__:["selection","selectionBehavior"],selection:["type",vl],selectionBehavior:["type",xl]};function e5(n,e,t){return(e=t5(e))in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function t5(n){var e=n5(n,"string");return typeof e=="symbol"?e:e+""}function n5(n,e){if(typeof n!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var i=t.call(n,e||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}var uR=["click","dblclick","contextmenu","mousedown","mouseup","mouseenter","mouseleave","mouseout","mouseover","mousemove","focusin","focusout","drag","dragstart","dragend","dragover","dragenter","dragleave","drop"],bl=class{constructor(e,t){e5(this,"_handleEvent",i=>{let{target:r,type:o}=i,s=i5(r);if(!s)return;let a=s.getAttribute("data-element-id");if(a){let l=this._eventBus.createEvent({id:a,event:i,node:s,target:s});this._eventBus.fire(`cell.${o}`,l),l.defaultPrevented&&i.preventDefault(),l.cancelBubble&&i.stopPropagation()}}),this._eventBus=t,this._container=e.container,t.on("table.init",()=>{this._addEventListeners(uR)}),t.on("table.destroy",()=>{this._removeEventListeners(uR)})}_addEventListeners(e){let t=this._container;e.forEach(i=>{t.addEventListener(i,this._handleEvent)})}_removeEventListeners(e){let t=this._container;e.forEach(i=>{t.removeEventListener(i,this._handleEvent)})}};bl.$inject=["config.renderer","eventBus"];function i5(n){return De(n,"[data-element-id]",!0)}var _l={__init__:["interactionEvents"],interactionEvents:["type",bl]};var Jx=Pw(hR());function r5(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Kx,dR;function o5(){if(dR)return Kx;dR=1,Kx=n;function n(e,t){return e^t}return Kx}var Gx,pR;function s5(){if(pR)return Gx;pR=1;var n=/\b(Array|Date|Object|Math|JSON)\b/g;Gx=function(o,s){var a=i(e(o));return s&&typeof s=="string"&&(s=r(s)),s?t(o,a,s):a};function e(o){return o.replace(/\.\w+|\w+ *\(|"[^"]*"|'[^']*'|\/([^/]+)\//g,"").replace(n,"").match(/[a-zA-Z_]\w*/g)||[]}function t(o,s,a){var l=/\.\w+|\w+ *\(|"[^"]*"|'[^']*'|\/([^/]+)\/|[a-zA-Z_]\w*/g;return o.replace(l,function(c){return c[c.length-1]=="("||~s.indexOf(c)?a(c):c})}function i(o){for(var s=[],a=0;a0?c:1;for(var f=this.node,h=this.closingTag,d=this._revisit;f;){if(n(s,h)&&f[o])f=f[o],h=!s;else if(f.nodeType==1&&!f[o]&&n(s,h)){if(h=s,!d)continue}else if(f[r])f=f[r],h=!s;else if(f=f.parentNode,h=s,!d)continue;if(!f||this.higher(f,this.root))break;if(l(f)&&this.selects(f,u)&&this.rejects(f,u)){if(--c)continue;return u||(this.node=f),this.closingTag=h,f}}return null}}return t.prototype.select=function(r){return r=this.compile(r),this._selects.push(r),this},t.prototype.selects=function(r,o){var s=this._selects,a=s.length;if(!a)return!0;for(var l=0;l0?this.next(r,o,!0):this.prev(r,Math.abs(o),!0):this.node},t.prototype.use=function(r){return r(this),this},Xx}var l5=a5(),gR=r5(l5),Zn=window.getSelection();function Zx(n){Zn==null||Zn.removeAllRanges(),Zn==null||Zn.addRange(n)}function yR(){return Zn}function c5(n){if(!(Zn!=null&&Zn.rangeCount))return null;var e=Zn.focusNode;return ig(e)&&(e=e.parentNode),n==e||n.contains(e)}function rg(n,e){var t=u5(n,e);Zx(t)}function wl(n){if(!c5(n))return null;var e=Zn.getRangeAt(0),t=e.startContainer,i=e.endContainer,r=e.startOffset,o=e.endOffset,s=gR(n.firstChild,n),a=s.node,l,c=!1,u,f=0;function h(p,m){return arguments.length===1&&(m=p),p.parentNode===i&&m==i.childNodes[o]}function d(p,m){return arguments.length===1&&(m=p),p.parentNode===t&&m==t.childNodes[r]}for(;a&&(d(a)&&!c&&(u=f),!(h(a)||Yx(a)&&i===a));){if(c||(Yx(a)||l&&l.nextSibling==a&&(vR(a)||xR(a)))&&f++,ig(a)){if(t===a&&(u=f+r),i===a){f+=o;break}f+=a.textContent.length}if((ig(a)||c)&&(d(a,a.nextSibling)&&(u=f),h(a,a.nextSibling)))break;l=a,a=s.next(),c=s.closingTag}return{start:typeof u=="undefined"?f:u,end:f}}function u5(n,e){for(var t=e.start,i=e.end,r=document.createRange(),o=gR(n.firstChild,n),s=o.node,a=!1,l=0,c;s;){if(l===t&&(a?r.setStartAfter(s):r.setStartBefore(s)),l===i)return a?r.setEndAfter(s):r.setEndBefore(s),r;if(a||(Yx(s)||s.previousSibling&&(vR(s)||xR(s)))&&l++,ig(s)){if(c=s.textContent.length,l<=t&&l+c>t&&r.setStart(s,t-l),l+c>i)return r.setEnd(s,i-l),r;l+=c}s=o.next(),a=o.closingTag}return l<=t&&(n.lastChild?r.setStartAfter(n.lastChild):r.setStart(n,0)),n.lastChild?r.setEndAfter(n.lastChild):r.setEnd(n,0),r}function ig(n){return n.nodeType===3}function Yx(n){return n.nodeType===1&&n.nodeName==="BR"}function vR(n){return n.nodeType===1&&n.nodeName==="DIV"}function xR(n){return n.nodeType===1&&n.nodeName==="P"}var f5="[contenteditable]",h5="[data-element-id]";function ah(n){return n.getAttribute("data-element-id")}function bR(n){let e=n.getAttribute("data-coords");if(!e)return null;let[t,i]=e.split(":");return{row:t,col:i}}function _R(n,e){let t=`${n.row}:${n.col}`;return X(`[data-coords="${(0,Jx.default)(t)}"]`,e)}function Gi(n,e){return X(`[data-element-id="${(0,Jx.default)(n)}"]`,e)}function wR(n){return De(n,".no-deselect",!0)}function lh(n){return De(n,h5,!0)}function e0(n){let e=f5;return hr(n,e)?n:X(e,n)}function CR(n){let e=e0(n);if(!e||!document.body.contains(e)||document.activeElement===e)return;e.focus();let t=wl(e);(!t||t.end===0)&&window.getSelection().setPosition(e.firstChild,e.firstChild.length)}var t0=500,d5={above:!0,below:!0,right:!0,left:!0};function og(n,e,t,i,r){let{container:o}=n,s=null;function a(h,d){e.fire("selection."+h+".changed",d),e.fire("cellSelection.changed",{elementId:h,selection:d})}function l(h){let d=h.target;if(wR(d))return;let p=lh(d),m=p&&ah(p),g=!h.defaultPrevented;f(m,g)}function c(h){let d=ah(h.target),p=!h.defaultPrevented;return h.stopPropagation(),f(d,p)}function u(h){let d=ah(h.target);a(d,{focussed:!1})}function f(h,d=!0){s!==h&&a(s,{selected:!1,focussed:!1}),s=h,h&&a(h,{selected:!0,focussed:d}),h?i.select(h):i.deselect()}e.on("cell.click",t0,l),e.on("cell.focusin",t0,c),e.on("cell.focusout",t0,u),e.on("cellSelection.changed",function(h){let{elementId:d,selection:p}=h,m=Gi(d,o);p.focussed&&m&&CR(m)}),e.on("selection.changed",function(h){let{selection:d,oldSelection:p}=h;var m=d&&d.id,g=p&&p.id;m&&m!==s?f(d.id):g&&g===s&&f()}),this.isCellSelected=function(){return!!s},this.getCellSelection=function(){return s},this.selectCell=function(h){if(!s)return;if(!(h in d5))throw new Error("direction must be any of { above, below, left, right }");var d=Gi(s,o);let p=bR(d);if(!p)return!1;let m=p5(p,h),g=_R(m,o);if(!g)return!1;let b=ah(g);return b&&f(b,{focussed:!0,selected:!0}),!0},e.on("contextMenu.close",function(){if(s)return f(s)})}og.$inject=["config.renderer","eventBus","sheet","selection","elementRegistry"];function p5(n,e){let{row:t,col:i}=n;if(e==="above"||e==="below"){let r=parseInt(t,10);if(isNaN(r))return n;let o=e==="above"?r-1:r+1;return{col:i,row:o}}if(e==="left"||e==="right"){let r=parseInt(i,10);if(isNaN(r))return n;let o=e==="left"?r-1:r+1;return{row:t,col:o}}throw new Error("invalid direction <"+e+">")}var Po={__depends__:[_l,Mo],__init__:["cellSelection"],cellSelection:["type",og]};function Ms(){}Ms.prototype.get=function(){return this._data};Ms.prototype.set=function(n){this._data=n};Ms.prototype.clear=function(){var n=this._data;return delete this._data,n};Ms.prototype.isEmpty=function(){return!this._data};var sg={clipboard:["type",Ms]};var n0=2e3,Cl=class extends Vi{constructor(e,t){super(e),this._sheet=t}init(){this.addRule("col.move",n0,({col:e,index:t})=>{let{businessObject:i}=this._sheet.getRoot(),{input:r}=i;return ie(e)?t=r.length}),this.addRule("col.remove",n0,({col:e})=>{let{cols:t}=this._sheet.getRoot();return Te(e)?t.filter(i=>Te(i)).length>1:!0}),this.addRule("paste",n0,({data:e,target:t})=>{if(!e||!t)return!1;let{root:i}=e;return t instanceof pt?this.canPasteRows(i):t instanceof mt?this.canPasteCols(i,t):!1})}canPasteRows(e){let{cols:t}=this._sheet.getRoot();return kt(e,i=>i.type!=="row"||i.cells.length!==t.length?!1:kt(i.cells,(r,o)=>ie(t[o])?r.businessObject.$type==="dmn:UnaryTests":r.businessObject.$type==="dmn:LiteralExpression"))}canPasteCols(e,t){let{rows:i}=this._sheet.getRoot();return kt(e,r=>r.type!=="col"||r.cells.length!==i.length?!1:ie(t)?r.businessObject.$type==="dmn:InputClause":r.businessObject.$type==="dmn:OutputClause")}};Cl.$inject=["eventBus","sheet"];var ER={__depends__:[yn]};var El={__depends__:[ER],__init__:["decisionTableModelingRules"],decisionTableModelingRules:["type",Cl]};var Sl=class{constructor(e,t,i){this._clipboard=e,this._modeling=t,this._sheet=i}execute(e){let{data:t}=e;return e.oldData=this._clipboard.get(),this._clipboard.set(t),this._sheet.getRoot()}postExecute(e){let{elements:t}=e;t.forEach(i=>{i instanceof pt?this._modeling.removeRow(i):i instanceof mt&&this._modeling.removeCol(i)})}revert(e){let{oldData:t}=e;return this._clipboard.set(t),this._sheet.getRoot()}};Sl.$inject=["clipboard","modeling","sheet"];var m5=[x5,b5],g5=[S5,E5];function ag(n,e,t){return t=t||m5,e=e||{},F(n)?y5(n,e,t):SR(n,e,t)}function y5(n,e,t){return st(n,(i,r)=>{var o=i.descriptorCache,s=i.root;let{root:a,descriptorCache:l}=SR(r,o,t);return{root:[...s,a],descriptorCache:{...o,...l}}},{root:[],descriptorCache:e})}function SR(n,e,t){var i=n.id,r={id:i},o=e.elements||{},s=o[i];if(s)return{root:s,descriptorCache:e};let a=v5(n,r,t,{...e,elements:o});return{root:a.root,descriptorCache:{...a.descriptorCache,elements:{...a.descriptorCache.elements,[i]:a.root}}}}function v5(n,e,t,i){function r(o,s){return ag(o,s,t)}return st(t,function(o,s){return s(n,o.root,o.descriptorCache,r)},{root:e,descriptorCache:i})}function x5(n,e,t,i){var r=t,o={...e,type:_5(n)};if(n instanceof pt||n instanceof mt){let s=i(n.cells,r);o.cells=s.root,r=s.descriptorCache}return{root:o,descriptorCache:r}}function b5(n,e,t){var i=n.businessObject;if(!i)return{root:e,descriptorCache:t};var r=i0(i,t);return{root:{...e,businessObject:r.root},descriptorCache:r.descriptorCache}}function _5(n){if(n instanceof pt)return"row";if(n instanceof mt)return"col";if(n instanceof ko)return"cell";throw new Error("cannot deduce element type: #"+n.id)}function i0(n,e){var t,i,r=n.id;if(r&&(t=e.boCache||{},i=t[r],i))return{root:i,descriptorCache:e};var o={$type:n.$type};return r&&(o.id=r,t={...t,[r]:o},e={...e,boCache:t}),n.$descriptor.properties.forEach(function(s){var a=n[s.name];if(a){if(F(a)&&(a=a.map(l=>{var c=i0(l,e);return e=c.descriptorCache,c.root})),a.$type){let l=i0(a,e);e=l.descriptorCache,a=l.root}o[s.name]=a}}),{root:o,descriptorCache:e}}function o0(n,e,t){return t=t||g5,e=e||{},F(n.root)?w5(n,e,t):OR(n,e,t)}function w5(n,e,t){let i=n.root,r=n.descriptorCache;return st(i,(o,s)=>{var a=o.reviveCache,l=o.root;let{root:c,reviveCache:u}=OR({root:s,descriptorCache:r},a,t);return{root:[...l,c],reviveCache:u}},{root:[],reviveCache:e})}function OR(n,e,t){var i=n.root,r=i.id,o=e.elements||{},s=o[r];if(s)return{root:s,reviveCache:e};var a={id:r};let l=C5(n,a,t,{...e,elements:o});return{root:l.root,reviveCache:{...l.reviveCache,elements:{...l.reviveCache.elements,[r]:l.root}}}}function C5(n,e,t,i){function r(o,s){return o0(o,s,t)}return st(t,function(o,s){return s(n,o.root,o.reviveCache,r)},{root:e,reviveCache:i})}function E5(n,e,t,i){var r=n.root,o=n.descriptorCache,s={...e};if(e.businessObject&&e.businessObject.id&&(s.id=e.businessObject.id),r.type==="row"||r.type==="col"){let c=i({root:r.cells,descriptorCache:o},t);s.cells=c.root,t=c.reviveCache}var a=O5(r),l=new a(s);return l instanceof pt?l.cells.forEach(c=>{c.row=l}):l instanceof mt&&l.cells.forEach(c=>{c.col=l}),{root:l,reviveCache:t}}function S5(n,e,t){var i=n.root.businessObject;if(!i)return{root:e,reviveCache:t};var r=r0({root:i,descriptorCache:n.descriptorCache},t);return{root:{...e,businessObject:r.root},reviveCache:r.reviveCache}}function O5(n){switch(n.type){case"row":return pt;case"cell":return ko;case"col":return mt;default:throw new Error("unknown element type: #"+n.type)}}function r0(n,e){var t=n.root,i=t.id;let r,o;if(i&&(r=e.boCache||{},o=r[i],o))return{root:o,reviveCache:e};var s={};di(t).forEach(c=>{let u,f;t[c].$type?(f=r0({root:t[c]},e),u=f.root,e=f.reviveCache,r=e.boCache||{}):F(t[c])?u=t[c].map(h=>(f=r0({root:h},e),e=f.reviveCache,r=e.boCache||{},f.root)):u=t[c],s[c]=u});let a=s.$type;delete s.$type,(!e._keepIds||e._model.ids.assigned(s.id))&&delete s.id;var l=e._dmnFactory.create(a,s);return k(s,c=>{c.$type&&(c.$parent=l),F(c)&&c.forEach(u=>u.$parent=l)}),i&&(r={...r,[i]:l},e={...e,boCache:r}),{root:l,reviveCache:e}}var Ol=class{constructor(e,t,i,r,o,s,a,l){this._clipboard=e,this._dmnFactory=t,this._elementFactory=i,this._elementRegistry=r,this._eventBus=o,this._model=s,this._modeling=a,this._sheet=l}postExecute(e){let{element:t,after:i}=e,r=this._clipboard.get();if(!r)throw new Error("missing clipboard data");let o=this._sheet.getRoot(),s=o0(r.elements,{_dmnFactory:this._dmnFactory,_keepIds:r.keepIds,_model:this._model}).root;if(t instanceof pt){let a=o.rows.indexOf(t);if(a===-1)return;s.forEach(l=>{i&&a++,this._modeling.addRow(l,a)})}else if(t instanceof mt){let a=o.cols.indexOf(t);if(a===-1)return;s.forEach(l=>{i&&a++,this._modeling.addCol(l,a)})}return e.oldElements=this._clipboard.get(),this._sheet.getRoot()}revert(e){}};Ol.$inject=["clipboard","dmnFactory","elementFactory","elementRegistry","eventBus","moddle","modeling","sheet"];var kl=class{constructor(e,t,i,r,o,s){this._clipboard=e,this._commandStack=t,this._eventBus=i,this._modeling=r,this._sheet=o,this._rules=s,t.registerHandler("cut",Sl),t.registerHandler("paste",Ol)}copy(e){F(e)||(e=[e]);let t={elements:ag(e)};this._eventBus.fire("copyCutPaste.copy",{data:t}),this._clipboard.set(t)}cut(e){F(e)||(e=[e]);let t={elements:ag(e),keepIds:!0},i={elements:e,data:t};this._eventBus.fire("copyCutPaste.cut",{data:t}),this._commandStack.execute("cut",i)}pasteBefore(e){return this._paste(e,{before:!0})}pasteAfter(e){return this._paste(e,{after:!0})}_paste(e,t){let i=this._clipboard.get();return i?this._rules.allowed("paste",{data:i.elements,target:e})?(this._commandStack.execute("paste",{element:e,...t}),this._clipboard.clear(),!0):!1:void 0}pasteAt(e){}};kl.$inject=["clipboard","commandStack","eventBus","modeling","sheet","rules"];var lg={__depends__:[sg,El],__init__:["copyCutPaste"],copyCutPaste:["type",kl]};var Rl=class{constructor(e,t,i,r,o,s){let a={addRule(){return i.addRow({type:"dmn:DecisionRule"})},addRuleAbove(l){let c=l&&l.rule;if(!c&&!r.hasSelection())return;c=c||r.get().row;let u=s.getRoot(),f=u.rows.indexOf(c);if(f!==-1)return i.addRow({type:"dmn:DecisionRule"},f)},addRuleBelow(l){let c=l&&l.rule;if(!c&&!r.hasSelection())return;c=c||r.get().row;let u=s.getRoot(),f=u.rows.indexOf(c);if(f!==-1)return i.addRow({type:"dmn:DecisionRule"},f+1)},removeRule(l){let c=l&&l.rule;!c&&!r.hasSelection()||(c=c||r.get().row,i.removeRow(c))},addInput(){let l=s.getRoot(),c=l.businessObject,{input:u}=c;return i.addCol({type:"dmn:InputClause"},u?u.length:0)},addInputLeft(l){let c=l&&l.input;if(!c&&!r.hasSelection())return;c=c||r.get().col;let u=s.getRoot(),f=u.cols.indexOf(c);if(f!==-1)return i.addCol({type:"dmn:InputClause"},f)},addInputRight(l){let c=l&&l.input;if(!c&&!r.hasSelection())return;c=c||r.get().col;let u=s.getRoot(),f=u.cols.indexOf(c);if(f!==-1)return i.addCol({type:"dmn:InputClause"},f+1)},removeInput(l){let c=l&&l.input;!c&&!r.hasSelection()||(c=c||r.get().col,i.removeCol(c))},addOutput(){let l=s.getRoot(),c=l.businessObject,u=c.get("input"),f=c.get("output");return i.addCol({type:"dmn:OutputClause"},u.length+f.length)},addOutputLeft(l){let c=l&&l.output;if(!c&&!r.hasSelection())return;c=c||r.get().col;let u=s.getRoot(),f=u.cols.indexOf(c);if(f!==-1)return i.addCol({type:"dmn:OutputClause"},f)},addOutputRight(l){let c=l&&l.output;if(!c&&!r.hasSelection())return;c=c||r.get().col;let u=s.getRoot(),f=u.cols.indexOf(c);if(f!==-1)return i.addCol({type:"dmn:OutputClause"},f+1)},removeOutput(l){let c=l&&l.output;!c&&!r.hasSelection()||(c=c||r.get().col,i.removeCol(c))},addClause(){if(!r.hasSelection())return;let l=r.get().col;if(O(l,"dmn:InputClause"))return a.addInput({input:l});if(O(l,"dmn:OutputClause"))return a.addOutput({output:l})},addClauseLeft(){if(!r.hasSelection())return;let l=r.get().col;if(O(l,"dmn:InputClause"))return a.addInputLeft({input:l});if(O(l,"dmn:OutputClause"))return a.addOutputLeft({output:l})},addClauseRight(){if(!r.hasSelection())return;let l=r.get().col;if(O(l,"dmn:InputClause"))return a.addInputRight({input:l});if(O(l,"dmn:OutputClause"))return a.addOutputRight({output:l})},removeClause(){if(!r.hasSelection())return;let l=r.get().col;if(O(l,"dmn:InputClause"))return a.removeInput({input:l});if(O(l,"dmn:OutputClause"))return a.removeOutput({output:l})},selectCellAbove(){return o.selectCell("above")},selectCellBelow(){return o.selectCell("below")},copy({element:l}){e.copy(l)},cut({element:l}){e.cut(l)},pasteBefore({element:l}){return e.pasteBefore(l)},pasteAfter({element:l}){return e.pasteAfter(l)}};t.register(a)}};Rl.$inject=["copyCutPaste","editorActions","modeling","selection","cellSelection","sheet"];var kR="is not a registered action",k5="is already registered",Tl=class{constructor(e,t,i,r){this._actions={undo(){e.undo()},redo(){e.redo()},select({cell:o}){r.select(o)},deselect(){r.deselect()},addRow({attrs:o,index:s}){i.addRow(o,s)},removeRow({row:o}){i.removeRow(o)},moveRow({row:o,index:s}){i.moveRow(o,s)},addCol({attrs:o,index:s}){i.addCol(o,s)},removeCol({col:o}){i.removeCol(o)},moveCol({col:o,index:s}){i.moveCol(o,s)}}}trigger(e,t){if(!this._actions[e])throw s0(e,kR);return this._actions[e](t)}register(e,t){if(typeof e=="string")return this._registerAction(e,t);k(e,(i,r)=>{this._registerAction(r,i)},this)}_registerAction(e,t){if(this.isRegistered(e))throw s0(e,k5);this._actions[e]=t}unregister(e){if(!this.isRegistered(e))throw s0(e,kR);this._actions[e]=void 0}isRegistered(e){return!!this._actions[e]}};Tl.$inject=["commandStack","eventBus","modeling","selection"];function s0(n,e){return new Error(n+" "+e)}var cg={__depends__:[Mo],__init__:["editorActions"],editorActions:["type",Tl]};var Jn={__depends__:[Po,lg,cg,Mo],__init__:["decisionTableEditorActions"],decisionTableEditorActions:["type",Rl]};var RR={__depends__:[Jn],__init__:["addRule"],addRule:["type",yl]};var PR=Pw(AR());function MR(n,e,t){var i=n.start,r=i,o=e.substring(i);t.lastIndexOf(o)===t.length-o.length&&(e=e.substring(0,e.length-o.length),t=t.substring(0,t.length-o.length));var s=A5(e,t);return s&&(s.type==="remove"?r=s.newStart:r=s.newEnd),M5(r)}function A5(n,e){var t,i,r,o=0,s,a,l=0;for(e.length>n.length?(i=e,s=n):(i=n,s=e);on.length?{newStart:t.l_start,newEnd:t.l_end,type:"add"}:{newStart:t.s_start,newEnd:t.s_end,type:e.length{var i=this.props.onFocus;this.setState({focussed:!0}),typeof i=="function"&&i(t)});M(this,"onBlur",t=>{let{onBlur:i,onChange:r,value:o}=this.props;if(this.setState({focussed:!1}),typeof r=="function"&&this.node){let s=ug(this.node);s!==o&&r(s)}typeof i=="function"&&i(t)});M(this,"onkeydown",t=>{if(t.which===13){if(t.preventDefault(),this.props.ctrlForNewline&&!I5(t)||this.props.singleLine)return;t.stopPropagation(),D5(),this.onInput(t)}});M(this,"onInput",t=>{var i=this.props.onInput;if(typeof i=="function"){var r=ug(this.node);i(r)}});M(this,"onPaste",t=>{if(this.props.singleLine){let i=(t.clipboardData||window.clipboardData).getData("text");document.execCommand("insertText",!1,i.replace(/\n/g," ")),t.preventDefault()}});this.state={}}componentWillUpdate(t,i){var r=this.node,o=i.focussed&&wl(r);this.selected=o&&{range:o,text:ug(r)}}componentDidUpdate(){var t=this.selected;if(!t)return;let i=t.range,r=t.text,o=this.node,s=ug(o),a=s!==r?MR(i,r,s):i;rg(o,a)}getClassName(){let{className:t,placeholder:i,value:r}=this.props;return[t||"","content-editable",!r&&i?"placeholder":""].join(" ")}render(t){var{label:i,value:r,placeholder:o}=t;return r=(0,PR.default)(r).replace(/\r?\n/g,"
    ")+"
    ",y(1,"div",this.getClassName(),null,1,{"aria-label":i,role:"textbox","aria-multiline":!this.props.singleLine,tabIndex:"0",contentEditable:"true",spellCheck:"false","data-placeholder":o||"",onInput:this.onInput,onkeypress:this.onkeypress,onPaste:this.onPaste,onFocus:this.onFocus,onBlur:this.onBlur,onkeydown:this.onkeydown,dangerouslySetInnerHTML:{__html:r}},null,s=>this.node=s)}};function P5(){return document.createElement("br")}function ug(n){return n.innerText.replace(/\n$/,"")}function D5(){var n=yR(),e=n.getRangeAt(0);if(e){var t=e.cloneRange(),i=P5();t.deleteContents(),t.insertNode(i),t.setStartAfter(i),t.setEndAfter(i),Zx(t)}}function I5(n){return n.metaKey||n.ctrlKey}var an=class extends L{constructor(t,i){super(t,i);M(this,"onFocus",t=>{this.setState({focussed:!0});var{onFocus:i}=this.props;typeof i=="function"&&i(t)});M(this,"onBlur",t=>{this.setState({focussed:!1});let{invalid:i}=this.state;i&&this.setState({changing:!1,invalid:!1});let{onBlur:r}=this.props;typeof r=="function"&&r(t)});this.state={changing:!1,focussed:!1};let{injector:r}=i,o=r.get("debounceInput");this.inputChanged=o(s=>{let{onChange:a}=this.props;typeof a=="function"&&a(s);let l=this.state.changing;this.setState({changing:l===s?!1:l})}),this.onInput=s=>{var a=this.props.validate||function(){},l=a(s);this.setState({changing:s,invalid:l}),l||this.inputChanged(s)}}getClassName(){var{className:t,value:i}=this.props,{changing:r,focussed:o,invalid:s}=this.state;return t+=" editable",o&&(t+=" focussed"),s&&(t+=" invalid"),!i&&!r&&(t+=" empty"),t}getDisplayValue(){var{value:t,placeholder:i}=this.props,{focussed:r,changing:o}=this.state;return typeof o=="string"&&(t=o),t||(t=r?"":i||""),t}getEditor(t={}){return P(2,Tn,{className:t.className,ctrlForNewline:this.props.ctrlForNewline,label:this.props.label,onFocus:this.onFocus,onBlur:this.onBlur,onInput:this.onInput,value:this.getDisplayValue()})}};var Al=class extends L{constructor(t,i){super(t,i);M(this,"onElementsChanged",()=>{this.forceUpdate()});M(this,"setAnnotationValue",t=>{let{row:i}=this.props;this.modeling.editAnnotation(i.businessObject,t)});Ce(this)}componentWillMount(){let{row:t}=this.props;this.changeSupport.onElementsChanged(t.id,this.onElementsChanged)}componentWillUnmount(){let{row:t}=this.props;this.changeSupport.offElementsChanged(t.id,this.onElementsChanged)}render(){let{row:t,rowIndex:i}=this.props,{description:r,id:o}=t.businessObject;return P(2,Rn,{className:"annotation",onChange:this.setAnnotationValue,coords:`${i}:annotation`,value:r,elementId:o,"data-row-id":t.id,children:P(2,a0,{label:this.translate("Annotation"),ctrlForNewline:!0,className:"annotation-editor",onChange:this.setAnnotationValue,value:r})})}};Al.$inject=["changeSupport","modeling","translate"];var a0=class extends an{render(){return y(1,"div",this.getClassName(),this.getEditor(),0)}};function fg(n){n.onGetComponent("cell",({cellType:e})=>{if(e==="after-label-cells")return To;if(e==="after-rule-cells")return Al})}fg.$inject=["components"];var L5=300;function hg(n){return function(t){if(n!==!1){var i=se(n)?n:L5;return Mi(t,i)}else return t}}hg.$inject=["config.debounceInput"];var Kt={debounceInput:["factory",hg]};var DR={__depends__:[Kt],__init__:["annotationsProvider"],annotationsProvider:["type",fg]};function Ps(n,e,t){return(e=B5(e))in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function B5(n){var e=N5(n,"string");return typeof e=="symbol"?e:e+""}function N5(n,e){if(typeof n!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var i=t.call(n,e||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}var $5={position:"absolute"},Ml=class extends L{constructor(e,t){super(e,t),Ps(this,"open",({position:i,context:r})=>{this.close(),this.setState({isOpen:!0,position:i||{x:0,y:0},context:r||{}})}),Ps(this,"close",()=>{this.state.isOpen&&this.setState({context:void 0,isOpen:!1,position:{x:0,y:0}})}),Ps(this,"triggerClose",()=>{this.eventBus.fire("contextMenu.close")}),this.state={isOpen:!1,position:{x:0,y:0}},Ce(this)}componentDidMount(){this.eventBus.on("contextMenu.open",this.open),this.eventBus.on("contextMenu.close",this.close)}componentWillUnmount(){this.eventBus.off("contextMenu.open",this.open),this.eventBus.off("contextMenu.close",this.close)}render(){let{isOpen:e,context:t,position:i}=this.state;if(!e)return null;let r=this.components.getComponents("context-menu",t);return r.length?P(2,dg,{className:"context-menu no-deselect",context:t,position:i,offset:t.offset||{x:0,y:0},autoFocus:t.autoFocus!==!1,autoClose:t.autoClose!==!1,components:r,onClose:this.triggerClose}):null}};Ml.$inject=["eventBus","components"];var dg=class extends L{constructor(e,t){super(e,t),Ps(this,"onGlobalMouseDown",i=>{this.checkClose(i.target)}),Ps(this,"onGlobalKey",i=>{var r=i.which;(r===13||r===27)&&(i.stopPropagation(),i.preventDefault(),this.close())}),Ps(this,"onFocusChanged",i=>{this.checkClose(i.target)}),Ps(this,"setNode",i=>{this.node=i;let{autoFocus:r}=this.props;i&&(this.updatePosition(),r&&F5(i))}),Ce(this)}close(){let{onClose:e}=this.props;ge(e)&&e()}checkClose(e){let{autoClose:t}=this.props;if(t){var i=this.node;i&&i!==e&&(i.contains(e)||this.close())}}componentDidMount(){document.addEventListener("focusin",this.onFocusChanged),document.addEventListener("keydown",this.onGlobalKey),document.addEventListener("mousedown",this.onGlobalMouseDown)}componentWillUnmount(){document.removeEventListener("focusin",this.onFocusChanged),document.removeEventListener("keydown",this.onGlobalKey),document.removeEventListener("mousedown",this.onGlobalMouseDown)}updatePosition(){let{position:e,offset:t}=this.props,{node:i}=this,r=i.getBoundingClientRect();e.width||(e.width=0),e.height||(e.height=0);let o=this.renderer.getContainer(),s=o.getBoundingClientRect();s.width>s.height?(this.node.classList.add("horizontal"),this.node.classList.remove("vertical")):(this.node.classList.add("vertical"),this.node.classList.remove("horizontal"));let{scrollLeft:a,scrollTop:l}=q5(i),c={},u;e.align&&(u=e.align.split("-"));let f,h;(u&&u[1]||(e.x+e.width/2>s.width/2?"left":"right"))==="left"?(f=e.x-s.left-r.width+t.x+a,i.classList.remove("right"),i.classList.add("left")):(f=-s.left+e.x+e.width-t.x+a,i.classList.remove("left"),i.classList.add("right")),f=u?f:IR(f,0+a,s.width-r.width+a),c.left=f+"px",(u&&u[0]||(e.y+e.height/2>s.height/2?"top":"bottom"))==="top"?(h=e.y-s.top-r.height+t.y+l,i.classList.remove("bottom"),i.classList.add("top")):(h=-s.top+e.y-t.y+l,i.classList.remove("top"),i.classList.add("bottom")),h=u?h:IR(h,0+l,s.height-r.height+l),c.top=h+"px",c.overflowY="auto",c.maxHeight=s.height-h+l+"px",T(this.node.style,$5,c)}render(){let{context:e,components:t,className:i}=this.props;return y(1,"div",i,t.map((r,o)=>P(2,r,{context:e},o)),0,{onContextMenu:r=>r.preventDefault()},null,this.setNode)}};dg.$inject=["renderer"];function IR(n,e,t){return Math.max(e,Math.min(t,n))}var j5=` input[type=text], input[type=number], input[type=button], input[type=submit], [contenteditable], [tabindex], a[href], textarea, button `;function F5(n){var e=X(j5,n);e&&(e.focus(),e.selectionStart&&e.type==="text"?e.selectionStart=1e5:"contentEditable"in e&&rg(e,{start:1e5,end:1e5}))}function q5(n){let e=De(n,".tjs-container");if(!e)return{scrollTop:0,scrollLeft:0};let{scrollLeft:t,scrollTop:i}=e;return{scrollTop:i,scrollLeft:t}}var Pl=class{constructor(e,t,i){this._eventBus=t,e.onGetComponent("table.before",()=>Ml)}open(e,t){this._eventBus.fire("contextMenu.open",{position:e,context:t})}close(){this._eventBus.fire("contextMenu.close")}};Pl.$inject=["components","eventBus","renderer"];var Gt={__init__:["contextMenu"],contextMenu:["type",Pl]};function Ir(n){return n.altKey?!1:n.ctrlKey||n.metaKey}function Lr(n){return n.shiftKey}var Dl=class{constructor(e,t,i,r,o,s,a){M(this,"_clearClipboard",()=>{this._clipboard.clear()});M(this,"_registerBindings",()=>{[(r,o)=>{if(Ir(o)&&r===67){let s=this._getSelectedCell();return s?(Lr(o)?this._editorActions.trigger("copy",{element:s.col}):this._editorActions.trigger("copy",{element:s.row}),!0):void 0}},(r,o)=>{if(Ir(o)&&r===88){let s=this._getSelectedCell();return s?(Lr(o)?this._editorActions.trigger("cut",{element:s.col}):this._editorActions.trigger("cut",{element:s.row}),!0):void 0}},(r,o)=>{let s;if(Ir(o)&&r===86){let a=this._getSelectedCell();if(!a)return;Lr(o)?(s=this._editorActions.trigger("pasteAfter",{element:a.col}),s&&this._cellSelection.selectCell("right")):(s=this._editorActions.trigger("pasteAfter",{element:a.row}),s&&this._cellSelection.selectCell("below"))}return typeof s!="undefined"}].forEach(r=>{this._keyboard.addListener(r)})});this._clipboard=i,this._cellSelection=r,this._elementRegistry=o,this._editorActions=s,this._keyboard=e.get("keyboard",!1),this._renderer=a,this._keyboard&&(t.on("keyboard.init",this._registerBindings),t.on("keyboard.bind",()=>{q.bind(document,"copy",this._clearClipboard,!0),q.bind(document,"cut",this._clearClipboard,!0)}),t.on("keyboard.unbind",()=>{q.unbind(document,"copy",this._clearClipboard,!0),q.unbind(document,"cut",this._clearClipboard,!0)}))}_getSelectedCell(){let e=this._cellSelection.getCellSelection();if(!e)return;let t=this._elementRegistry.get(e);if(!t)return;let i=this._renderer.getContainer(),r=Gi(e,i),o=e0(r);if(document.activeElement!==o)return;let s=wl(r);if(!(s&&s.start!==s.end))return t}};Dl.$inject=["injector","eventBus","clipboard","cellSelection","elementRegistry","editorActions","renderer"];var LR={__depends__:[sg,Po],__init__:["copyCutPasteKeyBindings"],copyCutPasteKeyBindings:["type",Dl]};var Il=class extends L{constructor(t,i){super(t,i);M(this,"onClick",t=>{this.editorActions.trigger("addInput")});Ce(this)}render(){return y(1,"th","input-cell create-inputs header actionable",[this.translate("Input"),Z(" "),y(1,"button","add-input dmn-icon-plus action-icon",null,1,{title:this.translate("Add input")})],0,{onClick:this.onClick,title:this.translate("Add input")})}};Il.$inject=["editorActions","translate"];var Ll=class extends L{constructor(t,i){super(t,i);M(this,"onClick",t=>{this.editorActions.trigger("addInput")});Ce(this)}render(){return y(1,"td","input-cell create-inputs",Z("-"),2,{onClick:this.onClick,title:this.translate("Add input")})}};Ll.$inject=["editorActions","translate"];var V5=500,Bl=class{constructor(e,t){e.onGetComponent("cell",V5,({cellType:i})=>{let{businessObject:r}=t.getRoot();if(!(r.input&&r.input.length)){if(i==="before-label-cells")return Il;if(i==="before-rule-cells")return Ll}})}};Bl.$inject=["components","sheet"];var BR={__depends__:[Jn],__init__:["createInputsProvider"],createInputsProvider:["type",Bl]};var H5=["string","boolean","number","date","time","dateTime","dayTimeDuration","yearMonthDuration","Any"],Nl=class{constructor(e){this._dataTypes=e||H5}getAll(){return this._dataTypes}};Nl.$inject=["config.dataTypes"];var Xi={__init__:["dataTypes"],dataTypes:["type",Nl]};var $l=class{constructor(e,t,i,r,o,s,a,l,c,u,f){this._contextMenu=t,this._clipboard=i,this._editorActions=r,this._elementRegistry=s,this._eventBus=o,this._modeling=a,this._selection=l,this._sheet=c,this._rules=u,this._translate=f,this._getEntries=this._getEntries.bind(this),e.onGetComponent("context-menu",(h={})=>{if(h.contextMenuType&&h.contextMenuType==="context-menu"){let d=this._getEntries(h),p=this._elementRegistry.get(h.id),m=z5(p)&&e.getComponents("context-menu-cell-additional",h);if(m&&m.length){let g=y(1,"div","context-menu-group context-menu-group-cell",m,0,{role:"presentation"});d.push(g)}return()=>y(1,"div","context-menu-flex",d,0,{tabIndex:0,role:"menu","aria-label":"Decision table context menu"})}}),o.on("cell.contextmenu",({event:h,id:d,node:p})=>{h.preventDefault(),t.open({x:h.pageX,y:h.pageY},{contextMenuType:"context-menu",event:h,id:d})})}_getEntries(e){let t={addRuleAbove:l=>{let c=l.cells.map(f=>f.id).indexOf(e.id),u=this._editorActions.trigger("addRuleAbove",{rule:l});u.cells[c]?this._selection.select(u.cells[c]):this._selection.select(u.cells[0]),this._contextMenu.close()},addRuleBelow:l=>{let c=l.cells.map(f=>f.id).indexOf(e.id),u=this._editorActions.trigger("addRuleBelow",{rule:l});u.cells[c]?this._selection.select(u.cells[c]):this._selection.select(u.cells[0]),this._contextMenu.close()},removeRule:l=>{this._editorActions.trigger("removeRule",{rule:l}),this._contextMenu.close()},addInputLeft:l=>{this._editorActions.trigger("addInputLeft",{input:l}),this._contextMenu.close()},addInputRight:l=>{this._editorActions.trigger("addInputRight",{input:l}),this._contextMenu.close()},removeInput:l=>{this._editorActions.trigger("removeInput",{input:l}),this._contextMenu.close()},addOutputLeft:l=>{this._editorActions.trigger("addOutputLeft",{output:l}),this._contextMenu.close()},addOutputRight:l=>{this._editorActions.trigger("addOutputRight",{output:l}),this._contextMenu.close()},removeOutput:l=>{this._editorActions.trigger("removeOutput",{output:l}),this._contextMenu.close()},copy:l=>{this._editorActions.trigger("copy",{element:l}),this._contextMenu.close()},cut:l=>{this._editorActions.trigger("cut",{element:l}),this._contextMenu.close()},pasteBefore:l=>{this._editorActions.trigger("pasteBefore",{element:l}),this._contextMenu.close()},pasteAfter:l=>{this._editorActions.trigger("pasteAfter",{element:l}),this._contextMenu.close()}},i=e&&e.id;if(!i)return null;let r=this._elementRegistry.get(i);if(!r)return null;let o=this._clipboard.get()||{},s=[],a=r.row||r;if(O(a,"dmn:DecisionRule")){let l=this._rules.allowed("paste",{data:o.elements,target:a});s.push(y(1,"div","context-menu-group",[y(1,"div","context-menu-group-entry context-menu-entry-copy-rule",this._translate("Copy rule"),0,{onClick:()=>t.copy(a),tabIndex:"-1",role:"menuitem"}),y(1,"div","context-menu-group-entry context-menu-entry-cut-rule",this._translate("Cut rule"),0,{onClick:()=>t.cut(a),tabIndex:"-1",role:"menuitem"}),y(1,"div",`context-menu-group-entry ${l?"":"disabled"} context-menu-entry-paste-rule-above`,this._translate("Paste rule above"),0,{onClick:()=>t.pasteBefore(a),tabIndex:"-1",role:"menuitem","aria-disabled":!l}),y(1,"div",`context-menu-group-entry ${l?"":"disabled"} context-menu-entry-paste-rule-below`,this._translate("Paste rule below"),0,{onClick:()=>t.pasteAfter(a),tabIndex:"-1",role:"menuitem","aria-disabled":!l})],4,{role:"presentation"}),y(1,"div","context-menu-group",[y(1,"div","context-menu-group-entry context-menu-entry-add-rule-above",this._translate("Add rule above"),0,{onClick:()=>t.addRuleAbove(a),tabIndex:"-1",role:"menuitem"}),y(1,"div","context-menu-group-entry context-menu-entry-add-rule-below",this._translate("Add rule below"),0,{onClick:()=>t.addRuleBelow(a),tabIndex:"-1",role:"menuitem"}),y(1,"div","context-menu-group-entry context-menu-entry-remove-rule",this._translate("Remove rule"),0,{onClick:()=>t.removeRule(a),tabIndex:"-1",role:"menuitem"})],4,{role:"presentation"}))}else if(O(r,"dmn:InputClause")){let l=O(r,"dmn:InputClause")?r:r.col,c=this._rules.allowed("col.remove",{col:r.col||r}),u=this._rules.allowed("paste",{data:o.elements,target:r.col||r});s.push(y(1,"div","context-menu-group",[y(1,"div","context-menu-group-entry context-menu-entry-copy-input",this._translate("Copy input column"),0,{onClick:()=>t.copy(l),tabIndex:"-1",role:"menuitem"}),y(1,"div",`context-menu-group-entry ${c?"":"disabled"} context-menu-entry-cut-input`,this._translate("Cut input column"),0,{onClick:()=>t.cut(l),tabIndex:"-1",role:"menuitem","aria-disabled":!c}),y(1,"div",`context-menu-group-entry ${u?"":"disabled"} context-menu-entry-paste-input-left`,this._translate("Paste input column left"),0,{onClick:()=>t.pasteBefore(l),tabIndex:"-1",role:"menuitem","aria-disabled":!u}),y(1,"div",`context-menu-group-entry ${u?"":"disabled"} context-menu-entry-paste-input-right`,this._translate("Paste input column right"),0,{onClick:()=>t.pasteAfter(l),tabIndex:"-1",role:"menuitem","aria-disabled":!u})],4,{role:"presentation"}),y(1,"div","context-menu-group",[y(1,"div","context-menu-group-entry context-menu-entry-add-input-left",this._translate("Add input column left"),0,{onClick:()=>t.addInputLeft(l),tabIndex:"-1",role:"menuitem"}),y(1,"div","context-menu-group-entry context-menu-entry-add-input-right",this._translate("Add input column right"),0,{onClick:()=>t.addInputRight(l),tabIndex:"-1",role:"menuitem"}),y(1,"div",`context-menu-group-entry ${c?"":"disabled"} context-menu-entry-remove-input`,this._translate("Remove input column"),0,{onClick:()=>t.removeInput(l),tabIndex:"-1",role:"menuitem","aria-disabled":!c})],4,{role:"presentation"}))}else if(O(r,"dmn:OutputClause")||O(r.col,"dmn:OutputClause")){let l=O(r,"dmn:OutputClause")?r:r.col,c=this._rules.allowed("col.remove",{col:r.col||r}),u=this._rules.allowed("paste",{data:o.elements,target:r.col||r});s.push(y(1,"div","context-menu-group",[y(1,"div","context-menu-group-entry context-menu-entry-copy-output",this._translate("Copy output column"),0,{onClick:()=>t.copy(l),tabIndex:"-1",role:"menuitem"}),y(1,"div",`context-menu-group-entry ${c?"":"disabled"} context-menu-entry-cut-output`,this._translate("Cut output column"),0,{onClick:()=>t.cut(l),tabIndex:"-1",role:"menuitem","aria-disabled":!c}),y(1,"div",`context-menu-group-entry ${u?"":"disabled"} context-menu-entry-paste-output-left`,this._translate("Paste output column left"),0,{onClick:()=>t.pasteBefore(l),tabIndex:"-1",role:"menuitem","aria-disabled":!u}),y(1,"div",`context-menu-group-entry ${u?"":"disabled"} context-menu-entry-paste-output-right`,this._translate("Paste output column right"),0,{onClick:()=>t.pasteAfter(l),tabIndex:"-1",role:"menuitem","aria-disabled":!u})],4,{role:"presentation"}),y(1,"div","context-menu-group",[y(1,"div","context-menu-group-entry context-menu-entry-add-output-left",this._translate("Add output column left"),0,{onClick:()=>t.addOutputLeft(l),tabIndex:"-1",role:"menuitem"}),y(1,"div","context-menu-group-entry context-menu-entry-add-output-right",this._translate("Add output column right"),0,{onClick:()=>t.addOutputRight(l),tabIndex:"-1",role:"menuitem"}),y(1,"div",`context-menu-group-entry ${c?"":"disabled"} context-menu-entry-remove-output`,this._translate("Remove output column"),0,{onClick:()=>t.removeOutput(l),tabIndex:"-1",role:"menuitem","aria-disabled":!c})],4,{role:"presentation"}))}return s}};$l.$inject=["components","contextMenu","clipboard","editorActions","eventBus","elementRegistry","modeling","selection","sheet","rules","translate"];function z5(n){return n instanceof ko}var W5=["row.add","row.remove","col.add","col.remove"],jl=class{constructor(e,t){t.on("commandStack.executed",({command:i})=>{W5.indexOf(i)!==-1&&e.close()}),t.on("commandStack.reverted",()=>{e.close()})}};jl.$inject=["contextMenu","eventBus"];var Fl=class{constructor(e){M(this,"addEventListeners",()=>{document.addEventListener("keydown",this.handleKeyEvent),document.addEventListener("mouseover",this.handleMouseOver)});M(this,"removeEventListeners",()=>{document.removeEventListener("keydown",this.handleKeyEvent),document.removeEventListener("mouseover",this.handleMouseOver)});M(this,"handleKeyEvent",e=>{this.getEntries().length&&(e.key==="ArrowUp"?(e.preventDefault(),this.move(e.target,-1)):e.key==="ArrowDown"?(e.preventDefault(),this.move(e.target,1)):e.key==="Enter"&&(e.preventDefault(),this.clickCurrentEntry()))});M(this,"handleMouseOver",()=>{this.getEntries().forEach(i=>Q5(i));let{focused:t}=this.getActiveEntries(document);t&&ee(t).remove("focused")});M(this,"getEntries",()=>Array.from(pn(".context-menu-group-entry")).filter(e=>!ee(e).has("disabled")));M(this,"getActiveEntries",e=>{let t=X(".context-menu-group-entry:hover",e),i=X(".context-menu-group-entry.focused",e);return{hover:t,focused:i,current:i||t}});M(this,"move",(e,t)=>{let i=this.getEntries(),{current:r,hover:o}=this.getActiveEntries(e);if(!r){let l=i[0];if(!l)return;ee(l).add("focused");return}let s=i.indexOf(r)+t,a=i[s];s<0&&(a=i[i.length-1]),s>=i.length&&(a=i[0]),o&&U5(o),ee(r).remove("focused"),ee(a).add("focused"),a.style.removeProperty("background-color")});M(this,"clickCurrentEntry",()=>{let{current:e}=this.getActiveEntries(document);e&&e.click()});e.on("contextMenu.open",()=>this.addEventListeners()),e.on("contextMenu.close",()=>this.removeEventListeners()),e.on("commandStack.executed",()=>this.removeEventListeners())}};Fl.$inject=["eventBus"];function U5(n){n.style.setProperty("pointer-events","none"),n.style.setProperty("background-color","transparent")}function Q5(n){n.style.removeProperty("background-color"),n.style.removeProperty("pointer-events")}var NR={__depends__:[Jn,Gt,El],__init__:["decisionTableContextMenu","contextMenuCloseBehavior","contextMenuKeyboard"],decisionTableContextMenu:["type",$l],contextMenuCloseBehavior:["type",jl],contextMenuKeyboard:["type",Fl]};var ch=class extends L{constructor(t,i){super(t,i);M(this,"onClick",t=>{let{output:i}=this.props;this._eventBus.fire("output.edit",{event:t,output:i})});M(this,"onContextmenu",t=>{let{id:i}=this.props.output;this._eventBus.fire("cell.contextmenu",{event:t,id:i})});M(this,"onElementsChanged",()=>{this.forceUpdate()});Ut(this,xi),this._translate=i.injector.get("translate")}componentWillMount(){let{injector:t}=this.context;this._changeSupport=this.context.changeSupport,this._eventBus=t.get("eventBus"),this._elementRegistry=t.get("elementRegistry");let{output:i}=this.props;this._changeSupport.onElementsChanged(i.id,this.onElementsChanged)}componentWillUnmount(){let{output:t}=this.props;this._changeSupport.offElementsChanged(t.id,this.onElementsChanged)}render(){let{output:t,index:i,outputsLength:r}=this.props,{label:o,name:s,outputValues:a,typeRef:l}=t,c=t.width?t.width+"px":"192px";return y(1,"th","output-cell output-editor",[this.slotFills({type:"cell-inner",context:{cellType:"output-cell",col:this._elementRegistry.get(t.id),index:i,outputsLength:r},col:t}),y(1,"div","clause",i===0?this._translate("Then"):this._translate("And"),0),o?y(1,"div","output-label",o,0,{title:this._translate("Output label: ")+o}):y(1,"div","output-name",s,0,{title:this._translate("Output name: ")+s}),y(1,"div","output-variable",a&&a.text||this._translate(l||""),0,{title:a&&a.text?this._translate("Output values"):this._translate("Output type")})],0,{"data-col-id":t.id,onDblClick:this.onClick,onContextMenu:this.onContextmenu,style:{width:c}})}};var St=class extends L{constructor(t,i){super(t,i);M(this,"onInput",t=>{let{onInput:i}=this.props,r=t.target.value;this.setState({value:r},()=>{typeof i=="function"&&i(r)})});M(this,"onChange",t=>{let{onChange:i}=this.props;typeof i=="function"&&i(t.target.value)});M(this,"onKeyDown",t=>{let{onKeyDown:i}=this.props;typeof i=="function"&&i(t)});M(this,"onKeyUp",t=>{let{onKeyUp:i}=this.props;typeof i=="function"&&i(t)});this.state={value:t.value}}componentDidUpdate(t){let{value:i}=this.props;i!==t.value&&i!==this.state.value&&this.setState({value:i})}render(){let{className:t,label:i,id:r,placeholder:o,type:s}=this.props,{value:a}=this.state;return y(64,"input",[t||"","dms-input"].join(" "),null,1,{"aria-label":i,placeholder:o||"",onChange:this.onChange,onInput:this.onInput,onKeyDown:this.onKeyDown,onKeyUp:this.onKeyUp,spellCheck:"false",type:s||"text",value:a,id:r})}};var uh=class extends L{constructor(e,t){super(e,t),this.translate=t.injector?t.injector.get("translate"):K5,this.setName=i=>{i=i||void 0,this.handleChange({name:i})},this.setLabel=i=>{i=i||void 0,this.handleChange({label:i})}}handleChange(e){var{onChange:t}=this.props;typeof t=="function"&&t(e)}render(){let{name:e,label:t}=this.props;return y(1,"div","context-menu-container ref-output-editor output-edit",[y(1,"div","dms-form-control",P(2,Tn,{label:this.translate("Output label"),className:"dms-output-label",value:t||"",placeholder:this.translate("Output"),singleLine:!0,onInput:this.setLabel}),2),y(1,"div","dms-form-control",[y(1,"label","dms-label",this.translate("Output name"),0),P(2,St,{label:this.translate("Output name"),className:"ref-output-name",value:e||"",onInput:this.setName})],4)],4)}};function K5(n){return n}var ql=class extends L{constructor(t,i){super(t,i);M(this,"persistChanges",()=>{let{output:t}=this.props.context,{unsaved:i}=this.state;i&&(this.modeling.updateProperties(t,i),this.setState({unsaved:!1}))});M(this,"handleChange",t=>{this.setState({unsaved:{...this.state.unsaved,...t}},this.persistChanges)});this.state={},Ce(this),this.persistChanges=this.debounceInput(this.persistChanges)}getValue(t){let{output:i}=this.props.context,{unsaved:r}=this.state;return r&&t in r?r[t]:i.get(t)}render(){return P(2,uh,{name:this.getValue("name"),label:this.getValue("label"),onChange:this.handleChange})}};ql.$inject=["debounceInput","modeling"];var pg=class extends L{constructor(t,i){super(t,i);M(this,"onClick",t=>{let{col:i}=this.props;this._eventBus.fire("output.edit",{event:t,output:i})});this._translate=i.injector.get("translate"),this._eventBus=i.injector.get("eventBus")}render(){return y(1,"button","edit-button dmn-icon-edit",null,1,{"aria-label":this._translate("Edit output"),type:"button",onClick:this.onClick})}};var Vl=class{constructor(e,t,i,r){e.onGetComponent("cell",({cellType:o})=>{if(o==="output-header")return ch}),e.onGetComponent("context-menu",(o={})=>{if(o.contextMenuType==="output-edit")return ql}),e.onGetComponent("cell-inner",(o={})=>{let{cellType:s}=o;if(s==="output-cell")return pg}),i.on("output.edit",({event:o,output:s})=>{let{target:a}=o,l=De(a,"th",!0),{left:c,top:u}=l.getBoundingClientRect(),f=G5(l);t.open({x:c,y:u,align:"bottom-right"},{contextMenuType:"output-edit",output:s,offset:f})})}};Vl.$inject=["components","contextMenu","eventBus","renderer"];function G5(n){if(!hr(n,".output-cell + .output-cell"))return{x:-1,y:0}}var fh=class extends L{constructor(t,i){super(t,i);M(this,"onClick",t=>{let{input:i}=this.props;this._eventBus.fire("input.edit",{event:t,input:i})});M(this,"onContextmenu",t=>{let{id:i}=this.props.input;this._eventBus.fire("cell.contextmenu",{event:t,id:i})});M(this,"onElementsChanged",()=>{this.forceUpdate()});Ut(this,xi),this._translate=i.injector.get("translate")}componentWillMount(){let{injector:t}=this.context;this._changeSupport=this.context.changeSupport,this._sheet=t.get("sheet"),this._eventBus=t.get("eventBus"),this._elementRegistry=t.get("elementRegistry");let i=this._sheet.getRoot(),{input:r}=this.props;this._changeSupport.onElementsChanged(i.id,this.onElementsChanged),this._changeSupport.onElementsChanged(r.id,this.onElementsChanged)}componentWillUnmount(){let t=this._sheet.getRoot(),{input:i}=this.props;this._changeSupport.offElementsChanged(t.id,this.onElementsChanged),this._changeSupport.offElementsChanged(i.id,this.onElementsChanged)}render(){let{input:t,index:i,inputsLength:r}=this.props,{inputExpression:o,inputValues:s}=t,a=t.get("label"),l=t.width?t.width+"px":"192px";return y(1,"th","input-cell input-editor",[this.slotFills({type:"cell-inner",context:{cellType:"input-cell",col:this._elementRegistry.get(t.id),index:i,inputsLength:r},col:t}),y(1,"div","clause",i===0?this._translate("When"):this._translate("And"),0),a?y(1,"div","input-label",a,0,{title:this._translate("Input label: ")+a}):y(1,"div","input-expression",o.text,0,{title:this._translate("Input expression: ")+o.text}),y(1,"div","input-variable",s&&s.text||this._translate(o.typeRef||""),0,{title:s&&s.text?this._translate("Input values"):this._translate("Input type")})],0,{"data-col-id":t.id,onDblClick:this.onClick,onContextMenu:this.onContextmenu,style:{width:l}})}};var c0=[],qR=[];(()=>{let n="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 e=0,t=0;e>1;if(n=qR[i])e=i+1;else return!0;if(e==t)return!1}}function $R(n){return n>=127462&&n<=127487}var jR=8205;function VR(n,e,t=!0,i=!0){return(t?HR:Y5)(n,e,i)}function HR(n,e,t){if(e==n.length)return e;e&&zR(n.charCodeAt(e))&&WR(n.charCodeAt(e-1))&&e--;let i=l0(n,e);for(e+=FR(i);e=0&&$R(l0(n,s));)o++,s-=2;if(o%2==0)break;e+=2}else break}return e}function Y5(n,e,t){for(;e>0;){let i=HR(n,e-2,t);if(i=56320&&n<57344}function WR(n){return n>=55296&&n<56320}function FR(n){return n<65536?1:2}var be=class n{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,i){[e,t]=Ql(this,e,t);let r=[];return this.decompose(0,e,r,2),i.length&&i.decompose(0,i.length,r,3),this.decompose(t,this.length,r,1),zl.from(r,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=Ql(this,e,t);let i=[];return this.decompose(e,t,i,0),zl.from(i,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),i=this.length-this.scanIdentical(e,-1),r=new Ls(this),o=new Ls(e);for(let s=t,a=t;;){if(r.next(s),o.next(s),s=0,r.lineBreak!=o.lineBreak||r.done!=o.done||r.value!=o.value)return!1;if(a+=r.value.length,r.done||a>=i)return!0}}iter(e=1){return new Ls(this,e)}iterRange(e,t=this.length){return new xg(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let r=this.line(e).from;i=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new bg(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?n.empty:e.length<=32?new An(e):zl.from(An.split(e,[]))}},An=class n extends be{constructor(e,t=Z5(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,r){for(let o=0;;o++){let s=this.text[o],a=r+s.length;if((t?i:a)>=e)return new f0(r,a,i,s);r=a+1,i++}}decompose(e,t,i,r){let o=e<=0&&t>=this.length?this:new n(UR(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(r&1){let s=i.pop(),a=vg(o.text,s.text.slice(),0,o.length);if(a.length<=32)i.push(new n(a,s.length+o.length));else{let l=a.length>>1;i.push(new n(a.slice(0,l)),new n(a.slice(l)))}}else i.push(o)}replace(e,t,i){if(!(i instanceof n))return super.replace(e,t,i);[e,t]=Ql(this,e,t);let r=vg(this.text,vg(i.text,UR(this.text,0,e)),t),o=this.length+i.length-(t-e);return r.length<=32?new n(r,o):zl.from(n.split(r,[]),o)}sliceString(e,t=this.length,i=` `){[e,t]=Ql(this,e,t);let r="";for(let o=0,s=0;o<=t&&se&&s&&(r+=i),eo&&(r+=a.slice(Math.max(0,e-o),t-o)),o=l+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let i=[],r=-1;for(let o of e)i.push(o),r+=o.length+1,i.length==32&&(t.push(new n(i,r)),i=[],r=-1);return r>-1&&t.push(new n(i,r)),t}},zl=class n extends be{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let i of e)this.lines+=i.lines}lineInner(e,t,i,r){for(let o=0;;o++){let s=this.children[o],a=r+s.length,l=i+s.lines-1;if((t?l:a)>=e)return s.lineInner(e,t,i,r);r=a+1,i=l+1}}decompose(e,t,i,r){for(let o=0,s=0;s<=t&&o=s){let c=r&((s<=e?1:0)|(l>=t?2:0));s>=e&&l<=t&&!c?i.push(a):a.decompose(e-s,t-s,i,c)}s=l+1}}replace(e,t,i){if([e,t]=Ql(this,e,t),i.lines=o&&t<=a){let l=s.replace(e-o,t-o,i),c=this.lines-s.lines+l.lines;if(l.lines>4&&l.lines>c>>6){let u=this.children.slice();return u[r]=l,new n(u,this.length-(t-e)+i.length)}return super.replace(o,a,l)}o=a+1}return super.replace(e,t,i)}sliceString(e,t=this.length,i=` `){[e,t]=Ql(this,e,t);let r="";for(let o=0,s=0;oe&&o&&(r+=i),es&&(r+=a.sliceString(e-s,t-s,i)),s=l+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof n))return 0;let i=0,[r,o,s,a]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;r+=t,o+=t){if(r==s||o==a)return i;let l=this.children[r],c=e.children[o];if(l!=c)return i+l.scanIdentical(c,t);i+=l.length+1}}static from(e,t=e.reduce((i,r)=>i+r.length+1,-1)){let i=0;for(let d of e)i+=d.lines;if(i<32){let d=[];for(let p of e)p.flatten(d);return new An(d,t)}let r=Math.max(32,i>>5),o=r<<1,s=r>>1,a=[],l=0,c=-1,u=[];function f(d){let p;if(d.lines>o&&d instanceof n)for(let m of d.children)f(m);else d.lines>s&&(l>s||!l)?(h(),a.push(d)):d instanceof An&&l&&(p=u[u.length-1])instanceof An&&d.lines+p.lines<=32?(l+=d.lines,c+=d.length+1,u[u.length-1]=new An(p.text.concat(d.text),p.length+1+d.length)):(l+d.lines>r&&h(),l+=d.lines,c+=d.length+1,u.push(d))}function h(){l!=0&&(a.push(u.length==1?u[0]:n.from(u,c)),c=-1,l=u.length=0)}for(let d of e)f(d);return h(),a.length==1?a[0]:new n(a,t)}};be.empty=new An([""],0);function Z5(n){let e=-1;for(let t of n)e+=t.length+1;return e}function vg(n,e,t=0,i=1e9){for(let r=0,o=0,s=!0;o=t&&(l>i&&(a=a.slice(0,i-r)),r0?1:(e instanceof An?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,r=this.nodes[i],o=this.offsets[i],s=o>>1,a=r instanceof An?r.text.length:r.children.length;if(s==(t>0?a:0)){if(i==0)return this.done=!0,this.value="",this;t>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((o&1)==(t>0?0:1)){if(this.offsets[i]+=t,e==0)return this.lineBreak=!0,this.value=` `,this;e--}else if(r instanceof An){let l=r.text[s+(t<0?-1:0)];if(this.offsets[i]+=t,l.length>Math.max(0,e))return this.value=e==0?l:t>0?l.slice(e):l.slice(0,l.length-e),this;e-=l.length}else{let l=r.children[s+(t<0?-1:0)];e>l.length?(e-=l.length,this.offsets[i]+=t):(t<0&&this.offsets[i]--,this.nodes.push(l),this.offsets.push(t>0?1:(l instanceof An?l.text.length:l.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}},xg=class{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new Ls(e,t>i?-1:1),this.pos=t>i?e.length:0,this.from=Math.min(t,i),this.to=Math.max(t,i)}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 i=t<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=i?r:t<0?r.slice(r.length-i):r.slice(0,i),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!=""}},bg=class{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:r}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol!="undefined"&&(be.prototype[Symbol.iterator]=function(){return this.iter()},Ls.prototype[Symbol.iterator]=xg.prototype[Symbol.iterator]=bg.prototype[Symbol.iterator]=function(){return this});var f0=class{constructor(e,t,i,r){this.from=e,this.to=t,this.number=i,this.text=r}get length(){return this.to-this.from}};function Ql(n,e,t){return e=Math.max(0,Math.min(n.length,e)),[e,Math.max(e,Math.min(n.length,t))]}function Dt(n,e,t=!0,i=!0){return VR(n,e,t,i)}function J5(n){return n>=56320&&n<57344}function eq(n){return n>=55296&&n<56320}function ti(n,e){let t=n.charCodeAt(e);if(!eq(t)||e+1==n.length)return t;let i=n.charCodeAt(e+1);return J5(i)?(t-55296<<10)+(i-56320)+65536:t}function E0(n){return n<=65535?String.fromCharCode(n):(n-=65536,String.fromCharCode((n>>10)+55296,(n&1023)+56320))}function Yi(n){return n<65536?1:2}var h0=/\r\n?|\n/,Ot=(function(n){return n[n.Simple=0]="Simple",n[n.TrackDel=1]="TrackDel",n[n.TrackBefore=2]="TrackBefore",n[n.TrackAfter=3]="TrackAfter",n})(Ot||(Ot={})),Br=class n{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;te)return o+(e-r);o+=a}else{if(i!=Ot.Simple&&c>=e&&(i==Ot.TrackDel&&re||i==Ot.TrackBefore&&re))return null;if(c>e||c==e&&t<0&&!a)return e==r||t<0?o:o+l;o+=l}r=c}if(e>r)throw new RangeError(`Position ${e} is out of range for changeset of length ${r}`);return o}touchesRange(e,t=e){for(let i=0,r=0;i=0&&r<=t&&a>=e)return rt?"cover":!0;r=a}return!1}toString(){let e="";for(let t=0;t=0?":"+r:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new n(e)}static create(e){return new n(e)}},cn=class n extends Br{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 d0(this,(t,i,r,o,s)=>e=e.replace(r,r+(i-t),s),!1),e}mapDesc(e,t=!1){return p0(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let r=0,o=0;r=0){t[r]=a,t[r+1]=s;let l=r>>1;for(;i.length0&&Do(i,t,o.text),o.forward(u),a+=u}let c=e[s++];for(;a>1].toJSON()))}return e}static of(e,t,i){let r=[],o=[],s=0,a=null;function l(u=!1){if(!u&&!r.length)return;sh||f<0||h>t)throw new RangeError(`Invalid change range ${f} to ${h} (in doc of length ${t})`);let p=d?typeof d=="string"?be.of(d.split(i||h0)):d:be.empty,m=p.length;if(f==h&&m==0)return;fs&&Xt(r,f-s,-1),Xt(r,h-f,m),Do(o,r,p),s=h}}return c(e),l(!a),a}static empty(e){return new n(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let r=0;ra&&typeof s!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(o.length==1)t.push(o[0],0);else{for(;i.length=0&&t<=0&&t==n[r+1]?n[r]+=e:r>=0&&e==0&&n[r]==0?n[r+1]+=t:i?(n[r]+=e,n[r+1]+=t):n.push(e,t)}function Do(n,e,t){if(t.length==0)return;let i=e.length-2>>1;if(i>1])),!(t||s==n.sections.length||n.sections[s+1]<0);)a=n.sections[s++],l=n.sections[s++];e(r,c,o,u,f),r=c,o=u}}}function p0(n,e,t,i=!1){let r=[],o=i?[]:null,s=new Bs(n),a=new Bs(e);for(let l=-1;;){if(s.done&&a.len||a.done&&s.len)throw new Error("Mismatched change set lengths");if(s.ins==-1&&a.ins==-1){let c=Math.min(s.len,a.len);Xt(r,c,-1),s.forward(c),a.forward(c)}else if(a.ins>=0&&(s.ins<0||l==s.i||s.off==0&&(a.len=0&&l=0){let c=0,u=s.len;for(;u;)if(a.ins==-1){let f=Math.min(u,a.len);c+=f,u-=f,a.forward(f)}else if(a.ins==0&&a.lenl||s.ins>=0&&s.len>l)&&(a||i.length>c),o.forward2(l),s.forward(l)}}}}var Bs=class{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return t>=e.length?be.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?be.empty:t[i].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}},Hl=class n{constructor(e,t,i){this.from=e,this.to=t,this.flags=i}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,t=-1){let i,r;return this.empty?i=r=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),r=e.mapPos(this.to,-1)),i==this.from&&r==this.to?this:new n(i,r,this.flags)}extend(e,t=e,i=0){if(e<=this.anchor&&t>=this.anchor)return $.range(e,t,void 0,void 0,i);let r=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return $.range(this.anchor,r,void 0,void 0,i)}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||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return $.range(e.anchor,e.head)}static create(e,t,i){return new n(e,t,i)}},$=class n{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:n.create(this.ranges.map(i=>i.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let i=0;ie.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new n(e.ranges.map(t=>Hl.fromJSON(t)),e.main)}static single(e,t=e){return new n([n.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,r=0;rr.from-o.from),t=e.indexOf(i);for(let r=1;ro.head?n.range(l,a):n.range(a,l))}}return new n(e,t)}};function ZR(n,e){for(let t of n.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}var S0=0,H=class n{constructor(e,t,i,r,o){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=r,this.id=S0++,this.default=e([]),this.extensions=typeof o=="function"?o(this):o}get reader(){return this}static define(e={}){return new n(e.combine||(t=>t),e.compareInput||((t,i)=>t===i),e.compare||(e.combine?(t,i)=>t===i:O0),!!e.static,e.enables)}of(e){return new Wl([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Wl(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Wl(e,this,2,t)}from(e,t){return t||(t=i=>i),this.compute([e],i=>t(i.field(e)))}};function O0(n,e){return n==e||n.length==e.length&&n.every((t,i)=>t===e[i])}var Wl=class{constructor(e,t,i,r){this.dependencies=e,this.facet=t,this.type=i,this.value=r,this.id=S0++}dynamicSlot(e){var t;let i=this.value,r=this.facet.compareInput,o=this.id,s=e[o]>>1,a=this.type==2,l=!1,c=!1,u=[];for(let f of this.dependencies)f=="doc"?l=!0:f=="selection"?c=!0:(((t=e[f.id])!==null&&t!==void 0?t:1)&1)==0&&u.push(e[f.id]);return{create(f){return f.values[s]=i(f),1},update(f,h){if(l&&h.docChanged||c&&(h.docChanged||h.selection)||m0(f,u)){let d=i(f);if(a?!QR(d,f.values[s],r):!r(d,f.values[s]))return f.values[s]=d,1}return 0},reconfigure:(f,h)=>{let d,p=h.config.address[o];if(p!=null){let m=Cg(h,p);if(this.dependencies.every(g=>g instanceof H?h.facet(g)===f.facet(g):g instanceof qt?h.field(g,!1)==f.field(g,!1):!0)||(a?QR(d=i(f),m,r):r(d=i(f),m)))return f.values[s]=m,0}else d=i(f);return f.values[s]=d,1}}}};function QR(n,e,t){if(n.length!=e.length)return!1;for(let i=0;in[l.id]),r=t.map(l=>l.type),o=i.filter(l=>!(l&1)),s=n[e.id]>>1;function a(l){let c=[];for(let u=0;ui===r),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(mg).find(i=>i.field==this);return((t==null?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:i=>(i.values[t]=this.create(i),1),update:(i,r)=>{let o=i.values[t],s=this.updateF(o,r);return this.compareF(o,s)?0:(i.values[t]=s,1)},reconfigure:(i,r)=>{let o=i.facet(mg),s=r.facet(mg),a;return(a=o.find(l=>l.field==this))&&a!=s.find(l=>l.field==this)?(i.values[t]=a.create(i),1):r.config.address[this.id]!=null?(i.values[t]=r.field(this),0):(i.values[t]=this.create(i),1)}}}init(e){return[this,mg.of({field:this,create:e})]}get extension(){return this}},Ds={lowest:4,low:3,default:2,high:1,highest:0};function hh(n){return e=>new _g(e,n)}var $r={highest:hh(Ds.highest),high:hh(Ds.high),default:hh(Ds.default),low:hh(Ds.low),lowest:hh(Ds.lowest)},_g=class{constructor(e,t){this.inner=e,this.prec=t}},Ns=class n{of(e){return new ph(this,e)}reconfigure(e){return n.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}},ph=class{constructor(e,t){this.compartment=e,this.inner=t}},wg=class n{constructor(e,t,i,r,o,s){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=r,this.staticValues=o,this.facets=s,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,t,i){let r=[],o=Object.create(null),s=new Map;for(let h of nq(e,t,s))h instanceof qt?r.push(h):(o[h.facet.id]||(o[h.facet.id]=[])).push(h);let a=Object.create(null),l=[],c=[];for(let h of r)a[h.id]=c.length<<1,c.push(d=>h.slot(d));let u=i==null?void 0:i.config.facets;for(let h in o){let d=o[h],p=d[0].facet,m=u&&u[h]||[];if(d.every(g=>g.type==0))if(a[p.id]=l.length<<1|1,O0(m,d))l.push(i.facet(p));else{let g=p.combine(d.map(b=>b.value));l.push(i&&p.compare(g,i.facet(p))?i.facet(p):g)}else{for(let g of d)g.type==0?(a[g.id]=l.length<<1|1,l.push(g.value)):(a[g.id]=c.length<<1,c.push(b=>g.dynamicSlot(b)));a[p.id]=c.length<<1,c.push(g=>tq(g,p,d))}}let f=c.map(h=>h(a));return new n(e,s,f,a,l,o)}};function nq(n,e,t){let i=[[],[],[],[],[]],r=new Map;function o(s,a){let l=r.get(s);if(l!=null){if(l<=a)return;let c=i[l].indexOf(s);c>-1&&i[l].splice(c,1),s instanceof ph&&t.delete(s.compartment)}if(r.set(s,a),Array.isArray(s))for(let c of s)o(c,a);else if(s instanceof ph){if(t.has(s.compartment))throw new RangeError("Duplicate use of compartment in extensions");let c=e.get(s.compartment)||s.inner;t.set(s.compartment,c),o(c,a)}else if(s instanceof _g)o(s.inner,s.prec);else if(s instanceof qt)i[a].push(s),s.provides&&o(s.provides,a);else if(s instanceof Wl)i[a].push(s),s.facet.extensions&&o(s.facet.extensions,Ds.default);else{let c=s.extension;if(!c)throw new Error(`Unrecognized extension value in extension set (${s}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);o(c,a)}}return o(n,Ds.default),i.reduce((s,a)=>s.concat(a))}function dh(n,e){if(e&1)return 2;let t=e>>1,i=n.status[t];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;n.status[t]=4;let r=n.computeSlot(n,n.config.dynamicSlots[t]);return n.status[t]=2|r}function Cg(n,e){return e&1?n.config.staticValues[e>>1]:n.values[e>>1]}var JR=H.define(),g0=H.define({combine:n=>n.some(e=>e),static:!0}),eT=H.define({combine:n=>n.length?n[0]:void 0,static:!0}),tT=H.define(),nT=H.define(),iT=H.define(),rT=H.define({combine:n=>n.length?n[0]:!1}),Mn=class{constructor(e,t){this.type=e,this.value=t}static define(){return new y0}},y0=class{of(e){return new Mn(this,e)}},v0=class{constructor(e){this.map=e}of(e){return new de(this,e)}},de=class n{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new n(this.type,t)}is(e){return this.type==e}static define(e={}){return new v0(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let r of e){let o=r.map(t);o&&i.push(o)}return i}};de.reconfigure=de.define();de.appendConfig=de.define();var Ft=class n{constructor(e,t,i,r,o,s){this.startState=e,this.changes=t,this.selection=i,this.effects=r,this.annotations=o,this.scrollIntoView=s,this._doc=null,this._state=null,i&&ZR(i,t.newLength),o.some(a=>a.type==n.time)||(this.annotations=o.concat(n.time.of(Date.now())))}static create(e,t,i,r,o,s){return new n(e,t,i,r,o,s)}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(n.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}};Ft.time=Mn.define();Ft.userEvent=Mn.define();Ft.addToHistory=Mn.define();Ft.remote=Mn.define();function iq(n,e){let t=[];for(let i=0,r=0;;){let o,s;if(i=n[i]))o=n[i++],s=n[i++];else if(r=0;r--){let o=i[r](n);o instanceof Ft?n=o:Array.isArray(o)&&o.length==1&&o[0]instanceof Ft?n=o[0]:n=sT(e,Ul(o),!1)}return n}function oq(n){let e=n.startState,t=e.facet(iT),i=n;for(let r=t.length-1;r>=0;r--){let o=t[r](n);o&&Object.keys(o).length&&(i=oT(i,x0(e,o,n.changes.newLength),!0))}return i==n?n:Ft.create(e,n.changes,n.selection,i.effects,i.annotations,i.scrollIntoView)}var sq=[];function Ul(n){return n==null?sq:Array.isArray(n)?n:[n]}var ln=(function(n){return n[n.Word=0]="Word",n[n.Space=1]="Space",n[n.Other=2]="Other",n})(ln||(ln={})),aq=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,b0;try{b0=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function lq(n){if(b0)return b0.test(n);for(let e=0;e"\x80"&&(t.toUpperCase()!=t.toLowerCase()||aq.test(t)))return!0}return!1}function cq(n){return e=>{if(!/\S/.test(e))return ln.Space;if(lq(e))return ln.Word;for(let t=0;t-1)return ln.Word;return ln.Other}}var Ze=class n{constructor(e,t,i,r,o,s){this.config=e,this.doc=t,this.selection=i,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=o,s&&(s._state=this);for(let a=0;ar.set(c,l)),t=null),r.set(a.value.compartment,a.value.extension)):a.is(de.reconfigure)?(t=null,i=a.value):a.is(de.appendConfig)&&(t=null,i=Ul(i).concat(a.value));let o;t?o=e.startState.values.slice():(t=wg.resolve(i,r,this),o=new n(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(l,c)=>c.reconfigure(l,this),null).values);let s=e.startState.facet(g0)?e.newSelection:e.newSelection.asSingle();new n(t,e.newDoc,s,o,(a,l)=>l.update(a,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:$.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),r=this.changes(i.changes),o=[i.range],s=Ul(i.effects);for(let a=1;as.spec.fromJSON(a,l)))}}return n.create({doc:e.doc,selection:$.fromJSON(e.selection),extensions:t.extensions?r.concat([t.extensions]):r})}static create(e={}){let t=wg.resolve(e.extensions||[],new Map),i=e.doc instanceof be?e.doc:be.of((e.doc||"").split(t.staticFacet(n.lineSeparator)||h0)),r=e.selection?e.selection instanceof $?e.selection:$.single(e.selection.anchor,e.selection.head):$.single(0);return ZR(r,i.length),t.staticFacet(g0)||(r=r.asSingle()),new n(t,i,r,t.dynamicSlots.map(()=>null),(o,s)=>s.create(o),null)}get tabSize(){return this.facet(n.tabSize)}get lineBreak(){return this.facet(n.lineSeparator)||` `}get readOnly(){return this.facet(rT)}phrase(e,...t){for(let i of this.facet(n.phrases))if(Object.prototype.hasOwnProperty.call(i,e)){e=i[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(i,r)=>{if(r=="$")return"$";let o=+(r||1);return!o||o>t.length?i:t[o-1]})),e}languageDataAt(e,t,i=-1){let r=[];for(let o of this.facet(JR))for(let s of o(this,t,i))Object.prototype.hasOwnProperty.call(s,e)&&r.push(s[e]);return r}charCategorizer(e){let t=this.languageDataAt("wordChars",e);return cq(t.length?t[0]:"")}wordAt(e){let{text:t,from:i,length:r}=this.doc.lineAt(e),o=this.charCategorizer(e),s=e-i,a=e-i;for(;s>0;){let l=Dt(t,s,!1);if(o(t.slice(l,s))!=ln.Word)break;s=l}for(;an.length?n[0]:4});Ze.lineSeparator=eT;Ze.readOnly=rT;Ze.phrases=H.define({compare(n,e){let t=Object.keys(n),i=Object.keys(e);return t.length==i.length&&t.every(r=>n[r]==e[r])}});Ze.languageData=JR;Ze.changeFilter=tT;Ze.transactionFilter=nT;Ze.transactionExtender=iT;Ns.reconfigure=de.define();function Io(n,e,t={}){let i={};for(let r of n)for(let o of Object.keys(r)){let s=r[o],a=i[o];if(a===void 0)i[o]=s;else if(!(a===s||s===void 0))if(Object.hasOwnProperty.call(t,o))i[o]=t[o](a,s);else throw new Error("Config merge conflict for field "+o)}for(let r in e)i[r]===void 0&&(i[r]=e[r]);return i}var ei=class{eq(e){return this==e}range(e,t=e){return mh.create(e,t,this)}};ei.prototype.startSide=ei.prototype.endSide=0;ei.prototype.point=!1;ei.prototype.mapMode=Ot.TrackDel;function k0(n,e){return n==e||n.constructor==e.constructor&&n.eq(e)}var mh=class n{constructor(e,t,i){this.from=e,this.to=t,this.value=i}static create(e,t,i){return new n(e,t,i)}};function _0(n,e){return n.from-e.from||n.value.startSide-e.value.startSide}var w0=class n{constructor(e,t,i,r){this.from=e,this.to=t,this.value=i,this.maxPoint=r}get length(){return this.to[this.to.length-1]}findIndex(e,t,i,r=0){let o=i?this.to:this.from;for(let s=r,a=o.length;;){if(s==a)return s;let l=s+a>>1,c=o[l]-e||(i?this.value[l].endSide:this.value[l].startSide)-t;if(l==s)return c>=0?s:a;c>=0?a=l:s=l+1}}between(e,t,i,r){for(let o=this.findIndex(t,-1e9,!0),s=this.findIndex(i,1e9,!1,o);od||h==d&&c.startSide>0&&c.endSide<=0)continue;(d-h||c.endSide-c.startSide)<0||(s<0&&(s=h),c.point&&(a=Math.max(a,d-h)),i.push(c),r.push(h-s),o.push(d-s))}return{mapped:i.length?new n(r,o,i,a):null,pos:s}}},Be=class n{constructor(e,t,i,r){this.chunkPos=e,this.chunk=t,this.nextLayer=i,this.maxPoint=r}static create(e,t,i,r){return new n(e,t,i,r)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:i=!1,filterFrom:r=0,filterTo:o=this.length}=e,s=e.filter;if(t.length==0&&!s)return this;if(i&&(t=t.slice().sort(_0)),this.isEmpty)return t.length?n.of(t):this;let a=new Eg(this,null,-1).goto(0),l=0,c=[],u=new Nr;for(;a.value||l=0){let f=t[l++];u.addInner(f.from,f.to,f.value)||c.push(f)}else a.rangeIndex==1&&a.chunkIndexthis.chunkEnd(a.chunkIndex)||oa.to||o=o&&e<=o+s.length&&s.between(o,e-o,t-o,i)===!1)return}this.nextLayer.between(e,t,i)}}iter(e=0){return gh.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return gh.from(e).goto(t)}static compare(e,t,i,r,o=-1){let s=e.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=o),a=t.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=o),l=KR(s,a,i),c=new Is(s,l,o),u=new Is(a,l,o);i.iterGaps((f,h,d)=>GR(c,f,u,h,d,r)),i.empty&&i.length==0&&GR(c,0,u,0,0,r)}static eq(e,t,i=0,r){r==null&&(r=999999999);let o=e.filter(u=>!u.isEmpty&&t.indexOf(u)<0),s=t.filter(u=>!u.isEmpty&&e.indexOf(u)<0);if(o.length!=s.length)return!1;if(!o.length)return!0;let a=KR(o,s),l=new Is(o,a,0).goto(i),c=new Is(s,a,0).goto(i);for(;;){if(l.to!=c.to||!C0(l.active,c.active)||l.point&&(!c.point||!k0(l.point,c.point)))return!1;if(l.to>r)return!0;l.next(),c.next()}}static spans(e,t,i,r,o=-1){let s=new Is(e,null,o).goto(t),a=t,l=s.openStart;for(;;){let c=Math.min(s.to,i);if(s.point){let u=s.activeForPoint(s.to),f=s.pointFroma&&(r.span(a,c,s.active,l),l=s.openEnd(c));if(s.to>i)return l+(s.point&&s.to>i?1:0);a=s.to,s.next()}}static of(e,t=!1){let i=new Nr;for(let r of e instanceof mh?[e]:t?uq(e):e)i.add(r.from,r.to,r.value);return i.finish()}static join(e){if(!e.length)return n.empty;let t=e[e.length-1];for(let i=e.length-2;i>=0;i--)for(let r=e[i];r!=n.empty;r=r.nextLayer)t=new n(r.chunkPos,r.chunk,t,Math.max(r.maxPoint,t.maxPoint));return t}};Be.empty=new Be([],[],null,-1);function uq(n){if(n.length>1)for(let e=n[0],t=1;t0)return n.slice().sort(_0);e=i}return n}Be.empty.nextLayer=Be.empty;var Nr=class n{finishChunk(e){this.chunks.push(new w0(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,i){this.addInner(e,t,i)||(this.nextLayer||(this.nextLayer=new n)).add(e,t,i)}addInner(e,t,i){let r=e-this.lastTo||i.startSide-this.last.endSide;if(r<=0&&(e-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return r<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=i,this.lastFrom=e,this.lastTo=t,this.value.push(i),i.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 i=t.value.length-1;return this.last=t.value[i],this.lastFrom=t.from[i]+e,this.lastTo=t.to[i]+e,!0}finish(){return this.finishInner(Be.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=Be.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}};function KR(n,e,t){let i=new Map;for(let o of n)for(let s=0;s=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=i&&r.push(new Eg(s,t,i,o));return r.length==1?r[0]:new n(r)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let i of this.heap)i.goto(e,t);for(let i=this.heap.length>>1;i>=0;i--)u0(this.heap,i);return this.next(),this}forward(e,t){for(let i of this.heap)i.forward(e,t);for(let i=this.heap.length>>1;i>=0;i--)u0(this.heap,i);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(this.heap.length==0)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(),u0(this.heap,0)}}};function u0(n,e){for(let t=n[e];;){let i=(e<<1)+1;if(i>=n.length)break;let r=n[i];if(i+1=0&&(r=n[i+1],i++),t.compare(r)<0)break;n[i]=t,n[e]=r,e=i}}var Is=class{constructor(e,t,i){this.minPoint=i,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=gh.from(e,t,i)}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){gg(this.active,e),gg(this.activeTo,e),gg(this.activeRank,e),this.minActive=XR(this.active,this.activeTo)}addActive(e){let t=0,{value:i,to:r,rank:o}=this.cursor;for(;t0;)t++;yg(this.active,t,i),yg(this.activeTo,t,r),yg(this.activeRank,t,o),e&&yg(e,t,this.cursor.from),this.minActive=XR(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let r=this.minActive;if(r>-1&&(this.activeTo[r]-this.cursor.from||this.active[r].endSide-this.cursor.startSide)<0){if(this.activeTo[r]>e){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),i&&gg(i,r)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let o=this.cursor.value;if(!o.point)this.addActive(i),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from=0&&i[r]=0&&!(this.activeRank[i]e||this.activeTo[i]==e&&this.active[i].endSide>=this.point.endSide)&&t.push(this.active[i]);return t.reverse()}openEnd(e){let t=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>e;i--)t++;return t}};function GR(n,e,t,i,r,o){n.goto(e),t.goto(i);let s=i+r,a=i,l=i-e,c=!!o.boundChange;for(let u=!1;;){let f=n.to+l-t.to,h=f||n.endSide-t.endSide,d=h<0?n.to+l:t.to,p=Math.min(d,s);if(n.point||t.point?(n.point&&t.point&&k0(n.point,t.point)&&C0(n.activeForPoint(n.to),t.activeForPoint(t.to))||o.comparePoint(a,p,n.point,t.point),u=!1):(u&&o.boundChange(a),p>a&&!C0(n.active,t.active)&&o.compareRange(a,p,n.active,t.active),c&&ps)break;a=d,h<=0&&n.next(),h>=0&&t.next()}}function C0(n,e){if(n.length!=e.length)return!1;for(let t=0;t=e;i--)n[i+1]=n[i];n[e]=t}function XR(n,e){let t=-1,i=1e9;for(let r=0;r=e)return r;if(r==n.length)break;o+=n.charCodeAt(r)==9?t-o%t:1,r=Dt(n,r)}return i===!0?-1:n.length}var lT=typeof Symbol=="undefined"?"__\u037C":Symbol.for("\u037C"),R0=typeof Symbol=="undefined"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),cT=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:{},ni=class{constructor(e,t){this.rules=[];let{finish:i}=t||{};function r(s){return/^@/.test(s)?[s]:s.split(/,\s*/)}function o(s,a,l,c){let u=[],f=/^@(\w+)\b/.exec(s[0]),h=f&&f[1]=="keyframes";if(f&&a==null)return l.push(s[0]+";");for(let d in a){let p=a[d];if(/&/.test(d))o(d.split(/,\s*/).map(m=>s.map(g=>m.replace(/&/,g))).reduce((m,g)=>m.concat(g)),p,l);else if(p&&typeof p=="object"){if(!f)throw new RangeError("The value of a property ("+d+") should be a primitive value.");o(r(d),p,u,h)}else p!=null&&u.push(d.replace(/_.*/,"").replace(/[A-Z]/g,m=>"-"+m.toLowerCase())+": "+p+";")}(u.length||h)&&l.push((i&&!f&&!c?s.map(i):s).join(", ")+" {"+u.join(" ")+"}")}for(let s in e)o(r(s),e[s],this.rules)}getRules(){return this.rules.join(` `)}static newName(){let e=cT[lT]||1;return cT[lT]=e+1,"\u037C"+e.toString(36)}static mount(e,t,i){let r=e[R0],o=i&&i.nonce;r?o&&r.setNonce(o):r=new T0(e,o),r.mount(Array.isArray(t)?t:[t],e)}},uT=new Map,T0=class{constructor(e,t){let i=e.ownerDocument||e,r=i.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let o=uT.get(i);if(o)return e[R0]=o;this.sheet=new r.CSSStyleSheet,uT.set(i,this)}else this.styleTag=i.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[R0]=this}mount(e,t){let i=this.sheet,r=0,o=0;for(let s=0;s-1&&(this.modules.splice(l,1),o--,l=-1),l==-1){if(this.modules.splice(o++,0,a),i)for(let c=0;c",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},fq=typeof navigator!="undefined"&&/Mac/.test(navigator.platform),hq=typeof navigator!="undefined"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(wt=0;wt<10;wt++)jr[48+wt]=jr[96+wt]=String(wt);var wt;for(wt=1;wt<=24;wt++)jr[wt+111]="F"+wt;var wt;for(wt=65;wt<=90;wt++)jr[wt]=String.fromCharCode(wt+32),Kl[wt]=String.fromCharCode(wt);var wt;for(Sg in jr)Kl.hasOwnProperty(Sg)||(Kl[Sg]=jr[Sg]);var Sg;function fT(n){var e=fq&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||hq&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Kl:jr)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}function Pn(){var n=arguments[0];typeof n=="string"&&(n=document.createElement(n));var e=1,t=arguments[1];if(t&&typeof t=="object"&&t.nodeType==null&&!Array.isArray(t)){for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i)){var r=t[i];typeof r=="string"?n.setAttribute(i,r):r!=null&&(n[i]=r)}e++}for(;e2),z={mac:mT||/Mac/.test(un.platform),windows:/Win/.test(un.platform),linux:/Linux|X11/.test(un.platform),ie:Jg,ie_version:zT?L0.documentMode||6:N0?+N0[1]:B0?+B0[1]:0,gecko:dT,gecko_version:dT?+(/Firefox\/(\d+)/.exec(un.userAgent)||[0,0])[1]:0,chrome:!!A0,chrome_version:A0?+A0[1]:0,ios:mT,android:/Android\b/.test(un.userAgent),webkit:pT,webkit_version:pT?+(/\bAppleWebKit\/(\d+)/.exec(un.userAgent)||[0,0])[1]:0,safari:$0,safari_version:$0?+(/\bVersion\/(\d+(\.\d+)?)/.exec(un.userAgent)||[0,0])[1]:0,tabSize:L0.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function _b(n,e){for(let t in n)t=="class"&&e.class?e.class+=" "+n.class:t=="style"&&e.style?e.style+=";"+n.style:e[t]=n[t];return e}var Ng=Object.create(null);function wb(n,e,t){if(n==e)return!0;n||(n=Ng),e||(e=Ng);let i=Object.keys(n),r=Object.keys(e);if(i.length-(t&&i.indexOf(t)>-1?1:0)!=r.length-(t&&r.indexOf(t)>-1?1:0))return!1;for(let o of i)if(o!=t&&(r.indexOf(o)==-1||n[o]!==e[o]))return!1;return!0}function dq(n,e){for(let t=n.attributes.length-1;t>=0;t--){let i=n.attributes[t].name;e[i]==null&&n.removeAttribute(i)}for(let t in e){let i=e[t];t=="style"?n.style.cssText=i:n.getAttribute(t)!=i&&n.setAttribute(t,i)}}function gT(n,e,t){let i=!1;if(e)for(let r in e)t&&r in t||(i=!0,r=="style"?n.style.cssText="":n.removeAttribute(r));if(t)for(let r in t)e&&e[r]==t[r]||(i=!0,r=="style"?n.style.cssText=t[r]:n.setAttribute(r,t[r]));return i}function pq(n){let e=Object.create(null);for(let t=0;t0?3e8:-4e8:t>0?1e8:-1e8,new qs(e,t,t,i,e.widget||null,!1)}static replace(e){let t=!!e.block,i,r;if(e.isBlockGap)i=-5e8,r=4e8;else{let{start:o,end:s}=WT(e,t);i=(o?t?-3e8:-1:5e8)-1,r=(s?t?2e8:1:-6e8)+1}return new qs(e,i,r,t,e.widget||null,!0)}static line(e){return new Rh(e)}static set(e,t=!1){return Be.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};he.none=Be.empty;var kh=class n extends he{constructor(e){let{start:t,end:i}=WT(e);super(t?-1:5e8,i?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?_b(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||Ng}eq(e){return this==e||e instanceof n&&this.tagName==e.tagName&&wb(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)}};kh.prototype.point=!1;var Rh=class n extends he{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof n&&this.spec.class==e.spec.class&&wb(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)}};Rh.prototype.mapMode=Ot.TrackBefore;Rh.prototype.point=!0;var qs=class n extends he{constructor(e,t,i,r,o,s){super(t,i,o,e),this.block=r,this.isReplace=s,this.mapMode=r?t<=0?Ot.TrackBefore:Ot.TrackAfter:Ot.TrackDel}get type(){return this.startSide!=this.endSide?si.WidgetRange:this.startSide<=0?si.WidgetBefore:si.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof n&&mq(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}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)}};qs.prototype.point=!0;function WT(n,e=!1){let{inclusiveStart:t,inclusiveEnd:i}=n;return t==null&&(t=n.inclusive),i==null&&(i=n.inclusive),{start:t!=null?t:e,end:i!=null?i:e}}function mq(n,e){return n==e||!!(n&&e&&n.compare(e))}function Jl(n,e,t,i=0){let r=t.length-1;r>=0&&t[r]+i>=n?t[r]=Math.max(t[r],e):t.push(n,e)}var $g=class n extends ei{constructor(e,t,i){super(),this.tagName=e,this.attributes=t,this.rank=i}eq(e){return e==this||e instanceof n&&this.tagName==e.tagName&&wb(this.attributes,e.attributes)}static create(e){return new n(e.tagName,e.attributes||Ng,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,t=!1){return Be.of(e,t)}};$g.prototype.startSide=$g.prototype.endSide=-1;function Th(n){let e;return n.nodeType==11?e=n.getSelection?n:n.ownerDocument:e=n,e.getSelection()}function j0(n,e){return e?n==e||n.contains(e.nodeType!=1?e.parentNode:e):!1}function xh(n,e){if(!e.anchorNode)return!1;try{return j0(n,e.anchorNode)}catch{return!1}}function bh(n){return n.nodeType==3?Mh(n,0,n.nodeValue.length).getClientRects():n.nodeType==1?n.getClientRects():[]}function _h(n,e,t,i){return t?yT(n,e,t,i,-1)||yT(n,e,t,i,1):!1}function No(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e}function jg(n){return n.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(n.nodeName)}function yT(n,e,t,i,r){for(;;){if(n==t&&e==i)return!0;if(e==(r<0?0:Vr(n))){if(n.nodeName=="DIV")return!1;let o=n.parentNode;if(!o||o.nodeType!=1)return!1;e=No(n)+(r<0?0:1),n=o}else if(n.nodeType==1){if(n=n.childNodes[e+(r<0?-1:0)],n.nodeType==1&&n.contentEditable=="false")return!1;e=r<0?Vr(n):0}else return!1}}function Vr(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Ah(n,e){let t=e?n.left:n.right;return{left:t,right:t,top:n.top,bottom:n.bottom}}function gq(n){let e=n.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.innerWidth,top:0,bottom:n.innerHeight}}function UT(n,e){let t=e.width/n.offsetWidth,i=e.height/n.offsetHeight;return(t>.995&&t<1.005||!isFinite(t)||Math.abs(e.width-n.offsetWidth)<1)&&(t=1),(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.height-n.offsetHeight)<1)&&(i=1),{scaleX:t,scaleY:i}}function yq(n,e,t,i,r,o,s,a){let l=n.ownerDocument,c=l.defaultView||window;for(let u=n,f=!1;u&&!f;)if(u.nodeType==1){let h,d=u==l.body,p=1,m=1;if(d)h=gq(c);else{if(/^(fixed|sticky)$/.test(getComputedStyle(u).position)&&(f=!0),u.scrollHeight<=u.clientHeight&&u.scrollWidth<=u.clientWidth){u=u.assignedSlot||u.parentNode;continue}let _=u.getBoundingClientRect();({scaleX:p,scaleY:m}=UT(u,_)),h={left:_.left,right:_.left+u.clientWidth*p,top:_.top,bottom:_.top+u.clientHeight*m}}let g=0,b=0;if(r=="nearest")e.top0&&e.bottom>h.bottom+b&&(b=e.bottom-h.bottom+s)):e.bottom>h.bottom-s&&(b=e.bottom-h.bottom+s,t<0&&e.top-b0&&e.right>h.right+g&&(g=e.right-h.right+o)):e.right>h.right-o&&(g=e.right-h.right+o,t<0&&e.lefth.bottom||e.lefth.right)&&(e={left:Math.max(e.left,h.left),right:Math.min(e.right,h.right),top:Math.max(e.top,h.top),bottom:Math.min(e.bottom,h.bottom)}),u=u.assignedSlot||u.parentNode}else if(u.nodeType==11)u=u.host;else break}function QT(n,e=!0){let t=n.ownerDocument,i=null,r=null;for(let o=n.parentNode;o&&!(o==t.body||(!e||i)&&r);)if(o.nodeType==1)!r&&o.scrollHeight>o.clientHeight&&(r=o),e&&!i&&o.scrollWidth>o.clientWidth&&(i=o),o=o.assignedSlot||o.parentNode;else if(o.nodeType==11)o=o.host;else break;return{x:i,y:r}}var F0=class{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:i}=e;this.set(t,Math.min(e.anchorOffset,t?Vr(t):0),i,Math.min(e.focusOffset,i?Vr(i):0))}set(e,t,i,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=i,this.focusOffset=r}},js=null;z.safari&&z.safari_version>=26&&(js=!1);function KT(n){if(n.setActive)return n.setActive();if(js)return n.focus(js);let e=[];for(let t=n;t&&(e.push(t,t.scrollTop,t.scrollLeft),t!=t.ownerDocument);t=t.parentNode);if(n.focus(js==null?{get preventScroll(){return js={preventScroll:!0},!0}}:void 0),!js){js=!1;for(let t=0;tMath.max(0,n.document.documentElement.scrollHeight-n.innerHeight-4):n.scrollTop>Math.max(1,n.scrollHeight-n.clientHeight-4)}function XT(n,e){for(let t=n,i=e;;){if(t.nodeType==3&&i>0)return{node:t,offset:i};if(t.nodeType==1&&i>0){if(t.contentEditable=="false")return null;t=t.childNodes[i-1],i=Vr(t)}else if(t.parentNode&&!jg(t))i=No(t),t=t.parentNode;else return null}}function YT(n,e){for(let t=n,i=e;;){if(t.nodeType==3&&i=t){if(a.level==i)return s;(o<0||(r!=0?r<0?a.fromt:e[o].level>a.level))&&(o=s)}}if(o<0)throw new RangeError("Index out of range");return o}};function eA(n,e){if(n.length!=e.length)return!1;for(let t=0;t=0;m-=3)if(Zi[m+1]==-d){let g=Zi[m+2],b=g&2?r:g&4?g&1?o:r:0;b&&(Ne[f]=Ne[Zi[m]]=b),a=m;break}}else{if(Zi.length==189)break;Zi[a++]=f,Zi[a++]=h,Zi[a++]=l}else if((p=Ne[f])==2||p==1){let m=p==r;l=m?0:1;for(let g=a-3;g>=0;g-=3){let b=Zi[g+2];if(b&2)break;if(m)Zi[g+2]|=2;else{if(b&4)break;Zi[g+2]|=4}}}}}function Sq(n,e,t,i){for(let r=0,o=i;r<=t.length;r++){let s=r?t[r-1].to:n,a=rl;)p==g&&(p=t[--m].from,g=m?t[m-1].to:n),Ne[--p]=d;l=u}else o=c,l++}}}function V0(n,e,t,i,r,o,s){let a=i%2?2:1;if(i%2==r%2)for(let l=e,c=0;ll&&s.push(new oi(l,m.from,d));let g=m.direction==Vs!=!(d%2);H0(n,g?i+1:i,r,m.inner,m.from,m.to,s),l=m.to}p=m.to}else{if(p==t||(u?Ne[p]!=a:Ne[p]==a))break;p++}h?V0(n,l,p,i+1,r,h,s):le;){let u=!0,f=!1;if(!c||l>o[c-1].to){let m=Ne[l-1];m!=a&&(u=!1,f=m==16)}let h=!u&&a==1?[]:null,d=u?i:i+1,p=l;e:for(;;)if(c&&p==o[c-1].to){if(f)break e;let m=o[--c];if(!u)for(let g=m.from,b=c;;){if(g==e)break e;if(b&&o[b-1].to==g)g=o[--b].from;else{if(Ne[g-1]==a)break e;break}}if(h)h.push(m);else{m.toNe.length;)Ne[Ne.length]=256;let i=[],r=e==Vs?0:1;return H0(n,r,r,t,0,n.length,i),i}function tA(n){return[new oi(0,n,0)]}var nA="";function kq(n,e,t,i,r){var o;let s=i.head-n.from,a=oi.find(e,s,(o=i.bidiLevel)!==null&&o!==void 0?o:-1,i.assoc),l=e[a],c=l.side(r,t);if(s==c){let h=a+=r?1:-1;if(h<0||h>=e.length)return null;l=e[a=h],s=l.side(!r,t),c=l.side(r,t)}let u=Dt(n.text,s,l.forward(r,t));(ul.to)&&(u=c),nA=n.text.slice(Math.min(s,u),Math.max(s,u));let f=a==(r?e.length-1:0)?null:e[a+(r?1:-1)];return f&&u==c&&f.level+(r?0:1)n.some(e=>e)}),Tq=H.define({combine:n=>n.some(e=>e)}),uA=H.define(),wh=class n{constructor(e,t,i,r,o,s=!1){this.range=e,this.y=t,this.x=i,this.yMargin=r,this.xMargin=o,this.isSnapshot=s}map(e){return e.empty?this:new n(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 n($.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}},Og=de.define({map:(n,e)=>n.map(e)}),fA=de.define();function It(n,e,t){let i=n.facet(sA);i.length?i[0](e):window.onerror&&window.onerror(String(e),t,void 0,void 0,e)||(t?console.error(t+":",e):console.error(e))}var Fr=H.define({combine:n=>n.length?n[0]:!0}),Aq=0,Xl=H.define({combine(n){return n.filter((e,t)=>{for(let i=0;i{let l=[];return s&&l.push(ey.of(c=>{let u=c.plugin(a);return u?s(u):he.none})),o&&l.push(o(a)),l})}static fromClass(e,t){return n.define((i,r)=>new e(i,r),t)}},Ch=class{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 t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(i){if(It(t.state,i,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){It(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(!((t=this.value)===null||t===void 0)&&t.destroy)try{this.value.destroy()}catch(i){It(e.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}},hA=H.define(),Ob=H.define(),ey=H.define(),dA=H.define(),kb=H.define(),Ph=H.define(),pA=H.define();function xT(n,e){let t=n.state.facet(pA);if(!t.length)return t;let i=t.map(o=>o instanceof Function?o(n):o),r=[];return Be.spans(i,e.from,e.to,{point(){},span(o,s,a,l){let c=o-e.from,u=s-e.from,f=r;for(let h=a.length-1;h>=0;h--,l--){let d=a[h].spec.bidiIsolate,p;if(d==null&&(d=Rq(e.text,c,u)),l>0&&f.length&&(p=f[f.length-1]).to==c&&p.direction==d)p.to=u,f=p.inner;else{let m={from:c,to:u,direction:d,inner:[]};f.push(m),f=m.inner}}}}),r}var mA=H.define();function Rb(n){let e=0,t=0,i=0,r=0;for(let o of n.state.facet(mA)){let s=o(n);s&&(s.left!=null&&(e=Math.max(e,s.left)),s.right!=null&&(t=Math.max(t,s.right)),s.top!=null&&(i=Math.max(i,s.top)),s.bottom!=null&&(r=Math.max(r,s.bottom)))}return{left:e,right:t,top:i,bottom:r}}var yh=H.define(),_i=class n{constructor(e,t,i,r){this.fromA=e,this.toA=t,this.fromB=i,this.toB=r}join(e){return new n(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,i=this;for(;t>0;t--){let r=e[t-1];if(!(r.fromA>i.toA)){if(r.toAr.push(new _i(o,s,a,l))),this.changedRanges=r}static create(e,t,i){return new n(e,t,i)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}},Mq=[],it=class{constructor(e,t,i=0){this.dom=e,this.length=t,this.flags=i,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return Mq}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,this.flags&4){this.flags&=-5;let t=this.domAttrs;t&&dq(this.dom,t)}}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 i=t;for(let r of this.children){if(r==e)return i;i+=r.length+r.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 i=No(this.dom),r=this.length?e>0:t>0;return new Ji(this.parent.dom,i+(r?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof nc)return e;return null}static get(e){return e.cmTile}},tc=class extends it{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(this.flags&2)return;super.sync(e);let t=this.dom,i=null,r,o=(e==null?void 0:e.node)==t?e:null,s=0;for(let a of this.children){if(a.sync(e),s+=a.length+a.breakAfter,r=i?i.nextSibling:t.firstChild,o&&r!=a.dom&&(o.written=!0),a.dom.parentNode==t)for(;r&&r!=a.dom;)r=bT(r);else t.insertBefore(a.dom,r);i=a.dom}for(r=i?i.nextSibling:t.firstChild,o&&r&&(o.written=!0);r;)r=bT(r);this.length=s}};function bT(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}var nc=class extends tc{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=it.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],i=this,r=0,o=0;;)if(r==i.children.length){if(!t.length)return;i=i.parent,i.breakAfter&&o++,r=t.pop()}else{let s=i.children[r++];if(s instanceof qr)t.push(r),i=s,r=0;else{let a=o+s.length,l=e(s,o);if(l!==void 0)return l;o=a+s.breakAfter}}}resolveBlock(e,t){let i,r=-1,o,s=-1;if(this.blockTiles((a,l)=>{let c=l+a.length;if(e>=l&&e<=c){if(a.isWidget()&&t>=-1&&t<=1){if(a.flags&32)return!0;a.flags&16&&(i=void 0)}(le||e==l&&(t>1?a.length:a.covers(-1)))&&(!o||!a.isWidget()&&o.isWidget())&&(o=a,s=e-l)}}),!i&&!o)throw new Error("No tile at position "+e);return i&&t<0||!o?{tile:i,offset:r}:{tile:o,offset:s}}},qr=class n extends tc{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):!1}get domAttrs(){return this.wrapper.attributes}static of(e,t){let i=new n(t||document.createElement(e.tagName),e);return t||(i.flags|=4),i}},ic=class n extends tc{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(e,t,i){let r=new n(t||document.createElement("div"),e);return(!t||!i)&&(r.flags|=4),r}get domAttrs(){return this.attrs}resolveInline(e,t,i){let r=null,o=-1,s=null,a=-1;function l(u,f){for(let h=0,d=0;h=f&&(p.isComposite()?l(p,f-d):(!s||s.isHidden&&(t>0||i&&Dq(s,p)))&&(m>f||p.flags&32)?(s=p,a=f-d):(di&&(e=i);let r=e,o=e,s=0;e==0&&t<0||e==i&&t>=0?z.chrome||z.gecko||(e?(r--,s=1):o=0)?0:a.length-1];return z.safari&&!s&&l.width==0&&(l=Array.prototype.find.call(a,c=>c.width)||l),s?Ah(l,s<0):l||null}static of(e,t){let i=new n(t||document.createTextNode(e),e);return t||(i.flags|=2),i}},Hs=class n extends it{constructor(e,t,i,r){super(e,t,r),this.widget=i}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,t){return this.coordsInWidget(e,t,!1)}coordsInWidget(e,t,i){let r=this.widget.coordsAt(this.dom,e,t);if(r)return r;if(i)return Ah(this.dom.getBoundingClientRect(),this.length?e==0:t<=0);{let o=this.dom.getClientRects(),s=null;if(!o.length)return null;let a=this.flags&16?!0:this.flags&32?!1:e>0;for(let l=a?o.length-1:0;s=o[l],!(e>0?l==0:l==o.length-1||s.top0;)if(r.isComposite())if(s){if(!e)break;i&&i.break(),e--,s=!1}else if(o==r.children.length){if(!e&&!a.length)break;i&&i.leave(r),s=!!r.breakAfter,{tile:r,index:o}=a.pop(),o++}else{let l=r.children[o],c=l.breakAfter;(t>0?l.length<=e:l.length=0;a--){let l=t.marks[a],c=r.lastChild;if(c instanceof bn&&c.mark.eq(l.mark))c.dom!=l.dom&&c.setDOM(M0(l.dom)),r=c;else{if(this.cache.reused.get(l)){let f=it.get(l.dom);f&&f.setDOM(M0(l.dom))}let u=bn.of(l.mark,l.dom);r.append(u),r=u}this.cache.reused.set(l,2)}let o=it.get(e.text);o&&this.cache.reused.set(o,2);let s=new Fs(e.text,e.text.nodeValue);s.flags|=8,this.pos=e.range.toB,r.append(s)}addInlineWidget(e,t,i){let r=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);r||this.flushBuffer();let o=this.ensureMarks(t,i);!r&&!(e.flags&16)&&o.append(this.getBuffer(1)),o.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,i){this.flushBuffer(),this.ensureMarks(t,i).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){let t=this.afterWidget||this.lastBlock;t.length+=e,this.pos+=e}addLineStart(e,t){var i;e||(e=gA);let r=ic.start(e,t||((i=this.cache.find(ic))===null||i===void 0?void 0:i.dom),!!t);this.getBlockPos().append(this.lastBlock=this.curLine=r)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,t){var i;let r=this.curLine;for(let o=e.length-1;o>=0;o--){let s=e[o],a;if(t>0&&(a=r.lastChild)&&a instanceof bn&&a.mark.eq(s))r=a,t--;else{let l=bn.of(s,(i=this.cache.find(bn,c=>c.mark.eq(s)))===null||i===void 0?void 0:i.dom);r.append(l),r=l,t=0}}return r}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!_T(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(z.ios&&_T(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(P0,0,32)||new Hs(P0.toDOM(),0,P0,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){let t=e.rank*102+e.value.rank,i=new U0(e.from,e.to,e.value,t),r=this.wrappers.length;for(;r>0&&(this.wrappers[r-1].rank-i.rank||this.wrappers[r-1].to-i.to)<0;)r--;this.wrappers.splice(r,0,i)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let t=this.root;for(let i of this.wrappers){let r=t.lastChild;if(i.froms.wrapper.eq(i.wrapper)))===null||e===void 0?void 0:e.dom);t.append(o),t=o}}return t}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let t=2|(e<0?16:32),i=this.cache.find(rc,void 0,1);return i&&(i.flags=t),i||new rc(t)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}},K0=class{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:r,lineBreak:o,done:s}=this.cursor.next(this.skipCount);if(this.skipCount=0,s)throw new Error("Ran out of text content when drawing inline views");this.text=r;let a=this.textOff=Math.min(e,r.length);return o?null:r.slice(0,a)}let t=Math.min(this.text.length,this.textOff+e),i=this.text.slice(this.textOff,t);return this.textOff=t,i}},qg=[Hs,ic,Fs,bn,rc,qr,nc];for(let n=0;n[]),this.index=qg.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,i=this.buckets[t];i.length<6?i.push(e):i[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,i=2){let r=e.bucket,o=this.buckets[r],s=this.index[r];for(let a=o.length-1;a>=0;a--){let l=(a+s)%o.length,c=o[l];if((!t||t(c))&&!this.reused.has(c))return o.splice(l,1),l{if(this.cache.add(s),s.isComposite())return!1},enter:s=>this.cache.add(s),leave:()=>{},break:()=>{}}}run(e,t){let i=t&&this.getCompositionContext(t.text);for(let r=0,o=0,s=0;;){let a=sr){let c=l-r;this.preserve(c,!s,!a),r=l,o+=c}if(!a)break;t&&a.fromA<=t.range.fromA&&a.toA>=t.range.toA?(this.forward(a.fromA,t.range.fromA,t.range.fromA{if(s.isWidget())if(this.openWidget)this.builder.continueWidget(l-a);else{let c=l>0||a{s.isLine()?this.builder.addLineStart(s.attrs,this.cache.maybeReuse(s)):(this.cache.add(s),s instanceof bn&&r.unshift(s.mark)),this.openWidget=!1},leave:s=>{s.isLine()?r.length&&(r.length=o=0):s instanceof bn&&(r.shift(),o=Math.min(o,r.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let i=null,r=this.builder,o=0,s=Be.spans(this.decorations,e,t,{point:(a,l,c,u,f,h)=>{if(c instanceof qs){if(this.disallowBlockEffectsFor[h]){if(c.block)throw new RangeError("Block decorations may not be specified via plugins");if(l>this.view.state.doc.lineAt(a).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(o=u.length,f>u.length)r.continueWidget(l-a);else{let d=c.widget||(c.block?$o.block:$o.inline),p=Iq(c),m=this.cache.findWidget(d,l-a,p)||Hs.of(d,this.view,l-a,p);c.block?(c.startSide>0&&r.addLineStartIfNotCovered(i),r.addBlockWidget(m)):(r.ensureLine(i),r.addInlineWidget(m,u,f))}i=null}else i=Lq(i,c);l>a&&this.text.skip(l-a)},span:(a,l,c,u)=>{for(let f=a;fo,this.openMarks=s}forward(e,t,i=1){t-e<=10?this.old.advance(t-e,i,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,i,this.reuseWalker))}getCompositionContext(e){let t=[],i=null;for(let r=e.parentNode;;r=r.parentNode){let o=it.get(r);if(r==this.view.contentDOM)break;o instanceof bn?t.push(o):o!=null&&o.isLine()?i=o:o instanceof qr||(r.nodeName=="DIV"&&!i&&r!=this.view.contentDOM?i=new ic(r,gA):i||t.push(bn.of(new kh({tagName:r.nodeName.toLowerCase(),attributes:pq(r)}),r)))}return{line:i,marks:t}}};function _T(n,e){let t=i=>{for(let r of i.children)if((e?r.isText():r.length)||t(r))return!0;return!1};return t(n)}function Iq(n){let e=n.isReplace?(n.startSide<0?64:0)|(n.endSide>0?128:0):n.startSide>0?32:16;return n.block&&(e|=256),e}var gA={class:"cm-line"};function Lq(n,e){let t=e.spec.attributes,i=e.spec.class;return!t&&!i||(n||(n={class:"cm-line"}),t&&_b(t,n),i&&(n.class+=" "+i)),n}function Bq(n){let e=[];for(let t=n.parents.length;t>1;t--){let i=t==n.parents.length?n.tile:n.parents[t].tile;i instanceof bn&&e.push(i.mark)}return e}function M0(n){let e=it.get(n);return e&&e.setDOM(n.cloneNode()),n}var $o=class extends ai{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}};$o.inline=new $o("span");$o.block=new $o("div");var P0=new class extends ai{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}},Vg=class{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=he.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 nc(e,e.contentDOM),this.updateInner([new _i(0,0,0,e.state.doc.length)],null)}update(e){var t;let i=e.changedRanges;this.minWidth>0&&i.length&&(i.every(({fromA:u,toA:f})=>fthis.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let r=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((t=this.domChanged)===null||t===void 0)&&t.newSel?r=this.domChanged.newSel.head:!zq(e.changes,this.hasComposition)&&!e.selectionSet&&(r=e.state.selection.main.head));let o=r>-1?$q(this.view,e.changes,r):null;if(this.domChanged=null,this.hasComposition){let{from:u,to:f}=this.hasComposition;i=new _i(u,f,e.changes.mapPos(u,-1),e.changes.mapPos(f,1)).addToSet(i.slice())}this.hasComposition=o?{from:o.range.fromB,to:o.range.toB}:null,(z.ie||z.chrome)&&!o&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let s=this.decorations,a=this.blockWrappers;this.updateDeco();let l=qq(s,this.decorations,e.changes);l.length&&(i=_i.extendWithRanges(i,l));let c=Vq(a,this.blockWrappers,e.changes);return c.length&&(i=_i.extendWithRanges(i,c)),o&&!i.some(u=>u.fromA<=o.range.fromA&&u.toA>=o.range.toA)&&(i=o.range.addToSet(i.slice())),this.tile.flags&2&&i.length==0?!1:(this.updateInner(i,o),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:i}=this.view;i.ignore(()=>{if(t||e.length){let s=this.tile,a=new X0(this.view,s,this.blockWrappers,this.decorations,this.dynamicDecorationMap);t&&it.get(t.text)&&a.cache.reused.set(it.get(t.text),2),this.tile=a.run(e,t),Y0(s,a.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 o=z.chrome||z.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(o),o&&(o.written||i.selectionRange.focusNode!=o.node||!this.tile.dom.contains(o.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let r=[];if(this.view.viewport.from||this.view.viewport.to-1)&&xh(i,this.view.observer.selectionRange)&&!(r&&i.contains(r));if(!(o||t||s))return;let a=this.forceSelection;this.forceSelection=!1;let l=this.view.state.selection.main,c,u;if(l.empty?u=c=this.inlineDOMNearPos(l.anchor,l.assoc||1):(u=this.inlineDOMNearPos(l.head,l.head==l.from?1:-1),c=this.inlineDOMNearPos(l.anchor,l.anchor==l.from?1:-1)),z.gecko&&l.empty&&!this.hasComposition&&Nq(c)){let h=document.createTextNode("");this.view.observer.ignore(()=>c.node.insertBefore(h,c.node.childNodes[c.offset]||null)),c=u=new Ji(h,0),a=!0}let f=this.view.observer.selectionRange;(a||!f.focusNode||(!_h(c.node,c.offset,f.anchorNode,f.anchorOffset)||!_h(u.node,u.offset,f.focusNode,f.focusOffset))&&!this.suppressWidgetCursorChange(f,l))&&(this.view.observer.ignore(()=>{z.android&&z.chrome&&i.contains(f.focusNode)&&Hq(f.focusNode,i)&&(i.blur(),i.focus({preventScroll:!0}));let h=Th(this.view.root);if(h)if(l.empty){if(z.gecko){let d=jq(c.node,c.offset);if(d&&d!=3){let p=(d==1?XT:YT)(c.node,c.offset);p&&(c=new Ji(p.node,p.offset))}}h.collapse(c.node,c.offset),l.bidiLevel!=null&&h.caretBidiLevel!==void 0&&(h.caretBidiLevel=l.bidiLevel)}else if(h.extend){h.collapse(c.node,c.offset);try{h.extend(u.node,u.offset)}catch{}}else{let d=document.createRange();l.anchor>l.head&&([c,u]=[u,c]),d.setEnd(u.node,u.offset),d.setStart(c.node,c.offset),h.removeAllRanges(),h.addRange(d)}s&&this.view.root.activeElement==i&&(i.blur(),r&&r.focus())}),this.view.observer.setSelectionRange(c,u)),this.impreciseAnchor=c.precise?null:new Ji(f.anchorNode,f.anchorOffset),this.impreciseHead=u.precise?null:new Ji(f.focusNode,f.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&_h(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,i=Th(e.root),{anchorNode:r,anchorOffset:o}=e.observer.selectionRange;if(!i||!t.empty||!t.assoc||!i.modify)return;let s=this.lineAt(t.head,t.assoc);if(!s)return;let a=s.posAtStart;if(t.head==a||t.head==a+s.length)return;let l=this.coordsAt(t.head,-1),c=this.coordsAt(t.head,1);if(!l||!c||l.bottom>c.top)return;let u=this.domAtPos(t.head+t.assoc,t.assoc);i.collapse(u.node,u.offset),i.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let f=e.observer.selectionRange;e.docView.posFromDOM(f.anchorNode,f.anchorOffset)!=t.from&&i.collapse(r,o)}posFromDOM(e,t){let i=this.tile.nearest(e);if(!i)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let r=i.posAtStart;if(i.isComposite()){let o;if(e==i.dom)o=i.dom.childNodes[t];else{let s=Vr(e)==0?0:t==0?-1:1;for(;;){let a=e.parentNode;if(a==i.dom)break;s==0&&a.firstChild!=a.lastChild&&(e==a.firstChild?s=-1:s=1),e=a}s<0?o=e:o=e.nextSibling}if(o==i.dom.firstChild)return r;for(;o&&!it.get(o);)o=o.nextSibling;if(!o)return r+i.length;for(let s=0,a=r;;s++){let l=i.children[s];if(l.dom==o)return a;a+=l.length+l.breakAfter}}else return i.isText()?e==i.dom?r+t:r+(t?i.length:0):r}domAtPos(e,t){let{tile:i,offset:r}=this.tile.resolveBlock(e,t);return i.isWidget()?i.domPosFor(e,t):i.domIn(r,t)}inlineDOMNearPos(e,t){let i,r=-1,o=!1,s,a=-1,l=!1;return this.tile.blockTiles((c,u)=>{if(c.isWidget()){if(c.flags&32&&u>=e)return!0;c.flags&16&&(o=!0)}else{let f=u+c.length;if(u<=e&&(i=c,r=e-u,o=f=e&&!s&&(s=c,a=e-u,l=u>e),u>e&&s)return!0}}),!i&&!s?this.domAtPos(e,t):(o&&s?i=null:l&&i&&(s=null),i&&t<0||!s?i.domIn(r,t):s.domIn(a,t))}coordsAt(e,t){let{tile:i,offset:r}=this.tile.resolveBlock(e,t);return i.isWidget()?i.widget instanceof Eh?null:i.coordsInWidget(r,t,!0):i.coordsIn(r,t)}lineAt(e,t){let{tile:i}=this.tile.resolveBlock(e,t);return i.isLine()?i:null}coordsForChar(e){let{tile:t,offset:i}=this.tile.resolveBlock(e,1);if(!t.isLine())return null;function r(o,s){if(o.isComposite())for(let a of o.children){if(a.length>=s){let l=r(a,s);if(l)return l}if(s-=a.length,s<0)break}else if(o.isText()&&sMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,a=-1,l=this.view.textDirection==We.LTR,c=0,u=(f,h,d)=>{for(let p=0;pr);p++){let m=f.children[p],g=h+m.length,b=m.dom.getBoundingClientRect(),{height:_}=b;if(d&&!p&&(c+=b.top-d.top),m instanceof qr)g>i&&u(m,h,b);else if(h>=i&&(c>0&&t.push(-c),t.push(_+c),c=0,s)){let v=m.dom.lastChild,x=v?bh(v):[];if(x.length){let C=x[x.length-1],E=l?C.right-b.left:b.right-C.left;E>a&&(a=E,this.minWidth=o,this.minWidthFrom=h,this.minWidthTo=g)}}d&&p==f.children.length-1&&(c+=d.bottom-b.bottom),h=g+m.breakAfter}};return u(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return getComputedStyle(t.dom).direction=="rtl"?We.RTL:We.LTR}measureTextSize(){let e=this.tile.blockTiles(s=>{if(s.isLine()&&s.children.length&&s.length<=20){let a=0,l;for(let c of s.children){if(!c.isText()||/[^ -~]/.test(c.text))return;let u=bh(c.dom);if(u.length!=1)return;a+=u[0].width,l=u[0].height}if(a)return{lineHeight:s.dom.getBoundingClientRect().height,charWidth:a/s.length,textHeight:l}}});if(e)return e;let t=document.createElement("div"),i,r,o;return t.className="cm-line",t.style.width="99999px",t.style.position="absolute",t.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(t);let s=bh(t.firstChild)[0];i=t.getBoundingClientRect().height,r=s&&s.width?s.width/27:7,o=s&&s.height?s.height:i,t.remove()}),{lineHeight:i,charWidth:r,textHeight:o}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let i=0,r=0;;r++){let o=r==t.viewports.length?null:t.viewports[r],s=o?o.from-1:this.view.state.doc.length;if(s>i){let a=(t.lineBlockAt(s).bottom-t.lineBlockAt(i).top)/this.view.scaleY;e.push(he.replace({widget:new Eh(a),block:!0,inclusive:!0,isBlockGap:!0}).range(i,s))}if(!o)break;i=o.to+1}return he.set(e)}updateDeco(){let e=1,t=this.view.state.facet(ey).map(o=>(this.dynamicDecorationMap[e++]=typeof o=="function")?o(this.view):o),i=!1,r=this.view.state.facet(kb).map((o,s)=>{let a=typeof o=="function";return a&&(i=!0),a?o(this.view):o});for(r.length&&(this.dynamicDecorationMap[e++]=i,t.push(Be.join(r))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];etypeof o=="function"?o(this.view):o)}scrollIntoView(e){var t;if(e.isSnapshot){let u=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=u.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let u of this.view.state.facet(uA))try{if(u(this.view,e.range,e))return!0}catch(f){It(this.view.state,f,"scroll handler")}let{range:i}=e,r=this.coordsAt(i.head,(t=i.assoc)!==null&&t!==void 0?t:i.empty?0:i.head>i.anchor?-1:1),o;if(!r)return;!i.empty&&(o=this.coordsAt(i.anchor,i.anchor>i.head?-1:1))&&(r={left:Math.min(r.left,o.left),top:Math.min(r.top,o.top),right:Math.max(r.right,o.right),bottom:Math.max(r.bottom,o.bottom)});let s=Rb(this.view),a={left:r.left-s.left,top:r.top-s.top,right:r.right+s.right,bottom:r.bottom+s.bottom},{offsetWidth:l,offsetHeight:c}=this.view.scrollDOM;if(yq(this.view.scrollDOM,a,i.head1&&(r.top>window.pageYOffset+window.visualViewport.offsetTop+window.visualViewport.height||r.bottomi.isWidget()||i.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){Y0(this.tile)}};function Y0(n,e){let t=e==null?void 0:e.get(n);if(t!=1){t==null&&n.destroy();for(let i of n.children)Y0(i,e)}}function Nq(n){return n.node.nodeType==1&&n.node.firstChild&&(n.offset==0||n.node.childNodes[n.offset-1].contentEditable=="false")&&(n.offset==n.node.childNodes.length||n.node.childNodes[n.offset].contentEditable=="false")}function yA(n,e){let t=n.observer.selectionRange;if(!t.focusNode)return null;let i=XT(t.focusNode,t.focusOffset),r=YT(t.focusNode,t.focusOffset),o=i||r;if(r&&i&&r.node!=i.node){let a=it.get(r.node);if(!a||a.isText()&&a.text!=r.node.nodeValue)o=r;else if(n.docView.lastCompositionAfterCursor){let l=it.get(i.node);!l||l.isText()&&l.text!=i.node.nodeValue||(o=r)}}if(n.docView.lastCompositionAfterCursor=o!=i,!o)return null;let s=e-o.offset;return{from:s,to:s+o.node.nodeValue.length,node:o.node}}function $q(n,e,t){let i=yA(n,t);if(!i)return null;let{node:r,from:o,to:s}=i,a=r.nodeValue;if(/[\n\r]/.test(a)||n.state.doc.sliceString(i.from,i.to)!=a)return null;let l=e.invertedDesc;return{range:new _i(l.mapPos(o),l.mapPos(s),o,s),text:r}}function jq(n,e){return n.nodeType!=1?0:(e&&n.childNodes[e-1].contentEditable=="false"?1:0)|(e{ie.from&&(t=!0)}),t}var Eh=class extends ai{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 Wq(n,e,t=1){let i=n.charCategorizer(e),r=n.doc.lineAt(e),o=e-r.from;if(r.length==0)return $.cursor(e);o==0?t=1:o==r.length&&(t=-1);let s=o,a=o;t<0?s=Dt(r.text,o,!1):a=Dt(r.text,o);let l=i(r.text.slice(s,a));for(;s>0;){let c=Dt(r.text,s,!1);if(i(r.text.slice(c,s))!=l)break;s=c}for(;an.defaultLineHeight*1.5){let a=n.viewState.heightOracle.textHeight,l=Math.floor((r-t.top-(n.defaultLineHeight-a)*.5)/a);o+=l*n.viewState.heightOracle.lineLength}let s=n.state.sliceDoc(t.from,t.to);return t.from+aT(s,o,n.state.tabSize)}function Qq(n,e,t){let i=n.lineBlockAt(e);if(Array.isArray(i.type)){let r;for(let o of i.type){if(o.from>e)break;if(!(o.toe)return o;(!r||o.type==si.Text&&(r.type!=o.type||(t<0?o.frome)))&&(r=o)}}return r||i}return i}function Kq(n,e,t,i){let r=Qq(n,e.head,e.assoc||-1),o=!i||r.type!=si.Text||!(n.lineWrapping||r.widgetLineBreaks)?null:n.coordsAtPos(e.assoc<0&&e.head>r.from?e.head-1:e.head);if(o){let s=n.dom.getBoundingClientRect(),a=n.textDirectionAt(r.from),l=n.posAtCoords({x:t==(a==We.LTR)?s.right-1:s.left+1,y:(o.top+o.bottom)/2});if(l!=null)return $.cursor(l,t?-1:1)}return $.cursor(t?r.to:r.from,t?-1:1)}function wT(n,e,t,i){let r=n.state.doc.lineAt(e.head),o=n.bidiSpans(r),s=n.textDirectionAt(r.from);for(let a=e,l=null;;){let c=kq(r,o,s,a,t),u=nA;if(!c){if(r.number==(t?n.state.doc.lines:1))return a;u=` `,r=n.state.doc.line(r.number+(t?1:-1)),o=n.bidiSpans(r),c=n.visualLineSide(r,!t)}if(l){if(!l(u))return a}else{if(!i)return c;l=i(u)}a=c}}function Gq(n,e,t){let i=n.state.charCategorizer(e),r=i(t);return o=>{let s=i(o);return r==ln.Space&&(r=s),r==s}}function Xq(n,e,t,i){let r=e.head,o=t?1:-1;if(r==(t?n.state.doc.length:0))return $.cursor(r,e.assoc);let s=e.goalColumn,a,l=n.contentDOM.getBoundingClientRect(),c=n.coordsAtPos(r,e.assoc||((e.empty?t:e.head==e.from)?1:-1)),u=n.documentTop;if(c)s==null&&(s=c.left-l.left),a=o<0?c.top:c.bottom;else{let p=n.viewState.lineBlockAt(r);s==null&&(s=Math.min(l.right-l.left,n.defaultCharacterWidth*(r-p.from))),a=(o<0?p.top:p.bottom)+u}let f=l.left+s,h=n.viewState.heightOracle.textHeight>>1,d=i!=null?i:h;for(let p=0;;p+=h){let m=a+(d+p)*o,g=J0(n,{x:f,y:m},!1,o);if(t?m>l.bottom:ma:_{if(e>o&&er(n)),t.from,e.head>t.from?-1:1);return i==t.from?t:$.cursor(i,in.viewState.docHeight)return new ri(n.state.doc.length,-1);if(c=n.elementAtHeight(l),i==null)break;if(c.type==si.Text){if(i<0?c.ton.viewport.to)break;let h=n.docView.coordsAt(i<0?c.from:c.to,i>0?-1:1);if(h&&(i<0?h.top<=l+o:h.bottom>=l+o))break}let f=n.viewState.heightOracle.textHeight/2;l=i>0?c.bottom+f:c.top-f}if(n.viewport.from>=c.to||n.viewport.to<=c.from){if(t)return null;if(c.type==si.Text){let f=Uq(n,r,c,s,a);return new ri(f,f==c.from?1:-1)}}if(c.type!=si.Text)return l<(c.top+c.bottom)/2?new ri(c.from,1):new ri(c.to,-1);let u=n.docView.lineAt(c.from,2);return(!u||u.length!=c.length)&&(u=n.docView.lineAt(c.from,-2)),new eb(n,s,a,n.textDirectionAt(c.from)).scanTile(u,c.from)}var eb=class{constructor(e,t,i,r){this.view=e,this.x=t,this.y=i,this.baseDir=r,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to1||i.length&&(i[0].level!=this.baseDir||i[0].to+r.from>1;t:if(s.has(m)){let b=r+Math.floor(Math.random()*p);for(let _=0;_1)){if(_.bottomthis.y)(!c||c.top>_.top)&&(c=_),v=-1;else{let x=_.left>this.x?this.x-_.left:_.right(p+p+m)/3)return this.y=l.bottom-1,this.scan(e,t,!0);if(c&&c.top<(p+m+m)/3)return this.y=c.top+1,this.scan(e,t,!0)}let d=(a?this.dirAt(e[u],1):this.baseDir)==We.LTR;return{i:u,after:this.x>(h.left+h.right)/2==d}}scanText(e,t){let i=[];for(let o=0;o{let s=i[o]-t,a=i[o+1]-t;return Mh(e.dom,s,a).getClientRects()});return r.after?new ri(i[r.i+1],-1):new ri(i[r.i],1)}scanTile(e,t){if(!e.length)return new ri(t,1);if(e.children.length==1){let a=e.children[0];if(a.isText())return this.scanText(a,t);if(a.isComposite())return this.scanTile(a,t)}let i=[t];for(let a=0,l=t;a{let l=e.children[a];return l.flags&48?null:(l.dom.nodeType==1?l.dom:Mh(l.dom,0,l.length)).getClientRects()}),o=e.children[r.i],s=i[r.i];return o.isText()?this.scanText(o,s):o.isComposite()?this.scanTile(o,s):r.after?new ri(i[r.i+1],-1):new ri(s,1)}},Gl="\uFFFF",tb=class{constructor(e,t){this.points=e,this.view=t,this.text="",this.lineSeparator=t.state.facet(Ze.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=Gl}readRange(e,t){if(!e)return this;let i=e.parentNode;for(let r=e;;){this.findPointBefore(i,r);let o=this.text.length;this.readNode(r);let s=it.get(r),a=r.nextSibling;if(a==t){s!=null&&s.breakAfter&&!a&&i!=this.view.contentDOM&&this.lineBreak();break}let l=it.get(a);(s&&l?s.breakAfter:(s?s.breakAfter:jg(r))||jg(a)&&(r.nodeName!="BR"||s!=null&&s.isWidget())&&this.text.length>o)&&!Zq(a,t)&&this.lineBreak(),r=a}return this.findPointBefore(i,t),this}readTextNode(e){let t=e.nodeValue;for(let i of this.points)i.node==e&&(i.pos=this.text.length+Math.min(i.offset,t.length));for(let i=0,r=this.lineSeparator?null:/\r\n?|\n/g;;){let o=-1,s=1,a;if(this.lineSeparator?(o=t.indexOf(this.lineSeparator,i),s=this.lineSeparator.length):(a=r.exec(t))&&(o=a.index,s=a[0].length),this.append(t.slice(i,o<0?t.length:o)),o<0)break;if(this.lineBreak(),s>1)for(let l of this.points)l.node==e&&l.pos>this.text.length&&(l.pos-=s-1);i=o+s}}readNode(e){let t=it.get(e),i=t&&t.overrideDOMText;if(i!=null){this.findPointInside(e,i.length);for(let r=i.iter();!r.next().done;)r.lineBreak?this.lineBreak():this.append(r.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let i of this.points)i.node==e&&e.childNodes[i.offset]==t&&(i.pos=this.text.length)}findPointInside(e,t){for(let i of this.points)(e.nodeType==3?i.node==e:e.contains(i.node))&&(i.pos=this.text.length+(Yq(e,i.node,i.offset)?t:0))}};function Yq(n,e,t){for(;;){if(!e||t-1;let{impreciseHead:o,impreciseAnchor:s}=e.docView,a=e.state.selection;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=xA(e.docView.tile,t,i,0))){let l=o||s?[]:eV(e),c=new tb(l,e);c.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=c.text,this.newSel=tV(l,this.bounds.from)}else{let l=e.observer.selectionRange,c=o&&o.node==l.focusNode&&o.offset==l.focusOffset||!j0(e.contentDOM,l.focusNode)?a.main.head:e.docView.posFromDOM(l.focusNode,l.focusOffset),u=s&&s.node==l.anchorNode&&s.offset==l.anchorOffset||!j0(e.contentDOM,l.anchorNode)?a.main.anchor:e.docView.posFromDOM(l.anchorNode,l.anchorOffset),f=e.viewport;if((z.ios||z.chrome)&&a.main.empty&&c!=u&&(f.from>0||f.to-1&&a.ranges.length>1)this.newSel=a.replaceRange($.range(u,c));else if(e.lineWrapping&&u==c&&!(a.main.empty&&a.main.head==c)&&e.inputState.lastTouchTime>Date.now()-100){let h=e.coordsAtPos(c,-1),d=0;h&&(d=e.inputState.lastTouchY<=h.bottom?-1:1),this.newSel=$.create([$.cursor(c,d)])}else this.newSel=$.single(u,c)}}};function xA(n,e,t,i){if(n.isComposite()){let r=-1,o=-1,s=-1,a=-1;for(let l=0,c=i,u=i;lt)return xA(f,e,t,c);if(h>=e&&r==-1&&(r=l,o=c),c>t&&f.dom.parentNode==n.dom){s=l,a=u;break}u=h,c=h+f.breakAfter}return{from:o,to:a<0?i+n.length:a,startDOM:(r?n.children[r-1].dom.nextSibling:null)||n.dom.firstChild,endDOM:s=0?n.children[s].dom:null}}else return n.isText()?{from:i,to:i+n.length,startDOM:n.dom,endDOM:n.dom.nextSibling}:null}function bA(n,e){let t,{newSel:i}=e,{state:r}=n,o=r.selection.main,s=n.inputState.lastKeyTime>Date.now()-100?n.inputState.lastKeyCode:-1;if(e.bounds){let{from:a,to:l}=e.bounds,c=o.from,u=null;(s===8||z.android&&e.text.length=a&&o.to<=l&&(e.typeOver||f!=e.text)&&f.slice(0,o.from-a)==e.text.slice(0,o.from-a)&&f.slice(o.to-a)==e.text.slice(h=e.text.length-(f.length-(o.to-a)))?t={from:o.from,to:o.to,insert:be.of(e.text.slice(o.from-a,h).split(Gl))}:(d=_A(f,e.text,c-a,u))&&(z.chrome&&s==13&&d.toB==d.from+2&&e.text.slice(d.from,d.toB)==Gl+Gl&&d.toB--,t={from:a+d.from,to:a+d.toA,insert:be.of(e.text.slice(d.from,d.toB).split(Gl))})}else i&&(!n.hasFocus&&r.facet(Fr)||zg(i,o))&&(i=null);if(!t&&!i)return!1;if((z.mac||z.android)&&t&&t.from==t.to&&t.from==o.head-1&&/^\. ?$/.test(t.insert.toString())&&n.contentDOM.getAttribute("autocorrect")=="off"?(i&&t.insert.length==2&&(i=$.single(i.main.anchor-1,i.main.head-1)),t={from:t.from,to:t.to,insert:be.of([t.insert.toString().replace("."," ")])}):r.doc.lineAt(o.from).toDate.now()-50?t={from:o.from,to:o.to,insert:r.toText(n.inputState.insertingText)}:z.chrome&&t&&t.from==t.to&&t.from==o.head&&t.insert.toString()==` `&&n.lineWrapping&&(i&&(i=$.single(i.main.anchor-1,i.main.head-1)),t={from:o.from,to:o.to,insert:be.of([" "])}),t)return Tb(n,t,i,s);if(i&&!zg(i,o)){let a=!1,l="select";return n.inputState.lastSelectionTime>Date.now()-50&&(n.inputState.lastSelectionOrigin=="select"&&(a=!0),l=n.inputState.lastSelectionOrigin,l=="select.pointer"&&(i=vA(r.facet(Ph).map(c=>c(n)),i))),n.dispatch({selection:i,scrollIntoView:a,userEvent:l}),!0}else return!1}function Tb(n,e,t,i=-1){if(z.ios&&n.inputState.flushIOSKey(e))return!0;let r=n.state.selection.main;if(z.android&&(e.to==r.to&&(e.from==r.from||e.from==r.from-1&&n.state.sliceDoc(e.from,r.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&ec(n.contentDOM,"Enter",13)||(e.from==r.from-1&&e.to==r.to&&e.insert.length==0||i==8&&e.insert.lengthr.head)&&ec(n.contentDOM,"Backspace",8)||e.from==r.from&&e.to==r.to+1&&e.insert.length==0&&ec(n.contentDOM,"Delete",46)))return!0;let o=e.insert.toString();n.inputState.composing>=0&&n.inputState.composing++;let s,a=()=>s||(s=Jq(n,e,t));return n.state.facet(aA).some(l=>l(n,e.from,e.to,o,a))||n.dispatch(a()),!0}function Jq(n,e,t){let i,r=n.state,o=r.selection.main,s=-1;if(e.from==e.to&&e.fromo.to){let l=e.fromf(n)),c,l);e.from==u&&(s=u)}if(s>-1)i={changes:e,selection:$.cursor(e.from+e.insert.length,-1)};else if(e.from>=o.from&&e.to<=o.to&&e.to-e.from>=(o.to-o.from)/3&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&n.inputState.composing<0){let l=o.frome.to?r.sliceDoc(e.to,o.to):"";i=r.replaceSelection(n.state.toText(l+e.insert.sliceString(0,void 0,n.state.lineBreak)+c))}else{let l=r.changes(e),c=t&&t.main.to<=l.newLength?t.main:void 0;if(r.selection.ranges.length>1&&(n.inputState.composing>=0||n.inputState.compositionPendingChange)&&e.to<=o.to+10&&e.to>=o.to-10){let u=n.state.sliceDoc(e.from,e.to),f,h=t&&yA(n,t.main.head);if(h){let p=e.insert.length-(e.to-e.from);f={from:h.from,to:h.to-p}}else f=n.state.doc.lineAt(o.head);let d=o.to-e.to;i=r.changeByRange(p=>{if(p.from==o.from&&p.to==o.to)return{changes:l,range:c||p.map(l)};let m=p.to-d,g=m-u.length;if(n.state.sliceDoc(g,m)!=u||m>=f.from&&g<=f.to)return{range:p};let b=r.changes({from:g,to:m,insert:e.insert}),_=p.to-o.to;return{changes:b,range:c?$.range(Math.max(0,c.anchor+_),Math.max(0,c.head+_)):p.map(b)}})}else i={changes:l,selection:c&&r.selection.replaceRange(c)}}let a="input.type";return(n.composing||n.inputState.compositionPendingChange&&n.inputState.compositionEndedAt>Date.now()-50)&&(n.inputState.compositionPendingChange=!1,a+=".compose",n.inputState.compositionFirstChange&&(a+=".start",n.inputState.compositionFirstChange=!1)),r.update(i,{userEvent:a,scrollIntoView:!0})}function _A(n,e,t,i){let r=Math.min(n.length,e.length),o=0;for(;o0&&a>0&&n.charCodeAt(s-1)==e.charCodeAt(a-1);)s--,a--;if(i=="end"){let l=Math.max(0,o-Math.min(s,a));t-=s+l-o}if(s=s?o-t:0;o-=l,a=o+(a-s),s=o}else if(a=a?o-t:0;o-=l,s=o+(s-a),a=o}return{from:o,toA:s,toB:a}}function eV(n){let e=[];if(n.root.activeElement!=n.contentDOM)return e;let{anchorNode:t,anchorOffset:i,focusNode:r,focusOffset:o}=n.observer.selectionRange;return t&&(e.push(new Hg(t,i)),(r!=t||o!=i)&&e.push(new Hg(r,o))),e}function tV(n,e){if(n.length==0)return null;let t=n[0].pos,i=n.length==2?n[1].pos:t;return t>-1&&i>-1?$.single(t+e,i+e):null}function zg(n,e){return e.head==n.main.head&&e.anchor==n.main.anchor}var ib=class{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,z.safari&&e.contentDOM.addEventListener("input",()=>null),z.gecko&&mV(e.contentDOM.ownerDocument)}handleEvent(e){!lV(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,t){let i=this.handlers[e];if(i){for(let r of i.observers)r(this.view,t);for(let r of i.handlers){if(t.defaultPrevented)break;if(r(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=nV(e),i=this.handlers,r=this.view.contentDOM;for(let o in t)if(o!="scroll"){let s=!t[o].handlers.length,a=i[o];a&&s!=!a.handlers.length&&(r.removeEventListener(o,this.handleEvent),a=null),a||r.addEventListener(o,this.handleEvent,{passive:s})}for(let o in i)o!="scroll"&&!t[o]&&r.removeEventListener(o,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&CA.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),z.android&&z.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return z.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&!e.shiftKey&&((t=wA.find(i=>i.keyCode==e.keyCode))&&!e.ctrlKey||iV.indexOf(e.key)>-1&&e.ctrlKey)?(this.pendingIOSKey=t||e,setTimeout(()=>this.flushIOSKey(),250),!0):(e.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(e){let t=this.pendingIOSKey;return!t||t.key=="Enter"&&e&&e.from0?!0:z.safari&&!z.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}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 CT(n,e){return(t,i)=>{try{return e.call(n,i,t)}catch(r){It(t.state,r)}}}function nV(n){let e=Object.create(null);function t(i){return e[i]||(e[i]={observers:[],handlers:[]})}for(let i of n){let r=i.spec,o=r&&r.plugin.domEventHandlers,s=r&&r.plugin.domEventObservers;if(o)for(let a in o){let l=o[a];l&&t(a).handlers.push(CT(i.value,l))}if(s)for(let a in s){let l=s[a];l&&t(a).observers.push(CT(i.value,l))}}for(let i in wi)t(i).handlers.push(wi[i]);for(let i in _n)t(i).observers.push(_n[i]);return e}var wA=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],iV="dthko",CA=[16,17,18,20,91,92,224,225],kg=6;function Rg(n){return Math.max(0,n)*.7+8}function rV(n,e){return Math.max(Math.abs(n.clientX-e.clientX),Math.abs(n.clientY-e.clientY))}var rb=class{constructor(e,t,i,r){this.view=e,this.startEvent=t,this.style=i,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=QT(e.contentDOM),this.atoms=e.state.facet(Ph).map(s=>s(e));let o=e.contentDOM.ownerDocument;o.addEventListener("mousemove",this.move=this.move.bind(this)),o.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(Ze.allowMultipleSelections)&&oV(e,t),this.dragging=aV(e,t)&&OA(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&rV(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,i=0,r=0,o=0,s=this.view.win.innerWidth,a=this.view.win.innerHeight;this.scrollParents.x&&({left:r,right:s}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:o,bottom:a}=this.scrollParents.y.getBoundingClientRect());let l=Rb(this.view);e.clientX-l.left<=r+kg?t=-Rg(r-e.clientX):e.clientX+l.right>=s-kg&&(t=Rg(e.clientX-s)),e.clientY-l.top<=o+kg?i=-Rg(o-e.clientY):e.clientY+l.bottom>=a-kg&&(i=Rg(e.clientY-a)),this.setScrollSpeed(t,i)}up(e){this.dragging==null&&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),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:t}=this,i=vA(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!i.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(t=>t.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}};function oV(n,e){let t=n.state.facet(iA);return t.length?t[0](e):z.mac?e.metaKey:e.ctrlKey}function sV(n,e){let t=n.state.facet(rA);return t.length?t[0](e):z.mac?!e.altKey:!e.ctrlKey}function aV(n,e){let{main:t}=n.state.selection;if(t.empty)return!1;let i=Th(n.root);if(!i||i.rangeCount==0)return!0;let r=i.getRangeAt(0).getClientRects();for(let o=0;o=e.clientX&&s.top<=e.clientY&&s.bottom>=e.clientY)return!0}return!1}function lV(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,i;t!=n.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(i=it.get(t))&&i.isWidget()&&!i.isHidden&&i.widget.ignoreEvent(e))return!1;return!0}var wi=Object.create(null),_n=Object.create(null),EA=z.ie&&z.ie_version<15||z.ios&&z.webkit_version<604;function cV(n){let e=n.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{n.focus(),t.remove(),SA(n,t.value)},50)}function ty(n,e,t){for(let i of n.facet(e))t=i(t,n);return t}function SA(n,e){e=ty(n.state,Eb,e);let{state:t}=n,i,r=1,o=t.toText(e),s=o.lines==t.selection.ranges.length;if(ob!=null&&t.selection.ranges.every(l=>l.empty)&&ob==o.toString()){let l=-1;i=t.changeByRange(c=>{let u=t.doc.lineAt(c.from);if(u.from==l)return{range:c};l=u.from;let f=t.toText((s?o.line(r++).text:e)+t.lineBreak);return{changes:{from:u.from,insert:f},range:$.cursor(c.from+f.length)}})}else s?i=t.changeByRange(l=>{let c=o.line(r++);return{changes:{from:l.from,to:l.to,insert:c.text},range:$.cursor(l.from+c.length)}}):i=t.replaceSelection(o);n.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}_n.scroll=n=>{n.inputState.lastScrollTop=n.scrollDOM.scrollTop,n.inputState.lastScrollLeft=n.scrollDOM.scrollLeft};_n.wheel=_n.mousewheel=n=>{n.inputState.lastWheelEvent=Date.now()};wi.keydown=(n,e)=>(n.inputState.setSelectionOrigin("select"),e.keyCode==27&&n.inputState.tabFocusMode!=0&&(n.inputState.tabFocusMode=Date.now()+2e3),!1);_n.touchstart=(n,e)=>{let t=n.inputState,i=e.targetTouches[0];t.lastTouchTime=Date.now(),i&&(t.lastTouchX=i.clientX,t.lastTouchY=i.clientY),t.setSelectionOrigin("select.pointer")};_n.touchmove=n=>{n.inputState.setSelectionOrigin("select.pointer")};wi.mousedown=(n,e)=>{if(n.observer.flush(),n.inputState.lastTouchTime>Date.now()-2e3)return!1;let t=null;for(let i of n.state.facet(oA))if(t=i(n,e),t)break;if(!t&&e.button==0&&(t=fV(n,e)),t){let i=!n.hasFocus;n.inputState.startMouseSelection(new rb(n,e,t,i)),i&&n.observer.ignore(()=>{KT(n.contentDOM);let o=n.root.activeElement;o&&!o.contains(n.contentDOM)&&o.blur()});let r=n.inputState.mouseSelection;if(r)return r.start(e),r.dragging===!1}else n.inputState.setSelectionOrigin("select.pointer");return!1};function ET(n,e,t,i){if(i==1)return $.cursor(e,t);if(i==2)return Wq(n.state,e,t);{let r=n.docView.lineAt(e,t),o=n.state.doc.lineAt(r?r.posAtEnd:e),s=r?r.posAtStart:o.from,a=r?r.posAtEnd:o.to;return aDate.now()-400&&Math.abs(e.clientX-n.clientX)<2&&Math.abs(e.clientY-n.clientY)<2?(OT+1)%3:1}function fV(n,e){let t=n.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),i=OA(e),r=n.state.selection;return{update(o){o.docChanged&&(t.pos=o.changes.mapPos(t.pos),r=r.map(o.changes))},get(o,s,a){let l=n.posAndSideAtCoords({x:o.clientX,y:o.clientY},!1),c,u=ET(n,l.pos,l.assoc,i);if(t.pos!=l.pos&&!s){let f=ET(n,t.pos,t.assoc,i),h=Math.min(f.from,u.from),d=Math.max(f.to,u.to);u=h1&&(c=hV(r,l.pos))?c:a?r.addRange(u):$.create([u])}}}function hV(n,e){for(let t=0;t=e)return $.create(n.ranges.slice(0,t).concat(n.ranges.slice(t+1)),n.mainIndex==t?0:n.mainIndex-(n.mainIndex>t?1:0))}return null}wi.dragstart=(n,e)=>{let{selection:{main:t}}=n.state;if(e.target.draggable){let r=n.docView.tile.nearest(e.target);if(r&&r.isWidget()){let o=r.posAtStart,s=o+r.length;(o>=t.to||s<=t.from)&&(t=$.range(o,s))}}let{inputState:i}=n;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",ty(n.state,Sb,n.state.sliceDoc(t.from,t.to))),e.dataTransfer.effectAllowed="copyMove"),!1};wi.dragend=n=>(n.inputState.draggedContent=null,!1);function RT(n,e,t,i){if(t=ty(n.state,Eb,t),!t)return;let r=n.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:o}=n.inputState,s=i&&o&&sV(n,e)?{from:o.from,to:o.to}:null,a={from:r,insert:t},l=n.state.changes(s?[s,a]:a);n.focus(),n.dispatch({changes:l,selection:{anchor:l.mapPos(r,-1),head:l.mapPos(r,1)},userEvent:s?"move.drop":"input.drop"}),n.inputState.draggedContent=null}wi.drop=(n,e)=>{if(!e.dataTransfer)return!1;if(n.state.readOnly)return!0;let t=e.dataTransfer.files;if(t&&t.length){let i=Array(t.length),r=0,o=()=>{++r==t.length&&RT(n,e,i.filter(s=>s!=null).join(n.state.lineBreak),!1)};for(let s=0;s{/[\x00-\x08\x0e-\x1f]{2}/.test(a.result)||(i[s]=a.result),o()},a.readAsText(t[s])}return!0}else{let i=e.dataTransfer.getData("Text");if(i)return RT(n,e,i,!0),!0}return!1};wi.paste=(n,e)=>{if(n.state.readOnly)return!0;n.observer.flush();let t=EA?null:e.clipboardData;return t?(SA(n,t.getData("text/plain")||t.getData("text/uri-list")),!0):(cV(n),!1)};function dV(n,e){let t=n.dom.parentNode;if(!t)return;let i=t.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=e,i.focus(),i.selectionEnd=e.length,i.selectionStart=0,setTimeout(()=>{i.remove(),n.focus()},50)}function pV(n){let e=[],t=[],i=!1;for(let r of n.selection.ranges)r.empty||(e.push(n.sliceDoc(r.from,r.to)),t.push(r));if(!e.length){let r=-1;for(let{from:o}of n.selection.ranges){let s=n.doc.lineAt(o);s.number>r&&(e.push(s.text),t.push({from:s.from,to:Math.min(n.doc.length,s.to+1)})),r=s.number}i=!0}return{text:ty(n,Sb,e.join(n.lineBreak)),ranges:t,linewise:i}}var ob=null;wi.copy=wi.cut=(n,e)=>{if(!xh(n.contentDOM,n.observer.selectionRange))return!1;let{text:t,ranges:i,linewise:r}=pV(n.state);if(!t&&!r)return!1;ob=r?t:null,e.type=="cut"&&!n.state.readOnly&&n.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let o=EA?null:e.clipboardData;return o?(o.clearData(),o.setData("text/plain",t),!0):(dV(n,t),!1)};var kA=Mn.define();function RA(n,e){let t=[];for(let i of n.facet(lA)){let r=i(n,e);r&&t.push(r)}return t.length?n.update({effects:t,annotations:kA.of(!0)}):null}function TA(n){setTimeout(()=>{let e=n.hasFocus;if(e!=n.inputState.notifiedFocused){let t=RA(n.state,e);t?n.dispatch(t):n.update([])}},10)}_n.focus=n=>{n.inputState.lastFocusTime=Date.now(),!n.scrollDOM.scrollTop&&(n.inputState.lastScrollTop||n.inputState.lastScrollLeft)&&(n.scrollDOM.scrollTop=n.inputState.lastScrollTop,n.scrollDOM.scrollLeft=n.inputState.lastScrollLeft),TA(n)};_n.blur=n=>{n.observer.clearSelectionRange(),TA(n)};_n.compositionstart=_n.compositionupdate=n=>{n.observer.editContext||(n.inputState.compositionFirstChange==null&&(n.inputState.compositionFirstChange=!0),n.inputState.composing<0&&(n.inputState.composing=0))};_n.compositionend=n=>{n.observer.editContext||(n.inputState.composing=-1,n.inputState.compositionEndedAt=Date.now(),n.inputState.compositionPendingKey=!0,n.inputState.compositionPendingChange=n.observer.pendingRecords().length>0,n.inputState.compositionFirstChange=null,z.chrome&&z.android?n.observer.flushSoon():n.inputState.compositionPendingChange?Promise.resolve().then(()=>n.observer.flush()):setTimeout(()=>{n.inputState.composing<0&&n.docView.hasComposition&&n.update([])},50))};_n.contextmenu=n=>{n.inputState.lastContextMenu=Date.now()};wi.beforeinput=(n,e)=>{var t,i;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(n.inputState.insertingText=e.data,n.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&n.observer.editContext){let o=(t=e.dataTransfer)===null||t===void 0?void 0:t.getData("text/plain"),s=e.getTargetRanges();if(o&&s.length){let a=s[0],l=n.posAtDOM(a.startContainer,a.startOffset),c=n.posAtDOM(a.endContainer,a.endOffset);return Tb(n,{from:l,to:c,insert:n.state.toText(o)},null),!0}}let r;if(z.chrome&&z.android&&(r=wA.find(o=>o.inputType==e.inputType))&&(n.observer.delayAndroidKey(r.key,r.keyCode),r.key=="Backspace"||r.key=="Delete")){let o=((i=window.visualViewport)===null||i===void 0?void 0:i.height)||0;setTimeout(()=>{var s;(((s=window.visualViewport)===null||s===void 0?void 0:s.height)||0)>o+10&&n.hasFocus&&(n.contentDOM.blur(),n.focus())},100)}return z.ios&&e.inputType=="deleteContentForward"&&n.observer.flushSoon(),z.safari&&e.inputType=="insertText"&&n.inputState.composing>=0&&setTimeout(()=>_n.compositionend(n,e),20),!1};var TT=new Set;function mV(n){TT.has(n)||(TT.add(n),n.addEventListener("copy",()=>{}),n.addEventListener("cut",()=>{}))}var AT=["pre-wrap","normal","pre-line","break-spaces"],oc=!1;function MT(){oc=!1}var sb=class{constructor(e){this.lineWrapping=e,this.doc=be.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let i=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((t-e-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return AT.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let i=0;i-1,l=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=a;if(this.lineWrapping=a,this.lineHeight=t,this.charWidth=i,this.textHeight=r,this.lineLength=o,l){this.heightSamples={};for(let c=0;c0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>Lg&&(oc=!0),this.height=e)}replace(e,t,i){return n.of(i)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,i,r){let o=this,s=i.doc;for(let a=r.length-1;a>=0;a--){let{fromA:l,toA:c,fromB:u,toB:f}=r[a],h=o.lineAt(l,ze.ByPosNoHeight,i.setDoc(t),0,0),d=h.to>=c?h:o.lineAt(c,ze.ByPosNoHeight,i,0,0);for(f+=d.to-c,c=d.to;a>0&&h.from<=r[a-1].toA;)l=r[a-1].fromA,u=r[a-1].fromB,a--,lo*2){let a=e[t-1];a.break?e.splice(--t,1,a.left,null,a.right):e.splice(--t,1,a.left,a.right),i+=1+a.break,r-=a.size}else if(o>r*2){let a=e[i];a.break?e.splice(i,1,a.left,null,a.right):e.splice(i,1,a.left,a.right),i+=2+a.break,o-=a.size}else break;else if(r=o&&s(this.lineAt(0,ze.ByPos,i,r,o))}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,i=!1,r){return r&&r.from<=t&&r.more&&this.setMeasuredHeight(r),this.outdated=!1,this}toString(){return`block(${this.length})`}},ii=class n extends Ug{constructor(e,t,i){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=i}mainBlock(e,t){return new bi(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,t,i){let r=i[0];return i.length==1&&(r instanceof n||r instanceof Bo&&r.flags&4)&&Math.abs(this.length-r.length)<10?(r instanceof Bo?r=new n(r.length,this.height,this.spaceAbove):r.height=this.height,this.outdated||(r.outdated=!1),r):Dn.of(i)}updateHeight(e,t=0,i=!1,r){return r&&r.from<=t&&r.more?this.setMeasuredHeight(r):(i||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:""})`}},Bo=class n extends Dn{constructor(e){super(e,0)}heightMetrics(e,t){let i=e.doc.lineAt(t).number,r=e.doc.lineAt(t+this.length).number,o=r-i+1,s,a=0;if(e.lineWrapping){let l=Math.min(this.height,e.lineHeight*o);s=l/o,this.length>o+1&&(a=(this.height-l)/(this.length-o-1))}else s=this.height/o;return{firstLine:i,lastLine:r,perLine:s,perChar:a}}blockAt(e,t,i,r){let{firstLine:o,lastLine:s,perLine:a,perChar:l}=this.heightMetrics(t,r);if(t.lineWrapping){let c=r+(e0){let o=i[i.length-1];o instanceof n?i[i.length-1]=new n(o.length+r):i.push(null,new n(r-1))}if(e>0){let o=i[0];o instanceof n?i[0]=new n(e+o.length):i.unshift(new n(e-1),null)}return Dn.of(i)}decomposeLeft(e,t){t.push(new n(e-1),null)}decomposeRight(e,t){t.push(null,new n(this.length-e-1))}updateHeight(e,t=0,i=!1,r){let o=t+this.length;if(r&&r.from<=t+this.length&&r.more){let s=[],a=Math.max(t,r.from),l=-1;for(r.from>t&&s.push(new n(r.from-t-1).updateHeight(e,t));a<=o&&r.more;){let u=e.doc.lineAt(a).length;s.length&&s.push(null);let f=r.heights[r.index++],h=0;f<0&&(h=-f,f=r.heights[r.index++]),l==-1?l=f:Math.abs(f-l)>=Lg&&(l=-2);let d=new ii(u,f,h);d.outdated=!1,s.push(d),a+=u+1}a<=o&&s.push(null,new n(o-a).updateHeight(e,a));let c=Dn.of(s);return(l<0||Math.abs(c.height-this.height)>=Lg||Math.abs(l-this.heightMetrics(e,t).perLine)>=Lg)&&(oc=!0),Wg(this,c)}else(i||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}},lb=class extends Dn{constructor(e,t,i){super(e.length+t+i.length,e.height+i.height,t|(e.outdated||i.outdated?2:0)),this.left=e,this.right=i,this.size=e.size+i.size}get break(){return this.flags&1}blockAt(e,t,i,r){let o=i+this.left.height;return ea))return c;let u=t==ze.ByPosNoHeight?ze.ByPosNoHeight:ze.ByPos;return l?c.join(this.right.lineAt(a,u,i,s,a)):this.left.lineAt(a,u,i,r,o).join(c)}forEachLine(e,t,i,r,o,s){let a=r+this.left.height,l=o+this.left.length+this.break;if(this.break)e=l&&this.right.forEachLine(e,t,i,a,l,s);else{let c=this.lineAt(l,ze.ByPos,i,r,o);e=e&&c.from<=t&&s(c),t>c.to&&this.right.forEachLine(c.to+1,t,i,a,l,s)}}replace(e,t,i){let r=this.left.length+this.break;if(tthis.left.length)return this.balanced(this.left,this.right.replace(e-r,t-r,i));let o=[];e>0&&this.decomposeLeft(e,o);let s=o.length;for(let a of i)o.push(a);if(e>0&&PT(o,s-1),t=i&&t.push(null)),e>i&&this.right.decomposeLeft(e-i,t)}decomposeRight(e,t){let i=this.left.length,r=i+this.break;if(e>=r)return this.right.decomposeRight(e-r,t);e2*t.size||t.size>2*e.size?Dn.of(this.break?[e,null,t]:[e,t]):(this.left=Wg(this.left,e),this.right=Wg(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,i=!1,r){let{left:o,right:s}=this,a=t+o.length+this.break,l=null;return r&&r.from<=t+o.length&&r.more?l=o=o.updateHeight(e,t,i,r):o.updateHeight(e,t,i),r&&r.from<=a+s.length&&r.more?l=s=s.updateHeight(e,a,i,r):s.updateHeight(e,a,i),l?this.balanced(o,s):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}};function PT(n,e){let t,i;n[e]==null&&(t=n[e-1])instanceof Bo&&(i=n[e+1])instanceof Bo&&n.splice(e-1,3,new Bo(t.length+1+i.length))}var yV=5,cb=class n{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 i=Math.min(t,this.lineEnd),r=this.nodes[this.nodes.length-1];r instanceof ii?r.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new ii(i-this.pos,-1,0)),this.writtenTo=i,t>i&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,i){if(e=yV)&&this.addLineDeco(r,o,s)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenToe&&this.nodes.push(new ii(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let i=new Bo(t-e);return this.oracle.doc.lineAt(e).to==t&&(i.flags|=4),i}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof ii)return e;let t=new ii(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,i){let r=this.ensureLine();r.length+=i,r.collapsed+=i,r.widgetHeight=Math.max(r.widgetHeight,e),r.breaks+=t,this.writtenTo=this.pos=this.pos+i}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof ii)&&!this.isCovered?this.nodes.push(new ii(0,-1,0)):(this.writtenTou.clientHeight||u.scrollWidth>u.clientWidth)&&f.overflow!="visible"){let h=u.getBoundingClientRect();o=Math.max(o,h.left),s=Math.min(s,h.right),a=Math.max(a,h.top),l=Math.min(c==n.parentNode?r.innerHeight:l,h.bottom)}c=f.position=="absolute"||f.position=="fixed"?u.offsetParent:u.parentNode}else if(c.nodeType==11)c=c.host;else break;return{left:o-t.left,right:Math.max(o,s)-t.left,top:a-(t.top+e),bottom:Math.max(a,l)-(t.top+e)}}function bV(n){let e=n.getBoundingClientRect(),t=n.ownerDocument.defaultView||window;return e.left0&&e.top0}function _V(n,e){let t=n.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}var Oh=class{constructor(e,t,i,r){this.from=e,this.to=t,this.size=i,this.displaySize=r}static same(e,t){if(e.length!=t.length)return!1;for(let i=0;itypeof r!="function"&&r.class=="cm-lineWrapping");this.heightOracle=new sb(i),this.stateDeco=IT(t),this.heightMap=Dn.empty().applyChanges(this.stateDeco,be.empty,this.heightOracle.setDoc(t.doc),[new _i(0,0,0,t.doc.length)]);for(let r=0;r<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());r++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=he.set(this.lineGaps.map(r=>r.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let i=0;i<=1;i++){let r=i?t.head:t.anchor;if(!e.some(({from:o,to:s})=>r>=o&&r<=s)){let{from:o,to:s}=this.lineBlockAt(r);e.push(new Yl(o,s))}}return this.viewports=e.sort((i,r)=>i.from-r.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?DT:new hb(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(vh(e,this.scaler))})}update(e,t=null){this.state=e.state;let i=this.stateDeco;this.stateDeco=IT(this.state);let r=e.changedRanges,o=_i.extendWithRanges(r,vV(i,this.stateDeco,e?e.changes:cn.empty(this.state.doc.length))),s=this.heightMap.height,a=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);MT(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),o),(this.heightMap.height!=s||oc)&&(e.flags|=2),a?(this.scrollAnchorPos=e.changes.mapPos(a.from,-1),this.scrollAnchorHeight=a.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=s);let l=o.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.headl.to)||!this.viewportIsAppropriate(l))&&(l=this.getViewport(0,t));let c=l.from!=this.viewport.from||l.to!=this.viewport.to;this.viewport=l,e.flags|=this.updateForViewport(),(c||!e.changes.empty||e.flags&2)&&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(Tq)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,t=e.contentDOM,i=window.getComputedStyle(t),r=this.heightOracle,o=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?We.RTL:We.LTR;let s=this.heightOracle.mustRefreshForWrapping(o)||this.mustMeasureContent==="refresh",a=t.getBoundingClientRect(),l=s||this.mustMeasureContent||this.contentDOMHeight!=a.height;this.contentDOMHeight=a.height,this.mustMeasureContent=!1;let c=0,u=0;if(a.width&&a.height){let{scaleX:C,scaleY:E}=UT(t,a);(C>.005&&Math.abs(this.scaleX-C)>.005||E>.005&&Math.abs(this.scaleY-E)>.005)&&(this.scaleX=C,this.scaleY=E,c|=16,s=l=!0)}let f=(parseInt(i.paddingTop)||0)*this.scaleY,h=(parseInt(i.paddingBottom)||0)*this.scaleY;(this.paddingTop!=f||this.paddingBottom!=h)&&(this.paddingTop=f,this.paddingBottom=h,c|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(l=!0),this.editorWidth=e.scrollDOM.clientWidth,c|=16);let d=QT(this.view.contentDOM,!1).y;d!=this.scrollParent&&(this.scrollParent=d,this.scrollAnchorHeight=-1,this.scrollOffset=0);let p=this.getScrollOffset();this.scrollOffset!=p&&(this.scrollAnchorHeight=-1,this.scrollOffset=p),this.scrolledToBottom=GT(this.scrollParent||e.win);let m=(this.printing?_V:xV)(t,this.paddingTop),g=m.top-this.pixelViewport.top,b=m.bottom-this.pixelViewport.bottom;this.pixelViewport=m;let _=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(_!=this.inView&&(this.inView=_,_&&(l=!0)),!this.inView&&!this.scrollTarget&&!bV(e.dom))return 0;let v=a.width;if((this.contentDOMWidth!=v||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=a.width,this.editorHeight=e.scrollDOM.clientHeight,c|=16),l){let C=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(C)&&(s=!0),s||r.lineWrapping&&Math.abs(v-this.contentDOMWidth)>r.charWidth){let{lineHeight:E,charWidth:S,textHeight:w}=e.docView.measureTextSize();s=E>0&&r.refresh(o,E,S,w,Math.max(5,v/S),C),s&&(e.docView.minWidth=0,c|=16)}g>0&&b>0?u=Math.max(g,b):g<0&&b<0&&(u=Math.min(g,b)),MT();for(let E of this.viewports){let S=E.from==this.viewport.from?C:e.docView.measureVisibleLineHeights(E);this.heightMap=(s?Dn.empty().applyChanges(this.stateDeco,be.empty,this.heightOracle,[new _i(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,s,new ab(E.from,S))}oc&&(c|=2)}let x=!this.viewportIsAppropriate(this.viewport,u)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return x&&(c&2&&(c|=this.updateScaler()),this.viewport=this.getViewport(u,this.scrollTarget),c|=this.updateForViewport()),(c&2||x)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(s?[]:this.lineGaps,e)),c|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),c}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let i=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),r=this.heightMap,o=this.heightOracle,{visibleTop:s,visibleBottom:a}=this,l=new Yl(r.lineAt(s-i*1e3,ze.ByHeight,o,0,0).from,r.lineAt(a+(1-i)*1e3,ze.ByHeight,o,0,0).to);if(t){let{head:c}=t.range;if(cl.to){let u=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),f=r.lineAt(c,ze.ByPos,o,0,0),h;t.y=="center"?h=(f.top+f.bottom)/2-u/2:t.y=="start"||t.y=="nearest"&&c=a+Math.max(10,Math.min(i,250)))&&r>s-2*1e3&&o>1,s=r<<1;if(this.defaultTextDirection!=We.LTR&&!i)return[];let a=[],l=(u,f,h,d)=>{if(f-uu&&bb.from>=h.from&&b.to<=h.to&&Math.abs(b.from-u)b.from<_&&b.to>_));if(!g){if(fv.from<=f&&v.to>=f)){let v=t.moveToLineBoundary($.cursor(f),!1,!0).head;v>u&&(f=v)}let b=this.gapSize(h,u,f,d),_=i||b<2e6?b:2e6;g=new Oh(u,f,b,_)}a.push(g)},c=u=>{if(u.length2e6)for(let E of e)E.from>=u.from&&E.fromu.from&&l(u.from,d,u,f),pt.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let i=[];Be.spans(t,this.viewport.from,this.viewport.to,{span(o,s){i.push({from:o,to:s})},point(){}},20);let r=0;if(i.length!=this.visibleRanges.length)r=12;else for(let o=0;o=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||vh(this.heightMap.lineAt(e,ze.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)||vh(this.heightMap.lineAt(this.scaler.fromDOM(e),ze.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 vh(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}},Yl=class{constructor(e,t){this.from=e,this.to=t}};function wV(n,e,t){let i=[],r=n,o=0;return Be.spans(t,n,e,{span(){},point(s,a){s>r&&(i.push({from:r,to:s}),o+=s-r),r=a}},20),r=1)return e[e.length-1].to;let i=Math.floor(n*t);for(let r=0;;r++){let{from:o,to:s}=e[r],a=s-o;if(i<=a)return o+i;i-=a}}function Ag(n,e){let t=0;for(let{from:i,to:r}of n.ranges){if(e<=r){t+=e-i;break}t+=r-i}return t/n.total}function CV(n,e){for(let t of n)if(e(t))return t}var DT={toDOM(n){return n},fromDOM(n){return n},scale:1,eq(n){return n==this}};function IT(n){let e=n.facet(ey).filter(i=>typeof i!="function"),t=n.facet(kb).filter(i=>typeof i!="function");return t.length&&e.push(Be.join(t)),e}var hb=class n{constructor(e,t,i){let r=0,o=0,s=0;this.viewports=i.map(({from:a,to:l})=>{let c=t.lineAt(a,ze.ByPos,e,0,0).top,u=t.lineAt(l,ze.ByPos,e,0,0).bottom;return r+=u-c,{from:a,to:l,top:c,bottom:u,domTop:0,domBottom:0}}),this.scale=(7e6-r)/(t.height-r);for(let a of this.viewports)a.domTop=s+(a.top-o)*this.scale,s=a.domBottom=a.domTop+(a.bottom-a.top),o=a.bottom}toDOM(e){for(let t=0,i=0,r=0;;t++){let o=tt.from==e.viewports[i].from&&t.to==e.viewports[i].to):!1}};function vh(n,e){if(e.scale==1)return n;let t=e.toDOM(n.top),i=e.toDOM(n.bottom);return new bi(n.from,n.length,t,i-t,Array.isArray(n._content)?n._content.map(r=>vh(r,e)):n._content)}var Mg=H.define({combine:n=>n.join(" ")}),db=H.define({combine:n=>n.indexOf(!0)>-1}),pb=ni.newName(),AA=ni.newName(),MA=ni.newName(),PA={"&light":"."+AA,"&dark":"."+MA};function mb(n,e,t){return new ni(e,{finish(i){return/&/.test(i)?i.replace(/&\w*/,r=>{if(r=="&")return n;if(!t||!t[r])throw new RangeError(`Unsupported selector: ${r}`);return t[r]}):n+" "+i}})}var EV=mb("."+pb,{"&":{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,')`,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"}},PA),SV={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},I0=z.ie&&z.ie_version<=11,gb=class{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new F0,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 i of t)this.queue.push(i);(z.ie&&z.ie_version<=11||z.ios&&e.composing)&&t.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&z.android&&e.constructor.EDIT_CONTEXT!==!1&&!(z.chrome&&z.chrome_version<126)&&(this.editContext=new yb(e),e.state.facet(Fr)&&(e.contentDOM.editContext=this.editContext.editContext)),I0&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.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")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.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(t=>{t.length>0&&t[t.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){(e.type=="change"||!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,i)=>t!=e[i]))){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:i}=this,r=this.selectionRange;if(i.state.facet(Fr)?i.root.activeElement!=this.dom:!xh(this.dom,r))return;let o=r.anchorNode&&i.docView.tile.nearest(r.anchorNode);if(o&&o.isWidget()&&o.widget.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(z.ie&&z.ie_version<=11||z.android&&z.chrome)&&!i.state.selection.main.empty&&r.focusNode&&_h(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=Th(e.root);if(!t)return!1;let i=z.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&OV(this.view,t)||t;if(!i||this.selectionRange.eq(i))return!1;let r=xh(this.dom,i);return r&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let o=this.delayedAndroidKey;o&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=o.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&o.force&&ec(this.dom,o.key,o.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(r)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange{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,i=-1,r=!1;for(let o of e){let s=this.readMutation(o);s&&(s.typeOver&&(r=!0),t==-1?{from:t,to:i}=s:(t=Math.min(s.from,t),i=Math.max(s.to,i)))}return{from:t,to:i,typeOver:r}}readChange(){let{from:e,to:t,typeOver:i}=this.processRecords(),r=this.selectionChanged&&xh(this.dom,this.selectionRange);if(e<0&&!r)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let o=new nb(this.view,e,t,i);return this.view.docView.domChanged={newSel:o.newSel?o.newSel.main:null},o}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 i=this.view.state,r=bA(this.view,t);return this.view.state==i&&(t.domChanged||t.newSel&&!zg(this.view.state.selection,t.newSel.main))&&this.view.update([]),r}readMutation(e){let t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty(e.type=="attributes"),e.type=="childList"){let i=LT(t,e.previousSibling||e.target.previousSibling,-1),r=LT(t,e.nextSibling||e.target.nextSibling,1);return{from:i?t.posAfter(i):t.posAtStart,to:r?t.posBefore(r):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{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(Fr)!=e.state.facet(Fr)&&(e.view.contentDOM.editContext=e.state.facet(Fr)?this.editContext.editContext:null))}destroy(){var e,t,i;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(i=this.resizeScroll)===null||i===void 0||i.disconnect();for(let r of this.scrollTargets)r.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 LT(n,e,t){for(;e;){let i=it.get(e);if(i&&i.parent==n)return i;let r=e.parentNode;e=r!=n.dom?r:t>0?e.nextSibling:e.previousSibling}return null}function BT(n,e){let t=e.startContainer,i=e.startOffset,r=e.endContainer,o=e.endOffset,s=n.docView.domAtPos(n.state.selection.main.anchor,1);return _h(s.node,s.offset,r,o)&&([t,i,r,o]=[r,o,t,i]),{anchorNode:t,anchorOffset:i,focusNode:r,focusOffset:o}}function OV(n,e){if(e.getComposedRanges){let r=e.getComposedRanges(n.root)[0];if(r)return BT(n,r)}let t=null;function i(r){r.preventDefault(),r.stopImmediatePropagation(),t=r.getTargetRanges()[0]}return n.contentDOM.addEventListener("beforeinput",i,!0),n.dom.ownerDocument.execCommand("indent"),n.contentDOM.removeEventListener("beforeinput",i,!0),t?BT(n,t):null}var yb=class{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=i=>{let r=e.state.selection.main,{anchor:o,head:s}=r,a=this.toEditorPos(i.updateRangeStart),l=this.toEditorPos(i.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:i.updateRangeStart,editorBase:a,drifted:!1});let c=l-a>i.text.length;a==this.from&&othis.to&&(l=o);let u=_A(e.state.sliceDoc(a,l),i.text,(c?r.from:r.to)-a,c?"end":null);if(!u){let h=$.single(this.toEditorPos(i.selectionStart),this.toEditorPos(i.selectionEnd));zg(h,r)||e.dispatch({selection:h,userEvent:"select"});return}let f={from:u.from+a,to:u.toA+a,insert:be.of(i.text.slice(u.from,u.toB).split(` `))};if((z.mac||z.android)&&f.from==s-1&&/^\. ?$/.test(i.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(f={from:a,to:l,insert:be.of([i.text.replace("."," ")])}),this.pendingContextChange=f,!e.state.readOnly){let h=this.to-this.from+(f.to-f.from+f.insert.length);Tb(e,f,$.single(this.toEditorPos(i.selectionStart,h),this.toEditorPos(i.selectionEnd,h)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),f.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,i.updateRangeStart-1),Math.min(t.text.length,i.updateRangeStart+1)))&&this.handlers.compositionend(i)},this.handlers.characterboundsupdate=i=>{let r=[],o=null;for(let s=this.toEditorPos(i.rangeStart),a=this.toEditorPos(i.rangeEnd);s{let r=[];for(let o of i.getTextFormats()){let s=o.underlineStyle,a=o.underlineThickness;if(!/none/i.test(s)&&!/none/i.test(a)){let l=this.toEditorPos(o.rangeStart),c=this.toEditorPos(o.rangeEnd);if(l{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:i}=this.composing;this.composing=null,i&&this.reset(e.state)}};for(let i in this.handlers)t.addEventListener(i,this.handlers[i]);this.measureReq={read:i=>{this.editContext.updateControlBounds(i.contentDOM.getBoundingClientRect());let r=Th(i.root);r&&r.rangeCount&&this.editContext.updateSelectionBounds(r.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,i=!1,r=this.pendingContextChange;return e.changes.iterChanges((o,s,a,l,c)=>{if(i)return;let u=c.length-(s-o);if(r&&s>=r.to)if(r.from==o&&r.to==s&&r.insert.eq(c)){r=this.pendingContextChange=null,t+=u,this.to+=u;return}else r=null,this.revertPending(e.state);if(o+=t,s+=t,s<=this.from)this.from+=u,this.to+=u;else if(othis.to||this.to-this.from+c.length>3e4){i=!0;return}this.editContext.updateText(this.toContextPos(o),this.toContextPos(s),c.toString()),this.to+=u}t+=u}),r&&!i&&this.revertPending(e.state),!i}update(e){let t=this.pendingContextChange,i=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(i.from,i.to)&&e.transactions.some(r=>!r.isUserEvent("input.type")&&r.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)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(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,i=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),r=this.toContextPos(t.head);(this.editContext.selectionStart!=i||this.editContext.selectionEnd!=r)&&this.editContext.updateSelection(i,r)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to1e4*3)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let i=this.composing;return i&&i.drifted?i.editorBase+(e-i.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])}},U=class n{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:i}=e;this.dispatchTransactions=e.dispatchTransactions||i&&(r=>r.forEach(o=>i(o,this)))||(r=>this.update(r)),this.dispatch=this.dispatch.bind(this),this._root=e.root||vq(e.parent)||document,this.viewState=new Qg(this,e.state||Ze.create(e)),e.scrollTo&&e.scrollTo.is(Og)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Xl).map(r=>new Ch(r));for(let r of this.plugins)r.update(this);this.observer=new gb(this),this.inputState=new ib(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Vg(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((t=document.fonts)===null||t===void 0)&&t.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let t=e.length==1&&e[0]instanceof Ft?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,i=!1,r,o=this.state;for(let h of e){if(h.startState!=o)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");o=h.state}if(this.destroyed){this.viewState.state=o;return}let s=this.hasFocus,a=0,l=null;e.some(h=>h.annotation(kA))?(this.inputState.notifiedFocused=s,a=1):s!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=s,l=RA(o,s),l||(a=1));let c=this.observer.delayedAndroidKey,u=null;if(c?(this.observer.clearDelayedAndroidKey(),u=this.observer.readChange(),(u&&!this.state.doc.eq(o.doc)||!this.state.selection.eq(o.selection))&&(u=null)):this.observer.clear(),o.facet(Ze.phrases)!=this.state.facet(Ze.phrases))return this.setState(o);r=Fg.create(this,o,e),r.flags|=a;let f=this.viewState.scrollTarget;try{this.updateState=2;for(let h of e){if(f&&(f=f.map(h.changes)),h.scrollIntoView){let{main:d}=h.state.selection,{x:p,y:m}=this.state.facet(n.cursorScrollMargin);f=new wh(d.empty?d:$.cursor(d.head,d.head>d.anchor?-1:1),"nearest","nearest",m,p)}for(let d of h.effects)d.is(Og)&&(f=d.value.clip(this.state))}this.viewState.update(r,f),this.bidiCache=Kg.update(this.bidiCache,r.changes),r.empty||(this.updatePlugins(r),this.inputState.update(r)),t=this.docView.update(r),this.state.facet(yh)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(h=>h.isUserEvent("select.pointer")))}finally{this.updateState=0}if(r.startState.facet(Mg)!=r.state.facet(Mg)&&(this.viewState.mustMeasureContent=!0),(t||i||f||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!r.empty)for(let h of this.state.facet(z0))try{h(r)}catch(d){It(this.state,d,"update listener")}(l||u)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),u&&!bA(this,u)&&c.force&&ec(this.contentDOM,c.key,c.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let i of this.plugins)i.destroy(this);this.viewState=new Qg(this,e),this.plugins=e.facet(Xl).map(i=>new Ch(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new Vg(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(Xl),i=e.state.facet(Xl);if(t!=i){let r=[];for(let o of i){let s=t.indexOf(o);if(s<0)r.push(new Ch(o));else{let a=this.plugins[s];a.mustUpdate=e,r.push(a)}}for(let o of this.plugins)o.mustUpdate!=e&&o.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let r of this.plugins)r.mustUpdate=e;for(let r=0;r-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,i=this.viewState.scrollParent,r=this.viewState.getScrollOffset(),{scrollAnchorPos:o,scrollAnchorHeight:s}=this.viewState;Math.abs(r-this.viewState.scrollOffset)>1&&(s=-1),this.viewState.scrollAnchorHeight=-1;try{for(let a=0;;a++){if(s<0)if(GT(i||this.win))o=-1,s=this.viewState.heightMap.height;else{let d=this.viewState.scrollAnchorAt(r);o=d.from,s=d.top}this.updateState=1;let l=this.viewState.measure();if(!l&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(a>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let c=[];l&4||([this.measureRequests,c]=[c,this.measureRequests]);let u=c.map(d=>{try{return d.read(this)}catch(p){return It(this.state,p),NT}}),f=Fg.create(this,this.state,[]),h=!1;f.flags|=l,t?t.flags|=l:t=f,this.updateState=2,f.empty||(this.updatePlugins(f),this.inputState.update(f),this.updateAttrs(),h=this.docView.update(f),h&&this.docViewUpdate());for(let d=0;d1||p<-1)&&(i==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){r=r+p,i?i.scrollTop+=p:this.win.scrollBy(0,p),s=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let a of this.state.facet(z0))a(t)}get themeClasses(){return pb+" "+(this.state.facet(db)?MA:AA)+" "+this.state.facet(Mg)}updateAttrs(){let e=$T(this,hA,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Fr)?"true":"false",class:"cm-content",style:`${z.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),$T(this,Ob,t);let i=this.observer.ignore(()=>{let r=gT(this.contentDOM,this.contentAttrs,t),o=gT(this.dom,this.editorAttrs,e);return r||o});return this.editorAttrs=e,this.contentAttrs=t,i}showAnnouncements(e){let t=!0;for(let i of e)for(let r of i.effects)if(r.is(n.announce)){t&&(this.announceDOM.textContent=""),t=!1;let o=this.announceDOM.appendChild(document.createElement("div"));o.textContent=r.value}}mountStyles(){this.styleModules=this.state.facet(yh);let e=this.state.facet(n.cspNonce);ni.mount(this.root,this.styleModules.concat(EV).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&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(e.key!=null){for(let t=0;ti.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,i){return D0(this,e,wT(this,e,t,i))}moveByGroup(e,t){return D0(this,e,wT(this,e,t,i=>Gq(this,e.head,i)))}visualLineSide(e,t){let i=this.bidiSpans(e),r=this.textDirectionAt(e.from),o=i[t?i.length-1:0];return $.cursor(o.side(t,r)+e.from,o.forward(!t,r)?1:-1)}moveToLineBoundary(e,t,i=!0){return Kq(this,e,t,i)}moveVertically(e,t,i){return D0(this,e,Xq(this,e,t,i))}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 i=J0(this,e,t);return i&&i.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),J0(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let i=this.docView.coordsAt(e,t);if(!i||i.left==i.right)return i;let r=this.state.doc.lineAt(e),o=this.bidiSpans(r),s=o[oi.find(o,e-r.from,-1,t)];return Ah(i,s.dir==We.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(cA)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>kV)return tA(e.length);let t=this.textDirectionAt(e.from),i;for(let o of this.bidiCache)if(o.from==e.from&&o.dir==t&&(o.fresh||eA(o.isolates,i=xT(this,e))))return o.order;i||(i=xT(this,e));let r=Oq(e.text,t,i);return this.bidiCache.push(new Kg(e.from,e.to,t,i,!0,r)),r}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||z.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{KT(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?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 i,r,o,s;return Og.of(new wh(typeof e=="number"?$.cursor(e):e,(i=t.y)!==null&&i!==void 0?i:"nearest",(r=t.x)!==null&&r!==void 0?r:"nearest",(o=t.yMargin)!==null&&o!==void 0?o:5,(s=t.xMargin)!==null&&s!==void 0?s:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,i=this.viewState.scrollAnchorAt(e);return Og.of(new wh($.cursor(i.from),"start","start",i.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return Yt.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return Yt.define(()=>({}),{eventObservers:e})}static theme(e,t){let i=ni.newName(),r=[Mg.of(i),yh.of(mb(`.${i}`,e))];return t&&t.dark&&r.push(db.of(!0)),r}static baseTheme(e){return $r.lowest(yh.of(mb("."+pb,e,PA)))}static findFromDOM(e){var t;let i=e.querySelector(".cm-content"),r=i&&it.get(i)||it.get(e);return((t=r==null?void 0:r.root)===null||t===void 0?void 0:t.view)||null}};U.styleModule=yh;U.inputHandler=aA;U.clipboardInputFilter=Eb;U.clipboardOutputFilter=Sb;U.scrollHandler=uA;U.focusChangeEffect=lA;U.perLineTextDirection=cA;U.exceptionSink=sA;U.updateListener=z0;U.editable=Fr;U.mouseSelectionStyle=oA;U.dragMovesSelection=rA;U.clickAddsSelectionRange=iA;U.decorations=ey;U.blockWrappers=dA;U.outerDecorations=kb;U.atomicRanges=Ph;U.bidiIsolatedRanges=pA;U.cursorScrollMargin=H.define({combine:n=>{let e=5,t=5;for(let i of n)typeof i=="number"?e=t=i:{x:e,y:t}=i;return{x:e,y:t}}});U.scrollMargins=mA;U.darkTheme=db;U.cspNonce=H.define({combine:n=>n.length?n[0]:""});U.contentAttributes=Ob;U.editorAttributes=hA;U.lineWrapping=U.contentAttributes.of({class:"cm-lineWrapping"});U.announce=de.define();var kV=4096,NT={},Kg=class n{constructor(e,t,i,r,o,s){this.from=e,this.to=t,this.dir=i,this.isolates=r,this.fresh=o,this.order=s}static update(e,t){if(t.empty&&!e.some(o=>o.fresh))return e;let i=[],r=e.length?e[e.length-1].dir:We.LTR;for(let o=Math.max(0,e.length-10);o=0;r--){let o=i[r],s=typeof o=="function"?o(n):o;s&&_b(s,t)}return t}var RV=z.mac?"mac":z.windows?"win":z.linux?"linux":"key";function TV(n,e){let t=n.split(/-(?!$)/),i=t[t.length-1];i=="Space"&&(i=" ");let r,o,s,a;for(let l=0;li.concat(r),[]))),t}var Lo=null,PV=4e3;function DV(n,e=RV){let t=Object.create(null),i=Object.create(null),r=(s,a)=>{let l=i[s];if(l==null)i[s]=a;else if(l!=a)throw new Error("Key binding "+s+" is used both as a regular binding and as a multi-stroke prefix")},o=(s,a,l,c,u)=>{var f,h;let d=t[s]||(t[s]=Object.create(null)),p=a.split(/ (?!$)/).map(b=>TV(b,e));for(let b=1;b{let x=Lo={view:v,prefix:_,scope:s};return setTimeout(()=>{Lo==x&&(Lo=null)},PV),!0}]})}let m=p.join(" ");r(m,!1);let g=d[m]||(d[m]={preventDefault:!1,stopPropagation:!1,run:((h=(f=d._any)===null||f===void 0?void 0:f.run)===null||h===void 0?void 0:h.slice())||[]});l&&g.run.push(l),c&&(g.preventDefault=!0),u&&(g.stopPropagation=!0)};for(let s of n){let a=s.scope?s.scope.split(" "):["editor"];if(s.any)for(let c of a){let u=t[c]||(t[c]=Object.create(null));u._any||(u._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:f}=s;for(let h in u)u[h].run.push(d=>f(d,vb))}let l=s[e]||s.key;if(l)for(let c of a)o(c,l,s.run,s.preventDefault,s.stopPropagation),s.shift&&o(c,"Shift-"+l,s.shift,s.preventDefault,s.stopPropagation)}return t}var vb=null;function IV(n,e,t,i){vb=e;let r=fT(e),o=ti(r,0),s=Yi(o)==r.length&&r!=" ",a="",l=!1,c=!1,u=!1;Lo&&Lo.view==t&&Lo.scope==i&&(a=Lo.prefix+" ",CA.indexOf(e.keyCode)<0&&(c=!0,Lo=null));let f=new Set,h=g=>{if(g){for(let b of g.run)if(!f.has(b)&&(f.add(b),b(t)))return g.stopPropagation&&(u=!0),!0;g.preventDefault&&(g.stopPropagation&&(u=!0),c=!0)}return!1},d=n[i],p,m;return d&&(h(d[a+Pg(r,e,!s)])?l=!0:s&&(e.altKey||e.metaKey||e.ctrlKey)&&!(z.windows&&e.ctrlKey&&e.altKey)&&!(z.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(p=jr[e.keyCode])&&p!=r?(h(d[a+Pg(p,e,!0)])||e.shiftKey&&(m=Kl[e.keyCode])!=r&&m!=p&&h(d[a+Pg(m,e,!1)]))&&(l=!0):s&&e.shiftKey&&h(d[a+Pg(r,e,!0)])&&(l=!0),!l&&h(d._any)&&(l=!0)),c&&(l=!0),l&&u&&e.stopPropagation(),vb=null,l}var pge=/x/.unicode!=null?"gu":"g";var xb=class extends ai{constructor(e){super(),this.content=e}toDOM(e){let t=document.createElement("span");return t.className="cm-placeholder",t.style.pointerEvents="none",t.appendChild(typeof this.content=="string"?document.createTextNode(this.content):typeof this.content=="function"?this.content(e):this.content.cloneNode(!0)),t.setAttribute("aria-hidden","true"),t}coordsAt(e){let t=e.firstChild?bh(e.firstChild):[];if(!t.length)return null;let i=window.getComputedStyle(e.parentNode),r=Ah(t[0],i.direction!="rtl"),o=parseInt(i.lineHeight);return r.bottom-r.top>o*1.5?{left:r.left,right:r.right,top:r.top,bottom:r.top+o}:r}ignoreEvent(){return!1}};function Ab(n){let e=Yt.fromClass(class{constructor(t){this.view=t,this.placeholder=n?he.set([he.widget({widget:new xb(n),side:1}).range(0)]):he.none}get decorations(){return this.view.state.doc.length?he.none:this.placeholder}},{decorations:t=>t.decorations});return typeof n=="string"?[e,U.contentAttributes.of({"aria-placeholder":n})]:e}var Dg="-10000px",Gg=class{constructor(e,t,i,r){this.facet=t,this.createTooltipView=i,this.removeTooltipView=r,this.input=e.state.facet(t),this.tooltips=this.input.filter(s=>s);let o=null;this.tooltipViews=this.tooltips.map(s=>o=i(s,o))}update(e,t){var i;let r=e.state.facet(this.facet),o=r.filter(l=>l);if(r===this.input){for(let l of this.tooltipViews)l.update&&l.update(e);return!1}let s=[],a=t?[]:null;for(let l=0;lt[c]=l),t.length=a.length),this.input=r,this.tooltips=o,this.tooltipViews=s,!0}};function DA(n={}){return Bg.of(n)}function LV(n){let e=n.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}var Bg=H.define({combine:n=>{var e,t,i;return{position:z.ios?"absolute":((e=n.find(r=>r.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((t=n.find(r=>r.parent))===null||t===void 0?void 0:t.parent)||null,tooltipSpace:((i=n.find(r=>r.tooltipSpace))===null||i===void 0?void 0:i.tooltipSpace)||LV}}}),FT=new WeakMap,Mb=Yt.fromClass(class{constructor(n){this.view=n,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=n.state.facet(Bg);this.position=e.position,this.parent=e.parent,this.classes=n.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new Gg(n,Dh,(t,i)=>this.createTooltip(t,i),t=>{this.resizeObserver&&this.resizeObserver.unobserve(t.dom),t.dom.remove()}),this.above=this.manager.tooltips.map(t=>!!t.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),n.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let n of this.manager.tooltipViews)this.intersectionObserver.observe(n.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(n){n.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(n,this.above);e&&this.observeIntersection();let t=e||n.geometryChanged,i=n.state.facet(Bg);if(i.position!=this.position&&!this.madeAbsolute){this.position=i.position;for(let r of this.manager.tooltipViews)r.dom.style.position=this.position;t=!0}if(i.parent!=this.parent){this.parent&&this.container.remove(),this.parent=i.parent,this.createContainer();for(let r of this.manager.tooltipViews)this.container.appendChild(r.dom);t=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);t&&this.maybeMeasure()}createTooltip(n,e){let t=n.create(this.view),i=e?e.dom:null;if(t.dom.classList.add("cm-tooltip"),n.arrow&&!t.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let r=document.createElement("div");r.className="cm-tooltip-arrow",t.dom.appendChild(r)}return t.dom.style.position=this.position,t.dom.style.top=Dg,t.dom.style.left="0px",this.container.insertBefore(t.dom,i),t.mount&&t.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(t.dom),t}destroy(){var n,e,t;this.view.win.removeEventListener("resize",this.measureSoon);for(let i of this.manager.tooltipViews)i.dom.remove(),(n=i.destroy)===null||n===void 0||n.call(i);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(t=this.intersectionObserver)===null||t===void 0||t.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let n=1,e=1,t=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:o}=this.manager.tooltipViews[0];if(z.safari){let s=o.getBoundingClientRect();t=Math.abs(s.top+1e4)>1||Math.abs(s.left)>1}else t=!!o.offsetParent&&o.offsetParent!=this.container.ownerDocument.body}if(t||this.position=="absolute")if(this.parent){let o=this.parent.getBoundingClientRect();o.width&&o.height&&(n=o.width/this.parent.offsetWidth,e=o.height/this.parent.offsetHeight)}else({scaleX:n,scaleY:e}=this.view.viewState);let i=this.view.scrollDOM.getBoundingClientRect(),r=Rb(this.view);return{visible:{left:i.left+r.left,top:i.top+r.top,right:i.right-r.right,bottom:i.bottom-r.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((o,s)=>{let a=this.manager.tooltipViews[s];return a.getCoords?a.getCoords(o.pos):this.view.coordsAtPos(o.pos)}),size:this.manager.tooltipViews.map(({dom:o})=>o.getBoundingClientRect()),space:this.view.state.facet(Bg).tooltipSpace(this.view),scaleX:n,scaleY:e,makeAbsolute:t}}writeMeasure(n){var e;if(n.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let a of this.manager.tooltipViews)a.dom.style.position="absolute"}let{visible:t,space:i,scaleX:r,scaleY:o}=n,s=[];for(let a=0;a=Math.min(t.bottom,i.bottom)||f.rightMath.min(t.right,i.right)+.1)){u.style.top=Dg;continue}let d=l.arrow?c.dom.querySelector(".cm-tooltip-arrow"):null,p=d?7:0,m=h.right-h.left,g=(e=FT.get(c))!==null&&e!==void 0?e:h.bottom-h.top,b=c.offset||NV,_=this.view.textDirection==We.LTR,v=h.width>i.right-i.left?_?i.left:i.right-h.width:_?Math.max(i.left,Math.min(f.left-(d?14:0)+b.x,i.right-m)):Math.min(Math.max(i.left,f.left-m+(d?14:0)-b.x),i.right-m),x=this.above[a];!l.strictSide&&(x?f.top-g-p-b.yi.bottom)&&x==i.bottom-f.bottom>f.top-i.top&&(x=this.above[a]=!x);let C=(x?f.top-i.top:i.bottom-f.bottom)-p;if(Cv&&w.topE&&(E=x?w.top-g-2-p:w.bottom+p+2);if(this.position=="absolute"?(u.style.top=(E-n.parent.top)/o+"px",qT(u,(v-n.parent.left)/r)):(u.style.top=E/o+"px",qT(u,v/r)),d){let w=f.left+(_?b.x:-b.x)-(v+14-7);d.style.left=w/r+"px"}c.overlap!==!0&&s.push({left:v,top:E,right:S,bottom:E+g}),u.classList.toggle("cm-tooltip-above",x),u.classList.toggle("cm-tooltip-below",!x),c.positioned&&c.positioned(n.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let n of this.manager.tooltipViews)n.dom.style.top=Dg}},{eventObservers:{scroll(){this.maybeMeasure()}}});function qT(n,e){let t=parseInt(n.style.left,10);(isNaN(t)||Math.abs(e-t)>1)&&(n.style.left=e+"px")}var BV=U.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:"14px",position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),NV={x:0,y:0},Dh=H.define({enables:[Mb,BV]}),Xg=H.define({combine:n=>n.reduce((e,t)=>e.concat(t),[])}),Yg=class n{static create(e){return new n(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new Gg(e,Xg,(t,i)=>this.createHostedView(t,i),t=>t.dom.remove())}createHostedView(e,t){let i=e.create(this.view);return i.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(i.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&i.mount&&i.mount(this.view),i}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)(e=t.destroy)===null||e===void 0||e.call(t)}passProp(e){let t;for(let i of this.manager.tooltipViews){let r=i[e];if(r!==void 0){if(t===void 0)t=r;else if(t!==r)return}}return t}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}},$V=Dh.compute([Xg],n=>{let e=n.facet(Xg);return e.length===0?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.map(t=>{var i;return(i=t.end)!==null&&i!==void 0?i:t.pos})),create:Yg.create,above:e[0].above,arrow:e.some(t=>t.arrow)}}),jV=H.define(),bb=class{constructor(e,t,i,r,o,s){this.view=e,this.source=t,this.field=i,this.locked=r,this.setHover=o,this.hoverTime=s,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(e){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;es.bottom||t.xs.right+e.defaultCharacterWidth)return;let a=e.bidiSpans(e.state.doc.lineAt(r)).find(c=>c.from<=r&&c.to>=r),l=a&&a.dir==We.RTL?-1:1;o=t.x{if(a&&!(Array.isArray(a)&&!a.length)){let l=Array.isArray(a)?a:[a];r&&this.locked.set(l,r),e.dispatch({effects:this.setHover.of(l)})}};if(o&&"then"in o){let a=this.pending={pos:t};o.then(l=>{this.pending==a&&(this.pending=null,s(l))},l=>It(e.state,l,"hover tooltip"))}else s(o)}get tooltip(){let e=this.view.plugin(Mb),t=e?e.manager.tooltips.findIndex(i=>i.create==Yg.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t,i;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:r,tooltip:o}=this;if(r.length&&!this.locked.has(r)&&o&&!FV(o.dom,e)||this.pending){let{pos:s}=r[0]||this.pending,a=(i=(t=r[0])===null||t===void 0?void 0:t.end)!==null&&i!==void 0?i:s;(s==a?this.view.posAtCoords(this.lastMove)!=s:!qV(this.view,s,a,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t.length&&!this.locked.has(t)){let{tooltip:i}=this;i&&i.dom.contains(e.relatedTarget)?this.watchTooltipLeave(i.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=i=>{e.removeEventListener("mouseleave",t);let{active:r}=this;r.length&&!this.locked.has(r)&&!this.view.dom.contains(i.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}},Ig=4;function FV(n,e){let{left:t,right:i,top:r,bottom:o}=n.getBoundingClientRect(),s;if(s=n.querySelector(".cm-tooltip-arrow")){let a=s.getBoundingClientRect();r=Math.min(a.top,r),o=Math.max(a.bottom,o)}return e.clientX>=t-Ig&&e.clientX<=i+Ig&&e.clientY>=r-Ig&&e.clientY<=o+Ig}function qV(n,e,t,i,r,o){let s=n.scrollDOM.getBoundingClientRect(),a=n.documentTop+n.documentPadding.top+n.contentHeight;if(s.left>i||s.rightr||Math.min(s.bottom,a)=e&&l<=t}function IA(n,e={}){let t=de.define(),i=new WeakMap,r=qt.define({create(){return[]},update(s,a){let l=i.get(s);if(s.length&&(e.hideOnChange&&(a.docChanged||a.selection)?s=[]:l&&l(a)?s=[]:e.hideOn&&(s=s.filter(c=>!e.hideOn(a,c)))),a.docChanged&&s.length){let c=[];for(let u of s){let f=a.changes.mapPos(u.pos,-1,Ot.TrackDel);if(f!=null){let h=Object.assign(Object.create(null),u);h.pos=f,h.end!=null&&(h.end=a.changes.mapPos(h.end)),c.push(h)}}s=c}for(let c of a.effects)c.is(t)&&(s=c.value,l=void 0),(c.is(VV)&&!c.value||c.value==r)&&(s=[]);return s.length&&l&&i.set(s,l),s},provide:s=>Xg.from(s)}),o=Yt.define(s=>new bb(s,n,r,i,t,e.hoverTime||300));return{active:r,extension:[r,o,jV.of(o),$V]}}function Pb(n,e){let t=n.plugin(Mb);if(!t)return null;let i=t.manager.tooltips.indexOf(e);return i<0?null:t.manager.tooltipViews[i]}var VV=de.define();var VT=H.define({combine(n){let e,t;for(let i of n)e=e||i.topContainer,t=t||i.bottomContainer;return{topContainer:e,bottomContainer:t}}});var HV=Yt.fromClass(class{constructor(n){this.input=n.state.facet(Zg),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(n));let e=n.state.facet(VT);this.top=new Zl(n,!0,e.topContainer),this.bottom=new Zl(n,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(n){let e=n.state.facet(VT);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new Zl(n.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new Zl(n.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=n.state.facet(Zg);if(t!=this.input){let i=t.filter(l=>l),r=[],o=[],s=[],a=[];for(let l of i){let c=this.specs.indexOf(l),u;c<0?(u=l(n.view),a.push(u)):(u=this.panels[c],u.update&&u.update(n)),r.push(u),(u.top?o:s).push(u)}this.specs=i,this.panels=r,this.top.sync(o),this.bottom.sync(s);for(let l of a)l.dom.classList.add("cm-panel"),l.mount&&l.mount()}else for(let i of this.panels)i.update&&i.update(n)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:n=>U.scrollMargins.of(e=>{let t=e.plugin(n);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})}),Zl=class{constructor(e,t,i){this.view=e,this.top=t,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=HT(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=HT(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}};function HT(n){let e=n.nextSibling;return n.remove(),e}var Zg=H.define({enables:HV});var er=class extends ei{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};er.prototype.elementClass="";er.prototype.toDOM=void 0;er.prototype.mapMode=Ot.TrackBefore;er.prototype.startSide=er.prototype.endSide=-1;er.prototype.point=!0;var zV=0,Ih=class{constructor(e,t){this.from=e,this.to=t}},ce=class{constructor(e={}){this.id=zV++,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 typeof e!="function"&&(e=Zt.match(e)),t=>{let i=e(t);return i===void 0?null:[this,i]}}};ce.closedBy=new ce({deserialize:n=>n.split(" ")});ce.openedBy=new ce({deserialize:n=>n.split(" ")});ce.group=new ce({deserialize:n=>n.split(" ")});ce.isolate=new ce({deserialize:n=>{if(n&&n!="rtl"&&n!="ltr"&&n!="auto")throw new RangeError("Invalid value for isolate: "+n);return n||"auto"}});ce.contextHash=new ce({perNode:!0});ce.lookAhead=new ce({perNode:!0});ce.mounted=new ce({perNode:!0});var zs=class{constructor(e,t,i,r=!1){this.tree=e,this.overlay=t,this.parser=i,this.bracketed=r}static get(e){return e&&e.props&&e.props[ce.mounted.id]}},WV=Object.create(null),Zt=class n{constructor(e,t,i,r=0){this.name=e,this.props=t,this.id=i,this.flags=r}static define(e){let t=e.props&&e.props.length?Object.create(null):WV,i=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),r=new n(e.name||"",t,e.id,i);if(e.props){for(let o of e.props)if(Array.isArray(o)||(o=o(r)),o){if(o[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[o[0].id]=o[1]}}return r}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(ce.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let i in e)for(let r of i.split(" "))t[r]=e[i];return i=>{for(let r=i.prop(ce.group),o=-1;o<(r?r.length:0);o++){let s=t[o<0?i.name:r[o]];if(s)return s}}}};Zt.none=new Zt("",Object.create(null),0,8);var Lh=class n{constructor(e){this.types=e;for(let t=0;t0;for(let l=this.cursor(s|rt.IncludeAnonymous);;){let c=!1;if(l.from<=o&&l.to>=r&&(!a&&l.type.isAnonymous||t(l)!==!1)){if(l.firstChild())continue;c=!0}for(;c&&i&&(a||!l.type.isAnonymous)&&i(l),!l.nextSibling();){if(!l.parent())return;c=!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:jb(Zt.none,this.children,this.positions,0,this.children.length,0,this.length,(t,i,r)=>new n(this.type,t,i,r,this.propValues),e.makeTree||((t,i,r)=>new n(Zt.none,t,i,r)))}static build(e){return QV(e)}};gt.empty=new gt(Zt.none,[],[],0);var Db=class n{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 n(this.buffer,this.index)}},jo=class n{constructor(e,t,i){this.buffer=e,this.length=t,this.set=i}get type(){return Zt.none}toString(){let e=[];for(let t=0;t0));l=s[l+3]);return a}slice(e,t,i){let r=this.buffer,o=new Uint16Array(t-e),s=0;for(let a=e,l=0;a=e&&te;case 1:return t<=e&&i>e;case 2:return i>e;case 4:return!0}}function Bh(n,e,t,i){for(var r;n.from==n.to||(t<1?n.from>=e:n.from>e)||(t>-1?n.to<=e:n.to0?a.length:-1;e!=c;e+=t){let u=a[e],f=l[e]+s.from,h;if(!(!(o&rt.EnterBracketed&&u instanceof gt&&(h=zs.get(u))&&!h.overlay&&h.bracketed&&i>=f&&i<=f+u.length)&&!$A(r,i,f,f+u.length))){if(u instanceof jo){if(o&rt.ExcludeBuffers)continue;let d=u.findChild(0,u.buffer.length,t,i-f,r);if(d>-1)return new Nh(new Lb(s,u,e,f),null,d)}else if(o&rt.IncludeAnonymous||!u.type.isAnonymous||$b(u)){let d;if(!(o&rt.IgnoreMounts)&&(d=zs.get(u))&&!d.overlay)return new n(d.tree,f,e,s);let p=new n(u,f,e,s);return o&rt.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(t<0?u.children.length-1:0,t,i,r,o)}}}if(o&rt.IncludeAnonymous||!s.type.isAnonymous||(s.index>=0?e=s.index+t:e=t<0?-1:s._parent._tree.children.length,s=s._parent,!s))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,t,i=0){let r;if(!(i&rt.IgnoreOverlays)&&(r=zs.get(this._tree))&&r.overlay){let o=e-this.from,s=i&rt.EnterBracketed&&r.bracketed;for(let{from:a,to:l}of r.overlay)if((t>0||s?a<=o:a=o:l>o))return new n(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,i)}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 BA(n,e,t,i){let r=n.cursor(),o=[];if(!r.firstChild())return o;if(t!=null){for(let s=!1;!s;)if(s=r.type.is(t),!r.nextSibling())return o}for(;;){if(i!=null&&r.type.is(i))return o;if(r.type.is(e)&&o.push(r.node),!r.nextSibling())return i==null?o:[]}}function Ib(n,e,t=e.length-1){for(let i=n;t>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(e[t]&&e[t]!=i.name)return!1;t--}}return!0}var Lb=class{constructor(e,t,i,r){this.parent=e,this.buffer=t,this.index=i,this.start=r}},Nh=class n extends ry{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,i){super(),this.context=e,this._parent=t,this.index=i,this.type=e.buffer.set.types[e.buffer.buffer[i]]}child(e,t,i){let{buffer:r}=this.context,o=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.context.start,i);return o<0?null:new n(this.context,this,o)}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,i=0){if(i&rt.ExcludeBuffers)return null;let{buffer:r}=this.context,o=r.findChild(this.index+4,r.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return o<0?null:new n(this.context,this,o)}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 n(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 n(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:i}=this.context,r=this.index+4,o=i.buffer[this.index+3];if(o>r){let s=i.buffer[this.index+1];e.push(i.slice(r,o,s)),t.push(0)}return new gt(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function jA(n){if(!n.length)return null;let e=0,t=n[0];for(let o=1;ot.from||s.to=e){let a=new tr(s.tree,s.overlay[0].from+o.from,-1,o);(r||(r=[i])).push(Bh(a,e,t,!1))}}return r?jA(r):i}var $h=class{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&~rt.EnterBracketed,e instanceof tr)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let i=e._parent;i;i=i._parent)this.stack.unshift(i.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):!1}yieldBuf(e,t){this.index=e;let{start:i,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=i+r.buffer[e+1],this.to=i+r.buffer[e+2],!0}yield(e){return e?e instanceof tr?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,i){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,i,this.mode));let{buffer:r}=this.buffer,o=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,i);return o<0?!1:(this.stack.push(this.index),this.yieldBuf(o))}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,i=this.mode){return this.buffer?i&rt.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&rt.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&rt.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)):!1;let{buffer:t}=this.buffer,i=this.stack.length-1;if(e<0){let r=i<0?0:this.stack[i]+4;if(this.index!=r)return this.yieldBuf(t.findChild(r,this.index,-1,0,4))}else{let r=t.buffer[this.index+3];if(r<(i<0?t.buffer.length:t.buffer[this.stack[i]+3]))return this.yieldBuf(r)}return i<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,i,{buffer:r}=this;if(r){if(e>0){if(this.index-1)for(let o=t+e,s=e<0?-1:i._tree.children.length;o!=s;o+=e){let a=i._tree.children[o];if(this.mode&rt.IncludeAnonymous||a instanceof jo||!a.type.isAnonymous||$b(a))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=0;){for(let s=e;s;s=s._parent)if(s.index==r){if(r==this.index)return s;t=s,i=o+1;break e}r=this.stack[--o]}for(let r=i;r=0;o--){if(o<0)return Ib(this._tree,e,r);let s=i[t.buffer[this.stack[o]]];if(!s.isAnonymous){if(e[r]&&e[r]!=s.name)return!1;r--}}return!0}};function $b(n){return n.children.some(e=>e instanceof jo||!e.type.isAnonymous||$b(e))}function QV(n){var e;let{buffer:t,nodeSet:i,maxBufferLength:r=1024,reused:o=[],minRepeatType:s=i.types.length}=n,a=Array.isArray(t)?new Db(t,t.length):t,l=i.types,c=0,u=0;function f(C,E,S,w,R,A){let{id:I,start:D,end:N,size:W}=a,Re=u,_e=c;if(W<0)if(a.next(),W==-1){let $e=o[I];S.push($e),w.push(D-C);return}else if(W==-3){c=I;return}else if(W==-4){u=I;return}else throw new RangeError(`Unrecognized record size: ${W}`);let ue=l[I],re,me,Ue=D-C;if(N-D<=r&&(me=g(a.pos-E,R))){let $e=new Uint16Array(me.size-me.skip),Ct=a.pos-me.size,Nt=$e.length;for(;a.pos>Ct;)Nt=b(me.start,$e,Nt);re=new jo($e,N-me.start,i),Ue=me.start-C}else{let $e=a.pos-W;a.next();let Ct=[],Nt=[],fn=I>=s?I:-1,ct=0,Ti=N;for(;a.pos>$e;)fn>=0&&a.id==fn&&a.size>=0?(a.end<=Ti-r&&(p(Ct,Nt,D,ct,a.end,Ti,fn,Re,_e),ct=Ct.length,Ti=a.end),a.next()):A>2500?h(D,$e,Ct,Nt):f(D,$e,Ct,Nt,fn,A+1);if(fn>=0&&ct>0&&ct-1&&ct>0){let Zo=d(ue,_e);re=jb(ue,Ct,Nt,0,Ct.length,0,N-D,Zo,Zo)}else re=m(ue,Ct,Nt,N-D,Re-N,_e)}S.push(re),w.push(Ue)}function h(C,E,S,w){let R=[],A=0,I=-1;for(;a.pos>E;){let{id:D,start:N,end:W,size:Re}=a;if(Re>4)a.next();else{if(I>-1&&N=0;W-=3)D[Re++]=R[W],D[Re++]=R[W+1]-N,D[Re++]=R[W+2]-N,D[Re++]=Re;S.push(new jo(D,R[2]-N,i)),w.push(N-C)}}function d(C,E){return(S,w,R)=>{let A=0,I=S.length-1,D,N;if(I>=0&&(D=S[I])instanceof gt){if(!I&&D.type==C&&D.length==R)return D;(N=D.prop(ce.lookAhead))&&(A=w[I]+D.length+N)}return m(C,S,w,R,A,E)}}function p(C,E,S,w,R,A,I,D,N){let W=[],Re=[];for(;C.length>w;)W.push(C.pop()),Re.push(E.pop()+S-R);C.push(m(i.types[I],W,Re,A-R,D-A,N)),E.push(R-S)}function m(C,E,S,w,R,A,I){if(A){let D=[ce.contextHash,A];I=I?[D].concat(I):[D]}if(R>25){let D=[ce.lookAhead,R];I=I?[D].concat(I):[D]}return new gt(C,E,S,w,I)}function g(C,E){let S=a.fork(),w=0,R=0,A=0,I=S.end-r,D={size:0,start:0,skip:0};e:for(let N=S.pos-C;S.pos>N;){let W=S.size;if(S.id==E&&W>=0){D.size=w,D.start=R,D.skip=A,A+=4,w+=4,S.next();continue}let Re=S.pos-W;if(W<0||Re=s?4:0,ue=S.start;for(S.next();S.pos>Re;){if(S.size<0)if(S.size==-3||S.size==-4)_e+=4;else break e;else S.id>=s&&(_e+=4);S.next()}R=ue,w+=W,A+=_e}return(E<0||w==C)&&(D.size=w,D.start=R,D.skip=A),D.size>4?D:void 0}function b(C,E,S){let{id:w,start:R,end:A,size:I}=a;if(a.next(),I>=0&&w4){let N=a.pos-(I-4);for(;a.pos>N;)S=b(C,E,S)}E[--S]=D,E[--S]=A-C,E[--S]=R-C,E[--S]=w}else I==-3?c=w:I==-4&&(u=w);return S}let _=[],v=[];for(;a.pos>0;)f(n.start||0,n.bufferStart||0,_,v,-1,0);let x=(e=n.length)!==null&&e!==void 0?e:_.length?v[0]+_[0].length:0;return new gt(l[n.topID],_.reverse(),v.reverse(),x)}var NA=new WeakMap;function iy(n,e){if(!n.isAnonymous||e instanceof jo||e.type!=n)return 1;let t=NA.get(e);if(t==null){t=1;for(let i of e.children){if(i.type!=n||!(i instanceof gt)){t=1;break}t+=iy(n,i)}NA.set(e,t)}return t}function jb(n,e,t,i,r,o,s,a,l){let c=0;for(let p=i;p=u)break;E+=S}if(v==x+1){if(E>u){let S=p[x];d(S.children,S.positions,0,S.children.length,m[x]+_);continue}f.push(p[x])}else{let S=m[v-1]+p[v-1].length-C;f.push(jb(n,p,m,x,v,C,S,null,l))}h.push(C+_-o)}}return d(e,t,i,r,0),(a||l)(f,h,s)}var Ws=class n{constructor(e,t,i,r,o=!1,s=!1){this.from=e,this.to=t,this.tree=i,this.offset=r,this.open=(o?1:0)|(s?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],i=!1){let r=[new n(0,e.length,e,0,!1,i)];for(let o of t)o.to>e.length&&r.push(o);return r}static applyChanges(e,t,i=128){if(!t.length)return e;let r=[],o=1,s=e.length?e[0]:null;for(let a=0,l=0,c=0;;a++){let u=a=i)for(;s&&s.from=h.from||f<=h.to||c){let d=Math.max(h.from,l)-c,p=Math.min(h.to,f)-c;h=d>=p?null:new n(d,p,h.tree,h.offset+c,a>0,!!u)}if(h&&r.push(h),s.to>f)break;s=onew Ih(r.from,r.to)):[new Ih(0,0)]:[new Ih(0,e.length)],this.createParse(e,t||[],i)}parse(e,t,i){let r=this.startParse(e,t,i);for(;;){let o=r.advance();if(o)return o}}},Nb=class{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)}};var bge=new ce({perNode:!0});var KV=0,Ci=class n{constructor(e,t,i,r){this.name=e,this.set=t,this.base=i,this.modified=r,this.id=KV++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let i=typeof e=="string"?e:"?";if(e instanceof n&&(t=e),t!=null&&t.base)throw new Error("Can not derive from a modified tag");let r=new n(i,[],null,[]);if(r.set.push(r),t)for(let o of t.set)r.set.push(o);return r}static defineModifier(e){let t=new ly(e);return i=>i.modified.indexOf(t)>-1?i:ly.get(i.base||i,i.modified.concat(t).sort((r,o)=>r.id-o.id))}},GV=0,ly=class n{constructor(e){this.name=e,this.instances=[],this.id=GV++}static get(e,t){if(!t.length)return e;let i=t[0].instances.find(a=>a.base==e&&XV(t,a.modified));if(i)return i;let r=[],o=new Ci(e.name,r,e,t);for(let a of t)a.instances.push(o);let s=YV(t);for(let a of e.set)if(!a.modified.length)for(let l of s)r.push(n.get(a,l));return o}};function XV(n,e){return n.length==e.length&&n.every((t,i)=>t==e[i])}function YV(n){let e=[[]];for(let t=0;ti.length-t.length)}function cy(n){let e=Object.create(null);for(let t in n){let i=n[t];Array.isArray(i)||(i=[i]);for(let r of t.split(" "))if(r){let o=[],s=2,a=r;for(let f=0;;){if(a=="..."&&f>0&&f+3==r.length){s=1;break}let h=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!h)throw new RangeError("Invalid path: "+r);if(o.push(h[0]=="*"?"":h[0][0]=='"'?JSON.parse(h[0]):h[0]),f+=h[0].length,f==r.length)break;let d=r[f++];if(f==r.length&&d=="!"){s=0;break}if(d!="/")throw new RangeError("Invalid path: "+r);a=r.slice(f)}let l=o.length-1,c=o[l];if(!c)throw new RangeError("Invalid path: "+r);let u=new Qs(i,s,l>0?o.slice(0,l):null);e[c]=u.sort(e[c])}}return VA.add(e)}var VA=new ce({combine(n,e){let t,i,r;for(;n||e;){if(!n||e&&n.depth>=e.depth?(r=e,e=e.next):(r=n,n=n.next),t&&t.mode==r.mode&&!r.context&&!t.context)continue;let o=new Qs(r.tags,r.mode,r.context);t?t.next=o:i=o,t=o}return i}}),Qs=class{constructor(e,t,i,r){this.tags=e,this.mode=t,this.context=i,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let s=r;for(let a of o)for(let l of a.set){let c=t[l.id];if(c){s=s?s+" "+c:c;break}}return s},scope:i}}function ZV(n,e){let t=null;for(let i of n){let r=i.style(e);r&&(t=t?t+" "+r:r)}return t}function HA(n,e,t,i=0,r=n.length){let o=new qb(i,Array.isArray(e)?e:[e],t);o.highlightRange(n.cursor(),i,r,"",o.highlighters),o.flush(r)}var qb=class{constructor(e,t,i){this.at=e,this.highlighters=t,this.span=i,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,i,r,o){let{type:s,from:a,to:l}=e;if(a>=i||l<=t)return;s.isTop&&(o=this.highlighters.filter(d=>!d.scope||d.scope(s)));let c=r,u=JV(e)||Qs.empty,f=ZV(o,u.tags);if(f&&(c&&(c+=" "),c+=f,u.mode==1&&(r+=(r?" ":"")+f)),this.startSpan(Math.max(t,a),c),u.opaque)return;let h=e.tree&&e.tree.prop(ce.mounted);if(h&&h.overlay){let d=e.node.enter(h.overlay[0].from+a,1),p=this.highlighters.filter(g=>!g.scope||g.scope(h.tree.type)),m=e.firstChild();for(let g=0,b=a;;g++){let _=g=v||!e.nextSibling())););if(!_||v>i)break;b=_.to+a,b>t&&(this.highlightRange(d.cursor(),Math.max(t,_.from+a),Math.min(i,b),"",p),this.startSpan(Math.min(i,b),c))}m&&e.parent()}else if(e.firstChild()){h&&(r="");do if(!(e.to<=t)){if(e.from>=i)break;this.highlightRange(e,t,i,r,o),this.startSpan(Math.min(i,e.to),c)}while(e.nextSibling());e.parent()}}};function JV(n){let e=n.type.prop(VA);for(;e&&e.context&&!n.matchContext(e.context);)e=e.next;return e||null}var V=Ci.define,oy=V(),Fo=V(),FA=V(Fo),qA=V(Fo),qo=V(),sy=V(qo),Fb=V(qo),rr=V(),Us=V(rr),nr=V(),ir=V(),Vb=V(),jh=V(Vb),ay=V(),B={comment:oy,lineComment:V(oy),blockComment:V(oy),docComment:V(oy),name:Fo,variableName:V(Fo),typeName:FA,tagName:V(FA),propertyName:qA,attributeName:V(qA),className:V(Fo),labelName:V(Fo),namespace:V(Fo),macroName:V(Fo),literal:qo,string:sy,docString:V(sy),character:V(sy),attributeValue:V(sy),number:Fb,integer:V(Fb),float:V(Fb),bool:V(qo),regexp:V(qo),escape:V(qo),color:V(qo),url:V(qo),keyword:nr,self:V(nr),null:V(nr),atom:V(nr),unit:V(nr),modifier:V(nr),operatorKeyword:V(nr),controlKeyword:V(nr),definitionKeyword:V(nr),moduleKeyword:V(nr),operator:ir,derefOperator:V(ir),arithmeticOperator:V(ir),logicOperator:V(ir),bitwiseOperator:V(ir),compareOperator:V(ir),updateOperator:V(ir),definitionOperator:V(ir),typeOperator:V(ir),controlOperator:V(ir),punctuation:Vb,separator:V(Vb),bracket:jh,angleBracket:V(jh),squareBracket:V(jh),paren:V(jh),brace:V(jh),content:rr,heading:Us,heading1:V(Us),heading2:V(Us),heading3:V(Us),heading4:V(Us),heading5:V(Us),heading6:V(Us),contentSeparator:V(rr),list:V(rr),quote:V(rr),emphasis:V(rr),strong:V(rr),link:V(rr),monospace:V(rr),strikethrough:V(rr),inserted:V(),deleted:V(),changed:V(),invalid:V(),meta:ay,documentMeta:V(ay),annotation:V(ay),processingInstruction:V(ay),definition:Ci.defineModifier("definition"),constant:Ci.defineModifier("constant"),function:Ci.defineModifier("function"),standard:Ci.defineModifier("standard"),local:Ci.defineModifier("local"),special:Ci.defineModifier("special")};for(let n in B){let e=B[n];e instanceof Ci&&(e.name=n)}var Cge=Hb([{tag:B.link,class:"tok-link"},{tag:B.heading,class:"tok-heading"},{tag:B.emphasis,class:"tok-emphasis"},{tag:B.strong,class:"tok-strong"},{tag:B.keyword,class:"tok-keyword"},{tag:B.atom,class:"tok-atom"},{tag:B.bool,class:"tok-bool"},{tag:B.url,class:"tok-url"},{tag:B.labelName,class:"tok-labelName"},{tag:B.inserted,class:"tok-inserted"},{tag:B.deleted,class:"tok-deleted"},{tag:B.literal,class:"tok-literal"},{tag:B.string,class:"tok-string"},{tag:B.number,class:"tok-number"},{tag:[B.regexp,B.escape,B.special(B.string)],class:"tok-string2"},{tag:B.variableName,class:"tok-variableName"},{tag:B.local(B.variableName),class:"tok-variableName tok-local"},{tag:B.definition(B.variableName),class:"tok-variableName tok-definition"},{tag:B.special(B.variableName),class:"tok-variableName2"},{tag:B.definition(B.propertyName),class:"tok-propertyName tok-definition"},{tag:B.typeName,class:"tok-typeName"},{tag:B.namespace,class:"tok-namespace"},{tag:B.className,class:"tok-className"},{tag:B.macroName,class:"tok-macroName"},{tag:B.propertyName,class:"tok-propertyName"},{tag:B.operator,class:"tok-operator"},{tag:B.comment,class:"tok-comment"},{tag:B.meta,class:"tok-meta"},{tag:B.invalid,class:"tok-invalid"},{tag:B.punctuation,class:"tok-punctuation"}]);var zb,lc=new ce;function t4(n){return H.define({combine:n?e=>e.concat(n):void 0})}var n4=new ce,In=class{constructor(e,t,i=[],r=""){this.data=e,this.name=r,Ze.prototype.hasOwnProperty("tree")||Object.defineProperty(Ze.prototype,"tree",{get(){return lt(this)}}),this.parser=t,this.extension=[cc.of(this),Ze.languageData.of((o,s,a)=>{let l=zA(o,s,a),c=l.type.prop(lc);if(!c)return[];let u=o.facet(c),f=l.type.prop(n4);if(f){let h=l.resolve(s-l.from,a);for(let d of f)if(d.test(h,o)){let p=o.facet(d.facet);return d.type=="replace"?p:p.concat(u)}}return u})].concat(i)}isActiveAt(e,t,i=-1){return zA(e,t,i).type.prop(lc)==this.data}findRegions(e){let t=e.facet(cc);if((t==null?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let i=[],r=(o,s)=>{if(o.prop(lc)==this.data){i.push({from:s,to:s+o.length});return}let a=o.prop(ce.mounted);if(a){if(a.tree.prop(lc)==this.data){if(a.overlay)for(let l of a.overlay)i.push({from:l.from+s,to:l.to+s});else i.push({from:s,to:s+o.length});return}else if(a.overlay){let l=i.length;if(r(a.tree,a.overlay[0].from+s),i.length>l)return}}for(let l=0;li.isTop?t:void 0)]}),e.name)}configure(e,t){return new n(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}};function lt(n){let e=n.field(In.state,!1);return e?e.tree:gt.empty}var Kb=class{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 i=this.cursorPos-this.string.length;return e=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-i,t-i)}},Fh=null,Gb=class n{constructor(e,t,i=[],r,o,s,a,l){this.parser=e,this.state=t,this.fragments=i,this.tree=r,this.treeLen=o,this.viewport=s,this.skipped=a,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(e,t,i){return new n(e,t,[],gt.empty,0,i,[],null)}startParse(){return this.parser.startParse(new Kb(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=gt.empty&&this.isDone(t!=null?t:this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof e=="number"){let r=Date.now()+e;e=()=>Date.now()>r}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t=this.treeLen&&((this.parse.stoppedAt==null||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(Ws.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=Fh;Fh=this;try{return e()}finally{Fh=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=WA(e,t.from,t.to);return e}changes(e,t){let{fragments:i,tree:r,treeLen:o,viewport:s,skipped:a}=this;if(this.takeTree(),!e.empty){let l=[];if(e.iterChangedRanges((c,u,f,h)=>l.push({fromA:c,toA:u,fromB:f,toB:h})),i=Ws.applyChanges(i,l),r=gt.empty,o=0,s={from:e.mapPos(s.from,-1),to:e.mapPos(s.to,1)},this.skipped.length){a=[];for(let c of this.skipped){let u=e.mapPos(c.from,1),f=e.mapPos(c.to,-1);ue.from&&(this.fragments=WA(this.fragments,r,o),this.skipped.splice(i--,1))}return this.skipped.length>=t?!1:(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 ac{createParse(t,i,r){let o=r[0].from,s=r[r.length-1].to;return{parsedPos:o,advance(){let l=Fh;if(l){for(let c of r)l.tempSkipped.push(c);e&&(l.scheduleOn=l.scheduleOn?Promise.all([l.scheduleOn,e]):e)}return this.parsedPos=s,new gt(Zt.none,[],[],s-o)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return Fh}};function WA(n,e,t){return Ws.applyChanges(n,[{fromA:e,toA:t,fromB:e,toB:t}])}var qh=class n{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),i=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,i)||t.takeTree(),new n(t)}static init(e){let t=Math.min(3e3,e.doc.length),i=Gb.create(e.facet(cc).parser,e,{from:0,to:t});return i.work(20,t)||i.takeTree(),new n(i)}};In.state=qt.define({create:qh.init,update(n,e){for(let t of e.effects)if(t.is(In.setState))return t.value;return e.startState.facet(cc)!=e.state.facet(cc)?qh.init(e.state):n.apply(e)}});var XA=n=>{let e=setTimeout(()=>n(),500);return()=>clearTimeout(e)};typeof requestIdleCallback!="undefined"&&(XA=n=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(n,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});var Wb=typeof navigator!="undefined"&&(!((zb=navigator.scheduling)===null||zb===void 0)&&zb.isInputPending)?()=>navigator.scheduling.isInputPending():null,i4=Yt.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(In.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(In.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=XA(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEndr+1e3,l=o.context.work(()=>Wb&&Wb()||Date.now()>s,r+(a?0:1e5));this.chunkBudget-=Date.now()-t,(l||this.chunkBudget<=0)&&(o.context.takeTree(),this.view.dispatch({effects:In.setState.of(new qh(o.context))})),this.chunkBudget>0&&!(l&&!a)&&this.scheduleWork(),this.checkAsyncSchedule(o.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>It(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),cc=H.define({combine(n){return n.length?n[0]:null},enables:n=>[In.state,i4,U.contentAttributes.compute([n],e=>{let t=e.facet(n);return t&&t.name?{"data-language":t.name}:{}})]}),fy=class{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}};var r4=H.define(),fc=H.define({combine:n=>{if(!n.length)return" ";let e=n[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(n[0]));return e}});function Vh(n){let e=n.facet(fc);return e.charCodeAt(0)==9?n.tabSize*e.length:e.length}function hc(n,e){let t="",i=n.tabSize,r=n.facet(fc)[0];if(r==" "){for(;e>=i;)t+=" ",e-=i;r=" "}for(let o=0;o=e?o4(n,t,e):null}var Ks=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=Vh(e)}lineAt(e,t=1){let i=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:o}=this.options;return r!=null&&r>=i.from&&r<=i.to?o&&r==e?{text:"",from:e}:(t<0?r-1&&(o+=s-this.countColumn(i,i.search(/\S|$/))),o}countColumn(e,t=e.length){return $s(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:i,from:r}=this.lineAt(e,t),o=this.options.overrideIndentation;if(o){let s=o(r);if(s>-1)return s}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},t_=new ce;function o4(n,e,t){let i=e.resolveStack(t),r=e.resolveInner(t,-1).resolve(t,0).enterUnfinishedNodesBefore(t);if(r!=i.node){let o=[];for(let s=r;s&&!(s.fromi.node.to||s.from==i.node.from&&s.type==i.node.type);s=s.parent)o.push(s);for(let s=o.length-1;s>=0;s--)i={node:o[s],next:i}}return YA(i,n,t)}function YA(n,e,t){for(let i=n;i;i=i.next){let r=a4(i.node);if(r)return r(Xb.create(e,t,i))}return 0}function s4(n){return n.pos==n.options.simulateBreak&&n.options.simulateDoubleBreak}function a4(n){let e=n.type.prop(t_);if(e)return e;let t=n.firstChild,i;if(t&&(i=t.type.prop(ce.closedBy))){let r=n.lastChild,o=r&&i.indexOf(r.name)>-1;return s=>ZA(s,!0,1,void 0,o&&!s4(s)?r.from:void 0)}return n.parent==null?l4:null}function l4(){return 0}var Xb=class n extends Ks{constructor(e,t,i){super(e.state,e.options),this.base=e,this.pos=t,this.context=i}get node(){return this.context.node}static create(e,t,i){return new n(e,t,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let i=e.resolve(t.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(c4(i,e))break;t=this.state.doc.lineAt(i.from)}return this.lineIndent(t.from)}continue(){return YA(this.context.next,this.base,this.pos)}};function c4(n,e){for(let t=e;t;t=t.parent)if(n==t)return!0;return!1}function u4(n){let e=n.node,t=e.childAfter(e.from),i=e.lastChild;if(!t)return null;let r=n.options.simulateBreak,o=n.state.doc.lineAt(t.from),s=r==null||r<=o.from?o.to:Math.min(o.to,r);for(let a=t.to;;){let l=e.childAfter(a);if(!l||l==i)return null;if(!l.type.isSkipped){if(l.from>=s)return null;let c=/^ */.exec(o.text.slice(t.to-o.from))[0].length;return{from:t.from,to:t.to+c}}a=l.to}}function n_({closing:n,align:e=!0,units:t=1}){return i=>ZA(i,e,t,n)}function ZA(n,e,t,i,r){let o=n.textAfter,s=o.match(/^\s*/)[0].length,a=i&&o.slice(s,s+i.length)==i||r==n.pos+s,l=e?u4(n):null;return l?a?n.column(l.from):n.column(l.to):n.baseIndent+(a?0:n.unit*t)}function dy({except:n,units:e=1}={}){return t=>{let i=n&&n.test(t.textAfter);return t.baseIndent+(i?0:e*t.unit)}}var f4=200;function JA(){return Ze.transactionFilter.of(n=>{if(!n.docChanged||!n.isUserEvent("input.type")&&!n.isUserEvent("input.complete"))return n;let e=n.startState.languageDataAt("indentOnInput",n.startState.selection.main.head);if(!e.length)return n;let t=n.newDoc,{head:i}=n.newSelection.main,r=t.lineAt(i);if(i>r.from+f4)return n;let o=t.sliceString(r.from,i);if(!e.some(c=>c.test(o)))return n;let{state:s}=n,a=-1,l=[];for(let{head:c}of s.selection.ranges){let u=s.doc.lineAt(c);if(u.from==a)continue;a=u.from;let f=hy(s,u.from);if(f==null)continue;let h=/^\s*/.exec(u.text)[0],d=hc(s,f);h!=d&&l.push({from:u.from,to:u.from+h.length,insert:d})}return l.length?[n,{changes:l,sequential:!0}]:n})}var eM=new ce;function py(n){let e=n.firstChild,t=n.lastChild;return e&&e.toa.prop(lc)==s.data:s?a=>a==s:void 0,this.style=Hb(e.map(a=>({tag:a.tag,class:a.class||r(Object.assign({},a,{tag:null}))})),{all:o}).style,this.module=i?new ni(i):null,this.themeType=t.themeType}static define(e,t){return new n(e,t||{})}},Yb=H.define(),tM=H.define({combine(n){return n.length?[n[0]]:null}});function Ub(n){let e=n.facet(Yb);return e.length?e:n.facet(tM)}function nM(n,e){let t=[h4],i;return n instanceof uc&&(n.module&&t.push(U.styleModule.of(n.module)),i=n.themeType),e!=null&&e.fallback?t.push(tM.of(n)):i?t.push(Yb.computeN([U.darkTheme],r=>r.facet(U.darkTheme)==(i=="dark")?[n]:[])):t.push(Yb.of(n)),t}var Zb=class{constructor(e){this.markCache=Object.create(null),this.tree=lt(e.state),this.decorations=this.buildDeco(e,Ub(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=lt(e.state),i=Ub(e.state),r=i!=Ub(e.startState),{viewport:o}=e.view,s=e.changes.mapPos(this.decoratedTo,1);t.length=o.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=s):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,i),this.decoratedTo=o.to)}buildDeco(e,t){if(!t||!this.tree.length)return he.none;let i=new Nr;for(let{from:r,to:o}of e.visibleRanges)HA(this.tree,t,(s,a,l)=>{i.add(s,a,this.markCache[l]||(this.markCache[l]=he.mark({class:l})))},r,o);return i.finish()}},h4=$r.high(Yt.fromClass(Zb,{decorations:n=>n.decorations})),Mge=uc.define([{tag:B.meta,color:"#404740"},{tag:B.link,textDecoration:"underline"},{tag:B.heading,textDecoration:"underline",fontWeight:"bold"},{tag:B.emphasis,fontStyle:"italic"},{tag:B.strong,fontWeight:"bold"},{tag:B.strikethrough,textDecoration:"line-through"},{tag:B.keyword,color:"#708"},{tag:[B.atom,B.bool,B.url,B.contentSeparator,B.labelName],color:"#219"},{tag:[B.literal,B.inserted],color:"#164"},{tag:[B.string,B.deleted],color:"#a11"},{tag:[B.regexp,B.escape,B.special(B.string)],color:"#e40"},{tag:B.definition(B.variableName),color:"#00f"},{tag:B.local(B.variableName),color:"#30a"},{tag:[B.typeName,B.namespace],color:"#085"},{tag:B.className,color:"#167"},{tag:[B.special(B.variableName),B.macroName],color:"#256"},{tag:B.definition(B.propertyName),color:"#00c"},{tag:B.comment,color:"#940"},{tag:B.invalid,color:"#f00"}]),d4=U.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),iM=1e4,rM="()[]{}",oM=H.define({combine(n){return Io(n,{afterCursor:!0,brackets:rM,maxScanDistance:iM,renderMatch:g4})}}),p4=he.mark({class:"cm-matchingBracket"}),m4=he.mark({class:"cm-nonmatchingBracket"});function g4(n){let e=[],t=n.matched?p4:m4;return e.push(t.range(n.start.from,n.start.to)),n.end&&e.push(t.range(n.end.from,n.end.to)),e}function UA(n){let e=[],t=n.facet(oM);for(let i of n.selection.ranges){if(!i.empty)continue;let r=Ei(n,i.head,-1,t)||i.head>0&&Ei(n,i.head-1,1,t)||t.afterCursor&&(Ei(n,i.head,1,t)||i.headn.decorations}),v4=[y4,d4];function sM(n={}){return[oM.of(n),v4]}var x4=new ce;function Jb(n,e,t){let i=n.prop(e<0?ce.openedBy:ce.closedBy);if(i)return i;if(n.name.length==1){let r=t.indexOf(n.name);if(r>-1&&r%2==(e<0?1:0))return[t[r+e]]}return null}function e_(n){let e=n.type.prop(x4);return e?e(n.node):n}function Ei(n,e,t,i={}){let r=i.maxScanDistance||iM,o=i.brackets||rM,s=lt(n),a=s.resolveInner(e,t);for(let l=a;l;l=l.parent){let c=Jb(l.type,t,o);if(c&&l.from0?e>=u.from&&eu.from&&e<=u.to))return b4(n,e,t,l,u,c,o)}}return _4(n,e,t,s,a.type,r,o)}function b4(n,e,t,i,r,o,s){let a=i.parent,l={from:r.from,to:r.to},c=0,u=a==null?void 0:a.cursor();if(u&&(t<0?u.childBefore(i.from):u.childAfter(i.to)))do if(t<0?u.to<=i.from:u.from>=i.to){if(c==0&&o.indexOf(u.type.name)>-1&&u.from0)return null;let c={from:t<0?e-1:e,to:t>0?e+1:e},u=n.doc.iterRange(e,t>0?n.doc.length:0),f=0;for(let h=0;!u.next().done&&h<=o;){let d=u.value;t<0&&(h+=d.length);let p=e+h*t;for(let m=t>0?0:d.length-1,g=t>0?d.length:-1;m!=g;m+=t){let b=s.indexOf(d[m]);if(!(b<0||i.resolveInner(p+m,1).type!=r))if(b%2==0==t>0)f++;else{if(f==1)return{start:c,end:{from:p+m,to:p+m+1},matched:b>>1==l>>1};f--}}t>0&&(h+=d.length)}return u.done?{start:c,matched:!1}:null}var w4=Object.create(null),QA=[Zt.none];var KA=[],GA=Object.create(null),C4=Object.create(null);for(let[n,e]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"]])C4[n]=E4(w4,e);function Qb(n,e){KA.indexOf(n)>-1||(KA.push(n),console.warn(e))}function E4(n,e){let t=[];for(let a of e.split(" ")){let l=[];for(let c of a.split(".")){let u=n[c]||B[c];u?typeof u=="function"?l.length?l=l.map(u):Qb(c,`Modifier ${c} used at start of tag`):l.length?Qb(c,`Tag ${c} used as modifier`):l=Array.isArray(u)?u:[u]:Qb(c,`Unknown highlighting tag ${c}`)}for(let c of l)t.push(c)}if(!t.length)return 0;let i=e.replace(/ /g,"_"),r=i+" "+t.map(a=>a.id),o=GA[r];if(o)return o.id;let s=GA[r]=Zt.define({id:QA.length,name:i,props:[cy({[i]:t})]});return QA.push(s),s.id}var Pge={rtl:he.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"rtl"},bidiIsolate:We.RTL}),ltr:he.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"ltr"},bidiIsolate:We.LTR}),auto:he.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"auto"},bidiIsolate:null})};var gy=class{constructor(e,t,i,r){this.state=e,this.pos=t,this.explicit=i,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=lt(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),i=Math.max(t.from,this.pos-250),r=t.text.slice(i-t.from,this.pos-t.from),o=r.search(mM(e,!1));return o<0?null:{from:i+o,to:this.pos,text:r.slice(o)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,i){e=="abort"&&this.abortListeners&&(this.abortListeners.push(t),i&&i.onDocChange&&(this.abortOnDocChange=!0))}};function aM(n){let e=Object.keys(n).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function S4(n){let e=Object.create(null),t=Object.create(null);for(let{label:r}of n){e[r[0]]=!0;for(let o=1;otypeof r=="string"?{label:r}:r),[t,i]=e.every(r=>/^\w+$/.test(r.label))?[/\w*$/,/\w+$/]:S4(e);return r=>{let o=r.matchBefore(i);return o||r.explicit?{from:o?o.from:r.pos,options:e,validFor:t}:null}}var yy=class{constructor(e,t,i,r){this.completion=e,this.source=t,this.match=i,this.score=r}};function Xs(n){return n.selection.main.from}function mM(n,e){var t;let{source:i}=n,r=e&&i[0]!="^",o=i[i.length-1]!="$";return!r&&!o?n:new RegExp(`${r?"^":""}(?:${i})${o?"$":""}`,(t=n.flags)!==null&&t!==void 0?t:n.ignoreCase?"i":"")}var m_=Mn.define();function O4(n,e,t,i){let{main:r}=n.selection,o=t-r.from,s=i-r.from;return{...n.changeByRange(a=>{if(a!=r&&t!=i&&n.sliceDoc(a.from+o,a.from+s)!=n.sliceDoc(t,i))return{range:a};let l=n.toText(e);return{changes:{from:a.from+o,to:i==r.from?a.to:a.from+s,insert:l},range:$.cursor(a.from+o+l.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}var lM=new WeakMap;function k4(n){if(!Array.isArray(n))return n;let e=lM.get(n);return e||lM.set(n,e=pc(n)),e}var vy=de.define(),Hh=de.define(),s_=class{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t=48&&C<=57||C>=97&&C<=122?2:C>=65&&C<=90?1:0:(E=E0(C))!=E.toLowerCase()?1:E!=E.toUpperCase()?2:0;(!_||S==1&&g||x==0&&S!=0)&&(t[f]==C||i[f]==C&&(h=!0)?s[f++]=_:s.length&&(b=!1)),x=S,_+=Yi(C)}return f==l&&s[0]==0&&b?this.result(-100+(h?-200:0),s,e):d==l&&p==0?this.ret(-200-e.length+(m==e.length?0:-100),[0,m]):a>-1?this.ret(-700-e.length,[a,a+this.pattern.length]):d==l?this.ret(-900-e.length,[p,m]):f==l?this.result(-100+(h?-200:0)+-700+(b?0:-1100),s,e):t.length==2?null:this.result((r[0]?-700:0)+-200+-1100,r,e)}result(e,t,i){let r=[],o=0;for(let s of t){let a=s+(this.astral?Yi(ti(i,s)):1);o&&r[o-1]==s?r[o-1]=a:(r[o++]=s,r[o++]=a)}return this.ret(e-i.length,r)}},a_=class{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:R4,filterStrict:!1,compareCompletions:(e,t)=>(e.sortText||e.label).localeCompare(t.sortText||t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>i=>cM(e(i),t(i)),optionClass:(e,t)=>i=>cM(e(i),t(i)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function cM(n,e){return n?e?n+" "+e:n:e}function R4(n,e,t,i,r,o){let s=n.textDirection==We.RTL,a=s,l=!1,c="top",u,f,h=e.left-r.left,d=r.right-e.right,p=i.right-i.left,m=i.bottom-i.top;if(a&&h=m||_>e.top?u=t.bottom-e.top:(c="bottom",u=e.bottom-t.top)}let g=(e.bottom-e.top)/o.offsetHeight,b=(e.right-e.left)/o.offsetWidth;return{style:`${c}: ${u/g}px; max-width: ${f/b}px`,class:"cm-completionInfo-"+(l?s?"left-narrow":"right-narrow":a?"left":"right")}}var g_=de.define();function T4(n){let e=n.addToOptions.slice();return n.icons&&e.push({render(t){let i=document.createElement("div");return i.classList.add("cm-completionIcon"),t.type&&i.classList.add(...t.type.split(/\s+/g).map(r=>"cm-completionIcon-"+r)),i.setAttribute("aria-hidden","true"),i},position:20}),e.push({render(t,i,r,o){let s=document.createElement("span");s.className="cm-completionLabel";let a=t.displayLabel||t.label,l=0;for(let c=0;cl&&s.appendChild(document.createTextNode(a.slice(l,u)));let h=s.appendChild(document.createElement("span"));h.appendChild(document.createTextNode(a.slice(u,f))),h.className="cm-completionMatchedText",l=f}return lt.position-i.position).map(t=>t.render)}function i_(n,e,t){if(n<=t)return{from:0,to:n};if(e<0&&(e=0),e<=n>>1){let r=Math.floor(e/t);return{from:r*t,to:(r+1)*t}}let i=Math.ceil((n-e)/t);return{from:n-i*t,to:n-(i-1)*t}}var l_=class{constructor(e,t,i){this.view=e,this.stateField=t,this.applyCompletion=i,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:l=>this.placeInfo(l),key:this},this.space=null,this.currentClass="";let r=e.state.field(t),{options:o,selected:s}=r.open,a=e.state.facet(Lt);this.optionContent=T4(a),this.optionClass=a.optionClass,this.tooltipClass=a.tooltipClass,this.range=i_(o.length,s,a.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",l=>{let{options:c}=e.state.field(t).open;for(let u=l.target,f;u&&u!=this.dom;u=u.parentNode)if(u.nodeName=="LI"&&(f=/-(\d+)$/.exec(u.id))&&+f[1]this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;u!=null&&(e.dispatch({effects:g_.of(u)}),l.preventDefault())}}),this.dom.addEventListener("focusout",l=>{let c=e.state.field(this.stateField,!1);c&&c.tooltip&&e.state.facet(Lt).closeOnBlur&&l.relatedTarget!=e.contentDOM&&e.dispatch({effects:Hh.of(null)})}),this.showOptions(o,r.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var t;let i=e.state.field(this.stateField),r=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),i!=r){let{options:o,selected:s,disabled:a}=i.open;(!r.open||r.open.options!=o)&&(this.range=i_(o.length,s,e.state.facet(Lt).maxRenderedOptions),this.showOptions(o,i.id)),this.updateSel(),a!=((t=r.open)===null||t===void 0?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!a)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let i of this.currentClass.split(" "))i&&this.dom.classList.remove(i);for(let i of t.split(" "))i&&this.dom.classList.add(i);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected=this.range.to)&&(this.range=i_(t.options.length,t.selected,this.view.state.facet(Lt).maxRenderedOptions),this.showOptions(t.options,e.id));let i=this.updateSelectedOption(t.selected);if(i){this.destroyInfo();let{completion:r}=t.options[t.selected],{info:o}=r;if(!o)return;let s=typeof o=="string"?document.createTextNode(o):o(r);if(!s)return;"then"in s?s.then(a=>{a&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(a,r)}).catch(a=>It(this.view.state,a,"completion info")):(this.addInfoPane(s,r),i.setAttribute("aria-describedby",this.info.id))}}addInfoPane(e,t){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",i.id="cm-completionInfo-"+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)i.appendChild(e),this.infoDestroy=null;else{let{dom:r,destroy:o}=e;i.appendChild(r),this.infoDestroy=o||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let i=this.list.firstChild,r=this.range.from;i;i=i.nextSibling,r++)i.nodeName!="LI"||!i.id?r--:r==e?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),t=i):i.hasAttribute("aria-selected")&&(i.removeAttribute("aria-selected"),i.removeAttribute("aria-describedby"));return t&&M4(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),r=e.getBoundingClientRect(),o=this.space;if(!o){let s=this.dom.ownerDocument.documentElement;o={left:0,top:0,right:s.clientWidth,bottom:s.clientHeight}}return r.top>Math.min(o.bottom,t.bottom)-10||r.bottom{s.target==r&&s.preventDefault()});let o=null;for(let s=i.from;si.from||i.from==0))if(o=h,typeof c!="string"&&c.header)r.appendChild(c.header(c));else{let d=r.appendChild(document.createElement("completion-section"));d.textContent=h}}let u=r.appendChild(document.createElement("li"));u.id=t+"-"+s,u.setAttribute("role","option");let f=this.optionClass(a);f&&(u.className=f);for(let h of this.optionContent){let d=h(a,this.view.state,this.view,l);d&&u.appendChild(d)}}return i.from&&r.classList.add("cm-completionListIncompleteTop"),i.tonew l_(t,n,e)}function M4(n,e){let t=n.getBoundingClientRect(),i=e.getBoundingClientRect(),r=t.height/n.offsetHeight;i.topt.bottom&&(n.scrollTop+=(i.bottom-t.bottom)/r)}function uM(n){return(n.boost||0)*100+(n.apply?10:0)+(n.info?5:0)+(n.type?1:0)}function P4(n,e){let t=[],i=null,r=null,o=u=>{t.push(u);let{section:f}=u.completion;if(f){i||(i=[]);let h=typeof f=="string"?f:f.name;i.some(d=>d.name==h)||i.push(typeof f=="string"?{name:h}:f)}},s=e.facet(Lt);for(let u of n)if(u.hasResult()){let f=u.result.getMatch;if(u.result.filter===!1)for(let h of u.result.options)o(new yy(h,u.source,f?f(h):[],1e9-t.length));else{let h=e.sliceDoc(u.from,u.to),d,p=s.filterStrict?new a_(h):new s_(h);for(let m of u.result.options)if(d=p.match(m.label)){let g=m.displayLabel?f?f(m,d.matched):[]:d.matched,b=d.score+(m.boost||0);if(o(new yy(m,u.source,g,b)),typeof m.section=="object"&&m.section.rank==="dynamic"){let{name:_}=m.section;r||(r=Object.create(null)),r[_]=Math.max(b,r[_]||-1e9)}}}}if(i){let u=Object.create(null),f=0,h=(d,p)=>(d.rank==="dynamic"&&p.rank==="dynamic"?r[p.name]-r[d.name]:0)||(typeof d.rank=="number"?d.rank:1e9)-(typeof p.rank=="number"?p.rank:1e9)||(d.nameh.score-f.score||c(f.completion,h.completion))){let f=u.completion;!l||l.label!=f.label||l.detail!=f.detail||l.type!=null&&f.type!=null&&l.type!=f.type||l.apply!=f.apply||l.boost!=f.boost?a.push(u):uM(u.completion)>uM(l)&&(a[a.length-1]=u),l=u.completion}return a}var c_=class n{constructor(e,t,i,r,o,s){this.options=e,this.attrs=t,this.tooltip=i,this.timestamp=r,this.selected=o,this.disabled=s}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new n(this.options,fM(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,i,r,o,s){if(r&&!s&&e.some(c=>c.isPending))return r.setDisabled();let a=P4(e,t);if(!a.length)return r&&e.some(c=>c.isPending)?r.setDisabled():null;let l=t.facet(Lt).selectOnOpen?0:-1;if(r&&r.selected!=l&&r.selected!=-1){let c=r.options[r.selected].completion;for(let u=0;uu.hasResult()?Math.min(c,u.from):c,1e8),create:$4,above:o.aboveCursor},r?r.timestamp:Date.now(),l,!1)}map(e){return new n(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new n(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}},u_=class n{constructor(e,t,i){this.active=e,this.id=t,this.open=i}static start(){return new n(B4,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,i=t.facet(Lt),o=(i.override||t.languageDataAt("autocomplete",Xs(t)).map(k4)).map(l=>(this.active.find(u=>u.source==l)||new Hr(l,this.active.some(u=>u.state!=0)?1:0)).update(e,i));o.length==this.active.length&&o.every((l,c)=>l==this.active[c])&&(o=this.active);let s=this.open,a=e.effects.some(l=>l.is(y_));s&&e.docChanged&&(s=s.map(e.changes)),e.selection||o.some(l=>l.hasResult()&&e.changes.touchesRange(l.from,l.to))||!D4(o,this.active)||a?s=c_.build(o,t,this.id,s,i,a):s&&s.disabled&&!o.some(l=>l.isPending)&&(s=null),!s&&o.every(l=>!l.isPending)&&o.some(l=>l.hasResult())&&(o=o.map(l=>l.hasResult()?new Hr(l.source,0):l));for(let l of e.effects)l.is(g_)&&(s=s&&s.setSelected(l.value,this.id));return o==this.active&&s==this.open?this:new n(o,this.id,s)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?I4:L4}};function D4(n,e){if(n==e)return!0;for(let t=0,i=0;;){for(;t-1&&(t["aria-activedescendant"]=n+"-"+e),t}var B4=[];function gM(n,e){if(n.isUserEvent("input.complete")){let i=n.annotation(m_);if(i&&e.activateOnCompletion(i))return 12}let t=n.isUserEvent("input.type");return t&&e.activateOnTyping?5:t?1:n.isUserEvent("delete.backward")?2:n.selection?8:n.docChanged?16:0}var Hr=class n{constructor(e,t,i=!1){this.source=e,this.state=t,this.explicit=i}hasResult(){return!1}get isPending(){return this.state==1}update(e,t){let i=gM(e,t),r=this;(i&8||i&16&&this.touches(e))&&(r=new n(r.source,0)),i&4&&r.state==0&&(r=new n(this.source,1)),r=r.updateFor(e,i);for(let o of e.effects)if(o.is(vy))r=new n(r.source,1,o.value);else if(o.is(Hh))r=new n(r.source,0);else if(o.is(y_))for(let s of o.value)s.source==r.source&&(r=s);return r}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(Xs(e.state))}},xy=class n extends Hr{constructor(e,t,i,r,o,s){super(e,3,t),this.limit=i,this.result=r,this.from=o,this.to=s}hasResult(){return!0}updateFor(e,t){var i;if(!(t&3))return this.map(e.changes);let r=this.result;r.map&&!e.changes.empty&&(r=r.map(r,e.changes));let o=e.changes.mapPos(this.from),s=e.changes.mapPos(this.to,1),a=Xs(e.state);if(a>s||!r||t&2&&(Xs(e.startState)==this.from||at.map(e))}}),wn=qt.define({create(){return u_.start()},update(n,e){return n.update(e)},provide:n=>[Dh.from(n,e=>e.tooltip),U.contentAttributes.from(n,e=>e.attrs)]});function v_(n,e){let t=e.completion.apply||e.completion.label,i=n.state.field(wn).active.find(r=>r.source==e.source);return i instanceof xy?(typeof t=="string"?n.dispatch({...O4(n.state,t,i.from,i.to),annotations:m_.of(e.completion)}):t(n,e.completion,i.from,i.to),!0):!1}var $4=A4(wn,v_);function my(n,e="option"){return t=>{let i=t.state.field(wn,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp-1?i.open.selected+r*(n?1:-1):n?0:s-1;return a<0?a=e=="page"?0:s-1:a>=s&&(a=e=="page"?s-1:0),t.dispatch({effects:g_.of(a)}),!0}}var j4=n=>{let e=n.state.field(wn,!1);return n.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestampn.state.field(wn,!1)?(n.dispatch({effects:vy.of(!0)}),!0):!1,F4=n=>{let e=n.state.field(wn,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(n.dispatch({effects:Hh.of(null)}),!0)},f_=class{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}},q4=50,V4=1e3,H4=Yt.fromClass(class{constructor(n){this.view=n,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of n.state.field(wn).active)e.isPending&&this.startQuery(e)}update(n){let e=n.state.field(wn),t=n.state.facet(Lt);if(!n.selectionSet&&!n.docChanged&&n.startState.field(wn)==e)return;let i=n.transactions.some(o=>{let s=gM(o,t);return s&8||(o.selection||o.docChanged)&&!(s&3)});for(let o=0;oq4&&Date.now()-s.time>V4){for(let a of s.context.abortListeners)try{a()}catch(l){It(this.view.state,l)}s.context.abortListeners=null,this.running.splice(o--,1)}else s.updates.push(...n.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),n.transactions.some(o=>o.effects.some(s=>s.is(vy)))&&(this.pendingStart=!0);let r=this.pendingStart?50:t.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(o=>o.isPending&&!this.running.some(s=>s.active.source==o.source))?setTimeout(()=>this.startUpdate(),r):-1,this.composing!=0)for(let o of n.transactions)o.isUserEvent("input.type")?this.composing=2:this.composing==2&&o.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:n}=this.view,e=n.field(wn);for(let t of e.active)t.isPending&&!this.running.some(i=>i.active.source==t.source)&&this.startQuery(t);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Lt).updateSyncTime))}startQuery(n){let{state:e}=this.view,t=Xs(e),i=new gy(e,t,n.explicit,this.view),r=new f_(n,i);this.running.push(r),Promise.resolve(n.source(i)).then(o=>{r.context.aborted||(r.done=o||null,this.scheduleAccept())},o=>{this.view.dispatch({effects:Hh.of(null)}),It(this.view.state,o)})}scheduleAccept(){this.running.every(n=>n.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Lt).updateSyncTime))}accept(){var n;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(Lt),i=this.view.state.field(wn);for(let r=0;ra.source==o.active.source);if(s&&s.isPending)if(o.done==null){let a=new Hr(o.active.source,0);for(let l of o.updates)a=a.update(l,t);a.isPending||e.push(a)}else this.startQuery(s)}(e.length||i.open&&i.open.disabled)&&this.view.dispatch({effects:y_.of(e)})}},{eventHandlers:{blur(n){let e=this.view.state.field(wn,!1);if(e&&e.tooltip&&this.view.state.facet(Lt).closeOnBlur){let t=e.open&&Pb(this.view,e.open.tooltip);(!t||!t.dom.contains(n.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:Hh.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:vy.of(!1)}),20),this.composing=0}}}),z4=typeof navigator=="object"&&/Win/.test(navigator.platform),W4=$r.highest(U.domEventHandlers({keydown(n,e){let t=e.state.field(wn,!1);if(!t||!t.open||t.open.disabled||t.open.selected<0||n.key.length>1||n.ctrlKey&&!(z4&&n.altKey)||n.metaKey)return!1;let i=t.open.options[t.open.selected],r=t.active.find(s=>s.source==i.source),o=i.completion.commitCharacters||r.result.commitCharacters;return o&&o.indexOf(n.key)>-1&&v_(e,i),!1}})),yM=U.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"\xB7\xB7\xB7"',opacity:.5,display:"block",textAlign:"center",cursor:"pointer"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'\u0192'"}},".cm-completionIcon-class":{"&:after":{content:"'\u25CB'"}},".cm-completionIcon-interface":{"&:after":{content:"'\u25CC'"}},".cm-completionIcon-variable":{"&:after":{content:"'\u{1D465}'"}},".cm-completionIcon-constant":{"&:after":{content:"'\u{1D436}'"}},".cm-completionIcon-type":{"&:after":{content:"'\u{1D461}'"}},".cm-completionIcon-enum":{"&:after":{content:"'\u222A'"}},".cm-completionIcon-property":{"&:after":{content:"'\u25A1'"}},".cm-completionIcon-keyword":{"&:after":{content:"'\u{1F511}\uFE0E'"}},".cm-completionIcon-namespace":{"&:after":{content:"'\u25A2'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}}),h_=class{constructor(e,t,i,r){this.field=e,this.line=t,this.from=i,this.to=r}},d_=class n{constructor(e,t,i){this.field=e,this.from=t,this.to=i}map(e){let t=e.mapPos(this.from,-1,Ot.TrackDel),i=e.mapPos(this.to,1,Ot.TrackDel);return t==null||i==null?null:new n(this.field,t,i)}},p_=class n{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let i=[],r=[t],o=e.doc.lineAt(t),s=/^\s*/.exec(o.text)[0];for(let l of this.lines){if(i.length){let c=s,u=/^\t*/.exec(l)[0].length;for(let f=0;fnew d_(l.field,r[l.line]+l.from,r[l.line]+l.to));return{text:i,ranges:a}}static parse(e){let t=[],i=[],r=[],o;for(let s of e.split(/\r\n?|\n/)){for(;o=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(s);){let a=o[1]?+o[1]:null,l=o[2]||o[3]||"",c=-1;a===0&&(a=1e9);let u=l.replace(/\\[{}]/g,f=>f[1]);for(let f=0;f=c&&h.field++}for(let f of r)if(f.line==i.length&&f.from>o.index){let h=o[2]?3+(o[1]||"").length:2;f.from-=h,f.to-=h}r.push(new h_(c,i.length,o.index,o.index+u.length)),s=s.slice(0,o.index)+l+s.slice(o.index+o[0].length)}s=s.replace(/\\([{}])/g,(a,l,c)=>{for(let u of r)u.line==i.length&&u.from>c&&(u.from--,u.to--);return l}),i.push(s)}return new n(i,r)}},U4=he.widget({widget:new class extends ai{toDOM(){let n=document.createElement("span");return n.className="cm-snippetFieldPosition",n}ignoreEvent(){return!1}}}),Q4=he.mark({class:"cm-snippetField"}),dc=class n{constructor(e,t){this.ranges=e,this.active=t,this.deco=he.set(e.map(i=>(i.from==i.to?U4:Q4).range(i.from,i.to)),!0)}map(e){let t=[];for(let i of this.ranges){let r=i.map(e);if(!r)return null;t.push(r)}return new n(t,this.active)}selectionInsideField(e){return e.ranges.every(t=>this.ranges.some(i=>i.field==this.active&&i.from<=t.from&&i.to>=t.to))}},Wh=de.define({map(n,e){return n&&n.map(e)}}),K4=de.define(),zh=qt.define({create(){return null},update(n,e){for(let t of e.effects){if(t.is(Wh))return t.value;if(t.is(K4)&&n)return new dc(n.ranges,t.value)}return n&&e.docChanged&&(n=n.map(e.changes)),n&&e.selection&&!n.selectionInsideField(e.selection)&&(n=null),n},provide:n=>U.decorations.from(n,e=>e?e.deco:he.none)});function x_(n,e){return $.create(n.filter(t=>t.field==e).map(t=>$.range(t.from,t.to)))}function G4(n){let e=p_.parse(n);return(t,i,r,o)=>{let{text:s,ranges:a}=e.instantiate(t.state,r),{main:l}=t.state.selection,c={changes:{from:r,to:o==l.from?l.to:o,insert:be.of(s)},scrollIntoView:!0,annotations:i?[m_.of(i),Ft.userEvent.of("input.complete")]:void 0};if(a.length&&(c.selection=x_(a,0)),a.some(u=>u.field>0)){let u=new dc(a,0),f=c.effects=[Wh.of(u)];t.state.field(zh,!1)===void 0&&f.push(de.appendConfig.of([zh,eH,tH,yM]))}t.dispatch(t.state.update(c))}}function vM(n){return({state:e,dispatch:t})=>{let i=e.field(zh,!1);if(!i||n<0&&i.active==0)return!1;let r=i.active+n,o=n>0&&!i.ranges.some(s=>s.field==r+n);return t(e.update({selection:x_(i.ranges,r),effects:Wh.of(o?null:new dc(i.ranges,r)),scrollIntoView:!0})),!0}}var X4=({state:n,dispatch:e})=>n.field(zh,!1)?(e(n.update({effects:Wh.of(null)})),!0):!1,Y4=vM(1),Z4=vM(-1);var J4=[{key:"Tab",run:Y4,shift:Z4},{key:"Escape",run:X4}],hM=H.define({combine(n){return n.length?n[0]:J4}}),eH=$r.highest(sc.compute([hM],n=>n.facet(hM)));function li(n,e){return{...e,apply:G4(n)}}var tH=U.domEventHandlers({mousedown(n,e){let t=e.state.field(zh,!1),i;if(!t||(i=e.posAtCoords({x:n.clientX,y:n.clientY}))==null)return!1;let r=t.ranges.find(o=>o.from<=i&&o.to>=i);return!r||r.field==t.active?!1:(e.dispatch({selection:x_(t.ranges,r.field),effects:Wh.of(t.ranges.some(o=>o.field>r.field)?new dc(t.ranges,r.field):null),scrollIntoView:!0}),!0)}});var by={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Gs=de.define({map(n,e){let t=e.mapPos(n,-1,Ot.TrackAfter);return t==null?void 0:t}}),b_=new class extends ei{};b_.startSide=1;b_.endSide=-1;var xM=qt.define({create(){return Be.empty},update(n,e){if(n=n.map(e.changes),e.selection){let t=e.state.doc.lineAt(e.selection.main.head);n=n.update({filter:i=>i>=t.from&&i<=t.to})}for(let t of e.effects)t.is(Gs)&&(n=n.update({add:[b_.range(t.value,t.value+1)]}));return n}});function bM(){return[oH,xM]}var o_="()[]{}<>\xAB\xBB\xBB\xAB\uFF3B\uFF3D\uFF5B\uFF5D";function nH(n){for(let e=0;e{if((rH?n.composing:n.compositionStarted)||n.state.readOnly)return!1;let r=n.state.selection.main;if(i.length>2||i.length==2&&Yi(ti(i,0))==1||e!=r.from||t!=r.to)return!1;let o=sH(n.state,i);return o?(n.dispatch(o),!0):!1});function sH(n,e){let t=iH(n,n.selection.main.head),i=t.brackets||by.brackets;for(let r of i){let o=nH(ti(r,0));if(e==r)return o==r?cH(n,r,i.indexOf(r+r+r)>-1,t):aH(n,r,o,t.before||by.before);if(e==o&&_M(n,n.selection.main.from))return lH(n,r,o)}return null}function _M(n,e){let t=!1;return n.field(xM).between(0,n.doc.length,i=>{i==e&&(t=!0)}),t}function __(n,e){let t=n.sliceString(e,e+2);return t.slice(0,Yi(ti(t,0)))}function aH(n,e,t,i){let r=null,o=n.changeByRange(s=>{if(!s.empty)return{changes:[{insert:e,from:s.from},{insert:t,from:s.to}],effects:Gs.of(s.to+e.length),range:$.range(s.anchor+e.length,s.head+e.length)};let a=__(n.doc,s.head);return!a||/\s/.test(a)||i.indexOf(a)>-1?{changes:{insert:e+t,from:s.head},effects:Gs.of(s.head+e.length),range:$.cursor(s.head+e.length)}:{range:r=s}});return r?null:n.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function lH(n,e,t){let i=null,r=n.changeByRange(o=>o.empty&&__(n.doc,o.head)==t?{changes:{from:o.head,to:o.head+t.length,insert:t},range:$.cursor(o.head+t.length)}:i={range:o});return i?null:n.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function cH(n,e,t,i){let r=i.stringPrefixes||by.stringPrefixes,o=null,s=n.changeByRange(a=>{if(!a.empty)return{changes:[{insert:e,from:a.from},{insert:e,from:a.to}],effects:Gs.of(a.to+e.length),range:$.range(a.anchor+e.length,a.head+e.length)};let l=a.head,c=__(n.doc,l),u;if(c==e){if(dM(n,l))return{changes:{insert:e+e,from:l},effects:Gs.of(l+e.length),range:$.cursor(l+e.length)};if(_M(n,l)){let h=t&&n.sliceDoc(l,l+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:l,to:l+h.length,insert:h},range:$.cursor(l+h.length)}}}else{if(t&&n.sliceDoc(l-2*e.length,l)==e+e&&(u=pM(n,l-2*e.length,r))>-1&&dM(n,u))return{changes:{insert:e+e+e+e,from:l},effects:Gs.of(l+e.length),range:$.cursor(l+e.length)};if(n.charCategorizer(l)(c)!=ln.Word&&pM(n,l,r)>-1&&!uH(n,l,e,r))return{changes:{insert:e+e,from:l},effects:Gs.of(l+e.length),range:$.cursor(l+e.length)}}return{range:o=a}});return o?null:n.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function dM(n,e){let t=lt(n).resolveInner(e+1);return t.parent&&t.from==e}function uH(n,e,t,i){let r=lt(n).resolveInner(e,-1),o=i.reduce((s,a)=>Math.max(s,a.length),0);for(let s=0;s<5;s++){let a=n.sliceDoc(r.from,Math.min(r.to,r.from+t.length+o)),l=a.indexOf(t);if(!l||l>-1&&i.indexOf(a.slice(0,l))>-1){let u=r.firstChild;for(;u&&u.from==r.from&&u.to-u.from>t.length+l;){if(n.sliceDoc(u.to-t.length,u.to)==t)return!1;u=u.firstChild}return!0}let c=r.to==e&&r.parent;if(!c)break;r=c}return!1}function pM(n,e,t){let i=n.charCategorizer(e);if(i(n.sliceDoc(e-1,e))!=ln.Word)return e;for(let r of t){let o=e-r.length;if(n.sliceDoc(o,e)==r&&i(n.sliceDoc(o-1,o))!=ln.Word)return o}return-1}function wM(n={}){return[W4,wn,Lt.of(n),H4,hH,yM]}var fH=[{key:"Ctrl-Space",run:r_},{mac:"Alt-`",run:r_},{mac:"Alt-i",run:r_},{key:"Escape",run:F4},{key:"ArrowDown",run:my(!0)},{key:"ArrowUp",run:my(!1)},{key:"PageDown",run:my(!0,"page")},{key:"PageUp",run:my(!1,"page")},{key:"Enter",run:j4}],hH=$r.highest(sc.computeN([Lt],n=>n.facet(Lt).defaultKeymap?[fH]:[]));var dH=n=>{let{state:e}=n,t=e.doc.lineAt(e.selection.main.from),i=k_(n.state,t.from);return i.line?pH(n):i.block?gH(n):!1};function O_(n,e){return({state:t,dispatch:i})=>{if(t.readOnly)return!1;let r=n(e,t);return r?(i(t.update(r)),!0):!1}}var pH=O_(xH,0);var mH=O_(PM,0);var gH=O_((n,e)=>PM(n,e,vH(e)),0);function k_(n,e){let t=n.languageDataAt("commentTokens",e,1);return t.length?t[0]:{}}var Uh=50;function yH(n,{open:e,close:t},i,r){let o=n.sliceDoc(i-Uh,i),s=n.sliceDoc(r,r+Uh),a=/\s*$/.exec(o)[0].length,l=/^\s*/.exec(s)[0].length,c=o.length-a;if(o.slice(c-e.length,c)==e&&s.slice(l,l+t.length)==t)return{open:{pos:i-a,margin:a&&1},close:{pos:r+l,margin:l&&1}};let u,f;r-i<=2*Uh?u=f=n.sliceDoc(i,r):(u=n.sliceDoc(i,i+Uh),f=n.sliceDoc(r-Uh,r));let h=/^\s*/.exec(u)[0].length,d=/\s*$/.exec(f)[0].length,p=f.length-d-t.length;return u.slice(h,h+e.length)==e&&f.slice(p,p+t.length)==t?{open:{pos:i+h+e.length,margin:/\s/.test(u.charAt(h+e.length))?1:0},close:{pos:r-d-t.length,margin:/\s/.test(f.charAt(p-1))?1:0}}:null}function vH(n){let e=[];for(let t of n.selection.ranges){let i=n.doc.lineAt(t.from),r=t.to<=i.to?i:n.doc.lineAt(t.to);r.from>i.from&&r.from==t.to&&(r=t.to==i.to+1?i:n.doc.lineAt(t.to-1));let o=e.length-1;o>=0&&e[o].to>i.from?e[o].to=r.to:e.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:r.to})}return e}function PM(n,e,t=e.selection.ranges){let i=t.map(o=>k_(e,o.from).block);if(!i.every(o=>o))return null;let r=t.map((o,s)=>yH(e,i[s],o.from,o.to));if(n!=2&&!r.every(o=>o))return{changes:e.changes(t.map((o,s)=>r[s]?[]:[{from:o.from,insert:i[s].open+" "},{from:o.to,insert:" "+i[s].close}]))};if(n!=1&&r.some(o=>o)){let o=[];for(let s=0,a;sr&&(o==s||s>f.from)){r=f.from;let h=/^\s*/.exec(f.text)[0].length,d=h==f.length,p=f.text.slice(h,h+c.length)==c?h:-1;ho.comment<0&&(!o.empty||o.single))){let o=[];for(let{line:a,token:l,indent:c,empty:u,single:f}of i)(f||!u)&&o.push({from:a.from+c,insert:l+" "});let s=e.changes(o);return{changes:s,selection:e.selection.map(s,1)}}else if(n!=1&&i.some(o=>o.comment>=0)){let o=[];for(let{line:s,comment:a,token:l}of i)if(a>=0){let c=s.from+a,u=c+l.length;s.text[u-s.from]==" "&&u++,o.push({from:c,to:u})}return{changes:o}}return null}var CM=Mn.define();var bH=H.define();var Ys=class n{constructor(e,t,i,r,o){this.changes=e,this.effects=t,this.mapped=i,this.startSelection=r,this.selectionsAfter=o}setSelAfter(e){return new n(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,i;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(i=this.startSelection)===null||i===void 0?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(r=>r.toJSON())}}static fromJSON(e){return new n(e.changes&&cn.fromJSON(e.changes),[],e.mapped&&Br.fromJSON(e.mapped),e.startSelection&&$.fromJSON(e.startSelection),e.selectionsAfter.map($.fromJSON))}static fromTransaction(e,t){let i=ci;for(let r of e.startState.facet(bH)){let o=r(e);o.length&&(i=i.concat(o))}return!i.length&&e.changes.empty?null:new n(e.changes.invert(e.startState.doc),i,void 0,t||e.startState.selection,ci)}static selection(e){return new n(void 0,ci,void 0,void 0,e)}};function C_(n,e,t,i){let r=e+1>t+20?e-t-1:0,o=n.slice(r,e);return o.push(i),o}function _H(n,e){let t=[],i=!1;return n.iterChangedRanges((r,o)=>t.push(r,o)),e.iterChangedRanges((r,o,s,a)=>{for(let l=0;l=c&&s<=u&&(i=!0)}}),i}function wH(n,e){return n.ranges.length==e.ranges.length&&n.ranges.filter((t,i)=>t.empty!=e.ranges[i].empty).length===0}function DM(n,e){return n.length?e.length?n.concat(e):n:e}var ci=[],CH=200;function EH(n,e){if(n.length){let t=n[n.length-1],i=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-CH));return i.length&&i[i.length-1].eq(e)?n:(i.push(e),C_(n,n.length-1,1e9,t.setSelAfter(i)))}else return[Ys.selection([e])]}function SH(n){let e=n[n.length-1],t=n.slice();return t[n.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function w_(n,e){if(!n.length)return n;let t=n.length,i=ci;for(;t;){let r=OH(n[t-1],e,i);if(r.changes&&!r.changes.empty||r.effects.length){let o=n.slice(0,t);return o[t-1]=r,o}else e=r.mapped,t--,i=r.selectionsAfter}return i.length?[Ys.selection(i)]:ci}function OH(n,e,t){let i=DM(n.selectionsAfter.length?n.selectionsAfter.map(a=>a.map(e)):ci,t);if(!n.changes)return Ys.selection(i);let r=n.changes.map(e),o=e.mapDesc(n.changes,!0),s=n.mapped?n.mapped.composeDesc(o):o;return new Ys(r,de.mapEffects(n.effects,e),s,n.startSelection.map(o),i)}var kH=/^(input\.type|delete)($|\.)/,wy=class n{constructor(e,t,i=0,r=void 0){this.done=e,this.undone=t,this.prevTime=i,this.prevUserEvent=r}isolate(){return this.prevTime?new n(this.done,this.undone):this}addChanges(e,t,i,r,o){let s=this.done,a=s[s.length-1];return a&&a.changes&&!a.changes.empty&&e.changes&&(!i||kH.test(i))&&(!a.selectionsAfter.length&&t-this.prevTime0&&t-this.prevTimet.empty?n.moveByChar(t,e):Cy(t,e))}function Jt(n){return n.textDirectionAt(n.state.selection.main.head)==We.LTR}var LM=n=>IM(n,!Jt(n)),BM=n=>IM(n,Jt(n));function NM(n,e){return Oi(n,t=>t.empty?n.moveByGroup(t,e):Cy(t,e))}var RH=n=>NM(n,!Jt(n)),TH=n=>NM(n,Jt(n));var Qge=typeof Intl!="undefined"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;function AH(n,e,t){if(e.type.prop(t))return!0;let i=e.to-e.from;return i&&(i>2||/[^\s,.;:]/.test(n.sliceDoc(e.from,e.to)))||e.firstChild}function Ey(n,e,t){let i=lt(n).resolveInner(e.head),r=t?ce.closedBy:ce.openedBy;for(let l=e.head;;){let c=t?i.childAfter(l):i.childBefore(l);if(!c)break;AH(n,c,r)?i=c:l=t?c.to:c.from}let o=i.type.prop(r),s,a;return o&&(s=t?Ei(n,i.from,1):Ei(n,i.to,-1))&&s.matched?a=t?s.end.to:s.end.from:a=t?i.to:i.from,$.cursor(a,t?-1:1)}var MH=n=>Oi(n,e=>Ey(n.state,e,!Jt(n))),PH=n=>Oi(n,e=>Ey(n.state,e,Jt(n)));function $M(n,e){return Oi(n,t=>{if(!t.empty)return Cy(t,e);let i=n.moveVertically(t,e);return i.head!=t.head?i:n.moveToLineBoundary(t,e)})}var jM=n=>$M(n,!1),FM=n=>$M(n,!0);function qM(n){let e=n.scrollDOM.clientHeights.empty?n.moveVertically(s,e,t.height):Cy(s,e));if(r.eq(i.selection))return!1;let o;if(t.selfScroll){let s=n.coordsAtPos(i.selection.main.head),a=n.scrollDOM.getBoundingClientRect(),l=a.top+t.marginTop,c=a.bottom-t.marginBottom;s&&s.top>l&&s.bottomVM(n,!1),E_=n=>VM(n,!0);function Vo(n,e,t){let i=n.lineBlockAt(e.head),r=n.moveToLineBoundary(e,t);if(r.head==e.head&&r.head!=(t?i.to:i.from)&&(r=n.moveToLineBoundary(e,t,!1)),!t&&r.head==i.from&&i.length){let o=/^\s*/.exec(n.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;o&&e.head!=i.from+o&&(r=$.cursor(i.from+o))}return r}var DH=n=>Oi(n,e=>Vo(n,e,!0)),IH=n=>Oi(n,e=>Vo(n,e,!1)),LH=n=>Oi(n,e=>Vo(n,e,!Jt(n))),BH=n=>Oi(n,e=>Vo(n,e,Jt(n))),NH=n=>Oi(n,e=>$.cursor(n.lineBlockAt(e.head).from,1)),$H=n=>Oi(n,e=>$.cursor(n.lineBlockAt(e.head).to,-1));function jH(n,e,t){let i=!1,r=mc(n.selection,o=>{let s=Ei(n,o.head,-1)||Ei(n,o.head,1)||o.head>0&&Ei(n,o.head-1,1)||o.headjH(n,e,!1);function ui(n,e){let t=mc(n.state.selection,i=>{let r=e(i);return $.range(i.anchor,r.head,r.goalColumn,r.bidiLevel||void 0,r.assoc)});return t.eq(n.state.selection)?!1:(n.dispatch(Si(n.state,t)),!0)}function HM(n,e){return ui(n,t=>n.moveByChar(t,e))}var zM=n=>HM(n,!Jt(n)),WM=n=>HM(n,Jt(n));function UM(n,e){return ui(n,t=>n.moveByGroup(t,e))}var qH=n=>UM(n,!Jt(n)),VH=n=>UM(n,Jt(n));var HH=n=>ui(n,e=>Ey(n.state,e,!Jt(n))),zH=n=>ui(n,e=>Ey(n.state,e,Jt(n)));function QM(n,e){return ui(n,t=>n.moveVertically(t,e))}var KM=n=>QM(n,!1),GM=n=>QM(n,!0);function XM(n,e){return ui(n,t=>n.moveVertically(t,e,qM(n).height))}var SM=n=>XM(n,!1),OM=n=>XM(n,!0),WH=n=>ui(n,e=>Vo(n,e,!0)),UH=n=>ui(n,e=>Vo(n,e,!1)),QH=n=>ui(n,e=>Vo(n,e,!Jt(n))),KH=n=>ui(n,e=>Vo(n,e,Jt(n))),GH=n=>ui(n,e=>$.cursor(n.lineBlockAt(e.head).from)),XH=n=>ui(n,e=>$.cursor(n.lineBlockAt(e.head).to)),kM=({state:n,dispatch:e})=>(e(Si(n,{anchor:0})),!0),RM=({state:n,dispatch:e})=>(e(Si(n,{anchor:n.doc.length})),!0),TM=({state:n,dispatch:e})=>(e(Si(n,{anchor:n.selection.main.anchor,head:0})),!0),AM=({state:n,dispatch:e})=>(e(Si(n,{anchor:n.selection.main.anchor,head:n.doc.length})),!0),YH=({state:n,dispatch:e})=>(e(n.update({selection:{anchor:0,head:n.doc.length},userEvent:"select"})),!0),ZH=({state:n,dispatch:e})=>{let t=Sy(n).map(({from:i,to:r})=>$.range(i,Math.min(r+1,n.doc.length)));return e(n.update({selection:$.create(t),userEvent:"select"})),!0},JH=({state:n,dispatch:e})=>{let t=mc(n.selection,i=>{let r=lt(n),o=r.resolveStack(i.from,1);if(i.empty){let s=r.resolveStack(i.from,-1);s.node.from>=o.node.from&&s.node.to<=o.node.to&&(o=s)}for(let s=o;s;s=s.next){let{node:a}=s;if((a.from=i.to||a.to>i.to&&a.from<=i.from)&&s.next)return $.range(a.to,a.from)}return i});return t.eq(n.selection)?!1:(e(Si(n,t)),!0)};function YM(n,e){let{state:t}=n,i=t.selection,r=t.selection.ranges.slice();for(let o of t.selection.ranges){let s=t.doc.lineAt(o.head);if(e?s.to0)for(let a=o;;){let l=n.moveVertically(a,e);if(l.heads.to){r.some(c=>c.head==l.head)||r.push(l);break}else{if(l.head==a.head)break;a=l}}}return r.length==i.ranges.length?!1:(n.dispatch(Si(t,$.create(r,r.length-1))),!0)}var e6=n=>YM(n,!1),t6=n=>YM(n,!0),n6=({state:n,dispatch:e})=>{let t=n.selection,i=null;return t.ranges.length>1?i=$.create([t.main]):t.main.empty||(i=$.create([$.cursor(t.main.head)])),i?(e(Si(n,i)),!0):!1};function Qh(n,e){if(n.state.readOnly)return!1;let t="delete.selection",{state:i}=n,r=i.changeByRange(o=>{let{from:s,to:a}=o;if(s==a){let l=e(o);ls&&(t="delete.forward",l=_y(n,l,!0)),s=Math.min(s,l),a=Math.max(a,l)}else s=_y(n,s,!1),a=_y(n,a,!0);return s==a?{range:o}:{changes:{from:s,to:a},range:$.cursor(s,sr(n)))i.between(e,e,(r,o)=>{re&&(e=t?o:r)});return e}var ZM=(n,e,t)=>Qh(n,i=>{let r=i.from,{state:o}=n,s=o.doc.lineAt(r),a,l;if(t&&!e&&r>s.from&&rZM(n,!1,!0);var JM=n=>ZM(n,!0,!1),eP=(n,e)=>Qh(n,t=>{let i=t.head,{state:r}=n,o=r.doc.lineAt(i),s=r.charCategorizer(i);for(let a=null;;){if(i==(e?o.to:o.from)){i==t.head&&o.number!=(e?r.doc.lines:1)&&(i+=e?1:-1);break}let l=Dt(o.text,i-o.from,e)+o.from,c=o.text.slice(Math.min(i,l)-o.from,Math.max(i,l)-o.from),u=s(c);if(a!=null&&u!=a)break;(c!=" "||i!=t.head)&&(a=u),i=l}return i}),tP=n=>eP(n,!1),i6=n=>eP(n,!0);var r6=n=>Qh(n,e=>{let t=n.lineBlockAt(e.head).to;return e.headQh(n,e=>{let t=n.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),s6=n=>Qh(n,e=>{let t=n.moveToLineBoundary(e,!0).head;return e.head{if(n.readOnly)return!1;let t=n.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:be.of(["",""])},range:$.cursor(i.from)}));return e(n.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},l6=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(i=>{if(!i.empty||i.from==0||i.from==n.doc.length)return{range:i};let r=i.from,o=n.doc.lineAt(r),s=r==o.from?r-1:Dt(o.text,r-o.from,!1)+o.from,a=r==o.to?r+1:Dt(o.text,r-o.from,!0)+o.from;return{changes:{from:s,to:a,insert:n.doc.slice(r,a).append(n.doc.slice(s,r))},range:$.cursor(a)}});return t.changes.empty?!1:(e(n.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Sy(n){let e=[],t=-1;for(let i of n.selection.ranges){let r=n.doc.lineAt(i.from),o=n.doc.lineAt(i.to);if(!i.empty&&i.to==o.from&&(o=n.doc.lineAt(i.to-1)),t>=r.number){let s=e[e.length-1];s.to=o.to,s.ranges.push(i)}else e.push({from:r.from,to:o.to,ranges:[i]});t=o.number+1}return e}function nP(n,e,t){if(n.readOnly)return!1;let i=[],r=[];for(let o of Sy(n)){if(t?o.to==n.doc.length:o.from==0)continue;let s=n.doc.lineAt(t?o.to+1:o.from-1),a=s.length+1;if(t){i.push({from:o.to,to:s.to},{from:o.from,insert:s.text+n.lineBreak});for(let l of o.ranges)r.push($.range(Math.min(n.doc.length,l.anchor+a),Math.min(n.doc.length,l.head+a)))}else{i.push({from:s.from,to:o.from},{from:o.to,insert:n.lineBreak+s.text});for(let l of o.ranges)r.push($.range(l.anchor-a,l.head-a))}}return i.length?(e(n.update({changes:i,scrollIntoView:!0,selection:$.create(r,n.selection.mainIndex),userEvent:"move.line"})),!0):!1}var c6=({state:n,dispatch:e})=>nP(n,e,!1),u6=({state:n,dispatch:e})=>nP(n,e,!0);function iP(n,e,t){if(n.readOnly)return!1;let i=[];for(let o of Sy(n))t?i.push({from:o.from,insert:n.doc.slice(o.from,o.to)+n.lineBreak}):i.push({from:o.to,insert:n.lineBreak+n.doc.slice(o.from,o.to)});let r=n.changes(i);return e(n.update({changes:r,selection:n.selection.map(r,t?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}var f6=({state:n,dispatch:e})=>iP(n,e,!1),h6=({state:n,dispatch:e})=>iP(n,e,!0),d6=n=>{if(n.state.readOnly)return!1;let{state:e}=n,t=e.changes(Sy(e).map(({from:r,to:o})=>(r>0?r--:o{let o;if(n.lineWrapping){let s=n.lineBlockAt(r.head),a=n.coordsAtPos(r.head,r.assoc||1);a&&(o=s.bottom+n.documentTop-a.bottom+n.defaultLineHeight/2)}return n.moveVertically(r,!0,o)}).map(t);return n.dispatch({changes:t,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function p6(n,e){if(/\(\)|\[\]|\{\}/.test(n.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=lt(n).resolveInner(e),i=t.childBefore(e),r=t.childAfter(e),o;return i&&r&&i.to<=e&&r.from>=e&&(o=i.type.prop(ce.closedBy))&&o.indexOf(r.name)>-1&&n.doc.lineAt(i.to).from==n.doc.lineAt(r.from).from&&!/\S/.test(n.sliceDoc(i.to,r.from))?{from:i.to,to:r.from}:null}var MM=rP(!1),m6=rP(!0);function rP(n){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=e.changeByRange(r=>{let{from:o,to:s}=r,a=e.doc.lineAt(o),l=!n&&o==s&&p6(e,o);n&&(o=s=(s<=a.to?a:e.doc.lineAt(s)).to);let c=new Ks(e,{simulateBreak:o,simulateDoubleBreak:!!l}),u=hy(c,o);for(u==null&&(u=$s(/^\s*/.exec(e.doc.lineAt(o).text)[0],e.tabSize));sa.from&&o{let r=[];for(let s=i.from;s<=i.to;){let a=n.doc.lineAt(s);a.number>t&&(i.empty||i.to>a.from)&&(e(a,r,i),t=a.number),s=a.to+1}let o=n.changes(r);return{changes:r,range:$.range(o.mapPos(i.anchor,1),o.mapPos(i.head,1))}})}var g6=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=Object.create(null),i=new Ks(n,{overrideIndentation:o=>{let s=t[o];return s==null?-1:s}}),r=R_(n,(o,s,a)=>{let l=hy(i,o.from);if(l==null)return;/\S/.test(o.text)||(l=0);let c=/^\s*/.exec(o.text)[0],u=hc(n,l);(c!=u||a.fromn.readOnly?!1:(e(n.update(R_(n,(t,i)=>{i.push({from:t.from,insert:n.facet(fc)})}),{userEvent:"input.indent"})),!0),v6=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(R_(n,(t,i)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let o=$s(r,n.tabSize),s=0,a=hc(n,Math.max(0,o-Vh(n)));for(;s(n.setTabFocusMode(),!0);var b6=[{key:"Ctrl-b",run:LM,shift:zM,preventDefault:!0},{key:"Ctrl-f",run:BM,shift:WM},{key:"Ctrl-p",run:jM,shift:KM},{key:"Ctrl-n",run:FM,shift:GM},{key:"Ctrl-a",run:NH,shift:GH},{key:"Ctrl-e",run:$H,shift:XH},{key:"Ctrl-d",run:JM},{key:"Ctrl-h",run:S_},{key:"Ctrl-k",run:r6},{key:"Ctrl-Alt-h",run:tP},{key:"Ctrl-o",run:a6},{key:"Ctrl-t",run:l6},{key:"Ctrl-v",run:E_}],_6=[{key:"ArrowLeft",run:LM,shift:zM,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:RH,shift:qH,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:LH,shift:QH,preventDefault:!0},{key:"ArrowRight",run:BM,shift:WM,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:TH,shift:VH,preventDefault:!0},{mac:"Cmd-ArrowRight",run:BH,shift:KH,preventDefault:!0},{key:"ArrowUp",run:jM,shift:KM,preventDefault:!0},{mac:"Cmd-ArrowUp",run:kM,shift:TM},{mac:"Ctrl-ArrowUp",run:EM,shift:SM},{key:"ArrowDown",run:FM,shift:GM,preventDefault:!0},{mac:"Cmd-ArrowDown",run:RM,shift:AM},{mac:"Ctrl-ArrowDown",run:E_,shift:OM},{key:"PageUp",run:EM,shift:SM},{key:"PageDown",run:E_,shift:OM},{key:"Home",run:IH,shift:UH,preventDefault:!0},{key:"Mod-Home",run:kM,shift:TM},{key:"End",run:DH,shift:WH,preventDefault:!0},{key:"Mod-End",run:RM,shift:AM},{key:"Enter",run:MM,shift:MM},{key:"Mod-a",run:YH},{key:"Backspace",run:S_,shift:S_,preventDefault:!0},{key:"Delete",run:JM,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:tP,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:i6,preventDefault:!0},{mac:"Mod-Backspace",run:o6,preventDefault:!0},{mac:"Mod-Delete",run:s6,preventDefault:!0}].concat(b6.map(n=>({mac:n.key,run:n.run,shift:n.shift}))),oP=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:MH,shift:HH},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:PH,shift:zH},{key:"Alt-ArrowUp",run:c6},{key:"Shift-Alt-ArrowUp",run:f6},{key:"Alt-ArrowDown",run:u6},{key:"Shift-Alt-ArrowDown",run:h6},{key:"Mod-Alt-ArrowUp",run:e6},{key:"Mod-Alt-ArrowDown",run:t6},{key:"Escape",run:n6},{key:"Mod-Enter",run:m6},{key:"Alt-l",mac:"Ctrl-l",run:ZH},{key:"Mod-i",run:JH,preventDefault:!0},{key:"Mod-[",run:v6},{key:"Mod-]",run:y6},{key:"Mod-Alt-\\",run:g6},{key:"Shift-Mod-k",run:d6},{key:"Shift-Mod-\\",run:FH},{key:"Mod-/",run:dH},{key:"Alt-A",run:mH},{key:"Ctrl-m",mac:"Shift-Alt-m",run:x6}].concat(_6);var ky=class{constructor(e,t,i){this.from=e,this.to=t,this.diagnostic=i}},Zs=class n{constructor(e,t,i){this.diagnostics=e,this.panel=t,this.selected=i}static init(e,t,i){let r=i.facet(or).markerFilter;r&&(e=r(e,i));let o=e.slice().sort((d,p)=>d.from-p.from||d.to-p.to),s=new Nr,a=[],l=0,c=i.doc.iter(),u=0,f=i.doc.length;for(let d=0;;){let p=d==o.length?null:o[d];if(!p&&!a.length)break;let m,g;if(a.length)m=l,g=a.reduce((v,x)=>Math.min(v,x.to),p&&p.from>m?p.from:1e8);else{if(m=p.from,m>f)break;g=p.to,a.push(p),d++}for(;dv.from||v.to==m))a.push(v),d++,g=Math.min(v.to,g);else{g=Math.min(v.from,g);break}}g=Math.min(g,f);let b=!1;if(a.some(v=>v.from==m&&(v.to==g||g==f))&&(b=m==g,!b&&g-m<10)){let v=m-(u+c.value.length);v>0&&(c.next(v),u=m);for(let x=m;;){if(x>=g){b=!0;break}if(!c.lineBreak&&u+c.value.length>x)break;x=u+c.value.length,u+=c.value.length,c.next()}}let _=D6(a);if(b)s.add(m,m,he.widget({widget:new T_(_),diagnostics:a.slice()}));else{let v=a.reduce((x,C)=>C.markClass?x+" "+C.markClass:x,"");s.add(m,g,he.mark({class:"cm-lintRange cm-lintRange-"+_+v,diagnostics:a.slice(),inclusiveEnd:a.some(x=>x.to>g)}))}if(l=g,l==f)break;for(let v=0;v{if(!(e&&s.diagnostics.indexOf(e)<0))if(!i)i=new ky(r,o,e||s.diagnostics[0]);else{if(s.diagnostics.indexOf(i.diagnostic)<0)return!1;i=new ky(i.from,o,i.diagnostic)}}),i}function w6(n,e){let t=e.pos,i=e.end||t,r=n.state.facet(or).hideOn(n,t,i);if(r!=null)return r;let o=n.startState.doc.lineAt(e.pos);return!!(n.effects.some(s=>s.is(Kh))||n.changes.touchesRange(o.from,Math.max(o.to,i)))}function C6(n,e){return n.field(ki,!1)?e:e.concat(de.appendConfig.of(dP))}function E6(n,e){return{effects:C6(n,[Kh.of(e)])}}var Kh=de.define(),lP=de.define(),cP=de.define(),ki=qt.define({create(){return new Zs(he.none,null,null)},update(n,e){if(e.docChanged&&n.diagnostics.size){let t=n.diagnostics.map(e.changes),i=null,r=n.panel;if(n.selected){let o=e.changes.mapPos(n.selected.from,1);i=gc(t,n.selected.diagnostic,o)||gc(t,null,o)}!t.size&&r&&e.state.facet(or).autoPanel&&(r=null),n=new Zs(t,r,i)}for(let t of e.effects)if(t.is(Kh)){let i=e.state.facet(or).autoPanel?t.value.length?Ty.open:null:n.panel;n=Zs.init(t.value,i,e.state)}else t.is(lP)?n=new Zs(n.diagnostics,t.value?Ty.open:null,n.selected):t.is(cP)&&(n=new Zs(n.diagnostics,n.panel,t.value));return n},provide:n=>[Zg.from(n,e=>e.panel),U.decorations.from(n,e=>e.diagnostics)]});var S6=he.mark({class:"cm-lintRange cm-lintRange-active"});function O6(n,e,t){let{diagnostics:i}=n.state.field(ki),r,o=-1,s=-1;i.between(e-(t<0?1:0),e+(t>0?1:0),(l,c,{spec:u})=>{if(e>=l&&e<=c&&(l==c||(e>l||t>0)&&(ehP(n,t,!1)))}var sP=n=>{let e=n.state.field(ki,!1);return!e||!e.panel?!1:(n.dispatch({effects:lP.of(!1)}),!0)};var R6=Yt.fromClass(class{constructor(n){this.view=n,this.timeout=-1,this.set=!0;let{delay:e}=n.state.facet(or);this.lintTime=Date.now()+e,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,e)}run(){clearTimeout(this.timeout);let n=Date.now();if(nPromise.resolve(i(this.view))),i=>{this.view.state.doc==e.doc&&this.view.dispatch(E6(this.view.state,i.reduce((r,o)=>r.concat(o))))},i=>{It(this.view.state,i)})}}update(n){let e=n.state.facet(or);(n.docChanged||e!=n.startState.facet(or)||e.needsRefresh&&e.needsRefresh(n))&&(this.lintTime=Date.now()+e.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,e.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}});function T6(n,e,t){let i=[],r=-1;for(let o of n)o.then(s=>{i.push(s),clearTimeout(r),i.length==n.length?e(i):r=setTimeout(()=>e(i),200)},t)}var or=H.define({combine(n){return{sources:n.map(e=>e.source).filter(e=>e!=null),...Io(n.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:aP,tooltipFilter:aP,needsRefresh:(e,t)=>e?t?i=>e(i)||t(i):e:t,hideOn:(e,t)=>e?t?(i,r,o)=>e(i,r,o)||t(i,r,o):e:t,autoPanel:(e,t)=>e||t})}}});function aP(n,e){return n?e?(t,i)=>e(n(t,i),i):n:e}function uP(n,e={}){return[or.of({source:n,config:e}),R6,dP]}function fP(n){let e=[];if(n)e:for(let{name:t}of n){for(let i=0;io.toLowerCase()==r.toLowerCase())){e.push(r);continue e}}e.push("")}return e}function hP(n,e,t){var i;let r=t?fP(e.actions):[];return Pn("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},Pn("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(n):e.message),(i=e.actions)===null||i===void 0?void 0:i.map((o,s)=>{let a=!1,l=d=>{if(d.preventDefault(),a)return;a=!0;let p=gc(n.state.field(ki).diagnostics,e);p&&o.apply(n,p.from,p.to)},{name:c}=o,u=r[s]?c.indexOf(r[s]):-1,f=u<0?c:[c.slice(0,u),Pn("u",c.slice(u,u+1)),c.slice(u+1)],h=o.markClass?" "+o.markClass:"";return Pn("button",{type:"button",class:"cm-diagnosticAction"+h,onclick:l,onmousedown:l,"aria-label":` Action: ${c}${u<0?"":` (access key "${r[s]})"`}.`},f)}),e.source&&Pn("div",{class:"cm-diagnosticSource"},e.source))}var T_=class extends ai{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return Pn("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}},Ry=class{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=hP(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}},Ty=class n{constructor(e){this.view=e,this.items=[];let t=r=>{if(!(r.ctrlKey||r.altKey||r.metaKey)){if(r.keyCode==27)sP(this.view),this.view.focus();else if(r.keyCode==38||r.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(r.keyCode==40||r.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(r.keyCode==36)this.moveSelection(0);else if(r.keyCode==35)this.moveSelection(this.items.length-1);else if(r.keyCode==13)this.view.focus();else if(r.keyCode>=65&&r.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:o}=this.items[this.selectedIndex],s=fP(o.actions);for(let a=0;a{for(let o=0;osP(this.view)},"\xD7")),this.update()}get selectedIndex(){let e=this.view.state.field(ki).selected;if(!e)return-1;for(let t=0;t{for(let u of c.diagnostics){if(s.has(u))continue;s.add(u);let f=-1,h;for(let d=i;di&&(this.items.splice(i,f-i),r=!0)),t&&h.diagnostic==t.diagnostic?h.dom.hasAttribute("aria-selected")||(h.dom.setAttribute("aria-selected","true"),o=h):h.dom.hasAttribute("aria-selected")&&h.dom.removeAttribute("aria-selected"),i++}});i({sel:o.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:a,panel:l})=>{let c=l.height/this.list.offsetHeight;a.topl.bottom&&(this.list.scrollTop+=(a.bottom-l.bottom)/c)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let i=e;e=i.nextSibling,i.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;e!=i.dom;)t();e=i.dom.nextSibling}else this.list.insertBefore(i.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=this.view.state.field(ki),i=gc(t.diagnostics,this.items[e].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:cP.of(i)})}static open(e){return new n(e)}};function A6(n,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,${encodeURIComponent(n)}')`}function Oy(n){return A6(``,'width="6" height="3"')}var M6=U.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:Oy("#f11")},".cm-lintRange-warning":{backgroundImage:Oy("orange")},".cm-lintRange-info":{backgroundImage:Oy("#999")},".cm-lintRange-hint":{backgroundImage:Oy("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:"#86714a80"},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:"#2e343e"}}});function P6(n){return n=="error"?4:n=="warning"?3:n=="info"?2:1}function D6(n){let e="hint",t=1;for(let i of n){let r=P6(i.severity);r>t&&(t=r,e=i.severity)}return e}var I6=IA(O6,{hideOn:w6}),dP=[ki,U.decorations.compute([ki],n=>{let{selected:e,panel:t}=n.field(ki);return!e||!t||e.from==e.to?he.none:he.set([S6.range(e.from,e.to)])}),I6,M6];function pP(n){return{all:n=n||new Map,on:function(e,t){var i=n.get(e);i?i.push(t):n.set(e,[t])},off:function(e,t){var i=n.get(e);i&&(t?i.splice(i.indexOf(t)>>>0,1):n.set(e,[]))},emit:function(e,t){var i=n.get(e);i&&i.slice().map(function(r){r(t)}),(i=n.get("*"))&&i.slice().map(function(r){r(e,t)})}}}var P_=class n{constructor(e,t,i,r,o,s,a,l,c,u=0,f){this.p=e,this.stack=t,this.state=i,this.reducePos=r,this.pos=o,this.score=s,this.buffer=a,this.bufferBase=l,this.curContext=c,this.lookAhead=u,this.parent=f}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,i=0){let r=e.parser.context;return new n(e,[],t,i,i,0,[],0,r?new Ay(r,r.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var t;let i=e>>19,r=e&65535,{parser:o}=this.p,s=this.reducePos=2e3&&!(!((t=this.p.parser.nodeSet.types[r])===null||t===void 0)&&t.isAnonymous)&&(c==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=u):this.p.lastBigReductionSizel;)this.stack.pop();this.reduceContext(r,c)}storeNode(e,t,i,r=4,o=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]0&&this.buffer[s-4]==0&&this.buffer[s-1]>-1){if(t==i)return;if(this.buffer[s-2]>=t){this.buffer[s-2]=i;return}}}if(!o||this.pos==i)this.buffer.push(e,t,i,r);else{let s=this.buffer.length;if(s>0&&(this.buffer[s-4]!=0||this.buffer[s-1]<0)){let a=!1;for(let l=s;l>0&&this.buffer[l-2]>i;l-=4)if(this.buffer[l-1]>=0){a=!0;break}if(a)for(;s>0&&this.buffer[s-2]>i;)this.buffer[s]=this.buffer[s-4],this.buffer[s+1]=this.buffer[s-3],this.buffer[s+2]=this.buffer[s-2],this.buffer[s+3]=this.buffer[s-1],s-=4,r>4&&(r-=4)}this.buffer[s]=e,this.buffer[s+1]=t,this.buffer[s+2]=i,this.buffer[s+3]=r}}shift(e,t,i,r){if(e&131072)this.pushState(e&65535,this.pos);else if((e&262144)==0){let o=e,{parser:s}=this.p;this.pos=r;let a=s.stateFlag(o,1);!a&&(r>i||t<=s.maxNode)&&(this.reducePos=r),this.pushState(o,a?i:Math.min(i,this.reducePos)),this.shiftContext(t,i),t<=s.maxNode&&this.buffer.push(t,i,r,4)}else this.pos=r,this.shiftContext(t,i),t<=this.p.parser.maxNode&&this.buffer.push(t,i,r,4)}apply(e,t,i,r){e&65536?this.reduce(e):this.shift(e,t,i,r)}useNode(e,t){let i=this.p.reused.length-1;(i<0||this.p.reused[i]!=e)&&(this.p.reused.push(e),i++);let r=this.pos;this.reducePos=this.pos=r+e.length,this.pushState(t,r),this.buffer.push(i,r,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(t&&e.buffer[t-4]==0&&(t-=4);t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let i=e.buffer.slice(t),r=e.bufferBase+t;for(;e&&r==e.bufferBase;)e=e.parent;return new n(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,i,r,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let i=e<=this.p.parser.maxNode;i&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,i?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new D_(this);;){let i=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(i==0)return!1;if((i&65536)==0)return!0;t.reduce(i)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let r=[];for(let o=0,s;ol&1&&a==s)||r.push(t[o],s)}t=r}let i=[];for(let r=0;r>19,r=t&65535,o=this.stack.length-i*3;if(o<0||e.getGoto(this.stack[o],r,!1)<0){let s=this.findForcedReduction();if(s==null)return!1;t=s}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],i=(r,o)=>{if(!t.includes(r))return t.push(r),e.allActions(r,s=>{if(!(s&393216))if(s&65536){let a=(s>>19)-o;if(a>1){let l=s&65535,c=this.stack.length-a*3;if(c>=0&&e.getGoto(this.stack[c],l,!1)>=0)return a<<19|65536|l}}else{let a=i(s,o+1);if(a!=null)return a}})};return i(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t0&&this.emitLookAhead()}},Ay=class{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}},D_=class{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,i=e>>19;i==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(i-1)*3;let r=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=r}},I_=class n{constructor(e,t,i){this.stack=e,this.pos=t,this.index=i,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new n(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new n(this.stack,this.pos,this.index)}};function Gh(n,e=Uint16Array){if(typeof n!="string")return n;let t=null;for(let i=0,r=0;i=92&&s--,s>=34&&s--;let l=s-32;if(l>=46&&(l-=46,a=!0),o+=l,a)break;o*=46}t?t[r++]=o:t=new e(o)}return t}var yc=class{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}},mP=new yc,L_=class{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=mP,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let i=this.range,r=this.rangeIndex,o=this.pos+e;for(;oi.to:o>=i.to;){if(r==this.ranges.length-1)return null;let s=this.ranges[++r];o+=s.from-i.to,i=s}return o}clipPos(e){if(e>=this.range.from&&ee)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,i,r;if(t>=0&&t=this.chunk2Pos&&ia.to&&(this.chunk2=this.chunk2.slice(0,a.to-i)),r=this.chunk2.charCodeAt(0)}}return i>=this.token.lookAhead&&(this.token.lookAhead=i+1),r}acceptToken(e,t=0){let i=t?this.resolveOffset(t,-1):this.pos;if(i==null||i=this.chunk2Pos&&this.posthis.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=mP,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let i="";for(let r of this.ranges){if(r.from>=t)break;r.to>e&&(i+=this.input.read(Math.max(r.from,e),Math.min(r.to,t)))}return i}},Ho=class{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:i}=t.p;bP(this.data,e,t,this.id,i.data,i.tokenPrecTable)}};Ho.prototype.contextual=Ho.prototype.fallback=Ho.prototype.extend=!1;var B_=class{constructor(e,t,i){this.precTable=t,this.elseToken=i,this.data=typeof e=="string"?Gh(e):e}token(e,t){let i=e.pos,r=0;for(;;){let o=e.next<0,s=e.resolveOffset(1,1);if(bP(this.data,e,t,0,this.data,this.precTable),e.token.value>-1)break;if(this.elseToken==null)return;if(o||r++,s==null)break;e.reset(s,e.token)}r&&(e.reset(i,e.token),e.acceptToken(this.elseToken,r))}};B_.prototype.contextual=Ho.prototype.fallback=Ho.prototype.extend=!1;var vc=class{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}};function bP(n,e,t,i,r,o){let s=0,a=1<0){let p=n[d];if(l.allows(p)&&(e.token.value==-1||e.token.value==p||B6(p,e.token.value,r,o))){e.acceptToken(p);break}}let u=e.next,f=0,h=n[s+2];if(e.next<0&&h>f&&n[c+h*3-3]==65535){s=n[c+h*3-1];continue e}for(;f>1,p=c+d+(d<<1),m=n[p],g=n[p+1]||65536;if(u=g)f=d+1;else{s=n[p+2],e.advance();continue e}}break}}function gP(n,e,t){for(let i=e,r;(r=n[i])!=65535;i++)if(r==t)return i-e;return-1}function B6(n,e,t,i){let r=gP(t,i,e);return r<0||gP(t,i,n)e)&&!i.type.isError)return t<0?Math.max(0,Math.min(i.to-1,e-25)):Math.min(n.length,Math.max(i.from+1,e+25));if(t<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return t<0?0:n.length}}var N_=class{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?yP(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?yP(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(ee)return this.nextStart=s,null;if(o instanceof gt){if(s==e){if(s=Math.max(this.safeFrom,e)&&(this.trees.push(o),this.start.push(s),this.index.push(0))}else this.index[t]++,this.nextStart=s+o.length}}},$_=class{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(i=>new yc)}getActions(e){let t=0,i=null,{parser:r}=e.p,{tokenizers:o}=r,s=r.stateSlot(e.state,3),a=e.curContext?e.curContext.hash:0,l=0;for(let c=0;cf.end+25&&(l=Math.max(f.lookAhead,l)),f.value!=0)){let h=t;if(f.extended>-1&&(t=this.addActions(e,f.extended,f.end,t)),t=this.addActions(e,f.value,f.end,t),!u.extend&&(i=f,t>h))break}}for(;this.actions.length>t;)this.actions.pop();return l&&e.setLookAhead(l),!i&&e.pos==this.stream.end&&(i=new yc,i.value=e.p.parser.eofTerm,i.start=i.end=e.pos,t=this.addActions(e,i.value,i.end,t)),this.mainToken=i,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new yc,{pos:i,p:r}=e;return t.start=i,t.end=Math.min(i+1,r.stream.end),t.value=i==r.stream.end?r.parser.eofTerm:0,t}updateCachedToken(e,t,i){let r=this.stream.clipPos(i.pos);if(t.token(this.stream.reset(r,e),i),e.value>-1){let{parser:o}=i.p;for(let s=0;s=0&&i.p.parser.dialect.allows(a>>1)){(a&1)==0?e.value=a>>1:e.extended=a>>1;break}}}else e.value=0,e.end=this.stream.clipPos(r+1)}putAction(e,t,i,r){for(let o=0;oe.bufferLength*4?new N_(i,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,i=this.stacks=[],r,o;if(this.bigReductionCount>300&&e.length==1){let[s]=e;for(;s.forceReduce()&&s.stack.length&&s.stack[s.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let s=0;st)i.push(a);else{if(this.advanceStack(a,i,e))continue;{r||(r=[],o=[]),r.push(a);let l=this.tokens.getMainToken(a);o.push(l.value,l.end)}}break}}if(!i.length){let s=r&&N6(r);if(s)return Ln&&console.log("Finish with "+this.stackID(s)),this.stackToTree(s);if(this.parser.strict)throw Ln&&r&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+t);this.recovering||(this.recovering=5)}if(this.recovering&&r){let s=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,o,i);if(s)return Ln&&console.log("Force-finish "+this.stackID(s)),this.stackToTree(s.forceAll())}if(this.recovering){let s=this.recovering==1?1:this.recovering*3;if(i.length>s)for(i.sort((a,l)=>l.score-a.score);i.length>s;)i.pop();i.some(a=>a.reducePos>t)&&this.recovering--}else if(i.length>1){e:for(let s=0;s500&&c.buffer.length>500)if((a.score-c.score||a.buffer.length-c.buffer.length)>0)i.splice(l--,1);else{i.splice(s--,1);continue e}}}i.length>12&&(i.sort((s,a)=>a.score-s.score),i.splice(12,i.length-12))}this.minStackPos=i[0].pos;for(let s=1;s ":"";if(this.stoppedAt!=null&&r>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let c=e.curContext&&e.curContext.tracker.strict,u=c?e.curContext.hash:0;for(let f=this.fragments.nodeAt(r);f;){let h=this.parser.nodeSet.types[f.type.id]==f.type?o.getGoto(e.state,f.type.id):-1;if(h>-1&&f.length&&(!c||(f.prop(ce.contextHash)||0)==u))return e.useNode(f,h),Ln&&console.log(s+this.stackID(e)+` (via reuse of ${o.getName(f.type.id)})`),!0;if(!(f instanceof gt)||f.children.length==0||f.positions[0]>0)break;let d=f.children[0];if(d instanceof gt&&f.positions[0]==0)f=d;else break}}let a=o.stateSlot(e.state,4);if(a>0)return e.reduce(a),Ln&&console.log(s+this.stackID(e)+` (via always-reduce ${o.getName(a&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let l=this.tokens.getActions(e);for(let c=0;cr?t.push(p):i.push(p)}return!1}advanceFully(e,t){let i=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>i)return vP(e,t),!0}}runRecovery(e,t,i){let r=null,o=!1;for(let s=0;s ":"";if(a.deadEnd&&(o||(o=!0,a.restart(),Ln&&console.log(u+this.stackID(a)+" (restarted)"),this.advanceFully(a,i))))continue;let f=a.split(),h=u;for(let d=0;d<10&&f.forceReduce()&&(Ln&&console.log(h+this.stackID(f)+" (via force-reduce)"),!this.advanceFully(f,i));d++)Ln&&(h=this.stackID(f)+" -> ");for(let d of a.recoverByInsert(l))Ln&&console.log(u+this.stackID(d)+" (via recover-insert)"),this.advanceFully(d,i);this.stream.end>a.pos?(c==a.pos&&(c++,l=0),a.recoverByDelete(l,c),Ln&&console.log(u+this.stackID(a)+` (via recover-delete ${this.parser.getName(l)})`),vP(a,i)):(!r||r.scoren,My=class{constructor(e){this.start=e.start,this.shift=e.shift||M_,this.reduce=e.reduce||M_,this.reuse=e.reuse||M_,this.hash=e.hash||(()=>0),this.strict=e.strict!==!1}},Py=class n extends ac{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let a=0;ae.topRules[a][1]),r=[];for(let a=0;a=0)o(u,l,a[c++]);else{let f=a[c+-u];for(let h=-u;h>0;h--)o(a[c++],l,f);c++}}}this.nodeSet=new Lh(t.map((a,l)=>Zt.define({name:l>=this.minRepeatTerm?void 0:a,id:l,props:r[l],top:i.indexOf(l)>-1,error:l==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(l)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=1024;let s=Gh(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let a=0;atypeof a=="number"?new Ho(s,a):a),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,i){let r=new j_(this,e,t,i);for(let o of this.wrappers)r=o(r,e,t,i);return r}getGoto(e,t,i=!1){let r=this.goto;if(t>=r[0])return-1;for(let o=r[t+1];;){let s=r[o++],a=s&1,l=r[o++];if(a&&i)return l;for(let c=o+(s>>1);o0}validAction(e,t){return!!this.allActions(e,i=>i==t?!0:null)}allActions(e,t){let i=this.stateSlot(e,4),r=i?t(i):void 0;for(let o=this.stateSlot(e,1);r==null;o+=3){if(this.data[o]==65535)if(this.data[o+1]==1)o=zr(this.data,o+2);else break;r=t(zr(this.data,o+1))}return r}nextStates(e){let t=[];for(let i=this.stateSlot(e,1);;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=zr(this.data,i+2);else break;if((this.data[i+2]&1)==0){let r=this.data[i+1];t.some((o,s)=>s&1&&o==r)||t.push(this.data[i],r)}}return t}configure(e){let t=Object.assign(Object.create(n.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let i=this.topRules[e.top];if(!i)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=i}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(i=>{let r=e.tokenizers.find(o=>o.from==i);return r?r.to:i})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((i,r)=>{let o=e.specializers.find(a=>a.from==i.external);if(!o)return i;let s=Object.assign(Object.assign({},i),{external:o.to});return t.specializers[r]=xP(s),s})),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),e.bufferLength!=null&&(t.bufferLength=e.bufferLength),t}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),i=t.map(()=>!1);if(e)for(let o of e.split(" ")){let s=t.indexOf(o);s>=0&&(i[s]=!0)}let r=null;for(let o=0;oi)&&t.p.parser.stateFlag(t.state,2)&&(!e||e.scoren.external(t,i)<<1|e}return n.get}var $6=121,H_=122,kP=123,j6=124,_P=128,F6=4,q6=131,V6=7,H6=8,z6=9,W6=10,U6=139,RP=19,Q6=140,K6=23,G6=141,X6=27,Y6=37,Z6=41,J6=144,ez=145,tz=146,nz=147,iz=47,rz=68,TP=153,AP=70,MP=154,PP=72,oz=155,sz=76,az=160,lz=79,cz=80,uz=81,fz=167,DP=89,hz=90,dz=169,pz=97,mz=171,gz=98,yz=100,vz=101,z_=typeof process!="undefined"&&process.env&&/\bfparse(:dbg)?\b/.test(process.env.LOG),W_=typeof process!="undefined"&&process.env&&/\bfparse:dbg\b/.test(process.env.LOG),Wr=typeof process!="undefined"&&process.env&&/\bcontext\b/.test(process.env.LOG),IP=[9,11,12,32,133,160,5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8232,8233,8239,8287,12288],xz=LP(` \r`),wP=42,bz=LP("'./-+*^");function LP(n){return Array.from(n).map(e=>e.charCodeAt(0))}function _z(n){return n===63||n>=65&&n<=90||n===95||n>=97&&n<=122||n>=192&&n<=214||n>=216&&n<=246||n>=248&&n<=767||n>=880&&n<=893||n>=895&&n<=8191||n>=8204&&n<=8205||n>=8304&&n<=8591||n>=11264&&n<=12271||n>=12289&&n<=55295||n>=63744&&n<=64975||n>=65008&&n<=65533||n>=55296&&n<=56319||n>=56320&&n<=57343}function wz(n){return bz.includes(n)}function Cz(n){return n>=48&&n<=57||n===183||n>=768&&n<=879||n>=8255&&n<=8256}function Ez(n){return IP.includes(n)}function CP(n,e){return e.concat(n.split(/\n/g).join(` `+e))}function Sz(n,e=0){let t=n.peek(e);return t===wP&&n.peek(e+1)===wP?{offset:2,token:"**"}:wz(t)?{offset:1,token:String.fromCharCode(t)}:null}function Dy(n,e=0,t=!1){for(let i=!1,r=[],o=0;;o++){let s=n.peek(e+o);if(_z(s)||(i||t)&&Cz(s))i||(i=!0),r.push(s);else return r.length?{token:String.fromCharCode(...r),offset:o}:null}}function BP(n,e){for(let t=!1,i=0;;i++){let r=n.peek(e+i);if(Ez(r))t||(t=!0);else return t?{token:" ",offset:i}:null}}function Oz(n,e){let{keys:t,prefixes:i}=e.contextCache(),r=e.tokens;for(let o=0,s=[],a=null;;){let l=r.length+s.length>0,c=s.length>0,u=Dy(n,o,l)||l&&Sz(n,o)||c&&BP(n,o);if(!u)return a;let{token:f,offset:h}=u;if(o+=h,f===" ")continue;s=[...s,f];let d=[...r,...s].join(" ");if(t.has(d)){let p=s[0];a={token:p,offset:p.length,term:kP}}if(!i.has(d)){if(EP.some(p=>p===d)){let p=s[0];a={token:p,offset:p.length,term:H_}}if(!EP.some(p=>p.startsWith(d)))return a}}}var kz={[H_]:"identifier",[kP]:"nameIdentifier"},Rz=new vc((n,e)=>{W_&&console.log("%s: T ",n.pos);let t=Oz(n,e.context),i=e.context.tokens,r=t||Dy(n,0,i.length>0);r&&(n.advance(r.offset),n.acceptToken(t?t.term:H_),z_&&console.log("%s: MATCH <%s> <%s>",n.pos,t?kz[t.term]:"identifier",r.token))},{contextual:!0}),Tz=new vc((n,e)=>{W_&&console.log("%s: T ",n.pos);let t=e.context.tokens,i=Dy(n,0,t.length>0);i&&(n.advance(i.offset),n.acceptToken($6),z_&&console.log("%s: MATCH <%s>",n.pos,i.token))}),Az=new vc((n,e)=>{W_&&console.log("%s: T ",n.pos);let t,i=!1;for(t=0;;t++){let r=n.peek(t);if(!IP.includes(r)){xz.includes(r)&&(i=!0);break}}if(i){let r=Dy(n,t+1);if(BP(n,t+1)||r&&/^(then|else|return|satisfies)$/.test(r.token))return;z_&&console.log("%s: MATCH ",n.pos),n.acceptToken(j6)}}),Mz={[oz]:"FunctionInvocation",[MP]:"FilterExpression",[TP]:"PathExpression"},Pz={[mz]:"Context",[dz]:"FunctionDefinition",[q6]:"ForExpression",[fz]:"List",[Q6]:"IfExpression",[G6]:"QuantifiedExpression"},Dz={[pz]:"Context",[hz]:"FunctionDefinition",[F6]:"ForExpression",[DP]:"List",[RP]:"IfExpression",[K6]:"QuantifiedExpression",[rz]:"PathExpression",[PP]:"FunctionInvocation",[AP]:"FilterExpression",[Z6]:"ArithmeticExpression"},bc=class n{constructor(e){this.fn=e}get(e){return this.fn(e)}static of(e){return new n(e)}},Iz={"date and time":1,date:1,time:1,duration:1},EP=Object.keys(Iz);function Lz(n){let e=[];for(let t=1;t<=n.length;t++)e.push(n.substring(0,t));return e}function NP(n,e){let t=U_(n),i=Lz(t);e.keys.add(t);for(let r of i)e.prefixes.add(r);return e.originalMap.set(t,n),e}function SP(n){let e=$P();for(let t of n.getKeys())NP(t,e);return e}function $P(n){return{keys:new Set(n==null?void 0:n.keys),prefixes:new Set(n==null?void 0:n.prefixes),originalMap:new Map(n==null?void 0:n.originalMap)}}var q_=class{constructor(e={}){this.value=e}getKeys(){return Object.keys(this.value)}get(e){let t=this.value[e],i=this.constructor;return i.isAtomic(t)?t:i.of(t)}set(e,t){let i=this.constructor;return new i({...this.value,[e]:t})}merge(e){let t=this.constructor;return new t(t.__merge(this.value,e))}static isAtomic(e){return e==null||e instanceof this||e instanceof bc||typeof e!="object"}static of(...e){let t=e.reduce((i,r)=>this.__merge(i,r),{});return new this(t)}static __unwrap(e){return e?e instanceof this?e.value:this.isAtomic(e)?{}:e:{}}static __merge(e,t){let i=Object.assign({},this.__unwrap(e));for(let[r,o]of Object.entries(this.__unwrap(t))){if(o instanceof bc){i[r]=o;continue}if(Zr(i,r)){i[r]=this.__merge(i[r],o);continue}i[r]=o}return i}},V_=class n{constructor({name:e="Expressions",tokens:t=[],children:i=[],parent:r=null,context:o,value:s,raw:a,__cache:l}){this.name=e,this.tokens=t,this.children=i,this.parent=r,this.context=o,this.value=s,this.raw=a,this.__cache=l}get root(){let e=this;for(;e.parent;)e=e.parent;return e}get cache(){let e=this.root;return e.__cache||(e.__cache=new WeakMap),e.__cache}enterScope(e){let t=this.of({name:e,parent:this});return Wr&&console.log("[%s] enter",t.path,t.context),t}exitScope(e){return this.parent?(Wr&&console.log(`[%s] exit %o %s`,this.path,this.context,CP(e," ")),this.parent.pushChild(this)):(Wr&&console.log(`[%s] NO exit %o %s`,this.path,this.context,CP(e," ")),this)}token(e){return Wr&&console.log("[%s] token <%s> + <%s>",this.path,this.tokens.join(" "),e),this.assign({tokens:[...this.tokens,e]})}literal(e){return Wr&&console.log("[%s] literal %o",this.path,e),this.pushChild(this.of({name:"Literal",value:e}))}computedValue(){for(let e=this;;e=xc(e.children)){if(!e)return null;if(!Yr(e.value))return e.value}}contextCache(){let e=this.cache.get(this.context);return e||(e=SP(this.context),this.cache.set(this.context,e)),e}get path(){var e,t;return((t=(e=this.parent)==null?void 0:e.path)==null?void 0:t.concat(" > ",this.name))||this.name}get(e){let t=e&&U_(e),i=this.contextCache().originalMap.get(t);if(typeof i=="undefined")return;let r=this.context.get(i);return r instanceof bc?r.get(this):r}resolveName(){let e=this.tokens.join(" "),t=[],i=this.assign({tokens:t}),r=this.of({name:"VariableName",parent:i,value:this.get(e),raw:e});return Wr&&console.log("[%s] resolve name <%s=%s>",r.path,e,this.get(e)),i.pushChild(r)}pushChild(e){if(!e)return this;let t=this.assign({children:[...this.children,e]});return e.parent=t,t}pushChildren(e){let t=this;for(let i of e)t=t.pushChild(i);return t}declareName(){if(this.tokens.length===0)throw Error("no tokens to declare name");let e=this.tokens.join(" ");return Wr&&console.log("[%s] declareName <%s>",this.path,e),this.assign({tokens:[]}).pushChild(this.of({name:"Name",value:e}))}define(e,t){if(typeof e!="string")return Wr&&console.log("[%s] no define <%s=%s>",this.path,e,t),this;Wr&&console.log("[%s] define <%s=%s>",this.path,e,t);let i=this.context,r=i.set(e,t),o=this.cache.get(i)||SP(i),s=NP(e,$P(o));return this.cache.set(r,s),this.assign({context:r})}assign(e={}){return n.of({...this,...e})}of(e={}){let t={context:this.context,parent:this.parent};return n.of({...t,...e})}static of(e){let{name:t,tokens:i=[],children:r=[],parent:o=null,context:s,value:a,raw:l,__cache:c}=e;if(!s)throw new Error("must provide ");return new n({name:t,tokens:[...i],children:[...r],context:s,parent:o,value:a,raw:l,__cache:c})}};function U_(n){return n.replace(/\s*([./\-'+]|\*\*?)\s*/g," $1 ").replace(/\s{2,}/g," ").trim()}function OP(n,e,t){var c;let i=n.children.filter(u=>u.name!==e),r=n.children.filter(u=>u.name===e),o=i[0],s=i[Math.max(1,i.length-1)],a=o==null?void 0:o.computedValue(),l=(c=s==null?void 0:s.computedValue())!=null?c:null;return n.assign({children:r}).enterScope(e).pushChildren(i).exitScope(t).define(a,l)}function Q_(n={},e=q_){let t=V_.of({context:e.of(n)});return new My({start:t,reduce(i,r,o,s){if(r===RP){let[f,h]=i.children.slice(-2);i=i.assign({value:e.of(f==null?void 0:f.computedValue(),h==null?void 0:h.computedValue())})}if(r===DP&&(i=i.assign({value:e.of(...i.children.map(f=>f==null?void 0:f.computedValue()))})),r===AP){let[f,h]=i.children.slice(-2);i=i.assign({value:f==null?void 0:f.computedValue()})}if(r===PP){let[f,...h]=i.children;(f==null?void 0:f.raw)==="get value"?i=Nz(i,h):i=i.assign({value:(f==null?void 0:f.computedValue())||e.of(void 0)})}let a=Pz[r];if(a)return i.enterScope(a);let l=Mz[r];if(l){let{children:f,context:h}=i,d=f.slice(0,-1),p=xc(f),m=null;return r===TP&&(m=e.of(p==null?void 0:p.computedValue())),r===MP&&(m=e.of(h,p==null?void 0:p.computedValue()).set("item",p==null?void 0:p.computedValue())),i.assign({children:d}).enterScope(l).pushChild(p).assign({context:m||h})}let c=s.read(s.pos,o.pos);if(Dz[r])return i.exitScope(c);if(r===gz){let f=i.children.filter(p=>p.name!=="ContextEntry"),h=f[0],d=xc(f);return OP(i,"ContextEntry",c).assign({value:e.of(i.value).set(h==null?void 0:h.computedValue(),d==null?void 0:d.computedValue())})}if(r===V6||r===X6)return OP(i,"InExpression",c);if(r===U6)return i.define("partial",bc.of(f=>{var h;return(h=xc(f.children))==null?void 0:h.computedValue()}));if(r===sz){let f=xc(i.children).computedValue();return i.define(f,1)}if(r===J6||r===ez||r===tz){let f=i.children.slice(0,-1),h=xc(i.children);return i.assign({children:f}).enterScope("ArithmeticExpression").pushChild(h)}if(r===nz)return i.enterScope("ArithmeticExpression");if(r===z6||r===W6||r===vz)return i.token(c);if(r===cz)return i.literal(c.replace(/^"|"$/g,"").replace(/\\(["\\])/g,"$1"));if(r===uz)return i.literal(c==="true");if(r===lz)return i.literal(parseFloat(c));if(r===az)return i.literal(null);if(r===iz)return i.resolveName();if(r===H6||r===yz)return i.declareName();if((r===_P||r===Y6)&&i.tokens.length>0)throw new Error("uncleared name");if(r===_P){let f=i;for(;f.parent;)f=f.exitScope(c);return f}return i}})}var Bz=Q_({});function Nz(n,e){if(!e.length)return n.assign({value:null});if(e[0].name==="Name"&&(e=$z(e,["m","key"])),e.length!==2)return n.assign({value:null});let[t,i]=e,r=i==null?void 0:i.computedValue(),o=t==null?void 0:t.computedValue();return!o||typeof o!="object"||typeof r!="string"?n.assign({value:null}):n.assign({value:[U_(r),r].reduce((s,a)=>o.get(a)||s,null)})}function $z(n,e){let t={};for(let i=0;it[i])}function xc(n){return n[n.length-1]}var jz=cy({StringLiteral:B.string,NumericLiteral:B.number,BooleanLiteral:B.bool,"AtLiteral!":B.special(B.string),CompareOp:B.compareOperator,ArithOp:B.arithmeticOperator,"for if then else some every return":B.controlKeyword,"in instance of and or satisfies between as":B.operatorKeyword,function:B.definitionKeyword,"Type/...":B.typeName,"Wildcard!":B.modifier,null:B.null,LineComment:B.lineComment,BlockComment:B.blockComment,"VariableName!":B.variableName,'"?"':B.special(B.variableName),"DateTimeConstructor! SpecialFunctionName!":B.standard(B.function(B.variableName)),"FunctionInvocation/VariableName!":B.function(B.variableName),"Name!":B.definition(B.variableName),"Key/Name! ContextEntryType/Name!":B.definition(B.propertyName),"PathExpression/VariableName!":B.propertyName,"FormalParameter/ParameterName!":B.function(B.definition(B.variableName)),"( )":B.paren,"[ ]":B.squareBracket,"{ }":B.brace,".":B.derefOperator,", ;":B.separator,"..":B.punctuation}),Fz={__proto__:null,for:10,in:32,return:36,if:40,then:42,else:44,some:48,every:50,satisfies:56,or:60,and:64,between:72,instance:86,of:89,days:101,time:103,duration:105,years:107,months:109,date:111,list:117,context:123,function:130,null:156,true:330,false:330,"?":170,external:186,not:211},jP=Py.deserialize({version:14,states:"CjO`QYOOO`QYOOO$yQYOOOOQU'#Ce'#CeO%TQYO'#C`O&^QYO'#FQOOQQ'#Fe'#FeO&hQYO'#FeO`QYO'#DVOOQU'#En'#EnO(_Q^O'#D]OOQU'#D^'#D^OOQU'#D]'#D]OOQO'#Fm'#FmO*[QWO'#DvOOQQ'#D}'#D}OOQQ'#EO'#EOOOQQ'#EP'#EPO*aOWO'#ESO*[QWO'#EQOOQQ'#EQ'#EQOOQQ'#Fs'#FsOOQQ'#Fq'#FqOOQQ'#Fy'#FyOOQQ'#EU'#EUO`QYO'#EWOOQQ'#FS'#FSO*iQ^O'#FSO,`QYO'#EXO,gQWO'#EYOOQP'#F}'#F}O,lQXO'#EaOOQQ'#Fz'#FzOOQQ'#FR'#FRQOQWOOOOQQ'#FT'#FTOOQQ'#F^'#F^O`QYO'#CoOOQQ'#F_'#F_O%TQYO'#CsO,zQYO'#DwOOQQ'#Fr'#FrO-PQYO'#EROOQO'#ER'#ERO`QYO'#EVO`QYO'#EUOOQO'#F{'#F{Q-XQWOOO-^QYO'#DRO.TQWO'#FaOOQO'#DT'#DTO.`QYO'#FeO.gQWOOO/^QYO'#CdO/kQYO'#FVOOQQ'#Cc'#CcO/pQYO'#FUOOQQ'#Cb'#CbO/xQYO,58zO`QYO,59iOOQQ'#Fb'#FbOOQQ'#Fc'#FcOOQQ'#Fd'#FdO`QYO,59qO`QYO,59qO`QYO,59qOOQQ'#Fk'#FkO/}QYO,5:^OOQQ'#Fl'#FlO`QYO,5:`O`QYO,59eO`QYO,59gO`QYO,59iO1|QYO,59iO2TQYO,59rOOQQ,5:i,5:iO2YQYO,59qOOQU-E8l-E8lO3|QYO'#FnOOQQ,5:b,5:bOOQQ,5:n,5:nOOQQ,5:l,5:lO4TQYO,5:rOOQQ,5;n,5;nO4_QYO,5:qO4lQWO,5:sO4qQYO,5:tOOQP'#Ee'#EeO5hQXO'#EdOOQO'#Ec'#EcO5oQWO'#EbO5tQWO'#GOO5|QWO,5:{O6RQYO,59ZOOQQ'#Cw'#CwO6YQYO'#F`OOQQ'#Cv'#CvO6bQYO,59_O6gQYO,5:cO6lQYO,5:mO4WQYO,5:qO6qQYO,5:pO`QYO'#EwQ-XQWOOO`QYO'#EmO7hQWO,5;{O`QYOOOOQR'#Cf'#CfOOQQ'#Ej'#EjO8bQYO,59OO`QYO,5;qOOQQ'#FY'#FYO%TQYO'#EkO8rQYO,5;pO`QYO1G.fOOQQ'#F]'#F]O9iQYO1G/TO<`QYO1G/]OhQYO1G/zO>oQYO1G/PO?xQYO1G/ROARQYO1G/TO`QYO1G/TOOQQ1G/T1G/TOAiQYO1G/^OBWQ^O'#CdOCjQYO'#FpOOQO'#Dz'#DzOCtQWO'#DyOCyQWO'#FoOOQO'#Dx'#DxOOQO'#D{'#D{ODRQWO,5fAN>fO/}QYO'#EoO!!]QYO<ZP?RP?UP?Y?z@lAdAjAm$tAsAsPPPPPBk8gCcDZD^EU!kjOPQWilu|}!]!a!b!c!g!h!i!j!k!p#Y#[#^#b#f#q#}$O$X$]$`$o${%V%a%v%wR![SQ!YSR$k#dW!WSw#d$^W#v!p!x$|%TT&Q%j&`#UXOPQWYilu|}!]!a!b!c!e!g!h!i!j!k#Y#[#^#b#f#q#s#}$O$X$]$`$o${%S%V%a%d%i%k%v%w%}&_&c&k&m&n&qb!VSw!x#d$^$|%T%j&`U#`!V#a#tR#t!pU#`!V#a#tT$V!z$WR$j#bR#TwQ#RwR%]$^U!RQ#^#qQ#r!kR$e#[QrQQ$g#^R$q#qQ$z#sQ%q%SQ&P%iU&U%k&c&qQ&f&_T&l&k&nc$s#s%S%i%k&_&c&k&n&q!jkOPQWilu|}!]!a!b!c!g!h!i!j!k!p#Y#[#^#b#f#q#}$O$X$]$`$o${%V%a%v%wQ#l!eU$r#s%S&kS%y%d&m]&O%i%k&_&c&n&q#T[OPQWilu|}!]!a!b!c!e!g!h!i!j!k!p#Y#[#^#b#f#q#s#}$O$X$]$`$o${%S%V%a%d%i%k%v%w&_&c&k&m&n&qR&T%jQ&R%jR&g&`Q&X%kR&p&qS&V%k&qR&i&c!k]OPQWilu|}!]!a!b!c!g!h!i!j!k!p#Y#[#^#b#f#q#}$O$X$]$`$o${%V%a%v%wR#{!pQ#x!pR%m$|S#w!p$|T$R!x%T!keOPQWilu|}!]!a!b!c!g!h!i!j!k!p#Y#[#^#b#f#q#}$O$X$]$`$o${%V%a%v%w!jeOPQWilu|}!]!a!b!c!g!h!i!j!k!p#Y#[#^#b#f#q#}$O$X$]$`$o${%V%a%v%wQ!rbT!{o$Y!kcOPQWilu|}!]!a!b!c!g!h!i!j!k!p#Y#[#^#b#f#q#}$O$X$]$`$o${%V%a%v%w!kdOPQWilu|}!]!a!b!c!g!h!i!j!k!p#Y#[#^#b#f#q#}$O$X$]$`$o${%V%a%v%w!khOPQWilu|}!]!a!b!c!g!h!i!j!k!p#Y#[#^#b#f#q#}$O$X$]$`$o${%V%a%v%w!kpOPQWilu|}!]!a!b!c!g!h!i!j!k!p#Y#[#^#b#f#q#}$O$X$]$`$o${%V%a%v%wR$U!xQ$S!xR%r%TQ%u%VR&Y%vQ!}oR%Y$YT!|o$YS!zo$YT$V!z$WRrQS#a!V#tR$h#aQ#e!YR$l#eQ$_#RR%^$_Q#]!RR$f#]!tYOPQWilu|}!]!a!b!c!e!g!h!i!j!k!p#Y#[#^#b#f#q#s#}$O$X$]$`$o${%S%V%a%d%v%w&kS!oY%}_%}%i%k&_&c&m&n&qQ%e$rS%z%e&]R&]&OQ&a&RR&h&aQ&d&VR&j&dQ$}#xR%n$}S$P!v#uR%R$PQ%U$SR%s%UQ$W!zR%W$WQ$Z!}R%Z$ZQ#Z!PR$d#ZQrOQ!PPR$c#YUTOP#YW!QQ!k#[#^Q!nWQ!tiQ!vlQ#PuQ#W|Q#X}Q#h!]Q#i!aQ#j!bQ#k!cQ#m!gQ#n!hQ#o!iQ#p!jQ#u!pQ$i#bQ$m#fQ$p#qQ%P#}Q%Q$OQ%X$XQ%[$]Q%_$`Q%b$oQ%l${S%t%V%vQ%x%aR&Z%w!kqOPQWilu|}!]!a!b!c!g!h!i!j!k!p#Y#[#^#b#f#q#}$O$X$]$`$o${%V%a%v%w!kSOPQWilu|}!]!a!b!c!g!h!i!j!k!p#Y#[#^#b#f#q#}$O$X$]$`$o${%V%a%v%wR!ZSS!XS#dT#Qw$^R#b!WR#f![!kuOPQWilu|}!]!a!b!c!g!h!i!j!k!p#Y#[#^#b#f#q#}$O$X$]$`$o${%V%a%v%w!kwOPQWilu|}!]!a!b!c!g!h!i!j!k!p#Y#[#^#b#f#q#}$O$X$]$`$o${%V%a%v%wR#SwV!SQ#^#q!V!aT!Q!t!v#P#W#X#h#m#n#o#p#u$i$m$p%P%Q%X%[%_%b%l%t%x&Z!X!bT!Q!t!v#P#W#X#h#i#m#n#o#p#u$i$m$p%P%Q%X%[%_%b%l%t%x&Z!Z!cT!Q!t!v#P#W#X#h#i#j#m#n#o#p#u$i$m$p%P%Q%X%[%_%b%l%t%x&Z!kWOPQWilu|}!]!a!b!c!g!h!i!j!k!p#Y#[#^#b#f#q#}$O$X$]$`$o${%V%a%v%wR&S%jT&W%k&q!_!eT!Q!n!t!v#P#W#X#h#i#j#k#m#n#o#p#u$i$m$p%P%Q%X%[%_%b%l%t%x&Z!_!gT!Q!n!t!v#P#W#X#h#i#j#k#m#n#o#p#u$i$m$p%P%Q%X%[%_%b%l%t%x&Z!k^OPQWilu|}!]!a!b!c!g!h!i!j!k!p#Y#[#^#b#f#q#}$O$X$]$`$o${%V%a%v%wQ!q^R!scR#y!pQ!wlR#z!p!kfOPQWilu|}!]!a!b!c!g!h!i!j!k!p#Y#[#^#b#f#q#}$O$X$]$`$o${%V%a%v%w!klOPQWilu|}!]!a!b!c!g!h!i!j!k!p#Y#[#^#b#f#q#}$O$X$]$`$o${%V%a%v%w!kmOPQWilu|}!]!a!b!c!g!h!i!j!k!p#Y#[#^#b#f#q#}$O$X$]$`$o${%V%a%v%wR$T!x!koOPQWilu|}!]!a!b!c!g!h!i!j!k!p#Y#[#^#b#f#q#}$O$X$]$`$o${%V%a%v%wR#Oo",nodeNames:"\u26A0 LineComment BlockComment Expression ForExpression for InExpressions InExpression Name Identifier Identifier ArithOp ArithOp ArithOp ArithOp ArithOp in IterationContext return IfExpression if then else QuantifiedExpression some every InExpressions InExpression satisfies Disjunction or Conjunction and Comparison CompareOp CompareOp between PositiveUnaryTest ( PositiveUnaryTests ) ArithmeticExpression InstanceOfExpression instance of Type QualifiedName VariableName BacktickIdentifier SpecialType days time duration years months date > ListType list < ContextType context ContextEntryTypes ContextEntryType FunctionType function ArgumentTypes ArgumentType PathExpression ] FilterExpression [ FunctionInvocation SpecialFunctionName NamedParameters NamedParameter ParameterName PositionalParameters null NumericLiteral StringLiteral BooleanLiteral DateTimeLiteral DateTimeConstructor AtLiteral ? SimplePositiveUnaryTest Interval ParenthesizedExpression List FunctionDefinition FormalParameters FormalParameter external FunctionBody } { Context ContextEntry Key Name Identifier Expressions UnaryTests Wildcard not",maxTerm:173,context:Bz,nodeProps:[["group",-17,4,19,23,29,31,33,41,42,68,70,72,85,86,88,89,90,97,"Expr",47,"Expr Expr",-5,78,79,80,81,82,"Expr Literal"],["closedBy",38,")",71,"]",96,"}"],["openedBy",40,"(",69,"[",95,"{"]],propSources:[jz],skippedNodes:[0,1,2],repeatNodeCount:14,tokenData:".v~RvXY#iYZ$^Z[#i]^$^pq#iqr$crs$nwx(Wxy(]yz(bz{(g{|(t|}(y}!O)O!O!P)]!P!Q*g!Q![,b![!],y!]!^-O!^!_-T!_!`$i!`!a-d!b!c-n!}#O-s#P#Q-x#Q#R(o#S#T-}#o#p.l#q#r.q$f$g#i#BY#BZ#i$IS$I_#i$I|$I}$^$I}$JO$^$JT$JU#i$KV$KW#i&FU&FV#i?HT?HU#i~#nY#r~XY#iZ[#ipq#i$f$g#i#BY#BZ#i$IS$I_#i$JT$JU#i$KV$KW#i&FU&FV#i?HT?HU#i~$cO#s~~$fP!_!`$i~$nOr~~$qXOY$nYZ%^Zr$nrs&zs#O$n#O#P'R#P;'S$n;'S;=`(Q<%lO$n~%aVOr%^rs%vs#O%^#O#P%{#P;'S%^;'S;=`&t<%lO%^~%{O$i~~&ORO;'S%^;'S;=`&X;=`O%^~&[WOr%^rs%vs#O%^#O#P%{#P;'S%^;'S;=`&t;=`<%l%^<%lO%^~&wP;=`<%l%^~'RO$i~$j~~'URO;'S$n;'S;=`'_;=`O$n~'bYOY$nYZ%^Zr$nrs&zs#O$n#O#P'R#P;'S$n;'S;=`(Q;=`<%l$n<%lO$n~(TP;=`<%l$n~(]O#{~~(bOv~~(gOx~~(lP^~z{(o~(tO_~~(yO[~~)OO$O~R)TPZP!`!a)WQ)]O$^Q~)bQ#z~!O!P)h!Q![)m~)mO#}~~)rR$h~!Q![)m!g!h){#X#Y){~*OR{|*X}!O*X!Q![*_~*[P!Q![*_~*dP$h~!Q![*_~*lQ]~z{*r!P!Q+y~*uTOz*rz{+U{;'S*r;'S;=`+s<%lO*r~+XVOz*rz{+U{!P*r!P!Q+n!Q;'S*r;'S;=`+s<%lO*r~+sOQ~~+vP;=`<%l*r~,OSP~OY+yZ;'S+y;'S;=`,[<%lO+y~,_P;=`<%l+y~,gS$h~!O!P,s!Q![,b!g!h){#X#Y){~,vP!Q![)m~-OO$[~~-TO$s~R-[P!]QsP!_!`-_P-dOsPR-kP!YQsP!_!`-_~-sO$l~~-xO!i~~-}O!g~~.QTO#S-}#S#T.a#T;'S-};'S;=`.f<%lO-}~.fO$Y~~.iP;=`<%l-}~.qO#S~~.vO#R~",tokenizers:[Tz,Rz,Az,0,1],topRules:{Expression:[0,3],Expressions:[1,102],UnaryTests:[2,103]},dialects:{camunda:2564},dynamicPrecedences:{31:-1,68:1,72:-1,74:-1},specialized:[{term:122,get:n=>Fz[n]||-1}],tokenPrec:2567});function qz(n){let e=[];return n.iterate({enter:t=>{let i=t.node;if(!i.type.isError)return;let r=i.parent,o=qP(i),s={from:i.from,to:i.to,severity:"error",type:"Syntax Error"};if(i.from!==i.to)s.message=`Unrecognized token in <${r.name}>`;else if(o)s.message=`Unrecognized token <${o.name}> in <${r.name}>`,s.to=o.to;else{let a=r.enterUnfinishedNodesBefore(i.to);s.message=`Incomplete <${(a||r).name}>`}e.push(s)}}),e}function qP(n){return n?n.nextSibling||qP(n.parent):null}var Vz="first-item",Hz={create(n){return{enter(e){if(e.name!=="FilterExpression")return;let t=n.readContent(e.from,e.to);if(FP().test(t)){let{from:i,to:r}=e;n.report({from:i,to:r,message:"First item is accessed via [1]",severity:"warning",type:Vz,actions:[{name:"fix",apply(o,s=i,a=r){n.updateContent(s,a,t.replace(FP(),"[1]"))}}]})}}}}};function FP(){return/\[\s*0\s*\]$/}var zz=[Hz];function Wz(n){let{readContent:e,syntaxTree:t,updateContent:i}=n,r=[],o={readContent:e,report:a=>{r.push(a)},updateContent:i},s=zz.map(a=>a.create(o));return t.iterate({enter:a=>{for(let l of s)l.enter&&l.enter(a)},leave:a=>{for(let l of s)l.leave&&l.leave(a)}}),r}function Uz(n){return[...qz(n.syntaxTree),...Wz(n)]}var VP=()=>n=>{if(n.state.doc.length===0)return[];let e=lt(n.state);return Uz({syntaxTree:e,readContent:(i,r)=>n.state.sliceDoc(i,r),updateContent:(i,r,o)=>n.dispatch({changes:{from:i,to:r,insert:o}})}).map(i=>({...i,source:i.type}))};var G_=[li("function(${params}) ${body}",{label:"function",detail:"definition",type:"keyword"}),li("for ${var} in ${collection} return ${value}",{label:"for",detail:"expression",type:"keyword"}),li("every ${var} in ${collection} satisfies ${condition}",{label:"every",detail:"quantified expression",type:"keyword"}),li("some ${var} in ${collection} satisfies ${condition}",{label:"some",detail:"quantified expression",type:"keyword"}),li("if ${condition} then ${value} else ${other value}",{label:"if",detail:"block",type:"keyword"}),li("{ ${key}: ${value} }",{label:"context",detail:"block",type:"keyword"}),li("null",{label:"null",detail:"literal",type:"keyword"}),li("true",{label:"true",detail:"literal",type:"keyword"}),li("false",{label:"false",detail:"literal",type:"keyword"})];function K_(){return K_=Object.assign?Object.assign.bind():function(n){for(var e=1;e{let{state:i,pos:r}=t,o=UP(lt(i).resolveInner(r,-1),e);if(o){let[s,a]=o;if(HP.includes(a))return null}return n(t)}}function Gz(n){return Kz(pc(n.map(e=>K_({},e,{type:"text"}))))}function zP(n,e,t){return WP(n,e,t,-1)}function Xz(n,e,t){return WP(n,e,t,1)}function WP(n,e,t,i){let r=n[i>0?"childAfter":"childBefore"](e);for(;r;){if(t.includes(r.name))return r;if(r.type.isError&&r.firstChild&&t.includes(r.firstChild.name))return r.firstChild;r=r[i>0?"nextSibling":"prevSibling"]}return null}function UP(n,e){for(Array.isArray(e)||(e=[e]);n;n=n.parent){let t=n.type,i=e.find(r=>r&&t.is(r));if(i)return[n,i];if(t.isTop)break}return null}function Yz(n,e){let{nodes:t,before:i,after:r,keyword:o}=n;return s=>{let{state:a,pos:l}=s,c=UP(lt(a).resolveInner(l,-1),t);if(!c)return null;let[u]=c;return zP(u,l,[o,i])||Xz(u,l,[o,r])||r&&!zP(u,l,[r])?null:e(s)}}var QP=uy.define({parser:jP.configure({props:[t_.add({Context:n_({closing:"}"}),"List FilterExpression":n_({closing:"]"}),"ParenthesizedExpression FunctionInvocation":dy({except:/^\s*\)/}),"ForExpression QuantifiedExpression IfExpression":dy({except:/^\s*(then|else|return|satisfies)\b/}),FunctionDefinition:dy({except:/^\s*(\(|\))/})}),eM.add({Context:py,List:py,ParenthesizedExpression:py,FunctionDefinition(n){let e=n.getChild(")");return e?{from:e.to,to:n.to}:null}})]}),languageData:{indentOnInput:/^\s*(\)|\}|\]|then|else|return|satisfies)$/,commentTokens:{line:"//",block:{open:"/*",close:"*/"}}}}),Zz=QP.configure({top:"UnaryTests"},"FEEL unary tests"),Jz=QP.configure({top:"Expression"},"FEEL expression");function KP(n={}){let e=n.dialect==="unaryTests"?Zz:Jz,t=n.parserDialect,i=Q_(n.context),r=e.configure({contextTracker:i,dialect:t}),o=n.completions||[Gz(G_),X_].flat();return new fy(r,[...o.map(s=>r.data.of({autocomplete:s}))])}var eW=[{name:"not",type:"function",params:[{name:"negand"}],info:`

    Returns the logical negation of the given value.

    Function signature

    not(negand: boolean): boolean
    

    Examples

    not(true)
    // false
    
    not(null)
    // null
    
    `},{name:"get value",type:"function",params:[{name:"context"},{name:"key"}],info:`

    Returns the value of the context entry with the given key.

    Function signature

    get value(context: context, key: string): Any
    

    Examples

    get value({foo: 123}, "foo")
    // 123
    
    get value({a: 1}, "b")
    // null
    
    `},{name:"get entries",type:"function",params:[{name:"context"}],info:`

    Returns the entries of the context as a list of key-value-pairs.

    Function signature

    get entries(context: context): list<context>
    

    The return value is a list of contexts. Each context contains two entries for "key" and "value".

    Examples

    get entries({foo: 123})
    // [{key: "foo", value: 123}]
    
    `},{name:"context put",type:"function",params:[{name:"context"},{name:"keys"},{name:"value"}],info:`

    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.

    If keys contains the keys [k1, k2] then it adds the nested entry k1.k2 = value to the context.

    If an entry for the same keys already exists in the context, it overrides the value.

    If keys are empty, it returns null.

    Function signature

    context put(context: context, keys: list<string>, value: Any): context
    

    Examples

    context put({x:1}, ["y"], 2)
    // {x:1, y:2}
    
    context put({x:1, y: {z:0}}, ["y", "z"], 2)
    // {x:1, y: {z:2}}
    
    context put({x:1}, ["y", "z"], 2)
    // {x:1, y: {z:2}}
    
    `},{name:"string",type:"function",params:[{name:"from"}],info:`

    Returns the given value as a string representation.

    Function signature

    string(from: Any): string
    

    Examples

    string(1.1)
    // "1.1"
    
    string(date("2012-12-25"))
    // "2012-12-25"
    
    `},{name:"number",type:"function",params:[{name:"from"}],info:`

    Parses the given string to a number.

    Returns null if the string is not a number.

    Function signature

    number(from: string): number
    

    Examples

    number("1500.5")
    // 1500.5
    
    `},{name:"number",type:"function",params:[{name:"from"},{name:"grouping separator"}],info:`

    Parses the given string to a number using the specified grouping separator.

    Returns null if the string is not a number.

    Function signature

    number(from: string, grouping separator: string): number
    

    Examples

    number("1,500", ",")
    // 1500
    
    `},{name:"number",type:"function",params:[{name:"from"},{name:"grouping separator"},{name:"decimal separator"}],info:`

    Parses the given string to a number using the specified grouping and decimal separators.

    Returns null if the string is not a number.

    Function signature

    number(from: string, grouping separator: string, decimal separator: string): number
    

    Examples

    number("1 500.5", " ", ".")
    // 1500.5
    
    `},{name:"context",type:"function",params:[{name:"entries"}],info:`

    Constructs a context of the given list of key-value pairs. It is the reverse function to get entries().

    Each key-value pair must be a context with two entries: key and value. The entry with name key must have a value of the type string.

    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.

    Returns null if one of the entries is not a context or if a context doesn't contain the required entries.

    Function signature

    context(entries: list<context>): context
    

    Examples

    context([{"key":"a", "value":1}, {"key":"b", "value":2}])
    // {a:1, b:2}
    
    `},{name:"date",type:"function",params:[{name:"from"}],info:`

    Returns a date from the given value.

    Returns null if the string is not a valid calendar date. For example, "2024-06-31" is invalid because June has only 30 days.

    Function signature

    date(from: string): date
    

    Parses the given string into a date.

    date(from: date and time): date
    

    Extracts the date component from the given date and time.

    Examples

    date("2018-04-29")
    // date("2018-04-29")
    
    date(date and time("2012-12-25T11:00:00"))
    // date("2012-12-25")
    
    `},{name:"date",type:"function",params:[{name:"year"},{name:"month"},{name:"day"}],info:`

    Returns a date from the given components.

    Returns null if the components don't represent a valid calendar date. For example, 2024,6,31 is invalid because June has only 30 days.

    Function signature

    date(year: number, month: number, day: number): date
    

    Examples

    date(2012, 12, 25)
    // date("2012-12-25")
    
    `},{name:"time",type:"function",params:[{name:"from"}],info:`

    Returns a time from the given value.

    Function signature

    time(from: string): time
    

    Parses the given string into a time.

    time(from: date and time): time
    

    Extracts the time component from the given date and time.

    Examples

    time("12:00:00")
    // time("12:00:00")
    
    time(date and time("2012-12-25T11:00:00"))
    // time("11:00:00")
    
    `},{name:"time",type:"function",params:[{name:"hour"},{name:"minute"},{name:"second"}],info:`

    Returns a time from the given components.

    Function signature

    time(hour: number, minute: number, second: number): time
    

    Examples

    time(23, 59, 0)
    // time("23:59:00")
    
    `},{name:"time",type:"function",params:[{name:"hour"},{name:"minute"},{name:"second"},{name:"offset"}],info:`

    Returns a time from the given components, including a timezone offset.

    Function signature

    time(hour: number, minute: number, second: number, offset: days and time duration): time
    

    Examples

    time(14, 30, 0, duration("PT1H"))
    // time("14:30:00+01:00")
    
    `},{name:"date and time",type:"function",params:[{name:"from"}],info:`

    Parses the given string into a date and time. The function supports strings in the format YYYY-MM-DDThh:mm:ss with optional timezone information either as offset (e.g., +01:00 or Z), as IANA timezone ID (e.g., @Europe/Berlin), or as a combination of both (e.g., +01:00[Europe/Berlin]).

    Returns null if the string is not a valid calendar date. For example, "2024-06-31T10:00:00" is invalid because June has only 30 days.

    Function signature

    date and time(from: string): date and time
    

    Examples

    date and time("2018-04-29T09:30:00")
    // date and time("2018-04-29T09:30:00")
    
    date and time("2018-04-29T09:30:00+02:00")
    // date and time("2018-04-29T09:30:00+02:00")
    
    date and time("2018-04-29T09:30:00@Europe/Berlin")
    // date and time("2018-04-29T09:30:00@Europe/Berlin")
    
    date and time("2018-04-29T09:30:00+02:00[Europe/Berlin]")
    // date and time("2018-04-29T09:30:00@Europe/Berlin")
    
    `},{name:"date and time",type:"function",params:[{name:"date"},{name:"time"}],info:`

    Returns a date and time from the given components.

    Function signature

    date and time(date: date, time: time): date and time
    
    date and time(date: date and time, time: time): date and time
    

    Returns a date and time value that consists of the date component of date combined with time.

    Examples

    date and time(date("2012-12-24"),time("T23:59:00"))
    // date and time("2012-12-24T23:59:00")
    
    date and time(date and time("2012-12-25T11:00:00"),time("T23:59:00"))
    // date and time("2012-12-25T23:59:00")
    
    `},{name:"duration",type:"function",params:[{name:"from"}],info:`

    Parses the given string into a duration. The duration is either a days and time duration or a years and months duration.

    Function signature

    duration(from: string): days and time duration
    
    duration(from: string): years and months duration
    

    Examples

    duration("P5D")
    // duration("P5D")
    
    duration("P32Y")
    // duration("P32Y")
    
    `},{name:"years and months duration",type:"function",params:[{name:"from"},{name:"to"}],info:`

    Returns the years and months duration between from and to.

    Function signature

    years and months duration(from: date, to: date): years and months duration
    

    Examples

    years and months duration(date("2011-12-22"), date("2013-08-24"))
    // duration("P1Y8M")
    
    `},{name:"from json",type:"function",params:[{name:"value"}],info:`

    Parses a JSON string into a FEEL value. The function converts JSON primitives, objects, and arrays into their corresponding FEEL types.

    Returns null if the string is not a valid JSON value.

    Function signature

    from json(value: string): Any
    

    Examples

    from json("{\\"a\\": 1, \\"b\\": 2}")
    // {a: 1, b: 2}
    
    from json("true")
    // true
    
    from json("\\"2023-06-14\\"")
    // "2023-06-14"
    
    `,engines:{camunda:">=8.9"}},{name:"to json",type:"function",params:[{name:"value"}],info:`

    Converts a FEEL value into a JSON string. The function converts FEEL primitives, contexts, and lists into their corresponding JSON types. Temporal values are converted to their ISO 8601 string representation, including timezone information for date and time values (format: 2025-11-24T10:00:00+01:00[Europe/Berlin]).

    Function signature

    to json(value: Any): string
    

    Examples

    to json({a: 1, b: 2})
    // "{\\"a\\":1,\\"b\\":2}"
    
    to json(true)
    // "true"
    
    to json(@"2023-06-14")
    // "\\"2023-06-14\\""
    
    to json(@"2025-11-24T10:00:00@Europe/Berlin")
    // "\\"2025-11-24T10:00:00+01:00[Europe/Berlin]\\""
    
    to json(@"P3Y")
    // "\\"P3Y\\""
    
    `,engines:{camunda:">=8.9"}},{name:"list contains",type:"function",params:[{name:"list"},{name:"element"}],info:`

    Returns true if the given list contains the element. Otherwise, returns false.

    Function signature

    list contains(list: list, element: Any): boolean
    

    Examples

    list contains([1,2,3], 2)
    // true
    
    `},{name:"count",type:"function",params:[{name:"list"}],info:`

    Returns the number of elements of the given list.

    Function signature

    count(list: list): number
    

    Examples

    count([1,2,3])
    // 3
    
    `},{name:"min",type:"function",params:[{name:"list"}],info:`

    Returns the minimum of the given list.

    Function signature

    min(list: list): Any
    

    All elements in list should have the same type and be comparable.

    The parameter list can be passed as a list or as a sequence of elements.

    Examples

    min([1,2,3])
    // 1
    
    min(1,2,3)
    // 1
    
    `},{name:"max",type:"function",params:[{name:"list"}],info:`

    Returns the maximum of the given list.

    Function signature

    max(list: list): Any
    

    All elements in list should have the same type and be comparable.

    The parameter list can be passed as a list or as a sequence of elements.

    Examples

    max([1,2,3])
    // 3
    
    max(1,2,3)
    // 3
    
    `},{name:"sum",type:"function",params:[{name:"list"}],info:`

    Returns the sum of the given list of numbers.

    Function signature

    sum(list: list<number>): number
    

    The parameter list can be passed as a list or as a sequence of elements.

    Examples

    sum([1,2,3])
    // 6
    
    sum(1,2,3)
    // 6
    
    `},{name:"product",type:"function",params:[{name:"list"}],info:`

    Returns the product of the given list of numbers.

    Function signature

    product(list: list<number>): number
    

    The parameter list can be passed as a list or as a sequence of elements.

    Examples

    product([2, 3, 4])
    // 24
    
    product(2, 3, 4)
    // 24
    
    `},{name:"mean",type:"function",params:[{name:"list"}],info:`

    Returns the arithmetic mean (i.e. average) of the given list of numbers.

    Function signature

    mean(list: list<number>): number
    

    The parameter list can be passed as a list or as a sequence of elements.

    Examples

    mean([1,2,3])
    // 2
    
    mean(1,2,3)
    // 2
    
    `},{name:"median",type:"function",params:[{name:"list"}],info:`

    Returns the median element of the given list of numbers.

    Function signature

    median(list: list<number>): number
    

    The parameter list can be passed as a list or as a sequence of elements.

    Examples

    median(8, 2, 5, 3, 4)
    // 4
    
    median([6, 1, 2, 3])
    // 2.5
    
    `},{name:"stddev",type:"function",params:[{name:"list"}],info:`

    Returns the standard deviation of the given list of numbers.

    Function signature

    stddev(list: list<number>): number
    

    The parameter list can be passed as a list or as a sequence of elements.

    Examples

    stddev(2, 4, 7, 5)
    // 2.0816659994661326
    
    stddev([2, 4, 7, 5])
    // 2.0816659994661326
    
    `},{name:"mode",type:"function",params:[{name:"list"}],info:`

    Returns the mode of the given list of numbers.

    Function signature

    mode(list: list<number>): number
    

    The parameter list can be passed as a list or as a sequence of elements.

    Examples

    mode(6, 3, 9, 6, 6)
    // [6]
    
    mode([6, 1, 9, 6, 1])
    // [1, 6]
    
    `},{name:"all",type:"function",params:[{name:"list"}],info:`

    Returns false if any element of the given list is false. Otherwise, returns true.

    If the given list is empty, it returns true.

    Function signature

    all(list: list<boolean>): boolean
    

    The parameter list can be passed as a list or as a sequence of elements.

    Examples

    all([true,false])
    // false
    
    all(false,null,true)
    // false
    

    :::info The function all() replaced the previous function and(). The previous function is deprecated and should not be used anymore. :::

    `},{name:"any",type:"function",params:[{name:"list"}],info:`

    Returns true if any element of the given list is true. Otherwise, returns false.

    If the given list is empty, it returns false.

    Function signature

    any(list: list<boolean>): boolean
    

    The parameter list can be passed as a list or as a sequence of elements.

    Examples

    any([false,true])
    // true
    
    any(false,null,true)
    // true
    

    :::info The function any() replaced the previous function or(). The previous function is deprecated and should not be used anymore. :::

    `},{name:"sublist",type:"function",params:[{name:"list"},{name:"start position"}],info:`

    Returns a partial list of the given value starting at start position.

    Function signature

    sublist(list: list, start position: number): list
    

    The start position starts at the index 1. The last position is -1.

    Examples

    sublist([1,2,3], 2)
    // [2,3]
    
    `},{name:"sublist",type:"function",params:[{name:"list"},{name:"start position"},{name:"length"}],info:`

    Returns a partial list of the given value starting at start position.

    Function signature

    sublist(list: list, start position: number, length: number): list
    

    The start position starts at the index 1. The last position is -1.

    Examples

    sublist([1,2,3], 1, 2)
    // [1,2]
    
    `},{name:"append",type:"function",params:[{name:"list"},{name:"items"}],info:`

    Returns the given list with all items appended.

    Function signature

    append(list: list, items: Any): list
    

    The parameter items can be a single element or a sequence of elements.

    Examples

    append([1], 2, 3)
    // [1,2,3]
    
    `},{name:"concatenate",type:"function",params:[{name:"lists"}],info:`

    Returns a list that includes all elements of the given lists.

    Function signature

    concatenate(lists: list): list
    

    The parameter lists is a sequence of lists.

    Examples

    concatenate([1,2],[3])
    // [1,2,3]
    
    concatenate([1],[2],[3])
    // [1,2,3]
    
    `},{name:"insert before",type:"function",params:[{name:"list"},{name:"position"},{name:"newItem"}],info:`

    Returns the given list with newItem inserted at position.

    Function signature

    insert before(list: list, position: number, newItem: Any): list
    

    The position starts at the index 1. The last position is -1.

    Examples

    insert before([1,3],1,2)
    // [2,1,3]
    
    `},{name:"remove",type:"function",params:[{name:"list"},{name:"position"}],info:`

    Returns the given list without the element at position.

    Function signature

    remove(list: list, position: number): list
    

    The position starts at the index 1. The last position is -1.

    Examples

    remove([1,2,3], 2)
    // [1,3]
    
    `},{name:"reverse",type:"function",params:[{name:"list"}],info:`

    Returns the given list in revered order.

    Function signature

    reverse(list: list): list
    

    Examples

    reverse([1,2,3])
    // [3,2,1]
    
    `},{name:"index of",type:"function",params:[{name:"list"},{name:"match"}],info:`

    Returns an ascending list of positions containing match.

    Function signature

    index of(list: list, match: Any): list<number>
    

    Examples

    index of([1,2,3,2],2)
    // [2,4]
    
    `},{name:"union",type:"function",params:[{name:"list"}],info:`

    Returns a list that includes all elements of the given lists without duplicates.

    Function signature

    union(list: list): list
    

    The parameter list is a sequence of lists.

    Examples

    union([1,2],[2,3])
    // [1,2,3]
    
    `},{name:"distinct values",type:"function",params:[{name:"list"}],info:`

    Returns the given list without duplicates.

    Function signature

    distinct values(list: list): list
    

    Examples

    distinct values([1,2,3,2,1])
    // [1,2,3]
    
    `},{name:"flatten",type:"function",params:[{name:"list"}],info:`

    Returns a list that includes all elements of the given list without nested lists.

    Function signature

    flatten(list: list): list
    

    Examples

    flatten([[1,2],[[3]], 4])
    // [1,2,3,4]
    
    `},{name:"sort",type:"function",params:[{name:"list"},{name:"precedes"}],info:`

    Returns the given list sorted by the precedes function.

    Function signature

    sort(list: list, precedes: function<(Any, Any) -> boolean>): list
    

    Examples

    sort(list: [3,1,4,5,2], precedes: function(x,y) x < y)
    // [1,2,3,4,5]
    
    `},{name:"string join",type:"function",params:[{name:"list"}],info:`

    Joins a list of strings into a single string. This is similar to Java's joining function.

    If an item of the list is null, the item is ignored for the result string. If an item is neither a string nor null, the function returns null instead of a string.

    Function signature

    string join(list: list<string>): string
    

    Examples

    string join(["a","b","c"])
    // "abc"
    
    string join(["a",null,"c"])
    // "ac"
    
    string join([])
    // ""
    
    `},{name:"string join",type:"function",params:[{name:"list"},{name:"delimiter"}],info:`

    Joins a list of strings into a single string. This is similar to Java's joining function.

    If an item of the list is null, the item is ignored for the result string. If an item is neither a string nor null, the function returns null instead of a string.

    The resulting string contains a delimiter between each element.

    Function signature

    string join(list: list<string>, delimiter: string): string
    

    Examples

    string join(["a"], "X")
    // "a"
    
    string join(["a","b","c"], ", ")
    // "a, b, c"
    
    `},{name:"decimal",type:"function",params:[{name:"n"},{name:"scale"}],info:`

    Rounds the given value at the given scale.

    Function signature

    decimal(n: number, scale: number): number
    

    Examples

    decimal(1/3, 2)
    // .33
    
    decimal(1.5, 0)
    // 2
    
    `},{name:"floor",type:"function",params:[{name:"n"}],info:`

    Rounds the given value with rounding mode flooring.

    Function signature

    floor(n: number): number
    

    Examples

    floor(1.5)
    // 1
    
    floor(-1.5)
    // -2
    
    `},{name:"floor",type:"function",params:[{name:"n"},{name:"scale"}],info:`

    Rounds the given value with rounding mode flooring at the given scale.

    Function signature

    floor(n: number, scale: number): number
    

    Examples

    floor(-1.56, 1)
    // -1.6
    
    `},{name:"ceiling",type:"function",params:[{name:"n"}],info:`

    Rounds the given value with rounding mode ceiling.

    Function signature

    ceiling(n: number): number
    

    Examples

    ceiling(1.5)
    // 2
    
    ceiling(-1.5)
    // -1
    
    `},{name:"ceiling",type:"function",params:[{name:"n"},{name:"scale"}],info:`

    Rounds the given value with rounding mode ceiling at the given scale.

    Function signature

    ceiling(n: number, scale: number): number
    

    Examples

    ceiling(-1.56, 1)
    // -1.5
    
    `},{name:"round up",type:"function",params:[{name:"n"},{name:"scale"}],info:`

    Rounds the given value with the rounding mode round-up at the given scale.

    Function signature

    round up(n: number, scale: number): number
    

    Examples

    round up(5.5)
    // 6
    
    round up(-5.5)
    // -6
    
    round up(1.121, 2)
    // 1.13
    
    round up(-1.126, 2)
    // -1.13
    
    `},{name:"round down",type:"function",params:[{name:"n"},{name:"scale"}],info:`

    Rounds the given value with the rounding mode round-down at the given scale.

    Function signature

    round down(n: number, scale: number): number
    

    Examples

    round down(5.5, 0)
    // 5
    
    round down (-5.5, 0)
    // -5
    
    round down (1.121, 2)
    // 1.12
    
    round down (-1.126, 2)
    // -1.12
    
    `},{name:"round half up",type:"function",params:[{name:"n"},{name:"scale"}],info:`

    Rounds the given value with the rounding mode round-half-up at the given scale.

    Function signature

    round half up(n: number, scale: number): number
    

    Examples

    round half up(5.5, 0)
    // 6
    
    round half up(-5.5, 0)
    // -6
    
    round half up(1.121, 2)
    // 1.12
    
    round half up(-1.126, 2)
    // -1.13
    
    `},{name:"round half down",type:"function",params:[{name:"n"},{name:"scale"}],info:`

    Rounds the given value with the rounding mode round-half-down at the given scale.

    Function signature

    round half down(n: number, scale: number): number
    

    Examples

    round half down (5.5, 0)
    // 5
    
    round half down (-5.5, 0)
    // -5
    
    round half down (1.121, 2)
    // 1.12
    
    round half down (-1.126, 2)
    // -1.13
    
    `},{name:"abs",type:"function",params:[{name:"number"}],info:`

    Returns the absolute value of the given numeric value.

    Function signature

    abs(number: number): number
    

    Examples

    abs(10)
    // 10
    
    abs(-10)
    // 10
    
    `},{name:"modulo",type:"function",params:[{name:"dividend"},{name:"divisor"}],info:`

    Returns the remainder of the division of dividend by divisor.

    Function signature

    modulo(dividend: number, divisor: number): number
    

    Examples

    modulo(12, 5)
    // 2
    
    `},{name:"sqrt",type:"function",params:[{name:"number"}],info:`

    Returns the square root of the given value.

    Function signature

    sqrt(number: number): number
    

    Examples

    sqrt(16)
    // 4
    
    `},{name:"log",type:"function",params:[{name:"number"}],info:`

    Returns the natural logarithm (base e) of the given value.

    Function signature

    log(number: number): number
    

    Examples

    log(10)
    // 2.302585092994046
    
    `},{name:"exp",type:"function",params:[{name:"number"}],info:`

    Returns the Euler\u2019s number e raised to the power of the given number .

    Function signature

    exp(number: number): number
    

    Examples

    exp(5)
    // 148.4131591025766
    
    `},{name:"odd",type:"function",params:[{name:"number"}],info:`

    Returns true if the given value is odd. Otherwise, returns false.

    Function signature

    odd(number: number): boolean
    

    Examples

    odd(5)
    // true
    
    odd(2)
    // false
    
    `},{name:"even",type:"function",params:[{name:"number"}],info:`

    Returns true if the given is even. Otherwise, returns false.

    Function signature

    even(number: number): boolean
    

    Examples

    even(5)
    // false
    
    even(2)
    // true
    
    `},{name:"before",type:"function",params:[{name:"point1"},{name:"point2"}],info:`

    Function signature

    before(point1: Any, point2: Any): boolean
    

    Examples

    before(1, 10)
    // true
    
    before(10, 1)
    // false
    
    `},{name:"before",type:"function",params:[{name:"range"},{name:"point"}],info:`

    Function signature

    before(range: range, point: Any): boolean
    

    Examples

    before([1..5], 10)
    // true
    
    `},{name:"before",type:"function",params:[{name:"point"},{name:"range"}],info:`

    Function signature

    before(point: Any, range: range): boolean
    

    Examples

    before(1, [2..5])
    // true
    
    `},{name:"before",type:"function",params:[{name:"range1"},{name:"range2"}],info:`

    Function signature

    before(range1: range, range2: range): boolean
    

    Examples

    before([1..5], [6..10])
    // true
    
    before([1..5),[5..10])
    // true
    
    `},{name:"after",type:"function",params:[{name:"point1"},{name:"point2"}],info:`

    Function signature

    after(point1: Any, point2: Any): boolean
    

    Examples

    after(10, 1)
    // true
    
    after(1, 10)
    // false
    
    `},{name:"after",type:"function",params:[{name:"range"},{name:"point"}],info:`

    Function signature

    after(range: range, point: Any): boolean
    

    Examples

    after([1..5], 10)
    // false
    
    `},{name:"after",type:"function",params:[{name:"point"},{name:"range"}],info:`

    Function signature

    after(point: Any, range: range): boolean
    

    Examples

    after(12, [2..5])
    // true
    
    `},{name:"after",type:"function",params:[{name:"range1"},{name:"range2"}],info:`

    Function signature

    after(range1: range, range2: range): boolean
    

    Examples

    after([6..10], [1..5])
    // true
    
    after([5..10], [1..5))
    // true
    
    `},{name:"meets",type:"function",params:[{name:"range1"},{name:"range2"}],info:`

    Function signature

    meets(range1: range, range2: range): boolean
    

    Examples

    meets([1..5], [5..10])
    // true
    
    meets([1..3], [4..6])
    // false
    
    meets([1..3], [3..5])
    // true
    
    meets([1..5], (5..8])
    // false
    
    `},{name:"met by",type:"function",params:[{name:"range1"},{name:"range2"}],info:`

    Function signature

    met by(range1: range, range2: range): boolean
    

    Examples

    met by([5..10], [1..5])
    // true
    
    met by([3..4], [1..2])
    // false
    
    met by([3..5], [1..3])
    // true
    
    met by((5..8], [1..5))
    // false
    
    met by([5..10], [1..5))
    // false
    
    `},{name:"overlaps",type:"function",params:[{name:"range1"},{name:"range2"}],info:`

    Function signature

    overlaps(range1: range, range2: range): boolean
    

    Examples

    overlaps([5..10], [1..6])
    // true
    
    overlaps((3..7], [1..4])
    // true
    
    overlaps([1..3], (3..6])
    // false
    
    overlaps((5..8], [1..5))
    // false
    
    overlaps([4..10], [1..5))
    // true
    
    `},{name:"overlaps before",type:"function",params:[{name:"range1"},{name:"range2"}],info:`

    Function signature

    overlaps before(range1: range, range2: range): boolean
    

    Examples

    overlaps before([1..5], [4..10])
    // true
    
    overlaps before([3..4], [1..2])
    // false
    
    overlaps before([1..3], (3..5])
    // false
    
    overlaps before([1..5), (3..8])
    // true
    
    overlaps before([1..5), [5..10])
    // false
    
    `},{name:"overlaps after",type:"function",params:[{name:"range1"},{name:"range2"}],info:`

    Function signature

    overlaps after(range1: range, range2: range): boolean
    

    Examples

    overlaps after([4..10], [1..5])
    // true
    
    overlaps after([3..4], [1..2])
    // false
    
    overlaps after([3..5], [1..3))
    // false
    
    overlaps after((5..8], [1..5))
    // false
    
    overlaps after([4..10], [1..5))
    // true
    
    `},{name:"finishes",type:"function",params:[{name:"point"},{name:"range"}],info:`

    Function signature

    finishes(point: Any, range: range): boolean
    

    Examples

    finishes(5, [1..5])
    // true
    
    finishes(10, [1..7])
    // false
    
    `},{name:"finishes",type:"function",params:[{name:"range1"},{name:"range2"}],info:`

    Function signature

    finishes(range1: range, range2: range): boolean
    

    Examples

    finishes([3..5], [1..5])
    // true
    
    finishes((1..5], [1..5))
    // false
    
    finishes([5..10], [1..10))
    // false
    
    `},{name:"finished by",type:"function",params:[{name:"range"},{name:"point"}],info:`

    Function signature

    finished by(range: range, point: Any): boolean
    

    Examples

    finished by([5..10], 10)
    // true
    
    finished by([3..4], 2)
    // false
    
    `},{name:"finished by",type:"function",params:[{name:"range1"},{name:"range2"}],info:`

    Function signature

    finished by(range1: range, range2: range): boolean
    

    Examples

    finished by([1..5], [3..5])
    // true
    
    finished by((5..8], [1..5))
    // false
    
    finished by([5..10], (1..10))
    // false
    
    `},{name:"includes",type:"function",params:[{name:"range"},{name:"point"}],info:`

    Function signature

    includes(range: range, point: Any): boolean
    

    Examples

    includes([5..10], 6)
    // true
    
    includes([3..4], 5)
    // false
    
    `},{name:"includes",type:"function",params:[{name:"range1"},{name:"range2"}],info:`

    Function signature

    includes(range1: range, range2: range): boolean
    

    Examples

    includes([1..10], [4..6])
    // true
    
    includes((5..8], [1..5))
    // false
    
    includes([1..10], [1..5))
    // true
    
    `},{name:"during",type:"function",params:[{name:"point"},{name:"range"}],info:`

    Function signature

    during(point: Any, range: range): boolean
    

    Examples

    during(5, [1..10])
    // true
    
    during(12, [1..10])
    // false
    
    during(1, (1..10])
    // false
    
    `},{name:"during",type:"function",params:[{name:"range1"},{name:"range2"}],info:`

    Function signature

    during(range1: range, range2: range): boolean
    

    Examples

    during([4..6], [1..10))
    // true
    
    during((1..5], (1..10])
    // true
    
    `},{name:"starts",type:"function",params:[{name:"point"},{name:"range"}],info:`

    Function signature

    starts(point: Any, range: range): boolean
    

    Examples

    starts(1, [1..5])
    // true
    
    starts(1, (1..8])
    // false
    
    `},{name:"starts",type:"function",params:[{name:"range1"},{name:"range2"}],info:`

    Function signature

    starts(range1: range, range2: range): boolean
    

    Examples

    starts((1..5], [1..5])
    // false
    
    starts([1..10], [1..5])
    // false
    
    starts((1..5), (1..10))
    // true
    
    `},{name:"started by",type:"function",params:[{name:"range"},{name:"point"}],info:`

    Function signature

    started by(range: range, point: Any): boolean
    

    Examples

    started by([1..10], 1)
    // true
    
    started by((1..10], 1)
    // false
    
    `},{name:"started by",type:"function",params:[{name:"range1"},{name:"range2"}],info:`

    Function signature

    started by(range1: range, range2: range): boolean
    

    Examples

    started by([1..10], [1..5])
    // true
    
    started by((1..10], [1..5))
    // false
    
    started by([1..10], [1..10))
    // true
    
    `},{name:"coincides",type:"function",params:[{name:"point1"},{name:"point2"}],info:`

    Function signature

    coincides(point1: Any, point2: Any): boolean
    

    Examples

    coincides(5, 5)
    // true
    
    coincides(3, 4)
    // false
    
    `},{name:"coincides",type:"function",params:[{name:"range1"},{name:"range2"}],info:`

    Function signature

    coincides(range1: range, range2: range): boolean
    

    Examples

    coincides([1..5], [1..5])
    // true
    
    coincides((1..5], [1..5))
    // false
    
    coincides([1..5], [2..6])
    // false
    
    `},{name:"substring",type:"function",params:[{name:"string"},{name:"start position"}],info:`

    Returns a substring of the given value starting at start position.

    Function signature

    substring(string: string, start position: number): string
    

    The start position starts at the index 1. The last position is -1.

    Examples

    substring("foobar", 3)
    // "obar"
    
    substring("foobar", -2)
    // "ar"
    
    `},{name:"substring",type:"function",params:[{name:"string"},{name:"start position"},{name:"length"}],info:`

    Returns a substring of the given value, starting at start position with the given length. If length is greater than the remaining characters of the value, it returns all characters from start position until the end.

    Function signature

    substring(string: string, start position: number, length: number): string
    

    The start position starts at the index 1. The last position is -1.

    Examples

    substring("foobar", 3, 3)
    // "oba"
    
    substring("foobar", -3, 2)
    // "ba"
    
    substring("foobar", 3, 10)
    // "obar"
    
    `},{name:"string length",type:"function",params:[{name:"string"}],info:`

    Returns the number of characters in the given value.

    Function signature

    string length(string: string): number
    

    Examples

    string length("foo")
    // 3
    
    `},{name:"upper case",type:"function",params:[{name:"string"}],info:`

    Returns the given value with all characters are uppercase.

    Function signature

    upper case(string: string): string
    

    Examples

    upper case("aBc4")
    // "ABC4"
    
    `},{name:"lower case",type:"function",params:[{name:"string"}],info:`

    Returns the given value with all characters are lowercase.

    Function signature

    lower case(string: string): string
    

    Examples

    lower case("aBc4")
    // "abc4"
    
    `},{name:"substring before",type:"function",params:[{name:"string"},{name:"match"}],info:`

    Returns a substring of the given value that contains all characters before match.

    Function signature

    substring before(string: string, match: string): string
    

    Examples

    substring before("foobar", "bar")
    // "foo"
    
    `},{name:"substring after",type:"function",params:[{name:"string"},{name:"match"}],info:`

    Returns a substring of the given value that contains all characters after match.

    Function signature

    substring after(string: string, match: string): string
    

    Examples

    substring after("foobar", "ob")
    // "ar"
    
    `},{name:"contains",type:"function",params:[{name:"string"},{name:"match"}],info:`

    Returns true if the given value contains the substring match. Otherwise, returns false.

    Function signature

    contains(string: string, match: string): boolean
    

    Examples

    contains("foobar", "of")
    // false
    
    `},{name:"starts with",type:"function",params:[{name:"string"},{name:"match"}],info:`

    Returns true if the given value starts with the substring match. Otherwise, returns false.

    Function signature

    starts with(string: string, match: string): boolean
    

    Examples

    starts with("foobar", "fo")
    // true
    
    `},{name:"ends with",type:"function",params:[{name:"string"},{name:"match"}],info:`

    Returns true if the given value ends with the substring match. Otherwise, returns false.

    Function signature

    ends with(string: string, match: string): boolean
    

    Examples

    ends with("foobar", "r")
    // true
    
    `},{name:"matches",type:"function",params:[{name:"input"},{name:"pattern"}],info:`

    Returns true if the given value matches the pattern. Otherwise, returns false.

    Function signature

    matches(input: string, pattern: string): boolean
    

    The pattern is a string that contains a regular expression.

    Examples

    matches("foobar", "^fo*bar")
    // true
    
    `},{name:"matches",type:"function",params:[{name:"input"},{name:"pattern"},{name:"flags"}],info:`

    Returns true if the given value matches the pattern. Otherwise, returns false.

    Function signature

    matches(input: string, pattern: string, flags: string): boolean
    

    The pattern is a string that contains a regular expression.

    The flags can contain one or more of the following characters:

    • s (dot-all)
    • m (multi-line)
    • i (case insensitive)
    • x (comments)

    Examples

    matches("FooBar", "foo", "i")
    // true
    
    `},{name:"replace",type:"function",params:[{name:"input"},{name:"pattern"},{name:"replacement"}],info:`

    Returns the resulting string after replacing all occurrences of pattern with replacement.

    Function signature

    replace(input: string, pattern: string, replacement: string): string
    

    The pattern is a string that contains a regular expression.

    The replacement can access the match groups by using $ and the number of the group, for example, $1 to access the first group.

    Examples

    replace("abcd", "(ab)|(a)", "[1=$1][2=$2]")
    // "[1=ab][2=]cd"
    
    replace("0123456789", "(\\d{3})(\\d{3})(\\d{4})", "($1) $2-$3")
    // "(012) 345-6789"
    
    `},{name:"replace",type:"function",params:[{name:"input"},{name:"pattern"},{name:"replacement"},{name:"flags"}],info:`

    Returns the resulting string after replacing all occurrences of pattern with replacement.

    Function signature

    replace(input: string, pattern: string, replacement: string, flags: string): string
    

    The pattern is a string that contains a regular expression.

    The replacement can access the match groups by using $ and the number of the group, for example, $1 to access the first group.

    The flags can contain one or more of the following characters:

    • s (dot-all)
    • m (multi-line)
    • i (case insensitive)
    • x (comments)

    Examples

    replace("How do you feel?", "Feel", "FEEL", "i")
    // "How do you FEEL?"
    
    `},{name:"split",type:"function",params:[{name:"string"},{name:"delimiter"}],info:`

    Splits the given value into a list of substrings, breaking at each occurrence of the delimiter pattern.

    Function signature

    split(string: string, delimiter: string): list<string>
    

    The delimiter is a string that contains a regular expression.

    Examples

    split("John Doe", "\\s" )
    // ["John", "Doe"]
    
    split("a;b;c;;", ";")
    // ["a", "b", "c", "", ""]
    
    `},{name:"now",type:"function",params:[],info:`

    Returns the current date and time including the timezone.

    Function signature

    now(): date and time
    

    Examples

    now()
    // date and time("2020-07-31T14:27:30@Europe/Berlin")
    
    `},{name:"today",type:"function",params:[],info:`

    Returns the current date.

    Function signature

    today(): date
    

    Examples

    today()
    // date("2020-07-31")
    
    `},{name:"day of week",type:"function",params:[{name:"date"}],info:`

    Returns the day of the week according to the Gregorian calendar. Note that it always returns the English name of the day.

    Function signature

    day of week(date: date): string
    
    day of week(date: date and time): string
    

    Examples

    day of week(date("2019-09-17"))
    // "Tuesday"
    
    day of week(date and time("2019-09-17T12:00:00"))
    // "Tuesday"
    
    `},{name:"day of year",type:"function",params:[{name:"date"}],info:`

    Returns the Gregorian number of the day within the year.

    Function signature

    day of year(date: date): number
    
    day of year(date: date and time): number
    

    Examples

    day of year(date("2019-09-17"))
    // 260
    
    day of year(date and time("2019-09-17T12:00:00"))
    // 260
    
    `},{name:"week of year",type:"function",params:[{name:"date"}],info:`

    Returns the Gregorian number of the week within the year, according to ISO 8601.

    Function signature

    week of year(date: date): number
    
    week of year(date: date and time): number
    

    Examples

    week of year(date("2019-09-17"))
    // 38
    
    week of year(date and time("2019-09-17T12:00:00"))
    // 38
    
    `},{name:"month of year",type:"function",params:[{name:"date"}],info:`

    Returns the month of the year according to the Gregorian calendar. Note that it always returns the English name of the month.

    Function signature

    month of year(date: date): string
    
    month of year(date: date and time): string
    

    Examples

    month of year(date("2019-09-17"))
    // "September"
    
    month of year(date and time("2019-09-17T12:00:00"))
    // "September"
    
    `},{name:"abs",type:"function",params:[{name:"n"}],info:`

    Returns the absolute value of a given duration.

    Function signature

    abs(n: days and time duration): days and time duration
    
    abs(n: years and months duration): years and months duration
    

    Examples

    abs(duration("-PT5H"))
    // "duration("PT5H")"
    
    abs(duration("PT5H"))
    // "duration("PT5H")"
    
    abs(duration("-P2M"))
    // duration("P2M")
    
    `}],tW=[{name:"is defined",type:"function",params:[{name:"value"}],info:`

    Camunda Extension

    Checks if a given value is not null. If the value is null then the function returns false. Otherwise, the function returns true.

    The function requires one argument. Calling is defined() without an argument is invalid.

    Function signature

    is defined(value: Any): boolean
    

    Examples

    is defined(1)
    // true
    
    is defined(null)
    // false
    
    is defined(x)
    // false - if no variable "x" exists
    
    is defined(x.y)
    // false - if no variable "x" exists or it doesn't have a property "y"
    
    is defined()
    // error - expected one argument
    

    :::caution Breaking change

    This function worked differently in previous versions. It returned true if the value was null. Since this version, the function returns false if the value is null.

    :::

    `},{name:"get or else",type:"function",params:[{name:"value"},{name:"default"}],info:`

    Camunda Extension

    Return the provided value parameter if not null, otherwise return the default parameter

    Function signature

    get or else(value: Any, default: Any): Any
    

    Examples

    get or else("this", "default")
    // "this"
    
    get or else(null, "default")
    // "default"
    
    get or else(null, null)
    // null
    
    `,engines:{camunda:">=8.3"}},{name:"assert",type:"function",params:[{name:"value"},{name:"condition"}],info:`

    Camunda Extension

    Verify that the given condition is met. If the condition is true, the function returns the value. Otherwise, the evaluation fails with an error.

    Function signature

    assert(value: Any, condition: Any)
    

    Examples

    assert(x, x != null)
    // "value" - if x is "value"
    // error - if x is null or doesn't exist
    
    assert(x, x >= 0)
    // 4 - if x is 4
    // error - if x is less than zero
    
    `,engines:{camunda:">=8.3"}},{name:"assert",type:"function",params:[{name:"value"},{name:"condition"},{name:"cause"}],info:`

    Camunda Extension

    Verify that the given condition is met. If the condition is true, the function returns the value. Otherwise, the evaluation fails with an error containing the given message.

    Function signature

    assert(value: Any, condition: Any, cause: String)
    

    Examples

    assert(x, x != null, "'x' should not be null")
    // "value" - if x is "value"
    // error('x' should not be null) - if x is null or doesn't exist
    
    assert(x, x >= 0, "'x' should be positive")
    // 4 - if x is 4
    // error('x' should be positive) - if x is less than zero
    
    `,engines:{camunda:">=8.3"}},{name:"get value",type:"function",params:[{name:"context"},{name:"keys"}],info:`

    Camunda Extension

    Returns the value of the context entry for a context path defined by the given keys.

    If keys contains the keys [k1, k2] then it returns the value at the nested entry k1.k2 of the context.

    If keys are empty or the nested entry defined by the keys doesn't exist in the context, it returns null.

    Function signature

    get value(context: context, keys: list<string>): Any
    

    Examples

    get value({x:1, y: {z:0}}, ["y", "z"])
    // 0
    
    get value({x: {y: {z:0}}}, ["x", "y"])
    // {z:0}
    
    get value({a: {b: 3}}, ["b"])
    // null
    
    `},{name:"context put",type:"function",params:[{name:"context"},{name:"key"},{name:"value"}],info:`

    Adds a new entry with the given key and value to the context. Returns a new context that includes the entry.

    If an entry for the same key already exists in the context, it overrides the value.

    Function signature

    context put(context: context, key: string, value: Any): context
    

    Examples

    context put({x:1}, "y", 2)
    // {x:1, y:2}
    

    :::info The function context put() replaced the previous function put() (Camunda Extension). The previous function is deprecated and should not be used anymore. :::

    `},{name:"context merge",type:"function",params:[{name:"contexts"}],info:`

    Union the given contexts. Returns a new context that includes all entries of the given contexts.

    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.

    Function signature

    context merge(contexts: list<context>): context
    

    Examples

    context merge([{x:1}, {y:2}])
    // {x:1, y:2}
    
    context merge([{x:1, y: 0}, {y:2}])
    // {x:1, y:2}
    

    :::info The function context merge() replaced the previous function put all() (Camunda Extension). The previous function is deprecated and should not be used anymore. :::

    `,engines:{camunda:">=8.2"}},{name:"date and time",type:"function",params:[{name:"date"},{name:"timezone"}],info:`

    Camunda Extension

    Returns the given date and time value at the given timezone.

    If date has a different timezone than timezone then it adjusts the time to match the local time of timezone.

    Function signature

    date and time(date: date and time, timezone: string): date and time
    

    Examples

    date and time(@"2020-07-31T14:27:30@Europe/Berlin", "America/Los_Angeles")
    // date and time("2020-07-31T05:27:30@America/Los_Angeles")
    
    date and time(@"2020-07-31T14:27:30", "Z")
    // date and time("2020-07-31T12:27:30Z")
    
    `},{name:"duplicate values",type:"function",params:[{name:"list"}],info:`

    Camunda Extension

    Returns all duplicate values of the given list.

    Function signature

    duplicate values(list: list): list
    

    Examples

    duplicate values([1,2,3,2,1])
    // [1,2]
    
    `,engines:{camunda:">=8.3"}},{name:"string join",type:"function",params:[{name:"list"},{name:"delimiter"},{name:"prefix"},{name:"suffix"}],info:`

    Camunda Extension

    Joins a list of strings into a single string. This is similar to Java's joining function.

    If an item of the list is null, the item is ignored for the result string. If an item is neither a string nor null, the function returns null instead of a string.

    The resulting string starts with prefix, contains a delimiter between each element, and ends with suffix.

    Function signature

    string join(list: list<string>, delimiter: string, prefix: string, suffix: string): string
    

    Examples

    string join(["a","b","c"], ", ", "[", "]")
    // "[a, b, c]"
    
    `},{name:"is empty",type:"function",params:[{name:"list"}],info:`

    Camunda Extension

    Returns true if the given list is empty. Otherwise, returns false.

    Function signature

    is empty(list: list): boolean
    

    Examples

    is empty([])
    // true
    
    is empty([1,2,3])
    // false
    
    `,engines:{camunda:">=8.6"}},{name:"partition",type:"function",params:[{name:"list"},{name:"size"}],info:`

    Camunda Extension

    Returns consecutive sublists of a list, each of the same size (the final list may be smaller).

    If size is less than 0, it returns null.

    Function signature

    partition(list: list, size: number): list
    

    Examples

    partition([1,2,3,4,5], 2)
    // [[1,2], [3,4], [5]]
    
    partition([], 2)
    // []
    
    partition([1,2], 0)
    // null
    
    `,engines:{camunda:">=8.7"}},{name:"fromAi",type:"function",params:[{name:"value"}],info:`

    Camunda Extension

    Returns the unmodified value parameter.

    • The purpose of this function is solely to tag the value as being generated by an AI integration.
    • The actual handling is not performed by the FEEL engine, but by a custom integration such as a connector or a job worker.

    The main use case of this function is for tool definitions used by the AI Agent connector.

    See the following function overloads for additional function parameters.

    Function signature

    fromAi(value: Any): Any
    

    Examples

    fromAi(toolCall.searchQuery)
    // toolCall.searchQuery contents
    
    fromAi(toolCall.userId)
    // toolCall.userId contents
    
    `,engines:{camunda:">=8.8"}},{name:"fromAi",type:"function",params:[{name:"value"},{name:"description"}],info:`

    Camunda Extension

    Returns the unmodified value parameter.

    In addition to the previous overload, it also accepts an optional description parameter to provide a textual description of the value. The description must be null or a string constant.

    Function signature

    fromAi(value: Any, description: string): Any
    

    Examples

    fromAi(toolCall.searchQuery, "The search query used to find the best match.")
    // toolCall.searchQuery contents
    
    fromAi(toolCall.searchQuery, null)
    // toolCall.searchQuery contents
    
    `,engines:{camunda:">=8.8"}},{name:"fromAi",type:"function",params:[{name:"value"},{name:"description"},{name:"type"}],info:`

    Camunda Extension

    Returns the unmodified value parameter.

    In addition to the previous overload, it also accepts an optional type parameter to provide type information about the value. The type must be null or a string constant.

    Function signature

    fromAi(value: Any, description: string, type: string): Any
    

    Examples

    fromAi(toolCall.searchQuery, "The search query used to find the best match.", "string")
    // toolCall.searchQuery contents
    
    fromAi(toolCall.userId, "The user's ID", "number")
    // toolCall.userId contents
    
    fromAi(toolCall.userId, null, "number")
    // toolCall.userId contents
    
    fromAi(value: toolCall.userId, type: "number")
    // toolCall.userId contents
    
    `,engines:{camunda:">=8.8"}},{name:"fromAi",type:"function",params:[{name:"value"},{name:"description"},{name:"type"},{name:"schema"}],info:`

    Camunda Extension

    Returns the unmodified value parameter.

    In addition to the previous overload, it also accepts an optional schema parameter to provide a (partial) JSON schema for the value.

    • The schema must be null or a context (map) containing only constant values. For example, function calls within the schema are not supported.
    • The schema is not validated by the FEEL engine but might be by a custom integration consuming the information.
    • From the engine side it is possible to specify both a type and a schema, and it depends on the integration as to which value takes precedence. The AI Agent connector will override any type specified in the schema if the type parameter is also provided.

    Function signature

    fromAi(value: Any, description: string, type: string, schema: context): Any
    

    Examples

    fromAi(toolCall.documentType, "The document type to provide", "string", {
      enum: ["invoice", "receipt", "contract"]
    })
    // toolCall.documentType contents
    
    fromAi(value: toolCall.documentType, description: "The document type to provide", schema: {
      type: "string",
      enum: ["invoice", "receipt", "contract"]
    })
    // toolCall.documentType contents
    
    fromAi(toolCall.tags, "Tags to apply to the blog post", "array", {
      items: {
        type: "string"
      }
    })
    // toolCall.tags contents
    
    `,engines:{camunda:">=8.8"}},{name:"fromAi",type:"function",params:[{name:"value"},{name:"description"},{name:"type"},{name:"schema"},{name:"options"}],info:`

    Camunda Extension

    Returns the unmodified value parameter.

    In addition to the previous overload, it also accepts an optional options parameter to provide additional options for the integration handling the value definition.

    • The options parameter must be null or a context (map) containing only constant values. For example, function calls within options are not supported.

    Function signature

    fromAi(value: Any, description: string, type: string, schema: context, options: context): Any
    

    Examples

    fromAi(toolCall.documentType, "The document type to provide", "string", null, {
      required: false
    })
    // toolCall.documentType contents
    
    fromAi(value: toolCall.documentType, options: {
      required: false
    })
    // toolCall.documentType contents
    
    `,engines:{camunda:">=8.8"}},{name:"random number",type:"function",params:[],info:`

    Camunda Extension

    Returns a random number between 0 and 1.

    Function signature

    random number(): number
    

    Examples

    random number()
    // 0.9701618132579795
    
    `,engines:{camunda:">=8.2"}},{name:"extract",type:"function",params:[{name:"string"},{name:"pattern"}],info:`

    Camunda Extension

    Returns all matches of the pattern in the given string. Returns an empty list if the pattern doesn't match.

    Function signature

    extract(string: string, pattern: string): list<string>
    

    The pattern is a string that contains a regular expression.

    Examples

    extract("references are 1234, 1256, 1378", "12[0-9]*")
    // ["1234","1256"]
    
    `},{name:"trim",type:"function",params:[{name:"string"}],info:`

    Camunda Extension

    Returns the given string without leading and trailing spaces.

    Function signature

    trim(string: string): string
    

    Examples

    trim("  hello world  ")
    // "hello world"
    
    trim("hello   world ")
    // "hello   world"
    
    `,engines:{camunda:">=8.6"}},{name:"uuid",type:"function",params:[],info:`

    Camunda Extension

    Returns a UUID (Universally Unique Identifier) with 36 characters.

    Function signature

    uuid(): string
    

    Examples

    uuid()
    // "7793aab1-d761-4d38-916b-b7270e309894"
    
    `,engines:{camunda:">=8.6"}},{name:"to base64",type:"function",params:[{name:"value"}],info:`

    Camunda Extension

    Returns the given string encoded in Base64 format.

    Function signature

    to base64(value: string): string
    

    Examples

    to base64("FEEL")
    // "RkVFTA=="
    
    `,engines:{camunda:">=8.6"}},{name:"is blank",type:"function",params:[{name:"string"}],info:`

    Camunda Extension

    Returns true if the given string is blank (empty or contains only whitespaces).

    Function signature

    is blank(string: string): boolean
    

    Examples

    is blank("")
    // true
    
    is blank(" ")
    // true
    
    is blank("hello world")
    // false
    
    `,engines:{camunda:">=8.8"}},{name:"last day of month",type:"function",params:[{name:"date"}],info:`

    Camunda Extension

    Takes the month of the given date or date-time value and returns the last day of this month.

    Function signature

    last day of month(date: date): date
    
    last day of month(date: date and time): date
    

    Examples

    last day of month(date("2022-10-01"))
    // date("2022-10-31"))
    
    last day of month(date and time("2022-10-16T12:00:00"))
    // date("2022-10-31"))
    
    `,engines:{camunda:">=8.2"}}],GP=[...eW,...tW];var nW=[uP(VP())],iW=U.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}}),rW=U.baseTheme({"& .variableName":{color:"#10f"},"& .number":{color:"#164"},"& .string":{color:"#a11"},"& .bool":{color:"#219"},"& .function":{color:"#aa3731",fontWeight:"bold"},"& .control":{color:"#708"}}),oW=nM(uc.define([{tag:B.variableName,class:"variableName"},{tag:B.name,class:"variableName"},{tag:B.number,class:"number"},{tag:B.string,class:"string"},{tag:B.bool,class:"bool"},{tag:B.function(B.variableName),class:"function"},{tag:B.function(B.special(B.variableName)),class:"function"},{tag:B.controlKeyword,class:"control"},{tag:B.operatorKeyword,class:"control"}])),sW=[iW,rW,oW];function XP(n){return n&&n.from===n.to}function aW(n,e){let t=n.nextSibling;return XP(n)||t&&t.from===e&&XP(t)}function lW(n){return n&&n.parent&&n.parent.name==="VariableName"}function Y_(n){return n?n.name==="PathExpression"?!0:Y_(n.parent):!1}function cW({variables:n}){return e=>{let t=lt(e.state).resolve(e.pos,-1);if(!Y_(t))return null;let i=uW(t),r=t===i?e.pos:t.from,o=Z_(i,e),s=n;for(var a=0;af.name===o[a].name);if(!l||l.isList!=="optional"&&!!l.isList!==o[a].isList)return null;s=l.entries}if(!s)return null;let c=s.map(f=>({label:f.name,type:"variable",info:f.info,detail:f.detail}));return{from:r,options:c}}}function uW(n){for(;n;){if(n.name==="PathExpression")return n;n=n.parent}}function Z_(n,e){let t=[];for(let i=n.firstChild;i;i=i.nextSibling)i.name==="PathExpression"?t.push(...Z_(i,e)):i.name==="FilterExpression"?t.push(...fW(i,e)):t.push({name:ZP(i,e),isList:!1});return t}function fW(n,e){let t=n.firstChild;if(t.name==="PathExpression"){let i=Z_(t,e),r=i[i.length-1];return r.isList=!0,i}return[{name:ZP(t,e),isList:!0}]}function ZP(n,e){return e.state.sliceDoc(n.from,n.to)}function hW({variables:n=[],builtins:e=[]}){let t=dW(n,e),i=/^[\w ]*$/;return t.length?r=>{let{pos:o,state:s}=r,a=lt(s).resolve(o,-1);if(aW(a,o))return r.explicit?{from:o,options:t,validFor:i}:null;if(!lW(a)||Y_(a))return null;let l=typeof r.matchBefore=="function"?r.matchBefore(/\w[\w ]*$/):null;return{from:l?l.from:a.from,options:t,validFor:i}}:r=>null}function dW(n,e){return[].concat(n.map(t=>YP(t)),e.map(t=>YP(t)))}function YP(n,e){return n.type==="function"?pW(n,e):{label:n.name,type:"variable",info:n.info,detail:n.detail,boost:e}}function pW(n,e){let{name:t,info:i,detail:r,params:o=[]}=n,s=o.map(({name:u,type:f},h)=>({name:u||`param ${h+1}`,type:f})),a=`${t}(${s.map(u=>"${"+u.name+"}").join(", ")})`,l=s.map(({name:u,type:f})=>f?`${u}: ${f}`:u).join(", "),c=`${t}(${l})`;return li(a,{label:c,type:"function",info:i,detail:r,boost:e})}function mW({variables:n=[],builtins:e=[]}){return[cW({variables:n}),hW({variables:n,builtins:e}),pc(G_),...X_]}function gW(n){return KP(n)}function yW(n){return n.slice().reverse().reduce((e,t)=>(e[t.name]=()=>{},e),{})}var JP=H.define(),e2=H.define(),t2=H.define(),n2=H.define();function i2({dialect:n="expression",parserDialect:e,variables:t=[],builtins:i=[],completions:r=mW({builtins:i,variables:t})}){let o=yW([...t,...i]);return[t2.of(n),JP.of(i),e2.of(t),n2.of(e),gW({dialect:n,parserDialect:e,context:o,completions:r})]}function vW(n){let e=n.facet(JP)[0],t=n.facet(e2)[0],i=n.facet(t2)[0],r=n.facet(n2)[0];return{builtins:e,variables:t,dialect:i,parserDialect:r}}var xW=GP.map(n=>({...n,info:()=>te(n.info)})),r2=new Ns,o2=new Ns;function Ur({extensions:n=[],dialect:e="expression",parserDialect:t,container:i,contentAttributes:r={},tooltipContainer:o,onChange:s=()=>{},onKeyDown:a=()=>{},onLint:l=()=>{},placeholder:c="",readOnly:u=!1,value:f="",builtins:h=xW,variables:d=[]}){this._events=pP();let p=U.updateListener.of(v=>{v.docChanged&&s(v.state.doc.toString())}),m=U.updateListener.of(v=>{let x=v.transactions.flatMap(E=>E.effects).filter(E=>E.is(Kh));if(!x.length)return;let C=x.flatMap(E=>E.value);this._events.emit("lint",{diagnostics:C})}),g=U.domEventObservers({keydown:a});typeof o=="string"&&(o=document.querySelector(o));let b=o?DA({tooltipSpace:function(){return o.getBoundingClientRect()}}):[],_=[wM(),r2.of(i2({dialect:e,builtins:h,variables:d,parserDialect:t})),sM(),JA(),bM(),U.contentAttributes.of(r),p,g,sc.of([...oP]),nW,m,b,o2.of(Ab(c)),sW,...n];return u&&_.push(U.editable.of(!1)),this.on("lint",({diagnostics:v})=>l(v)),this._cmEditor=new U({state:Ze.create({doc:f,extensions:_}),parent:i}),this}Ur.prototype.setValue=function(n){this._cmEditor.dispatch({changes:{from:0,to:this._cmEditor.state.doc.length,insert:n}})};Ur.prototype.focus=function(n){let e=this._cmEditor;if(e.contentDOM.focus(),e.focus(),typeof n=="number"){let t=e.state.doc.length;e.dispatch({selection:{anchor:n<=t?n:t}})}};Ur.prototype.on=function(n,e){this._events.on(n,e)};Ur.prototype.off=function(n,e){this._events.off(n,e)};Ur.prototype.getSelection=function(){return this._cmEditor.state.selection};Ur.prototype.setVariables=function(n){let e=vW(this._cmEditor.state);this._cmEditor.dispatch({effects:[r2.reconfigure(i2({...e,variables:n}))]})};Ur.prototype.setPlaceholder=function(n){this._cmEditor.dispatch({effects:o2.reconfigure(Ab(n))})};var Ri=class extends L{constructor(t,i){var r;super(t,i);M(this,"handleMouseEvent",t=>{t.stopPropagation()});M(this,"handleKeyDownCapture",t=>{if(t.key==="Enter"){if(_W(this.node)){t.triggeredFromAutocomplete=!0;return}this.props.ctrlForNewline&&!bW(t)&&t.preventDefault(),this.props.singleLine&&t.preventDefault()}});M(this,"handleKeyDown",t=>{["Enter","Escape"].includes(t.key)&&t.triggeredFromAutocomplete&&t.stopPropagation()});M(this,"handleChange",t=>{let{onInput:i}=this.props;this.setState({value:t}),i&&i(t)});M(this,"handleBlur",()=>{let{onBlur:t,onChange:i}=this.props;i&&this.state.value!==this.props.value&&i(this.state.value),t&&t()});M(this,"setNode",t=>{this.node=t});this.node=null,this.editor=null,this.state={value:t.value},this._feelLanguageContext=(r=i.injector)==null?void 0:r.get("feelLanguageContext",!1)}_getFeelLanguageContext(){return this._feelLanguageContext&&this._feelLanguageContext.getConfig()}componentDidMount(){let t=this._getFeelLanguageContext();this.editor=new Ur({contentAttributes:{"aria-label":this.props.label},parserDialect:t==null?void 0:t.parserDialect,builtins:t==null?void 0:t.builtins,dialect:this.props.feelLanguageDialect,container:this.node,onChange:this.handleChange,value:this.state.value,variables:this.props.variables||[],extensions:[U.lineWrapping]}),this.node.addEventListener("mousedown",this.handleMouseEvent),this.node.addEventListener("keydown",this.handleKeyDownCapture,!0),this.node.addEventListener("keydown",this.handleKeyDown),this.props.autoFocus&&this.editor.focus(this.state.value.length)}componentDidUpdate(t){let{value:i}=this.props;t.value!==i&&i!==this.state.value&&this.setState({value:i},()=>{this.editor.setValue(i)}),wW(t.variables,this.props.variables)||this.editor.setVariables(this.props.variables)}componentWillUnmount(){this.node.removeEventListener("mousedown",this.handleMouseEvent),this.node.removeEventListener("keydown",this.handleKeyDownCapture,!0),this.node.removeEventListener("keydown",this.handleKeyDown)}render(){return y(1,"div",["literal-expression",this.props.className||""].join(" "),null,1,{onClick:this.handleMouseEvent,onFocusIn:this.props.onFocus,onFocusOut:this.handleBlur},null,this.setNode)}};function bW(n){return n.metaKey||n.ctrlKey}function _W(n){return n.querySelector(".cm-tooltip-autocomplete")}function wW(n,e){return JSON.stringify(n)===JSON.stringify(e)}var Yh=class extends L{constructor(t,i){super(t,i);M(this,"handleKeyDown",t=>{t.key==="Enter"&&t.stopPropagation()});this.translate=i.injector.get("translate"),this.expressionLanguages=i.injector.get("expressionLanguages",!1),this.variableResolver=i.injector.get("variableResolver",!1),this.handleValue=r=>{let o={text:r};this.handleChange(o)},this.handleLabelChange=r=>{var o=r||void 0;this.handleChange({label:o})}}handleChange(t){var{onChange:i}=this.props;typeof i=="function"&&i(t)}getExpressionEditorComponent(){return this.expressionLanguages&&this.expressionLanguages.getDefault("inputCell").value!=="feel"?Tn:Ri}_getVariables(){return this.variableResolver&&this.variableResolver.getVariables(this.props.element)}render(){let{label:t,text:i}=this.props,r=this.getExpressionEditorComponent(),o=this._getVariables();return y(1,"div","context-menu-container ref-input-editor input-edit",[y(1,"div","dms-form-control",P(2,Tn,{label:this.translate("Input label"),className:"dms-input-label",value:t||"",placeholder:this.translate("Input"),singleLine:!0,onInput:this.handleLabelChange}),2),y(1,"div","dms-form-control",[y(1,"label","dms-label",this.translate("Expression"),0),P(2,r,{label:this.translate("Input expression"),placeholder:this.translate("Enter expression"),className:["ref-text","dms-input"].join(" "),onInput:this.handleValue,value:i||"",variables:o})],4)],4,{onKeyDown:this.handleKeyDown})}};var _c=class extends L{constructor(t,i){super(t,i);M(this,"persistChanges",()=>{let{input:t}=this.props.context,{unsaved:i}=this.state;if(!i)return;let{label:r,...o}=i;var s={};"label"in i&&(s.label=r),CW(o)&&(s.inputExpression=o),this.modeling.updateProperties(t,s),this.setState({unsaved:!1})});M(this,"handleChange",t=>{this.setState({unsaved:{...this.state.unsaved,...t}},this.persistChanges)});this.state={},Ce(this),this.persistChanges=this.debounceInput(this.persistChanges)}getValue(t){let{input:i}=this.props.context,{unsaved:r}=this.state,o=i;return t==="text"&&(o=o.inputExpression),r&&t in r?r[t]:o.get(t)}render(){return P(2,Yh,{label:this.getValue("label"),text:this.getValue("text"),element:this.props.context.input,onChange:this.handleChange})}};_c.$inject=["debounceInput","modeling","injector"];function CW(n){return Object.keys(n).length}var Iy=class extends L{constructor(t,i){super(t,i);M(this,"onClick",t=>{let{col:i}=this.props;this._eventBus.fire("input.edit",{event:t,input:i})});this._translate=i.injector.get("translate"),this._eventBus=i.injector.get("eventBus")}render(){return y(1,"button","edit-button dmn-icon-edit",null,1,{"aria-label":this._translate("Edit input"),type:"button",onClick:this.onClick})}};var wc=class{constructor(e,t,i,r){e.onGetComponent("cell",({cellType:o})=>{if(o==="input-header")return fh}),e.onGetComponent("context-menu",(o={})=>{if(o.contextMenuType==="input-edit")return _c}),e.onGetComponent("cell-inner",(o={})=>{let{cellType:s}=o;if(s==="input-cell")return Iy}),i.on("input.edit",({event:o,input:s})=>{let{target:a}=o,l=De(a,"th",!0),{left:c,top:u}=l.getBoundingClientRect();t.open({x:c,y:u,align:"bottom-right"},{contextMenuType:"input-edit",input:s})})}};wc.$inject=["components","contextMenu","eventBus","renderer"];var pe=class extends L{constructor(t,i){super(t,i);M(this,"onChange",t=>{this.setState({value:t});let{onChange:i}=this.props;typeof i=="function"&&i(t)});M(this,"onInputClick",t=>{t.preventDefault(),t.stopPropagation(),this.setOptionsVisible(!this.state.optionsVisible),this.focusInput()});M(this,"onInput",t=>{let{value:i}=t.target;this.onChange(i)});M(this,"onOptionClick",(t,i)=>{i.preventDefault(),i.stopPropagation(),this.setOptionsVisible(!1),this.onChange(t),this.focusInput()});M(this,"onFocusChanged",t=>{this.checkClose(t.target)});M(this,"onGlobalClick",t=>{this.checkClose(t.target)});M(this,"onKeyDown",t=>{let{optionsVisible:i}=this.state;var r=t.which;(r===40||r===38)&&(t.stopPropagation(),t.preventDefault(),i?this.select(r===40?1:-1):this.setOptionsVisible(!0)),i&&(r===13||r===27)&&(t.stopPropagation(),t.preventDefault(),this.setOptionsVisible(!1))});M(this,"onKeyboard",t=>{let{optionsVisible:i}=this.state;if(i&&t===27)return this.setOptionsVisible(!1),!0});Ce(this);let{value:r}=t;this.state={value:r,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(t){let{value:i}=t;this.setState({value:i})}componentWillUpdate(t,i){let{optionsVisible:r}=i;r?this._portalEl||this.addPortalEl():this._portalEl&&this.removePortalEl()}componentDidUpdate(){let{optionsVisible:t}=this.state;if(!t||!this.inputNode)return;let i=this.getOptionsBounds();T(this._portalEl.style,i)}getOptionsBounds(){let t=this.renderer.getContainer(),{top:i,left:r,bottom:o}=t.getBoundingClientRect(),{top:s,left:a,width:l,height:c,bottom:u}=this.inputNode.getBoundingClientRect(),f=s+c-i+t.scrollTop,h=a-r+t.scrollLeft,d={top:`${f}px`,left:`${h}px`,width:`${l}px`,"max-height":`calc(100% - ${f}px)`};if(o-u
    '),this.renderer.getContainer().appendChild(this._portalEl),this._portalEl.addEventListener("mousedown",s2)}removePortalEl(){this._portalEl&&(this._portalEl.removeEventListener("mousedown",s2),Qe(this._portalEl),this._portalEl=null)}focusInput(){let t=this.inputNode;t.focus(),"selectionStart"in t&&(t.selectionStart=1e5)}checkClose(t){this._portalEl&&!this._portalEl.contains(t)&&!this.parentNode.contains(t)&&this.setOptionsVisible(!1)}select(t){let{options:i}=this.props,{value:r}=this.state;if(!i)return;let o=i.filter(c=>c.value===r)[0],s=o?i.indexOf(o):-1,a=s===-1?t===1?0:i.length-1:(s+t)%i.length,l=i[a<0?i.length+a:a];this.onChange(l.value)}setOptionsVisible(t){this.setState({optionsVisible:t})}renderOptions(t,i){return y(1,"div","options",t.map(r=>y(1,"div",["option",i===r?"active":""].join(" "),r.label,0,{"data-value":r.value,onClick:o=>this.onOptionClick(r.value,o)})),0)}render(){let{className:t,label:i,id:r,options:o,noInput:s,title:a}=this.props,{optionsVisible:l,value:c}=this.state,u=o?o.filter(h=>h.value===c)[0]:!1,f=u?u.label:c;return y(1,"div",[t||"","dms-input-select"].join(" "),[s?y(1,"div","dms-input",f,0,{"aria-label":i,tabIndex:"0",onKeyDown:this.onKeyDown},null,h=>this.inputNode=h):y(64,"input","dms-input",null,1,{"aria-label":i,onInput:this.onInput,onKeyDown:this.onKeyDown,spellCheck:"false",type:"text",value:c,id:r},null,h=>this.inputNode=h),y(1,"span",["dms-input-select-icon",l?"dmn-icon-up":"dmn-icon-down"].join(" ")),l&&PC(this.renderOptions(o,u),this._portalEl)],0,{title:a,onClick:this.onInputClick},null,h=>this.parentNode=h)}};pe.$inject=["keyboard","renderer"];function s2(n){n.stopPropagation()}var Zh=class extends L{constructor(t,i){super(t);M(this,"onTypeChange",t=>{let i=this.getElement(),r=O(i,"dmn:LiteralExpression")?i.$parent:i,o;ie(r)?o={inputExpression:{typeRef:t}}:Te(r)&&(o={typeRef:t}),this._modeling.updateProperties(r,o)});this._translate=i.injector.get("translate"),this._modeling=i.injector.get("modeling"),this._dataTypes=i.injector.get("dataTypes")}getElement(){return this.props.context.input||this.props.context.output}render(){let t=this.getElement(),i=(O(t,"dmn:InputClause")?t.inputExpression:t).typeRef,r=this._dataTypes.getAll().map(s=>({label:this._translate(s),value:s})),o=this._translate("Type");return y(1,"div","type-ref-edit context-menu-container",y(1,"div","dms-form-control",[y(1,"label","dms-label",[o,Z(":")],0),P(2,pe,{className:"type-ref-edit-select",label:o,onChange:this.onTypeChange,options:r,value:i})],4),2)}};var EW=750,Cc=class{constructor(e){e.onGetComponent("context-menu",EW,(t={})=>{let{contextMenuType:i}=t;if(i==="input-edit"||i==="output-edit")return Zh})}};Cc.$inject=["components"];var a2={__depends__:[Gt,Xi],__init__:["typeRefEditingProvider"],typeRefEditingProvider:["type",Cc]};var Ec=class extends ae{constructor(e,t){super(e),this.postExecuted("element.updateProperties",i=>{let{element:r,properties:o}=i.context,s=ie(r)?o.inputExpression:o;if(s&&s.typeRef&&s.typeRef!=="string"){let a=O(r,"dmn:LiteralExpression")?r.$parent:r;t.editAllowedValues(a,null)}})}};Ec.$inject=["eventBus","modeling"];var SW="radio",OW="remove dmn-icon-clear",Js=class extends L{constructor(t,i){super(t,i);M(this,"getRemoveClickHandler",t=>i=>{i.stopPropagation(),this.removeItem(t)});M(this,"getToggleClickHandler",t=>i=>{i.stopPropagation(),this.toggleItem(t)});M(this,"removeItem",t=>{let{onChange:i}=this.props,r=this.state.items.filter(o=>o!==t);this.setState({items:r}),i&&i(r)});M(this,"toggleItem",t=>{let{onChange:i,type:r}=this.props,o=this.state.items.map(s=>(s===t?s.isChecked=!s.isChecked:r===SW&&(s.isChecked=!1),s));this.setState({items:o}),i&&i(o)});let{items:r}=t;this.state={items:r}}componentWillReceiveProps(t){let{items:i}=t;this.setState({items:i})}render(){let{className:t,items:i,type:r,labelComponent:o}=this.props,s=["dms-list-component"];t&&s.push(t);let a=ur(i,"group"),l=kW(a);return y(1,"div",s.join(" "),l.map(c=>{let u=c[0],f=c[1];return y(1,"div","group",[o&&o(u)||y(1,"h4","dms-heading",u,0),y(1,"ul","items no-wrap",f.map(h=>y(1,"li","item",[r&&y(64,"input","item-toggle",null,1,{type:r,checked:h.isChecked,onClick:this.getToggleClickHandler(h)}),Z("\xA0"),h.value,h.isRemovable&&y(1,"span",OW,null,1,{title:"Remove item",onClick:this.getRemoveClickHandler(h)})],0)),0)],0)}),0)}};function kW(n){let e=[];for(let t in n)e.push([t,n[t]]);return e}var ot=class extends L{constructor(e,t){super(e,t);let{validate:i,value:r}=e,o=i?i(r||""):void 0;this.state={validationWarning:o,value:r},this.onInput=this.onInput.bind(this),this.onKeyDown=this.onKeyDown.bind(this),this.onKeyUp=this.onKeyUp.bind(this)}componentWillReceiveProps(e){let{validate:t,value:i}=e,r=t?t(i||""):void 0;this.setState({validationWarning:r,value:i})}onInput(e){let{onInput:t,validate:i}=this.props,r=i?i(e):void 0;this.setState({validationWarning:r,value:e}),typeof t=="function"&&t&&t({isValid:!r,value:e})}onKeyDown(e){let{target:t}=e,{value:i}=t,{onKeyDown:r,validate:o}=this.props,s=o?o(i):void 0;typeof r=="function"&&r({isValid:!s,value:i,event:e})}onKeyUp(e){let{target:t}=e,{value:i}=t,{onKeyUp:r,validate:o}=this.props,s=o?o(i):void 0;typeof r=="function"&&r({isValid:!s,value:i,event:e})}render(){let{placeholder:e,type:t,className:i,label:r}=this.props,{validationWarning:o,value:s}=this.state,a=["dms-validated-input",i].join(" "),l=[];return o&&l.push("invalid"),y(1,"div",a,[P(2,St,{className:l,label:r,onInput:this.onInput,onKeyDown:this.onKeyDown,onKeyUp:this.onKeyUp,placeholder:e||"",type:t,value:s||""}),o&&y(1,"p","dms-hint dms-validation-warning",o,0)],0)}};function Ly(n){if(!n||RW(n.trim()))return{values:[]};let e=n.split(","),t={values:[]},i="";if(e.forEach(r=>{i+=r,/^"[^"]*"$/.test(i.trim())?(t.values.push(i.trim()),i=""):i+=","}),!i)return t}function RW(n){return n===""}function l2(n){return n.map(e=>e.value)}var Jh=class extends L{constructor(t,i){super(t,i);M(this,"onElementsChanged",()=>{this.forceUpdate()});M(this,"setPredefinedValues",t=>{let i=this.getAllowedValuesTarget();this.setState({values:t}),this._modeling.editAllowedValues(i,t&&l2(t))});M(this,"onListChange",t=>{this.setPredefinedValues(t)});M(this,"onInput",({isValid:t,value:i})=>{this.setState({inputValue:i})});M(this,"onKeyDown",({isValid:t,event:i})=>{if(AW(i.keyCode)&&(i.stopPropagation(),i.preventDefault(),t)){let{inputValue:r,values:o}=this.state,s=Ly(r);this.onListChange((o||[]).concat(s.values.map(a=>({value:a,isCheckable:!1,isRemovable:!0,group:this._translate("Predefined values")})))),this.setState({inputValue:""})}});M(this,"handleRemovePredifinedValuesClick",t=>{t.stopPropagation(),this.removePredefinedValues()});M(this,"removePredefinedValues",()=>{this.setPredefinedValues(null)});this._translate=i.injector.get("translate"),this._modeling=i.injector.get("modeling"),this._changeSupport=i.changeSupport;let r=this.getAllowedValuesTarget(),o=Ly(r.inputValues&&r.inputValues.text||r.outputValues&&r.outputValues.text||"");o?this.state={values:o.values.map(s=>({value:s,isCheckable:!1,isRemovable:!0,group:this._translate("Predefined values")})),inputValue:""}:this.state={values:null,inputValue:""}}componentWillMount(){let t=this.getAllowedValuesTarget();this._changeSupport.onElementsChanged(t.id,this.onElementsChanged)}componentWillUnmount(){let t=this.getAllowedValuesTarget();this._changeSupport.offElementsChanged(t.id,this.onElementsChanged)}getAllowedValuesTarget(){let t=this.getElement();return O(t,"dmn:LiteralExpression")?t.$parent:t}getElement(){return this.props.context.output||this.props.context.input.inputExpression}render(){let t=this.getElement(),{inputValue:i,values:r}=this.state;return t.typeRef==="string"?y(1,"div","context-menu-container allowed-values-edit",y(1,"div","dms-form-control",[!J_(r)&&r.length>0&&P(2,Js,{labelComponent:TW,items:r,onChange:this.onListChange}),!J_(r)&&!r.length&&y(1,"div",null,[y(1,"label","dms-label",this._translate("Predefined values"),0),y(1,"span","placeholder",this._translate("No values"),0)],4),!J_(r)&&y(1,"p","dms-hint",y(1,"button","del-values",this._translate("Clear predefined values"),0,{type:"button",onClick:this.handleRemovePredifinedValuesClick}),2),y(1,"label","dms-label",this._translate("Add predefined values"),0),P(2,ot,{onInput:this.onInput,onKeyDown:this.onKeyDown,placeholder:this._translate('"value", "value", ...'),type:"text",validate:o=>{if(!Ly(o))return this._translate("Strings must be in double quotes")},value:i})],0),2):null}};function TW(n){return y(1,"label","dms-label",n,0)}function AW(n){return n===13}function J_(n){return n===null}var MW=500,Sc=class{constructor(e){e.onGetComponent("context-menu",MW,(t={})=>{let{contextMenuType:i}=t;if(i==="input-edit"||i==="output-edit")return Jh})}};Sc.$inject=["components"];var c2={__init__:["allowedValuesUpdateBehavior","allowedValuesEditingProvider"],allowedValuesUpdateBehavior:["type",Ec],allowedValuesEditingProvider:["type",Sc]};var ed=class extends L{constructor(t,i){super(t,i);M(this,"onElementsChanged",()=>{this.forceUpdate()});M(this,"handleClick",t=>{t.stopPropagation(),this.add()});M(this,"add",()=>{this._eventBus.fire("addInput")});this._sheet=i.injector.get("sheet"),this._eventBus=i.injector.get("eventBus"),this._changeSupport=i.changeSupport,this._translate=i.injector.get("translate")}componentWillMount(){let t=this.getRoot();this._changeSupport.onElementsChanged(t.id,this.onElementsChanged)}componentWillUnmount(){let t=this.getRoot();this._changeSupport.offElementsChanged(t.id,this.onElementsChanged)}getRoot(){return this._sheet.getRoot()}render(){return y(1,"div","add-input actionable",y(1,"button","dmn-icon-plus action-icon",null,1,{title:this._translate("Add input")}),2,{onClick:this.handleClick})}};var td=class extends L{constructor(t,i){super(t,i);M(this,"onElementsChanged",()=>{this.forceUpdate()});M(this,"handleClick",t=>{t.stopPropagation(),this.add()});M(this,"add",()=>{this._eventBus.fire("addOutput")});this._sheet=i.injector.get("sheet"),this._eventBus=i.injector.get("eventBus"),this._changeSupport=i.changeSupport,this._translate=i.injector.get("translate")}componentWillMount(){let t=this.getRoot();this._changeSupport.onElementsChanged(t.id,this.onElementsChanged)}componentWillUnmount(){let t=this.getRoot();this._changeSupport.offElementsChanged(t.id,this.onElementsChanged)}getRoot(){return this._sheet.getRoot()}render(){return y(1,"div","add-output actionable",y(1,"button","dmn-icon-plus action-icon",null,1,{title:this._translate("Add output")}),2,{onClick:this.handleClick})}};function By(n,e,t){n.onGetComponent("cell-inner",(i={})=>{let{cellType:r,index:o,inputsLength:s,outputsLength:a}=i;if(r==="input-cell"&&o===s-1)return ed;if(r==="output-cell"&&o===a-1)return td}),t.on("addInput",()=>{e.trigger("addInput")}),t.on("addOutput",()=>{e.trigger("addOutput")})}By.$inject=["components","editorActions","eventBus"];var u2={__depends__:[Jn],__init__:["addInputOutputProvider"],addInputOutputProvider:["type",By]};var f2="Keyboard binding is now implicit; explicit binding to an element got removed. For more information, see https://github.com/bpmn-io/diagram-js/pull/662",Oc=class{constructor(e,t,i,r,o){M(this,"_init",()=>{this._registerDefaultBindings(),this._fire("init")});M(this,"_destroy",()=>{this._fire("destroy"),this.unbind(),this._listeners=null});M(this,"_keyHandler",e=>{var t,i,r=this._listeners,o=e.keyCode||e.charCode||-1;for(t=0;i=r[t];t++)if(i(o,e)){e.preventDefault(),e.stopPropagation();return}});M(this,"unbind",()=>{var e=this._node;e&&(this._fire("unbind"),q.unbind(e,"keydown",this._keyHandler)),this._node=null});this._config=e||{},this._editorActions=i,this._eventBus=t,this._cellSelection=r,this._listeners=[],t.on("table.destroy",this._destroy),t.on("table.init",this._init),t.on("attach",()=>{this._config.bindTo&&console.error("unsupported configuration ",new Error(f2)),this._target=o.getContainer();var s=this._config&&this._config.bind!==!1;s&&this.bind()}),t.on("detach",this.unbind)}bind(e){e&&console.error("unsupported argument ",new Error(f2)),this.unbind(),e=this._node=this._target,q.bind(e,"keydown",this._keyHandler),this._fire("bind")}getBinding(){return this._node}_fire(e){this._eventBus.fire("keyboard."+e,{node:this._node,listeners:this._listeners})}_registerDefaultBindings(){var e=this._listeners,t=this._editorActions,i=this._cellSelection;function r(l,c){if(Ir(c)&&!Lr(c)&&l===90)return t.trigger("undo"),!0}function o(l,c){if(Ir(c)&&(l===89||l===90&&Lr(c)))return t.trigger("redo"),!0}e.push(r),e.push(o);function s(l,c){if(!(l!==13||Ir(c)||!Lr(c))&&lh(c.target))return t.trigger("selectCellAbove"),!0}e.push(s);function a(l,c){if(l!==13||Ir(c)||Lr(c)||!lh(c.target))return;let u=t.trigger("selectCellBelow"),f=i.getCellSelection();if(!u&&f&&!PW(f)){let h=t.trigger("addRule");return t.trigger("selectCellBelow"),h}return!0}e.push(a)}addListener(e){this._listeners.unshift(e)}removeListener(e){this._listeners=this._listeners.filter(t=>t!==e)}};Oc.$inject=["config.keyboard","eventBus","editorActions","cellSelection","renderer"];function PW(n){return n==="__decisionProperties_name"}var Bt={__depends__:[Jn],__init__:["keyboard"],keyboard:["type",Oc]};var h2={__depends__:[u2,c2,Gt,Kt,Qt,Yn,Bt,a2],__init__:["inputEditingProvider","outputEditingProvider"],inputEditingProvider:["type",wc],outputEditingProvider:["type",Vl]};function ew(n,e,t){return(e=DW(e))in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function DW(n){var e=IW(n,"string");return typeof e=="symbol"?e:e+""}function IW(n,e){if(typeof n!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var i=t.call(n,e||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}var LW=`.dmn-decision-table-container td, .dmn-decision-table-container th`,kc=class{constructor(e,t,i,r){ew(this,"handleDragOver",o=>{Ny(o);let s=o.target,a=De(s,LW,!0),l=!!a,{hoverEl:c}=this._dragContext;c&&c!==a&&(this._emit("dragAndDrop.dragLeave",o),this._dragContext.targetEl=null,this._dragContext.hoverEl=null),a&&(a!==c&&(this._dragContext.hoverEl=a,l=this._emit("dragAndDrop.dragEnter",o),l!==!1&&(this._dragContext.targetEl=a)),l=this._emit("dragAndDrop.dragOver",o)),o.dataTransfer.dropEffect=l!==!1?"move":"none"}),ew(this,"handleDrop",o=>{Ny(o);let s=this._emit("dragAndDrop.drop",o);if(s){let{draggedElement:a}=this._dragContext;if(a instanceof pt){let{rows:l}=this._sheet.getRoot(),c=l.indexOf(s);this._modeling.moveRow(a,c)}else if(a instanceof mt){let{cols:l}=this._sheet.getRoot(),c=l.indexOf(s);this._modeling.moveCol(a,c)}}this.handleDragEnd(o)}),ew(this,"handleDragEnd",o=>{Ny(o),this._unbindListeners(),this._emit("dragAndDrop.dragEnd",o),this._dragContext=null}),this._eventBus=e,this._renderer=t,this._modeling=i,this._sheet=r,this._dragContext=null,e.on("table.destroy",()=>{this._unbindListeners()})}_bindListeners(){q.bind(document,"dragover",this.handleDragOver),q.bind(document,"drop",this.handleDrop),q.bind(document,"dragend",this.handleDragEnd)}_unbindListeners(){q.unbind(document,"dragover",this.handleDragOver),q.unbind(document,"drop",this.handleDrop),q.unbind(document,"dragend",this.handleDragEnd)}_emit(e,t){return this._eventBus.fire(e,{dragContext:this._dragContext,originalEvent:t})}startDrag(e,t){Ny(t,!0),t.dataTransfer.effectAllowed="move",t.dataTransfer.setData&&t.dataTransfer.setData("text","__DUMMY"),this._dragContext={draggedElement:e},this._bindListeners(),this._emit("dragAndDrop.dragStart",t)}};kc.$inject=["eventBus","renderer","modeling","sheet"];function Ny(n,e){n.stopPropagation(),e!==!0&&n.preventDefault()}var d2={__init__:["dragAndDrop"],dragAndDrop:["type",kc]};var nw="top",BW="right",NW="bottom",iw="left",Rc=class{constructor(e,t,i,r,o,s,a,l){M(this,"_cleanup",()=>{let e=this._renderer.getContainer();tw(e),qW(e),this._dragImage&&(Qe(this._dragImage),this._dragImage=null)});this._elementRegistry=t,this._dragAndDrop=r,this._renderer=o,this._rules=s,this._sheet=a,this._translate=l,e.onGetComponent("cell-inner",({cellType:c,col:u,row:f})=>{if(c==="rule-index")return()=>y(1,"span","dmn-icon-drag vertical",Z("\xA0"),2,{draggable:"true",onDragStart:h=>this.startDrag(f,h),title:this._translate("Move rule")});if(c==="input-cell"||c==="output-cell"){let h=`Move ${ie(u)?"Input":"Output"}`;return()=>y(1,"span","dmn-icon-drag horizontal",null,1,{draggable:"true",onDragStart:d=>this.startDrag(u,d),title:h})}}),i.on("dragAndDrop.dragEnter",c=>{let{dragContext:u}=c,{draggedElement:f,hoverEl:h}=u;if(f instanceof pt)return!0;if(f instanceof mt){let d=$W(h,this._elementRegistry,this._sheet);return d===-1?!1:this._rules.allowed("col.move",{col:f,index:d})}return!1}),i.on("dragAndDrop.dragLeave",c=>{let{dragContext:u}=c,{targetEl:f}=u;if(!f)return;let h=this._renderer.getContainer();tw(h)}),i.on("dragAndDrop.dragOver",c=>{let{dragContext:u,originalEvent:f}=c,{draggedElement:h,lastPosition:d,targetEl:p}=u,m=this._renderer.getContainer();if(!p)return!1;let g;return h instanceof pt&&(g=y2(f,p)),h instanceof mt&&(g=g2(f,p)),d===g||(tw(m),h instanceof pt&&(g===nw?p2(p,m,"top"):p2(p,m,"bottom")),h instanceof mt&&(g===iw?m2(p,m,"left"):m2(p,m,"right")),u.lastPosition=g),!0}),i.on("dragAndDrop.drop",c=>{let{dragContext:u,originalEvent:f}=c,{draggedElement:h,targetEl:d}=u;if(!d)return!1;if(h instanceof pt){let p=y2(f,d),m=d.dataset.rowId,g=this._elementRegistry.get(m);if(!g||g===h)return;let b=VW(h,g,p,this._sheet.getRoot().rows);return b===h?void 0:b}if(h instanceof mt){let p=g2(f,d),m=d.dataset.colId,g=this._elementRegistry.get(m);if(!g||g===h)return;let b=HW(h,g,p,this._sheet.getRoot().cols);return b===h?void 0:b}}),i.on("dragAndDrop.dragEnd",this._cleanup)}startDrag(e,t){let i=this._renderer.getContainer();this._dragImage=te(``),document.body.appendChild(this._dragImage),t.dataTransfer.setDragImage&&t.dataTransfer.setDragImage(this._dragImage,0,0),e instanceof pt?jW(e,i):e instanceof mt&&FW(e,i),this._dragAndDrop.startDrag(e,t)}};Rc.$inject=["components","elementRegistry","eventBus","dragAndDrop","renderer","rules","sheet","translate"];function $W(n,e,t){let i=e.get(n.dataset.colId);if(!i)return-1;let{cols:r}=t.getRoot();return r.indexOf(i)}function p2(n,e,t){let i=n.dataset.rowId;if(!i)return;let r=pn(`[data-row-id=${i}]`,e);k(r,o=>{Tc(o)&&(ee(o).add("dragover"),ee(o).add(t))})}function m2(n,e,t){let i=n.dataset.colId;if(!i)return;let r=pn(`[data-col-id=${i}]`,e);k(r,o=>{Tc(o)&&(ee(o).add("dragover"),ee(o).add(t))})}function tw(n){let e=pn(".dragover",n);k(e,t=>{Tc(t)&&(ee(t).remove("dragover"),ee(t).remove("top"),ee(t).remove("right"),ee(t).remove("bottom"),ee(t).remove("left"))})}function jW(n,e){let t=pn(`[data-row-id=${n.id}]`,e);k(t,i=>{Tc(i)&&ee(i).add("dragged")})}function FW(n,e){let t=pn(`[data-col-id=${n.id}]`,e);k(t,i=>{Tc(i)&&ee(i).add("dragged")})}function qW(n){let e=pn(".dragged",n);k(e,t=>{Tc(t)&&ee(t).remove("dragged")})}function g2(n,e){let t=e.getBoundingClientRect();return n.clientXi.indexOf(e)&&(e=WW(e,i)),t===nw?zW(e,i):e}function HW(n,e,t,i){return i.indexOf(n)>i.indexOf(e)&&(e=QW(e,i)),t===iw?UW(e,i):e}function zW(n,e){let t=e.indexOf(n);return e[Math.max(0,t-1)]}function WW(n,e){let t=e.indexOf(n);return e[Math.min(e.length-1,t+1)]}function UW(n,e){let t=e.indexOf(n);if(Te(n)){let i=e.filter(o=>Te(o))[0],r=e.indexOf(i);return e[Math.max(r,t-1)]}return e[Math.max(0,t-1)]}function QW(n,e){let t=e.indexOf(n);if(ie(n)){let i=e.filter(s=>ie(s)),r=i[i.length-1],o=e.indexOf(r);return e[Math.min(o,t+1)]}return e[Math.min(e.length-1,t+1)]}function Tc(n){return n&&(n.nodeType===1||n.nodeType==11)}var v2={__depends__:[d2,El],__init__:["dmnDragAndDrop"],dmnDragAndDrop:["type",Rc]};var nd=class extends L{constructor(t,i){super(t,i);M(this,"onElementsChanged",()=>{this.forceUpdate()});M(this,"changeDescription",t=>{this._modeling.updateProperties(this._element,{description:t})});this._elementRegistry=i.injector.get("elementRegistry"),this._modeling=i.injector.get("modeling"),this._changeSupport=this.context.changeSupport;let{id:r}=this.props.context;this._element=this._elementRegistry.get(r)}componentWillMount(){this._element&&this._changeSupport.onElementsChanged(this._element.id,this.onElementsChanged)}componentDidMount(){let{autoFocus:t}=this.props.context;t&&this.node&&KW(this.node).focus()}componentWillUnmount(){if(this._element){this._changeSupport.offElementsChanged(this._element.id,this.onElementsChanged);let{businessObject:t}=this._element,{description:i}=t;Ie(i)&&!i.length&&this.changeDescription(null)}}render(){if(!this._element)return;let{businessObject:t}=this._element,{description:i}=t;if(Ie(i))return y(1,"div","context-menu-container description-editor",P(2,rw,{className:"dms-input",onChange:this.changeDescription,value:i}),2,null,null,r=>this.node=r)}},rw=class extends an{render(){return y(1,"div",this.getClassName(),this.getEditor(),0)}};function KW(n){return X(".content-editable",n)}var GW=500,XW=750,x2=26,Ac=class{constructor(e,t,i,r,o,s,a){M(this,"addDescription",e=>{this._modeling.updateProperties(e,{description:""});let t=this._renderer.getContainer(),r=Gi(e.id,t).getBoundingClientRect(),o=b2(t,r);this._contextMenu.open(o,{contextMenuType:"cell-description",id:e.id,autoFocus:!0,offset:{x:4,y:4}})});M(this,"removeDescription",e=>{this._modeling.updateProperties(e,{description:null}),this._contextMenu.close()});this._contextMenu=t,this._modeling=o,this._renderer=s,this._translate=a,r.on("cell.click",XW,l=>{if(l.defaultPrevented)return;let{target:c,id:u}=l,f=i.get(u);if(!Ge(f,["dmn:UnaryTests","dmn:LiteralExpression"]))return;_2(f)||l.preventDefault();let d=s.getContainer(),p=c.getBoundingClientRect(),m=b2(d,p);t.open(m,{contextMenuType:"cell-description",autoFocus:!1,id:u,offset:{x:4,y:4}})}),e.onGetComponent("context-menu",(l={})=>{if(l.contextMenuType&&l.contextMenuType==="cell-description"){let c=i.get(l.id),u=_2(c);if(Ie(u))return nd}}),e.onGetComponent("context-menu-cell-additional",GW,(l={})=>{if(l.contextMenuType&&l.contextMenuType==="context-menu"){let{id:c}=l;if(!c)return;let u=i.get(c);if(!u)return;let{businessObject:f}=u,{description:h}=f,d=Ie(h),p=d?"remove-description":"add-description",m=d?()=>this.removeDescription(u):()=>this.addDescription(u);return y(1,"div",`context-menu-group-entry ${p}`,Ie(h)?this._translate("Remove cell description"):this._translate("Add cell description"),0,{onClick:m})}})}};Ac.$inject=["components","contextMenu","elementRegistry","eventBus","modeling","renderer","translate"];function b2(n,e){let{top:t,left:i,width:r,height:o}=e;return{x:i+n.parentNode.scrollLeft-x2,y:t+n.parentNode.scrollTop,width:r+2*x2,height:o}}function _2(n){return n&&n.businessObject&&n.businessObject.description}var w2={__depends__:[Gt,_l],__init__:["description"],description:["type",Ac]};var Mc=class{constructor(e,t,i,r,o,s){this._modeling=i,this._translate=o,this._expressionLanguages=r,e.onGetComponent("context-menu-cell-additional",(a={})=>{if(a.contextMenuType&&a.contextMenuType==="context-menu"){let{event:l,id:c}=a;if(!c)return;let u=t.get(c);if(!u||!this._shouldDisplayContextMenuEntry(u))return;let f=h=>{s.open({x:(l||h).pageX,y:(l||h).pageY},{contextMenuType:"expression-language",id:c})};return y(1,"div","context-menu-group-entry",this._translate("Change cell expression language"),0,{onClick:f})}}),e.onGetComponent("context-menu",(a={})=>{if(a.contextMenuType&&a.contextMenuType==="expression-language"){let{id:l}=a;if(!l)return;let c=t.get(l);if(!c)return;let u=this._getElementExpressionLanguage(c),f=r.getAll(),h="context-menu-group-entry context-menu-entry-set-expression-language",d=this._translate("Expression language");return()=>y(1,"div","context-menu-flex",y(1,"div","context-menu-group",y(1,"div",h,[y(1,"div",null,d,0),P(2,pe,{label:d,className:"expression-language",onChange:p=>this.onChange(c,p),options:f,value:u})],4),2),2)}}),e.onGetComponent("context-menu",(a={})=>{if(a.contextMenuType==="input-edit")return()=>{let{inputExpression:l}=a.input;if(!this._shouldDisplayContextMenuEntry(l))return;let c=this._getElementExpressionLanguage(l),u=r.getAll(),f=this._translate("Expression language");return y(1,"div","context-menu-container ref-language",y(1,"div","dms-form-control",[y(1,"label","dms-label",f,0),P(2,pe,{label:f,className:"ref-language",value:c||"",onChange:h=>this.onChange(l,h),options:u})],4),2)}})}onChange(e,t){this._modeling.editExpressionLanguage(e,t)}_shouldDisplayContextMenuEntry(e){return this._expressionLanguages.getAll().length>1?!0:this._getElementExpressionLanguage(e)!==this._getDefaultElementExpressionLanguage(e)}_getElementExpressionLanguage(e){return Ke(e).expressionLanguage||this._getDefaultElementExpressionLanguage(e)}_getDefaultElementExpressionLanguage(e){return this._expressionLanguages.getDefault(ie(e.col)?"inputCell":"outputCell").value}};Mc.$inject=["components","elementRegistry","modeling","expressionLanguages","translate","contextMenu"];var C2={__depends__:[Qt],__init__:["expressionLanguage"],expressionLanguage:["type",Mc]};var Pc=class extends L{constructor(t,i){super(t,i);M(this,"onElementsChanged",()=>{this.forceUpdate()});M(this,"setDecisionTableName",t=>{this.modeling.editDecisionTableName(t)});Ce(this)}componentWillMount(){this.setupChangeListeners({bind:this.getBusinessObject().id})}componentWillUnmount(){this.setupChangeListeners({unbind:this.getBusinessObject().id})}setupChangeListeners({bind:t,unbind:i}){typeof i=="string"&&this.changeSupport.offElementsChanged(i,this.onElementsChanged),typeof t=="string"&&this.changeSupport.onElementsChanged(t,this.onElementsChanged)}getBusinessObject(){return this.sheet.getRoot().businessObject.$parent}render(){let t=this.getBusinessObject(),{name:i}=t,r=this.components.getComponent("hit-policy")||YW;return y(1,"div","decision-table-properties",[P(2,ow,{label:this.translate("Decision name"),className:"decision-table-name",value:i,ctrlForNewline:!0,onBlur:ZW,onChange:this.setDecisionTableName,elementId:"__decisionProperties_name",coords:"0:__decisionProperties"}),y(1,"div","decision-table-header-separator"),P(2,r)],4)}};Pc.$inject=["sheet","modeling","changeSupport","components","translate"];var ow=class extends an{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),Ut(this,Yf)}render(){let e=this.props.value,t=Ro(this.getSelectionClasses(),this.getClassName());return y(1,"div",t,this.getEditor(),0,{"data-element-id":this.props.elementId,"data-coords":this.props.coords,title:this._translate("Decision name: ")+e})}};function YW(){return null}function ZW(n){n.target.scroll(0,0)}var JW=500,Dc=class{constructor(e){e.onGetComponent("table.before",JW,()=>Pc)}};Dc.$inject=["components"];var E2={__depends__:[Kt],__init__:["decisionTableProperties"],decisionTableProperties:["type",Dc]};var Ic=class extends L{constructor(t,i){super(t,i);M(this,"onChange",({aggregation:t,hitPolicy:i})=>{this.modeling.editHitPolicy(i,t)});M(this,"onElementsChanged",()=>{this.forceUpdate()});this._translate=i.injector.get("translate"),Ce(this)}componentDidMount(){this.changeSupport.onElementsChanged(this.getRoot().id,this.onElementsChanged)}componentWillUnmount(){this.changeSupport.offElementsChanged(this.getRoot().id,this.onElementsChanged)}getRoot(){return this.sheet.getRoot()}render(){let t=this.getRoot(),i=t.businessObject,{aggregation:r,hitPolicy:o}=i,s=ye(oh,a=>e8(a.value,{aggregation:r,hitPolicy:o}));return y(1,"div","hit-policy",[y(1,"label","dms-label",this._translate("Hit policy:"),0),P(2,pe,{className:"hit-policy-edit-policy-select",label:this._translate("Hit policy"),onChange:this.onChange,options:oh.map(a=>({...a,label:this._translate(a.label)})),value:s.value,"data-hit-policy":"true",noInput:!0})],4,{title:this._translate(s.explanation)})}};Ic.$inject=["changeSupport","sheet","modeling"];function e8(n,e){return n.hitPolicy===e.hitPolicy&&n.aggregation===e.aggregation}function $y(n){n.onGetComponent("hit-policy",()=>Ic)}$y.$inject=["components"];var S2={__depends__:[Gt],__init__:["hitPolicyProvider"],hitPolicyProvider:["type",$y]};var Lc=class extends ae{constructor(e,t){super(e),this.executed(["row.add","row.remove","col.add","col.remove"],O2(i=>{var r=i.context,o=r.row||r.col;this.updateRoot(o,r.oldRoot)})),this.reverted(["row.add","row.remove","col.add","col.remove"],O2(i=>{var r=i.context,o=r.row||r.col;this.updateRoot(o,r.newRoot)}))}updateRoot(e,t){var i=e.root,r=e.businessObject;if(O(e,"dmn:DecisionRule")){if(t){let s=t.businessObject.get("rule"),a=s.indexOf(r);s.splice(a,1),r.$parent=null}if(i){let o=i.businessObject,s=i.rows.indexOf(e);o.get("rule").splice(s,0,r),r.$parent=o,e.cells.forEach((a,l)=>{this.wireCell(a,e,l)})}}if(O(e,"dmn:InputClause")||O(e,"dmn:OutputClause")){let o,s;if(t){let a=t.businessObject,l=a.get("input"),c=a.get("output");if(O(e,"dmn:InputClause")&&(o=l,s=l.indexOf(r)),O(e,"dmn:OutputClause")&&(o=c,s=c.indexOf(r)),s===-1)throw new Error("inconsistent model: clause not in table");o.splice(s,1),r.$parent=null,e.cells.forEach((u,f)=>{this.unwireCell(u,t.rows[f])})}if(i){let a=i.businessObject,l=a.get("input"),c=a.get("output"),u=i.cols.indexOf(e),f,h;O(e,"dmn:InputClause")&&(h=l,f=u),O(e,"dmn:OutputClause")&&(h=c,f=u-l.length),h.splice(f,0,r),r.$parent=a,e.cells.forEach((d,p)=>{this.wireCell(d,i.rows[p],u)})}}}unwireCell(e,t){var i=e.businessObject;let r=t.businessObject,o=r.get("inputEntry"),s=r.get("outputEntry"),a,l;if(O(e,"dmn:UnaryTests")&&(a=o),O(e,"dmn:LiteralExpression")&&(a=s),l=a.indexOf(i),l===-1)throw new Error("cell not in row");a.splice(l,1),i.$parent=null}wireCell(e,t,i){var r=e.businessObject;let o=t.businessObject,s=o.get("inputEntry"),a=o.get("outputEntry"),l,c;r.$parent!==o&&(O(e,"dmn:UnaryTests")&&(l=s,c=i),O(e,"dmn:LiteralExpression")&&(l=a,c=i-s.length),l.splice(c,0,r),r.$parent=o)}};Lc.$inject=["eventBus","sheet"];function O2(n){return function(e){var t=e.context,i=t.row||t.col;O(i,"dmn:DMNElement")&&n(e)}}var Bc=class{constructor(e){this._model=e}create(e,t={}){var i=this._model.create(e,t||{});return O(i,"dmn:InputClause")&&(t.inputExpression?i.inputExpression=t.inputExpression:(i.inputExpression=this.create("dmn:LiteralExpression",{typeRef:"string"}),i.inputExpression.$parent=i)),O(i,"dmn:OutputClause")&&(i.typeRef=t.typeRef||"string"),(O(i,"dmn:UnaryTests")||O(i,"dmn:LiteralExpression"))&&(i.text=t.text||""),this._ensureId(i),i}_needsId(e){return O(e,"dmn:DMNElement")}_ensureId(e){var t=(e.$type||"").replace(/^[^:]*:/g,"")+"_";!e.id&&this._needsId(e)&&(e.id=this._model.ids.nextPrefixed(t,e))}};Bc.$inject=["moddle"];var Nc=class extends As{constructor(e){super(),this._dmnFactory=e}create(e,t){let i=this._dmnFactory,{businessObject:r,type:o,...s}=t;if(!r){if(!o){if(e==="root")o="dmn:DecisionTable";else if(e==="cell"){let{col:a}=s;O(a,"dmn:OutputClause")&&(o="dmn:LiteralExpression"),O(a,"dmn:InputClause")&&(o="dmn:UnaryTests")}if(!o)throw new Error("cannot guess ")}r=i.create(o)}return super.create(e,{businessObject:r,id:r.id,...s})}};Nc.$inject=["dmnFactory"];var $c=class{constructor(e,t){this._sheet=e,this._elementFactory=t}execute(e){let t=this._sheet,i=this._elementFactory,r=t.getRoot(),{row:o,index:s}=e;return typeof s=="undefined"&&(s=e.index=r.rows.length),e.newRoot=r,o.cells.length||r.cols.forEach((a,l)=>{let c=i.create("cell",{row:o,col:a});o.cells[l]=c}),t.addRow(o,s),t.getRoot()}revert(e){let{row:t}=e,i=this._sheet;return i.removeRow(t),i.getRoot()}};$c.$inject=["sheet","elementFactory"];var jc=class{constructor(e){this._sheet=e}execute(e){let t=this._sheet,i=t.getRoot(),{row:r}=e,o=e.oldIndex=i.rows.indexOf(r);if(e.oldRoot=r.root,o===-1)throw new Error(`row#${r.id} not in sheet`);return t.removeRow(r),t.getRoot()}revert(e){let{row:t,oldIndex:i}=e,r=this._sheet;return r.addRow(t,i),r.getRoot()}};jc.$inject=["sheet"];var Fc=class{constructor(e){this._modeling=e}preExecute(e){let{row:t}=e;this._modeling.removeRow(t)}postExecute(e){let{row:t,index:i}=e;this._modeling.addRow(t,i)}};Fc.$inject=["modeling"];var qc=class{constructor(e,t){this._sheet=e,this._elementFactory=t}execute(e){let t=this._sheet,i=this._elementFactory,r=t.getRoot(),{col:o,index:s}=e;return typeof s=="undefined"&&(s=e.index=r.cols.length),e.newRoot=r,o.cells.length||r.rows.forEach((a,l)=>{let c=i.create("cell",{row:a,col:o});o.cells[l]=c}),t.addCol(o,s),t.getRoot()}revert(e){let{col:t}=e,i=this._sheet;return i.removeCol(t),i.getRoot()}};qc.$inject=["sheet","elementFactory"];var Vc=class{constructor(e,t){this._sheet=e,this._elementFactory=t}execute(e){let t=this._sheet,{col:i}=e,r=e.oldRoot=i.root;if((e.oldIndex=r.cols.indexOf(i))===-1)throw new Error(`col#${i.id} not in sheet`);return t.removeCol(i),t.getRoot()}revert(e){let{col:t,oldIndex:i}=e,r=this._sheet;return r.addCol(t,i),r.getRoot()}};Vc.$inject=["sheet","elementFactory"];var Hc=class{constructor(e){this._modeling=e}preExecute(e){let{col:t}=e;this._modeling.removeCol(t)}postExecute(e){let{col:t,index:i}=e;this._modeling.addCol(t,i)}};Hc.$inject=["modeling"];var id=class{execute(e){let{cell:t}=e;return t}revert(e){let{cell:t}=e;return t}};var zc=class n{constructor(e,t,i){this._eventBus=e,this._elementFactory=t,this._commandStack=i,e.on("table.init",()=>{t8(this.getHandlers(),i)})}getHandlers(){return n._getHandlers()}static _getHandlers(){return{"row.add":$c,"row.remove":jc,"row.move":Fc,"col.add":qc,"col.remove":Vc,"col.move":Hc,"cell.edit":id}}_create(e,t){return t instanceof Oo?t:this._elementFactory.create(e,t)}addRow(e,t){let i=this._create("row",e),r={row:i,index:t};return this._commandStack.execute("row.add",r),i}removeRow(e){this._commandStack.execute("row.remove",{row:e})}moveRow(e,t){let i={row:e,index:t};this._commandStack.execute("row.move",i)}addCol(e,t){let i=this._create("col",e),r={col:i,index:t};return this._commandStack.execute("col.add",r),i}removeCol(e){this._commandStack.execute("col.remove",{col:e})}moveCol(e,t){let i={col:e,index:t};this._commandStack.execute("col.move",i)}editCell(e,t){let i={cell:e,...t};this._commandStack.execute("cell.edit",i)}};zc.$inject=["eventBus","elementFactory","commandStack"];function t8(n,e){k(n,function(t,i){e.registerHandler(i,t)})}var Wc=class{constructor(e,t,i){this._dmnFactory=e,this._moddle=t,this._modeling=i}execute(e){let{element:t,allowedValues:i}=e;return O(t,"dmn:InputClause")?(t.inputValues?e.oldAllowedValues=t.inputValues.text:jy(i)||(t.inputValues=this._dmnFactory.create("dmn:UnaryTests",{text:""})),jy(i)?t.inputValues&&delete t.inputValues:t.inputValues.text=i.join(",")):(t.outputValues&&t?e.oldAllowedValues=t.outputValues.text:jy(i)||(t.outputValues=this._dmnFactory.create("dmn:UnaryTests",{text:""})),jy(i)?t.outputValues&&delete t.outputValues:t.outputValues.text=i.join(",")),t}revert(e){let{element:t,oldAllowedValues:i}=e;return O(t,"dmn:InputClause")?i?(t.inputValues||(t.inputValues=this._dmnFactory.create("dmn:UnaryTests",{text:""})),t.inputValues.text=i):delete t.inputValues:i?(t.outputValues||(t.outputValues=this._dmnFactory.create("dmn:UnaryTests",{text:""})),t.outputValues.text=i):delete t.outputValues,t}};Wc.$inject=["dmnFactory","moddle","modeling"];function jy(n){return n===null}var sw="id",sr=class{constructor(e,t){this._elementRegistry=e,this._moddle=t}execute(e){let{element:t,properties:i}=e,r=Ke(t),{changed:o,oldProperties:s}=this.updateProperties(r,i);return e.oldProperties=s,[...o,t]}revert(e){let{element:t,oldProperties:i}=e;var r=Ke(t),{changed:o}=this.updateProperties(r,i);return[...o,t]}updateProperties(e,t){let i=this._moddle.ids;return st(t,(r,o,s)=>{let a=e.get(s);if(k2(o)){if(!R2(a)&&!k2(a))throw new Error(`non-existing property <${s}>: cannot update values`);let{changed:l,oldProperties:c}=this.updateProperties(a,o);return{changed:[...r.changed,...l,a],oldProperties:{...r.oldProperties,[s]:c}}}return s===sw&&n8(e,o)&&(i.unclaim(e[sw]),this._elementRegistry.updateId(e,o),i.claim(o,e)),e.set(s,o),{changed:r.changed,oldProperties:{...r.oldProperties,[s]:a}}},{changed:[],oldProperties:{}})}};sr.$inject=["elementRegistry","moddle"];function n8(n,e){return n[sw]!==e}function k2(n){return Me(n)&&Pe(n)&&!R2(n)}function R2(n){return!!(n!=null&&n.$type)}var Uc=class{constructor(e){this._moddle=e}execute(e){let t=this._moddle.ids,i=e.id,r=e.element;e.claiming?t.claim(i,r):t.unclaim(i)}revert(e){let t=this._moddle.ids,i=e.id,r=e.element;e.claiming?t.unclaim(i):t.claim(i,r)}};Uc.$inject=["moddle"];var Qc=class n extends zc{constructor(e,t,i,r){super(e,t,i),this._eventBus=e,this._elementFactory=t,this._commandStack=i,this._sheet=r}getHandlers(){return n._getHandlers()}static _getHandlers(){return T({},super._getHandlers(),{editAllowedValues:Wc,"element.updateProperties":sr,"id.updateClaim":Uc})}editDecisionTableName(e){let o={element:this._sheet.getRoot().businessObject.$parent,properties:{name:e}};this._commandStack.execute("element.updateProperties",o)}editDecisionTableId(e){let o={element:this._sheet.getRoot().businessObject.$parent,properties:{id:e}};this._commandStack.execute("element.updateProperties",o)}editHitPolicy(e,t){let o={element:this._sheet.getRoot().businessObject,properties:{hitPolicy:e,aggregation:t}};this._commandStack.execute("element.updateProperties",o)}updateProperties(e,t){let i={element:e,properties:t};this._commandStack.execute("element.updateProperties",i)}editInputExpression(e,t){let i={element:e,properties:t};this._commandStack.execute("element.updateProperties",i)}editOutputName(e,t){let i={element:e,properties:{name:t}};this._commandStack.execute("element.updateProperties",i)}editInputExpressionTypeRef(e,t){let i={element:e,properties:{typeRef:t}};this._commandStack.execute("element.updateProperties",i)}editOutputTypeRef(e,t){let i={element:e,properties:{typeRef:t}};this._commandStack.execute("element.updateProperties",i)}editCell(e,t){let i={element:e,properties:{text:t}};this._commandStack.execute("element.updateProperties",i)}editAnnotation(e,t){let i={element:e,properties:{description:t}};this._commandStack.execute("element.updateProperties",i)}editAllowedValues(e,t){let i={element:e,allowedValues:t};this._commandStack.execute("editAllowedValues",i)}editExpressionLanguage(e,t){let i={element:e,properties:{expressionLanguage:t}};this._commandStack.execute("element.updateProperties",i)}claimId(e,t){let i={id:e,element:t,claiming:!0};this._commandStack.execute("id.updateClaim",i)}unclaimId(e,t){let i={id:e,element:t};this._commandStack.execute("id.updateClaim",i)}};Qc.$inject=["eventBus","elementFactory","commandStack","sheet"];var Kc=class extends ae{constructor(e,t,i){super(e),this._ids=t.ids,this._modeling=i,this.preExecute(["row.add","col.add"],r=>{let o=r.context,s=o.row||o.col;this.claimId(s.businessObject),s.cells&&s.cells.forEach(a=>this.claimId(a.businessObject))})}claimId(e){e.id&&!this._ids.assigned(e.id)&&this._modeling.claimId(e.id,e),e.$descriptor.properties.forEach(t=>{let i=e[t.name];i&&(F(i)&&i.forEach(r=>this.claimId(r)),i.$type&&this.claimId(i))})}};Kc.$inject=["eventBus","moddle","modeling"];var Gc=class extends ae{constructor(e,t){super(e),this._modeling=t,this.preExecute(["row.remove","col.remove"],i=>{let r=i.context,o=r.row||r.col;this.unclaimId(o.businessObject),o.cells&&o.cells.forEach(s=>this.unclaimId(s.businessObject))})}unclaimId(e){e.id&&this._modeling.unclaimId(e.id,e),e.$descriptor.properties.forEach(t=>{let i=e[t.name];i&&(F(i)&&i.forEach(r=>this.unclaimId(r)),i.$type&&this.unclaimId(i))})}};Gc.$inject=["eventBus","modeling"];var T2={__init__:["idClaimBehavior","idUnclaimBehavior"],idClaimBehavior:["type",Kc],idUnclaimBehavior:["type",Gc]};var A2={__init__:["dmnUpdater","idChangeBehavior","nameChangeBehavior","modeling"],__depends__:[T2,xs],dmnUpdater:["type",Lc],dmnFactory:["type",Bc],elementFactory:["type",Nc],idChangeBehavior:["type",Gn],nameChangeBehavior:["type",qi],modeling:["type",Qc]};var rd=class extends L{constructor(e,t){super(e,t),this.changeCellValue=this.changeCellValue.bind(this),this.onElementsChanged=this.onElementsChanged.bind(this)}onElementsChanged(){this.forceUpdate()}componentWillMount(){let{injector:e}=this.context,{cell:t}=this.props,i=this._changeSupport=this.context.changeSupport;this._modeling=e.get("modeling"),i.onElementsChanged(t.id,this.onElementsChanged)}componentWillUnmount(){let{cell:e}=this.props;this._changeSupport.offElementsChanged(e.id,this.onElementsChanged)}changeCellValue(e){let{cell:t}=this.props;this._modeling.editCell(t.businessObject,e)}render(){let{cell:e,rowIndex:t,row:i,col:r,colIndex:o}=this.props,s=O(e,"dmn:UnaryTests"),a=e.businessObject;return P(2,Rn,{className:s?"input-cell":"output-cell",elementId:e.id,coords:`${t}:${o}`,"data-row-id":i.id,"data-col-id":r.id,children:P(2,lw,{placeholder:s?"-":"",onChange:this.changeCellValue,value:a.text,businessObject:a})})}},aw=class extends L{constructor(e,t){super(e,t),this.state={focussed:!1},this.onFocus=this.onFocus.bind(this),this.onBlur=this.onBlur.bind(this)}onFocus(){this.setState({focussed:!0})}onBlur(){this.setState({focussed:!1})}render(){let{focussed:e}=this.state;return y(1,"div",`feel-editor${e?" focussed":""}`,[e&&En(P(2,Ri,{...this.props,autoFocus:!0,onBlur:this.onBlur})),En(P(2,Tn,{...this.props,onInput:()=>{},onFocus:this.onFocus}))],0,{onClick:this.onFocus})}},lw=class extends L{constructor(e,t){super(e,t),this._expressionLanguages=t.injector.get("expressionLanguages"),this._translate=t.injector.get("translate"),this._variableResolver=t.injector.get("variableResolver",!1)}isDefaultExpressionLanguage(e){let{expressionLanguage:t}=e,i=this.getDefaultExpressionLanguage().value;return!t||t===i}getDescription(e){return e.description}getExpressionLanguageLabel(e){let{expressionLanguage:t}=e,i=this.getDefaultExpressionLanguage();return this._expressionLanguages.getLabel(t)||i.label}isScript(){let{businessObject:e}=this.props,t=this.getDefaultExpressionLanguage();return this._isInputCell()?e.text.indexOf(` `)!==-1?!0:e.expressionLanguage&&e.expressionLanguage!==t:!1}_isInputCell(){return O(this.props.businessObject,"dmn:UnaryTests")}getDefaultExpressionLanguage(){let e=this._isInputCell()?"inputCell":"outputCell";return this._expressionLanguages.getDefault(e)}getEditor(){return this.isFEEL()?aw:Tn}isFEEL(){return this.getExpressionLanguage()==="feel"}getExpressionLanguage(){let{businessObject:e}=this.props;return e.expressionLanguage||this.getDefaultExpressionLanguage().value}_getVariables(){let{businessObject:e}=this.props;return this._variableResolver&&this._variableResolver.getVariables(e)}_getLabel(){return this._isInputCell()?this._translate("Input"):this._translate("Output")}render(){let{businessObject:e,placeholder:t,value:i,onChange:r}=this.props,o=this.getDescription(e),s=this.isDefaultExpressionLanguage(e),a=this.getExpressionLanguageLabel(e),l=this.isScript(),c=this.getEditor(),u=this._getVariables();return y(1,"div","cell-editor",[Ie(o)&&y(1,"div","description-indicator"),P(2,c,{label:this._getLabel(),className:l?"script-editor":"",ctrlForNewline:!0,onInput:r,value:i,placeholder:t,variables:u,feelLanguageDialect:"unaryTests"}),!s&&y(1,"span","dms-badge dmn-expression-language",[y(1,"span","dms-badge-icon dmn-icon-file-code"),y(1,"span","dms-badge-label",a,0)],4,{title:this._translate("Expression language: {expressionLanguageLabel}",{expressionLanguageLabel:a})})],0)}};var i8=1500,Xc=class{constructor(e){e.onGetComponent("cell",i8,({cellType:t})=>{if(t==="rule")return rd})}};Xc.$inject=["components"];var M2={__depends__:[Kt,tg],__init__:["decisionRulesEditor"],decisionRulesEditor:["type",Xc]};var Fy=4,Yc=class extends L{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),this.state={top:0,left:0,isVisible:!1,isDisabled:!1,selection:null},Ce(this);let{debounceInput:i}=this;this.onClick=this.onClick.bind(this),this.handleSelectionChanged=this.handleSelectionChanged.bind(this),this.hideAndShowDebounced=this.hideAndShowDebounced.bind(this),this.showDebounced=i(this.showDebounced.bind(this)),this.updatePosition=this.updatePosition.bind(this)}componentDidMount(){let{eventBus:e}=this;e.on("cellSelection.changed",this.handleSelectionChanged),e.on("commandStack.changed",this.updatePosition),e.on("sheet.scroll",this.hideAndShowDebounced)}componentWillUnmount(){let{eventBus:e}=this;e.off("cellSelection.changed",this.handleSelectionChanged),e.off("commandStack.changed",this.updatePosition),e.off("sheet.scroll",this.hideAndShowDebounced)}hideAndShowDebounced(){this.state.isVisible&&(this.hide(),this.showDebounced())}showDebounced(){this.show()}hide(e={}){this.setState({...e,isVisible:!1})}show(e={}){this.setState({...e,isVisible:!0}),this.updatePosition()}handleSelectionChanged({elementId:e}){let{elementRegistry:t,expressionLanguages:i,simpleMode:r}=this,o=t.get(e);if(!o||!r.canSimpleEdit(o)){this.hide({isDisabled:!1,selection:null});return}let s=r8(o),a=!o8(o,s,i);this.show({isDisabled:a,selection:o})}updatePosition(){let{selection:e}=this.state,{node:t}=this;if(!e||!t)return;let{renderer:i}=this,r=i.getContainer(),o=r.getBoundingClientRect(),a=Gi(e.id,r).getBoundingClientRect(),l=this.node.getBoundingClientRect(),{scrollLeft:c,scrollTop:u}=a8(t),f={};a.left+a.width/2>o.width/2?f.left=-o.left+a.left-l.width+Fy+c+"px":f.left=-o.left+a.left+a.width-Fy+c+"px",a.top+a.height/2>o.height/2?f.top=-o.top+a.top-l.height+Fy+u+"px":f.top=-o.top+a.top-Fy+u+"px",T(this.node.style,f)}onClick(){let{eventBus:e}=this,{isDisabled:t}=this.state;if(t)return;let{selection:i}=this,r=i.get();r&&(e.fire("simpleMode.open",{element:r,node:Gi(r.id,this._container)}),this.hide())}render(){let{isDisabled:e,isVisible:t,top:i,left:r}=this.state,o=["simple-mode-button","no-deselect"];return e&&o.push("disabled"),t?y(1,"div",o.join(" "),y(1,"span","dmn-icon-edit"),2,{onClick:this.onClick,style:{top:i,left:r},title:e?this._translate("Editing not supported for set expression language"):this._translate("Edit")},null,s=>this.node=s):null}};Yc.$inject=["debounceInput","elementRegistry","eventBus","expressionLanguages","renderer","selection","simpleMode"];function r8(n){return n.businessObject.expressionLanguage}function o8(n,e,t){return!e||e===s8(n,t)}function s8(n,e){if(ie(n.col))return e.getDefault("inputCell").value;if(Te(n.col))return e.getDefault("outputCell").value}function a8(n){let e=De(n,".tjs-table-container");if(!e)return{scrollTop:0,scrollLeft:0};let{scrollLeft:t,scrollTop:i}=e;return{scrollTop:i,scrollLeft:t}}var Zc=class{constructor(e,t,i,r,o){this._providers=[],e.onGetComponent("table.before",()=>Yc),r.on("simpleMode.open",({element:s,node:a})=>{let{left:l,top:c,width:u,height:f}=a.getBoundingClientRect(),h=o.getContainer();t.open({x:l+h.parentNode.scrollLeft,y:c+h.parentNode.scrollTop,width:u,height:f},{contextMenuType:"simple-mode-edit",element:s,offset:{x:4,y:4}})}),r.on("cell.click",s=>{let{event:a,node:l,id:c}=s;if(l8(a)){let u=i.get(c);u&&r.fire("simpleMode.open",{node:l,element:u}),s.preventDefault()}})}registerProvider(e){this._providers.push(e)}canSimpleEdit(e){return this._providers.reduce((t,i)=>t||i(e),!1)}};Zc.$inject=["components","contextMenu","elementRegistry","eventBus","renderer"];function l8(n){return n.altKey?!1:n.ctrlKey||n.metaKey}var en={__depends__:[Gt,Po,Qt],__init__:["simpleMode"],simpleMode:["type",Zc]};function P2(n){if(!n||c8(n))return"none";if(n.trim()==="true")return"true";if(n.trim()==="false")return"false"}function c8(n){return n===""}var u8="true",f8="false",cw="none",od=class extends L{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),this._modeling=t.injector.get("modeling");let{element:i}=this.props.context,r=P2(i.businessObject.text);this.state={value:r||cw},this.editCell=this.editCell.bind(this),this.onChange=this.onChange.bind(this)}editCell(e,t){this._modeling.editCell(e,t)}onChange(e){let{element:t}=this.props.context;this.editCell(t.businessObject,e===cw?"":e),this.setState({value:e})}render(){let{value:e}=this.state,t=[{label:"-",value:cw},{label:this._translate("Yes"),value:u8},{label:this._translate("No"),value:f8}];return y(1,"div","simple-boolean-edit context-menu-container",[y(1,"h3","dms-heading",this._translate("Edit boolean"),0),y(1,"h4","dms-heading",this._translate("Set value"),0),P(2,pe,{label:this._translate("Boolean value"),noInput:!0,className:"dms-block",onChange:this.onChange,options:t,value:e})],4)}};var Jc=class{constructor(e,t){t.registerProvider(i=>(ie(i.col)||Te(i.col))&&D2(i)==="boolean"),e.onGetComponent("context-menu",(i={})=>{if(i.contextMenuType&&i.contextMenuType==="simple-mode-edit"){if(!i.element)return;if(D2(i.element)==="boolean")return od}})}};Jc.$inject=["components","simpleMode"];function D2(n){return ie(n.col)?n.col&&n.col.businessObject.inputExpression.typeRef:n.col&&n.col.businessObject.typeRef}var I2={__depends__:[Bt,en],__init__:["simpleBooleanEdit"],simpleBooleanEdit:["type",Jc]};var h8=/^\d{4}(?:-\d\d){2}$/,d8=/^\[date\("([^"]*)"\)..date\("([^"]*)"\)\]$/,p8=/^(<|>)\s*date\("([^"]*)"\)$/,m8=/^date\("([^"]*)"\)$/,g8="exact",y8="before",v8="after",x8="between";function zo(n){if(!h8.test(n.trim()))return"Date must match pattern yyyy-MM-dd"}function Qr(n,e){if(n===g8)return`date("${e[0]}")`;if(n===y8)return`< date("${e[0]}")`;if(n===v8)return`> date("${e[0]}")`;if(n===x8)return`[date("${e[0]}")..date("${e[1]}")]`}function Bn(){let n=new Date;return n.setUTCHours(0,0,0,0),n.toISOString().slice(0,10)}function ea(n){if(!n||n.trim()==="")return{type:"exact",date:""};let e=n.match(d8);if(e)return{type:"between",dates:[e[1],e[2]]};if(e=n.match(p8),e)return{type:e[1]==="<"?"before":"after",date:e[2]};if(e=n.match(m8),e)return{type:"exact",date:e[1]}}var L2="exact",b8="before",_8="after",sd="between",ad=class extends L{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),this._modeling=t.injector.get("modeling");let{element:i}=this.props.context,r=ea(i.businessObject.text);if(r){let s;r.date?s=[r.date,""]:r.dates?s=r.dates:s=["",""],this.state={type:r.type,dates:s}}else this.state={type:L2,dates:["",""]};let o=t.injector.get("debounceInput");this.debouncedEditCell=o(this.editCell.bind(this)),this.editCell=this.editCell.bind(this),this.onTypeChange=this.onTypeChange.bind(this),this.onSetStartDateTodayClick=this.onSetStartDateTodayClick.bind(this),this.onSetEndDateTodayClick=this.onSetEndDateTodayClick.bind(this),this.onStartDateInput=this.onStartDateInput.bind(this),this.onEndDateInput=this.onEndDateInput.bind(this)}editCell(e,t){this._modeling.editCell(e,t)}onTypeChange(e){let{element:t}=this.props.context,{dates:i}=this.state;this.setState({type:e}),ea(Qr(e,i))&&this.editCell(t.businessObject,Qr(e,i))}onSetStartDateTodayClick(){let{element:e}=this.props.context,{dates:t,type:i}=this.state,r=Bn();this.setState({dates:[r,t[1]]}),ea(Qr(i,[r,t[1]]))&&this.editCell(e.businessObject,Qr(i,[r,t[1]]))}onSetEndDateTodayClick(){let{element:e}=this.props.context,{dates:t,type:i}=this.state,r=Bn();this.setState({dates:[t[0],r]}),ea(Qr(i,[t[0],r]))&&this.editCell(e.businessObject,Qr(i,[t[0],r]))}onStartDateInput({value:e}){let{element:t}=this.props.context,{dates:i,type:r}=this.state;this.setState({dates:[e,i[1]]}),this.debouncedEditCell(t.businessObject,Qr(r,[e,i[1]]))}onEndDateInput({value:e}){let{element:t}=this.props.context,{dates:i,type:r}=this.state;this.setState({dates:[i[0],e]}),this.debouncedEditCell(t.businessObject,Qr(r,[i[0],e]))}render(){let{dates:e,type:t}=this.state,i=[{label:this._translate("Exactly"),value:L2},{label:this._translate("Before"),value:b8},{label:this._translate("After"),value:_8},{label:this._translate("Between"),value:sd}];return y(1,"div","context-menu-container simple-date-edit",[y(1,"h3","dms-heading",this._translate("Edit date"),0),y(1,"div","dms-fill-row",P(2,pe,{label:this._translate("Test type"),noInput:!0,onChange:this.onTypeChange,options:i,value:t}),2),y(1,"h4","dms-heading",t===sd?this._translate("Edit start date"):this._translate("Set date"),0),y(1,"div",null,[P(2,ot,{label:t===sd?this._translate("Start date"):this._translate("Date"),className:"start-date-input dms-block",onInput:this.onStartDateInput,placeholder:this._translate("e.g. { sample }",{sample:Bn()}),validate:r=>zo(r)&&this._translate(zo(r)),value:e[0]}),y(1,"p","dms-hint",[y(1,"button","use-today",this._translate("Use today"),0,{type:"button",onClick:this.onSetStartDateTodayClick}),Z(".")],4)],4),t===sd&&y(1,"h4","dms-heading",this._translate("Edit end date"),0),t===sd&&y(1,"div",null,[P(2,ot,{label:this._translate("End date"),className:"end-date-input dms-block",onInput:this.onEndDateInput,placeholder:this._translate("e.g. { sample }",{sample:Bn()}),validate:r=>zo(r)&&this._translate(zo(r)),value:e[1]}),y(1,"p","dms-hint",[y(1,"button","use-today",this._translate("Use today"),0,{type:"button",onClick:this.onSetEndDateTodayClick}),Z(".")],4)],4)],0)}};var ld=class extends L{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),this._modeling=t.injector.get("modeling");let{element:i}=this.props.context,r=ea(i.businessObject.text);this.state={date:r?r.date:""};let o=t.injector.get("debounceInput");this.debouncedEditCell=o(this.editCell.bind(this)),this.editCell=this.editCell.bind(this),this.onClick=this.onClick.bind(this),this.onInput=this.onInput.bind(this)}editCell(e,t){this._modeling.editCell(e,t)}onClick(){let{element:e}=this.props.context,t=Bn();this.setState({date:t}),this.editCell(e.businessObject,`date("${t}")`)}onInput({value:e}){let{element:t}=this.props.context;this.setState({date:e}),this.debouncedEditCell(t.businessObject,`date("${e}")`)}render(){let{date:e}=this.state;return y(1,"div","context-menu-container simple-date-edit",[y(1,"h3","dms-heading",this._translate("Edit date"),0),y(1,"h4","dms-heading",this._translate("Set date"),0),y(1,"div",null,[P(2,ot,{label:this._translate("Date value"),onInput:this.onInput,placeholder:this._translate("e.g. { example } ",{example:Bn()}),validate:t=>zo(t)&&this._translate(zo(t)),value:e,className:"dms-block"}),y(1,"p","dms-hint",y(1,"button","use-today",this._translate("Use today"),0,{type:"button",onClick:this.onClick}),2)],4)],4)}};var eu=class{constructor(e,t){t.registerProvider(i=>{let r=B2(i);return(ie(i.col)||Te(i.col))&&N2(r)}),e.onGetComponent("context-menu",(i={})=>{if(i.contextMenuType&&i.contextMenuType==="simple-mode-edit"){if(!i.element)return;let r=B2(i.element);if(N2(r)){if(ie(i.element.col))return ad;if(Te(i.element.col))return ld}}})}};eu.$inject=["components","simpleMode"];function B2(n){return ie(n.col)?n.col&&n.col.businessObject.inputExpression.typeRef:n.col&&n.col.businessObject.typeRef}function N2(n){return n==="date"}var $2={__depends__:[Bt,en],__init__:["simpleDateEdit"],simpleDateEdit:["type",eu]};var w8=/^\d{4}(?:-\d\d){2}T(?:\d\d:){2}\d\d(?:Z|(?:[@+-][^")]+))?$/,C8=/^\[date and time\("([^"]*)"\)..date and time\("([^"]*)"\)\]$/,E8=/^(<|>)\s*date and time\("([^"]*)"\)$/,S8=/^date and time\("([^"]*)"\)$/,O8="exact",k8="before",R8="after",T8="between";function Wo(n){if(!w8.test(n.trim()))return"Date and time must match pattern yyyy-MM-ddTHH:mm:ss[time zone]"}function Kr(n,e){if(n===O8)return`date and time("${e[0]}")`;if(n===k8)return`< date and time("${e[0]}")`;if(n===R8)return`> date and time("${e[0]}")`;if(n===T8)return`[date and time("${e[0]}")..date and time("${e[1]}")]`}function Uo(){let n=new Date;return n.setUTCHours(0,0,0,0),n.toISOString().replace(".000Z","Z")}function ta(n){if(!n||n.trim()==="")return{type:"exact",date:""};let e=n.match(C8);if(e)return{type:"between",dates:[e[1],e[2]]};if(e=n.match(E8),e)return{type:e[1]==="<"?"before":"after",date:e[2]};if(e=n.match(S8),e)return{type:"exact",date:e[1]}}var j2="exact",A8="before",M8="after",cd="between",ud=class extends L{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),this._modeling=t.injector.get("modeling");let{element:i}=this.props.context,r=ta(i.businessObject.text);if(r){let s;r.date?s=[r.date,""]:r.dates?s=r.dates:s=["",""],this.state={type:r.type,dates:s}}else this.state={type:j2,dates:["",""]};let o=t.injector.get("debounceInput");this.debouncedEditCell=o(this.editCell.bind(this)),this.editCell=this.editCell.bind(this),this.onTypeChange=this.onTypeChange.bind(this),this.onSetStartDateTodayClick=this.onSetStartDateTodayClick.bind(this),this.onSetEndDateTodayClick=this.onSetEndDateTodayClick.bind(this),this.onStartDateInput=this.onStartDateInput.bind(this),this.onEndDateInput=this.onEndDateInput.bind(this)}editCell(e,t){this._modeling.editCell(e,t)}onTypeChange(e){let{element:t}=this.props.context,{dates:i}=this.state;this.setState({type:e}),ta(Kr(e,i))&&this.editCell(t.businessObject,Kr(e,i))}onSetStartDateTodayClick(){let{element:e}=this.props.context,{dates:t,type:i}=this.state,r=Uo();this.setState({dates:[r,t[1]]}),ta(Kr(i,[r,t[1]]))&&this.editCell(e.businessObject,Kr(i,[r,t[1]]))}onSetEndDateTodayClick(){let{element:e}=this.props.context,{dates:t,type:i}=this.state,r=Uo();this.setState({dates:[t[0],r]}),ta(Kr(i,[t[0],r]))&&this.editCell(e.businessObject,Kr(i,[t[0],r]))}onStartDateInput({value:e}){let{element:t}=this.props.context,{dates:i,type:r}=this.state;this.setState({dates:[e,i[1]]}),this.debouncedEditCell(t.businessObject,Kr(r,[e,i[1]]))}onEndDateInput({value:e}){let{element:t}=this.props.context,{dates:i,type:r}=this.state;this.setState({dates:[i[0],e]}),this.debouncedEditCell(t.businessObject,Kr(r,[i[0],e]))}render(){let{dates:e,type:t}=this.state,i=[{label:this._translate("Exactly"),value:j2},{label:this._translate("Before"),value:A8},{label:this._translate("After"),value:M8},{label:this._translate("Between"),value:cd}];return y(1,"div","context-menu-container simple-date-edit",[y(1,"h3","dms-heading",this._translate("Edit date and time"),0),y(1,"div","dms-fill-row",P(2,pe,{label:this._translate("Test type"),noInput:!0,onChange:this.onTypeChange,options:i,value:t}),2),y(1,"h4","dms-heading",t===cd?this._translate("Edit start date and time"):this._translate("Set date and time"),0),y(1,"div",null,[P(2,ot,{label:t===cd?this._translate("Start date and time"):this._translate("Date and time"),className:"start-date-input dms-block",onInput:this.onStartDateInput,placeholder:this._translate("e.g. { sample }",{sample:Uo()}),validate:r=>Wo(r)&&this._translate(Wo(r)),value:e[0]}),y(1,"p","dms-hint",y(1,"button","use-today",this._translate("Use today"),0,{type:"button",onClick:this.onSetStartDateTodayClick}),2)],4),t===cd&&y(1,"h4","dms-heading",this._translate("Edit end date and time"),0),t===cd&&y(1,"div",null,[P(2,ot,{label:this._translate("End date and time"),className:"end-date-input dms-block",onInput:this.onEndDateInput,placeholder:this._translate("e.g. { sample }",{sample:Uo()}),validate:r=>Wo(r)&&this._translate(Wo(r)),value:e[1]}),y(1,"p","dms-hint",y(1,"button","use-today",this._translate("Use today"),0,{type:"button",onClick:this.onSetEndDateTodayClick}),2)],4)],0)}};var fd=class extends L{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),this._modeling=t.injector.get("modeling");let{element:i}=this.props.context,r=ta(i.businessObject.text);this.state={date:r?r.date:""};let o=t.injector.get("debounceInput");this.debouncedEditCell=o(this.editCell.bind(this)),this.editCell=this.editCell.bind(this),this.onClick=this.onClick.bind(this),this.onInput=this.onInput.bind(this)}editCell(e,t){this._modeling.editCell(e,t)}onClick(){let{element:e}=this.props.context,t=Uo();this.setState({date:t}),this.editCell(e.businessObject,`date and time("${t}")`)}onInput({value:e}){let{element:t}=this.props.context;this.setState({date:e}),this.debouncedEditCell(t.businessObject,`date and time("${e}")`)}render(){let{date:e}=this.state;return y(1,"div","context-menu-container simple-date-edit",[y(1,"h3","dms-heading",this._translate("Edit date and time"),0),y(1,"h4","dms-heading",this._translate("Set date and time"),0),y(1,"div",null,[P(2,ot,{label:this._translate("Date and time value"),onInput:this.onInput,placeholder:this._translate("e.g. { sample }",{sample:Uo()}),validate:t=>Wo(t)&&this._translate(Wo(t)),value:e,className:"dms-block"}),y(1,"p","dms-hint",y(1,"button","use-today",this._translate("Use today"),0,{type:"button",onClick:this.onClick}),2)],4)],4)}};var tu=class{constructor(e,t){t.registerProvider(i=>{let r=F2(i);return(ie(i.col)||Te(i.col))&&q2(r)}),e.onGetComponent("context-menu",(i={})=>{if(i.contextMenuType&&i.contextMenuType==="simple-mode-edit"){if(!i.element)return;let r=F2(i.element);if(q2(r)){if(ie(i.element.col))return ud;if(Te(i.element.col))return fd}}})}};tu.$inject=["components","simpleMode"];function F2(n){return ie(n.col)?n.col&&n.col.businessObject.inputExpression.typeRef:n.col&&n.col.businessObject.typeRef}function q2(n){return n==="dateTime"}var V2={__depends__:[Bt,en],__init__:["simpleDateTimeEdit"],simpleDateTimeEdit:["type",tu]};var uw={equals:"=",less:"<",lessEquals:"<=",greater:">",greaterEquals:">="};function P8(n){return di(uw).filter(e=>n===uw[e])[0]}function H2(n){if(!n||D8(n.trim()))return{type:"comparison",values:[]};let e=B8(n);if(e)return e;let t=N8(n);if(t)return t}function D8(n){return n===""}function qy(n,e){return n==="equals"?`duration("${e}")`:`${uw[n]} duration("${e}")`}function nu(n,e,t,i){return`${t==="exclude"?"]":"["}duration("${n}")..duration("${e}")${i==="exclude"?"[":"]"}`}function z2(n,e){if(n==="yearMonthDuration")return I8(e);if(n==="dayTimeDuration")return L8(e)}function I8(n){return/^P(\d+Y\d+M|\d+Y|\d+M)$/.test(n)}function L8(n){return/^P(\d+DT\d+H|\d+D|T\d+H)$/.test(n)}function fw(n){let e=/^duration\("([^"]*)"\)$/.exec(n);return e&&e[1]}function B8(n){let e=fw(n);if(e)return{type:"comparison",operator:"equals",values:[e]};let{operator:t,value:i}=W2(/^(?=|(:?<|>)=?)\s*duration\("(?[^"]*)"\)$/,n);if(t&&i)return{type:"comparison",values:[i],operator:P8(t)}}function N8(n){let{start:e,end:t,firstValue:i,secondValue:r}=W2(/^(?[[\]])duration\("(?[^"]*)"\)\.\.duration\("(?[^"]*)"\)(?[[\]])$/,n);if(e&&t)return{type:"range",values:[i,r],start:e==="]"?"exclude":"include",end:t==="["?"exclude":"include"}}function W2(n,e){let{groups:t}=n.exec(e)||{groups:{}};return t}var $8={yearMonthDuration:"Must match PnYnM",dayTimeDuration:"Must match PnDTnH"},Qo=class extends L{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),this._type=e.type,this.onInput=this.onInput.bind(this),this.validate=this.validate.bind(this),this.state={value:e.value}}onInput({value:e}){this.setState({value:e}),this.props.onInput(e)}validate(e){if(!z2(this._type,e))return this._translate($8[this._type])}_getPlaceholder(){if(this._type==="yearMonthDuration")return this._translate("e.g. { sample }",{sample:"P1Y2M"});this._type==="dayTimeDuration"&&this._translate("e.g. { sample }",{sample:"P1DT2H"})}render(){return P(2,ot,{label:this.props.label,type:"text",onInput:this.onInput,placeholder:this._getPlaceholder(),validate:this.validate,value:this.state.value,className:this.props.className})}};var iu="comparison",ru="range",hd=class extends L{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),this._modeling=t.injector.get("modeling");let{element:i}=this.props.context;this._type=j8(i);let r=H2(i.businessObject.text,this._type);r?this.state={type:r.type,comparisonOperator:r.operator||"equals",startValue:r.values[0]||"",endValue:r.values[1]||"",rangeStartType:r.start||"include",rangeEndType:r.end||"include"}:this.state={type:iu,comparisonOperator:"equals",startValue:"",endValue:"",rangeStartType:"include",rangeEndType:"include"};let o=t.injector.get("debounceInput");this.debouncedEditCell=o(this.editCell.bind(this)),this.editCell=this.editCell.bind(this),this.onComparisonOperatorChange=this.onComparisonOperatorChange.bind(this),this.onComparisonValueChange=this.onComparisonValueChange.bind(this),this.onTypeChange=this.onTypeChange.bind(this),this.onRangeStartTypeChange=this.onRangeStartTypeChange.bind(this),this.onRangeStartValueChange=this.onRangeStartValueChange.bind(this),this.onRangeEndTypeChange=this.onRangeEndTypeChange.bind(this),this.onRangeEndValueChange=this.onRangeEndValueChange.bind(this)}editCell(e,t){this._modeling.editCell(e,t)}onTypeChange(e){let{element:t}=this.props.context,{comparisonOperator:i,startValue:r,endValue:o,rangeStartType:s,rangeEndType:a}=this.state;e===iu?this.editCell(t.businessObject,qy(i,r)):this.editCell(t.businessObject,nu(r,o,s,a)),this.setState({type:e})}onComparisonOperatorChange(e){let{element:t}=this.props.context,{type:i,startValue:r}=this.state;i===iu&&(this.editCell(t.businessObject,qy(e,r)),this.setState({comparisonOperator:e}))}onComparisonValueChange(e){let{element:t}=this.props.context,{type:i,comparisonOperator:r}=this.state;i===iu&&(this.debouncedEditCell(t.businessObject,qy(r,e)),this.setState({startValue:e}))}onRangeStartTypeChange(e){let{element:t}=this.props.context,{type:i,startValue:r,endValue:o,rangeEndType:s}=this.state;i===ru&&(this.editCell(t.businessObject,nu(r,o,e,s)),this.setState({rangeStartType:e}))}onRangeStartValueChange(e){let{element:t}=this.props.context,{type:i,endValue:r,rangeStartType:o,rangeEndType:s}=this.state;i===ru&&(this.editCell(t.businessObject,nu(e,r,o,s)),this.setState({startValue:e}))}onRangeEndTypeChange(e){let{element:t}=this.props.context,{type:i,startValue:r,endValue:o,rangeStartType:s}=this.state;i===ru&&(this.editCell(t.businessObject,nu(r,o,s,e)),this.setState({rangeEndType:e}))}onRangeEndValueChange(e){let{element:t}=this.props.context,{type:i,startValue:r,rangeStartType:o,rangeEndType:s}=this.state;i===ru&&(this.editCell(t.businessObject,nu(r,e,o,s)),this.setState({endValue:e}))}renderComparison(e,t){let i=[{label:this._translate("Equals"),value:"equals"},{label:this._translate("Less"),value:"less"},{label:this._translate("Less or equals"),value:"lessEquals"},{label:this._translate("Greater"),value:"greater"},{label:this._translate("Greater or equals"),value:"greaterEquals"}];return y(1,"div","comparison",[y(1,"h4","dms-heading",Z("Value"),2),y(1,"div","dms-fill-row dms-input-duration-edit-row",[P(2,pe,{label:this._translate("Comparison operator"),noInput:!0,onChange:this.onComparisonOperatorChange,options:i,value:e}),Z("\xA0"),P(2,Qo,{label:this._translate("Duration value"),type:this._type,className:"comparison-duration-input",onInput:this.onComparisonValueChange,value:t})],4)],4)}renderRange(e,t,i,r){let o=[{label:this._translate("Include"),value:"include"},{label:this._translate("Exclude"),value:"exclude"}];return y(1,"div","range",[y(1,"h4","dms-heading",this._translate("Start value"),0),y(1,"div","dms-fill-row dms-input-duration-edit-row",[P(2,pe,{label:this._translate("Range start operator"),noInput:!0,onChange:this.onRangeStartTypeChange,options:o,value:i}),Z("\xA0"),P(2,Qo,{label:this._translate("Range start value"),type:this._type,className:"range-start-duration-input",onInput:this.onRangeStartValueChange,value:e})],4),y(1,"h4","dms-heading",this._translate("End value"),0),y(1,"div","dms-fill-row dms-input-duration-edit-row",[P(2,pe,{label:this._translate("Range end operator"),noInput:!0,onChange:this.onRangeEndTypeChange,options:o,value:r}),Z("\xA0"),P(2,Qo,{label:this._translate("Range end value"),type:this._type,className:"range-end-duration-input",onInput:this.onRangeEndValueChange,value:t})],4)],4)}render(){let{type:e,comparisonOperator:t,startValue:i,endValue:r,rangeStartType:o,rangeEndType:s}=this.state,a=[{label:this._translate("Comparison"),value:iu},{label:this._translate("Range"),value:ru}];return y(1,"div","context-menu-container simple-duration-edit",[y(1,"h3","dms-heading",this._translate("Edit duration"),0),y(1,"div","dms-fill-row",P(2,pe,{label:this._translate("Test type"),noInput:!0,onChange:this.onTypeChange,options:a,value:e}),2),e===iu&&this.renderComparison(t,i),e===ru&&this.renderRange(i,r,o,s)],0)}};function j8(n){return n.col.businessObject.inputExpression.typeRef}var dd=class extends L{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),this._modeling=t.injector.get("modeling");let{element:i}=this.props.context;this._type=F8(i);let r=t.injector.get("debounceInput");this.debouncedEditCell=r(this.editCell.bind(this)),this.editCell=this.editCell.bind(this),this.onInput=this.onInput.bind(this)}editCell(e,t){this._modeling.editCell(e,t)}onInput(e){let{element:t}=this.props.context;this.debouncedEditCell(t.businessObject,`duration("${e}")`)}render(){let e=fw(this.props.context.element.businessObject.text,this._type);return y(1,"div","context-menu-container simple-duration-edit",[y(1,"h3","dms-heading",this._translate("Edit duration"),0),y(1,"h4","dms-heading",this._translate("Set duration"),0),P(2,Qo,{label:this._translate("Duration value"),onInput:this.onInput,value:e,type:this._type,className:"dms-block"})],4)}};function F8(n){return n.col.businessObject.typeRef}var ou=class{constructor(e,t){t.registerProvider(i=>{let r=U2(i);return(ie(i.col)||Te(i.col))&&Q2(r)}),e.onGetComponent("context-menu",(i={})=>{if(i.contextMenuType&&i.contextMenuType==="simple-mode-edit"){if(!i.element)return;let r=U2(i.element);if(Q2(r)){if(ie(i.element.col))return hd;if(Te(i.element.col))return dd}}})}};ou.$inject=["components","simpleMode"];function U2(n){return ie(n.col)?n.col&&n.col.businessObject.inputExpression.typeRef:n.col&&n.col.businessObject.typeRef}var q8=["yearMonthDuration","dayTimeDuration"];function Q2(n){return q8.includes(n)}var K2={__depends__:[Bt,en],__init__:["simpleDurationEdit"],simpleDurationEdit:["type",ou]};var V8=/^(-?(?:[0-9]|\.[0-9])+)$|^((?:<|>|=){0,2})\s*(-?(?:[0-9]|\.[0-9])+)$/,H8=/^(\[|\]){1}(-?(?:[0-9]|\.[0-9])+){1,}\.\.(-?(?:[0-9]|\.[0-9])+){1,}(\[|\]){1}$/,hw={equals:"=",less:"<",lessEquals:"<=",greater:">",greaterEquals:">="};function z8(n){return di(hw).filter(e=>n===hw[e])[0]}function Vy(n){if(!n||W8(n.trim()))return{type:"comparison"};let e=n.match(V8),t=n.match(H8);if(e){if(U8(e))return{type:"comparison",value:parseFloat(e[1]),operator:"equals"};if(Q8(e))return{type:"comparison",value:parseFloat(e[3]),operator:z8(e[2])}}else if(t)return{type:"range",values:[t[2],t[3]].map(i=>parseFloat(i)),start:t[1]==="]"?"exclude":"include",end:t[4]==="["?"exclude":"include"}}function W8(n){return n===""}function U8(n){return n[0]&&n[1]&&!n[2]&&!n[3]}function Q8(n){return n[0]&&!n[1]&&n[2]&&n[3]}function Hy(n,e){return n==="equals"?`${e}`:`${hw[n]} ${e}`}function su(n,e,t,i){return`${t==="exclude"?"]":"["}${n}..${e}${i==="exclude"?"[":"]"}`}var au="comparison",lu="range",pd=class extends L{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),this._modeling=t.injector.get("modeling");let{element:i}=this.props.context,r=Vy(i.businessObject.text);r?this.state={type:r.type,comparisonOperator:r.operator||"equals",comparisonValue:r.value||0,rangeStartValue:r.values?r.values[0]:0,rangeEndValue:r.values?r.values[1]:0,rangeStartType:r.start||"include",rangeEndType:r.end||"include"}:this.state={type:au,comparisonOperator:"equals",comparisonValue:0,rangeStartValue:0,rangeEndValue:0,rangeStartType:"include",rangeEndType:"include"};let o=t.injector.get("debounceInput");this.debouncedEditCell=o(this.editCell.bind(this)),this.editCell=this.editCell.bind(this),this.onComparisonOperatorChange=this.onComparisonOperatorChange.bind(this),this.onComparisonValueChange=this.onComparisonValueChange.bind(this),this.onTypeChange=this.onTypeChange.bind(this),this.onRangeStartTypeChange=this.onRangeStartTypeChange.bind(this),this.onRangeStartValueChange=this.onRangeStartValueChange.bind(this),this.onRangeEndTypeChange=this.onRangeEndTypeChange.bind(this),this.onRangeEndValueChange=this.onRangeEndValueChange.bind(this)}editCell(e,t){this._modeling.editCell(e,t)}onTypeChange(e){let{element:t}=this.props.context,{comparisonOperator:i,comparisonValue:r,rangeStartValue:o,rangeEndValue:s,rangeStartType:a,rangeEndType:l}=this.state;e===au?this.editCell(t.businessObject,Hy(i,r)):this.editCell(t.businessObject,su(o,s,a,l)),this.setState({type:e})}onComparisonOperatorChange(e){let{element:t}=this.props.context,{type:i,comparisonValue:r}=this.state;i===au&&(this.editCell(t.businessObject,Hy(e,r)),this.setState({comparisonOperator:e}))}onComparisonValueChange(e){let{element:t}=this.props.context,{type:i,comparisonOperator:r}=this.state;i===au&&(this.debouncedEditCell(t.businessObject,Hy(r,e)),this.setState({comparisonValue:e}))}onRangeStartTypeChange(e){let{element:t}=this.props.context,{type:i,rangeStartValue:r,rangeEndValue:o,rangeEndType:s}=this.state;i===lu&&(this.editCell(t.businessObject,su(r,o,e,s)),this.setState({rangeStartType:e}))}onRangeStartValueChange(e){let{element:t}=this.props.context,{type:i,rangeEndValue:r,rangeStartType:o,rangeEndType:s}=this.state;i===lu&&(this.editCell(t.businessObject,su(e,r,o,s)),this.setState({rangeStartValue:e}))}onRangeEndTypeChange(e){let{element:t}=this.props.context,{type:i,rangeStartValue:r,rangeEndValue:o,rangeStartType:s}=this.state;i===lu&&(this.editCell(t.businessObject,su(r,o,s,e)),this.setState({rangeEndType:e}))}onRangeEndValueChange(e){let{element:t}=this.props.context,{type:i,rangeStartValue:r,rangeStartType:o,rangeEndType:s}=this.state;i===lu&&(this.editCell(t.businessObject,su(r,e,o,s)),this.setState({rangeEndValue:e}))}renderComparison(e,t){let i=[{label:this._translate("Equals"),value:"equals"},{label:this._translate("Less"),value:"less"},{label:this._translate("Less or equals"),value:"lessEquals"},{label:this._translate("Greater"),value:"greater"},{label:this._translate("Greater or equals"),value:"greaterEquals"}];return y(1,"div","comparison",[y(1,"h4","dms-heading",this._translate("Value"),0),y(1,"div","dms-fill-row",[P(2,pe,{label:this._translate("Comparison operator"),noInput:!0,onChange:this.onComparisonOperatorChange,options:i,value:e}),Z("\xA0"),P(2,St,{label:this._translate("Value"),className:"comparison-number-input",onInput:this.onComparisonValueChange,type:"number",value:t})],4)],4)}renderRange(e,t,i,r){let o=[{label:this._translate("Include"),value:"include"},{label:this._translate("Exclude"),value:"exclude"}];return y(1,"div","range",[y(1,"h4","dms-heading",this._translate("Start value"),0),y(1,"div","dms-fill-row",[P(2,pe,{label:this._translate("Start value"),noInput:!0,onChange:this.onRangeStartTypeChange,options:o,value:i}),Z("\xA0"),P(2,St,{className:"range-start-number-input",onInput:this.onRangeStartValueChange,type:"number",value:e})],4),y(1,"h4","dms-heading",this._translate("End value"),0),y(1,"div","dms-fill-row",[P(2,pe,{label:this._translate("End value"),noInput:!0,onChange:this.onRangeEndTypeChange,options:o,value:r}),Z("\xA0"),P(2,St,{className:"range-end-number-input",onInput:this.onRangeEndValueChange,type:"number",value:t})],4)],4)}render(){let{type:e,comparisonOperator:t,comparisonValue:i,rangeStartValue:r,rangeEndValue:o,rangeStartType:s,rangeEndType:a}=this.state,l=[{label:this._translate("Comparison"),value:au},{label:this._translate("Range"),value:lu}];return y(1,"div","context-menu-container simple-number-edit",[y(1,"h3","dms-heading",this._translate("Edit number"),0),y(1,"div","dms-fill-row",P(2,pe,{label:this._translate("Test type"),noInput:!0,onChange:this.onTypeChange,options:l,value:e}),2),e===au&&this.renderComparison(t,i),e===lu&&this.renderRange(r,o,s,a)],0)}};var md=class extends L{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),this._modeling=t.injector.get("modeling");let{element:i}=this.props.context,r=Vy(i.businessObject.text);r?this.state={value:r.value}:this.state={value:""};let o=t.injector.get("debounceInput");this.debouncedEditCell=o(this.editCell.bind(this)),this.editCell=this.editCell.bind(this),this.onInput=this.onInput.bind(this)}editCell(e,t){this._modeling.editCell(e,t)}onInput(e){let{element:t}=this.props.context;this.debouncedEditCell(t.businessObject,e),this.setState({value:e})}render(){let{value:e}=this.state;return y(1,"div","context-menu-container simple-number-edit",[y(1,"h3","dms-heading",this._translate("Edit number"),0),y(1,"h4","dms-heading",this._translate("Set value"),0),P(2,St,{onInput:this.onInput,type:"number",value:e})],4)}};var cu=class{constructor(e,t){t.registerProvider(i=>{let r=G2(i);return(ie(i.col)||Te(i.col))&&X2(r)}),e.onGetComponent("context-menu",(i={})=>{if(i.contextMenuType&&i.contextMenuType==="simple-mode-edit"){if(!i.element)return;let r=G2(i.element);if(X2(r)){if(ie(i.element.col))return pd;if(Te(i.element.col))return md}}})}};cu.$inject=["components","simpleMode"];function G2(n){return ie(n.col)?n.col&&n.col.businessObject.inputExpression.typeRef:n.col&&n.col.businessObject.typeRef}var K8=["number","integer","long","double"];function X2(n){return K8.includes(n)}var Y2={__depends__:[Bt,en],__init__:["simpleNumberEdit"],simpleNumberEdit:["type",cu]};function gd(n){if(!n||J2(n.trim()))return{type:"disjunction",values:[]};let e=n.split(","),t={type:"disjunction",values:[]},i="";if(e.forEach(o=>{i+=o,/^"[^"]*"$/.test(i.trim())?(t.values.push(i.trim()),i=""):i+=","}),!i)return t;t.type="negation",t.values=[],i="";let r=n.match(/^\s*not\((.*)\)\s*$/);if(r&&(e=r[1].split(","),e.forEach(o=>{i+=o,/^"[^"]*"$/.test(i.trim())?(t.values.push(i.trim()),i=""):i+=","}),!i))return t}function Z2(n){let e=ie(n)?n.inputValues:n.outputValues;return!e||J2(e.text)?[]:e.text.split(",").map(t=>t.trim())}function J2(n){return n===""}var na="disjunction",zy="negation",G8="Predefined values",X8="Predefined values",Y8="Custom values",yd=class extends L{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),this._modeling=t.injector.get("modeling");let i=gd(e.context.element.businessObject.text);i||(i={values:[],type:na});let r=Z2(e.context.element.col.businessObject),o=i.values.filter(u=>!pw(r,u)),s=ie(e.context.element.col),a=r.map(u=>({value:u,isChecked:pw(i.values,u),isRemovable:!1,group:s?this._translate(G8):this._translate(X8)}));s&&(a=a.concat(o.map(u=>({value:u,isChecked:!0,isRemovable:!0,group:this._translate(Y8)}))));let l="";!s&&i.values.length&&!pw(r,i.values[0])&&(l=i.values[0]),this.state={items:a,unaryTestsType:i.type,inputValue:l,isOutputValueInputChecked:l!==""};let c=t.injector.get("debounceInput");this.debouncedEditCell=c(this.editCell.bind(this)),this.editCell=this.editCell.bind(this),this.addUnaryTestsListItem=this.addUnaryTestsListItem.bind(this),this.onInput=this.onInput.bind(this),this.onKeyDown=this.onKeyDown.bind(this),this.onOutputValueInputClick=this.onOutputValueInputClick.bind(this),this.onUnaryTestsListChanged=this.onUnaryTestsListChanged.bind(this),this.onUnaryTestsTypeChange=this.onUnaryTestsTypeChange.bind(this)}editCell(e,t){this._modeling.editCell(e,t)}onUnaryTestsTypeChange(e){let{items:t}=this.state,i=dw(t),{element:r}=this.props.context;e===na?(this.editCell(r.businessObject,i.join(",")),this.setState({unaryTestsType:na})):(this.editCell(r.businessObject,`not(${i.join(",")})`),this.setState({unaryTestsType:zy}))}onUnaryTestsListChanged(e){let t=dw(e),{element:i}=this.props.context,{unaryTestsType:r}=this.state;r===na?this.editCell(i.businessObject,t.join(",")):this.editCell(i.businessObject,`not(${t.join(",")})`),this.setState({items:e,isOutputValueInputChecked:!1})}onOutputValueInputClick(){let{element:e}=this.props.context,{inputValue:t,items:i}=this.state,r=gd(t);!r||r.values.length>1||(this.editCell(e.businessObject,`${r.values.join("")}`),this.setState({items:i.map(o=>(o.isChecked=!1,o)),isOutputValueInputChecked:!0}))}onInput({isValid:e,value:t}){let{isOutputValueInputChecked:i}=this.state;this.setState({inputValue:t});let{element:r}=this.props.context;!ie(r)&&e&&i&&this.debouncedEditCell(r.businessObject,t)}onKeyDown({isValid:e,event:t}){if(!Z8(t.keyCode))return;let{element:i}=this.props.context,r=ie(i.col);(r||!e)&&(t.stopPropagation(),t.preventDefault()),e&&(r?this.addUnaryTestsListItem():this.onOutputValueInputClick())}addUnaryTestsListItem(){let{inputValue:e,items:t,unaryTestsType:i}=this.state,r=gd(e);if(!r)return;let{element:o}=this.props.context,s=dw(t),a=[].concat(s,r.values);i===na?this.editCell(o.businessObject,a.join(",")):this.editCell(o.businessObject,`not(${a.join(",")})`);let l=t.concat(r.values.map(c=>({value:c,isChecked:!0,isRemovable:!0,group:this._translate("Custom values")})));this.setState({items:l,inputValue:""})}render(){let{element:e}=this.props.context,{inputValue:t,isOutputValueInputChecked:i,items:r,unaryTestsType:o}=this.state,s=[{label:this._translate("Match one"),value:na},{label:this._translate("Match none"),value:zy}],a=ie(e.col),l=o===zy,c=!a&&r.length>0;return y(1,"div","simple-string-edit context-menu-container",[y(1,"h3","dms-heading",this._translate("Edit string"),0),a&&y(1,"p",null,P(2,pe,{label:this._translate("String value"),noInput:!0,onChange:this.onUnaryTestsTypeChange,options:s,value:l?zy:na},null,u=>this.selectNode=u),2),P(2,Js,{onChange:this.onUnaryTestsListChanged,items:r,type:a?"checkbox":"radio"}),a?y(1,"h4","dms-heading",this._translate("Add values"),0):y(1,"h4","dms-heading",this._translate("Set value"),0),y(1,"div","dms-fill-row",[c&&y(64,"input","cursor-pointer",null,1,{checked:i,onClick:this.onOutputValueInputClick,type:"radio",style:{marginRight:"8px"}}),P(2,ot,{label:a?this._translate("Values"):this._translate("Value"),className:"dms-block",onKeyDown:this.onKeyDown,onInput:this.onInput,placeholder:a?this._translate('"value", "value", ...'):this._translate('"value"'),type:"text",validate:u=>{if(!gd(u))return this._translate("Strings must be in double quotes")},value:t})],0)],0)}};function Z8(n){return n===13}function dw(n){return n.filter(e=>e.isChecked).map(e=>e.value)}function pw(n,e){return n.indexOf(e)!==-1}var uu=class{constructor(e,t){t.registerProvider(i=>(ie(i.col)||Te(i.col))&&eD(i)==="string"),e.onGetComponent("context-menu",(i={})=>{if(i.contextMenuType&&i.contextMenuType==="simple-mode-edit"){if(!i.element)return;if(eD(i.element)==="string")return yd}})}};uu.$inject=["components","simpleMode"];function eD(n){return ie(n.col)?n.col&&n.col.businessObject.inputExpression.typeRef:n.col&&n.col.businessObject.typeRef}var tD={__depends__:[Bt,en],__init__:["simpleStringEdit"],simpleStringEdit:["type",uu]};var J8=/^(?:\d\d:){2}\d\d(?:Z|(?:[@+-][^")]+))?$/,e9=/^\[time\("([^"]*)"\)..time\("([^"]*)"\)\]$/,t9=/^(<|>)\s*time\("([^"]*)"\)$/,n9=/^time\("([^"]*)"\)$/,i9="exact",r9="before",o9="after",s9="between";function Ko(n){if(!J8.test(n.trim()))return"Time must match pattern hh:mm:ss[time zone]"}function Gr(n,e){if(n===i9)return`time("${e[0]}")`;if(n===r9)return`< time("${e[0]}")`;if(n===o9)return`> time("${e[0]}")`;if(n===s9)return`[time("${e[0]}")..time("${e[1]}")]`}function vd(){return new Date().toISOString().slice(11,-5)+"Z"}function ia(n){if(!n||n.trim()==="")return{type:"exact",time:""};let e=n.match(e9);if(e)return{type:"between",times:[e[1],e[2]]};if(e=n.match(t9),e)return{type:e[1]==="<"?"before":"after",time:e[2]};if(e=n.match(n9),e)return{type:"exact",time:e[1]}}var nD="exact",a9="before",l9="after",Wy="between",xd=class extends L{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),this._modeling=t.injector.get("modeling");let{element:i}=this.props.context,r=ia(i.businessObject.text);if(r){let s;r.time?s=[r.time,""]:r.times?s=r.times:s=["",""],this.state={type:r.type,times:s}}else this.state={type:nD,times:["",""]};let o=t.injector.get("debounceInput");this.debouncedEditCell=o(this.editCell.bind(this)),this.editCell=this.editCell.bind(this),this.onTypeChange=this.onTypeChange.bind(this),this.onSetStartTimeNowClick=this.onSetStartTimeNowClick.bind(this),this.onSetEndTimeNowClick=this.onSetEndTimeNowClick.bind(this),this.onStartTimeInput=this.onStartTimeInput.bind(this),this.onEndTimeInput=this.onEndTimeInput.bind(this)}editCell(e,t){this._modeling.editCell(e,t)}onTypeChange(e){let{element:t}=this.props.context,{times:i}=this.state;this.setState({type:e}),ia(Gr(e,i))&&this.editCell(t.businessObject,Gr(e,i))}onSetStartTimeNowClick(){let{element:e}=this.props.context,{times:t,type:i}=this.state,r=vd();this.setState({times:[r,t[1]]}),ia(Gr(i,[r,t[1]]))&&this.editCell(e.businessObject,Gr(i,[r,t[1]]))}onSetEndTimeNowClick(){let{element:e}=this.props.context,{times:t,type:i}=this.state,r=vd();this.setState({times:[t[0],r]}),ia(Gr(i,[t[0],r]))&&this.editCell(e.businessObject,Gr(i,[t[0],r]))}onStartTimeInput({value:e}){let{element:t}=this.props.context,{times:i,type:r}=this.state;this.setState({times:[e,i[1]]}),this.debouncedEditCell(t.businessObject,Gr(r,[e,i[1]]))}onEndTimeInput({value:e}){let{element:t}=this.props.context,{times:i,type:r}=this.state;this.setState({times:[i[0],e]}),this.debouncedEditCell(t.businessObject,Gr(r,[i[0],e]))}render(){let{times:e,type:t}=this.state,i=[{label:this._translate("Exactly"),value:nD},{label:this._translate("Before"),value:a9},{label:this._translate("After"),value:l9},{label:this._translate("Between"),value:Wy}];return y(1,"div","context-menu-container simple-time-edit",[y(1,"h3","dms-heading",this._translate("Edit time"),0),y(1,"div","dms-fill-row",P(2,pe,{label:this._translate("Time"),noInput:!0,onChange:this.onTypeChange,options:i,value:t}),2),y(1,"h4","dms-heading",t===Wy?this._translate("Edit start time"):this._translate("Set time"),0),y(1,"div",null,[P(2,ot,{label:this._translate("Start time"),className:"start-time-input dms-block",onInput:this.onStartTimeInput,placeholder:this._translate("e.g. { example } ",{example:Bn()}),validate:r=>Ko(r)&&this._translate(Ko(r)),value:e[0]}),y(1,"p","dms-hint",[y(1,"button","use-now",this._translate("Use now"),0,{type:"button",onClick:this.onSetStartTimeNowClick}),Z(".")],4)],4),t===Wy&&y(1,"h4","dms-heading",this._translate("Edit end time"),0),t===Wy&&y(1,"div",null,[P(2,ot,{label:this._translate("End time"),className:"end-time-input dms-block",onInput:this.onEndTimeInput,placeholder:this._translate("e.g. { example } ",{example:Bn()}),validate:r=>Ko(r)&&this._translate(Ko(r)),value:e[1]}),y(1,"p","dms-hint",[y(1,"button","use-now",this._translate("Use now"),0,{type:"button",onClick:this.onSetEndTimeNowClick}),Z(".")],4)],4)],0)}};var bd=class extends L{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),this._modeling=t.injector.get("modeling");let{element:i}=this.props.context,r=ia(i.businessObject.text);this.state={date:r?r.date:""};let o=t.injector.get("debounceInput");this.debouncedEditCell=o(this.editCell.bind(this)),this.editCell=this.editCell.bind(this),this.onClick=this.onClick.bind(this),this.onInput=this.onInput.bind(this)}editCell(e,t){this._modeling.editCell(e,t)}onClick(){let{element:e}=this.props.context,t=vd();this.setState({date:t}),this.editCell(e.businessObject,`time("${t}")`)}onInput({value:e}){let{element:t}=this.props.context;this.setState({date:e}),this.debouncedEditCell(t.businessObject,`time("${e}")`)}render(){let{date:e}=this.state;return y(1,"div","context-menu-container simple-time-edit",[y(1,"h3","dms-heading",this._translate("Edit time"),0),y(1,"h4","dms-heading",this._translate("Set time"),0),y(1,"div",null,[P(2,ot,{label:this._translate("Time value"),onInput:this.onInput,placeholder:this._translate("e.g. { example } ",{example:Bn()}),validate:t=>Ko(t)&&this._translate(Ko(t)),value:e,className:"dms-block"}),y(1,"p","dms-hint",[y(1,"button","use-now",this._translate("Use now"),0,{type:"button",onClick:this.onClick}),Z(".")],4)],4)],4)}};var fu=class{constructor(e,t){t.registerProvider(i=>{let r=iD(i);return(ie(i.col)||Te(i.col))&&rD(r)}),e.onGetComponent("context-menu",(i={})=>{if(i.contextMenuType&&i.contextMenuType==="simple-mode-edit"){if(!i.element)return;let r=iD(i.element);if(rD(r)){if(ie(i.element.col))return xd;if(Te(i.element.col))return bd}}})}};fu.$inject=["components","simpleMode"];function iD(n){return ie(n.col)?n.col&&n.col.businessObject.inputExpression.typeRef:n.col&&n.col.businessObject.typeRef}function rD(n){return n==="time"}var oD={__depends__:[Bt,en],__init__:["simpleTimeEdit"],simpleTimeEdit:["type",fu]};var hu=class extends L{constructor(t,i){super(t,i);M(this,"onElementsChanged",()=>{this.forceUpdate()});M(this,"handleMouseDown",t=>{let i=De(t.target,"th",!1);c9({node:i,event:t,minWidth:this.props.minWidth||150,onEnd:this.saveWidth})});M(this,"saveWidth",t=>{let{col:i}=this.props,r={};O(i,"dmn:DecisionTable")?r.annotationsWidth=t:r.width=t,this.modeling.updateProperties(i,r)});Ce(this)}componentDidMount(){let t=this.getRoot();this.changeSupport.onElementsChanged(t,this.onElementsChanged)}componentWillUnmount(){let t=this.getRoot();this.changeSupport.offElementsChanged(t,this.onElementsChanged)}getRoot(){return this.sheet.getRoot()}isLastInputOrOutput(){let{col:t}=this.props,i=this.getRoot(),r=Ke(i);if(O(t,"dmn:InputClause")){let o=r.get("input");return o.indexOf(t)===o.length-1}else if(O(t,"dmn:OutputClause")){let o=r.get("output");return o.indexOf(t)===o.length-1}}render(){let t=this.isLastInputOrOutput()?{right:"-7px",width:"27px"}:null;return y(1,"div","resize-column-handle",null,1,{onMouseDown:this.handleMouseDown,title:this.translate("Resize"),style:t})}};hu.$inject=["sheet","changeSupport","translate","modeling"];function c9({node:n,event:e,minWidth:t,onEnd:i=u9}){e.preventDefault();let r=n.getBoundingClientRect().width,o=e.clientX,s;document.addEventListener("mousemove",a),document.addEventListener("mouseup",l);function a(u){u.preventDefault();let f=c(u.clientX);s&&cancelAnimationFrame(s),s=requestAnimationFrame(()=>{n.style.width=f+"px"})}function l(u){u.preventDefault(),document.removeEventListener("mousemove",a),document.removeEventListener("mouseup",l);let f=c(u.clientX);i(f)}function c(u){let f=u-o;return Math.max(r+f,t)}}function u9(){}function Uy(n){n.onGetComponent("cell-inner",(e={})=>{let{cellType:t}=e;if(t==="input-cell"||t==="output-cell"||t==="annotations")return hu})}Uy.$inject=["components"];var sD={__init__:["columnResizeProvider"],columnResizeProvider:["type",Uy]};var _d=class n extends Ao{getModules(){return[...Ao._getModules(),...n._getModules()]}static _getModules(){return[RR,DR,Po,Gt,lg,LR,BR,Xi,NR,Jn,h2,sD,v2,w2,C2,Qt,Yn,Bt,E2,cg,S2,_l,A2,M2,Mo,en,I2,$2,V2,K2,Y2,tD,oD,tl]}};var du=class{constructor(e){this._listeners={},e.on("elements.changed",({elements:t})=>{this.elementsChanged(t)}),e.on("element.updateId",({element:t,newId:i})=>{this.updateId(t.id,i)})}elementsChanged(e){let t={},i=e.length;for(let r=0;rP(2,t,null,i)),0)}};var pu=class{constructor(e,t,i,r,o){let{container:s}=i;this._container=s,r.on("renderer.mount",()=>{xa(P(2,Cd,{injector:o}),s)}),r.on("renderer.unmount",()=>{xa(null,s)})}getContainer(){return this._container}};pu.$inject=["changeSupport","components","config.renderer","eventBus","injector"];var aD={__init__:["changeSupport","components","renderer"],changeSupport:["type",du],components:["type",wd],eventBus:["type",ut],renderer:["type",pu]};var ra=class{constructor(e={}){let{injector:t}=e;if(!t){let{modules:i,config:r}=this._init(e);t=h9(r,i)}this.get=t.get,this.invoke=t.invoke,this.get("eventBus").fire("viewer.init")}_init(e){let{modules:t,...i}=e;return{modules:t,config:i}}destroy(){this.get("eventBus").fire("viewer.destroy")}clear(){this.get("eventBus").fire("viewer.clear")}};function h9(n,e){let t=[{config:["value",n]},aD].concat(e||[]),i=new os(t);return i.init(),i}var mu=class{constructor(e,t){this._eventBus=t,this._viewer=e}getDecision(){return this._viewer.getDecision()}updateId(e,t){var i=this.getDecision();if(e!==i)throw new Error("element !== decision");this._eventBus.fire("element.updateId",{element:e,newId:t}),e.id=t}};mu.$inject=["viewer","eventBus"];var lD={__init__:["elementRegistry"],elementRegistry:["type",mu]};var Ed=class extends L{constructor(e,t){super(e,t),this._viewer=t.injector.get("viewer")}render(){let{name:e}=this._viewer.getDecision();return y(1,"div","decision-properties",y(1,"h3","decision-name",e,0),2)}};var d9=1500,gu=class{constructor(e){e.onGetComponent("viewer",d9,()=>Ed)}};gu.$inject=["components"];var cD={__init__:["decisionProperties"],decisionProperties:["type",gu]};var Sd=class extends L{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),this._viewer=t.injector.get("viewer")}render(){let{decisionLogic:e,variable:t}=this._viewer.getDecision();return y(1,"div","literal-expression-properties",y(1,"table",null,[y(1,"tr",null,[y(1,"td",null,this._translate("Variable name:"),0),y(1,"td",null,y(1,"span",null,t.name||"-",0),2)],4),y(1,"tr",null,[y(1,"td",null,this._translate("Variable type:"),0),y(1,"td",null,y(1,"span",null,this._translate(t.typeRef||"")||"-",0),2)],4),y(1,"tr",null,[y(1,"td",null,this._translate("Expression language:"),0),y(1,"td",null,y(1,"span",null,e.expressionLanguage||"-",0),2)],4)],4),2)}};var p9=500,yu=class{constructor(e){e.onGetComponent("viewer",p9,()=>Sd)}};yu.$inject=["components"];var uD={__depends__:[],__init__:["literalExpressionProperties"],literalExpressionProperties:["type",yu]};var m9=2e3,vu=class{constructor(e){e.onGetComponent("viewer",m9,()=>co)}};vu.$inject=["components"];var fD={__init__:["poweredBy"],poweredBy:["type",vu]};var Od=class extends L{constructor(e,t){super(e,t),this._viewer=t.injector.get("viewer")}render(){let{text:e}=this._viewer.getDecision().decisionLogic;return y(1,"div","textarea",y(1,"div","content",e,0),2)}};var xu=class{constructor(e){e.onGetComponent("viewer",()=>Od)}};xu.$inject=["components"];var hD={__init__:["textarea"],textarea:["type",xu]};var bu=class extends L{constructor(t,i){super(t,i);M(this,"onClick",()=>{this._eventBus.fire("showDrd")});let{injector:r}=i;this._translate=r.get("translate"),this._eventBus=r.get("eventBus")}render(){return y(1,"div","view-drd",y(1,"button","view-drd-button",this._translate("View DRD"),0,{type:"button",onClick:this.onClick}),2,null,null,t=>this.node=t)}};bu.$inject=["translate"];var g9=2e3,_u=class{constructor(e,t,i,r){this._injector=r,this._viewer=t,e.onGetComponent("viewer",g9,()=>{if(this.canViewDrd())return bu}),i.on("showDrd",()=>{let o=r.get("_parent",!1),s=this.getDefinitions(),a=o.getView(s);o.open(a)})}canViewDrd(){let e=this._injector.get("_parent",!1);if(!e)return;let t=this.getDefinitions();return!!e.getView(t)}getDefinitions(){return y9(this._viewer.getDecision())}};_u.$inject=["components","viewer","eventBus","injector"];function y9(n){return n.$parent}var dD={__init__:["viewDrd"],viewDrd:["type",_u]};var Go=class n extends ra{constructor(e={}){let t=n._createContainer();super(T(e,{renderer:{container:t}})),this._container=t}open(e){var t=this;return new Promise(function(i,r){var o;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(s){o=s}o?(o.warnings=o.warnings||[],r(o)):i({warnings:[]})})}_init(e){let{modules:t,additionalModules:i,...r}=e,o=t||this.getModules(),s=i||[],a=[{viewer:["value",this]}];return{modules:[...o,...s,...a],config:r}}on(e,t,i,r){return this.get("eventBus").on(e,t,i,r)}off(e,t){this.get("eventBus").off(e,t)}_emit(e,t){return this.get("eventBus").fire(e,t)}getDecision(){return this._decision}attachTo(e){if(!e)throw new Error("parentNode required");this.detach(),e.appendChild(this._container),this._emit("attach",{})}detach(){let e=this._container;e.parentNode&&(this._emit("detach",{}),Qe(e))}destroy(){super.destroy(),this.detach()}getModules(){return n._getModules()}static _getModules(){return[lD,qe,cD,uD,fD,hD,dD]}static _createContainer(){return te('
    ')}};var kd=class extends L{constructor(t,i){super(t,i);M(this,"onElementsChanged",()=>{this.forceUpdate()});M(this,"setDecisionName",t=>{this._modeling.editDecisionName(t)});this._viewer=i.injector.get("viewer"),this._modeling=i.injector.get("modeling"),this._translate=i.injector.get("translate"),this.setupChangeListeners({bind:this.getDecision().id})}componentWillUnmount(){this.setupChangeListeners({unbind:this.getDecision().id})}getDecision(){return this._viewer.getDecision()}setupChangeListeners({bind:t,unbind:i}){let{changeSupport:r}=this.context;typeof i=="string"&&r.offElementsChanged(i,this.onElementsChanged),typeof t=="string"&&r.onElementsChanged(t,this.onElementsChanged)}render(){let{name:t}=this.getDecision();return y(1,"header","decision-properties",P(2,mw,{label:this._translate("Decision name"),className:"decision-name editor",value:t,onBlur:v9,onChange:this.setDecisionName}),2)}},mw=class extends an{render(){return y(1,"h3",this.getClassName(),this.getEditor(),0)}};function v9(n){n.target.scroll(0,0)}var x9=1500,wu=class{constructor(e){e.onGetComponent("viewer",x9,()=>kd)}};wu.$inject=["components"];var pD={__depends__:[Kt,qe],__init__:["decisionProperties"],decisionProperties:["type",wu]};var mD="is not a registered action",b9="is already registered",Cu=class{constructor(e,t){this._actions={undo(){e.undo()},redo(){e.redo()}}}trigger(e,t){if(!this._actions[e])throw gw(e,mD);return this._actions[e](t)}register(e,t){if(typeof e=="string")return this._registerAction(e,t);k(e,(i,r)=>{this._registerAction(r,i)},this)}_registerAction(e,t){if(this.isRegistered(e))throw gw(e,b9);this._actions[e]=t}unregister(e){if(!this.isRegistered(e))throw gw(e,mD);this._actions[e]=void 0}isRegistered(e){return!!this._actions[e]}};Cu.$inject=["commandStack","eventBus"];function gw(n,e){return new Error(n+" "+e)}var gD={__init__:["editorActions"],editorActions:["type",Cu]};function yw(n){return n.altKey?!1:n.ctrlKey||n.metaKey}function vw(n){return n.shiftKey}var yD="Keyboard binding is now implicit; explicit binding to an element got removed. For more information, see https://github.com/bpmn-io/diagram-js/pull/662",Eu=class{constructor(e,t,i,r){M(this,"_init",()=>{this._registerDefaultBindings(),this._fire("init")});M(this,"_destroy",()=>{this._fire("destroy"),this.unbind(),this._listeners=null});M(this,"_keyHandler",e=>{var t,i,r=this._listeners,o=e.keyCode||e.charCode||-1;for(t=0;i=r[t];t++)if(i(o,e)){e.preventDefault(),e.stopPropagation();return}});M(this,"unbind",()=>{var e=this._node;e&&(this._fire("unbind"),q.unbind(e,"keydown",this._keyHandler,!0)),this._node=null});this._config=e||{},this._eventBus=t,this._editorActions=i,this._listeners=[],t.on("viewer.destroy",this._destroy),t.on("viewer.init",this._init),t.on("attach",()=>{this._config.bindTo&&console.error("unsupported configuration ",new Error(yD)),this._target=r.getContainer();var o=this._config&&this._config.bind!==!1;o&&this.bind()}),t.on("detach",this.unbind)}bind(e){e&&console.error("unsupported argument ",new Error(yD)),this.unbind(),e=this._node=this._target,q.bind(e,"keydown",this._keyHandler,!0),this._fire("bind")}getBinding(){return this._node}_fire(e){this._eventBus.fire("keyboard."+e,{node:this._node,listeners:this._listeners})}_registerDefaultBindings(){var e=this._listeners,t=this._editorActions;function i(o,s){if(yw(s)&&!vw(s)&&o===90)return t.trigger("undo"),!0}function r(o,s){if(yw(s)&&(o===89||o===90&&vw(s)))return t.trigger("redo"),!0}e.push(i),e.push(r)}addListener(e){this._listeners.unshift(e)}removeListener(e){this._listeners=this._listeners.filter(t=>t!==e)}};Eu.$inject=["config.keyboard","eventBus","editorActions","renderer"];var Qy={__depends__:[gD],__init__:["keyboard"],keyboard:["type",Eu]};var Rd=class extends L{constructor(t,i){super(t,i);M(this,"onChange",()=>{let t=this._viewer.getDecision();t.variable&&this.setState({name:t.variable.name})});this._translate=i.injector.get("translate"),this._viewer=i.injector.get("viewer"),this._modeling=i.injector.get("modeling"),this._dataTypes=i.injector.get("dataTypes"),this._eventBus=i.injector.get("eventBus");let r=this._viewer.getDecision();this.state={name:r.variable.name,typeRef:r.variable.typeRef},this.setVariableName=this.setVariableName.bind(this),this.setVariableType=this.setVariableType.bind(this)}setVariableName(t){this._modeling.editVariableName(t),this.setState({name:t})}componentWillMount(){this._eventBus.on("elements.changed",this.onChange)}componentWillUnmount(){this._eventBus.off("elements.changed",this.onChange)}setVariableType(t){t===""?(this._modeling.editVariableType(void 0),this.setState({typeRef:void 0})):(this._modeling.editVariableType(t),this.setState({typeRef:t}))}render(){let{name:t,typeRef:i}=this.state,r=this._dataTypes.getAll().map(o=>({label:this._translate(o),value:o}));return y(1,"div","literal-expression-properties",y(1,"table","variables-table",[y(1,"tr",null,[y(1,"td",null,this._translate("Variable name:"),0),y(1,"td",null,P(2,St,{label:this._translate("Variable name"),className:"variable-name-input",onInput:this.setVariableName,placeholder:this._translate("name"),value:t||""}),2)],4),y(1,"tr",null,[y(1,"td",null,this._translate("Variable type:"),0),y(1,"td",null,y(1,"div","dms-fill-row",P(2,pe,{label:this._translate("Variable type"),onChange:this.setVariableType,options:r,value:i,className:"variable-type-select dms-block"}),2),2)],4),P(2,xw)],4),2)}},xw=class extends L{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),this._viewer=t.injector.get("viewer"),this._modeling=t.injector.get("modeling"),this._expressionLanguages=t.injector.get("expressionLanguages"),this.setExpressionLanguage=this.setExpressionLanguage.bind(this)}setExpressionLanguage(e){e===""?this._modeling.editExpressionLanguage(void 0):this._modeling.editExpressionLanguage(e)}_getExpressionLanguage(){let t=this._viewer.getDecision().decisionLogic;return t&&t.expressionLanguage?t.expressionLanguage.toLowerCase():this._getDefaultExpressionLanguage()}_getDefaultExpressionLanguage(){return this._expressionLanguages.getDefault().value}_shouldRender(){return this._expressionLanguages.getAll().length>1?!0:this._getExpressionLanguage()!==this._getDefaultExpressionLanguage()}render(){if(!this._shouldRender())return null;let e=this._getExpressionLanguage(),t=this._expressionLanguages.getAll();return y(1,"tr",null,[y(1,"td",null,this._translate("Expression language:"),0),y(1,"td",null,y(1,"div","dms-fill-row",P(2,pe,{label:this._translate("Expression language"),onChange:this.setExpressionLanguage,options:t,value:e,className:"expression-language-select dms-block"}),2),2)],4)}};var _9=500,Su=class{constructor(e){e.onGetComponent("viewer",_9,()=>Rd)}};Su.$inject=["components"];var vD={__depends__:[Kt,Qy,Qt,Yn,Xi],__init__:["literalExpressionProperties"],literalExpressionProperties:["type",Su]};var Ou=class n{constructor(e,t,i){this._commandStack=e,this._viewer=t,this._eventBus=i,i.on("viewer.init",()=>{w9(this.getHandlers(),e)})}getHandlers(){return n._getHandlers()}static _getHandlers(){return{"element.updateProperties":sr}}getDecision(){return this._viewer.getDecision()}editDecisionName(e){let i={element:this.getDecision(),properties:{name:e}};this._commandStack.execute("element.updateProperties",i)}editDecisionId(e){let i={element:this.getDecision(),properties:{id:e}};this._commandStack.execute("element.updateProperties",i)}editLiteralExpressionText(e){let r={element:this.getDecision().decisionLogic,properties:{text:e}};this._commandStack.execute("element.updateProperties",r)}editExpressionLanguage(e){let r={element:this.getDecision().decisionLogic,properties:{expressionLanguage:e}};this._commandStack.execute("element.updateProperties",r)}editVariableName(e){let r={element:this.getDecision().variable,properties:{name:e}};this._commandStack.execute("element.updateProperties",r)}editVariableType(e){let r={element:this.getDecision().variable,properties:{typeRef:e}};this._commandStack.execute("element.updateProperties",r)}updateProperties(e,t){let i={element:e,properties:t};this._commandStack.execute("element.updateProperties",i)}};Ou.$inject=["commandStack","viewer","eventBus"];function w9(n,e){k(n,function(t,i){e.registerHandler(i,t)})}var xD={__init__:["idChangeBehavior","nameChangeBehavior","modeling"],commandStack:["type",ke],idChangeBehavior:["type",Gn],nameChangeBehavior:["type",qi],modeling:["type",Ou]};var Td=class extends L{constructor(e,t){super(e,t),this._modeling=t.injector.get("modeling"),this._viewer=t.injector.get("viewer"),this._expressionLanguages=t.injector.get("expressionLanguages"),this._variableResolver=t.injector.get("variableResolver",!1),this._translate=t.injector.get("translate"),this.editLiteralExpressionText=this.editLiteralExpressionText.bind(this),this.onElementsChanged=this.onElementsChanged.bind(this);let{id:i}=this.getLiteralExpression();t.changeSupport.onElementsChanged(i,this.onElementsChanged)}getLiteralExpression(){return this._viewer.getDecision().decisionLogic}onElementsChanged(){this.forceUpdate()}editLiteralExpressionText(e){this._modeling.editLiteralExpressionText(e)}getEditor(){return this.isFeel()?bw:_w}isFeel(){return this.getExpressionLanguage()==="feel"}getExpressionLanguage(){return this.getLiteralExpression().expressionLanguage||this._expressionLanguages.getDefault().value}_getVariables(){let e=this.getLiteralExpression();return this._variableResolver&&this._variableResolver.getVariables(e)}render(){let{text:e}=this.getLiteralExpression(),t=this.getEditor(),i=this._getVariables();return P(2,t,{label:this._translate("Literal expression editor"),className:"textarea editor",value:e,onChange:this.editLiteralExpressionText,variables:i})}},bw=class extends L{render(){return P(2,Ri,{label:this.props.label,className:this.props.className,value:this.props.value,onInput:this.props.onChange,variables:this.props.variables})}},_w=class extends an{render(){return y(1,"div",this.getClassName(),this.getEditor(),0)}};var ku=class{constructor(e){e.onGetComponent("viewer",()=>Td)}};ku.$inject=["components"];var bD={__depends__:[Kt,qe],__init__:["textarea"],textarea:["type",ku]};var Ad=class n extends Go{getModules(){return[...Go._getModules(),...n._getModules()]}static _getModules(){return[pD,Qy,vD,xD,Qt,Yn,Xi,bD,tl]}};var Md=class{constructor(e){e.onGetComponent("viewer",()=>C9),e.onGetComponent("viewer",()=>E9),e.onGetComponent("viewer",()=>S9)}};M(Md,"$inject",["components"]);function C9(n,{injector:e}){let i=e.get("components").getComponents("header");return y(1,"div","dmn-boxed-expression-section dmn-boxed-expression-header",i&&i.map((r,o)=>P(2,r,null,o)),0)}function E9(n,{injector:e}){let i=e.get("components").getComponents("body");return y(1,"div","dmn-boxed-expression-section dmn-boxed-expression-body",i&&i.map((r,o)=>P(2,r,null,o)),0)}function S9(n,{injector:e}){let i=e.get("components").getComponents("footer");return y(1,"div","dmn-boxed-expression-section dmn-boxed-expression-footer",i&&i.map((r,o)=>P(2,r,null,o)),0)}var Pd=class{constructor(e){e.onGetComponent("viewer",()=>{let t=e.getComponents("table.before")||[];return()=>y(1,"div",null,t.map((i,r)=>P(2,i,null,r)),0)})}};M(Pd,"$inject",["components"]);var _D={__init__:["viewRenderer","tableJsSupport"],viewRenderer:["type",Md],tableJsSupport:["type",Pd]};var O9=2e3,Ru=class{constructor(e){e.onGetComponent("viewer",O9,()=>co)}};Ru.$inject=["components"];var wD={__init__:["poweredBy"],poweredBy:["type",Ru]};var Dd=class{constructor(e){e.onGetComponent("expression",({expression:t})=>{if(O(t,"dmn:LiteralExpression"))return k9})}};M(Dd,"$inject",["components"]);function k9({expression:n},e){let i=e.injector.get("literalExpression").getText(n);return y(1,"div","textarea",y(1,"div","content",i,0),2)}var oa=class{getText(e){return e.get("text")}};var CD={__init__:["literalExpressionComponent"],literalExpressionComponent:["type",Dd],literalExpression:["type",oa]};var Tu=class{getParameters(e){return e.get("formalParameter")}getBody(e){return e.get("body")}getKind(e){return e.get("kind")||"FEEL"}};var Id=class{constructor(e){e.onGetComponent("expression",({expression:t})=>{if(O(t,"dmn:FunctionDefinition"))return R9})}};M(Id,"$inject",["components"]);function R9({expression:n},e){let t=e.injector.get("functionDefinition"),i=t.getKind(n),r=t.getParameters(n),o=t.getBody(n);return y(1,"div","function-definition",[P(2,A9,{kind:i}),P(2,M9,{parameters:r}),P(2,D9,{expression:o})],4)}var T9={FEEL:"F",Java:"J",PMML:"P"};function A9({kind:n},e){let t=e.injector.get("translate");return y(1,"div","function-definition-kind",T9[n],0,{title:t("Function kind: {kind}",{kind:n})})}function M9({parameters:n}){return y(1,"div","function-definition-parameters",y(1,"div",null,[Z("("),n.reduce((e,t)=>e.concat(P(2,P9,{parameter:t}),", "),[]).slice(0,-1),Z(")")],0),2)}function P9({parameter:n}){let{name:e,typeRef:t}=n,i=e||"";return y(1,"span",null,t?`${i}: ${t}`:i,0)}function D9({expression:n},e){let t=e.components.getComponent("expression",{expression:n});return y(1,"div","function-definition-body",P(2,t,{expression:n}),2)}var ED={__init__:["functionDefinitionComponent"],functionDefinition:["type",Tu],functionDefinitionComponent:["type",Id]};var Au=class extends L{constructor(t,i){super(t,i);M(this,"onClick",()=>{this._eventBus.fire("showDrd")});let{injector:r}=i;this._translate=r.get("translate"),this._eventBus=r.get("eventBus")}render(){return y(1,"div","view-drd",y(1,"button","view-drd-button",this._translate("View DRD"),0,{type:"button",onClick:this.onClick}),2,null,null,t=>this.node=t)}};Au.$inject=["translate"];var I9=2e3,Mu=class{constructor(e,t,i){this._injector=i,e.onGetComponent("viewer",I9,()=>{if(this.canViewDrd())return Au}),t.on("showDrd",()=>{let r=i.get("_parent",!1),o=r.getDefinitions(),s=r.getView(o);r.open(s)})}canViewDrd(){let e=this._injector.get("_parent",!1);if(!e)return;let t=e.getDefinitions();return!!e.getView(t)}};Mu.$inject=["components","eventBus","injector"];var SD={__init__:["viewDrd"],viewDrd:["type",Mu]};function ww(n,e){let t=e.injector.get("viewer"),{name:i}=t.getRootElement();return y(1,"div","element-properties",y(1,"h2","element-name",i,0),2)}var Pu=class{constructor(e){e.onGetComponent("header",()=>ww)}};Pu.$inject=["components"];var OD={__init__:["elementProperties"],elementProperties:["type",Pu]};var L9=100,Du=class{constructor(e){e.onGetComponent("body",()=>B9),e.onGetComponent("expression",L9,()=>$9)}};M(Du,"$inject",["components"]);function B9(n,{injector:e}){let t=e.get("components"),r=e.get("viewer").getRootElement(),o=N9(r),s=t.getComponent("expression",{expression:o});return P(2,s,{expression:o})}function N9(n){if(O(n,"dmn:Decision"))return n.get("decisionLogic");if(O(n,"dmn:BusinessKnowledgeModel"))return n.get("encapsulatedLogic")}function $9({expression:n}){return y(1,"div",null,y(1,"span",null,[Z("Expression of type "),n.$type,Z(" is not supported.")],0,{style:"color:red;"}),2)}var kD={__init__:["elementLogic"],elementLogic:["type",Du]};var Xo=class{constructor(e){this._viewer=e}getName(){let e=this.getVariable(),t=this._getElement();return(e?e.get("name"):null)||t.get("name")}getType(){let e=this.getVariable();return e?e.get("typeRef"):"Any"}_getElement(){return this._viewer.getRootElement()}getVariable(){return this._getElement().get("variable")}};M(Xo,"$inject",["viewer"]);var Iu=class{constructor(e){e.onGetComponent("footer",()=>j9)}};M(Iu,"$inject",["components"]);function j9(n,e){let t=e.injector.get("elementVariable"),i=e.injector.get("translate"),r=t.getName(),o=t.getType();return y(1,"div","element-variable",[y(1,"h2",null,Z("Result"),2),y(1,"div","element-variable-name",[y(1,"span","element-variable-name-label",i("Variable name"),0),y(1,"span",null,r,0)],4),y(1,"div","element-variable-type",[y(1,"span","element-variable-type-label",i("Variable type"),0),y(1,"span",null,o,0)],4)],4)}var RD={__init__:["elementVariableComponent"],elementVariable:["type",Xo],elementVariableComponent:["type",Iu]};var sa=class n extends ra{constructor(e={}){let t=n._createContainer();super(T(e,{renderer:{container:t}})),this._container=t}open(e){let t=this.get("eventBus");return new Promise((i,r)=>{let o;try{this.getRootElement()&&(this.clear(),t.fire("renderer.unmount")),this._setRootElement(e),t.fire("import",e),t.fire("renderer.mount")}catch(s){o=s}o?(o.warnings=o.warnings||[],r(o)):i({warnings:[]})})}_init(e){let{modules:t,additionalModules:i,...r}=e,o=t||this.getModules(),s=i||[],a=[{viewer:["value",this]}];return{modules:[...o,...s,...a],config:r}}on(e,t,i,r){return this.get("eventBus").on(e,t,i,r)}off(e,t){this.get("eventBus").off(e,t)}_emit(e,t){return this.get("eventBus").fire(e,t)}getRootElement(){return 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(){let e=this._container;e.parentNode&&(this._emit("detach",{}),Qe(e))}destroy(){super.destroy(),this.detach()}getModules(){return[_D,qe,wD,SD,OD,kD,ED,CD,RD]}static _createContainer(){return te('
    ')}};var Ld=class{constructor(e,t){this.registerBindings(t,e)}registerBindings(e,t){function i(r,o){t.isRegistered(r)&&e.addListener(o)}i("undo",function(r){let o=r.keyEvent;if(Tp(o))return t.trigger("undo"),!0}),i("redo",function(r){let o=r.keyEvent;if(Ap(o))return t.trigger("redo"),!0})}};M(Ld,"$inject",["editorActions","keyboard"]);var TD={__depends__:[_o],__init__:["keyboardBindings"],keyboardBindings:["type",Ld]};var Lu=class extends ae{constructor(t,i){super(t);M(this,"updateName",({context:t})=>{let{element:i,properties:r}=t;this.isNameChanged(r)&&(this.isVariable(i)?this.handleVariableNameChange(i):this.isVariableContainer(i)&&this.handleVariableContainerNameChange(i))});this._modeling=i,this.postExecuted("element.updateProperties",this.updateName)}isNameChanged(t){return"name"in t}isVariable(t){let i=AD(t);return O(t,"dmn:InformationItem")&&i&&i.get("variable")===t}isVariableContainer(t){let i=t.get("variable");return i&&O(i,"dmn:InformationItem")}handleVariableNameChange(t){let i=AD(t),r=t.get("name");r!==i.get("name")&&this._modeling.updateProperties(i,{name:r})}handleVariableContainerNameChange(t){let i=t.get("variable"),r=t.get("name");i&&r!==i.get("name")&&this._modeling.updateProperties(i,{name:r})}};M(Lu,"$inject",["eventBus","modeling"]);function AD(n){return n.$parent}var Bu=class{constructor(e,t,i){this._commandStack=e,this._viewer=t,this._eventBus=i,F9(this._getHandlers(),e)}_getHandlers(){return{"element.updateProperties":sr}}updateProperties(e,t){let i={element:e,properties:t};this._commandStack.execute("element.updateProperties",i)}};Bu.$inject=["commandStack","viewer","eventBus"];function F9(n,e){k(n,function(t,i){e.registerHandler(i,t)})}var MD={__init__:["idChangeBehavior","modeling","nameChangeBehavior"],commandStack:["type",ke],idChangeBehavior:["type",Gn],modeling:["type",Bu],nameChangeBehavior:["type",Lu]};function Nn(n,e){return function(t){return En(P(2,Cw,{...t,_component:n,_selectDependencies:e}))}}var Cw=class extends L{constructor(t,i){super(t,i);M(this,"onChange",({elements:t})=>{this.props._selectDependencies(this.props).some(r=>t.includes(r))&&this.forceUpdate()});this._eventBus=i.injector.get("eventBus")}componentDidMount(){this._subscribe()}componentWillUnmount(){this._unsubscribe()}_subscribe(){this._eventBus.on("elements.changed",this.onChange)}_unsubscribe(){this._eventBus.off("elements.changed",this.onChange)}render(){let t=this.props._component;return En(P(2,t,{...this.props}))}};var Ew=class extends L{constructor(t,i){super(t,i);M(this,"editLiteralExpressionText",t=>{let i=this.getLiteralExpression();this._literalExpression.setText(i,t)});this._literalExpression=i.injector.get("literalExpression"),this._translate=i.injector.get("translate"),this._expressionLanguages=i.injector.get("expressionLanguages"),this._variableResolver=i.injector.get("variableResolver",!1)}getLiteralExpression(){return this.props.expression}getEditor(){return this.isFeel()?q9:Sw}isFeel(){let t=this.getLiteralExpression();return h1(t)}_getVariables(){let t=this.getLiteralExpression();return this._variableResolver&&this._variableResolver.getVariables(t)}render(){let{text:t}=this.getLiteralExpression(),i=this.getEditor(),r=this._getVariables(),o=this._translate("Literal expression");return P(2,i,{label:o,className:"textarea editor",value:t,onChange:this.editLiteralExpressionText,variables:r})}};function q9(n){return En(P(2,Ri,{...n,onChange:n.onChange}))}var Sw=class extends an{render(){return y(1,"div",this.getClassName(),this.getEditor(),0)}},V9=Nn(Ew,n=>[n.expression]),Bd=class{constructor(e){e.onGetComponent("expression",({expression:t})=>{if(O(t,"dmn:LiteralExpression"))return V9})}};M(Bd,"$inject",["components"]);var Nu=class extends oa{constructor(e){super(),this._modeling=e}setText(e,t){this._modeling.updateProperties(e,{text:t})}};Nu.$inject=["modeling"];var PD={__init__:["literalExpressionComponent"],literalExpressionComponent:["type",Bd],literalExpression:["type",Nu]};var Nd=class extends Tu{constructor(e,t){super(),this._modeling=e,this._dmnFactory=t}addParameter(e){this._modeling.updateProperties(e,{formalParameter:[...this.getParameters(e),this._dmnFactory.create("dmn:InformationItem",{name:"",typeRef:""})]})}removeParameter(e,t){this._modeling.updateProperties(e,{formalParameter:this.getParameters(e).filter(i=>i!==t)})}updateParameter(e,t){this._modeling.updateProperties(e,t)}setKind(e,t){this._modeling.updateProperties(e,{kind:t})}};M(Nd,"$inject",["modeling","dmnFactory"]);function Ow({label:n,onClick:e}){return y(1,"button","edit-button dmn-icon-edit",null,1,{"aria-label":n,type:"button",onClick:e})}var $d=class{constructor(e){e.onGetComponent("expression",({expression:t})=>{if(O(t,"dmn:FunctionDefinition"))return H9})}};M($d,"$inject",["components"]);var H9=Nn(z9,n=>[n.expression]);function z9({expression:n},e){let t=e.injector.get("functionDefinition"),i=e.injector.get("contextMenu"),r=t.getKind(n),o=t.getParameters(n),s=t.getBody(n),a=c=>{let u=DD(c);i.open(u,{contextMenuType:"kind-editor",expression:n})},l=c=>{let u=DD(c);i.open(u,{contextMenuType:"formal-parameters-editor",expression:n})};return y(1,"div","function-definition",[P(2,U9,{kind:r,openEditor:a}),P(2,Q9,{parameters:o,openEditor:l}),P(2,X9,{expression:s,parameters:o})],4)}var W9={FEEL:"F",Java:"J",PMML:"P"};function U9({kind:n,openEditor:e},t){let i=t.injector.get("translate");return y(1,"div","function-definition-kind",[W9[n],P(2,Ow,{label:i("Edit function kind"),onClick:e})],0)}function Q9({openEditor:n,parameters:e},t){let i=t.injector.get("translate");return y(1,"div","function-definition-parameters",[y(1,"div",null,[Z("("),e.reduce((r,o)=>r.concat(P(2,K9,{parameter:o}),", "),[]).slice(0,-1),Z(")")],0),P(2,Ow,{label:i("Edit formal parameters"),onClick:n})],4)}var K9=Nn(G9,n=>[n.parameter]);function G9({parameter:n}){let{name:e,typeRef:t}=n,i=e||"";return y(1,"span",null,t?`${i}: ${t}`:i,0)}var X9=Nn(Y9,n=>n.parameters);function Y9({expression:n,parameters:e},t){let i=t.components.getComponent("expression",{expression:n});return y(1,"div","function-definition-body",P(2,i,{expression:n,parameters:e}),2)}function DD(n){let e=n.target.parentElement,t=e.getBoundingClientRect();return{x:t.x,y:t.y}}var Z9=[{value:"FEEL",label:"FEEL"},{value:"Java",label:"Java"},{value:"PMML",label:"PMML"}],jd=class{constructor(e){e.onGetComponent("context-menu",(t={})=>{if(t.contextMenuType&&t.contextMenuType==="kind-editor")return J9})}};M(jd,"$inject",["components"]);function J9({context:{expression:n}},e){let t=e.injector.get("functionDefinition"),i=e.injector.get("translate"),r=t.getKind(n),o=s=>{t.setKind(n,s)};return y(1,"div","context-menu-container",[y(1,"h3",null,i("Edit function kind"),0),P(2,pe,{label:i("Kind"),options:Z9,value:r,onChange:o,noInput:!0})],4)}var Fd=class{constructor(e){e.onGetComponent("context-menu",(t={})=>{if(t.contextMenuType&&t.contextMenuType==="formal-parameters-editor")return eU})}};M(Fd,"$inject",["components"]);var eU=Nn(tU,n=>[n.context.expression]);function tU({context:{expression:n}},e){let t=e.injector.get("functionDefinition"),i=e.injector.get("translate"),r=t.getParameters(n),o=a=>{t.removeParameter(n,a)},s=()=>{t.addParameter(n)};return y(1,"div","context-menu-container formal-parameters",[y(1,"h3",null,i("Edit formal parameters"),0),r.length?y(1,"table",null,[y(1,"thead",null,y(1,"tr",null,[y(1,"th",null,Z("Name"),2),y(1,"th",null,Z("Type"),2)],4),2),y(1,"tbody",null,r.map((a,l)=>P(2,nU,{parameter:a,remove:()=>o(a)},l)),0)],4):null,y(1,"button","add-parameter",i("Add parameter"),0,{type:"button",onClick:s})],0)}var nU=Nn(function({parameter:n,remove:e},t){let i=t.injector.get("dataTypes"),r=t.injector.get("translate"),o=t.injector.get("functionDefinition"),{name:s,typeRef:a}=n,l=f=>{o.updateParameter(n,{name:f})},c=f=>{o.updateParameter(n,{typeRef:f})},u=i.getAll().map(f=>({label:r(f),value:f}));return y(1,"tr","function-definition-parameter",[y(1,"td",null,P(2,St,{onChange:l,value:s}),2),y(1,"td",null,P(2,pe,{onChange:c,value:a,options:u}),2),y(1,"td",null,y(1,"button","dmn-icon-trash",null,1,{type:"button",onClick:e,"aria-label":r("Remove parameter")}),2)],4)},n=>[n.parameter]);var ID={__init__:["formalParametersEditorComponent","functionDefinitionComponent","kindEditorComponent"],__depends__:[Gt],formalParametersEditorComponent:["type",Fd],functionDefinition:["type",Nd],functionDefinitionComponent:["type",$d],kindEditorComponent:["type",jd]};var iU=Nn(function(n,e){let{element:t}=n,i=e.injector.get("modeling"),r=e.injector.get("translate"),o=t.get("name"),s=a=>{i.updateProperties(t,{name:a})};return P(2,St,{label:r("Element name"),className:"element-name editor",value:o,onChange:s})},n=>[n.element]);function kw(n,e){let i=e.injector.get("viewer").getRootElement();return y(1,"div","element-properties",P(2,iU,{element:i}),2)}var $u=class{constructor(e){e.onGetComponent("header",()=>kw)}};$u.$inject=["components"];var LD={__depends__:[Kt],__init__:["elementProperties"],elementProperties:["type",$u]};var ju=class{constructor(e,t){this._eventBus=t,this._viewer=e}updateId(e,t){let i=this._viewer.getRootElement();if(e!==i)throw new Error("element !== rootElement");this._eventBus.fire("element.updateId",{element:e,newId:t}),e.id=t}};ju.$inject=["viewer","eventBus"];var qd=class{constructor(e){this._moddle=e}create(e,t={}){return this._moddle.create(e,t)}};M(qd,"$inject",["moddle"]);var BD={__init__:["elementRegistry"],elementRegistry:["type",ju],dmnFactory:["type",qd]};var Fu=class extends Xo{constructor(e,t,i){super(e),this._modeling=t,this._dmnFactory=i}setType(e){let t=this.getVariable();if(!t){let i=this._getElement(),r=this._dmnFactory.create("dmn:InformationItem",{name:i.get("name"),typeRef:e});r.$parent=i,this._modeling.updateProperties(i,{variable:r});return}this._modeling.updateProperties(t,{typeRef:e})}};M(Fu,"$inject",["viewer","modeling","dmnFactory"]);var ND="dmn-boxed-expression-variable-type",qu=class{constructor(e,t){let i=Nn(rU,()=>[t.getVariable()]);e.onGetComponent("footer",()=>i)}};M(qu,"$inject",["components","elementVariable"]);function rU(n,e){let t=e.injector.get("elementVariable"),i=e.injector.get("translate"),r=t.getName();return y(1,"div","element-variable",[y(1,"h2",null,Z("Result"),2),y(1,"div","element-variable-name",[y(1,"span","element-variable-name-label",i("Variable name"),0),y(1,"span",null,r,0)],4),y(1,"div","element-variable-type",[y(1,"label","element-variable-type-label",Z("Result type"),2,{for:ND}),P(2,oU)],4)],4)}function oU(n,e){let t=e.injector.get("elementVariable"),i=e.injector.get("dataTypes"),r=e.injector.get("translate"),o=t.getType(),s=l=>t.setType(l),a=i.getAll().map(l=>({label:r(l),value:l}));return P(2,pe,{value:o,onChange:s,options:a,id:ND})}var $D={__init__:["elementVariableComponent"],elementVariable:["type",Fu],elementVariableComponent:["type",qu]};var jD="is not a registered action",sU="is already registered",Vu=class{constructor(e,t){this._actions={undo(){e.undo()},redo(){e.redo()}}}trigger(e,t){if(!this._actions[e])throw Rw(e,jD);return this._actions[e](t)}register(e,t){if(typeof e=="string")return this._registerAction(e,t);k(e,(i,r)=>{this._registerAction(r,i)},this)}_registerAction(e,t){if(this.isRegistered(e))throw Rw(e,sU);this._actions[e]=t}unregister(e){if(!this.isRegistered(e))throw Rw(e,jD);this._actions[e]=void 0}isRegistered(e){return!!this._actions[e]}};Vu.$inject=["commandStack","eventBus"];function Rw(n,e){return new Error(n+" "+e)}var FD={__init__:["editorActions"],editorActions:["type",Vu]};var Vd=class extends sa{getModules(){return[...super.getModules(),BD,MD,FD,LD,ID,Qt,Yn,PD,TD,Xi,$D,tl]}};var Yo=class extends Yu{_getViewProviders(){return[{id:"drd",constructor:So,opens:"dmn:Definitions"},{id:"decisionTable",constructor:_d,opens(e){return O(e,"dmn:Decision")&&O(e.decisionLogic,"dmn:DecisionTable")}},{id:"literalExpression",constructor:Ad,opens(e){return O(e,"dmn:Decision")&&O(e.decisionLogic,"dmn:LiteralExpression")}},{id:"boxedExpression",constructor:Vd,opens(e){return O(e,"dmn:BusinessKnowledgeModel")&&dr(e)}}]}_getInitialView(e,...t){let i=super._getInitialView(e,...t);if(!i)return;let r=i.element;return O(r,"dmn:Definitions")&&!La(r)&&(i=ye(e,o=>!O(o.element,"dmn:Definitions"))||i),i}};var Hd=class extends rs{_getViewProviders(){return[{id:"drd",constructor:Et,opens(e){return O(e,"dmn:Definitions")&&La(e)}},{id:"decisionTable",constructor:Ao,opens(e){return O(e,"dmn:Decision")&&O(e.decisionLogic,"dmn:DecisionTable")}},{id:"literalExpression",constructor:Go,opens(e){return O(e,"dmn:Decision")&&O(e.decisionLogic,"dmn:LiteralExpression")}},{id:"boxedExpression",constructor:sa,opens(e){return O(e,"dmn:BusinessKnowledgeModel")&&dr(e)}}]}};var aU=globalThis;Object.assign(Yo,{Modeler:Yo,Viewer:Hd});aU.DmnJS=Yo;var UTe=Yo;})();