/*! dmn-js - 17.7.0 | generated for dokuwiki-plugin-bpmnio | SEE LICENSE IN LICENSE */ (()=>{var N2=Object.create;var Ky=Object.defineProperty;var $2=Object.getOwnPropertyDescriptor;var j2=Object.getOwnPropertyNames;var F2=Object.getPrototypeOf,q2=Object.prototype.hasOwnProperty;var V2=(n,e,t)=>e in n?Ky(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var Aw=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports);var H2=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of j2(e))!q2.call(n,r)&&r!==t&&Ky(n,r,{get:()=>e[r],enumerable:!(i=$2(e,r))||i.enumerable});return n};var Mw=(n,e,t)=>(t=n!=null?N2(F2(n)):{},H2(e||!n||!n.__esModule?Ky(t,"default",{value:n,enumerable:!0}):t,n));var M=(n,e,t)=>V2(n,typeof e!="symbol"?e+"":e,t);var cR=Aw((Ux,lR)=>{/*! https://mths.be/cssescape v1.5.1 by @mathias | MIT license */(function(n,e){typeof Ux=="object"?lR.exports=e(n):typeof define=="function"&&define.amd?define([],e.bind(n,n)):e(n)})(typeof window!="undefined"?window:Ux,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 kR=Aw((Ide,OR)=>{"use strict";/*! * escape-html * Copyright(c) 2012-2013 TJ Holowaychuk * Copyright(c) 2015 Andreas Lubbe * Copyright(c) 2015 Tiancheng "Timothy" Gu * MIT Licensed */var w5=/["'&<>]/;OR.exports=C5;function C5(n){var e=""+n,t=w5.exec(e);if(!t)return e;var i,r="",o=0,s=0;for(o=t.index;oe)}function cr(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 Lw(n,...e){n=Gy(n);let t={};return k(e,r=>cr(r,n,t)),qt(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 aa(n){return function(e){return St(n,function(t,i){return e[i]===t})}}function Gy(n){return pe(n)?n:e=>e[n]}function Xy(n){return pe(n)?n:e=>e===n}function W2(n){return n}function U2(n){return Number(n)}function Ai(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 Bw(n,e){let t=!1;return function(...i){t||(n(...i),t=!0,setTimeout(()=>{t=!1},e))}}function it(n,e){return n.bind(e)}function T(n,...e){return Object.assign(n,...e)}function Nw(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];Te(s)&&Xr(a)&&(a=i[r]=isNaN(+s)?{}:[]),qu(s)?qu(t)?delete i[r]:i[r]=t:i=a}),n}function fn(n,e){let t={},i=Object(n);return k(e,function(r){r in i&&(t[r]=n[r])}),t}function Hu(n,e){let t={},i=Object(n);return k(i,function(r,o){e.indexOf(o)===-1&&(t[o]=r)}),t}var zd="__fn",$w=1e3,Q2=Array.prototype.slice;function st(){this._listeners={},this.on("diagram.destroy",1,this._destroy,this)}st.prototype.on=function(n,e,t,i){if(n=F(n)?n:[n],pe(e)&&(i=t,t=e,e=$w),!oe(e))throw new Error("priority must be a number");var r=t;i&&(r=it(t,i),r[zd]=t[zd]||t);var o=this;n.forEach(function(s){o._addListener(s,{priority:e,callback:r,next:null})})};st.prototype.once=function(n,e,t,i){var r=this;if(pe(e)&&(i=t,t=e,e=$w),!oe(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[zd]=t,this.on(n,e,o)};st.prototype.off=function(n,e){n=F(n)?n:[n];var t=this;n.forEach(function(i){t._removeListener(i,e)})};st.prototype.createEvent=function(n){var e=new zu;return e.init(n),e};st.prototype.fire=function(n,e){var t,i,r,o;if(o=Q2.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 zu?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}};st.prototype.handleError=function(n){return this.fire("error",{error:n})===!1};st.prototype._destroy=function(){this._listeners={}};st.prototype._invokeListeners=function(n,e,t){for(var i;t&&!n.cancelBubble;)i=this._invokeListener(n,e,t),t=t.next;return i};st.prototype._invokeListener=function(n,e,t){var i;if(t.callback.__isTomb)return i;try{i=K2(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};st.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 fn(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=Ot(r[0],i),s=Ot(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,it(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 Zr(n,e){this.packageMap={},this.typeMap={},this.packages=[],this.properties=e,k(n,it(this.registerPackage,this))}Zr.prototype.getPackage=function(n){return this.packageMap[n]};Zr.prototype.getPackages=function(){return this.packages};Zr.prototype.registerPackage=function(n){n=T({},n);var e=this.packageMap;jw(e,n,"prefix"),jw(e,n,"uri"),k(n.types,it(function(t){this.registerType(t,n)},this)),e[n.uri]=e[n.prefix]=n,this.packages.push(n)};Zr.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=Ot(n.name,e.prefix),i=t.name,r={};k(n.properties,it(function(o){var s=Ot(o.name,t.prefix),a=s.name;Yy(o.type)||(o.type=Ot(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,it(function(o){var s=Ot(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};Zr.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=Ot(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)};Zr.prototype.getEffectiveDescriptor=function(n){var e=Ot(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};Zr.prototype.definePackage=function(n,e){this.properties.define(n,"$pkg",{value:e})};function jw(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(!Pe(e)||!e.length)throw new TypeError("property name must be a non-empty string");var i=this.getProperty(n,e),r=i&&i.name;X2(t)?i?delete n[r]:delete n.$attrs[Zy(e)]:i?r in n?n[r]=t:Vw(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&&Vw(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 X2(n){return typeof n=="undefined"}function Vw(n,e,t){Object.defineProperty(n,e.name,{enumerable:!e.isReference,writable:!0,value:t,configurable:!0})}function Zy(n){return n.replace(/^:/,"")}function hn(n,e={}){this.properties=new es(this),this.factory=new Fw(this,this.properties),this.registry=new Zr(n,this.properties),this.typeCache={},this.config=e}hn.prototype.create=function(n,e){var t=this.getType(n);if(!t)throw new Error("unknown type <"+n+">");return new t(e)};hn.prototype.getType=function(n){var e=this.typeCache,t=Pe(n)?n:n.ns.name,i=e[t];return i||(n=this.registry.getEffectiveDescriptor(t),i=e[t]=this.factory.createType(n)),i};hn.prototype.createAny=function(n,e,t){var i=Ot(n),r={$type:n,$instanceOf:function(s){return s===this.$type},get:function(s){return this[s]},set:function(s,a){Nw(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){Ae(s)&&s.value!==void 0?r[s.name]=s.value:r[a]=s}),r};hn.prototype.getPackage=function(n){return this.registry.getPackage(n)};hn.prototype.getPackages=function(){return this.registry.getPackages()};hn.prototype.getElementDescriptor=function(n){return n.$descriptor};hn.prototype.hasType=function(n,e){e===void 0&&(e=n,n=this);var t=n.$model.getElementDescriptor(n);return e in t.allTypesByName};hn.prototype.getPropertyDescriptor=function(n,e){return this.getElementDescriptor(n).propertiesByName[e]};hn.prototype.getTypeDescriptor=function(n){return this.registry.typeMap[n]};var Hw=String.fromCharCode,Y2=Object.prototype.hasOwnProperty,Z2=/&#(\d+);|&#x([0-9a-f]+);|&(\w+);/ig,Wu={amp:"&",apos:"'",gt:">",lt:"<",quot:'"'};Object.keys(Wu).forEach(function(n){Wu[n.toUpperCase()]=Wu[n]});function J2(n,e,t,i){return i?Y2.call(Wu,i)?Wu[i]:"&"+i+";":Hw(e||parseInt(t,16))}function ts(n){return n.length>3&&n.indexOf("&")!==-1?n.replace(Z2,J2):n}var zw="non-whitespace outside of root node";function la(n){return new Error(n)}function Ww(n){return"missing namespace for prefix <"+n+">"}function Ud(n){return{get:n,enumerable:!0}}function eI(n){var e={},t;for(t in n)e[t]=n[t];return e}function tv(n){return n+"$uri"}function tI(n){var e={},t,i;for(t in n)i=n[t],e[i]=i,e[tv(i)]=t;return e}function Uw(){return{line:0,column:0}}function nI(n){throw n}function nv(n){if(!this)return new nv(n);var e=n&&n.proxy,t,i,r,o,s=nI,a,l,c,u,f=Uw,h=!1,d=!1,p=null,m=!1,g;function b(x){x instanceof Error||(x=la(x)),p=x,s(x,f)}function w(x){a&&(x instanceof Error||(x=la(x)),a(x,f))}this.on=function(x,_){if(typeof _!="function")throw la("required args ");switch(x){case"openTag":i=_;break;case"text":t=_;break;case"closeTag":r=_;break;case"error":s=_;break;case"warn":a=_;break;case"cdata":o=_;break;case"attention":u=_;break;case"question":c=_;break;case"comment":l=_;break;default:throw la("unsupported event: "+x)}return this},this.ns=function(x){if(typeof x=="undefined"&&(x={}),typeof x!="object")throw la("required args ");var _={},E;for(E in x)_[E]=x[E];return d=!0,g=_,this},this.parse=function(x){if(typeof x!="string")throw la("required args ");return p=null,v(x),f=Uw,m=!1,p},this.stop=function(){m=!0};function v(x){var _=d?[]:null,E=d?tI(g):null,S,C=[],R=0,A=!1,D=!1,I=0,N=0,H,ke,be,ue,wn,Ft,dt,vt,_t,Lt="",un=0,ot;function Ri(){if(ot!==null)return ot;var ui,$n,jn,sr=d&&E.xmlns,ar=d&&h?[]:null,Ge=un,Bt=Lt,Jo=Bt.length,Rw,Gr,lr,Ti,Re,sa={},Tw={},fi,re,Ce;e:for(;Ge8)){for((re<65||re>122||re>90&&re<97)&&re!==95&&re!==58&&(w("illegal first char attribute name"),fi=!0),Ce=Ge+1;Ce96&&re<123||re>64&&re<91||re>47&&re<59||re===46||re===45||re===95)){if(re===32||re<14&&re>8){w("missing attribute value"),Ge=Ce;continue e}if(re===61)break;w("illegal attribute name char"),fi=!0}if(Re=Bt.substring(Ge,Ce),Re==="xmlns:xmlns"&&(w("illegal declaration of xmlns"),fi=!0),re=Bt.charCodeAt(Ce+1),re===34)Ce=Bt.indexOf('"',Ge=Ce+2),Ce===-1&&(Ce=Bt.indexOf("'",Ge),Ce!==-1&&(w("attribute value quote missmatch"),fi=!0));else if(re===39)Ce=Bt.indexOf("'",Ge=Ce+2),Ce===-1&&(Ce=Bt.indexOf('"',Ge),Ce!==-1&&(w("attribute value quote missmatch"),fi=!0));else for(w("missing attribute value quotes"),fi=!0,Ce=Ce+1;Ce8));Ce++);for(Ce===-1&&(w("missing closing quotes"),Ce=Jo,fi=!0),fi||(lr=Bt.substring(Ge,Ce)),Ge=Ce;Ce+18));Ce++)Ge===Ce&&(w("illegal character after attribute end"),fi=!0);if(Ge=Ce+1,fi)continue e;if(Re in Tw){w("attribute <"+Re+"> already defined");continue}if(Tw[Re]=!0,!d){sa[Re]=lr;continue}if(h){if(Gr=Re==="xmlns"?"xmlns":Re.charCodeAt(0)===120&&Re.substr(0,6)==="xmlns:"?Re.substr(6):null,Gr!==null){if(ui=ts(lr),$n=tv(Gr),Ti=g[ui],!Ti){if(Gr==="xmlns"||$n in E&&E[$n]!==ui)do Ti="ns"+R++;while(typeof E[Ti]!="undefined");else Ti=Gr;g[ui]=Ti}E[Gr]!==Ti&&(Rw||(E=eI(E),Rw=!0),E[Gr]=Ti,Gr==="xmlns"&&(E[tv(Ti)]=ui,sr=Ti),E[$n]=ui),sa[Re]=lr;continue}ar.push(Re,lr);continue}if(re=Re.indexOf(":"),re===-1){sa[Re]=lr;continue}if(!(jn=E[Re.substring(0,re)])){w(Ww(Re.substring(0,re)));continue}Re=sr===jn?Re.substr(re+1):jn+Re.substr(re),sa[Re]=lr}if(h)for(Ge=0,Jo=ar.length;Ge=sr&&(Ge=ui.exec(x),!(!Ge||(ar=Ge[0].length+Ge.index,ar>I)));)$n+=1,sr=ar;return I==-1?(jn=ar,Bt=x.substring(N)):N===0?Bt=x.substring(N,I):(jn=I-sr,Bt=N==-1?x.substring(I):x.substring(I,N+1)),{data:Bt,line:$n,column:jn}}for(f=Zo,e&&(_t=Object.create({},{name:Ud(function(){return dt}),originalName:Ud(function(){return vt}),attrs:Ud(Ri),ns:Ud(function(){return E})}));N!==-1;){if(x.charCodeAt(N)===60?I=N:I=x.indexOf("<",N),I===-1){if(C.length)return b("unexpected end of file");if(N===0)return b("missing start tag");N",I),N===-1)return b("unclosed cdata");if(o&&(o(x.substring(I+9,N),f),m))return;N+=3;continue}if(be===45&&x.charCodeAt(I+3)===45){if(N=x.indexOf("-->",I),N===-1)return b("unclosed comment");if(l&&(l(x.substring(I+4,N),ts,f),m))return;N+=3;continue}}if(ue===63){if(N=x.indexOf("?>",I),N===-1)return b("unclosed question");if(c&&(c(x.substring(I,N+2),f),m))return;N+=2;continue}for(H=I+1;;H++){if(wn=x.charCodeAt(H),isNaN(wn))return N=-1,b("unclosed tag");if(wn===34)be=x.indexOf('"',H+1),H=be!==-1?be:H;else if(wn===39)be=x.indexOf("'",H+1),H=be!==-1?be:H;else if(wn===62){N=H;break}}if(ue===33){if(u&&(u(x.substring(I,N+1),ts,f),m))return;N+=1;continue}if(ot={},ue===47){if(A=!1,D=!0,!C.length)return b("missing open tag");if(H=dt=C.pop(),be=I+2+H.length,x.substring(I+2,be)!==H)return b("closing tag mismatch");for(;be8&&ue<14))return b("close tag")}else{if(x.charCodeAt(N-1)===47?(H=dt=x.substring(I+1,N-1),A=!0,D=!0):(H=dt=x.substring(I+1,N),A=!0,D=!1),!(ue>96&&ue<123||ue>64&&ue<91||ue===95||ue===58))return b("illegal first char nodeName");for(be=1,ke=H.length;be96&&ue<123||ue>64&&ue<91||ue>47&&ue<59||ue===45||ue===95||ue==46)){if(ue===32||ue<14&&ue>8){dt=H.substring(0,be),ot=null;break}return b("invalid nodeName")}D||C.push(dt)}if(d){if(S=E,A&&(D||_.push(S),ot===null&&(h=H.indexOf("xmlns",be)!==-1)&&(un=be,Lt=H,Ri(),h=!1)),vt=dt,ue=dt.indexOf(":"),ue!==-1){if(Ft=E[dt.substring(0,ue)],!Ft)return b("missing namespace on <"+vt+">");dt=dt.substr(ue+1)}else Ft=E.xmlns;Ft&&(dt=Ft+":"+dt)}if(A&&(un=be,Lt=H,i&&(e?i(_t,ts,D,f):i(dt,Ri,ts,D,f),m)))return;if(D){if(r&&(r(e?_t:dt,ts,A,f),m))return;d&&(A?E=S:E=_.pop())}N+=1}}}function Qw(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"},Kw="property";function Gw(n){return n.xml&&n.xml.serialize}function iI(n){let e=Gw(n);return e!==Kw&&(e||null)}function rI(n){return n.charAt(0).toUpperCase()+n.slice(1)}function Xw(n,e){return Qw(e)?n.prefix+":"+rI(n.localName):n.name}function oI(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 sI(n,e,t){let i=Ot(n,e.xmlns),r=`${e[i.prefix]||i.prefix}:${i.localName}`,o=Ot(r);var s=t.getPackage(o.prefix);return oI(o,s)}function Jr(n){return new Error(n)}function ur(n){return n.$descriptor}function aI(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 Jr("expected element");var t=this.elementsById,i=ur(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 Jr("duplicate ID <"+o+">");t[o]=e}},this.addWarning=function(e){this.warnings.push(e)}}function Uu(){}Uu.prototype.handleEnd=function(){};Uu.prototype.handleText=function(){};Uu.prototype.handleNode=function(){};function rv(){}rv.prototype=Object.create(Uu.prototype);rv.prototype.handleNode=function(){return this};function ua(){}ua.prototype=Object.create(Uu.prototype);ua.prototype.handleText=function(n){this.body=(this.body||"")+n};function Qu(n,e){this.property=n,this.context=e}Qu.prototype=Object.create(ua.prototype);Qu.prototype.handleNode=function(n){if(this.element)throw Jr("expected no sub nodes");return this.element=this.createReference(n),this};Qu.prototype.handleEnd=function(){this.element.id=this.body};Qu.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(ua.prototype);ov.prototype.handleEnd=function(){var n=this.body||"",e=this.element,t=this.propertyDesc;n=Wd(t.type,n),t.isMany?e.get(t.name).push(n):e.set(t.name,n)};function Qd(){}Qd.prototype=Object.create(ua.prototype);Qd.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 Vt(n,e,t){this.model=n,this.type=n.getType(e),this.context=t}Vt.prototype=Object.create(Qd.prototype);Vt.prototype.addReference=function(n){this.context.addReference(n)};Vt.prototype.handleText=function(n){var e=this.element,t=ur(e),i=t.bodyProperty;if(!i)throw Jr("unexpected body text <"+n+">");ua.prototype.handleText.call(this,n)};Vt.prototype.handleEnd=function(){var n=this.body,e=this.element,t=ur(e),i=t.bodyProperty;i&&n!==void 0&&(n=Wd(i.type,n),e.set(i.name,n))};Vt.prototype.createElement=function(n){var e=n.attributes,t=this.type,i=ur(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=Wd(u.type,l):c==="xmlns"?c=":"+c:(a=Ot(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};Vt.prototype.getPropertyForNode=function(n){var e=n.name,t=Ot(e),i=this.type,r=this.model,o=ur(i),s=t.name,a=o.propertiesByName[s];if(a&&!a.isAttr){let c=iI(a);if(c){let u=n.attributes[c];if(u){let f=sI(u,n.ns,r),h=r.getType(f);return T({},a,{effectiveType:ur(h).name})}}return a}var l=r.getPackage(t.prefix);if(l){let c=Xw(t,l),u=r.getType(c);if(a=me(o.properties,function(f){return!f.isVirtual&&!f.isReference&&!f.isAttribute&&u.hasType(f.type)}),a)return T({},a,{effectiveType:ur(u).name})}else if(a=me(o.properties,function(c){return!c.isReference&&!c.isAttribute&&c.type==="Element"}),a)return a;throw Jr("unrecognized element <"+t.name+">")};Vt.prototype.toString=function(){return"ElementDescriptor["+ur(this.type).name+"]"};Vt.prototype.valueHandler=function(n,e){return new ov(n,e)};Vt.prototype.referenceHandler=function(n){return new Qu(n,this.context)};Vt.prototype.handler=function(n){return n==="Element"?new ca(this.model,n,this.context):new Vt(this.model,n,this.context)};Vt.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){Vt.call(this,n,e,t)}sv.prototype=Object.create(Vt.prototype);sv.prototype.createElement=function(n){var e=n.name,t=Ot(e),i=this.model,r=this.type,o=i.getPackage(t.prefix),s=o&&Xw(t,o)||e;if(!r.hasType(s))throw Jr("unexpected element <"+n.originalName+">");return Vt.prototype.createElement.call(this,n)};function ca(n,e,t){this.model=n,this.context=t}ca.prototype=Object.create(Qd.prototype);ca.prototype.createElement=function(n){var e=n.name,t=Ot(e),i=t.prefix,r=n.ns[i+"$uri"],o=n.attributes;return this.model.createAny(e,r,o)};ca.prototype.handleChild=function(n){var e=new ca(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};ca.prototype.handleEnd=function(){this.body&&(this.element.$body=this.body)};function Kd(n){n instanceof hn&&(n={model:n}),T(this,{lax:!1},n)}Kd.prototype.fromXML=function(n,e,t){var i=e.rootHandler;e instanceof Vt?(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 aI(T({},e,{rootHandler:i})),a=new nv({proxy:!0}),l=lI();i.context=s,l.push(i);function c(_,E,S){var C=E(),R=C.line,A=C.column,D=C.data;D.charAt(0)==="<"&&D.indexOf(" ")!==-1&&(D=D.slice(0,D.indexOf(" "))+">");var I="unparsable content "+(D?D+" ":"")+`detected line: `+R+` column: `+A+` nested error: `+_.message;if(S)return s.addWarning({message:I,error:_}),!0;throw Jr(I)}function u(_,E){return c(_,E,!0)}function f(){var _=s.elementsById,E=s.references,S,C;for(S=0;C=E[S];S++){var R=C.element,A=_[C.id],D=ur(R).propertiesByName[C.property];if(A||s.addWarning({message:"unresolved reference <"+C.id+">",element:C.element,property:C.property,value:C.id}),D.isMany){var I=R.get(D.name),N=I.indexOf(C);N===-1&&(N=I.length),A?I[N]=A:I.splice(N,1)}else R.set(D.name,A)}}function h(){l.pop().handleEnd()}var d=/^<\?xml /i,p=/ encoding="([^"]+)"/i,m=/^utf-8$/i;function g(_){if(d.test(_)){var E=p.exec(_),S=E&&E[1];!S||m.test(S)||s.addWarning({message:"unsupported document encoding <"+S+">, falling back to UTF-8"})}}function b(_,E){var S=l.peek();try{l.push(S.handleNode(_))}catch(C){c(C,E,o)&&l.push(new rv)}}function w(_,E){try{l.peek().handleText(_)}catch(S){u(S,E)}}function v(_,E){_.trim()&&w(_,E)}var x=r.getPackages().reduce(function(_,E){return _[E.uri]=E.prefix,_},Object.entries(iv).reduce(function(_,[E,S]){return _[S]=E,_},r.config&&r.config.nsMap||{}));return a.ns(x).on("openTag",function(_,E,S,C){var R=_.attrs||{},A=Object.keys(R).reduce(function(I,N){var H=E(R[N]);return I[N]=H,I},{}),D={name:_.name,originalName:_.originalName,attributes:A,ns:_.ns};b(D,C)}).on("question",g).on("closeTag",h).on("cdata",w).on("text",function(_,E,S){v(E(_),S)}).on("error",c).on("warn",u),new Promise(function(_,E){var S;try{a.parse(n),f()}catch(I){S=I}var C=i.element;!S&&!C&&(S=Jr("failed to parse document as <"+i.type.$descriptor.name+">"));var R=s.warnings,A=s.references,D=s.elementsById;return S?(S.warnings=R,E(S)):_({rootElement:C,elementsById:D,references:A,warnings:R})})};Kd.prototype.handler=function(n){return new sv(this.model,n)};function lI(){var n=[];return Object.defineProperty(n,"peek",{value:function(){return this[this.length-1]}}),n}var cI=` `,uI=/<|>|'|"|&|\n\r|\n/g,Yw=/<|>|&/g;function Mi(n){this.prefixMap={},this.uriMap={},this.used={},this.wellknown=[],this.custom=[],this.parent=n,this.defaultPrefixMap=n&&n.defaultPrefixMap||{}}Mi.prototype.mapDefaultPrefixes=function(n){this.defaultPrefixMap=n};Mi.prototype.defaultUriByPrefix=function(n){return this.defaultPrefixMap[n]};Mi.prototype.byUri=function(n){return this.uriMap[n]||this.parent&&this.parent.byUri(n)};Mi.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)};Mi.prototype.uriByPrefix=function(n){return this.prefixMap[n||"xmlns"]||this.parent&&this.parent.uriByPrefix(n)};Mi.prototype.mapPrefix=function(n,e){this.prefixMap[n||"xmlns"]=e};Mi.prototype.getNSKey=function(n){return n.prefix!==void 0?n.uri+"|"+n.prefix:n.uri};Mi.prototype.logUsed=function(n){var e=n.uri,t=this.getNSKey(n);this.used[t]=this.byUri(e),this.parent&&this.parent.logUsed(n)};Mi.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 fI(n){return n.charAt(0).toLowerCase()+n.slice(1)}function hI(n,e){return Qw(e)?fI(n):n}function Zw(n,e){n.super_=e,n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}})}function Jw(n){return Pe(n)?n:(n.prefix?n.prefix+":":"")+n.localName}function dI(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 pI(n,e){return e.isGeneric?T({localName:e.ns.localName},n):T({localName:hI(e.ns.localName,e.$pkg)},n)}function mI(n,e){return T({localName:e.ns.localName},n)}function gI(n){var e=n.$descriptor;return _e(e.properties,function(t){var i=t.name;if(t.isVirtual||!Yr(n,i))return!1;var r=n[i];return r===t.default||r===null?!1:t.isMany?r.length:!0})}var yI={"\n":"#10","\n\r":"#10",'"':"#34","'":"#39","<":"#60",">":"#62","&":"#38"},vI={"<":"lt",">":"gt","&":"amp"};function e1(n,e,t){return n=Pe(n)?n:""+n,n.replace(e,function(i){return"&"+t[i]+";"})}function xI(n){return e1(n,uI,yI)}function bI(n){return e1(n,Yw,vI)}function _I(n){return _e(n,function(e){return e.isAttr})}function wI(n){return _e(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?bI(this.value):this.value)};ns.prototype.build=function(n,e){return this.value=e,n.type==="String"&&e.search(Yw)!==-1&&(this.escape=!0),this};function lv(n){this.tagName=n}Zw(lv,ns);lv.prototype.serializeTo=function(n){n.appendIndent().append("<"+this.tagName+">"),this.serializeValue(n),n.append("").appendNewLine()};function Be(n,e){this.body=[],this.attrs=[],this.parent=n,this.propertyDescriptor=e}Be.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=gI(n),this.parseAttributes(_I(r)),this.parseContainments(wI(r))),this.parseGenericAttributes(n,i),this};Be.prototype.nsTagName=function(n){var e=this.logNamespaceUsed(n.ns);return pI(e,n)};Be.prototype.nsPropertyTagName=function(n){var e=this.logNamespaceUsed(n.ns);return mI(e,n)};Be.prototype.isLocalNs=function(n){return n.uri===this.ns.uri};Be.prototype.nsAttributeName=function(n){var e;if(Pe(n)?e=Ot(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)};Be.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}))};Be.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 Be(this).build(i))})};Be.prototype.parseNsAttribute=function(n,e,t){var i=n.$model,r=Ot(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)}};Be.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};Be.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)}})};Be.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=Gw(r);k(o,function(c){var u;l?l===Kw?u=new Be(e,r):u=new Gd(e,r,l):u=new Be(e),t.push(u.build(c))})}})};Be.prototype.getNamespaces=function(n){var e=this.namespaces,t=this.parent,i;return e||(i=t&&t.getNamespaces(),n||!i?this.namespaces=e=new Mi(i):e=i),e};Be.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};Be.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};Be.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)})};Be.prototype.addTagName=function(n){var e=this.logNamespaceUsed(n);return this.getNamespaces().logUsed(e),Jw(n)};Be.prototype.addAttribute=function(n,e){var t=this.attrs;Pe(e)&&(e=xI(e));var i=Dw(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)};Be.prototype.serializeAttributes=function(n){var e=this.attrs,t=this.namespaces;t&&(e=dI(t).concat(e)),k(e,function(i){n.append(" ").append(Jw(i.name)).append('="').append(i.value).append('"')})};Be.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 Gd(n,e,t){Be.call(this,n,e),this.serialization=t}Zw(Gd,Be);Gd.prototype.parseNsAttributes=function(n){var e=Be.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};Gd.prototype.isLocalNs=function(n){return n.uri===(this.typeNs||this.ns).uri};function CI(){this.value="",this.write=function(n){this.value+=n}}function EI(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 t1(n){n=T({format:!1,preamble:!0},n||{});function e(t,i){var r=i||new CI,o=new EI(r,n.format);n.preamble&&o.append(cI);var s=new Be,a=t.$model;if(s.getNamespaces().mapDefaultPrefixes(SI(a)),s.build(t).serializeTo(o),!i)return r.value}return{toXML:e}}function SI(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 Xd(n,e){hn.call(this,n,e)}Xd.prototype=Object.create(hn.prototype);Xd.prototype.fromXML=function(n,e,t){Pe(e)||(t=e,e="dmn:Definitions");var i=new Kd(T({model:this,lax:!0},t)),r=i.handler(e);return i.fromXML(n,r)};Xd.prototype.toXML=function(n,e){var t=new t1(e);return new Promise(function(i,r){try{var o=t.toXML(n);return i({xml:o})}catch(s){return r(s)}})};var OI="DC",kI="dc",RI="http://www.omg.org/spec/DMN/20180521/DC/",TI=[{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"}]}],AI=[],MI=[{name:"AlignmentKind",literalValues:[{name:"start"},{name:"center"},{name:"end"}]}],PI={name:OI,prefix:kI,uri:RI,types:TI,associations:AI,enumerations:MI},DI="DI",II="di",LI="http://www.omg.org/spec/DMN/20180521/DI/",BI=[{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"}]}],NI=[],$I=[],jI={tagAlias:"lowerCase"},FI={name:DI,prefix:II,uri:LI,types:BI,associations:NI,enumerations:$I,xml:jI},qI="DMN",VI="dmn",HI="https://www.omg.org/spec/DMN/20191111/MODEL/",zI=[{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"}]}],WI=[{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"}]}],UI=[],QI={tagAlias:"lowerCase"},KI={name:qI,prefix:VI,uri:HI,types:zI,enumerations:WI,associations:UI,xml:QI},GI="DMNDI",XI="dmndi",YI="https://www.omg.org/spec/DMN/20191111/DMNDI/",ZI=[{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"]}],JI=[],eL=[],tL={name:GI,prefix:XI,uri:YI,types:ZI,associations:JI,enumerations:eL},nL="bpmn.io DI for DMN",iL="http://bpmn.io/schema/dmn/biodi/2.0",rL="biodi",oL={tagAlias:"lowerCase"},sL=[{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"}]}],aL={name:nL,uri:iL,prefix:rL,xml:oL,types:sL},lL={dc:PI,di:FI,dmn:KI,dmndi:tL,biodi:aL};function n1(n,e){var t=T({},lL,n);return new Xd(t,e)}var pt={legend:[1,"
","
"],tr:[2,"","
"],col:[2,"","
"],_default:[0,"",""]};pt.td=pt.th=[3,"","
"];pt.option=pt.optgroup=[1,'"];pt.thead=pt.tbody=pt.colgroup=pt.caption=pt.tfoot=[1,"","
"];pt.polyline=pt.ellipse=pt.polygon=pt.circle=pt.text=pt.line=pt.path=pt.rect=pt.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(pt,i)?pt[i]:pt._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 cL(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 Xe(n,e,t){return arguments.length==2?n.getAttribute(e):t===null?n.removeAttribute(e):(n.setAttribute(e,t),n)}var uL=Object.prototype.toString;function ee(n){return new eo(n)}function eo(n){if(!n||!n.nodeType)throw new Error("A DOM element reference is required");this.el=n,this.list=n.classList}eo.prototype.add=function(n){return this.list.add(n),this};eo.prototype.remove=function(n){return uL.call(n)=="[object RegExp]"?this.removeMatching(n):(this.list.remove(n),this)};eo.prototype.removeMatching=function(n){let e=this.array();for(let t=0;t=1&&pe(arguments[e-1])){var t=arguments[e-1];console.warn(new Error("Passing callbacks to "+gL(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 gL(n){return n.replace("bound ","")}var yL={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 st,this._viewsChanged=Ai(this._viewsChanged,0),this._views=[],this._viewers={},this.open=fa(this.open.bind(this)),this.importXML=fa(this.importXML.bind(this)),this.saveXML=fa(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=vL(c,e)||xL(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",{}),He(this._container)}destroy(){Object.keys(this._viewers).forEach(e=>{var t=this._viewers[e];l1(t,"destroy")}),He(this._container)}_init(e){this._options=e,this._moddle=this._createModdle(e),this._viewers={},this._views=[];let t=te('
'),i=T({},yL,e);T(t.style,{width:s1(i.width),height:s1(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=me(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=me(o,function(d){return Zd(c,d)})||this._getInitialView(o),!u)){this._switchView(null);return}var f=!Zd(c,u)||a1(c,u),h=r.length!==o.length||!St(o,function(d){return me(r,function(p){return Zd(p,d)&&!a1(p,d)})});this._activeView=u,this._views=o,(f||h)&&this._viewsChanged()}_getInitialView(e,t){var i;return t&&(i=me(e,function(r){return Zd(r,t)})||me(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&&(l1(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=me(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 n1(e.moddleExtensions)}_getViewProviders(){return[]}};function s1(n){return n+(oe(n)?"px":"")}function vL(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 xL(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 Zd(n,e){return Te(n)?Te(e)?n.element===e.element||n.id===e.id:!1:!Te(e)}function a1(n,e){return!n||!e||n.name!==e.name}function l1(n,e){pe(n[e])&&n[e]()}function bL(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var cv={exports:{}},c1;function _L(){if(c1)return cv.exports;c1=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 wL=_L(),CL=bL(wL);function qn(n){if(!(this instanceof qn))return new qn(n);n=n||[128,36,1],this._seed=n.length?CL.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=ze(n);return t&&typeof t.$instanceOf=="function"&&t.$instanceOf(e)}function ne(n){return O(n,"dmn:InputClause")}function Se(n){return O(n,"dmn:OutputClause")}function ze(n){return n&&n.businessObject||n}function u1(n){return ze(n).name}function We(n,e){return Vd(e,function(t){return O(n,t)})}function fr(n){var e=ze(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 EL="https://www.omg.org/spec/DMN/20191111/FEEL/";function f1(n){for(let e=n;e;e=e.$parent){let t=e.get("expressionLanguage");if(t)return!!(t===EL||/feel/i.test(t));if(O(e,"dmn:FunctionDefinition"))return(e.get("kind")||"FEEL")==="FEEL"}return!0}var Ku=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 We(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 ce(n,e){e&&(n.super_=e,n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}))}var SL=/^class[ {]/;function OL(n){return SL.test(n.toString())}function fv(n){return Array.isArray(n)}function uv(n,e){return Object.prototype.hasOwnProperty.call(n,e)}function Jd(...n){n.length===1&&fv(n[0])&&(n=n[0]),n=[...n];let e=n.pop();return e.$inject=n,e}var kL=/constructor\s*[^(]*\(\s*([^)]*)\)/m,RL=/^(?:async\s+)?(?:function\s*[^(]*)?(?:\(\s*([^)]*)\)|(\w+))/m,TL=/\/\*([^*]*)\*\//m;function AL(n){if(typeof n!="function")throw new Error(`Cannot annotate "${n}". Expected a function!`);let e=n.toString().match(OL(n)?kL:RL);if(!e)return[];let t=e[1]||e[2];return t&&t.split(",").map(i=>{let r=i.match(TL);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 _=v.split("."),E=l(_.shift());for(;_.length;)E=E[_.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=Jd(v.slice());else throw a(`Cannot invoke "${v}". Expected a function!`);let E=(v.$inject||AL(v)).map(S=>uv(x,S)?x[S]:l(S));return{fn:v,dependencies:E}}function u(v){let{fn:x,dependencies:_}=c(v),E=Function.prototype.bind.call(x,null,..._);return new E}function f(v,x,_){let{fn:E,dependencies:S}=c(v,_);return E.apply(x,S)}function h(v){return Jd(x=>v.get(x))}function d(v,x){if(x&&x.length){let _=Object.create(null),E=Object.create(null),S=[],C=[],R=[],A,D,I,N;for(let H in r)A=r[H],x.indexOf(H)!==-1&&(A[2]==="private"?(D=S.indexOf(A[3]),D===-1?(I=A[3].createChild([],x),N=h(I),S.push(A[3]),C.push(I),R.push(N),_[H]=[N,H,"private",I]):_[H]=[R[D],H,"private",C[D]]):_[H]=[A[2],A[1]],E[H]=!0),(A[2]==="factory"||A[2]==="type")&&A[1].$scope&&x.forEach(ke=>{A[1].$scope.indexOf(ke)!==-1&&(_[H]=[A[2],A[1]],E[ke]=!0)});x.forEach(H=>{if(!E[H])throw new Error('No provider for "'+H+'". Cannot use provider from the parent!')}),v.unshift(_)}return new os(v,s)}let p={factory:f,type:u,value:function(v){return v}};function m(v,x){let _=v.__init__||[];return function(){_.forEach(E=>{typeof E=="string"?x.get(E):x.invoke(E)})}}function g(v){let x=v.__exports__;if(x){let _=v.__modules__,E=Object.keys(v).reduce((D,I)=>(I!=="__exports__"&&I!=="__modules__"&&I!=="__init__"&&I!=="__depends__"&&(D[I]=v[I]),D),Object.create(null)),S=(_||[]).concat(E),C=d(S),R=Jd(function(D){return C.get(D)});x.forEach(function(D){r[D]=[R,D,"private",C]});let A=(v.__init__||[]).slice();return A.unshift(function(){C.init()}),v=Object.assign({},v,{__init__:A}),m(v,C)}return Object.keys(v).forEach(function(_){if(_==="__init__"||_==="__depends__")return;let E=v[_];if(E[2]==="private"){r[_]=E;return}let S=E[0],C=E[1];r[_]=[p[S],ML(S,C),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 w(v){let x=v.reduce(b,[]).map(g),_=!1;return function(){_||(_=!0,x.forEach(E=>E()))}}this.get=l,this.invoke=f,this.instantiate=u,this.createChild=d,this.init=w(n)}function ML(n,e){return n!=="value"&&fv(e)&&(e=Jd(e.slice())),e}var PL=1e3;function pn(n,e){var t=this;e=e||PL,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)})}pn.prototype.canRender=function(n){};pn.prototype.drawShape=function(n,e){};pn.prototype.drawConnection=function(n,e){};pn.prototype.getShapePath=function(n){};pn.prototype.getConnectionPath=function(n){};function DL(n,e){if(n.ownerDocument!==e.ownerDocument)try{return e.ownerDocument.importNode(n,!0)}catch{}return n}function m1(n,e){return e.appendChild(DL(n,e))}function K(n,e){return m1(e,n),n}var pv=2,g1={"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 IL(n,e){return g1[e]?n.style[e]:n.getAttributeNS(null,e)}function y1(n,e,t){var i=e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),r=g1[i];r?(r===pv&&typeof t=="number"&&(t=String(t)+"px"),n.style[i]=t):n.setAttributeNS(null,e,t)}function LL(n,e){var t=Object.keys(e),i,r;for(i=0,r;r=t[i];i++)y1(n,r,e[r])}function j(n,e,t){if(typeof e=="string")if(t!==void 0)y1(n,e,t);else return IL(n,e);else LL(n,e);return n}var BL=Object.prototype.toString;function ie(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 BL.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=NL(n);if(!e)return t;for(var i=document.createDocumentFragment(),r=t.firstChild;r.firstChild;)i.appendChild(r.firstChild);return i}function NL(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=v1(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 d1(n,e){var t,i,r=Object.keys(e);for(t=0;i=r[t];t++)n[i]=e[i];return n}function x1(n,e,t,i,r,o){var s=mv().createSVGMatrix();switch(arguments.length){case 0:return s;case 1:return d1(s,n);case 6:return d1(s,{a:n,b:e,c:t,d:i,e:r,f:o})}}function ha(n){return n?mv().createSVGTransformFromMatrix(n):mv().createSVGTransform()}var p1=/([&<>]{1})/g,$L=/([&<>\n\r"]{1})/g,jL={"&":"&","<":"<",">":">",'"':"'"};function dv(n,e){function t(i,r){return jL[r]||r}return n.replace(e,t)}function b1(n,e){var t,i,r,o,s;switch(n.nodeType){case 3:e.push(dv(n.textContent,p1));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 FL(n,e){var t=v1(e);if(ss(n),!!e){VL(t)||(t=t.documentElement);for(var i=HL(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 k1(n,e){var t={};return k(n,function(i){var r=i;r.waypoints&&(r=kt(r)),!oe(e.y)&&r.x>e.x&&(t[i.id]=i),!oe(e.x)&&r.y>e.y&&(t[i.id]=i),r.x>e.x&&r.y>e.y&&(oe(e.width)&&oe(e.height)&&r.width+r.x=1e3&&delete r[o.shift()],o.push(i),r[i]=n(...arguments),r[i])}return e}function oB(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(eB,function(i,r,o){var s=[],a=r.toLowerCase();for(o.replace(tB,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=Ev,t}function sB(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 cB(n,e){return n=Cv(n),e=Cv(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;pIi(r,s)||Ii(e,i)Ii(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=ap(l/u),h=ap(c/u),d=+f.toFixed(2),p=+h.toFixed(2);if(!(d<+Di(n,t).toFixed(2)||d>+Ii(n,t).toFixed(2)||d<+Di(r,s).toFixed(2)||d>+Ii(r,s).toFixed(2)||p<+Di(e,i).toFixed(2)||p>+Ii(e,i).toFixed(2)||p<+Di(o,a).toFixed(2)||p>+Ii(o,a).toFixed(2)))return{x:f,y:h}}}}function ap(n){return Math.round(n*1e11)/1e11}function fB(n,e,t){var i=D1(n),r=D1(e);if(!cB(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&&C<=1&&R>=0&&R<=1&&(t?h++:h.push({x:E.x,y:E.y,t1:C,t2:R}))}}return h}function Yu(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=at.sqrt(b),t=b*t,i=b*i);var w=t*t,v=i*i,x=(o==s?-1:1)*at.sqrt(ao((w*v-w*g*g-v*m*m)/(w*g*g+v*m*m))),_=x*t*g/i+(n+a)/2,E=x*-i*m/t+(e+l)/2,S=at.asin(((e-E)/i).toFixed(9)),C=at.asin(((l-E)/i).toFixed(9));S=n<_?oo-S:S,C=a<_?oo-C:C,S<0&&(S=oo*2+S),C<0&&(C=oo*2+C),s&&S>C&&(S=S-oo*2),!s&&C>S&&(C=C-oo*2)}var R=C-S;if(ao(R)>u){var A=C,D=a,I=l;C=S+u*(s&&C>S?1:-1),a=_+t*at.cos(C),l=E+i*at.sin(C),h=j1(a,l,t,i,r,0,s,D,I,[C,A,_,E])}R=C-S;var N=at.cos(S),H=at.sin(S),ke=at.cos(C),be=at.sin(C),ue=at.tan(R/4),wn=4/3*t*ue,Ft=4/3*i*ue,dt=[n,e],vt=[n+wn*H,e-Ft*N],_t=[a+wn*be,l-Ft*ke],Lt=[a,l];if(vt[0]=2*dt[0]-vt[0],vt[1]=2*dt[1]-vt[1],c)return[vt,_t,Lt].concat(h);h=[vt,_t,Lt].concat(h).join().split(",");for(var un=[],ot=0,Ri=h.length;ot7){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 Zu(n,e,t){var i=yB(n,e);return i.length===1||i.length===2&&da(i[0],i[1])<1?pa(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}),pa(i[t?0:i.length-1])):null}function yB(n,e){return Yu(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],da(t,r)===0||op(i,r,t)?n.splice(e,1):e++;return n}function vB(n,e){return Math.sqrt(Math.pow(n.x-e.x,2)+Math.pow(n.y-e.y,2))}function lp(n,e){return Math.round(n*e)/e}function V1(n){return oe(n)?n+"px":n}function xB(n){for(;n.parent;)n=n.parent;return n}function bB(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");ie(i).add(e);let r=t!==void 0?t:n.childNodes.length-1;return n.insertBefore(i,n.childNodes[r]||null),i}var _B="base",z1=0,wB=1,CB={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=bB(n),i=this._svg=Q("svg");j(i,{width:"100%",height:"100%"}),Xe(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=Ai(it(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=np(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(_B,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 nt(this._layers,function(e,t){return t.visible&&n>=t.index&&e++,e},0)};Y.prototype._createLayer=function(n,e){typeof e=="undefined"&&(e=wB);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&&(Ne(t),e.visible=!1),t};Y.prototype._removeLayer=function(n){let e=this._layers[n];e&&(delete this._layers[n],Ne(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(xB(n))||{}).rootElement:void 0};Y.prototype.getRootElements=function(){return this._planes.map(function(n){return n.rootElement})};Y.prototype._findPlaneForRoot=function(n){return me(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),ie(r).add(e)):(n.markers.delete(e),ie(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=CB[n];if(!St(t,function(r){return typeof e[r]!="undefined"}))throw new Error("must supply { "+t.join(", ")+" } with "+n)};Y.prototype._setParent=function(n,e,t){Ht(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:x1(),a=lp(r.a,1e3),l=lp(-r.e||0,1e3),c=lp(-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=kt(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 ma="data-element-id";function en(n){this._elements={},this._eventBus=n}en.$inject=["eventBus"];en.prototype.add=function(n,e,t){var i=n.id;this._validateId(i),j(e,ma,i),t&&j(t,ma,i),this._elements[i]={element:n,gfx:e,secondaryGfx:t}};en.prototype.remove=function(n){var e=this._elements,t=n.id||n,i=t&&e[t];i&&(j(i.gfx,ma,""),i.secondaryGfx&&j(i.secondaryGfx,ma,""),delete e[t])};en.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)};en.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,ma,i),e};en.prototype.get=function(n){var e;typeof n=="string"?e=n:e=n&&j(n,ma);var t=this._elements[e];return t&&t.element};en.prototype.filter=function(n){var e=[];return this.forEach(function(t,i){n(t,i)&&e.push(t)}),e};en.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):kB(this,e,n)};tn.prototype.ensureRefsCollection=function(n,e){var t=n[e.name];return SB(t)||U1(this,e,n),t};tn.prototype.ensureBound=function(n,e){OB(n,e)||this.bind(n,e)};tn.prototype.unset=function(n,e,t){n&&(this.ensureBound(n,e),e.collection?this.ensureRefsCollection(n,e).remove(t):n[e.name]=void 0)};tn.prototype.set=function(n,e,t){n&&(this.ensureBound(n,e),e.collection?this.ensureRefsCollection(n,e).add(t):n[e.name]=t)};var Ov=new tn({name:"children",enumerable:!0,collection:!0},{name:"parent"}),K1=new tn({name:"labels",enumerable:!0,collection:!0},{name:"labelTarget"}),Q1=new tn({name:"attachers",collection:!0},{name:"host"}),G1=new tn({name:"outgoing",collection:!0},{name:"source"}),X1=new tn({name:"incoming",collection:!0},{name:"target"});function ga(){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)}}),Ov.bind(this,"parent"),K1.bind(this,"labels"),G1.bind(this,"outgoing"),X1.bind(this,"incoming")}function Ju(){ga.call(this),Ov.bind(this,"children"),Q1.bind(this,"host"),Q1.bind(this,"attachers")}ce(Ju,ga);function Y1(){ga.call(this),Ov.bind(this,"children")}ce(Y1,Ju);function Z1(){Ju.call(this),K1.bind(this,"labelTarget")}ce(Z1,Ju);function J1(){ga.call(this),G1.bind(this,"source"),X1.bind(this,"target")}ce(J1,ga);var RB={connection:J1,shape:Ju,label:Z1,root:Y1};function eC(n,e){var t=RB[n];if(!t)throw new Error("unknown type: <"+n+">");return T(new t,e)}function tC(n){return n instanceof ga}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=ha();o.setTranslate(e,t);var s=ha();s.setRotate(i||0,0,0);var a=ha();a.setScale(r||1,r||1),as(n,[o,s,a])}function Nt(n,e,t){var i=ha();i.setTranslate(e,t),as(n,i)}function rC(n,e){var t=ha();t.setRotate(e,0,0),as(n,t)}function nn(n,e){this._eventBus=n,this._elementRegistry=e}nn.$inject=["eventBus","elementRegistry"];nn.prototype._getChildrenContainer=function(n){var e=this._elementRegistry.getGraphics(n),t;return n.parent?(t=nC(e),t||(t=Q("g"),ie(t).add("djs-children"),K(e.parentNode,t))):t=e,t};nn.prototype._clear=function(n){var e=ls(n);return to(e),e};nn.prototype._createContainer=function(n,e,t,i){var r=Q("g");ie(r).add("djs-group"),typeof t!="undefined"?oC(r,e,e.childNodes[t]):K(e,r);var o=Q("g");ie(o).add("djs-element"),ie(o).add("djs-"+n),i&&ie(o).add("djs-frame"),K(r,o);var s=Q("g");return ie(s).add("djs-visual"),K(o,s),o};nn.prototype.create=function(n,e,t){var i=this._getChildrenContainer(e.parent);return this._createContainer(n,i,t,ip(e))};nn.prototype.updateContainments=function(n){var e=this,t=this._elementRegistry,i;i=nt(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)})}})};nn.prototype.drawShape=function(n,e,t={}){var i=this._eventBus;return i.fire("render.shape",{gfx:n,element:e,attrs:t})};nn.prototype.getShapePath=function(n){var e=this._eventBus;return e.fire("render.getShapePath",n)};nn.prototype.drawConnection=function(n,e,t={}){var i=this._eventBus;return i.fire("render.connection",{gfx:n,element:e,attrs:t})};nn.prototype.getConnectionPath=function(n){var e=this._eventBus;return e.fire("render.getConnectionPath",n)};nn.prototype.update=function(n,e,t){if(e.parent){var i=this._clear(t);if(n==="shape")this.drawShape(i,e),Nt(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")}};nn.prototype.remove=function(n){var e=this._elementRegistry.getGraphics(n);Ne(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",en],elementFactory:["type",Hn],eventBus:["type",st],graphicsFactory:["type",nn]};function TB(n){var e=new os(n);return e.init(),e}function AB(n){n=n||{};var e={config:["value",n]},t=[e,sC].concat(n.modules||[]);return TB(t)}function dr(n,e){this._injector=e||AB(n),this.get("eventBus").fire("diagram.init")}dr.prototype.get=function(n,e){return this._injector.get(n,e)};dr.prototype.invoke=function(n,e,t){return this._injector.invoke(n,e,t)};dr.prototype.destroy=function(){this.get("eventBus").fire("diagram.destroy")};dr.prototype.clear=function(){this.get("eventBus").fire("diagram.clear")};var MB=new tn({name:"dmnElementRef",enumerable:!0},{name:"di",configurable:!0});function kv(n,e){var t=[];function i(b){var w=b.gfx;if(w)throw new Error("already rendered "+b.id);return n.element(b)}function r(b){return n.root(b)}function o(b){try{var w=b.di&&i(b);return w}catch(v){g(v.message,{element:b,error:v})}}function s(b,w){var v=b.dmnDI;if(!v)throw new Error("no dmndi:DMNDI");var x=v.diagrams||[];if(w&&x.indexOf(w)===-1)throw new Error("diagram not part of dmndi:DMNDI");if(!w&&x&&x.length&&(w=x[0]),!w)throw new Error("no diagram to display");b.di=w,f(w),r(b),a(b.get("drgElement")),l(b.get("artifact")),m()}function a(b){k(b,function(w){o(w),u(w)})}function l(b){k(b,function(w){O(w,"dmn:Association")?c(w):o(w)})}function c(b){p(function(){o(b)})}function u(b){k(["informationRequirement","knowledgeRequirement","authorityRequirement"],function(w){k(b[w],function(v){p(function(){o(v)})})})}function f(b){k(b.diagramElements,h)}function h(b){d(b)}function d(b){var w=b.dmnElementRef;w?w.di?g("multiple DI elements defined for element",{element:w}):(MB.bind(w,"di"),w.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,w){n.error(b,w)}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 kv(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 Iv="$NO_OP",PB="a runtime error occured! Use Inferno in development environment to find the error.",hp=Array.isArray;function Lv(n){var e=typeof n;return e==="string"||e==="number"}function ve(n){return dp(n)||Qe(n)}function lo(n){return Qe(n)||n===!1||DB(n)||dp(n)}function ge(n){return typeof n=="function"}function ya(n){return typeof n=="string"}function Mv(n){return typeof n=="number"}function Qe(n){return n===null}function DB(n){return n===!0}function dp(n){return n===void 0}function IB(n){throw n||(n=PB),new Error("Inferno Error: "+n)}function nf(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 ef="$";function Bv(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=Bv(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&&ge(e.prototype.render)?4:8);var o=e.defaultProps;if(!ve(o)){t||(t={});for(var s in o)dp(t[s])&&(t[s]=o[s])}if((n&8)>0){var a=e.defaultHooks;if(!ve(a))if(!r)r=a;else for(var l in a)dp(r[l])&&(r[l]=a[l])}var c=Bv(1,null,null,n,i,t,r,e),u=Wn.createVNode;return ge(u)&&u(c),c}function Z(n,e){return Bv(1,ve(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&&ve(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=nf(n.ref,e.ref):n.ref=e.ref,e.ref=void 0)}return n}function zt(n){var e,t=n.flags;if(t&14){var i,r=n.props;if(!Qe(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&&YB(e,i,t));for(var a in t)Pv(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===Rt&&(r.props=t),r.$UN=!1,ge(r.componentWillMount)){if(r.$BR=!0,r.componentWillMount(),r.$PSS){var o=r.state,s=r.$PS;if(Qe(o))r.state=s;else for(var a in s)o[a]=s[a];r.$PSS=!1,r.$PS=null}r.$BR=!1}ge(Wn.beforeRender)&&Wn.beforeRender(r);var l=sf(r.render(t,r.state,i),n),c;return ge(r.getChildContext)&&(c=r.getChildContext()),ve(c)?r.$CX=i:r.$CX=nf(i,c),ge(Wn.afterRender)&&Wn.afterRender(r),r.$LI=l,r}function sf(n,e){return lo(n)?n=pC():Lv(n)?n=Z(n,null):(n.dom&&(n=zt(n)),n.flags&14&&(n.parentVNode=e)),n}function rn(n,e,t,i){var r=n.flags;if(r&481)return kC(n,e,t,i);if(r&14)return tN(n,e,t,i,(r&4)>0);if(r&512||r&16)return Dv(n,e);if(r&1024)return rn(n.children,n.type,t,!1),n.dom=Dv(pC(),e)}function Dv(n,e){var t=n.dom=document.createTextNode(n.children);return Qe(e)||pp(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=BB(n.type,i);if(n.dom=u,!ve(a)&&a!==""&&(i?u.setAttribute("class",a):u.className=a),Qe(e)||pp(e,u),(c&1)===0){var f=i===!0&&n.type!=="foreignObject";c===2?rn(o,u,t,f):c&12&&tf(o,u,t,f)}return Qe(s)||SC(n,r,s,u,i),ge(l)&&Vv(u,l),u}function tf(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,Nv(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)Qe(u)?rn(r,e,t,i):(h=u.nextSibling,rf(r,u,t,i),u=h);else if(f&12)for(var d=0,p=r.length;d0):r&481?oN(n,e,t,i):r&16?sN(n,e):r&512?n.dom=e:IB()}function aN(n,e,t){var i=e.firstChild;if(!Qe(i))for(lo(n)||rf(n,i,Rt,!1),i=e.firstChild;i=i.nextSibling;)e.removeChild(i);Bi.length>0&&$v(Bi),e.$V=n,ge(t)&&t()}function Hv(n,e,t,i,r){us(n),Nv(t,rn(e,null,i,r),n.dom)}function pr(n,e,t,i,r){var o=e.flags|0;n.flags!==o||o&2048?Hv(n,e,t,i,r):o&481?uN(n,e,t,i,r,o):o&14?fN(n,e,t,i,r,(o&4)>0):o&16?hN(n,e):o&512?e.dom=n.dom:cN(n,e,i)}function lN(n,e){n.textContent!==e.children&&(n.textContent=e.children)}function cN(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 uN(n,e,t,i,r,o){var s=e.type;if(n.type!==s)Hv(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||Rt;if(h=c||Rt,h!==Rt){u=(o&448)>0,u&&(f=EC(h));for(var p in h){var m=d[p],g=h[p];m!==g&&Pv(p,m,g,a,r,f,n)}}if(d!==Rt)for(var b in d)!h.hasOwnProperty(b)&&!ve(d[b])&&Pv(b,d[b],null,a,r,f,n)}var w=n.children,v=e.children,x=e.ref,_=n.className,E=e.className;o&4096?lN(a,v):AC(n.childFlags,e.childFlags,w,v,a,i,r&&s!=="foreignObject"),u&&CC(o,e,a,h,!1,f),_!==E&&(ve(E)?a.removeAttribute("class"):r?a.setAttribute("class",E):a.className=E),ge(x)&&n.ref!==x&&Vv(a,x)}}function AC(n,e,t,i,r,o,s){switch(n){case 2:switch(e){case 2:pr(t,i,r,o,s);break;case 1:zn(t,r);break;default:zn(t,r),tf(i,r,o,s);break}break;case 1:switch(e){case 2:rn(i,r,o,s);break;case 1:break;default:tf(i,r,o,s);break}break;default:if(e&12){var a=t.length,l=i.length;a===0?l>0&&tf(i,r,o,s):l===0?fp(r,t):e===8&&n===8?pN(t,i,r,o,s,a,l):dN(t,i,r,o,s,a,l)}else e===1?fp(r,t):e===2&&(fp(r,t),rn(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===Rt){if(!l&&ge(n.componentWillReceiveProps)){if(n.$BR=!0,n.componentWillReceiveProps(i,o),n.$UN)return;n.$BR=!1}n.$PSS&&(e=nf(e,n.$PS),n.$PSS=!1,n.$PS=null)}var h=!!n.shouldComponentUpdate;if(a||!h||h&&n.shouldComponentUpdate(i,e,o)){ge(n.componentWillUpdate)&&(n.$BS=!0,n.componentWillUpdate(i,e,o),n.$BS=!1),n.props=i,n.state=e,n.context=o,ge(Wn.beforeRender)&&Wn.beforeRender(n),f=n.render(i,e,o),ge(Wn.afterRender)&&Wn.afterRender(n);var d=f!==Iv,p;if(ge(n.getChildContext)&&(p=n.getChildContext()),ve(p)?p=o:p=nf(o,p),n.$CX=p,d){var m=n.$LI,g=sf(f,t);pr(m,g,r,p,s),n.$LI=g,ge(n.componentDidUpdate)&&n.componentDidUpdate(u,c)}}else n.props=i,n.state=e,n.context=o;t.dom=n.$LI.dom}}function fN(n,e,t,i,r,o){var s=e.type,a=n.key,l=e.key;if(n.type!==s||a!==l)Hv(n,e,t,i,r);else{var c=e.props||Rt;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=!ve(d),m=n.children;if(e.dom=n.dom,e.children=m,p&&ge(d.onComponentShouldUpdate)&&(f=d.onComponentShouldUpdate(h,c)),f!==!1){p&&ge(d.onComponentWillUpdate)&&d.onComponentWillUpdate(h,c);var g=s(c,i);g!==Iv&&(g=sf(g,e),pr(m,g,t,i,r),e.children=g,e.dom=g.dom,p&&ge(d.onComponentDidUpdate)&&d.onComponentDidUpdate(h,c))}else m.flags&14&&(m.parentVNode=e)}}}function hN(n,e){var t=e.children,i=n.dom;t!==n.children&&(i.nodeValue=t),e.dom=i}function dN(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=zt(h)),pr(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,w=l-u+1,v=[];for(c=0;cm;)zn(n[m++],t);E>u?_=!0:E=u,h.dom&&(e[u]=h=zt(h)),pr(f,h,t,i,r),S++;break}!x&&u>l&&zn(f,t)}else x||zn(f,t);else{var C={};for(c=g;c<=l;c++)C[e[c].key]=c;for(c=m;c<=a;c++)if(f=n[c],Sm;)zn(n[m++],t);h=e[u],v[u-g]=c+1,E>u?_=!0:E=u,h.dom&&(e[u]=h=zt(h)),pr(f,h,t,i,r),S++}else x||zn(f,t);else x||zn(f,t)}if(x)fp(t,n),tf(e,t,i,r);else if(_){var R=mN(v);for(u=R.length-1,c=w-1;c>=0;c--)v[c]===0?(E=c+g,h=e[E],h.dom&&(e[E]=h=zt(h)),d=E+1,cp(t,rn(h,null,i,r),d=0;c--)v[c]===0&&(E=c+g,h=e[E],h.dom&&(e[E]=h=zt(h)),d=E+1,cp(t,rn(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 va(n,e,t){if(n!==Iv){var i=e.$V;if(ve(i)?lo(n)||(n.dom&&(n=zt(n)),Qe(e.firstChild)?(rn(n,e,Rt,!1),e.$V=n):aN(n,e),i=n):ve(n)?(zn(i,e),e.$V=null):(n.dom&&(n=zt(n)),pr(i,n,e,Rt,!1),i=e.$V=n),Bi.length>0&&$v(Bi),ge(t)&&t(),ge(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(),gN=typeof requestAnimationFrame=="undefined"?setTimeout:requestAnimationFrame.bind(window);function yN(n){return hC?hC.then(n):gN(n)}function dC(n,e,t,i){ge(e)&&(e=e(n.state,n.props,n.context));var r=n.$PS;if(ve(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;Qe(s)&&(s=n.$QU=[],yN(vN(n,s))),ge(t)&&s.push(t)}else n.$PSS=!0,n.$BR&&ge(t)&&Bi.push(t.bind(n))}function vN(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;!Qe(l=l.parentVNode);)(l.flags&14)>0&&(l.dom=f);Bi.length>0&&$v(Bi)}else n.state=n.$PS,n.$PS=null;ge(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||Rt,this.context=i||Rt}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 zv(n){var e=''+IC+"",t=te(e);n.appendChild(t),q.bind(t,"click",function(i){CN(),i.preventDefault()})}var co=class extends L{constructor(e,t){super(e,t),this.node=null}componentDidMount(){zv(this.node)}render(){return y(1,"div",null,null,1,null,null,e=>this.node=e)}};function Wv(n){return n.join(";")}var xN=Wv(["z-index: 1001","position: fixed","top: 0","left: 0","right: 0","bottom: 0"]),bN=Wv(["width: 100%","height: 100%","background: rgba(40,40,40,0.2)"]),_N=Wv(["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"]),wN='
'+IC+'Web-based tooling for BPMN, DMN and CMMN diagrams powered by bpmn.io.
',af;function CN(){af||(af=te(wN),xt.bind(af,".backdrop","click",function(n){document.body.removeChild(af)})),document.body.appendChild(af)}var EN=new qn,mp="hsl(225, 10%, 15%)";function lf(n,e,t,i,r,o){pn.call(this,e);var s=EN.next(),a=i.computeStyle,l={},c=n&&n.defaultFillColor||"white",u=n&&n.defaultStrokeColor||mp,f=n&&n.defaultLabelColor;function h(S,C,R){var A=S+"-"+BC(C)+"-"+BC(R)+"-"+s;return l[A]||p(A,S,C,R),"url(#"+A+")"}function d(S,C){var R=T({strokeWidth:1,strokeLinecap:"round",strokeDasharray:"none"},C.attrs),A=C.ref||{x:0,y:0},D=C.scale||1;R.strokeDasharray==="none"&&(R.strokeDasharray=[1e4,1]);var I=Q("marker");j(C.element,R),K(I,C.element),j(I,{id:S,viewBox:"0 0 20 20",refX:A.x,refY:A.y,markerWidth:20*D,markerHeight:20*D,orient:"auto"});var N=X("defs",o._svg);N||(N=Q("defs"),K(o._svg,N)),K(N,I),l[S]=I}function p(S,C,R,A){if(C==="association-start"){var D=Q("path");j(D,{d:"M 11 5 L 1 10 L 11 15"}),d(S,{element:D,attrs:{fill:"none",stroke:A,strokeWidth:1.5},ref:{x:1,y:10},scale:.5})}else if(C==="association-end"){var I=Q("path");j(I,{d:"M 1 5 L 11 10 L 1 15"}),d(S,{element:I,attrs:{fill:"none",stroke:A,strokeWidth:1.5},ref:{x:12,y:10},scale:.5})}else if(C==="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(C==="knowledge-requirement-end"){var H=Q("path");j(H,{d:"M 1 3 L 11 10 L 1 17"}),d(S,{element:H,attrs:{fill:"none",stroke:A,strokeWidth:2},ref:{x:11,y:10},scale:.8})}else if(C==="authority-requirement-end"){var ke=Q("circle");j(ke,{cx:3,cy:3,r:3}),d(S,{element:ke,attrs:{fill:A,stroke:"none"},ref:{x:3,y:3},scale:.9})}}function m(S,C,R,A,D,I){Ae(D)&&(I=D,D=0),D=D||0,I=a(I,{stroke:mp,strokeWidth:2,fill:"white"});var N=Q("rect");return j(N,{x:D,y:D,width:C-D*2,height:R-D*2,rx:A,ry:A}),j(N,I),K(S,N),N}function g(S,C,R){var A=r.createText(C||"",R);return Xe(A,"class","djs-label"),K(S,A),A}function b(S,C,R,A){var D=u1(C);return A=T({box:C,align:R,padding:5,style:{fill:NC(C,f,u)}},A),g(S,D,A)}function w(S,C,R){R=a(R,["no-fill"],{strokeWidth:2,stroke:mp});var A=Q("path");return j(A,{d:C}),j(A,R),K(S,A),A}var v={"dmn:Decision":function(S,C){var R=m(S,C.width,C.height,0,{stroke:Ni(C,u),fill:uo(C,c)});return b(S,C,"center-middle"),R},"dmn:KnowledgeSource":function(S,C){var R=t.getScaledPath("KNOWLEDGE_SOURCE",{xScaleFactor:1.021,yScaleFactor:1,containerWidth:C.width,containerHeight:C.height,position:{mx:0,my:.075}}),A=w(S,R,{strokeWidth:2,fill:uo(C,c),stroke:Ni(C,u)});return b(S,C,"center-middle"),A},"dmn:BusinessKnowledgeModel":function(S,C){var R=t.getScaledPath("BUSINESS_KNOWLEDGE_MODEL",{xScaleFactor:1,yScaleFactor:1,containerWidth:C.width,containerHeight:C.height,position:{mx:0,my:.3}}),A=w(S,R,{strokeWidth:2,fill:uo(C,c),stroke:Ni(C,u)});return b(S,C,"center-middle"),A},"dmn:InputData":function(S,C){var R=m(S,C.width,C.height,22,{stroke:Ni(C,u),fill:uo(C,c)});return b(S,C,"center-middle"),R},"dmn:TextAnnotation":function(S,C){var R={fill:"none",stroke:"none"},A=m(S,C.width,C.height,0,0,R),D=t.getScaledPath("TEXT_ANNOTATION",{xScaleFactor:1,yScaleFactor:1,containerWidth:C.width,containerHeight:C.height,position:{mx:0,my:0}});w(S,D,{stroke:Ni(C,u)});var I=LC(C).text||"";return g(S,I,{style:{fill:NC(C,f,u)},box:C,align:"left-top",padding:5}),A},"dmn:Association":function(S,C){var R=LC(C),A=uo(C,c),D=Ni(C,u),I={stroke:D,strokeDasharray:"0.5, 5",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"};return(R.associationDirection==="One"||R.associationDirection==="Both")&&(I.markerEnd=h("association-end",A,D)),R.associationDirection==="Both"&&(I.markerStart=h("association-start",A,D)),E(S,C.waypoints,I)},"dmn:InformationRequirement":function(S,C){var R=uo(C,c),A=Ni(C,u),D={stroke:A,strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round",markerEnd:h("information-requirement-end",R,A)};return E(S,C.waypoints,D)},"dmn:KnowledgeRequirement":function(S,C){var R=uo(C,c),A=Ni(C,u),D={stroke:A,strokeWidth:1,strokeDasharray:5,strokeLinecap:"round",strokeLinejoin:"round",markerEnd:h("knowledge-requirement-end",R,A)};return E(S,C.waypoints,D)},"dmn:AuthorityRequirement":function(S,C){var R=uo(C,c),A=Ni(C,u),D={stroke:A,strokeWidth:1.5,strokeDasharray:5,strokeLinecap:"round",strokeLinejoin:"round",markerEnd:h("authority-requirement-end",R,A)};return E(S,C.waypoints,D)}};function x(S,C){var R=v[C.type];return R?R(S,C):pn.prototype.drawShape.apply(this,[S,C])}function _(S,C){var R=C.type,A=v[R];return A?A(S,C):pn.prototype.drawConnection.apply(this,[S,C])}function E(S,C,R){R=a(R,["no-fill"],{stroke:mp,strokeWidth:2,fill:"none"});var A=ro(C,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=_}ce(lf,pn);lf.$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 Ni(n,e){return e}function uo(n,e){return e}function NC(n,e,t){return e||Ni(n,t)}var SN=0,ON={width:150,height:50};function kN(n){var e=n.split("-");return{horizontal:e[0]||"center",vertical:e[1]||"top"}}function RN(n){return Ae(n)?T({top:0,left:0,right:0,bottom:0},n):{top:n,left:n,right:n,bottom:n}}var Uv=null;function TN(){return Uv||(Uv=document.createElement("canvas").getContext("2d")),Uv}function AN(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 MN(n,e){var t=TN();if(!t)return{width:0,height:0};t.font=AN(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 PN(n,e,t){for(var i=n.shift(),r=i,o;;){if(o=MN(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 w=Q("tspan");j(w,{x:b,y:d}),w.textContent=g.text,K(p,w)});var m={width:h,height:f};return{dimensions:m,element:p}};function BN(n){if("fontSize"in n&&"lineHeight"in n)return n.lineHeight*parseInt(n.fontSize,10)}var NN=12,$N=1.2,jN=30;function gp(n){var e=T({fontFamily:"Arial, sans-serif",fontSize:NN,fontWeight:"normal",lineHeight:$N},n&&n.defaultStyle||{}),t=parseInt(e.fontSize,10)-1,i=T({},e,{fontSize:t},n&&n.externalStyle||{}),r=new xa({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(jN,Math.round(a.height))}},this.createText=function(o,s){return r.createText(o,s||{})},this.getDefaultStyle=function(){return e},this.getExternalStyle=function(){return i}}gp.$inject=["config.textRenderer"];function Qv(){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(D,R,A)}var f="svg, .djs-element";function h(C,R,A,D){var I=o[A]=function(N){r(A,N)};D&&(c[A]=D),I.$delegate=xt.bind(C,f,R,I)}function d(C,R,A){var D=s(A);D&&xt.unbind(C,R,D.$delegate)}function p(C){k(l,function(R,A){h(C,A,R)})}function m(C){k(l,function(R,A){d(C,A,R)})}n.on("canvas.destroy",function(C){m(C.svg)}),n.on("canvas.init",function(C){p(C.svg)}),n.on(["shape.added","connection.added"],function(C){var R=C.element,A=C.gfx;n.fire("interactionEvents.createHit",{element:R,gfx:A})}),n.on(["shape.changed","connection.changed"],QC,function(C){var R=C.element,A=C.gfx;n.fire("interactionEvents.updateHit",{element:R,gfx:A})}),n.on("interactionEvents.createHit",QC,function(C){var R=C.element,A=C.gfx;i.createDefaultHit(R,A)}),n.on("interactionEvents.updateHit",function(C){var R=C.element,A=C.gfx;i.updateDefaultHit(R,A)});var g=_("djs-hit djs-hit-stroke"),b=_("djs-hit djs-hit-click-stroke"),w=_("djs-hit djs-hit-all"),v=_("djs-hit djs-hit-no-move"),x={all:w,"click-stroke":b,stroke:g,"no-move":v};function _(C,R){return R=T({stroke:"white",strokeWidth:15},R||{}),t.cls(C,["no-fill","no-border"],R)}function E(C,R){var A=x[R];if(!A)throw new Error("invalid hit type <"+R+">");return j(C,A),C}function S(C,R){K(C,R)}this.removeHits=function(C){var R=dn(".djs-hit",C);k(R,Ne)},this.createDefaultHit=function(C,R){var A=C.waypoints,D=C.isFrame,I;return A?this.createWaypointsHit(R,A):(I=D?"stroke":"all",this.createBoxHit(R,I,{width:C.width,height:C.height}))},this.createWaypointsHit=function(C,R){var A=ro(R);return E(A,"stroke"),S(C,A),A},this.createBoxHit=function(C,R,A){A=T({x:0,y:0},A);var D=Q("rect");return E(D,R),j(D,A),S(C,D),D},this.updateDefaultHit=function(C,R){var A=X(".djs-hit",R);if(A)return C.waypoints?bv(A,C.waypoints):j(A,{width:C.width,height:C.height}),A},this.fire=r,this.triggerMouseEvent=u,this.mouseHandler=s,this.registerEvent=h,this.unregisterEvent=d}bp.$inject=["eventBus","elementRegistry","styles"];var fo={__init__:["interactionEvents"],interactionEvents:["type",bp]};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 _p(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)})})}_p.$inject=["canvas","eventBus"];function wp(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(UN))}}),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=me(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=uf(r);if(s&&a)return l?e.deselect(o):e.select(o);s?e.deselect(o):e.select(o,l)}})}wp.$inject=["eventBus","selection","canvas","elementRegistry"];function UN(n){return!n.hidden}var lt={__init__:["selectionVisuals","selectionBehavior"],__depends__:[fo],selection:["type",ho],selectionVisuals:["type",_p],selectionBehavior:["type",wp]};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 QN=new po("ov"),KN=500;function gt(n,e,t,i){this._eventBus=e,this._canvas=t,this._elementRegistry=i,this._ids=QN,this._overlayDefaults=T({show:null,scale:!0},n&&n.defaults),this._overlays={},this._overlayContainers=[],this._overlayRoot=GN(t.getContainer()),this._init()}gt.$inject=["config.overlays","eventBus","canvas","elementRegistry"];gt.prototype.get=function(n){if(Pe(n)&&(n={id:n}),Pe(n.element)&&(n.element=this._elementRegistry.get(n.element)),n.element){var e=this._getOverlayContainer(n.element,!0);return e?n.type?_e(e.overlays,aa({type:n.type})):e.overlays.slice():[]}else return n.type?_e(this._overlays,aa({type:n.type})):n.id?this._overlays[n.id]:null};gt.prototype.add=function(n,e,t){if(Ae(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};gt.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&&(He(i.html),He(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)}})};gt.prototype.isShown=function(){return this._overlayRoot.style.display!=="none"};gt.prototype.show=function(){Cp(this._overlayRoot)};gt.prototype.hide=function(){Cp(this._overlayRoot,!1)};gt.prototype.clear=function(){this._overlays={},this._overlayContainers=[],to(this._overlayRoot)};gt.prototype._updateOverlayContainer=function(n){var e=n.element,t=n.html,i=e.x,r=e.y;if(e.waypoints){var o=kt(e);i=o.x,r=o.y}XC(t,i,r),Xe(n.html,"data-container-id",e.id)};gt.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=kt(i).width:s=i.width,r=e.right*-1+s}if(e.bottom!==void 0){var a;i.waypoints?a=kt(i).height:a=i.height,o=e.bottom*-1+a}XC(t,r||0,o||0),this._updateOverlayVisibilty(n,this._canvas.viewbox())};gt.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};gt.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)};gt.prototype._getOverlayContainer=function(n,e){var t=me(this._overlayContainers,function(i){return i.element===n});return!t&&!e?this._createOverlayContainer(n):t};gt.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)),Pe(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();Cp(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())};gt.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&&(Te(r)&&r>e.scale||Te(o)&&or&&(s=(1/e.scale||1)*r)),Te(s)&&(a="scale("+s+","+s+")"),YC(o,a)};gt.prototype._updateOverlaysVisibilty=function(n){var e=this;k(this._overlays,function(t){e._updateOverlayVisibilty(t,n)})};gt.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){He(s.html);var a=e._overlayContainers.indexOf(s);a!==-1&&e._overlayContainers.splice(a,1)}}),n.on("element.changed",KN,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 GN(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 Cp(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",gt]};function ba(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='
'}ba.$inject=["eventBus","canvas","translate"];ba.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),xt.bind(i,".dmn-definitions-name, .dmn-definitions-id","mousedown",function(r){r.stopPropagation()}),e.fire("definitionIdView.create",{html:i})};ba.prototype.update=function(){var n=this._canvas.getRootElement().businessObject;this.nameElement.textContent=n.name,this.idElement.textContent=n.id};function _a(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)})}_a.$inject=["eventBus","canvas"];var wa={__depends__:[$e],__init__:["definitionPropertiesView","definitionPropertiesPaletteAdapter"],definitionPropertiesView:["type",ba],definitionPropertiesPaletteAdapter:["type",_a]};var ZC=[{className:"dmn-icon-decision-table",matches:function(n){var e=ze(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=fr(n);return O(e,"dmn:LiteralExpression")},title:"Open literal expression"}],Ca=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}};Ca.$inject=["injector","eventBus","overlays","config.drillDown","translate"];var JC={__depends__:[mo,$e],__init__:["drillDown"],drillDown:["type",Ca]};function wt(n){this._container=this._createContainer(),zv(this._container),this._init(this._container,n)}ce(wt,dr);wt.prototype.saveSVG=fa(function(n){var e=this;return new Promise(function(t){var i=e.get("canvas"),r=i.getActiveLayer(),o=X("defs",i._svg),s=_1(r),a=o&&o.outerHTML||"",l=r.getBBox(),c=` '+a+s+"";t({svg:c})})});wt.prototype.getModules=function(){return this._modules};wt.prototype.destroy=function(){dr.prototype.destroy.call(this),He(this._container)};wt.prototype.on=function(n,e,t,i){return this.get("eventBus").on(n,e,t,i)};wt.prototype.off=function(n,e){this.get("eventBus").off(n,e)};wt.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};dr.call(this,l),e&&e.container&&this.attachTo(e.container)};wt.prototype._emit=function(n,e){return this.get("eventBus").fire(n,e)};wt.prototype._createContainer=function(){return te('
')};wt.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:[]})})};wt.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()};wt.prototype.detach=function(){var n=this._container,e=n.parentNode;e&&(this._emit("detach",{}),e.removeChild(n))};wt.prototype._modules=[HC,$e,lt,mo,wa,JC];function Xv(n){return{x:n.x+n.width/2,y:n.y+n.height/2}}function yr(n,e){return{x:n.x-e.x,y:n.y-e.y}}function ff(n){return Math.log(n)/Math.log(10)}function Yv(n,e){var t=ff(n.min),i=ff(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 XN=Math.sign||function(n){return n>=0?1:-1},Zv={min:.2,max:4},tE=10,YN=.1,ZN=.75;function Qn(n,e,t){n=n||{},this._enabled=!1,this._canvas=t,this._container=t._container,this._handleWheel=it(this._handleWheel,this),this._totalDelta=0,this._scale=n.scale||ZN;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=Yv(Zv,tE*2);this._totalDelta+=e,Math.abs(this._totalDelta)>YN&&(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||vp()&&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))*XN(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=Yv(Zv,tE);this._zoom(e,t,i)};Qn.prototype._zoom=function(n,e,t){var i=this._canvas,r=n>0?1:-1,o=ff(i.zoom()),s=Math.round(o/t)*t;s+=t*r;var a=Math.pow(10,s);i.zoom(eE(Zv,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 JN=/^djs-cursor-.*$/;function hf(n){var e=ee(document.body);e.removeMatching(JN),n&&e.add("djs-cursor-"+n)}function Ep(){hf(null)}var e$=5e3;function Sp(n,e){e=e||"element.click";function t(){return!1}return n.once(e,e$,t),function(){n.off(e,t)}}var t$=15;function Op(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=yr(u,l);if(!t.dragging&&n$(f)>t$&&(t.dragging=!0,c===0&&Sp(n),hf("grab")),t.dragging){var h=t.last||t.start;f=yr(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,Ep()}function s(a){if(!Me(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}}Op.$inject=["eventBus","canvas"];function n$(n){return Math.sqrt(Math.pow(n.x,2)+Math.pow(n.y,2))}var iE={__init__:["moveCanvas"],moveCanvas:["type",Op]};function Ea(n){return CSS.escape(n)}var i$={"&":"&","<":"<",">":">",'"':""","'":"'"};function rE(n){return n=""+n,n&&n.replace(/[&<>"']/g,function(e){return i$[e]})}var oE=["c","C"],sE=["v","V"],r$=["d","D"],o$=["x","X"],aE=["y","Y"],Jv=["z","Z"];function lE(n){return n.ctrlKey||n.metaKey||n.shiftKey||n.altKey}function Tt(n){return n.altKey?!1:n.ctrlKey||n.metaKey}function je(n,e){return n=F(n)?n:[n],n.indexOf(e.key)!==-1||n.indexOf(e.code)!==-1}function kp(n){return n.shiftKey}function cE(n){return Tt(n)&&je(oE,n)}function uE(n){return Tt(n)&&je(sE,n)}function fE(n){return Tt(n)&&je(r$,n)}function hE(n){return Tt(n)&&je(o$,n)}function Rp(n){return Tt(n)&&!kp(n)&&je(Jv,n)}function Tp(n){return Tt(n)&&(je(aE,n)||je(Jv,n)&&kp(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:xt.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){je("ArrowUp",t)&&t.preventDefault(),je("ArrowDown",t)&&t.preventDefault()}),e(this._container,J.INPUT_SELECTOR,"keyup",function(t){if(je("Escape",t))return n.close();if(je("Enter",t)){var i=n._getCurrentResult();return i?n._select(i):n.close(!1)}if(je("ArrowUp",t))return n._scrollToDirection(!0);if(je("ArrowDown",t))return n._scrollToDirection();je(["ArrowLeft","ArrowRight"],t)||n._search(t.delegateTarget.value)})};J.prototype._unbindEvents=function(){this._eventMaps.forEach(function(n){xt.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),Xe(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=Xe(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=Xe(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=s$(e),r=te(t);r.innerHTML=i,n.appendChild(r)}function s$(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__:[$e,mo,lt],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 df(n,e,t){this._elementRegistry=n,this._canvas=t,e.registerProvider(this)}df.$inject=["elementRegistry","searchPad","canvas"];df.prototype.find=function(n){let e=this._canvas.getRootElement(),t=this._elementRegistry.filter(function(i){return!i.labelTarget});return t=_e(t,function(i){return i!==e}),t=qt(t,function(i){return{primaryTokens:xE(fs(i),n),secondaryTokens:xE(i.id,n),element:i}}),t=_e(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 _e(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]=ex(l).center,o;c=e[0],e=Fn(e,function(h){return h[i]+h[r]}),u=ex(e),o[n]=f(c,u)}return o};go.prototype.trigger=function(n,e){var t=this._modeling,i,r=_e(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=a$[e],s=Fn(r,o),a=this._alignmentPosition(e,s);t.alignElements(s,a)}};var CE={__init__:["alignElements"],alignElements:["type",go]};var l$=10,nx=50,c$=250;function ix(n,e,t,i){for(var r;r=u$(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 u$(n,e,t){var i={x:e.x-t.width/2,y:e.y-t.height/2,width:t.width,height:t.height},r=f$(n);return me(r,function(o){if(o===t)return!1;var s=mt(o,i,l$);return s==="intersect"})}function SE(n,e){e||(e={});function t(p){return p.source===n?1:-1}var i=e.defaultDistance||nx,r=e.direction||"e",o=e.filter,s=e.getWeight||t,a=e.maxDistance||c$,l=e.reference||"start";o||(o=p$);function c(p,m){return r==="n"?l==="start"?G(p).top-G(m).bottom:l==="center"?G(p).top-ae(m).y:G(p).top-G(m).top:r==="w"?l==="start"?G(p).left-G(m).right:l==="center"?G(p).left-ae(m).x:G(p).left-G(m).left:r==="s"?l==="start"?G(m).top-G(p).bottom:l==="center"?ae(m).y-G(p).bottom:G(m).bottom-G(p).bottom:l==="start"?G(m).left-G(p).right:l==="center"?ae(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=nt(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=ox:a=kE),a===ox?{x:Math.min(ae(t).x-RE-Pp,G(t).left-Pp-r.width/2),y:o.y}:{x:Math.max(ae(i).x+RE+Pp,G(i).right+Pp+r.width/2),y:o.y}}}function Dp(n){n.on("autoPlace",function(e){var t=e.shape,i=e.source;return AE(i,t)})}Dp.$inject=["eventBus"];var ME={__depends__:[OE],__init__:["dmnAutoPlace"],dmnAutoPlace:["type",Dp]};var PE=1500;function Ip(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),E$(l)}}Ip.$inject=["elementRegistry","eventBus","injector"];function E$(n){return Me(n,"svg, .djs-element",!0)}var DE={__init__:["hoverFix"],hoverFix:["type",Ip]};var Sa=Math.round,IE="djs-drag-active";function hs(n){n.preventDefault()}function S$(n){return typeof TouchEvent!="undefined"&&n instanceof TouchEvent}function O$(n){return Math.sqrt(Math.pow(n.x,2)+Math.pow(n.y,2))}function Lp(n,e,t,i){var r={threshold:5,trapClick:!0},o;function s(v){var x=e.viewbox(),_=e._container.getBoundingClientRect();return{x:x.x+(v.x-_.left)/x.scale,y:x.y+(v.y-_.top)/x.scale}}function a(v,x){x=x||o;var _=n.createEvent(T({},x.payload,x.data,{isTouch:x.isTouch}));return n.fire("drag."+v,_)===!1?!1:n.fire(x.prefix+"."+v,_)}function l(v){var x=v.filter(function(_){return i.get(_.id)});x.length&&t.select(x)}function c(v,x){var _=o.payload,E=o.displacement,S=o.globalStart,C=Un(v),R=yr(C,S),A=o.localStart,D=s(C),I=yr(D,A);if(!o.active&&(x||O$(R)>o.threshold)){if(T(_,{x:Sa(A.x+E.x),y:Sa(A.y+E.y),dx:0,dy:0},{originalEvent:v}),a("start")===!1)return g();o.active=!0,o.keepSelection||(_.previousSelection=t.get(),t.select(null)),o.cursor&&hf(o.cursor),e.addMarker(e.getRootElement(),IE)}yp(v),o.active&&(T(_,{x:Sa(D.x+E.x),y:Sa(D.y+E.y),dx:Sa(I.x),dy:Sa(I.y)},{originalEvent:v}),a("move"))}function u(v){var x,_=!0;o.active&&(v&&(o.payload.originalEvent=v,yp(v)),_=a("end")),_===!1&&a("rejected"),x=b(_!==!0),a("ended",x)}function f(v){je("Escape",v)&&(hs(v),g())}function h(v){var x;o.active&&(x=Sp(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 _=o.active;_&&a("cancel"),x=b(v),_&&a("canceled",x)}}function b(v){var x,_;a("cleanup"),Ep(),o.trapClick?_=h:_=u,q.unbind(document,"mousemove",c),q.unbind(document,"dragstart",hs),q.unbind(document,"selectstart",hs),q.unbind(document,"mousedown",_,!0),q.unbind(document,"mouseup",_,!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 w(v,x,_,E){o&&g(!1),typeof x=="string"&&(E=_,_=x,x=null),E=T({},r,E||{});var S=E.data||{},C,R,A,D,I;E.trapClick?D=h:D=u,v?(C=gr(v)||v,R=Un(v),yp(v),C.type==="dragstart"&&hs(C)):(C=null,R={x:0,y:0}),A=s(R),x||(x=A),I=S$(C),o=T({prefix:_,data:S,payload:{},globalStart:R,displacement:yr(x,A),localStart:A,isTouch:I},E),E.manual||(I?(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",D,!0),q.bind(document,"mouseup",D,!0)),q.bind(document,"keyup",f),n.on("element.hover",p),n.on("element.out",m)),a("init"),E.autoActivate&&c(v,!0)}n.on("diagram.destroy",g),this.init=w,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)}}Lp.$inject=["eventBus","canvas","selection","elementRegistry"];var mn={__depends__:[DE,lt],dragging:["type",Lp]};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++)k$(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 k$(n,e,t){return eE-3&&(R=mt(d.target,_),m===E-2?R==="intersect"&&(v.pop(),v[v.length-1]=_):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&&Ne(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(_){return{original:_.original,x:Math.round(_.x),y:Math.round(_.y)}});var g=u(p,m),b=g.waypoints,w=a(d,b),v=g.segmentOffset,x={segmentMove:{segmentStartIndex:h.segmentStartIndex,newSegmentStartIndex:m+v}};o.updateWaypoints(d,w,x)})}Vp.$inject=["injector","eventBus","canvas","dragging","graphicsFactory","modeling"];var H$=Math.abs,YE=Math.round;function ZE(n,e,t){t=t===void 0?10:t;var i,r;for(i=0;io-ux)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)&&yn(o,"x",c),(h||s.horizontal.indexOf(l)!==-1)&&yn(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);!Ue(a)||!l||!l.x||!l.y||(yn(o,"x",l.x),yn(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)&&yn(o,"x",h),(m||a.horizontal.indexOf(f)!==-1)&&yn(o,"y",d)}})}zp.$inject=["eventBus"];var nS={__depends__:[mn,gn],__init__:["bendpoints","bendpointSnapping","bendpointMovePreview"],bendpoints:["type",jp],bendpointMove:["type",xf],bendpointMovePreview:["type",qp],connectionSegmentMove:["type",Vp],bendpointSnapping:["type",zp]};var W$=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=W$.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=U$();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 U$(){let n={};return n.promise=new Promise((e,t)=>{n.resolve=e,n.reject=t}),n}var iS={scheduler:["type",vo]};var Q$="djs-element-hidden",Wp=".entry",K$=1e3,rS=8,G$=300;function Ye(n,e,t,i){this._canvas=n,this._elementRegistry=e,this._eventBus=t,this._scheduler=i,this._current=null,this._init()}Ye.$inject=["canvas","elementRegistry","eventBus","scheduler"];Ye.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()};Ye.prototype._createContainer=function(){var n=te('
');return this._canvas.getContainer().appendChild(n),n};Ye.prototype.registerProvider=function(n,e){e||(e=n,n=K$),this._eventBus.on("contextPad.getProviders",n,function(t){t.providers.push(e)})};Ye.prototype.getEntries=function(n){var e=this._getProviders(),t=F(n)?"getMultiElementContextPadEntries":"getContextPadEntries",i={};return k(e,function(r){if(pe(r[t])){var o=r[t](n);pe(o)?i=o(i):k(o,function(s,a){i[a]=s})}}),i};Ye.prototype.trigger=function(n,e,t){var i=this,r,o,s=e.delegateTarget||e.target;if(!s)return e.preventDefault();if(r=Xe(s,"data-action"),o=e.originalEvent||e,n==="mouseover"){this._timeout=setTimeout(function(){i._mouseout=i.triggerEntry(r,"hover",o,t)},G$);return}else if(n==="mouseout"){clearTimeout(this._timeout),this._mouseout&&(this._mouseout(),this._mouseout=null);return}return this.triggerEntry(r,n,o,t)};Ye.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(pe(a)){if(e==="click")return a(t,r,i)}else if(a[e])return a[e](t,r,i);t.preventDefault()}}}};Ye.prototype.open=function(n,e){!e&&this.isOpen(n)||(this.close(),this._updateAndOpen(n))};Ye.prototype._getProviders=function(){var n=this._eventBus.createEvent({type:"contextPad.getProviders",providers:[]});return this._eventBus.fire(n),n.providers};Ye.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;Xe(a,"data-action",o),l=X("[data-group="+Ea(s)+"]",t),l||(l=te('
'),Xe(l,"data-group",s),t.appendChild(l)),l.appendChild(a),r.className&&X$(a,r.className),r.title&&Xe(a,"title",r.title),r.imageUrl&&(i=te(""),Xe(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})};Ye.prototype._createHtml=function(n){var e=this,t=te('
');return xt.bind(t,Wp,"click",function(i){e.trigger("click",i)}),xt.bind(t,Wp,"dragstart",function(i){e.trigger("dragstart",i)}),xt.bind(t,Wp,"mouseover",function(i){e.trigger("mouseover",i)}),xt.bind(t,Wp,"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};Ye.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()&&Z$(this._current.target,n)?e=this._current.html:e=this._createHtml(n),{html:e}};Ye.prototype.close=function(){this.isOpen()&&(clearTimeout(this._timeout),this._container.innerHTML="",this._eventBus.fire("contextPad.close",{current:this._current}),this._current=null)};Ye.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&&St(n,function(i){return t.includes(i)}):t===n};Ye.prototype.isShown=function(){return this.isOpen()&&ee(this._current.html).has("open")};Ye.prototype.show=function(){this.isOpen()&&(ee(this._current.html).add("open"),this._updatePosition(),this._eventBus.fire("contextPad.show",{current:this._current}))};Ye.prototype.hide=function(){this.isOpen()&&(ee(this._current.html).remove("open"),this._eventBus.fire("contextPad.hide",{current:this._current}))};Ye.prototype._getPosition=function(n){if(!F(n)&&Ue(n)){var e=this._canvas.viewbox(),t=Y$(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}};Ye.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")};Ye.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,Q$)});r?e.hide():e.show()}};this._scheduler.schedule(n,"ContextPad#_updateVisibility")};Ye.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 X$(n,e){var t=ee(n);e=F(e)?e:e.split(/\s+/g),e.forEach(function(i){t.add(i)})}function Y$(n){return n.waypoints[n.waypoints.length-1]}function Z$(n,e){return n=F(n)?n:[n],e=F(e)?e:[e],n.length===e.length&&St(n,function(t){return e.includes(t)})}var oS={__depends__:[fo,iS,mo],contextPad:["type",Ye]};function Qp(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),!Xr(u)){if(u!==!1){a.source=l,a.target=c;return}u=a.canExecute=o(l,c),!Xr(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:Up(a)?u:c,connectionEnd:Up(a)?c:u};Ae(l)&&(d=l),a.connection=t.connect(f,h,d,p)}),this.start=function(s,a,l,c){Ae(l)||(c=l,l=ae(a)),e.init(s,"connect",{autoActivate:c,data:{shape:a,context:{start:a,connectionStart:l}}})}}Qp.$inject=["eventBus","dragging","modeling","rules"];function Up(n){var e=n.hover,t=n.source,i=n.target;return e&&t&&e===t&&t!==i}var J$=1100,ej=900,sS="connect-ok",aS="connect-not-ok";function Kp(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;Up(o)&&(p=d,m=h),i.drawPreview(o,s,{source:l||c,target:f||a,connectionStart:p,connectionEnd:m})}),e.on("connect.hover",ej,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"],J$,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)})}Kp.$inject=["injector","eventBus","canvas"];var lS={__depends__:[lt,gn,mn],__init__:["connectPreview"],connect:["type",Qp],connectPreview:["type",Kp]};var tj=new po("ps"),nj=["marker-start","marker-mid","marker-end"],ij=["circle","ellipse","line","path","polygon","polyline","path","rect"];function $i(n,e,t,i){this._elementRegistry=n,this._canvas=t,this._styles=i}$i.$inject=["elementRegistry","eventBus","canvas","styles"];$i.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")};$i.prototype.getGfx=function(n){return this._elementRegistry.getGraphics(n)};$i.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};$i.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};$i.prototype._cloneMarkers=function(n,e="djs-dragger",t=n){var i=this;n.childNodes&&n.childNodes.forEach(r=>{i._cloneMarkers(r,e,t)}),aj(n)&&nj.forEach(function(r){if(j(n,r)){var o=rj(n,r,i._canvas.getContainer());o&&i._cloneMarker(t,n,o,r,e)}})};$i.prototype._cloneMarker=function(n,e,t,i,r="djs-dragger"){var o=[t.id,r,tj.next()].join("-"),s=X("marker#"+t.id,n);n=n||this._canvas._svg;var a=s||gv(t);a.id=o,ie(a).add(r);var l=X(":scope > defs",n);l||(l=Q("defs"),K(n,l)),K(l,a);var c=sj(a.id);j(e,i,c)};function rj(n,e,t){var i=oj(j(n,e));return X("marker#"+i,t||document)}function oj(n){return n.match(/url\(['"]?#([^'"]*)['"]?\)/)[1]}function sj(n){return"url(#"+n+")"}function aj(n){return ij.indexOf(n.nodeName)!==-1}var Oa={__init__:["previewSupport"],previewSupport:["type",$i]};var lj="drop-ok",cS="drop-not-ok",uS="attach-ok",fS="new-parent",hS="create",cj=2e3;function Gp(n,e,t,i,r){function o(l,c,u,f,h){if(!c)return!1;l=_e(l,function(w){var v=w.labelTarget;return!w.parent&&!(Li(w)&&l.indexOf(v)!==-1)});var d=me(l,function(w){return!Ue(w)}),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,lj,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 w={x:l.x,y:l.y};g?f=i.appendShape(u,f,w,d,{attach:m,connection:g===!0?{}:g,connectionTarget:b.connectionTarget}):(h=i.createElements(h,w,d,T({},b,{attach:m})),f=me(h,function(v){return!Ue(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"],cj,function(){t.off("elements.changed",a)})}),this.start=function(l,c,u){F(c)||(c=[c]);var f=me(c,function(p){return!Ue(p)});if(f){u=T({elements:c,hints:{},shape:f},u||{}),k(c,function(p){oe(p.x)||(p.x=0),oe(p.y)||(p.y=0)});var h=_e(c,function(p){return!p.hidden}),d=kt(h);k(c,function(p){Ue(p)&&(p.waypoints=qt(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}})}}}Gp.$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&&!Ue(n[0])}var uj=750;function Xp(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),Nt(u,c.x,c.y)),i.addDragger(c,a,u))}),a}e.on("create.move",uj,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)),Nt(u,s.x,s.y)):Ne(u)}),e.on("create.cleanup",function(s){var a=s.context,l=a.dragGroup;l&&Ne(l)})}Xp.$inject=["canvas","eventBus","graphicsFactory","previewSupport","styles"];var Yp={__depends__:[mn,Oa,gn,lt],__init__:["create","createPreview"],create:["type",Gp],createPreview:["type",Xp]};var rm,Fe,xS,fj,xo,mS,bS,_S,fx,Jp,_f,wS,mx,hx,dx,hj,tm={},nm=[],dj=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,om=Array.isArray;function _r(n,e){for(var t in e)n[t]=e[t];return n}function gx(n){n&&n.parentNode&&n.parentNode.removeChild(n)}function sm(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?rm.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 em(n,s,i,r,null)}function em(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&&Fe.vnode!=null&&Fe.vnode(o),o}function am(n){return n.children}function wf(n,e){this.props=n,this.context=e}function ka(n,e){if(e==null)return n.__?ka(n.__,n.__i+1):null;for(var t;ee&&xo.sort(_S),n=xo.shift(),e=xo.length,pj(n)}finally{xo.length=im.__r=0}}function ES(n,e,t,i,r,o,s,a,l,c,u){var f,h,d,p,m,g,b,w=i&&i.__k||nm,v=e.length;for(l=mj(t,e,w,l,v),f=0;f0?s=n.__k[o]=em(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=gj(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"||dj.test(e)?t:t+"px"}function Zp(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[_f]=i[_f]:(t[_f]=mx,n.addEventListener(e,o?dx:hx,o)):n.removeEventListener(e,o?dx:hx,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[Jp]==null)e[Jp]=mx++;else if(e[Jp]0?n:om(n)?n.map(kS):_r({},n)}function yj(n,e,t,i,r,o,s,a,l){var c,u,f,h,d,p,m,g=t.props||tm,b=e.props,w=e.type;if(w=="svg"?r="http://www.w3.org/2000/svg":w=="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 Oe=MS.bind(sm);var Ra,ct,xx,PS,Cf=0,FS=[],yt=Fe,DS=yt.__b,IS=yt.__r,LS=yt.diffed,BS=yt.__c,NS=yt.unmount,$S=yt.__;function um(n,e){yt.__h&&yt.__h(ct,n,Cf||e),Cf=0;var t=ct.__H||(ct.__H={__:[],__h:[]});return n>=t.__.length&&t.__.push({}),t.__[n]}function fm(n){return Cf=1,qS(VS,n)}function qS(n,e,t){var i=um(Ra++,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=ct,!ct.__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};ct.__f=!0;var o=ct.shouldComponentUpdate,s=ct.componentWillUpdate;ct.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)},ct.shouldComponentUpdate=r}return i.__N||i.__}function Ef(n,e){var t=um(Ra++,3);!yt.__s&&_x(t.__H,e)&&(t.__=n,t.u=e,ct.__H.__h.push(t))}function Ta(n,e){var t=um(Ra++,4);!yt.__s&&_x(t.__H,e)&&(t.__=n,t.u=e,ct.__h.push(t))}function Sf(n){return Cf=5,ji(function(){return{current:n}},[])}function ji(n,e){var t=um(Ra++,7);return _x(t.__H,e)&&(t.__=n(),t.__H=e,t.__h=n),t.__}function Aa(n,e){return Cf=8,ji(function(){return n},e)}function xj(){for(var n;n=FS.shift();){var e=n.__H;if(n.__P&&e)try{e.__h.some(cm),e.__h.some(bx),e.__h=[]}catch(t){e.__h=[],yt.__e(t,n.__v)}}}yt.__b=function(n){ct=null,DS&&DS(n)},yt.__=function(n,e){n&&e.__k&&e.__k.__m&&(n.__m=e.__k.__m),$S&&$S(n,e)},yt.__r=function(n){IS&&IS(n),Ra=0;var e=(ct=n.__c).__H;e&&(xx===ct?(e.__h=[],ct.__h=[],e.__.some(function(t){t.__N&&(t.__=t.__N),t.u=t.__N=void 0})):(e.__h.some(cm),e.__h.some(bx),e.__h=[],Ra=0)),xx=ct},yt.diffed=function(n){LS&&LS(n);var e=n.__c;e&&e.__H&&(e.__H.__h.length&&(FS.push(e)!==1&&PS===yt.requestAnimationFrame||((PS=yt.requestAnimationFrame)||bj)(xj)),e.__H.__.some(function(t){t.u&&(t.__H=t.u),t.u=void 0})),xx=ct=null},yt.__c=function(n,e){e.some(function(t){try{t.__h.some(cm),t.__h=t.__h.filter(function(i){return!i.__||bx(i)})}catch(i){e.some(function(r){r.__h&&(r.__h=[])}),e=[],yt.__e(i,t.__v)}}),BS&&BS(n,e)},yt.unmount=function(n){NS&&NS(n);var e,t=n.__c;t&&t.__H&&(t.__H.__.some(function(i){try{cm(i)}catch(r){e=r}}),t.__H=void 0,e&&yt.__e(e,t.__v))};var jS=typeof requestAnimationFrame=="function";function bj(n){var e,t=function(){clearTimeout(i),jS&&cancelAnimationFrame(e),setTimeout(n)},i=setTimeout(t,35);jS&&(e=requestAnimationFrame(t))}function cm(n){var e=ct,t=n.__c;typeof t=="function"&&(n.__c=void 0,t()),ct=e}function bx(n){var e=ct;n.__c=n.__(),ct=e}function _x(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 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;ewj(e),[e]),a=c=>c.action&&!c.disabled,l=(c,u)=>{if(a(u))return t(c,u)};return Oe`

${o}

${s.map(c=>Oe`
    ${c.entries.map(u=>Oe`
  • <${a(u)?"button":"span"} class=${Cj(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&&Oe``||u.imageHtml&&Oe`
    `} ${u.label?Oe` ${u.label} `:null}
  • `)}
`)}
`}function wj(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 Cj(n,e){return gs("entry",n.className,n.active?"active":"",n.disabled?"disabled":"",e?"selected":"")}function Cx(n){let{entry:e,selected:t,onMouseEnter:i,onMouseLeave:r,onAction:o}=n,s=(a,l)=>{if(!e.disabled)return o(a,e,l)};return Oe`
  • s(a,"dragstart")} draggable=${!0} >
    ${e.imageUrl&&Oe``||e.imageHtml&&Oe`
    `} ${e.label?Oe` ${e.label} `:null} ${e.description&&Oe` ${e.description} `}
    ${e.documentationRef&&Oe`
    a.stopPropagation()} title="Open element documentation" target="_blank" rel="noopener" >
    `}
  • `}function Ex(n){let{selectedEntry:e,setSelectedEntry:t,groupedEntries:i,...r}=n,o=Sf();return Ta(()=>{let s=o.current;if(!s)return;let a=s.querySelector(".selected");a&&Ej(a)},[e]),Oe`
    ${i.map(s=>Oe` ${s.name&&Oe`
    ${s.name}
    `}
      ${s.entries.map(a=>Oe` <${Cx} key=${a.id} entry=${a} selected=${a===e} onMouseEnter=${()=>t(a)} onMouseLeave=${()=>t(null)} ...${r} /> `)}
    `)}
    `}function Ej(n){typeof n.scrollIntoViewIfNeeded=="function"?n.scrollIntoViewIfNeeded():n.scrollIntoView({scrollMode:"if-needed",block:"nearest"})}function Sx(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=ji(()=>Te(c)?h.length>5:!1,[c,h]),[g,b]=fm(""),w=Aa((D,I)=>{if(!m)return D;if(!I.trim())return D.filter(({rank:H=0})=>H>=0);let N=D.filter(({searchable:H})=>H!==!1);return f(N,I,{keys:["label","search","description"]}).map(({item:H})=>H)},[m]),v=ji(()=>w(h,g),[h,g,w]),[x,_]=fm(v[0]),E=ji(()=>g.trim()?v.length?[{id:"default",entries:v}]:[]:kj(v),[v,g]);Ef(()=>{_(v[0])},[v]);let S=Aa(D=>{let I=Oj(E),H=I.indexOf(x)+D;H<0&&(H=I.length-1),H>=I.length&&(H=0),_(I[H])},[E,x,_]),C=Aa(D=>{if(D.key==="Enter"&&x)return x.disabled?void 0:t(D,x);if(D.key==="ArrowUp")return S(-1),D.preventDefault();if(D.key==="ArrowDown")return S(1),D.preventDefault()},[t,x,S]),R=Aa(D=>{no(D.target,"input")&&b(()=>D.target.value)},[b]);Ef(()=>(d(),()=>{p()}),[]);let A=ji(()=>s||r.length>0,[s,r]);return Oe` <${zS} onClose=${e} onKeyup=${R} onKeydown=${C} className=${i} position=${o} width=${a} scale=${l} > ${A&&Oe` <${wx} headerEntries=${r} onSelect=${t} selectedEntry=${x} setSelectedEntry=${_} title=${s} /> `} ${h.length>0&&Oe`
    ${m&&Oe` `} <${Ex} groupedEntries=${E} selectedEntry=${x} setSelectedEntry=${_} onAction=${t} />
    `} ${u&&v.length===0&&Oe`
    ${pe(u)?u(g):u}
    `} `}function zS(n){let{onClose:e,onKeydown:t,onKeyup:i,className:r,children:o,position:s}=n,a=Sf();return Ta(()=>{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]),Ta(()=>{let l=a.current;if(!l)return;(l.querySelector("input")||l).focus()},[]),Ef(()=>{let l=u=>{if(u.key==="Escape")return u.preventDefault(),e()},c=u=>{if(!Me(u.target,".djs-popup",!0))return e()};return document.documentElement.addEventListener("keydown",l),document.body.addEventListener("click",c),()=>{document.documentElement.removeEventListener("keydown",l),document.body.removeEventListener("click",c)}},[]),Oe`
    ${o}
    `}function Sj(n){return{transform:`scale(${n.scale})`,width:`${n.width}px`,"transform-origin":"top left"}}function Oj(n){let e=[];return n.forEach(t=>{t.entries.forEach(i=>{e.push(i)})}),e}function kj(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 Rj="data-id",WS=["contextPad.close","canvas.viewbox.changing","commandStack.changed"],Tj=1e3;function De(n,e,t,i){this._eventBus=e,this._canvas=t,this._search=i,this._current=null;var r=Te(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()})}De.$inject=["config.popupMenu","eventBus","canvas","search"];De.prototype._render=function(){let{position:n,providerId:e,entries:t,headerEntries:i,emptyPlaceholder:r,options:o}=this._current,s=Object.entries(t).map(([h,d])=>({id:h,...d})),a=Object.entries(i).map(([h,d])=>({id:h,...d})),l=n&&(h=>this._ensureVisible(h,n)),c=this._updateScale(this._current.container);lm(Oe` <${Sx} 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)};De.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");this.isOpen()&&this.close();let{entries:r,headerEntries:o,emptyPlaceholder:s}=this._getContext(n,e);this._current={position:t,providerId:e,target:n,entries:r,headerEntries:o,emptyPlaceholder:s,container:this._createContainer({provider:e}),options:i},this._emit("open"),this._bindAutoClose(),this._render()};De.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()};De.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)}};De.prototype.close=function(){this.isOpen()&&(this._emit("close"),this.reset(),this._canvas.restoreFocus(),this._current=null)};De.prototype.reset=function(){let n=this._current.container;lm(null,n),He(n)};De.prototype._emit=function(n,e){this._eventBus.fire(`popupMenu.${n}`,e)};De.prototype._onOpened=function(){this._emit("opened")};De.prototype._onClosed=function(){this._emit("closed")};De.prototype._createContainer=function(n){var e=this._canvas,t=e.getContainer();let i=te(`
    `);return t.appendChild(i),i};De.prototype._bindAutoClose=function(){this._eventBus.once(WS,this.close,this)};De.prototype._unbindAutoClose=function(){this._eventBus.off(WS,this.close,this)};De.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),Te(t)&&ni&&(r=i)),r};De.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.ype(t.getEmptyPlaceholder));return e&&e.getEmptyPlaceholder()};De.prototype.isOpen=function(){return!!this._current};De.prototype.trigger=function(n,e,t="click"){if(n.preventDefault(),!e){let r=Me(n.delegateTarget||n.target,".entry",!0),o=Xe(r,Rj);e={id:o,...this._getEntry(o)}}let i=e.action;if(this._emit("trigger",{entry:e,event:n})!==!1){if(pe(i)){if(t==="click")return i(n,e)}else if(i[t])return i[t](n,e)}};De.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 Ox(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=Aj(o,r,i);return s?{item:o,tokens:s}:[]}).sort(Mj(i))}function Aj(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}=GS(f,e);return{tokens:[...u.tokens,h],matchedWords:{...u.matchedWords,...d}}},{matchedWords:{},tokens:[]}):GS(a,e);return{tokens:{...o.tokens,[s]:l},matchedWords:{...o.matchedWords,...c}}},{matchedWords:{},tokens:{}});return Object.keys(i).length!==e.length?null:r}function Mj(n){return(e,t)=>{let i=0,r=1;for(let o of n){let s=Pj(e.tokens[o],t.tokens[o]);if(s!==0){i+=s*r,r*=US;continue}let a=Dj(e.item[o],t.item[o]);if(a!==0){i+=a*r,r*=US;continue}}return i}}function Pj(n,e){return QS(e)-QS(n)}var US=.5,Ma={FULL:131.9,START_FULL_WORD:8,START_WORD_PART:7.87,WORD_START:2.19,WORD_PART:1,NO_MATCH:-.07};function QS(n){let e=n.reduce((a,l)=>a+XS(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 XS(n){if(F(n))return Math.max(...n.map(XS));let e=Math.log(n.value.length);return n.match?(n.start?n.end?Ma.FULL:n.wordEnd?Ma.START_FULL_WORD:Ma.START_WORD_PART:n.wordStart?Ma.WORD_START:Ma.WORD_PART)*e:Ma.NO_MATCH*e}function KS(n=""){return F(n)?n.join(", "):n}function Dj(n,e){return KS(n).localeCompare(KS(e))}function GS(n,e){var c;if(!n)return{tokens:[],matchedWords:{}};let t=[],i={},r=e.map(Ij),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 w=m?e:[u];for(let v of w)i[v.toLowerCase()]=!0;l=a.index+u.length}return le.removeElements(o.slice())}}}),i};ys.prototype._isDeleteAllowed=function(n){var e=this._rules.allowed("elements.delete",{elements:n});return F(e)?St(n,t=>e.includes(t)):e};var rO={__depends__:[$e,oS,lt,lS,Yp,iO],__init__:["contextPadProvider"],contextPadProvider:["type",ys]};var Lj="djs-dragger";function di(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)}di.$inject=["injector","canvas","graphicsFactory","elementFactory"];di.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=Bj(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?ae(o):l,s?ae(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)"})};di.prototype.drawNoopPreview=function(n,e){var t=e.source,i=e.target,r=e.connectionStart||ae(t),o=e.connectionEnd||ae(i),s=this.cropWaypoints(r,o,t,i),a=this.createNoopConnection(s[0],s[1]);K(n,a)};di.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&&Zu(o,a,!0)||n,e=i&&Zu(s,a,!1)||e,[n,e]};di.prototype.cleanUp=function(n){n&&n.connectionPreviewGfx&&Ne(n.connectionPreviewGfx)};di.prototype.getConnection=function(n){var e=Nj(n);return this._elementFactory.createConnection(e)};di.prototype.createConnectionPreviewGfx=function(){var n=Q("g");return j(n,{pointerEvents:"none"}),ie(n).add(Lj),K(this._canvas.getActiveLayer(),n),n};di.prototype.createNoopConnection=function(n,e){return ro([n,e],{stroke:"#333",strokeDasharray:[1],strokeWidth:2,"pointer-events":"none"})};function Bj(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 Nj(n){return Ae(n)?n:{}}var oO={__init__:["connectionPreview"],connectionPreview:["type",di]};var $j=/\s/,jj=/^([a-z][\w-.]*:)?[a-z_][\w-.]*$/i,Fj=/^[a-z_][\w-.]*$/i,qj=/\$\{([^}]*)\}/g;function sO(n,e){let t=n.$model.ids.assigned(e),i=t&&t!==n;return e?i?"Element must have unique ID.":Vj(e):"Element must have ID."}function Vj(n){if(n=zj(n),Hj(n))return"Id must not contain spaces.";if(!Fj.test(n))return jj.test(n)?"Id must not contain prefix.":"Id must be a valid QName."}function Hj(n){return $j.test(n)}function zj(n){return n.replace(qj,"$1")}var Wj=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=sO(ze(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",Ai(function(i){var r=i.target.value||i.target.textContent;t.update(e,r.trim())},Wj)),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 aO={__depends__:[wa],__init__:["definitionPropertiesEdit","definitionPropertiesPaletteAdapter"],definitionPropertiesEdit:["type",bo],definitionPropertiesPaletteAdapter:["type",_a]};var Uj={horizontal:["x","width"],vertical:["y","height"]},lO=5;function pi(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:[]})}pi.$inject=["modeling","rules"];pi.prototype.registerFilter=function(n){if(typeof n!="function")throw new Error("the filter has to be a function");this._filters.push(n)};pi.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};pi.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};pi.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};pi.prototype._setOrientation=function(n){var e=Uj[n];this._axis=e[0],this._dimension=e[1]};pi.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)};pi.prototype._findRange=function(n){var e=n[this._axis],t=n[this._dimension];return{min:e+lO,max:e+t-lO}};var cO={__init__:["distributeElements"],distributeElements:["type",pi]};function pm(n){n.registerFilter(function(e){return _e(e,function(t){var i=We(t,["dmn:AuthorityRequirement","dmn:InformationRequirement","dmn:KnowledgeRequirement","dmn:Association","dmn:TextAnnotation"]);return!(t.labelTarget||i)})})}pm.$inject=["distributeElements"];var uO={__depends__:[cO],__init__:["drdDistributeElements"],drdDistributeElements:["type",pm]};var fO="is not a registered action",Qj="is already registered";function on(n,e){this._actions={};var t=this;n.on("diagram.init",function(){t._registerDefaultActions(e),n.fire("editorActions.init",{editorActions:t})})}on.$inject=["eventBus","injector"];on.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)})};on.prototype.trigger=function(n,e){if(!this._actions[n])throw Rx(n,fO);return this._actions[n](e)};on.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)})};on.prototype._registerAction=function(n,e){if(this.isRegistered(n))throw Rx(n,Qj);this._actions[n]=e};on.prototype.unregister=function(n){if(!this.isRegistered(n))throw Rx(n,fO);this._actions[n]=void 0};on.prototype.getActions=function(){return Object.keys(this._actions)};on.prototype.isRegistered=function(n){return!!this._actions[n]};function Rx(n,e){return new Error(n+" "+e)}var hO={__init__:["editorActions"],editorActions:["type",on]};function Pa(n){n.invoke(on,this)}ce(Pa,on);Pa.$inject=["injector"];Pa.prototype._registerDefaultActions=function(n){on.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 dO={__depends__:[hO],editorActions:["type",Pa]};function Da(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})=>{Da(o)||r(o)})}mm.$inject=["drdFactory","elementFactory","eventBus","drdUpdater"];var pO={__init__:["diGenerator"],diGenerator:["type",mm]};var kf=10;function gm(n,e,t){return t||(t="round"),Math[t](n/e)*e}var Kj=1200,Gj=800;function Fi(n,e,t){var i=!t||t.active!==!1;this._eventBus=e;var r=this;e.on("diagram.init",Gj,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"],Kj,function(o){var s=o.originalEvent;if(!(!r.active||s&&Tt(s))){var a=o.context,l=a.gridSnappingContext;l||(l=a.gridSnappingContext={}),["x","y"].forEach(function(c){var u={},f=Yj(o,c,n);f&&(u.offset=f);var h=Xj(o,c);h&&T(u,h),br(o,c)||r.snapEvent(o,c,u)})}})}Fi.prototype.snapEvent=function(n,e,t){var i=this.snapValue(n[e],t);yn(n,e,i)};Fi.prototype.getGridSpacing=function(){return kf};Fi.prototype.snapValue=function(n,e){var t=0;e&&e.offset&&(t=e.offset),n+=t,n=gm(n,kf);var i,r;return e&&e.min&&(i=e.min,oe(i)&&(i=gm(i+t,kf,"ceil"),n=Math.max(n,i))),e&&e.max&&(r=e.max,oe(r)&&(r=gm(r+t,kf,"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 Xj(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&&(ym(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&&(ym(e)?gO(a)?s.x.max=l.left:s.x.min=l.right:mO(a)?s.y.max=l.top:s.y.min=l.bottom),c&&(ym(e)?gO(a)?s.x.min=c.left:s.x.max=c.right:mO(a)?s.y.min=c.top:s.y.max=c.bottom),s[e]}function Yj(n,e,t){var i=n.context,r=n.shape,o=i.gridSnappingContext,s=o.snapLocation,a=o.snapOffset;return a&&oe(a[e])||(a||(a=o.snapOffset={}),oe(a[e])||(a[e]=0),!r)||(t.get(r.id)||(ym(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 ym(n){return n==="x"}function mO(n){return n.indexOf("n")!==-1}function gO(n){return n.indexOf("w")!==-1}var Zj=1e3;function se(n){this._eventBus=n}se.$inject=["eventBus"];function Jj(n,e){return function(t){return n.call(e||null,t.context,t.command,t)}}se.prototype.on=function(n,e,t,i,r,o){if((pe(e)||oe(e))&&(o=r,r=i,i=t,t=e,e=null),pe(t)&&(o=r,r=i,i=t,t=Zj),Ae(r)&&(o=r,r=!1),!pe(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?Jj(i,o):i,o)})};se.prototype.canExecute=Cr("canExecute");se.prototype.preExecute=Cr("preExecute");se.prototype.preExecuted=Cr("preExecuted");se.prototype.execute=Cr("execute");se.prototype.executed=Cr("executed");se.prototype.postExecute=Cr("postExecute");se.prototype.postExecuted=Cr("postExecuted");se.prototype.revert=Cr("revert");se.prototype.reverted=Cr("reverted");function Cr(n){return function(t,i,r,o,s){(pe(t)||oe(t))&&(s=o,o=r,r=i,i=t,t=null),this.on(t,n,i,r,o,s)}}function Er(n,e){se.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;Pe(s)?r.newBounds=t.snapComplex(l,s):r.newBounds=t.snapSimple(a,l)}})}Er.$inject=["eventBus","gridSnapping","modeling"];ce(Er,se);Er.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};Er.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};Er.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};Er.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 eF=2e3;function vm(n,e){n.on(["spaceTool.move","spaceTool.end"],eF,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)}})}vm.$inject=["eventBus","gridSnapping"];var yO={__init__:["gridSnappingResizeBehavior","gridSnappingSpaceToolBehavior"],gridSnappingResizeBehavior:["type",Er],gridSnappingSpaceToolBehavior:["type",vm]};var vO={__depends__:[yO],__init__:["gridSnapping"],gridSnapping:["type",Fi]};var xm="keyboard.keydown",tF="keyboard.keyup",nF=1e3,xO="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 At(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(xO));var i=n&&n.bind!==!1;e.on("canvas.init",function(r){t._target=r.svg,i&&t.bind(),t._fire("init")})}At.$inject=["config.keyboard","eventBus"];At.prototype._keydownHandler=function(n){this._keyHandler(n,xm)};At.prototype._keyupHandler=function(n){this._keyHandler(n,tF)};At.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()}};At.prototype._isEventIgnored=function(n){return!1};At.prototype.bind=function(n){n&&console.error("unsupported argument ",new Error(xO)),this.unbind(),n=this._node=this._target,q.bind(n,"keydown",this._keydownHandler),q.bind(n,"keyup",this._keyupHandler),this._fire("bind")};At.prototype.getBinding=function(){return this._node};At.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};At.prototype._fire=function(n){this._eventBus.fire("keyboard."+n,{node:this._node})};At.prototype.addListener=function(n,e,t){pe(n)&&(t=e,e=n,n=nF),this._eventBus.on(t||xm,n,e)};At.prototype.removeListener=function(n,e){this._eventBus.off(e||xm,n)};At.prototype.hasModifier=lE;At.prototype.isCmd=Tt;At.prototype.isShift=kp;At.prototype.isKey=je;var iF=500;function Sr(n,e){var t=this;n.on("editorActions.init",iF,function(i){var r=i.editorActions;t.registerBindings(e,r)})}Sr.$inject=["eventBus","keyboard"];Sr.prototype.registerBindings=function(n,e){function t(i,r){e.isRegistered(i)&&n.addListener(r)}t("undo",function(i){var r=i.keyEvent;if(Rp(r))return e.trigger("undo"),!0}),t("redo",function(i){var r=i.keyEvent;if(Tp(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(je(["+","Add","="],r)&&Tt(r))return e.trigger("stepZoom",{value:1}),!0}),t("stepZoom",function(i){var r=i.keyEvent;if(je(["-","Subtract"],r)&&Tt(r))return e.trigger("stepZoom",{value:-1}),!0}),t("zoom",function(i){var r=i.keyEvent;if(je("0",r)&&Tt(r))return e.trigger("zoom",{value:1}),!0}),t("removeSelection",function(i){var r=i.keyEvent;if(je(["Backspace","Delete","Del"],r))return e.trigger("removeSelection"),!0})};var _o={__init__:["keyboard","keyboardBindings"],keyboard:["type",At],keyboardBindings:["type",Sr]};function Ia(n){n.invoke(Sr,this)}ce(Ia,Sr);Ia.$inject=["injector"];Ia.prototype.registerBindings=function(n,e){Sr.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 bO={__depends__:[_o],__init__:["keyboardBindings"],keyboardBindings:["type",Ia]};var rF={moveSpeed:50,moveSpeedAccelerated:200};function bm(n,e,t){var i=this;this._config=T({},rF,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 _O={__depends__:[_o],__init__:["keyboardMove"],keyboardMove:["type",bm]};var oF={moveSpeed:1,moveSpeedAccelerated:10},sF=1500,wO="left",CO="up",EO="right",SO="down",aF={ArrowLeft:wO,Left:wO,ArrowUp:CO,Up:CO,ArrowRight:EO,Right:EO,ArrowDown:SO,Down:SO},lF={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({},oF,n||{}),e.addListener(sF,function(s){var a=s.keyEvent,l=aF[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=lF[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 OO={__depends__:[_o,lt],__init__:["keyboardMoveSelection"],keyboardMoveSelection:["type",_m]};function Ee(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)}Ee.$inject=["eventBus","injector"];Ee.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()};Ee.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};Ee.prototype.clear=function(n){this._stack.length=0,this._stackIdx=-1,n!==!1&&this._fire("changed",{trigger:"clear"})};Ee.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()}};Ee.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()}};Ee.prototype.register=function(n,e){this._setHandler(n,e)};Ee.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)};Ee.prototype.canUndo=function(){return!!this._getUndoAction()};Ee.prototype.canRedo=function(){return!!this._getRedoAction()};Ee.prototype._getRedoAction=function(){return this._stack[this._stackIdx+1]};Ee.prototype._getUndoAction=function(){return this._stack[this._stackIdx]};Ee.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)})};Ee.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};Ee.prototype._createId=function(){return this._uid++};Ee.prototype._atomicDo=function(n){let e=this._currentExecution;e.atomic=!0;try{n()}finally{e.atomic=!1}};Ee.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()};Ee.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)};Ee.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:Lw("id",i.reverse())}),i.length=0,this._fire("changed",{trigger:e}),n.trigger=null)};Ee.prototype._markDirty=function(n){let e=this._currentExecution;n&&(n=F(n)?n:[n],e.dirty=e.dirty.concat(n))};Ee.prototype._executedAction=function(n,e){let t=++this._stackIdx;e||this._stack.splice(t,this._stack.length,n)};Ee.prototype._revertedAction=function(n){this._stackIdx--};Ee.prototype._getHandler=function(n){return this._handlerMap[n]};Ee.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 vs={commandStack:["type",Ee]};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(np(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 kO=Math.min,RO=Math.max;function Tx(n){n.preventDefault()}function Rf(n){n.stopPropagation()}function cF(n){return n.nodeType===Node.TEXT_NODE}function uF(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=it(this.autoResize,this),this.handlePaste=it(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=fn(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=fn(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",Rf),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=fF(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=uF(s.childNodes),l,c;if(cF(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&&He(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){Tx(p),Rf(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){Tx(p),Rf(p);var m=kO(RO(c+p.clientX-a,i),o),g=kO(RO(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){Tx(p),Rf(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",Rf),q.unbind(e,"input",this.autoResize),q.unbind(e,"paste",this.handlePaste),t&&(t.removeAttribute("style"),He(t)),He(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 fF(n){return n.replace(/\r\n|\r|\n/g,` `)}function vn(n,e){this._eventBus=n,this._canvas=e,this._providers=[],this._textbox=new On({container:e.getContainer(),keyHandler:it(this._handleKey,this),resizeHandler:it(this._handleResize,this)})}vn.$inject=["eventBus","canvas"];vn.prototype.registerProvider=function(n){this._providers.push(n)};vn.prototype.isActive=function(n){return!!(this._active&&(!n||this._active.element===n))};vn.prototype.cancel=function(){this._active&&(this._fire("cancel"),this.close())};vn.prototype._fire=function(n,e){this._eventBus.fire("directEditing."+n,e||{active:this._active})};vn.prototype.close=function(){this._textbox.destroy(),this._fire("deactivate"),this._active=null,this.resizable=void 0,this._canvas.restoreFocus&&this._canvas.restoreFocus()};vn.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()}};vn.prototype.getValue=function(){return this._textbox.getValue()};vn.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()};vn.prototype._handleResize=function(n){this._fire("resize",n)};vn.prototype.activate=function(n){this.isActive()&&this.cancel();var e,t=me(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 TO={__depends__:[fo],__init__:["directEditing"],directEditing:["type",vn]};var AO="djs-label-hidden";function xs(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,AO)}})}xs.$inject=["canvas","directEditing","eventBus","modeling","textRenderer"];xs.prototype.activate=function(n){var e=fs(n);if(Te(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,AO),t}};xs.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}};xs.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}),hF(e)&&(e=null),this._modeling.updateLabel(n,e,r)};function hF(n){return!n||!n.trim()}var MO={__depends__:[vs,Cm,TO],__init__:["labelEditingProvider"],labelEditingProvider:["type",xs]};function Tf(n,e){e.invoke(se,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"+dF(o)]=n.create("dmn:DMNElementReference",{href:"#"+o.id}),a.$parent=r)},!0)}Tf.$inject=["drdFactory","injector"];ce(Tf,se);function dF(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 pF=500;function Af(n,e,t,i){n.invoke(se,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=mt(a,l);o.hints||(o.hints={}),T(o.hints,mF(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=yF(o,s),k(l,function(c,u){c=vF(c,u);var f=gF(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=mt(a,l),u=l.incoming.filter(f=>{var h=mt(f.source,f.target);return O(f,"dmn:InformationRequirement")&&PO(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=mt(a,l),u=l.incoming.filter(f=>{var h=mt(f.source,f.target);return f!==s&&O(f,"dmn:InformationRequirement")&&PO(h,c)});u.length&&r(l,u,c)}},!0),this.postExecuted("elements.move",pF,function(o){var s=o.shapes,a=o.closure,l=a.enclosedConnections;s.forEach(function(c){if(We(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)}Af.$inject=["injector","layouter","modeling","rules"];ce(Af,se);function mF(n,e,t){var i=ae(n),r=ae(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 gF(n,e,t){return n.map(function(i,r){var o=i.source,s=ae(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 yF(n,e){var t={};return e.forEach(function(i){var r=mt(i.source,n).split("-").shift();t[r]||(t[r]=[]),t[r].push(i)}),t}function PO(n,e){return n&&e&&n.split("-").shift()===e.split("-").shift()}function vF(n,e){var t;return e.includes("top")||e.includes("bottom")?t="x":t="y",n.sort(function(i,r){return ae(i.source)[t]-ae(r.source)[t]})}function Mf(n,e,t){n.invoke(se,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)}ce(Mf,se);Mf.$inject=["injector","modeling","rules"];function Pf(n,e,t){se.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)})}ce(Pf,se);Pf.$inject=["eventBus","modeling","selection"];var DO="id",Kn=class extends se{constructor(e){super(e),this.executed("element.updateProperties",this.updateIds.bind(this))}updateIds({context:e}){let{element:t,oldProperties:i,properties:r}=e,o=ze(t);if(this.shouldSkipUpdate(o,i,r))return;let s=bF(o);s.get("drgElement").forEach(c=>{_F(c,i.id,r.id)}),s.get("artifact").forEach(c=>{wF(c,i.id,r.id)})}shouldSkipUpdate(e,t,i){return!xF(t,i)||!O(e,"dmn:DRGElement")&&!O(e,"dmn:TextAnnotation")}};Kn.$inject=["eventBus"];function xF(n,e){return DO in n&&DO in e}function bF(n){let e=n;for(;!O(e,"dmn:Definitions");)e=e.$parent;return e}function _F(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 wF(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 se{constructor(t,i){super(t);M(this,"updateVariableFromLabel",({context:t})=>{let{element:i,newLabel:r}=t,o=ze(i),s=o.variable;s&&this._modeling.updateProperties(s,{name:r})});M(this,"updateVariableFromElement",({context:t})=>{let{element:i,properties:r}=t,o=ze(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=CF(t);return O(t,"dmn:InformationItem")&&i&&i.get("variable")===t}shouldSyncVariable(t){let i=ze(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 CF(n){return n.$parent}var IO={__init__:["createConnectionBehavior","idChangeBehavior","nameChangeBehavior","layoutConnectionBehavior","replaceConnectionBehavior","replaceElementBehavior"],createConnectionBehavior:["type",Tf],idChangeBehavior:["type",Kn],nameChangeBehavior:["type",qi],layoutConnectionBehavior:["type",Af],replaceConnectionBehavior:["type",Mf],replaceElementBehavior:["type",Pf]};function Vi(n){se.call(this,n),this.init()}Vi.$inject=["eventBus"];ce(Vi,se);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 Or(n){n.invoke(Vi,this)}ce(Or,Vi);Or.$inject=["injector"];Or.prototype.init=function(){this.addRule("connection.create",function(n){var e=n.source,t=n.target;return Ax(e,t)}),this.addRule("connection.reconnect",function(n){var e=n.connection,t=n.source,i=n.target;return Ax(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 NO(t,e,i)}),this.addRule("shape.create",function(n){var e=n.shape,t=n.target;return BO(e,t)}),this.addRule("shape.resize",function(n){var e=n.shape;return O(e,"dmn:TextAnnotation")})};Or.prototype.canConnect=Ax;Or.prototype.canCreate=BO;Or.prototype.canMove=NO;function Ax(n,e){if(!n||LO(n)||!e||LO(e))return null;if(n===e)return!1;if(O(n,"dmn:BusinessKnowledgeModel")&&We(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")&&We(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 BO(n,e){return We(n,["dmn:BusinessKnowledgeModel","dmn:Decision","dmn:InputData","dmn:KnowledgeSource","dmn:TextAnnotation"])&&O(e,"dmn:Definitions")}function NO(n,e){return F(n)||(n=[n]),!!(!e||St(n,function(t){return We(t,["dmn:BusinessKnowledgeModel","dmn:Decision","dmn:InputData","dmn:KnowledgeSource","dmn:TextAnnotation","dmn:InformationRequirement","dmn:AuthorityRequirement","dmn:KnowledgeRequirement","dmn:Association"])})&&O(e,"dmn:Definitions"))}function LO(n){return!!n.labelTarget}var $O={__depends__:[gn],__init__:["drdRules"],drdRules:["type",Or]};function kn(n){this._model=n}kn.$inject=["moddle"];kn.prototype._needsId=function(n){return We(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",fn(n,["x","y"]))};kn.prototype.createExtensionElements=function(){return this.create("dmn:ExtensionElements",{values:[]})};function Hi(n,e,t,i,r){r.invoke(se,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)}ce(Hi,se);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(We(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,Ht(i,n)):(n.$parent=null,Vn(i,n))}else throw new Error("unsupported")};function La(n,e){this._modeling=n,this._canvas=e}La.$inject=["modeling","canvas"];La.prototype.preExecute=function(n){var e=this._modeling,t=n.elements,i=n.alignment;k(t,function(r){var o={x:0,y:0};Te(i.left)?o.x=i.left-r.x:Te(i.right)?o.x=i.right-r.width-r.x:Te(i.center)?o.x=i.center-Math.round(r.width/2)-r.x:Te(i.top)?o.y=i.top-r.y:Te(i.bottom)?o.y=i.bottom-r.height-r.y:Te(i.middle)&&(o.y=i.middle-Math.round(r.height/2)-r.y),e.moveElements([r],o,r.parent)})};La.prototype.postExecute=function(n){};function Ba(n){this._modeling=n}Ba.$inject=["modeling"];Ba.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};Ba.prototype.postExecute=function(n){var e=n.hints||{};EF(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 EF(n,e){return Vd(n.outgoing,function(t){return t.target===e})}function Na(n,e){this._canvas=n,this._layouter=e}Na.$inject=["canvas","layouter"];Na.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};Na.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 Df(n){this._modeling=n}Df.$inject=["modeling"];Df.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){oe(f.x)||(f.x=0),oe(f.y)||(f.y=0)});var a=_e(e,function(f){return!f.hidden}),l=kt(a);k(e,function(f){Ue(f)&&(f.waypoints=qt(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=C1(e),u={};k(e,function(f){if(Ue(f)){u[f.id]=oe(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),Li(f)&&(h=Hu(h,["attach"])),u[f.id]=oe(i)?s.createShape(f,fn(f,["x","y","width","height"]),f.parent||t,i,h):s.createShape(f,fn(f,["x","y","width","height"]),f.parent||t,h)}),n.elements=Hd(u)};var jO=Math.round;function mi(n){this._canvas=n}mi.$inject=["canvas"];mi.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-jO(e.width/2),y:t.y-jO(e.height/2)}),this._canvas.addShape(e,i,r),e};mi.prototype.revert=function(n){var e=n.shape;return this._canvas.removeShape(e),e};function bs(n){mi.call(this,n)}ce(bs,mi);bs.$inject=["canvas"];var SF=mi.prototype.execute;bs.prototype.execute=function(n){var e=n.shape;return kF(e),e.labelTarget=n.labelTarget,SF.call(this,n)};var OF=mi.prototype.revert;bs.prototype.revert=function(n){return n.shape.labelTarget=null,OF.call(this,n)};function kF(n){["width","height"].forEach(function(e){typeof n[e]=="undefined"&&(n[e]=0)})}function _s(n,e){if(typeof e!="function")throw new Error("removeFn iterator must be a function");if(n){for(var t;t=n[0];)e(t);return n}}function ws(n,e){this._canvas=n,this._modeling=e}ws.$inject=["canvas","modeling"];ws.prototype.preExecute=function(n){var e=this._modeling,t=n.connection;_s(t.incoming,function(i){e.removeConnection(i,{nested:!0})}),_s(t.outgoing,function(i){e.removeConnection(i,{nested:!0})})};ws.prototype.execute=function(n){var e=n.connection,t=e.parent;return n.parent=t,n.parentIndex=rp(t.children,e),n.source=e.source,n.target=e.target,this._canvas.removeConnection(e),e.source=null,e.target=null,e};ws.prototype.revert=function(n){var e=n.connection,t=n.parent,i=n.parentIndex;return e.source=n.source,e.target=n.target,Ht(t.children,e,i),this._canvas.addConnection(e,t),e};function If(n,e){this._modeling=n,this._elementRegistry=e}If.$inject=["modeling","elementRegistry"];If.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 Cs(n,e){this._canvas=n,this._modeling=e}Cs.$inject=["canvas","modeling"];Cs.prototype.preExecute=function(n){var e=this._modeling,t=n.shape;_s(t.incoming,function(i){e.removeConnection(i,{nested:!0})}),_s(t.outgoing,function(i){e.removeConnection(i,{nested:!0})}),_s(t.children,function(i){Ue(i)?e.removeConnection(i,{nested:!0}):e.removeShape(i,{nested:!0})})};Cs.prototype.execute=function(n){var e=this._canvas,t=n.shape,i=t.parent;return n.oldParent=i,n.oldParentIndex=rp(i.children,t),e.removeShape(t),t};Cs.prototype.revert=function(n){var e=this._canvas,t=n.shape,i=n.oldParent,r=n.oldParentIndex;return Ht(i.children,t,r),e.addShape(t,i),t};function $a(n){this._modeling=n}$a.$inject=["modeling"];var FO={x:"y",y:"x"};$a.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 w={y:0};w[i]=g-s(b),w[i]&&(w[FO[i]]=0,e.moveElements([b],w,b.parent))}var u=t[0],f=a(t),h=t[f],d,p,m=0;k(t,function(g,b){var w,v,x;if(g.elements.length<2){b&&b!==t.length-1&&(o(g,g.elements[0]),m+=l(g.range));return}w=Fn(g.elements,i),v=w[0],b===f&&(v=w[a(w)]),x=s(v),g.range=null,k(w,function(_){if(c(x,_),g.range===null){g.range={min:_[i],max:_[i]+_[r]};return}o(g,_)}),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||IF(t,hi(i));return nk(t,i),n.oldProperties=o,n.changed=r,r};Ga.prototype.revert=function(n){var e=n.oldProperties,t=n.moddleElement,i=n.changed;return nk(t,e),i};function IF(n,e){return nt(e,function(t,i){return t[i]=n.get(i),t},{})}function nk(n,e){k(e,function(t,i){n.set(i,t)})}function Gn(n,e,t){this._canvas=n,this._drdRules=e,t.invoke(we,this)}ce(Gn,we);Gn.$inject=["canvas","drdRules","injector"];Gn.prototype.claimId=function(n,e){this._commandStack.execute("id.updateClaim",{id:n,element:e,claiming:!0})};Gn.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)};Gn.prototype.getHandlers=function(){var n=we.prototype.getHandlers.call(this);return n["id.updateClaim"]=Qa,n["element.updateLabel"]=Mx,n["element.updateProperties"]=Ka,n["element.updateModdleProperties"]=Ga,n};Gn.prototype.unclaimId=function(n,e){this._commandStack.execute("id.updateClaim",{id:n,element:e})};Gn.prototype.updateModdleProperties=function(n,e,t){this._commandStack.execute("element.updateModdleProperties",{element:n,moddleElement:e,properties:t})};Gn.prototype.updateProperties=function(n,e){this._commandStack.execute("element.updateProperties",{element:n,properties:e})};Gn.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||ae(e.source||n.source),e.connectionEnd||ae(e.target||n.target)]};var km=20;function Xa(n){this._connectionDocking=n}ce(Xa,Om);Xa.$inject=["connectionDocking"];Xa.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=mt(i,r);if(s||(s=ik(o[0],i)),a||(a=ik(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 ik(n,e){return n?n.original||n:ae(e)}function rk(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(rk(i)),o.push(rk(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 Zu(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 ok={__init__:["modeling","drdUpdater"],__depends__:[IO,$O,wa,vs,lt,Cm],drdFactory:["type",kn],drdUpdater:["type",Hi],elementFactory:["type",xr],modeling:["type",Gn],layouter:["type",Xa],connectionDocking:["type",Wi]};var LF=500,BF=1e3;function Tr(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"],LF,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)})}Tr.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})};Tr.prototype.updateConnectionOutline=function(n,e){var t=kt(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})};Tr.prototype.registerProvider=function(n,e){e||(e=n,n=BF),this._eventBus.on("outline.getProviders",n,function(t){t.providers.push(e)})};Tr.prototype._getProviders=function(){var n=this._eventBus.createEvent({type:"outline.getProviders",providers:[]});return this._eventBus.fire(n),n.providers};Tr.prototype.getOutline=function(n){var e,t=this._getProviders();return k(t,function(i){pe(i.getOutline)&&(e=e||i.getOutline(n))}),e};Tr.$inject=["eventBus","styles","elementRegistry"];var Rm=6;function Ff(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)})}Ff.prototype._updateMultiSelectionOutline=function(n){var e=this._canvas.getLayer("selectionOutline");ss(e);var t=n.length>1,i=this._canvas.getContainer();if(ie(i)[t?"add":"remove"]("djs-multi-select"),!!t){var r=NF(kt(n)),o=Q("rect");j(o,T({rx:3},r)),ie(o).add("djs-selection-outline"),K(e,o)}};Ff.$inject=["eventBus","canvas","selection"];function NF(n){return{x:n.x-Rm,y:n.y-Rm,width:n.width+Rm*2,height:n.height+Rm*2}}var Tm={__depends__:[lt],__init__:["outline","multiSelectionOutline"],outline:["type",Tr],multiSelectionOutline:["type",Ff]};var $F=500,jF=1250,FF=1500,Am=Math.round;function qF(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",FF,function(a){var l=a.context,c=a.shape,u=i.get().slice();u.indexOf(c)===-1&&(u=[c]),u=VF(u),T(l,{shapes:u,validatedShapes:u,shape:c})}),n.on("shape.move.start",jF,function(a){var l=a.context,c=l.validatedShapes,u;if(u=l.canExecute=o(c),!u)return!1}),n.on("shape.move.move",$F,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=gr(a);if(!l)throw new Error("must supply DOM mousedown event");return s(l,a.element)}});function s(a,l,c,u){if(Ae(c)&&(u=c,c=!1),!(l.waypoints||!l.parent)&&!ie(a.target).has("djs-hit-no-move")){var f=qF(l);return e.init(a,f,"shape.move",{cursor:"grabbing",autoActivate:c,data:{shape:l,context:u||{}}}),!0}}this.start=s}Mm.$inject=["eventBus","dragging","modeling","selection","rules"];function VF(n){var e=cr(n,"id");return _e(n,function(t){for(;t=t.parent;)if(e[t.id])return!1;return!0})}var sk=499,Px="djs-dragging",ak="drop-ok",lk="drop-not-ok",ck="new-parent",uk="attach-ok";function Pm(n,e,t,i){function r(l){var c=o(l),u=HF(c);return u}function o(l){var c=S1(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){[uk,ak,lk,ck].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,Px),l.allDraggedElements?l.allDraggedElements.push(c):l.allDraggedElements=[c]}n.on("shape.move.start",sk,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=Pw([f,o(u)]):f=o(u),k(f,function(m){e.addMarker(m,Px)}),c.allDraggedElements=f,c.differentParents=zF(u)}),n.on("shape.move.move",sk,function(l){var c=l.context,u=c.dragGroup,f=c.target,h=c.shape.parent,d=c.canExecute;f&&(d==="attach"?s(f,uk):c.canExecute&&h&&f.id!==h.id?s(f,ck):s(f,c.canExecute?ak:lk)),Nt(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,Px)}),f&&Ne(f)}),this.makeDraggable=a}Pm.$inject=["eventBus","canvas","styles","previewSupport"];function HF(n){var e=_e(n,function(t){return Ue(t)?me(n,aa({id:t.source.id}))&&me(n,aa({id:t.target.id})):!0});return e}function zF(n){return Iw(cr(n,function(e){return e.parent&&e.parent.id}))!==1}var fk={__depends__:[fo,lt,Tm,gn,mn,Oa],__init__:["move","movePreview"],move:["type",Mm],movePreview:["type",Pm]};var hk=` 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 `,dk=` 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 `,pk={width:135,height:46},mk={width:100,height:63};function Dx(n,e,t){return Q("path",{d:n,strokeWidth:2,transform:`translate(${e.x}, ${e.y})`,...t})}var Dm=5;function Ya(n,e){this._styles=e,n.registerProvider(this)}Ya.$inject=["outline","styles"];Ya.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")&&gk(n,"dmn:BusinessKnowledgeModel")?t=Dx(hk,{x:-6,y:-6},e):O(n,"dmn:KnowledgeSource")&&gk(n,"dmn:KnowledgeSource")&&(t=Dx(dk,{x:-6,y:-1.5},e)),t};Ya.prototype.updateOutline=function(n){return!!We(n,["dmn:InputData","dmn:BusinessKnowledgeModel","dmn:KnowledgeSource"])};function gk(n,e){var t;return e==="dmn:BusinessKnowledgeModel"?t=pk:e==="dmn:KnowledgeSource"&&(t=mk),n.width===t.width&&n.height===t.height}var yk={__depends__:[Tm],__init__:["outlineProvider"],outlineProvider:["type",Ya]};var xk=".djs-palette-toggle",bk=".entry",WF=xk+", "+bk,Ix="djs-palette-",UF="shown",Lx="open",vk="two-column",QF=1e3;function Ze(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()})}Ze.$inject=["eventBus","canvas"];Ze.prototype.registerProvider=function(n,e){e||(e=n,n=QF),this._eventBus.on("palette.getProviders",n,function(t){t.providers.push(e)}),this._rebuild()};Ze.prototype.getEntries=function(){var n=this._getProviders();return n.reduce(GF,{})};Ze.prototype._rebuild=function(){if(this._diagramInitialized){var n=this._getProviders();n.length&&(this._container||this._init(),this._update())}};Ze.prototype._init=function(){var n=this,e=this._eventBus,t=this._getParentContainer(),i=this._container=te(Ze.HTML_MARKUP);t.appendChild(i),ee(t).add(Ix+UF),xt.bind(i,WF,"click",function(r){var o=r.delegateTarget;if(no(o,xk))return n.toggle();n.trigger("click",r)}),q.bind(i,"mousedown",function(r){r.stopPropagation()}),xt.bind(i,bk,"dragstart",function(r){n.trigger("dragstart",r)}),e.on("canvas.resized",this._layoutChanged,this),e.fire("palette.create",{container:i})};Ze.prototype._getProviders=function(n){var e=this._eventBus.createEvent({type:"palette.getProviders",providers:[]});return this._eventBus.fire(e),e.providers};Ze.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(vk,r),s.toggle(Ix+vk,r),"open"in n&&(o.toggle(Lx,n.open),s.toggle(Ix+Lx,n.open)),i.fire("palette.changed",{twoColumn:r,open:this.isOpen()})};Ze.prototype._update=function(){var n=X(".djs-palette-entries",this._container),e=this._entries=this.getEntries();to(n),k(e,function(t,i){var r=t.group||"default",o=X("[data-group="+Ea(r)+"]",n);o||(o=te('
    '),Xe(o,"data-group",r),n.appendChild(o));var s=t.html||(t.separator?'
    ':'
    '),a=te(s);if(o.appendChild(a),!t.separator&&(Xe(a,"data-action",i),t.title&&Xe(a,"title",t.title),t.className&&KF(a,t.className),t.imageUrl)){var l=te("");Xe(l,"src",t.imageUrl),a.appendChild(l)}}),this.open()};Ze.prototype.trigger=function(n,e,t){var i,r,o=e.delegateTarget||e.target;return o?(i=Xe(o,"data-action"),r=e.originalEvent||e,this.triggerEntry(i,n,r,t)):e.preventDefault()};Ze.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(pe(s)){if(e==="click")return s(t,i)}else if(s[e])return s[e](t,i);t.preventDefault()}};Ze.prototype._layoutChanged=function(){this._toggleState({})};Ze.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 Ck={__depends__:[Im,Lm],__init__:["lassoTool"],lassoTool:["type",Mr]};var Nx=1500,Sk="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",Nx,function(l){if(cf(l))return s.activateMove(l.originalEvent,!0),!1}),a&&a.addListener(Nx,function(l){if(!(!Ek(l.keyEvent)||s.isActive())){var c=s._mouse.getLastMoveEvent();s.activateMove(c,!!c)}},"keyboard.keydown"),a&&a.addListener(Nx,function(l){!Ek(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!cf(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:Sk,data:{context:t||{}}})};Eo.prototype.activateHand=function(n,e,t){this._dragging.init(n,"hand",{trapClick:!1,autoActivate:e,cursor:Sk,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 Ek(n){return je("Space",n)}var Ok={__depends__:[Im,Lm],__init__:["handTool"],handTool:["type",Eo]};function Vf(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)}Vf.$inject=["palette","create","elementFactory","handTool","lassoTool","translate"];Vf.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 kk={__depends__:[$e,_k,Yp,Ck,Ok],__init__:["paletteProvider"],paletteProvider:["type",Vf]};var Nm=Math.max,$m=Math.min,JF=20;function Rk(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 oe(r)&&(i=(/top|left/.test(n)?$m:Nm)(i,r)),oe(o)&&(i=(/top|left/.test(n)?Nm:$m)(i,o)),i}function Tk(n,e){if(!e)return n;var t=G(n);return Sv({top:Bm("top",t,e),right:Bm("right",t,e),bottom:Bm("bottom",t,e),left:Bm("left",t,e)})}function Ak(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 Sv(a)}function Hf(n,e){return typeof n!="undefined"?n:JF}function eq(n,e){var t,i,r,o;return typeof e=="object"?(t=Hf(e.left),i=Hf(e.right),r=Hf(e.top),o=Hf(e.bottom)):t=i=r=o=Hf(e),{x:n.x-t,y:n.y-r,width:n.width+t+i,height:n.height+r+o}}function tq(n){return!(n.waypoints||n.type==="label")}function Mk(n,e){var t;if(n.length===void 0?t=_e(n.children,tq):t=n,t.length)return eq(kt(t),e)}var Pk=10;function Os(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=Rk(u,f,c),l.newBounds=Tk(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),!nq(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)})}Os.prototype.canResize=function(n){var e=this._rules,t=fn(n,["newBounds","shape","delta","direction"]);return e.allowed("shape.resize",t)};Os.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,$x(e,o),"resize",{autoActivate:!0,cursor:iq(o),data:{shape:e,context:r}})};Os.prototype.computeMinResizeBox=function(n){var e=n.shape,t=n.direction,i,r;return i=n.minDimensions||{width:Pk,height:Pk},r=Mk(e,n.childrenBoxPadding),Ak(t,e,i,r)};Os.$inject=["eventBus","rules","modeling","dragging"];function nq(n,e){return n.x!==e.x||n.y!==e.y||n.width!==e.width||n.height!==e.height}function $x(n,e){var t=ae(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 iq(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 Dk="djs-resizing",Ik="resize-not-ok",rq=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,Dk)),a.width>5&&j(l,{x:a.x,width:a.width}),a.height>5&&j(l,{y:a.y,height:a.height}),o.canExecute?ie(l).remove(Ik):ie(l).add(Ik)}function r(o){var s=o.shape,a=o.frame;a&&Ne(o.frame),e.removeMarker(s,Dk)}n.on("resize.move",rq,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,zf="djs-resizer",oq=["n","w","s","e","nw","ne","se","sw"];function Ui(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,it(r.addResizer,r))}),n.on("shape.changed",function(o){var s=o.element;t.isSelected(s)&&(r.removeResizers(),r.addResizer(s))})}Ui.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)};Ui.prototype._createResizer=function(n,e,t,i){var r=this._getResizersParent(),o=sq(i),s=Q("g");ie(s).add(zf),ie(s).add(zf+"-"+n.id),ie(s).add(zf+"-"+i),K(r,s);var a=Q("rect");j(a,{x:-qm/2+o.x,y:-qm/2+o.y,width:qm,height:qm}),ie(a).add(zf+"-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}),ie(l).add(zf+"-hit"),K(s,l),iC(s,e,t),s};Ui.prototype.createResizer=function(n,e){var t=$x(n,e),i=this._createResizer(n,t.x,t.y,e);this.makeDraggable(n,i,e)};Ui.prototype.addResizer=function(n){var e=this;Ue(n)||!this._resize.canResize({shape:n})||k(oq,function(t){e.createResizer(n,t)})};Ui.prototype.removeResizers=function(){var n=this._getResizersParent();ss(n)};Ui.prototype._getResizersParent=function(){return this._canvas.getLayer("resizers")};Ui.$inject=["eventBus","canvas","selection","resize"];function sq(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 Lk={__depends__:[gn,mn,Oa],__init__:["resize","resizePreview","resizeHandles"],resize:["type",Os],resizePreview:["type",jm],resizeHandles:["type",Ui]};var aq="reconnectStart",lq="reconnectEnd",cq=2e3;function Hm(n){n.on(["bendpoint.move.move","bendpoint.move.end"],cq,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||!We(r,["dmn:Decision","dmn:InputData"]))&&o!==s){var l=a===aq||a===lq,c=mt(o,s);l&&r===o?(uq(e,c),t.hints.connectionEnd=Nk(s,c)):l&&r===s&&(t.hints.connectionStart=Bk(o,c),fq(e,c))}})}Hm.$inject=["eventBus"];function Bk(n,e){var t=G(n),i=ae(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 Nk(n,e){var t=G(n),i=ae(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 uq(n,e){var t=n.context,i=t.source,r=Bk(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 fq(n,e){var t=n.context,i=t.target,r=Nk(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 hq=250;function zm(n){n.on(["connect.hover","connect.move","connect.end"],hq,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=mt(o,s);t.connectionStart=ae(o),r===o?t.connectionEnd=ae(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 yi(){this._targets={},this._snapOrigins={},this._snapLocations=[],this._defaultSnaps={}}yi.prototype.getSnapOrigin=function(n){return this._snapOrigins[n]};yi.prototype.setSnapOrigin=function(n,e){this._snapOrigins[n]=e,this._snapLocations.indexOf(n)===-1&&this._snapLocations.push(n)};yi.prototype.addDefaultSnap=function(n,e){var t=this._defaultSnaps[n];t||(t=this._defaultSnaps[n]=[]),t.push(e)};yi.prototype.getSnapLocations=function(){return this._snapLocations};yi.prototype.setSnapLocations=function(n){this._snapLocations=n};yi.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 dq=1250;function ks(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"],dq,function(r){var o=r.context,s=o.shape,a=o.snapContext,l=o.target;if(!(r.originalEvent&&Tt(r.originalEvent))&&!(br(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()})}ks.$inject=["elementRegistry","eventBus","snapping"];ks.prototype.initSnap=function(n){var e=this._elementRegistry,t=n.context,i=t.shape,r=t.snapContext;r||(r=t.snapContext=new yi);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}),Li(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};ks.prototype.addSnapTargetPoints=function(n,e,t){var i=this.getSnapTargets(e,t);return k(i,function(r){if(Li(r)){Li(e)&&n.add("mid",ms(r));return}if(Ue(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))}),!oe(e.x)||!oe(e.y)||this._elementRegistry.get(e.id)&&n.add("mid",ms(e)),n};ks.prototype.getSnapTargets=function(n,e){return Hp(e).filter(function(t){return!pq(t)})};function pq(n){return!!n.hidden}var mq=1250;function Rs(n,e){var t=this;n.on(["resize.start"],function(i){t.initSnap(i)}),n.on(["resize.move","resize.end"],mq,function(i){var r=i.context,o=r.shape,s=o.parent,a=r.direction,l=r.snapContext;if(!(i.originalEvent&&Tt(i.originalEvent))&&!br(i)){var c=l.pointsForTarget(s);c.initialized||(c=t.addSnapTargetPoints(c,o,s,a),c.initialized=!0),vq(a)&&yn(i,"x",i.x),xq(a)&&yn(i,"y",i.y),e.snap(i,c)}}),n.on(["resize.cleanup"],function(){e.hide()})}Rs.prototype.initSnap=function(n){var e=n.context,t=e.shape,i=e.direction,r=e.snapContext;r||(r=e.snapContext=new yi);var o=$k(t,i);return r.setSnapOrigin("corner",{x:o.x-n.x,y:o.y-n.y}),r};Rs.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",$k(e,i)),n};Rs.$inject=["eventBus","snapping"];Rs.prototype.getSnapTargets=function(n,e){return Hp(e).filter(function(t){return!gq(t,n)&&!Ue(t)&&!yq(t)&&!Li(t)})};function $k(n,e){var t=ae(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 gq(n,e){return n.host===e}function yq(n){return!!n.hidden}function vq(n){return n==="n"||n==="s"}function xq(n){return n==="e"||n==="w"}var bq=7,_q=1e3;function Qi(n){this._canvas=n,this._asyncHide=Ai(it(this.hide,this),_q)}Qi.$inject=["canvas"];Qi.prototype.snap=function(n,e){var t=n.context,i=t.snapContext,r=i.getSnapLocations(),o={x:br(n,"x"),y:br(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,bq),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];Ae(a)&&yn(n,s,a.originValue)})};Qi.prototype._createLine=function(n){var e=this._canvas.getLayer("snap"),t=Q("path");return j(t,{d:"M0,0 L0,0"}),ie(t).add("djs-snap-line"),K(e,t),{update:function(i){oe(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"})}}};Qi.prototype._createSnapLines=function(){this._snapLines={horizontal:this._createLine("horizontal"),vertical:this._createLine("vertical")}};Qi.prototype.showSnapLine=function(n,e){var t=this.getSnapLine(n);t&&t.update(e),this._asyncHide()};Qi.prototype.getSnapLine=function(n){return this._snapLines||this._createSnapLines(),this._snapLines[n]};Qi.prototype.hide=function(){k(this._snapLines,function(n){n.update()})};var jk={__init__:["createMoveSnapping","resizeSnapping","snapping"],createMoveSnapping:["type",ks],resizeSnapping:["type",Rs],snapping:["type",Qi]};var Fk={__depends__:[jk],__init__:["bendpointSnapping","connectSnapping"],bendpointSnapping:["type",Hm],connectSnapping:["type",zm]};function So(n){vr.call(this,n)}ce(So,vr);So.prototype._modelingModules=[CE,ME,LE,nS,rO,oO,aO,uO,dO,pO,vO,bO,_O,OO,MO,ok,fk,yk,kk,Lk,Fk];So.prototype._modules=[].concat(So.prototype._modules,So.prototype._modelingModules);function jx(n){let e={variables:[],rootElement:Bq(n)};for(let t=n;t;t=t.$parent)wq(t,e);return e.variables}function wq(n,e){Za(n,"dmn:Decision")?Cq(n,e):Za(n,"dmn:BusinessKnowledgeModel")?Eq(n,e):Za(n,"dmn:Expression")&&Dq(n,e)}function Cq(n,e){for(let t of n.get("informationRequirement"))Sq(t,e);for(let t of n.get("knowledgeRequirement"))Vk(t,e)}function Eq(n,e){for(let t of n.get("knowledgeRequirement"))Vk(t,e)}function Sq(n,e){let t=n.get("requiredInput");t&&Oq(t,e);let i=n.get("requiredDecision");i&&kq(i,e)}function Oq(n,e){let t=Fx(n,e.rootElement);if(!t)return;let i=t.get("name");i&&e.variables.push({name:i,origin:t})}function kq(n,e){let t=Fx(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&&Rq(o,r,e),e.variables.push(r)}function Rq(n,e,t){if(Za(n,"dmn:DecisionTable")){let i=n.get("output");Tq(i,e,t)}}function Tq(n,e,t){if(n.length===1){let r={...qk(n[0]),name:e.name};Object.assign(e,r);return}let i=n.map(qk);e.entries=i.filter(r=>!!r.name)}function qk(n){let e={name:n.name};return n.typeRef&&(e.detail=n.typeRef),e}function Vk(n,e){let t=n.get("requiredKnowledge");t&&Aq(t,e)}function Aq(n,e){let t=Fx(n,e.rootElement);t&&Za(t,"dmn:BusinessKnowledgeModel")&&Mq(t,e)}function Mq(n,e){let t=n.get("name");if(!t)return;let i={name:t,origin:n},r=n.get("encapsulatedLogic");r&&Pq(r,i),e.variables.push(i)}function Pq(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 Dq(n,e){Za(n,"dmn:FunctionDefinition")&&Iq(n,e)}function Iq(n,e){let t=n.get("formalParameter");for(let i of t)Lq(i,e)}function Lq(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 Bq(n){let e=n;for(;e.$parent;)e=e.$parent;return e}function Fx(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 Za(n,e){return n.$instanceOf(e)}var Wf=class{constructor(e){e.registerProvider(this)}getVariables(e,t){return e.concat(jx(t))}};Wf.$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 Ja={__init__:["dmnVariableProvider"],dmnVariableProvider:["type",Wf],variableResolver:["type",Um]};var Oo=class{constructor(e){T(this,e),Pr(this,"businessObject",{writable:!0})}},qx=class extends Oo{constructor(e){super(e),Pr(this,"rows",{enumerable:!0,value:this.rows||[]}),Pr(this,"cols",{enumerable:!0,value:this.cols||[]})}},ut=class extends Oo{constructor(e){super(e),Pr(this,"root",{writable:!0}),Pr(this,"cells",{enumerable:!0,value:this.cells||[]})}},ft=class extends Oo{constructor(e){super(e),Pr(this,"root",{writable:!0}),Pr(this,"cells",{enumerable:!0,value:this.cells||[]})}},ko=class extends Oo{constructor(e){super(e),Pr(this,"row",{writable:!0}),Pr(this,"col",{writable:!0})}},Nq={root:qx,row:ut,col:ft,cell:ko};function Hk(n,e){let t=Nq[n];if(!t)throw new Error("unknown type "+n);return new t(e)}function Pr(n,e,t){Object.defineProperty(n,e,t)}var Ts=class{constructor(){this._uid=12}create(e,t={}){return t.id||(t.id=e+"_"+this._uid++),Hk(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 el=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 Vx(this._elements)}forEach(e){Vx(this._elements).forEach(t=>e(t))}filter(e){return Vx(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")}};el.$inject=["eventBus"];function Vx(n){return Object.keys(n).map(function(e){return n[e]})}var tl=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 nl=class{constructor(e,t,i,r,o){let{container:s}=i;this._container=s,r.on("root.added",()=>{va(P(2,Qf,{injector:o}),s)}),r.on("root.remove",()=>{va(null,s)})}getContainer(){return this._container}};nl.$inject=["changeSupport","components","config.renderer","eventBus","injector"];var Qm={__init__:["changeSupport","components","renderer"],changeSupport:["type",tl],components:["type",Uf],renderer:["type",nl]};var il=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")}};il.$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=>Bw(t,e):t=>t}Xm.$inject=["config.throttle"];var zk={__depends__:[Qm],__init__:["elementFactory","sheet"],elementFactory:["type",Ts],elementRegistry:["type",el],eventBus:["type",st],sheet:["type",il],throttle:["factory",Xm]};var Kf=class{constructor(e={}){let{injector:t}=e;if(!t){let{modules:i,config:r}=this._init(e);t=jq(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 jq(n,e){let t=[{config:["value",n]},zk].concat(e||[]),i=new os(t);return i.init(),i}var Wk=Kf;function Ym(n){if(!n)return"";let e=n.id?` id="${n.id}"`:"";return`<${n.$type}${e} />`}function Hx(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 Uk(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 Hx(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 Fq(){return{elements:[],index:{}}}function Qk(n,e){let{elements:t,index:i}=n;return i[e]?n:{elements:[...t,e],index:{...i,[e]:!0}}}function qq(n,e){return n.elements.join(e)}function Ro(...n){let e=Fq();return n.forEach(function(t){let i=typeof t;i==="string"&&t.length>0?e=Qk(e,t):i==="object"&&t!==null&&Object.keys(t).forEach(function(r){t[r]&&(e=Qk(e,r))})}),qq(e," ")}function xe(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 zx(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 Wt(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]=zx(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 Kk={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)}},Gf=Kk;Kk.$inject=["eventBus"];var Xf=class extends L{constructor(e,t){super(e,t),Wt(this,Gf),xe(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 Xf{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 Gk={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})))}},vi=Gk;Gk.$inject=["components"];var Xk=400,To=class extends L{constructor(t,i){super(t,i);M(this,"onElementsChanged",()=>{this.forceUpdate()});Wt(this,vi),xe(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")||Xk)+"px";return y(1,"th","annotation header",[this.slotFills({type:"cell-inner",context:{cellType:"annotations",col:this.sheet.getRoot(),minWidth:Xk}}),this.translate("Annotations")],0,{style:{width:r}})}};To.$inject=["changeSupport","sheet","translate"];function Wx(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 Wx})}Jm.$inject=["components"];var Yk={__init__:["annotationsProvider"],annotationsProvider:["type",Jm]};function Yf(n,e){return T({id:n.id,type:n.$type,businessObject:n},e)}var rl=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(Yf(e)),this._sheet.setRoot(t);else if(O(e,"dmn:InputClause"))t=this._elementFactory.createCol(Yf(e)),this._sheet.addCol(t);else if(O(e,"dmn:OutputClause"))t=this._elementFactory.createCol(Yf(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(Yf(r)));t=this._elementFactory.createRow(T(Yf(e),{cells:i})),this._sheet.addRow(t)}return this._eventBus.fire("dmnElement.added",{element:t}),t}};rl.$inject=["elementFactory","eventBus","sheet"];var Zk={__depends__:[$e],tableImporter:["type",rl]};var Jk={__depends__:[Zk,Qm]};var Zf=class extends L{constructor(t,i){super(t,i);M(this,"onElementsChanged",()=>{this.forceUpdate()});Wt(this,vi),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=ze(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},Vq)}),o.map((s,a)=>this.slotFill({type:"cell",context:{cellType:"output-header",output:s,index:a,outputsLength:o.length},key:s.id},Hq)),this.slotFills({type:"cell",context:{cellType:"after-label-cells"}})],0),2)}};function Vq(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 Hq(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",()=>Zf)}eg.$inject=["components"];var eR={__init__:["decisionTableHeadProvider"],decisionTableHeadProvider:["type",eg]};var ol=class extends L{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),xe(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")||zq;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)}};ol.$inject=["sheet","components"];function zq(){return null}var Wq=500,sl=class{constructor(e){e.onGetComponent("table.before",Wq,()=>ol)}};sl.$inject=["components"];var tR={__init__:["decisionTableProperties"],decisionTableProperties:["type",sl]};var Jf=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 al=class{constructor(e){e.onGetComponent("cell",({cellType:t})=>{if(t==="before-rule-cells")return Jf})}};al.$inject=["components"];var nR={__init__:["decisionRuleIndices"],decisionRuleIndices:["type",al]};var Uq=[{label:"FEEL",value:"feel"}],ll=class{constructor(e){this._injector=e;let t=e.get("config.expressionLanguages")||{};this._config={options:Uq,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 me(this.getAll(),t=>e===t.value)}};ll.$inject=["injector"];var Ut={__init__:["expressionLanguages"],expressionLanguages:["type",ll]};var cl=class{constructor(e){this._feelLanguageContext=e}getConfig(){return this._feelLanguageContext}};cl.$inject=["config.feelLanguageContext"];var Xn={__init__:["feelLanguageContext"],feelLanguageContext:["type",cl]};var eh=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 th=class extends L{constructor(e,t){super(e,t),Wt(this,vi)}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 nh=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 ul=class{constructor(e){e.onGetComponent("table.body",()=>eh),e.onGetComponent("row",({rowType:t})=>{if(t==="rule")return th}),e.onGetComponent("cell",({cellType:t})=>{if(t==="rule")return nh})}};ul.$inject=["components"];var tg={__depends__:[Ut,Xn],__init__:["decisionRules"],decisionRules:["type",ul]};var ih=[{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 fl=class extends L{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),xe(this)}getRoot(){return this.sheet.getRoot()}render(){let e=this.getRoot(),t=e.businessObject,{aggregation:i,hitPolicy:r}=t,o=me(ih,s=>Qq(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)})}};fl.$inject=["sheet"];function Qq(n,e){return n.hitPolicy===e.hitPolicy&&n.aggregation===e.aggregation}function ng(n){n.onGetComponent("hit-policy",()=>fl)}ng.$inject=["components"];var iR={__init__:["hitPolicyProvider"],hitPolicyProvider:["type",ng]};var rh=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 hl=class{constructor(e,t,i,r){this._injector=i,this._sheet=r,e.onGetComponent("table.before",()=>{if(this.canViewDrd())return rh}),t.on("showDrd",()=>{let o=i.get("_parent",!1),s=r.getRoot(),a=rR(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=rR(t);return!!e.getView(i)}};hl.$inject=["components","eventBus","injector","sheet"];function rR(n){let{businessObject:e}=n;return e?e.$parent.$parent:void 0}var oR={__init__:["viewDrd"],viewDrd:["type",hl]};var dl=class{constructor(e){e.onGetComponent("table.before",()=>co)}};dl.$inject=["components"];var sR={__init__:["poweredBy"],poweredBy:["type",dl]};var Ao=class n extends Wk{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,Uk(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:[sR,...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",{}),He(e))}destroy(){super.destroy(),this.detach()}getModules(){return n._getModules()}static _getModules(){return[Yk,Jk,$e,eR,tR,nR,tg,iR,oR]}static _createContainer(){return te('
    ')}};var pl=class extends L{constructor(t,i){super(t,i);M(this,"handleClick",t=>{t.stopPropagation(),this.addRule(t.target.dataset.colIndex)});xe(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;opl),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])})}};ml.$inject=["components","editorActions","eventBus","selection"];var gl=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){Pe(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}};gl.$inject=["elementRegistry","eventBus","renderer"];var yl=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()})}};yl.$inject=["elementRegistry","eventBus","renderer","selection"];var Mo={__init__:["selection","selectionBehavior"],selection:["type",gl],selectionBehavior:["type",yl]};function Kq(n,e,t){return(e=Gq(e))in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function Gq(n){var e=Xq(n,"string");return typeof e=="symbol"?e:e+""}function Xq(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 aR=["click","dblclick","contextmenu","mousedown","mouseup","mouseenter","mouseleave","mouseout","mouseover","mousemove","focusin","focusout","drag","dragstart","dragend","dragover","dragenter","dragleave","drop"],vl=class{constructor(e,t){Kq(this,"_handleEvent",i=>{let{target:r,type:o}=i,s=Yq(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(aR)}),t.on("table.destroy",()=>{this._removeEventListeners(aR)})}_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)})}};vl.$inject=["config.renderer","eventBus"];function Yq(n){return Me(n,"[data-element-id]",!0)}var xl={__init__:["interactionEvents"],interactionEvents:["type",vl]};var Zx=Mw(cR());function Zq(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Qx,uR;function Jq(){if(uR)return Qx;uR=1,Qx=n;function n(e,t){return e^t}return Qx}var Kx,fR;function e5(){if(fR)return Kx;fR=1;var n=/\b(Array|Date|Object|Math|JSON)\b/g;Kx=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},Gx}var n5=t5(),dR=Zq(n5),Yn=window.getSelection();function Yx(n){Yn==null||Yn.removeAllRanges(),Yn==null||Yn.addRange(n)}function pR(){return Yn}function i5(n){if(!(Yn!=null&&Yn.rangeCount))return null;var e=Yn.focusNode;return ig(e)&&(e=e.parentNode),n==e||n.contains(e)}function rg(n,e){var t=r5(n,e);Yx(t)}function bl(n){if(!i5(n))return null;var e=Yn.getRangeAt(0),t=e.startContainer,i=e.endContainer,r=e.startOffset,o=e.endOffset,s=dR(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)||Xx(a)&&i===a));){if(c||(Xx(a)||l&&l.nextSibling==a&&(mR(a)||gR(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 r5(n,e){for(var t=e.start,i=e.end,r=document.createRange(),o=dR(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||(Xx(s)||s.previousSibling&&(mR(s)||gR(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 Xx(n){return n.nodeType===1&&n.nodeName==="BR"}function mR(n){return n.nodeType===1&&n.nodeName==="DIV"}function gR(n){return n.nodeType===1&&n.nodeName==="P"}var o5="[contenteditable]",s5="[data-element-id]";function oh(n){return n.getAttribute("data-element-id")}function yR(n){let e=n.getAttribute("data-coords");if(!e)return null;let[t,i]=e.split(":");return{row:t,col:i}}function vR(n,e){let t=`${n.row}:${n.col}`;return X(`[data-coords="${(0,Zx.default)(t)}"]`,e)}function Ki(n,e){return X(`[data-element-id="${(0,Zx.default)(n)}"]`,e)}function xR(n){return Me(n,".no-deselect",!0)}function sh(n){return Me(n,s5,!0)}function Jx(n){let e=o5;return no(n,e)?n:X(e,n)}function bR(n){let e=Jx(n);if(!e||!document.body.contains(e)||document.activeElement===e)return;e.focus();let t=bl(e);(!t||t.end===0)&&window.getSelection().setPosition(e.firstChild,e.firstChild.length)}var e0=500,a5={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(xR(d))return;let p=sh(d),m=p&&oh(p),g=!h.defaultPrevented;f(m,g)}function c(h){let d=oh(h.target),p=!h.defaultPrevented;return h.stopPropagation(),f(d,p)}function u(h){let d=oh(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",e0,l),e.on("cell.focusin",e0,c),e.on("cell.focusout",e0,u),e.on("cellSelection.changed",function(h){let{elementId:d,selection:p}=h,m=Ki(d,o);p.focussed&&m&&bR(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 a5))throw new Error("direction must be any of { above, below, left, right }");var d=Ki(s,o);let p=yR(d);if(!p)return!1;let m=l5(p,h),g=vR(m,o);if(!g)return!1;let b=oh(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 l5(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__:[xl,Mo],__init__:["cellSelection"],cellSelection:["type",og]};function As(){}As.prototype.get=function(){return this._data};As.prototype.set=function(n){this._data=n};As.prototype.clear=function(){var n=this._data;return delete this._data,n};As.prototype.isEmpty=function(){return!this._data};var sg={clipboard:["type",As]};var t0=2e3,_l=class extends Vi{constructor(e,t){super(e),this._sheet=t}init(){this.addRule("col.move",t0,({col:e,index:t})=>{let{businessObject:i}=this._sheet.getRoot(),{input:r}=i;return ne(e)?t=r.length}),this.addRule("col.remove",t0,({col:e})=>{let{cols:t}=this._sheet.getRoot();return Se(e)?t.filter(i=>Se(i)).length>1:!0}),this.addRule("paste",t0,({data:e,target:t})=>{if(!e||!t)return!1;let{root:i}=e;return t instanceof ut?this.canPasteRows(i):t instanceof ft?this.canPasteCols(i,t):!1})}canPasteRows(e){let{cols:t}=this._sheet.getRoot();return St(e,i=>i.type!=="row"||i.cells.length!==t.length?!1:St(i.cells,(r,o)=>ne(t[o])?r.businessObject.$type==="dmn:UnaryTests":r.businessObject.$type==="dmn:LiteralExpression"))}canPasteCols(e,t){let{rows:i}=this._sheet.getRoot();return St(e,r=>r.type!=="col"||r.cells.length!==i.length?!1:ne(t)?r.businessObject.$type==="dmn:InputClause":r.businessObject.$type==="dmn:OutputClause")}};_l.$inject=["eventBus","sheet"];var _R={__depends__:[gn]};var wl={__depends__:[_R],__init__:["decisionTableModelingRules"],decisionTableModelingRules:["type",_l]};var Cl=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 ut?this._modeling.removeRow(i):i instanceof ft&&this._modeling.removeCol(i)})}revert(e){let{oldData:t}=e;return this._clipboard.set(t),this._sheet.getRoot()}};Cl.$inject=["clipboard","modeling","sheet"];var c5=[d5,p5],u5=[x5,v5];function ag(n,e,t){return t=t||c5,e=e||{},F(n)?f5(n,e,t):wR(n,e,t)}function f5(n,e,t){return nt(n,(i,r)=>{var o=i.descriptorCache,s=i.root;let{root:a,descriptorCache:l}=wR(r,o,t);return{root:[...s,a],descriptorCache:{...o,...l}}},{root:[],descriptorCache:e})}function wR(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=h5(n,r,t,{...e,elements:o});return{root:a.root,descriptorCache:{...a.descriptorCache,elements:{...a.descriptorCache.elements,[i]:a.root}}}}function h5(n,e,t,i){function r(o,s){return ag(o,s,t)}return nt(t,function(o,s){return s(n,o.root,o.descriptorCache,r)},{root:e,descriptorCache:i})}function d5(n,e,t,i){var r=t,o={...e,type:m5(n)};if(n instanceof ut||n instanceof ft){let s=i(n.cells,r);o.cells=s.root,r=s.descriptorCache}return{root:o,descriptorCache:r}}function p5(n,e,t){var i=n.businessObject;if(!i)return{root:e,descriptorCache:t};var r=n0(i,t);return{root:{...e,businessObject:r.root},descriptorCache:r.descriptorCache}}function m5(n){if(n instanceof ut)return"row";if(n instanceof ft)return"col";if(n instanceof ko)return"cell";throw new Error("cannot deduce element type: #"+n.id)}function n0(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=n0(l,e);return e=c.descriptorCache,c.root})),a.$type){let l=n0(a,e);e=l.descriptorCache,a=l.root}o[s.name]=a}}),{root:o,descriptorCache:e}}function r0(n,e,t){return t=t||u5,e=e||{},F(n.root)?g5(n,e,t):CR(n,e,t)}function g5(n,e,t){let i=n.root,r=n.descriptorCache;return nt(i,(o,s)=>{var a=o.reviveCache,l=o.root;let{root:c,reviveCache:u}=CR({root:s,descriptorCache:r},a,t);return{root:[...l,c],reviveCache:u}},{root:[],reviveCache:e})}function CR(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=y5(n,a,t,{...e,elements:o});return{root:l.root,reviveCache:{...l.reviveCache,elements:{...l.reviveCache.elements,[r]:l.root}}}}function y5(n,e,t,i){function r(o,s){return r0(o,s,t)}return nt(t,function(o,s){return s(n,o.root,o.reviveCache,r)},{root:e,reviveCache:i})}function v5(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=b5(r),l=new a(s);return l instanceof ut?l.cells.forEach(c=>{c.row=l}):l instanceof ft&&l.cells.forEach(c=>{c.col=l}),{root:l,reviveCache:t}}function x5(n,e,t){var i=n.root.businessObject;if(!i)return{root:e,reviveCache:t};var r=i0({root:i,descriptorCache:n.descriptorCache},t);return{root:{...e,businessObject:r.root},reviveCache:r.reviveCache}}function b5(n){switch(n.type){case"row":return ut;case"cell":return ko;case"col":return ft;default:throw new Error("unknown element type: #"+n.type)}}function i0(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={};hi(t).forEach(c=>{let u,f;t[c].$type?(f=i0({root:t[c]},e),u=f.root,e=f.reviveCache,r=e.boCache||{}):F(t[c])?u=t[c].map(h=>(f=i0({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 El=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=r0(r.elements,{_dmnFactory:this._dmnFactory,_keepIds:r.keepIds,_model:this._model}).root;if(t instanceof ut){let a=o.rows.indexOf(t);if(a===-1)return;s.forEach(l=>{i&&a++,this._modeling.addRow(l,a)})}else if(t instanceof ft){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){}};El.$inject=["clipboard","dmnFactory","elementFactory","elementRegistry","eventBus","moddle","modeling","sheet"];var Sl=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",Cl),t.registerHandler("paste",El)}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){}};Sl.$inject=["clipboard","commandStack","eventBus","modeling","sheet","rules"];var lg={__depends__:[sg,wl],__init__:["copyCutPaste"],copyCutPaste:["type",Sl]};var Ol=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)}};Ol.$inject=["copyCutPaste","editorActions","modeling","selection","cellSelection","sheet"];var ER="is not a registered action",_5="is already registered",kl=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 o0(e,ER);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 o0(e,_5);this._actions[e]=t}unregister(e){if(!this.isRegistered(e))throw o0(e,ER);this._actions[e]=void 0}isRegistered(e){return!!this._actions[e]}};kl.$inject=["commandStack","eventBus","modeling","selection"];function o0(n,e){return new Error(n+" "+e)}var cg={__depends__:[Mo],__init__:["editorActions"],editorActions:["type",kl]};var Zn={__depends__:[Po,lg,cg,Mo],__init__:["decisionTableEditorActions"],decisionTableEditorActions:["type",Ol]};var SR={__depends__:[Zn],__init__:["addRule"],addRule:["type",ml]};var TR=Mw(kR());function RR(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=E5(e,t);return s&&(s.type==="remove"?r=s.newStart:r=s.newEnd),S5(r)}function E5(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&&!R5(t)||this.props.singleLine)return;t.stopPropagation(),k5(),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&&bl(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?RR(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,TR.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 O5(){return document.createElement("br")}function ug(n){return n.innerText.replace(/\n$/,"")}function k5(){var n=pR(),e=n.getRangeAt(0);if(e){var t=e.cloneRange(),i=O5();t.deleteContents(),t.insertNode(i),t.setStartAfter(i),t.setEndAfter(i),Yx(t)}}function R5(n){return n.metaKey||n.ctrlKey}var sn=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 Rl=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)});xe(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,s0,{label:this.translate("Annotation"),ctrlForNewline:!0,className:"annotation-editor",onChange:this.setAnnotationValue,value:r})})}};Rl.$inject=["changeSupport","modeling","translate"];var s0=class extends sn{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 Rl})}fg.$inject=["components"];var T5=300;function hg(n){return function(t){if(n!==!1){var i=oe(n)?n:T5;return Ai(t,i)}else return t}}hg.$inject=["config.debounceInput"];var Qt={debounceInput:["factory",hg]};var AR={__depends__:[Qt],__init__:["annotationsProvider"],annotationsProvider:["type",fg]};function Ms(n,e,t){return(e=A5(e))in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function A5(n){var e=M5(n,"string");return typeof e=="symbol"?e:e+""}function M5(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 P5={position:"absolute"},Tl=class extends L{constructor(e,t){super(e,t),Ms(this,"open",({position:i,context:r})=>{this.close(),this.setState({isOpen:!0,position:i||{x:0,y:0},context:r||{}})}),Ms(this,"close",()=>{this.state.isOpen&&this.setState({context:void 0,isOpen:!1,position:{x:0,y:0}})}),Ms(this,"triggerClose",()=>{this.eventBus.fire("contextMenu.close")}),this.state={isOpen:!1,position:{x:0,y:0}},xe(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}};Tl.$inject=["eventBus","components"];var dg=class extends L{constructor(e,t){super(e,t),Ms(this,"onGlobalMouseDown",i=>{this.checkClose(i.target)}),Ms(this,"onGlobalKey",i=>{var r=i.which;(r===13||r===27)&&(i.stopPropagation(),i.preventDefault(),this.close())}),Ms(this,"onFocusChanged",i=>{this.checkClose(i.target)}),Ms(this,"setNode",i=>{this.node=i;let{autoFocus:r}=this.props;i&&(this.updatePosition(),r&&I5(i))}),xe(this)}close(){let{onClose:e}=this.props;pe(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}=L5(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:MR(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:MR(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,P5,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 MR(n,e,t){return Math.max(e,Math.min(t,n))}var D5=` input[type=text], input[type=number], input[type=button], input[type=submit], [contenteditable], [tabindex], a[href], textarea, button `;function I5(n){var e=X(D5,n);e&&(e.focus(),e.selectionStart&&e.type==="text"?e.selectionStart=1e5:"contentEditable"in e&&rg(e,{start:1e5,end:1e5}))}function L5(n){let e=Me(n,".tjs-container");if(!e)return{scrollTop:0,scrollLeft:0};let{scrollLeft:t,scrollTop:i}=e;return{scrollTop:i,scrollLeft:t}}var Al=class{constructor(e,t,i){this._eventBus=t,e.onGetComponent("table.before",()=>Tl)}open(e,t){this._eventBus.fire("contextMenu.open",{position:e,context:t})}close(){this._eventBus.fire("contextMenu.close")}};Al.$inject=["components","eventBus","renderer"];var Kt={__init__:["contextMenu"],contextMenu:["type",Al]};function Dr(n){return n.altKey?!1:n.ctrlKey||n.metaKey}function Ir(n){return n.shiftKey}var Ml=class{constructor(e,t,i,r,o,s,a){M(this,"_clearClipboard",()=>{this._clipboard.clear()});M(this,"_registerBindings",()=>{[(r,o)=>{if(Dr(o)&&r===67){let s=this._getSelectedCell();return s?(Ir(o)?this._editorActions.trigger("copy",{element:s.col}):this._editorActions.trigger("copy",{element:s.row}),!0):void 0}},(r,o)=>{if(Dr(o)&&r===88){let s=this._getSelectedCell();return s?(Ir(o)?this._editorActions.trigger("cut",{element:s.col}):this._editorActions.trigger("cut",{element:s.row}),!0):void 0}},(r,o)=>{let s;if(Dr(o)&&r===86){let a=this._getSelectedCell();if(!a)return;Ir(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=Ki(e,i),o=Jx(r);if(document.activeElement!==o)return;let s=bl(r);if(!(s&&s.start!==s.end))return t}};Ml.$inject=["injector","eventBus","clipboard","cellSelection","elementRegistry","editorActions","renderer"];var PR={__depends__:[sg,Po],__init__:["copyCutPasteKeyBindings"],copyCutPasteKeyBindings:["type",Ml]};var Pl=class extends L{constructor(t,i){super(t,i);M(this,"onClick",t=>{this.editorActions.trigger("addInput")});xe(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")})}};Pl.$inject=["editorActions","translate"];var Dl=class extends L{constructor(t,i){super(t,i);M(this,"onClick",t=>{this.editorActions.trigger("addInput")});xe(this)}render(){return y(1,"td","input-cell create-inputs",Z("-"),2,{onClick:this.onClick,title:this.translate("Add input")})}};Dl.$inject=["editorActions","translate"];var B5=500,Il=class{constructor(e,t){e.onGetComponent("cell",B5,({cellType:i})=>{let{businessObject:r}=t.getRoot();if(!(r.input&&r.input.length)){if(i==="before-label-cells")return Pl;if(i==="before-rule-cells")return Dl}})}};Il.$inject=["components","sheet"];var DR={__depends__:[Zn],__init__:["createInputsProvider"],createInputsProvider:["type",Il]};var N5=["string","boolean","number","date","time","dateTime","dayTimeDuration","yearMonthDuration","Any"],Ll=class{constructor(e){this._dataTypes=e||N5}getAll(){return this._dataTypes}};Ll.$inject=["config.dataTypes"];var Gi={__init__:["dataTypes"],dataTypes:["type",Ll]};var Bl=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=$5(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}};Bl.$inject=["components","contextMenu","clipboard","editorActions","eventBus","elementRegistry","modeling","selection","sheet","rules","translate"];function $5(n){return n instanceof ko}var j5=["row.add","row.remove","col.add","col.remove"],Nl=class{constructor(e,t){t.on("commandStack.executed",({command:i})=>{j5.indexOf(i)!==-1&&e.close()}),t.on("commandStack.reverted",()=>{e.close()})}};Nl.$inject=["contextMenu","eventBus"];var $l=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=>{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(dn(".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];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&&F5(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())}};$l.$inject=["eventBus"];function F5(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 IR={__depends__:[Zn,Kt,wl],__init__:["decisionTableContextMenu","contextMenuCloseBehavior","contextMenuKeyboard"],decisionTableContextMenu:["type",Bl],contextMenuCloseBehavior:["type",Nl],contextMenuKeyboard:["type",$l]};var ah=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()});Wt(this,vi),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 Ct=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 lh=class extends L{constructor(e,t){super(e,t),this.translate=t.injector?t.injector.get("translate"):V5,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,Ct,{label:this.translate("Output name"),className:"ref-output-name",value:e||"",onInput:this.setName})],4)],4)}};function V5(n){return n}var jl=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={},xe(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,lh,{name:this.getValue("name"),label:this.getValue("label"),onChange:this.handleChange})}};jl.$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 Fl=class{constructor(e,t,i,r){e.onGetComponent("cell",({cellType:o})=>{if(o==="output-header")return ah}),e.onGetComponent("context-menu",(o={})=>{if(o.contextMenuType==="output-edit")return jl}),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=Me(a,"th",!0),{left:c,top:u}=l.getBoundingClientRect(),f=H5(l);t.open({x:c,y:u,align:"bottom-right"},{contextMenuType:"output-edit",output:s,offset:f})})}};Fl.$inject=["components","contextMenu","eventBus","renderer"];function H5(n){if(!no(n,".output-cell + .output-cell"))return{x:-1,y:0}}var ch=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()});Wt(this,vi),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 l0=[],$R=[];(()=>{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=$R[i])e=i+1;else return!0;if(e==t)return!1}}function LR(n){return n>=127462&&n<=127487}var BR=8205;function jR(n,e,t=!0,i=!0){return(t?FR:W5)(n,e,i)}function FR(n,e,t){if(e==n.length)return e;e&&qR(n.charCodeAt(e))&&VR(n.charCodeAt(e-1))&&e--;let i=a0(n,e);for(e+=NR(i);e=0&&LR(a0(n,s));)o++,s-=2;if(o%2==0)break;e+=2}else break}return e}function W5(n,e,t){for(;e>0;){let i=FR(n,e-2,t);if(i=56320&&n<57344}function VR(n){return n>=55296&&n<56320}function NR(n){return n<65536?1:2}var ye=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]=Wl(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),Vl.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]=Wl(this,e,t);let i=[];return this.decompose(e,t,i,0),Vl.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 Is(this),o=new Is(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 Is(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):Vl.from(An.split(e,[]))}},An=class n extends ye{constructor(e,t=U5(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 u0(r,a,i,s);r=a+1,i++}}decompose(e,t,i,r){let o=e<=0&&t>=this.length?this:new n(HR(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]=Wl(this,e,t);let r=vg(this.text,vg(i.text,HR(this.text,0,e)),t),o=this.length+i.length-(t-e);return r.length<=32?new n(r,o):Vl.from(n.split(r,[]),o)}sliceString(e,t=this.length,i=` `){[e,t]=Wl(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}},Vl=class n extends ye{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]=Wl(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]=Wl(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)}};ye.empty=new An([""],0);function U5(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 Is(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"&&(ye.prototype[Symbol.iterator]=function(){return this.iter()},Is.prototype[Symbol.iterator]=xg.prototype[Symbol.iterator]=bg.prototype[Symbol.iterator]=function(){return this});var u0=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 Wl(n,e,t){return e=Math.max(0,Math.min(n.length,e)),[e,Math.max(e,Math.min(n.length,t))]}function Mt(n,e,t=!0,i=!0){return jR(n,e,t,i)}function Q5(n){return n>=56320&&n<57344}function K5(n){return n>=55296&&n<56320}function ei(n,e){let t=n.charCodeAt(e);if(!K5(t)||e+1==n.length)return t;let i=n.charCodeAt(e+1);return Q5(i)?(t-55296<<10)+(i-56320)+65536:t}function C0(n){return n<=65535?String.fromCharCode(n):(n-=65536,String.fromCharCode((n>>10)+55296,(n&1023)+56320))}function Xi(n){return n<65536?1:2}var f0=/\r\n?|\n/,Et=(function(n){return n[n.Simple=0]="Simple",n[n.TrackDel=1]="TrackDel",n[n.TrackBefore=2]="TrackBefore",n[n.TrackAfter=3]="TrackAfter",n})(Et||(Et={})),Lr=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!=Et.Simple&&c>=e&&(i==Et.TrackDel&&re||i==Et.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)}},ln=class n extends Lr{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 h0(this,(t,i,r,o,s)=>e=e.replace(r,r+(i-t),s),!1),e}mapDesc(e,t=!1){return d0(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"?ye.of(d.split(i||f0)):d:ye.empty,m=p.length;if(f==h&&m==0)return;fs&&Gt(r,f-s,-1),Gt(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 d0(n,e,t,i=!1){let r=[],o=i?[]:null,s=new Ls(n),a=new Ls(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);Gt(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 Ls=class{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return t>=e.length?ye.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?ye.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)}},ql=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=>ql.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 GR(n,e){for(let t of n.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}var E0=0,W=class n{constructor(e,t,i,r,o){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=r,this.id=E0++,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:S0),!!e.static,e.enables)}of(e){return new Hl([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Hl(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Hl(e,this,2,t)}from(e,t){return t||(t=i=>i),this.compute([e],i=>t(i.field(e)))}};function S0(n,e){return n==e||n.length==e.length&&n.every((t,i)=>t===e[i])}var Hl=class{constructor(e,t,i,r){this.dependencies=e,this.facet=t,this.type=i,this.value=r,this.id=E0++}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)||p0(f,u)){let d=i(f);if(a?!zR(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 W?h.facet(g)===f.facet(g):g instanceof jt?h.field(g,!1)==f.field(g,!1):!0)||(a?zR(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 zR(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}},Ps={lowest:4,low:3,default:2,high:1,highest:0};function uh(n){return e=>new _g(e,n)}var Nr={highest:uh(Ps.highest),high:uh(Ps.high),default:uh(Ps.default),low:uh(Ps.low),lowest:uh(Ps.lowest)},_g=class{constructor(e,t){this.inner=e,this.prec=t}},Bs=class n{of(e){return new hh(this,e)}reconfigure(e){return n.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}},hh=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 X5(e,t,s))h instanceof jt?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,S0(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=>G5(g,p,d))}}let f=c.map(h=>h(a));return new n(e,s,f,a,l,o)}};function X5(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 hh&&t.delete(s.compartment)}if(r.set(s,a),Array.isArray(s))for(let c of s)o(c,a);else if(s instanceof hh){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 jt)i[a].push(s),s.provides&&o(s.provides,a);else if(s instanceof Hl)i[a].push(s),s.facet.extensions&&o(s.facet.extensions,Ps.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,Ps.default),i.reduce((s,a)=>s.concat(a))}function fh(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 XR=W.define(),m0=W.define({combine:n=>n.some(e=>e),static:!0}),YR=W.define({combine:n=>n.length?n[0]:void 0,static:!0}),ZR=W.define(),JR=W.define(),eT=W.define(),tT=W.define({combine:n=>n.length?n[0]:!1}),Mn=class{constructor(e,t){this.type=e,this.value=t}static define(){return new g0}},g0=class{of(e){return new Mn(this,e)}},y0=class{constructor(e){this.map=e}of(e){return new he(this,e)}},he=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 y0(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}};he.reconfigure=he.define();he.appendConfig=he.define();var $t=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&&GR(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]=="."))}};$t.time=Mn.define();$t.userEvent=Mn.define();$t.addToHistory=Mn.define();$t.remote=Mn.define();function Y5(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 $t?n=o:Array.isArray(o)&&o.length==1&&o[0]instanceof $t?n=o[0]:n=iT(e,zl(o),!1)}return n}function J5(n){let e=n.startState,t=e.facet(eT),i=n;for(let r=t.length-1;r>=0;r--){let o=t[r](n);o&&Object.keys(o).length&&(i=nT(i,v0(e,o,n.changes.newLength),!0))}return i==n?n:$t.create(e,n.changes,n.selection,i.effects,i.annotations,i.scrollIntoView)}var eV=[];function zl(n){return n==null?eV:Array.isArray(n)?n:[n]}var an=(function(n){return n[n.Word=0]="Word",n[n.Space=1]="Space",n[n.Other=2]="Other",n})(an||(an={})),tV=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,x0;try{x0=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function nV(n){if(x0)return x0.test(n);for(let e=0;e"\x80"&&(t.toUpperCase()!=t.toLowerCase()||tV.test(t)))return!0}return!1}function iV(n){return e=>{if(!/\S/.test(e))return an.Space;if(nV(e))return an.Word;for(let t=0;t-1)return an.Word;return an.Other}}var Ke=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(he.reconfigure)?(t=null,i=a.value):a.is(he.appendConfig)&&(t=null,i=zl(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(m0)?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=zl(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 ye?e.doc:ye.of((e.doc||"").split(t.staticFacet(n.lineSeparator)||f0)),r=e.selection?e.selection instanceof $?e.selection:$.single(e.selection.anchor,e.selection.head):$.single(0);return GR(r,i.length),t.staticFacet(m0)||(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(tT)}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(XR))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 iV(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=Mt(t,s,!1);if(o(t.slice(l,s))!=an.Word)break;s=l}for(;an.length?n[0]:4});Ke.lineSeparator=YR;Ke.readOnly=tT;Ke.phrases=W.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])}});Ke.languageData=XR;Ke.changeFilter=ZR;Ke.transactionFilter=JR;Ke.transactionExtender=eT;Bs.reconfigure=he.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 Jn=class{eq(e){return this==e}range(e,t=e){return dh.create(e,t,this)}};Jn.prototype.startSide=Jn.prototype.endSide=0;Jn.prototype.point=!1;Jn.prototype.mapMode=Et.TrackDel;function O0(n,e){return n==e||n.constructor==e.constructor&&n.eq(e)}var dh=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 b0(n,e){return n.from-e.from||n.value.startSide-e.value.startSide}var _0=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}}},Ie=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(b0)),this.isEmpty)return t.length?n.of(t):this;let a=new Eg(this,null,-1).goto(0),l=0,c=[],u=new Br;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 ph.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return ph.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=WR(s,a,i),c=new Ds(s,l,o),u=new Ds(a,l,o);i.iterGaps((f,h,d)=>UR(c,f,u,h,d,r)),i.empty&&i.length==0&&UR(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=WR(o,s),l=new Ds(o,a,0).goto(i),c=new Ds(s,a,0).goto(i);for(;;){if(l.to!=c.to||!w0(l.active,c.active)||l.point&&(!c.point||!O0(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 Ds(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 Br;for(let r of e instanceof dh?[e]:t?rV(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}};Ie.empty=new Ie([],[],null,-1);function rV(n){if(n.length>1)for(let e=n[0],t=1;t0)return n.slice().sort(b0);e=i}return n}Ie.empty.nextLayer=Ie.empty;var Br=class n{finishChunk(e){this.chunks.push(new _0(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(Ie.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=Ie.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}};function WR(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--)c0(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--)c0(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(),c0(this.heap,0)}}};function c0(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 Ds=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=ph.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=QR(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=QR(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 UR(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&&O0(n.point,t.point)&&w0(n.activeForPoint(n.to),t.activeForPoint(t.to))||o.comparePoint(a,p,n.point,t.point),u=!1):(u&&o.boundChange(a),p>a&&!w0(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 w0(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 QR(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=Mt(n,r)}return i===!0?-1:n.length}var oT=typeof Symbol=="undefined"?"__\u037C":Symbol.for("\u037C"),k0=typeof Symbol=="undefined"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),sT=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:{},ti=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=sT[oT]||1;return sT[oT]=e+1,"\u037C"+e.toString(36)}static mount(e,t,i){let r=e[k0],o=i&&i.nonce;r?o&&r.setNonce(o):r=new R0(e,o),r.mount(Array.isArray(t)?t:[t],e)}},aT=new Map,R0=class{constructor(e,t){let i=e.ownerDocument||e,r=i.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let o=aT.get(i);if(o)return e[k0]=o;this.sheet=new r.CSSStyleSheet,aT.set(i,this)}else this.styleTag=i.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[k0]=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:'"'},oV=typeof navigator!="undefined"&&/Mac/.test(navigator.platform),sV=typeof navigator!="undefined"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(bt=0;bt<10;bt++)$r[48+bt]=$r[96+bt]=String(bt);var bt;for(bt=1;bt<=24;bt++)$r[bt+111]="F"+bt;var bt;for(bt=65;bt<=90;bt++)$r[bt]=String.fromCharCode(bt+32),Ul[bt]=String.fromCharCode(bt);var bt;for(Sg in $r)Ul.hasOwnProperty(Sg)||(Ul[Sg]=$r[Sg]);var Sg;function lT(n){var e=oV&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||sV&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Ul:$r)[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:hT||/Mac/.test(cn.platform),windows:/Win/.test(cn.platform),linux:/Linux|X11/.test(cn.platform),ie:Jg,ie_version:qT?I0.documentMode||6:B0?+B0[1]:L0?+L0[1]:0,gecko:uT,gecko_version:uT?+(/Firefox\/(\d+)/.exec(cn.userAgent)||[0,0])[1]:0,chrome:!!T0,chrome_version:T0?+T0[1]:0,ios:hT,android:/Android\b/.test(cn.userAgent),webkit:fT,webkit_version:fT?+(/\bAppleWebKit\/(\d+)/.exec(cn.userAgent)||[0,0])[1]:0,safari:N0,safari_version:N0?+(/\bVersion\/(\d+(\.\d+)?)/.exec(cn.userAgent)||[0,0])[1]:0,tabSize:I0.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function bb(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 _b(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 aV(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 dT(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 lV(n){let e=Object.create(null);for(let t=0;t0?3e8:-4e8:t>0?1e8:-1e8,new Fs(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}=VT(e,t);i=(o?t?-3e8:-1:5e8)-1,r=(s?t?2e8:1:-6e8)+1}return new Fs(e,i,r,t,e.widget||null,!0)}static line(e){return new Oh(e)}static set(e,t=!1){return Ie.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};fe.none=Ie.empty;var Sh=class n extends fe{constructor(e){let{start:t,end:i}=VT(e);super(t?-1:5e8,i?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?bb(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&&_b(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)}};Sh.prototype.point=!1;var Oh=class n extends fe{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof n&&this.spec.class==e.spec.class&&_b(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)}};Oh.prototype.mapMode=Et.TrackBefore;Oh.prototype.point=!0;var Fs=class n extends fe{constructor(e,t,i,r,o,s){super(t,i,o,e),this.block=r,this.isReplace=s,this.mapMode=r?t<=0?Et.TrackBefore:Et.TrackAfter:Et.TrackDel}get type(){return this.startSide!=this.endSide?oi.WidgetRange:this.startSide<=0?oi.WidgetBefore:oi.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof n&&cV(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)}};Fs.prototype.point=!0;function VT(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 cV(n,e){return n==e||!!(n&&e&&n.compare(e))}function Yl(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 Jn{constructor(e,t){super(),this.tagName=e,this.attributes=t}eq(e){return e==this||e instanceof n&&this.tagName==e.tagName&&_b(this.attributes,e.attributes)}static create(e){return new n(e.tagName,e.attributes||Ng)}static set(e,t=!1){return Ie.of(e,t)}};$g.prototype.startSide=$g.prototype.endSide=-1;function kh(n){let e;return n.nodeType==11?e=n.getSelection?n:n.ownerDocument:e=n,e.getSelection()}function $0(n,e){return e?n==e||n.contains(e.nodeType!=1?e.parentNode:e):!1}function yh(n,e){if(!e.anchorNode)return!1;try{return $0(n,e.anchorNode)}catch{return!1}}function vh(n){return n.nodeType==3?Th(n,0,n.nodeValue.length).getClientRects():n.nodeType==1?n.getClientRects():[]}function xh(n,e,t,i){return t?pT(n,e,t,i,-1)||pT(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 pT(n,e,t,i,r){for(;;){if(n==t&&e==i)return!0;if(e==(r<0?0:qr(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?qr(n):0}else return!1}}function qr(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Rh(n,e){let t=e?n.left:n.right;return{left:t,right:t,top:n.top,bottom:n.bottom}}function uV(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 HT(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 fV(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=uV(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 w=u.getBoundingClientRect();({scaleX:p,scaleY:m}=HT(u,w)),h={left:w.left,right:w.left+u.clientWidth*p,top:w.top,bottom:w.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 zT(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 j0=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?qr(t):0),i,Math.min(e.focusOffset,i?qr(i):0))}set(e,t,i,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=i,this.focusOffset=r}},$s=null;z.safari&&z.safari_version>=26&&($s=!1);function WT(n){if(n.setActive)return n.setActive();if($s)return n.focus($s);let e=[];for(let t=n;t&&(e.push(t,t.scrollTop,t.scrollLeft),t!=t.ownerDocument);t=t.parentNode);if(n.focus($s==null?{get preventScroll(){return $s={preventScroll:!0},!0}}:void 0),!$s){$s=!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 QT(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=qr(t)}else if(t.parentNode&&!jg(t))i=No(t),t=t.parentNode;else return null}}function KT(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 YT(n,e){if(n.length!=e.length)return!1;for(let t=0;t=0;m-=3)if(Yi[m+1]==-d){let g=Yi[m+2],b=g&2?r:g&4?g&1?o:r:0;b&&(Le[f]=Le[Yi[m]]=b),a=m;break}}else{if(Yi.length==189)break;Yi[a++]=f,Yi[a++]=h,Yi[a++]=l}else if((p=Le[f])==2||p==1){let m=p==r;l=m?0:1;for(let g=a-3;g>=0;g-=3){let b=Yi[g+2];if(b&2)break;if(m)Yi[g+2]|=2;else{if(b&4)break;Yi[g+2]|=4}}}}}function xV(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),Le[--p]=d;l=u}else o=c,l++}}}function q0(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 ri(l,m.from,d));let g=m.direction==qs!=!(d%2);V0(n,g?i+1:i,r,m.inner,m.from,m.to,s),l=m.to}p=m.to}else{if(p==t||(u?Le[p]!=a:Le[p]==a))break;p++}h?q0(n,l,p,i+1,r,h,s):le;){let u=!0,f=!1;if(!c||l>o[c-1].to){let m=Le[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(Le[g-1]==a)break e;break}}if(h)h.push(m);else{m.toLe.length;)Le[Le.length]=256;let i=[],r=e==qs?0:1;return V0(n,r,r,t,0,n.length,i),i}function ZT(n){return[new ri(0,n,0)]}var JT="";function _V(n,e,t,i,r){var o;let s=i.head-n.from,a=ri.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=Mt(n.text,s,l.forward(r,t));(ul.to)&&(u=c),JT=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)}),CV=W.define({combine:n=>n.some(e=>e)}),aA=W.define(),bh=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=he.define({map:(n,e)=>n.map(e)}),lA=he.define();function Pt(n,e,t){let i=n.facet(iA);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 jr=W.define({combine:n=>n.length?n[0]:!0}),EV=0,Kl=W.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):fe.none})),o&&l.push(o(a)),l})}static fromClass(e,t){return n.define((i,r)=>new e(i,r),t)}},_h=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(Pt(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){Pt(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){Pt(e.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}},cA=W.define(),Sb=W.define(),ey=W.define(),uA=W.define(),Ob=W.define(),Ah=W.define(),fA=W.define();function gT(n,e){let t=n.state.facet(fA);if(!t.length)return t;let i=t.map(o=>o instanceof Function?o(n):o),r=[];return Ie.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=wV(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 hA=W.define();function kb(n){let e=0,t=0,i=0,r=0;for(let o of n.state.facet(hA)){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 mh=W.define(),bi=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 bi(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}},SV=[],Je=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 SV}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&&aV(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 Zi(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 ec)return e;return null}static get(e){return e.cmTile}},Jl=class extends Je{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=yT(r);else t.insertBefore(a.dom,r);i=a.dom}for(r=i?i.nextSibling:t.firstChild,o&&r&&(o.written=!0);r;)r=yT(r);this.length=s}};function yT(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}var ec=class extends Jl{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=Je.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 Fr)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}}},Fr=class n extends Jl{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}},tc=class n extends Jl{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&&kV(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?Rh(l,s<0):l||null}static of(e,t){let i=new n(t||document.createTextNode(e),e);return t||(i.flags|=2),i}},Vs=class n extends Je{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 Rh(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 xn&&c.mark.eq(l.mark))c.dom!=l.dom&&c.setDOM(A0(l.dom)),r=c;else{if(this.cache.reused.get(l)){let f=Je.get(l.dom);f&&f.setDOM(A0(l.dom))}let u=xn.of(l.mark,l.dom);r.append(u),r=u}this.cache.reused.set(l,2)}let o=Je.get(e.text);o&&this.cache.reused.set(o,2);let s=new js(e.text,e.text.nodeValue);s.flags|=8,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=dA);let r=tc.start(e,t||((i=this.cache.find(tc))===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 xn&&a.mark.eq(s))r=a,t--;else{let l=xn.of(s,(i=this.cache.find(xn,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||!vT(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(z.ios&&vT(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(M0,0,32)||new Vs(M0.toDOM(),0,M0,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=new W0(e.from,e.to,e.value,e.rank),i=this.wrappers.length;for(;i>0&&(this.wrappers[i-1].rank-t.rank||this.wrappers[i-1].to-t.to)<0;)i--;this.wrappers.splice(i,0,t)}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(nc,void 0,1);return i&&(i.flags=t),i||new nc(t)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}},Q0=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=[Vs,tc,js,xn,nc,Fr,ec];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 xn&&r.unshift(s.mark)),this.openWidget=!1},leave:s=>{s.isLine()?r.length&&(r.length=o=0):s instanceof xn&&(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=Ie.spans(this.decorations,e,t,{point:(a,l,c,u,f,h)=>{if(c instanceof Fs){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=RV(c),m=this.cache.findWidget(d,l-a,p)||Vs.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=TV(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=Je.get(r);if(r==this.view.contentDOM)break;o instanceof xn?t.push(o):o!=null&&o.isLine()?i=o:o instanceof Fr||(r.nodeName=="DIV"&&!i&&r!=this.view.contentDOM?i=new tc(r,dA):i||t.push(xn.of(new Sh({tagName:r.nodeName.toLowerCase(),attributes:lV(r)}),r)))}return{line:i,marks:t}}};function vT(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 RV(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 dA={class:"cm-line"};function TV(n,e){let t=e.spec.attributes,i=e.spec.class;return!t&&!i||(n||(n={class:"cm-line"}),t&&bb(t,n),i&&(n.class+=" "+i)),n}function AV(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 xn&&e.push(i.mark)}return e}function A0(n){let e=Je.get(n);return e&&e.setDOM(n.cloneNode()),n}var $o=class extends si{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 M0=new class extends si{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=fe.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 ec(e,e.contentDOM),this.updateInner([new bi(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:!$V(e.changes,this.hasComposition)&&!e.selectionSet&&(r=e.state.selection.main.head));let o=r>-1?PV(this.view,e.changes,r):null;if(this.domChanged=null,this.hasComposition){let{from:u,to:f}=this.hasComposition;i=new bi(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=LV(s,this.decorations,e.changes);l.length&&(i=bi.extendWithRanges(i,l));let c=BV(a,this.blockWrappers,e.changes);return c.length&&(i=bi.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 G0(this.view,s,this.blockWrappers,this.decorations,this.dynamicDecorationMap);t&&Je.get(t.text)&&a.cache.reused.set(Je.get(t.text),2),this.tile=a.run(e,t),X0(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)&&yh(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&&MV(c)){let h=document.createTextNode("");this.view.observer.ignore(()=>c.node.insertBefore(h,c.node.childNodes[c.offset]||null)),c=u=new Zi(h,0),a=!0}let f=this.view.observer.selectionRange;(a||!f.focusNode||(!xh(c.node,c.offset,f.anchorNode,f.anchorOffset)||!xh(u.node,u.offset,f.focusNode,f.focusOffset))&&!this.suppressWidgetCursorChange(f,l))&&(this.view.observer.ignore(()=>{z.android&&z.chrome&&i.contains(f.focusNode)&&NV(f.focusNode,i)&&(i.blur(),i.focus({preventScroll:!0}));let h=kh(this.view.root);if(h)if(l.empty){if(z.gecko){let d=DV(c.node,c.offset);if(d&&d!=3){let p=(d==1?QT:KT)(c.node,c.offset);p&&(c=new Zi(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 Zi(f.anchorNode,f.anchorOffset),this.impreciseHead=u.precise?null:new Zi(f.focusNode,f.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&xh(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=kh(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=qr(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&&!Je.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 wh?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==Ve.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:w}=b;if(d&&!p&&(c+=b.top-d.top),m instanceof Fr)g>i&&u(m,h,b);else if(h>=i&&(c>0&&t.push(-c),t.push(w+c),c=0,s)){let v=m.dom.lastChild,x=v?vh(v):[];if(x.length){let _=x[x.length-1],E=l?_.right-b.left:b.right-_.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"?Ve.RTL:Ve.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=vh(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=vh(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(fe.replace({widget:new wh(a),block:!0,inclusive:!0,isBlockGap:!0}).range(i,s))}if(!o)break;i=o.to+1}return fe.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(Ob).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(Ie.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(aA))try{if(u(this.view,e.range,e))return!0}catch(f){Pt(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=kb(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(fV(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(){X0(this.tile)}};function X0(n,e){let t=e==null?void 0:e.get(n);if(t!=1){t==null&&n.destroy();for(let i of n.children)X0(i,e)}}function MV(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 pA(n,e){let t=n.observer.selectionRange;if(!t.focusNode)return null;let i=QT(t.focusNode,t.focusOffset),r=KT(t.focusNode,t.focusOffset),o=i||r;if(r&&i&&r.node!=i.node){let a=Je.get(r.node);if(!a||a.isText()&&a.text!=r.node.nodeValue)o=r;else if(n.docView.lastCompositionAfterCursor){let l=Je.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 PV(n,e,t){let i=pA(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 bi(l.mapPos(o),l.mapPos(s),o,s),text:r}}function DV(n,e){return n.nodeType!=1?0:(e&&n.childNodes[e-1].contentEditable=="false"?1:0)|(e{ie.from&&(t=!0)}),t}var wh=class extends si{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 jV(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=Mt(r.text,o,!1):a=Mt(r.text,o);let l=i(r.text.slice(s,a));for(;s>0;){let c=Mt(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+rT(s,o,n.state.tabSize)}function qV(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==oi.Text&&(r.type!=o.type||(t<0?o.frome)))&&(r=o)}}return r||i}return i}function VV(n,e,t,i){let r=qV(n,e.head,e.assoc||-1),o=!i||r.type!=oi.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==Ve.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 xT(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=_V(r,o,s,a,t),u=JT;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 HV(n,e,t){let i=n.state.charCategorizer(e),r=i(t);return o=>{let s=i(o);return r==an.Space&&(r=s),r==s}}function zV(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=Z0(n,{x:f,y:m},!1,o);if(t?m>l.bottom:ma:w{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 ii(n.state.doc.length,-1);if(c=n.elementAtHeight(l),i==null)break;if(c.type==oi.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==oi.Text){let f=FV(n,r,c,s,a);return new ii(f,f==c.from?1:-1)}}if(c.type!=oi.Text)return l<(c.top+c.bottom)/2?new ii(c.from,1):new ii(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 J0(n,s,a,n.textDirectionAt(c.from)).scanTile(u,c.from)}var J0=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(o.has(p)){let g=i+Math.floor(Math.random()*d);for(let b=0;b1)){if(b.bottomthis.y)(!l||l.top>b.top)&&(l=b),w=-1;else{let v=b.left>this.x?this.x-b.left:b.right(d+d+p)/3)return this.y=a.bottom-1,this.scan(e,t);if(l&&l.top<(d+p+p)/3)return this.y=l.top+1,this.scan(e,t)}let h=(s?this.dirAt(e[c],1):this.baseDir)==Ve.LTR;return{i:c,after:this.x>(f.left+f.right)/2==h}}scanText(e,t){let i=[];for(let o=0;o{let s=i[o]-t,a=i[o+1]-t;return Th(e.dom,s,a).getClientRects()});return r.after?new ii(i[r.i+1],-1):new ii(i[r.i],1)}scanTile(e,t){if(!e.length)return new ii(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:Th(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 ii(i[r.i+1],-1):new ii(s,1)}},Ql="\uFFFF",eb=class{constructor(e,t){this.points=e,this.view=t,this.text="",this.lineSeparator=t.state.facet(Ke.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=Ql}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=Je.get(r),a=r.nextSibling;if(a==t){s!=null&&s.breakAfter&&!a&&i!=this.view.contentDOM&&this.lineBreak();break}let l=Je.get(a);(s&&l?s.breakAfter:(s?s.breakAfter:jg(r))||jg(a)&&(r.nodeName!="BR"||s!=null&&s.isWidget())&&this.text.length>o)&&!UV(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=Je.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+(WV(e,i.node,i.offset)?t:0))}};function WV(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=gA(e.docView.tile,t,i,0))){let l=o||s?[]:KV(e),c=new eb(l,e);c.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=c.text,this.newSel=GV(l,this.bounds.from)}else{let l=e.observer.selectionRange,c=o&&o.node==l.focusNode&&o.offset==l.focusOffset||!$0(e.contentDOM,l.focusNode)?a.main.head:e.docView.posFromDOM(l.focusNode,l.focusOffset),u=s&&s.node==l.anchorNode&&s.offset==l.anchorOffset||!$0(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 gA(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 gA(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 yA(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:ye.of(e.text.slice(o.from-a,h).split(Ql))}:(d=vA(f,e.text,c-a,u))&&(z.chrome&&s==13&&d.toB==d.from+2&&e.text.slice(d.from,d.toB)==Ql+Ql&&d.toB--,t={from:a+d.from,to:a+d.toA,insert:ye.of(e.text.slice(d.from,d.toB).split(Ql))})}else i&&(!n.hasFocus&&r.facet(jr)||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:ye.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:ye.of([" "])}),t)return Rb(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=mA(r.facet(Ah).map(c=>c(n)),i))),n.dispatch({selection:i,scrollIntoView:a,userEvent:l}),!0}else return!1}function Rb(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&&Zl(n.contentDOM,"Enter",13)||(e.from==r.from-1&&e.to==r.to&&e.insert.length==0||i==8&&e.insert.lengthr.head)&&Zl(n.contentDOM,"Backspace",8)||e.from==r.from&&e.to==r.to+1&&e.insert.length==0&&Zl(n.contentDOM,"Delete",46)))return!0;let o=e.insert.toString();n.inputState.composing>=0&&n.inputState.composing++;let s,a=()=>s||(s=QV(n,e,t));return n.state.facet(rA).some(l=>l(n,e.from,e.to,o,a))||n.dispatch(a()),!0}function QV(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&&pA(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}),w=p.to-o.to;return{changes:b,range:c?$.range(Math.max(0,c.anchor+w),Math.max(0,c.head+w)):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 vA(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 KV(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 GV(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 nb=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&&c3(e.contentDOM.ownerDocument)}handleEvent(e){!n3(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=XV(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&&bA.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=xA.find(i=>i.keyCode==e.keyCode))&&!e.ctrlKey||YV.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 bT(n,e){return(t,i)=>{try{return e.call(n,i,t)}catch(r){Pt(t.state,r)}}}function XV(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(bT(i.value,l))}if(s)for(let a in s){let l=s[a];l&&t(a).observers.push(bT(i.value,l))}}for(let i in _i)t(i).handlers.push(_i[i]);for(let i in bn)t(i).observers.push(bn[i]);return e}var xA=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],YV="dthko",bA=[16,17,18,20,91,92,224,225],kg=6;function Rg(n){return Math.max(0,n)*.7+8}function ZV(n,e){return Math.max(Math.abs(n.clientX-e.clientX),Math.abs(n.clientY-e.clientY))}var ib=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=zT(e.contentDOM),this.atoms=e.state.facet(Ah).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(Ke.allowMultipleSelections)&&JV(e,t),this.dragging=t3(e,t)&&CA(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&&ZV(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=kb(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=mA(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 JV(n,e){let t=n.state.facet(eA);return t.length?t[0](e):z.mac?e.metaKey:e.ctrlKey}function e3(n,e){let t=n.state.facet(tA);return t.length?t[0](e):z.mac?!e.altKey:!e.ctrlKey}function t3(n,e){let{main:t}=n.state.selection;if(t.empty)return!1;let i=kh(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 n3(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=Je.get(t))&&i.isWidget()&&!i.isHidden&&i.widget.ignoreEvent(e))return!1;return!0}var _i=Object.create(null),bn=Object.create(null),_A=z.ie&&z.ie_version<15||z.ios&&z.webkit_version<604;function i3(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(),wA(n,t.value)},50)}function ty(n,e,t){for(let i of n.facet(e))t=i(t,n);return t}function wA(n,e){e=ty(n.state,Cb,e);let{state:t}=n,i,r=1,o=t.toText(e),s=o.lines==t.selection.ranges.length;if(rb!=null&&t.selection.ranges.every(l=>l.empty)&&rb==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})}bn.scroll=n=>{n.inputState.lastScrollTop=n.scrollDOM.scrollTop,n.inputState.lastScrollLeft=n.scrollDOM.scrollLeft};bn.wheel=bn.mousewheel=n=>{n.inputState.lastWheelEvent=Date.now()};_i.keydown=(n,e)=>(n.inputState.setSelectionOrigin("select"),e.keyCode==27&&n.inputState.tabFocusMode!=0&&(n.inputState.tabFocusMode=Date.now()+2e3),!1);bn.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")};bn.touchmove=n=>{n.inputState.setSelectionOrigin("select.pointer")};_i.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(nA))if(t=i(n,e),t)break;if(!t&&e.button==0&&(t=o3(n,e)),t){let i=!n.hasFocus;n.inputState.startMouseSelection(new ib(n,e,t,i)),i&&n.observer.ignore(()=>{WT(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 _T(n,e,t,i){if(i==1)return $.cursor(e,t);if(i==2)return jV(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?(CT+1)%3:1}function o3(n,e){let t=n.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),i=CA(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=_T(n,l.pos,l.assoc,i);if(t.pos!=l.pos&&!s){let f=_T(n,t.pos,t.assoc,i),h=Math.min(f.from,u.from),d=Math.max(f.to,u.to);u=h1&&(c=s3(r,l.pos))?c:a?r.addRange(u):$.create([u])}}}function s3(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}_i.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,Eb,n.state.sliceDoc(t.from,t.to))),e.dataTransfer.effectAllowed="copyMove"),!1};_i.dragend=n=>(n.inputState.draggedContent=null,!1);function ST(n,e,t,i){if(t=ty(n.state,Cb,t),!t)return;let r=n.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:o}=n.inputState,s=i&&o&&e3(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}_i.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&&ST(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 ST(n,e,i,!0),!0}return!1};_i.paste=(n,e)=>{if(n.state.readOnly)return!0;n.observer.flush();let t=_A?null:e.clipboardData;return t?(wA(n,t.getData("text/plain")||t.getData("text/uri-list")),!0):(i3(n),!1)};function a3(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 l3(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,Eb,e.join(n.lineBreak)),ranges:t,linewise:i}}var rb=null;_i.copy=_i.cut=(n,e)=>{if(!yh(n.contentDOM,n.observer.selectionRange))return!1;let{text:t,ranges:i,linewise:r}=l3(n.state);if(!t&&!r)return!1;rb=r?t:null,e.type=="cut"&&!n.state.readOnly&&n.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let o=_A?null:e.clipboardData;return o?(o.clearData(),o.setData("text/plain",t),!0):(a3(n,t),!1)};var EA=Mn.define();function SA(n,e){let t=[];for(let i of n.facet(oA)){let r=i(n,e);r&&t.push(r)}return t.length?n.update({effects:t,annotations:EA.of(!0)}):null}function OA(n){setTimeout(()=>{let e=n.hasFocus;if(e!=n.inputState.notifiedFocused){let t=SA(n.state,e);t?n.dispatch(t):n.update([])}},10)}bn.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),OA(n)};bn.blur=n=>{n.observer.clearSelectionRange(),OA(n)};bn.compositionstart=bn.compositionupdate=n=>{n.observer.editContext||(n.inputState.compositionFirstChange==null&&(n.inputState.compositionFirstChange=!0),n.inputState.composing<0&&(n.inputState.composing=0))};bn.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))};bn.contextmenu=n=>{n.inputState.lastContextMenu=Date.now()};_i.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 Rb(n,{from:l,to:c,insert:n.state.toText(o)},null),!0}}let r;if(z.chrome&&z.android&&(r=xA.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(()=>bn.compositionend(n,e),20),!1};var OT=new Set;function c3(n){OT.has(n)||(OT.add(n),n.addEventListener("copy",()=>{}),n.addEventListener("cut",()=>{}))}var kT=["pre-wrap","normal","pre-line","break-spaces"],ic=!1;function RT(){ic=!1}var ob=class{constructor(e){this.lineWrapping=e,this.doc=ye.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 kT.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||Math.abs(i-this.charWidth)>.1;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&&(ic=!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,qe.ByPosNoHeight,i.setDoc(t),0,0),d=h.to>=c?h:o.lineAt(c,qe.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,qe.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})`}},ni=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 xi(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 ni(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)&&(ic=!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})`}},ab=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==qe.ByPosNoHeight?qe.ByPosNoHeight:qe.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,qe.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&&TT(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 TT(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 f3=5,lb=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 ni?r.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new ni(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=f3)&&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 ni(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 ni)return e;let t=new ni(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 ni)&&!this.isCovered?this.nodes.push(new ni(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 p3(n){let e=n.getBoundingClientRect(),t=n.ownerDocument.defaultView||window;return e.left0&&e.top0}function m3(n,e){let t=n.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}var Eh=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 ob(i),this.stateDeco=MT(t),this.heightMap=Dn.empty().applyChanges(this.stateDeco,ye.empty,this.heightOracle.setDoc(t.doc),[new bi(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=fe.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 Gl(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?AT:new fb(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(gh(e,this.scaler))})}update(e,t=null){this.state=e.state;let i=this.stateDeco;this.stateDeco=MT(this.state);let r=e.changedRanges,o=bi.extendWithRanges(r,h3(i,this.stateDeco,e?e.changes:ln.empty(this.state.doc.length))),s=this.heightMap.height,a=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);RT(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),o),(this.heightMap.height!=s||ic)&&(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(CV)&&(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"?Ve.RTL:Ve.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:_,scaleY:E}=HT(t,a);(_>.005&&Math.abs(this.scaleX-_)>.005||E>.005&&Math.abs(this.scaleY-E)>.005)&&(this.scaleX=_,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=zT(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=UT(this.scrollParent||e.win);let m=(this.printing?m3:d3)(t,this.paddingTop),g=m.top-this.pixelViewport.top,b=m.bottom-this.pixelViewport.bottom;this.pixelViewport=m;let w=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(w!=this.inView&&(this.inView=w,w&&(l=!0)),!this.inView&&!this.scrollTarget&&!p3(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 _=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(_)&&(s=!0),s||r.lineWrapping&&Math.abs(v-this.contentDOMWidth)>r.charWidth){let{lineHeight:E,charWidth:S,textHeight:C}=e.docView.measureTextSize();s=E>0&&r.refresh(o,E,S,C,Math.max(5,v/S),_),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)),RT();for(let E of this.viewports){let S=E.from==this.viewport.from?_:e.docView.measureVisibleLineHeights(E);this.heightMap=(s?Dn.empty().applyChanges(this.stateDeco,ye.empty,this.heightOracle,[new bi(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,s,new sb(E.from,S))}ic&&(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 Gl(r.lineAt(s-i*1e3,qe.ByHeight,o,0,0).from,r.lineAt(a+(1-i)*1e3,qe.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,qe.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!=Ve.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.fromw));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),w=i||b<2e6?b:2e6;g=new Eh(u,f,b,w)}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=[];Ie.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)||gh(this.heightMap.lineAt(e,qe.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)||gh(this.heightMap.lineAt(this.scaler.fromDOM(e),qe.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 gh(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}},Gl=class{constructor(e,t){this.from=e,this.to=t}};function g3(n,e,t){let i=[],r=n,o=0;return Ie.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 y3(n,e){for(let t of n)if(e(t))return t}var AT={toDOM(n){return n},fromDOM(n){return n},scale:1,eq(n){return n==this}};function MT(n){let e=n.facet(ey).filter(i=>typeof i!="function"),t=n.facet(Ob).filter(i=>typeof i!="function");return t.length&&e.push(Ie.join(t)),e}var fb=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,qe.ByPos,e,0,0).top,u=t.lineAt(l,qe.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 gh(n,e){if(e.scale==1)return n;let t=e.toDOM(n.top),i=e.toDOM(n.bottom);return new xi(n.from,n.length,t,i-t,Array.isArray(n._content)?n._content.map(r=>gh(r,e)):n._content)}var Mg=W.define({combine:n=>n.join(" ")}),hb=W.define({combine:n=>n.indexOf(!0)>-1}),db=ti.newName(),kA=ti.newName(),RA=ti.newName(),TA={"&light":"."+kA,"&dark":"."+RA};function pb(n,e,t){return new ti(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 v3=pb("."+db,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-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"}},TA),x3={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},D0=z.ie&&z.ie_version<=11,mb=class{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new j0,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 gb(e),e.state.facet(jr)&&(e.contentDOM.editContext=this.editContext.editContext)),D0&&(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(jr)?i.root.activeElement!=this.dom:!yh(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&&xh(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=kh(e.root);if(!t)return!1;let i=z.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&b3(this.view,t)||t;if(!i||this.selectionRange.eq(i))return!1;let r=yh(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&&Zl(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&&yh(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 tb(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=yA(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=PT(t,e.previousSibling||e.target.previousSibling,-1),r=PT(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(jr)!=e.state.facet(jr)&&(e.view.contentDOM.editContext=e.state.facet(jr)?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 PT(n,e,t){for(;e;){let i=Je.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 DT(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 xh(s.node,s.offset,r,o)&&([t,i,r,o]=[r,o,t,i]),{anchorNode:t,anchorOffset:i,focusNode:r,focusOffset:o}}function b3(n,e){if(e.getComposedRanges){let r=e.getComposedRanges(n.root)[0];if(r)return DT(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?DT(n,t):null}var gb=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=vA(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:ye.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:ye.of([i.text.replace("."," ")])}),this.pendingContextChange=f,!e.state.readOnly){let h=this.to-this.from+(f.to-f.from+f.insert.length);Rb(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=kh(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||hV(e.parent)||document,this.viewState=new Qg(this,e.state||Ke.create(e)),e.scrollTo&&e.scrollTo.is(Og)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Kl).map(r=>new _h(r));for(let r of this.plugins)r.update(this);this.observer=new mb(this),this.inputState=new nb(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 $t?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(EA))?(this.inputState.notifiedFocused=s,a=1):s!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=s,l=SA(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(Ke.phrases)!=this.state.facet(Ke.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 bh(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(mh)!=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(H0))try{h(r)}catch(d){Pt(this.state,d,"update listener")}(l||u)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),u&&!yA(this,u)&&c.force&&Zl(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(Kl).map(i=>new _h(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(Kl),i=e.state.facet(Kl);if(t!=i){let r=[];for(let o of i){let s=t.indexOf(o);if(s<0)r.push(new _h(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(UT(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 Pt(this.state,p),IT}}),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(H0))a(t)}get themeClasses(){return db+" "+(this.state.facet(hb)?RA:kA)+" "+this.state.facet(Mg)}updateAttrs(){let e=LT(this,cA,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(jr)?"true":"false",class:"cm-content",style:`${z.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),LT(this,Sb,t);let i=this.observer.ignore(()=>{let r=dT(this.contentDOM,this.contentAttrs,t),o=dT(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(mh);let e=this.state.facet(n.cspNonce);ti.mount(this.root,this.styleModules.concat(v3).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 P0(this,e,xT(this,e,t,i))}moveByGroup(e,t){return P0(this,e,xT(this,e,t,i=>HV(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 VV(this,e,t,i)}moveVertically(e,t,i){return P0(this,e,zV(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=Z0(this,e,t);return i&&i.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),Z0(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[ri.find(o,e-r.from,-1,t)];return Rh(i,s.dir==Ve.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(sA)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>_3)return ZT(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||YT(o.isolates,i=gT(this,e))))return o.order;i||(i=gT(this,e));let r=bV(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(()=>{WT(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 bh(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 bh($.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 Xt.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return Xt.define(()=>({}),{eventObservers:e})}static theme(e,t){let i=ti.newName(),r=[Mg.of(i),mh.of(pb(`.${i}`,e))];return t&&t.dark&&r.push(hb.of(!0)),r}static baseTheme(e){return Nr.lowest(mh.of(pb("."+db,e,TA)))}static findFromDOM(e){var t;let i=e.querySelector(".cm-content"),r=i&&Je.get(i)||Je.get(e);return((t=r==null?void 0:r.root)===null||t===void 0?void 0:t.view)||null}};U.styleModule=mh;U.inputHandler=rA;U.clipboardInputFilter=Cb;U.clipboardOutputFilter=Eb;U.scrollHandler=aA;U.focusChangeEffect=oA;U.perLineTextDirection=sA;U.exceptionSink=iA;U.updateListener=H0;U.editable=jr;U.mouseSelectionStyle=nA;U.dragMovesSelection=tA;U.clickAddsSelectionRange=eA;U.decorations=ey;U.blockWrappers=uA;U.outerDecorations=Ob;U.atomicRanges=Ah;U.bidiIsolatedRanges=fA;U.cursorScrollMargin=W.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=hA;U.darkTheme=hb;U.cspNonce=W.define({combine:n=>n.length?n[0]:""});U.contentAttributes=Sb;U.editorAttributes=cA;U.lineWrapping=U.contentAttributes.of({class:"cm-lineWrapping"});U.announce=he.define();var _3=4096,IT={},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:Ve.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&&bb(s,t)}return t}var w3=z.mac?"mac":z.windows?"win":z.linux?"linux":"key";function C3(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,O3=4e3;function k3(n,e=w3){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=>C3(b,e));for(let b=1;b{let x=Lo={view:v,prefix:w,scope:s};return setTimeout(()=>{Lo==x&&(Lo=null)},O3),!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,yb))}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 yb=null;function R3(n,e,t,i){yb=e;let r=lT(e),o=ei(r,0),s=Xi(o)==r.length&&r!=" ",a="",l=!1,c=!1,u=!1;Lo&&Lo.view==t&&Lo.scope==i&&(a=Lo.prefix+" ",bA.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=$r[e.keyCode])&&p!=r?(h(d[a+Pg(p,e,!0)])||e.shiftKey&&(m=Ul[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(),yb=null,l}var rge=/x/.unicode!=null?"gu":"g";var vb=class extends si{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?vh(e.firstChild):[];if(!t.length)return null;let i=window.getComputedStyle(e.parentNode),r=Rh(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 Tb(n){let e=Xt.fromClass(class{constructor(t){this.view=t,this.placeholder=n?fe.set([fe.widget({widget:new vb(n),side:1}).range(0)]):fe.none}get decorations(){return this.view.state.doc.length?fe.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 AA(n={}){return Bg.of(n)}function T3(n){let e=n.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}var Bg=W.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)||T3}}}),NT=new WeakMap,Ab=Xt.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,Mh,(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=kb(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=NT.get(c))!==null&&e!==void 0?e:h.bottom-h.top,b=c.offset||M3,w=this.view.textDirection==Ve.LTR,v=h.width>i.right-i.left?w?i.left:i.right-h.width:w?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 _=(x?f.top-i.top:i.bottom-f.bottom)-p;if(_v&&C.topE&&(E=x?C.top-g-2-p:C.bottom+p+2);if(this.position=="absolute"?(u.style.top=(E-n.parent.top)/o+"px",$T(u,(v-n.parent.left)/r)):(u.style.top=E/o+"px",$T(u,v/r)),d){let C=f.left+(w?b.x:-b.x)-(v+14-7);d.style.left=C/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 $T(n,e){let t=parseInt(n.style.left,10);(isNaN(t)||Math.abs(e-t)>1)&&(n.style.left=e+"px")}var A3=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"}}}),M3={x:0,y:0},Mh=W.define({enables:[Ab,A3]}),Xg=W.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")}},P3=Mh.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)}}),xb=class{constructor(e,t,i,r,o){this.view=e,this.source=t,this.field=i,this.setHover=r,this.hoverTime=o,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;ea.bottom||t.xa.right+e.defaultCharacterWidth)return;let l=e.bidiSpans(e.state.doc.lineAt(r)).find(u=>u.from<=r&&u.to>=r),c=l&&l.dir==Ve.RTL?-1:1;o=t.x{this.pending==a&&(this.pending=null,l&&!(Array.isArray(l)&&!l.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(l)?l:[l])}))},l=>Pt(e.state,l,"hover tooltip"))}else s&&!(Array.isArray(s)&&!s.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(s)?s:[s])})}get tooltip(){let e=this.view.plugin(Ab),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&&o&&!D3(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:!I3(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){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),this.active.length&&!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 D3(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 I3(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 MA(n,e={}){let t=he.define(),i=jt.define({create(){return[]},update(r,o){if(r.length&&(e.hideOnChange&&(o.docChanged||o.selection)?r=[]:e.hideOn&&(r=r.filter(s=>!e.hideOn(o,s))),o.docChanged)){let s=[];for(let a of r){let l=o.changes.mapPos(a.pos,-1,Et.TrackDel);if(l!=null){let c=Object.assign(Object.create(null),a);c.pos=l,c.end!=null&&(c.end=o.changes.mapPos(c.end)),s.push(c)}}r=s}for(let s of o.effects)s.is(t)&&(r=s.value),s.is(L3)&&(r=[]);return r},provide:r=>Xg.from(r)});return{active:i,extension:[i,Xt.define(r=>new xb(r,n,i,t,e.hoverTime||300)),P3]}}function Mb(n,e){let t=n.plugin(Ab);if(!t)return null;let i=t.manager.tooltips.indexOf(e);return i<0?null:t.manager.tooltipViews[i]}var L3=he.define();var jT=W.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 B3=Xt.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(jT);this.top=new Xl(n,!0,e.topContainer),this.bottom=new Xl(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(jT);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new Xl(n.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new Xl(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()}})}),Xl=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=FT(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=FT(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 FT(n){let e=n.nextSibling;return n.remove(),e}var Zg=W.define({enables:B3});var Ji=class extends Jn{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};Ji.prototype.elementClass="";Ji.prototype.toDOM=void 0;Ji.prototype.mapMode=Et.TrackBefore;Ji.prototype.startSide=Ji.prototype.endSide=-1;Ji.prototype.point=!0;var N3=0,Ph=class{constructor(e,t){this.from=e,this.to=t}},le=class{constructor(e={}){this.id=N3++,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=Yt.match(e)),t=>{let i=e(t);return i===void 0?null:[this,i]}}};le.closedBy=new le({deserialize:n=>n.split(" ")});le.openedBy=new le({deserialize:n=>n.split(" ")});le.group=new le({deserialize:n=>n.split(" ")});le.isolate=new le({deserialize:n=>{if(n&&n!="rtl"&&n!="ltr"&&n!="auto")throw new RangeError("Invalid value for isolate: "+n);return n||"auto"}});le.contextHash=new le({perNode:!0});le.lookAhead=new le({perNode:!0});le.mounted=new le({perNode:!0});var Hs=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[le.mounted.id]}},$3=Object.create(null),Yt=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):$3,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(le.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(le.group),o=-1;o<(r?r.length:0);o++){let s=t[o<0?i.name:r[o]];if(s)return s}}}};Yt.none=new Yt("",Object.create(null),0,8);var Dh=class n{constructor(e){this.types=e;for(let t=0;t0;for(let l=this.cursor(s|et.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:$b(Yt.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(Yt.none,t,i,r)))}static build(e){return F3(e)}};ht.empty=new ht(Yt.none,[],[],0);var Pb=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 Yt.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 Ih(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&et.EnterBracketed&&u instanceof ht&&(h=Hs.get(u))&&!h.overlay&&h.bracketed&&i>=f&&i<=f+u.length)&&!LA(r,i,f,f+u.length))){if(u instanceof jo){if(o&et.ExcludeBuffers)continue;let d=u.findChild(0,u.buffer.length,t,i-f,r);if(d>-1)return new Lh(new Ib(s,u,e,f),null,d)}else if(o&et.IncludeAnonymous||!u.type.isAnonymous||Nb(u)){let d;if(!(o&et.IgnoreMounts)&&(d=Hs.get(u))&&!d.overlay)return new n(d.tree,f,e,s);let p=new n(u,f,e,s);return o&et.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(t<0?u.children.length-1:0,t,i,r,o)}}}if(o&et.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&et.IgnoreOverlays)&&(r=Hs.get(this._tree))&&r.overlay){let o=e-this.from,s=i&et.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 DA(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 Db(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 Ib=class{constructor(e,t,i,r){this.parent=e,this.buffer=t,this.index=i,this.start=r}},Lh=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&et.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 ht(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function BA(n){if(!n.length)return null;let e=0,t=n[0];for(let o=1;ot.from||s.to=e){let a=new er(s.tree,s.overlay[0].from+o.from,-1,o);(r||(r=[i])).push(Ih(a,e,t,!1))}}return r?BA(r):i}var Bh=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&~et.EnterBracketed,e instanceof er)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 er?(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&et.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&et.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&et.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&et.IncludeAnonymous||a instanceof jo||!a.type.isAnonymous||Nb(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 Db(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 Nb(n){return n.children.some(e=>e instanceof jo||!e.type.isAnonymous||Nb(e))}function F3(n){var e;let{buffer:t,nodeSet:i,maxBufferLength:r=1024,reused:o=[],minRepeatType:s=i.types.length}=n,a=Array.isArray(t)?new Pb(t,t.length):t,l=i.types,c=0,u=0;function f(_,E,S,C,R,A){let{id:D,start:I,end:N,size:H}=a,ke=u,be=c;if(H<0)if(a.next(),H==-1){let vt=o[D];S.push(vt),C.push(I-_);return}else if(H==-3){c=D;return}else if(H==-4){u=D;return}else throw new RangeError(`Unrecognized record size: ${H}`);let ue=l[D],wn,Ft,dt=I-_;if(N-I<=r&&(Ft=g(a.pos-E,R))){let vt=new Uint16Array(Ft.size-Ft.skip),_t=a.pos-Ft.size,Lt=vt.length;for(;a.pos>_t;)Lt=b(Ft.start,vt,Lt);wn=new jo(vt,N-Ft.start,i),dt=Ft.start-_}else{let vt=a.pos-H;a.next();let _t=[],Lt=[],un=D>=s?D:-1,ot=0,Ri=N;for(;a.pos>vt;)un>=0&&a.id==un&&a.size>=0?(a.end<=Ri-r&&(p(_t,Lt,I,ot,a.end,Ri,un,ke,be),ot=_t.length,Ri=a.end),a.next()):A>2500?h(I,vt,_t,Lt):f(I,vt,_t,Lt,un,A+1);if(un>=0&&ot>0&&ot<_t.length&&p(_t,Lt,I,ot,I,Ri,un,ke,be),_t.reverse(),Lt.reverse(),un>-1&&ot>0){let Zo=d(ue,be);wn=$b(ue,_t,Lt,0,_t.length,0,N-I,Zo,Zo)}else wn=m(ue,_t,Lt,N-I,ke-N,be)}S.push(wn),C.push(dt)}function h(_,E,S,C){let R=[],A=0,D=-1;for(;a.pos>E;){let{id:I,start:N,end:H,size:ke}=a;if(ke>4)a.next();else{if(D>-1&&N=0;H-=3)I[ke++]=R[H],I[ke++]=R[H+1]-N,I[ke++]=R[H+2]-N,I[ke++]=ke;S.push(new jo(I,R[2]-N,i)),C.push(N-_)}}function d(_,E){return(S,C,R)=>{let A=0,D=S.length-1,I,N;if(D>=0&&(I=S[D])instanceof ht){if(!D&&I.type==_&&I.length==R)return I;(N=I.prop(le.lookAhead))&&(A=C[D]+I.length+N)}return m(_,S,C,R,A,E)}}function p(_,E,S,C,R,A,D,I,N){let H=[],ke=[];for(;_.length>C;)H.push(_.pop()),ke.push(E.pop()+S-R);_.push(m(i.types[D],H,ke,A-R,I-A,N)),E.push(R-S)}function m(_,E,S,C,R,A,D){if(A){let I=[le.contextHash,A];D=D?[I].concat(D):[I]}if(R>25){let I=[le.lookAhead,R];D=D?[I].concat(D):[I]}return new ht(_,E,S,C,D)}function g(_,E){let S=a.fork(),C=0,R=0,A=0,D=S.end-r,I={size:0,start:0,skip:0};e:for(let N=S.pos-_;S.pos>N;){let H=S.size;if(S.id==E&&H>=0){I.size=C,I.start=R,I.skip=A,A+=4,C+=4,S.next();continue}let ke=S.pos-H;if(H<0||ke=s?4:0,ue=S.start;for(S.next();S.pos>ke;){if(S.size<0)if(S.size==-3||S.size==-4)be+=4;else break e;else S.id>=s&&(be+=4);S.next()}R=ue,C+=H,A+=be}return(E<0||C==_)&&(I.size=C,I.start=R,I.skip=A),I.size>4?I:void 0}function b(_,E,S){let{id:C,start:R,end:A,size:D}=a;if(a.next(),D>=0&&C4){let N=a.pos-(D-4);for(;a.pos>N;)S=b(_,E,S)}E[--S]=I,E[--S]=A-_,E[--S]=R-_,E[--S]=C}else D==-3?c=C:D==-4&&(u=C);return S}let w=[],v=[];for(;a.pos>0;)f(n.start||0,n.bufferStart||0,w,v,-1,0);let x=(e=n.length)!==null&&e!==void 0?e:w.length?v[0]+w[0].length:0;return new ht(l[n.topID],w.reverse(),v.reverse(),x)}var IA=new WeakMap;function iy(n,e){if(!n.isAnonymous||e instanceof jo||e.type!=n)return 1;let t=IA.get(e);if(t==null){t=1;for(let i of e.children){if(i.type!=n||!(i instanceof ht)){t=1;break}t+=iy(n,i)}IA.set(e,t)}return t}function $b(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]+w);continue}f.push(p[x])}else{let S=m[v-1]+p[v-1].length-_;f.push($b(n,p,m,x,v,_,S,null,l))}h.push(_+w-o)}}return d(e,t,i,r,0),(a||l)(f,h,s)}var zs=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 Ph(r.from,r.to)):[new Ph(0,0)]:[new Ph(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}}},Bb=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 uge=new le({perNode:!0});var q3=0,wi=class n{constructor(e,t,i,r){this.name=e,this.set=t,this.base=i,this.modified=r,this.id=q3++}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))}},V3=0,ly=class n{constructor(e){this.name=e,this.instances=[],this.id=V3++}static get(e,t){if(!t.length)return e;let i=t[0].instances.find(a=>a.base==e&&H3(t,a.modified));if(i)return i;let r=[],o=new wi(e.name,r,e,t);for(let a of t)a.instances.push(o);let s=z3(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 H3(n,e){return n.length==e.length&&n.every((t,i)=>t==e[i])}function z3(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 Us(i,s,l>0?o.slice(0,l):null);e[c]=u.sort(e[c])}}return jA.add(e)}var jA=new le({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 Us(r.tags,r.mode,r.context);t?t.next=o:i=o,t=o}return i}}),Us=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 W3(n,e){let t=null;for(let i of n){let r=i.style(e);r&&(t=t?t+" "+r:r)}return t}function FA(n,e,t,i=0,r=n.length){let o=new Fb(i,Array.isArray(e)?e:[e],t);o.highlightRange(n.cursor(),i,r,"",o.highlighters),o.flush(r)}var Fb=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=U3(e)||Us.empty,f=W3(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(le.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 w=g=v||!e.nextSibling())););if(!w||v>i)break;b=w.to+a,b>t&&(this.highlightRange(d.cursor(),Math.max(t,w.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 U3(n){let e=n.type.prop(jA);for(;e&&e.context&&!n.matchContext(e.context);)e=e.next;return e||null}var V=wi.define,oy=V(),Fo=V(),NA=V(Fo),$A=V(Fo),qo=V(),sy=V(qo),jb=V(qo),ir=V(),Ws=V(ir),tr=V(),nr=V(),qb=V(),Nh=V(qb),ay=V(),B={comment:oy,lineComment:V(oy),blockComment:V(oy),docComment:V(oy),name:Fo,variableName:V(Fo),typeName:NA,tagName:V(NA),propertyName:$A,attributeName:V($A),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:jb,integer:V(jb),float:V(jb),bool:V(qo),regexp:V(qo),escape:V(qo),color:V(qo),url:V(qo),keyword:tr,self:V(tr),null:V(tr),atom:V(tr),unit:V(tr),modifier:V(tr),operatorKeyword:V(tr),controlKeyword:V(tr),definitionKeyword:V(tr),moduleKeyword:V(tr),operator:nr,derefOperator:V(nr),arithmeticOperator:V(nr),logicOperator:V(nr),bitwiseOperator:V(nr),compareOperator:V(nr),updateOperator:V(nr),definitionOperator:V(nr),typeOperator:V(nr),controlOperator:V(nr),punctuation:qb,separator:V(qb),bracket:Nh,angleBracket:V(Nh),squareBracket:V(Nh),paren:V(Nh),brace:V(Nh),content:ir,heading:Ws,heading1:V(Ws),heading2:V(Ws),heading3:V(Ws),heading4:V(Ws),heading5:V(Ws),heading6:V(Ws),contentSeparator:V(ir),list:V(ir),quote:V(ir),emphasis:V(ir),strong:V(ir),link:V(ir),monospace:V(ir),strikethrough:V(ir),inserted:V(),deleted:V(),changed:V(),invalid:V(),meta:ay,documentMeta:V(ay),annotation:V(ay),processingInstruction:V(ay),definition:wi.defineModifier("definition"),constant:wi.defineModifier("constant"),function:wi.defineModifier("function"),standard:wi.defineModifier("standard"),local:wi.defineModifier("local"),special:wi.defineModifier("special")};for(let n in B){let e=B[n];e instanceof wi&&(e.name=n)}var dge=Vb([{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 Hb,sc=new le;function K3(n){return W.define({combine:n?e=>e.concat(n):void 0})}var G3=new le,In=class{constructor(e,t,i=[],r=""){this.data=e,this.name=r,Ke.prototype.hasOwnProperty("tree")||Object.defineProperty(Ke.prototype,"tree",{get(){return rt(this)}}),this.parser=t,this.extension=[ac.of(this),Ke.languageData.of((o,s,a)=>{let l=qA(o,s,a),c=l.type.prop(sc);if(!c)return[];let u=o.facet(c),f=l.type.prop(G3);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 qA(e,t,i).type.prop(sc)==this.data}findRegions(e){let t=e.facet(ac);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(sc)==this.data){i.push({from:s,to:s+o.length});return}let a=o.prop(le.mounted);if(a){if(a.tree.prop(sc)==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 rt(n){let e=n.field(In.state,!1);return e?e.tree:ht.empty}var Qb=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)}},$h=null,Kb=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,[],ht.empty,0,i,[],null)}startParse(){return this.parser.startParse(new Qb(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=ht.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(zs.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=$h;$h=this;try{return e()}finally{$h=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=VA(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=zs.applyChanges(i,l),r=ht.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=VA(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 oc{createParse(t,i,r){let o=r[0].from,s=r[r.length-1].to;return{parsedPos:o,advance(){let l=$h;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 ht(Yt.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 $h}};function VA(n,e,t){return zs.applyChanges(n,[{fromA:e,toA:t,fromB:e,toB:t}])}var jh=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=Kb.create(e.facet(ac).parser,e,{from:0,to:t});return i.work(20,t)||i.takeTree(),new n(i)}};In.state=jt.define({create:jh.init,update(n,e){for(let t of e.effects)if(t.is(In.setState))return t.value;return e.startState.facet(ac)!=e.state.facet(ac)?jh.init(e.state):n.apply(e)}});var QA=n=>{let e=setTimeout(()=>n(),500);return()=>clearTimeout(e)};typeof requestIdleCallback!="undefined"&&(QA=n=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(n,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});var zb=typeof navigator!="undefined"&&(!((Hb=navigator.scheduling)===null||Hb===void 0)&&Hb.isInputPending)?()=>navigator.scheduling.isInputPending():null,X3=Xt.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=QA(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEndr+1e3,l=o.context.work(()=>zb&&zb()||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 jh(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=>Pt(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()}}}),ac=W.define({combine(n){return n.length?n[0]:null},enables:n=>[In.state,X3,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 Y3=W.define(),cc=W.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 Fh(n){let e=n.facet(cc);return e.charCodeAt(0)==9?n.tabSize*e.length:e.length}function uc(n,e){let t="",i=n.tabSize,r=n.facet(cc)[0];if(r==" "){for(;e>=i;)t+=" ",e-=i;r=" "}for(let o=0;o=e?Z3(n,t,e):null}var Qs=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=Fh(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 Ns(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}},e_=new le;function Z3(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 KA(i,n,t)}function KA(n,e,t){for(let i=n;i;i=i.next){let r=eH(i.node);if(r)return r(Gb.create(e,t,i))}return 0}function J3(n){return n.pos==n.options.simulateBreak&&n.options.simulateDoubleBreak}function eH(n){let e=n.type.prop(e_);if(e)return e;let t=n.firstChild,i;if(t&&(i=t.type.prop(le.closedBy))){let r=n.lastChild,o=r&&i.indexOf(r.name)>-1;return s=>GA(s,!0,1,void 0,o&&!J3(s)?r.from:void 0)}return n.parent==null?tH:null}function tH(){return 0}var Gb=class n extends Qs{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(nH(i,e))break;t=this.state.doc.lineAt(i.from)}return this.lineIndent(t.from)}continue(){return KA(this.context.next,this.base,this.pos)}};function nH(n,e){for(let t=e;t;t=t.parent)if(n==t)return!0;return!1}function iH(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 t_({closing:n,align:e=!0,units:t=1}){return i=>GA(i,e,t,n)}function GA(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?iH(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 rH=200;function XA(){return Ke.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+rH)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=uc(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 YA=new le;function py(n){let e=n.firstChild,t=n.lastChild;return e&&e.toa.prop(sc)==s.data:s?a=>a==s:void 0,this.style=Vb(e.map(a=>({tag:a.tag,class:a.class||r(Object.assign({},a,{tag:null}))})),{all:o}).style,this.module=i?new ti(i):null,this.themeType=t.themeType}static define(e,t){return new n(e,t||{})}},Xb=W.define(),ZA=W.define({combine(n){return n.length?[n[0]]:null}});function Wb(n){let e=n.facet(Xb);return e.length?e:n.facet(ZA)}function JA(n,e){let t=[oH],i;return n instanceof lc&&(n.module&&t.push(U.styleModule.of(n.module)),i=n.themeType),e!=null&&e.fallback?t.push(ZA.of(n)):i?t.push(Xb.computeN([U.darkTheme],r=>r.facet(U.darkTheme)==(i=="dark")?[n]:[])):t.push(Xb.of(n)),t}var Yb=class{constructor(e){this.markCache=Object.create(null),this.tree=rt(e.state),this.decorations=this.buildDeco(e,Wb(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=rt(e.state),i=Wb(e.state),r=i!=Wb(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 fe.none;let i=new Br;for(let{from:r,to:o}of e.visibleRanges)FA(this.tree,t,(s,a,l)=>{i.add(s,a,this.markCache[l]||(this.markCache[l]=fe.mark({class:l})))},r,o);return i.finish()}},oH=Nr.high(Xt.fromClass(Yb,{decorations:n=>n.decorations})),_ge=lc.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"}]),sH=U.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),eM=1e4,tM="()[]{}",nM=W.define({combine(n){return Io(n,{afterCursor:!0,brackets:tM,maxScanDistance:eM,renderMatch:cH})}}),aH=fe.mark({class:"cm-matchingBracket"}),lH=fe.mark({class:"cm-nonmatchingBracket"});function cH(n){let e=[],t=n.matched?aH:lH;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 HA(n){let e=[],t=n.facet(nM);for(let i of n.selection.ranges){if(!i.empty)continue;let r=Ci(n,i.head,-1,t)||i.head>0&&Ci(n,i.head-1,1,t)||t.afterCursor&&(Ci(n,i.head,1,t)||i.headn.decorations}),fH=[uH,sH];function iM(n={}){return[nM.of(n),fH]}var hH=new le;function Zb(n,e,t){let i=n.prop(e<0?le.openedBy:le.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 Jb(n){let e=n.type.prop(hH);return e?e(n.node):n}function Ci(n,e,t,i={}){let r=i.maxScanDistance||eM,o=i.brackets||tM,s=rt(n),a=s.resolveInner(e,t);for(let l=a;l;l=l.parent){let c=Zb(l.type,t,o);if(c&&l.from0?e>=u.from&&eu.from&&e<=u.to))return dH(n,e,t,l,u,c,o)}}return pH(n,e,t,s,a.type,r,o)}function dH(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 mH=Object.create(null),zA=[Yt.none];var WA=[],UA=Object.create(null),gH=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"]])gH[n]=yH(mH,e);function Ub(n,e){WA.indexOf(n)>-1||(WA.push(n),console.warn(e))}function yH(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):Ub(c,`Modifier ${c} used at start of tag`):l.length?Ub(c,`Tag ${c} used as modifier`):l=Array.isArray(u)?u:[u]:Ub(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=UA[r];if(o)return o.id;let s=UA[r]=Yt.define({id:zA.length,name:i,props:[cy({[i]:t})]});return zA.push(s),s.id}var wge={rtl:fe.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"rtl"},bidiIsolate:Ve.RTL}),ltr:fe.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"ltr"},bidiIsolate:Ve.LTR}),auto:fe.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=rt(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(hM(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 rM(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 vH(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+$/]:vH(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 Gs(n){return n.selection.main.from}function hM(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 p_=Mn.define();function xH(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 oM=new WeakMap;function bH(n){if(!Array.isArray(n))return n;let e=oM.get(n);return e||oM.set(n,e=hc(n)),e}var vy=he.define(),qh=he.define(),o_=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&&_<=57||_>=97&&_<=122?2:_>=65&&_<=90?1:0:(E=C0(_))!=E.toLowerCase()?1:E!=E.toUpperCase()?2:0;(!w||S==1&&g||x==0&&S!=0)&&(t[f]==_||i[f]==_&&(h=!0)?s[f++]=w:s.length&&(b=!1)),x=S,w+=Xi(_)}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?Xi(ei(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)}},s_=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:_H,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=>sM(e(i),t(i)),optionClass:(e,t)=>i=>sM(e(i),t(i)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function sM(n,e){return n?e?n+" "+e:n:e}function _H(n,e,t,i,r,o){let s=n.textDirection==Ve.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||w>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 m_=he.define();function wH(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 n_(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.floor((n-e)/t);return{from:n-(i+1)*t,to:n-i*t}}var a_=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(Dt);this.optionContent=wH(a),this.optionClass=a.optionClass,this.tooltipClass=a.tooltipClass,this.range=n_(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:m_.of(u)}),l.preventDefault())}}),this.dom.addEventListener("focusout",l=>{let c=e.state.field(this.stateField,!1);c&&c.tooltip&&e.state.facet(Dt).closeOnBlur&&l.relatedTarget!=e.contentDOM&&e.dispatch({effects:qh.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=n_(o.length,s,e.state.facet(Dt).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=n_(t.options.length,t.selected,this.view.state.facet(Dt).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=>Pt(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&&EH(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 a_(t,n,e)}function EH(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 aM(n){return(n.boost||0)*100+(n.apply?10:0)+(n.info?5:0)+(n.type?1:0)}function SH(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(Dt);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 s_(h):new o_(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:w}=m.section;r||(r=Object.create(null)),r[w]=Math.max(b,r[w]||-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):aM(u.completion)>aM(l)&&(a[a.length-1]=u),l=u.completion}return a}var l_=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,lM(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=SH(e,t);if(!a.length)return r&&e.some(c=>c.isPending)?r.setDisabled():null;let l=t.facet(Dt).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:MH,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)}},c_=class n{constructor(e,t,i){this.active=e,this.id=t,this.open=i}static start(){return new n(TH,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,i=t.facet(Dt),o=(i.override||t.languageDataAt("autocomplete",Gs(t)).map(bH)).map(l=>(this.active.find(u=>u.source==l)||new Vr(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(g_));s&&e.docChanged&&(s=s.map(e.changes)),e.selection||o.some(l=>l.hasResult()&&e.changes.touchesRange(l.from,l.to))||!OH(o,this.active)||a?s=l_.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 Vr(l.source,0):l));for(let l of e.effects)l.is(m_)&&(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?kH:RH}};function OH(n,e){if(n==e)return!0;for(let t=0,i=0;;){for(;t-1&&(t["aria-activedescendant"]=n+"-"+e),t}var TH=[];function dM(n,e){if(n.isUserEvent("input.complete")){let i=n.annotation(p_);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 Vr=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=dM(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(qh))r=new n(r.source,0);else if(o.is(g_))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(Gs(e.state))}},xy=class n extends Vr{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=Gs(e.state);if(a>s||!r||t&2&&(Gs(e.startState)==this.from||at.map(e))}}),_n=jt.define({create(){return c_.start()},update(n,e){return n.update(e)},provide:n=>[Mh.from(n,e=>e.tooltip),U.contentAttributes.from(n,e=>e.attrs)]});function y_(n,e){let t=e.completion.apply||e.completion.label,i=n.state.field(_n).active.find(r=>r.source==e.source);return i instanceof xy?(typeof t=="string"?n.dispatch({...xH(n.state,t,i.from,i.to),annotations:p_.of(e.completion)}):t(n,e.completion,i.from,i.to),!0):!1}var MH=CH(_n,y_);function my(n,e="option"){return t=>{let i=t.state.field(_n,!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:m_.of(a)}),!0}}var PH=n=>{let e=n.state.field(_n,!1);return n.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestampn.state.field(_n,!1)?(n.dispatch({effects:vy.of(!0)}),!0):!1,DH=n=>{let e=n.state.field(_n,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(n.dispatch({effects:qh.of(null)}),!0)},u_=class{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}},IH=50,LH=1e3,BH=Xt.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(_n).active)e.isPending&&this.startQuery(e)}update(n){let e=n.state.field(_n),t=n.state.facet(Dt);if(!n.selectionSet&&!n.docChanged&&n.startState.field(_n)==e)return;let i=n.transactions.some(o=>{let s=dM(o,t);return s&8||(o.selection||o.docChanged)&&!(s&3)});for(let o=0;oIH&&Date.now()-s.time>LH){for(let a of s.context.abortListeners)try{a()}catch(l){Pt(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(_n);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(Dt).updateSyncTime))}startQuery(n){let{state:e}=this.view,t=Gs(e),i=new gy(e,t,n.explicit,this.view),r=new u_(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:qh.of(null)}),Pt(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(Dt).updateSyncTime))}accept(){var n;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(Dt),i=this.view.state.field(_n);for(let r=0;ra.source==o.active.source);if(s&&s.isPending)if(o.done==null){let a=new Vr(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:g_.of(e)})}},{eventHandlers:{blur(n){let e=this.view.state.field(_n,!1);if(e&&e.tooltip&&this.view.state.facet(Dt).closeOnBlur){let t=e.open&&Mb(this.view,e.open.tooltip);(!t||!t.dom.contains(n.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:qh.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:vy.of(!1)}),20),this.composing=0}}}),NH=typeof navigator=="object"&&/Win/.test(navigator.platform),$H=Nr.highest(U.domEventHandlers({keydown(n,e){let t=e.state.field(_n,!1);if(!t||!t.open||t.open.disabled||t.open.selected<0||n.key.length>1||n.ctrlKey&&!(NH&&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&&y_(e,i),!1}})),pM=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"},".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"}}}),f_=class{constructor(e,t,i,r){this.field=e,this.line=t,this.from=i,this.to=r}},h_=class n{constructor(e,t,i){this.field=e,this.from=t,this.to=i}map(e){let t=e.mapPos(this.from,-1,Et.TrackDel),i=e.mapPos(this.to,1,Et.TrackDel);return t==null||i==null?null:new n(this.field,t,i)}},d_=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 h_(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,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 f_(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)}},jH=fe.widget({widget:new class extends si{toDOM(){let n=document.createElement("span");return n.className="cm-snippetFieldPosition",n}ignoreEvent(){return!1}}}),FH=fe.mark({class:"cm-snippetField"}),fc=class n{constructor(e,t){this.ranges=e,this.active=t,this.deco=fe.set(e.map(i=>(i.from==i.to?jH:FH).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))}},Hh=he.define({map(n,e){return n&&n.map(e)}}),qH=he.define(),Vh=jt.define({create(){return null},update(n,e){for(let t of e.effects){if(t.is(Hh))return t.value;if(t.is(qH)&&n)return new fc(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:fe.none)});function v_(n,e){return $.create(n.filter(t=>t.field==e).map(t=>$.range(t.from,t.to)))}function VH(n){let e=d_.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:ye.of(s)},scrollIntoView:!0,annotations:i?[p_.of(i),$t.userEvent.of("input.complete")]:void 0};if(a.length&&(c.selection=v_(a,0)),a.some(u=>u.field>0)){let u=new fc(a,0),f=c.effects=[Hh.of(u)];t.state.field(Vh,!1)===void 0&&f.push(he.appendConfig.of([Vh,QH,KH,pM]))}t.dispatch(t.state.update(c))}}function mM(n){return({state:e,dispatch:t})=>{let i=e.field(Vh,!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:v_(i.ranges,r),effects:Hh.of(o?null:new fc(i.ranges,r)),scrollIntoView:!0})),!0}}var HH=({state:n,dispatch:e})=>n.field(Vh,!1)?(e(n.update({effects:Hh.of(null)})),!0):!1,zH=mM(1),WH=mM(-1);var UH=[{key:"Tab",run:zH,shift:WH},{key:"Escape",run:HH}],cM=W.define({combine(n){return n.length?n[0]:UH}}),QH=Nr.highest(rc.compute([cM],n=>n.facet(cM)));function ai(n,e){return{...e,apply:VH(n)}}var KH=U.domEventHandlers({mousedown(n,e){let t=e.state.field(Vh,!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:v_(t.ranges,r.field),effects:Hh.of(t.ranges.some(o=>o.field>r.field)?new fc(t.ranges,r.field):null),scrollIntoView:!0}),!0)}});var by={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Ks=he.define({map(n,e){let t=e.mapPos(n,-1,Et.TrackAfter);return t==null?void 0:t}}),x_=new class extends Jn{};x_.startSide=1;x_.endSide=-1;var gM=jt.define({create(){return Ie.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(Ks)&&(n=n.update({add:[x_.range(t.value,t.value+1)]}));return n}});function yM(){return[ZH,gM]}var r_="()[]{}<>\xAB\xBB\xBB\xAB\uFF3B\uFF3D\uFF5B\uFF5D";function GH(n){for(let e=0;e{if((YH?n.composing:n.compositionStarted)||n.state.readOnly)return!1;let r=n.state.selection.main;if(i.length>2||i.length==2&&Xi(ei(i,0))==1||e!=r.from||t!=r.to)return!1;let o=JH(n.state,i);return o?(n.dispatch(o),!0):!1});function JH(n,e){let t=XH(n,n.selection.main.head),i=t.brackets||by.brackets;for(let r of i){let o=GH(ei(r,0));if(e==r)return o==r?n4(n,r,i.indexOf(r+r+r)>-1,t):e4(n,r,o,t.before||by.before);if(e==o&&vM(n,n.selection.main.from))return t4(n,r,o)}return null}function vM(n,e){let t=!1;return n.field(gM).between(0,n.doc.length,i=>{i==e&&(t=!0)}),t}function b_(n,e){let t=n.sliceString(e,e+2);return t.slice(0,Xi(ei(t,0)))}function e4(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:Ks.of(s.to+e.length),range:$.range(s.anchor+e.length,s.head+e.length)};let a=b_(n.doc,s.head);return!a||/\s/.test(a)||i.indexOf(a)>-1?{changes:{insert:e+t,from:s.head},effects:Ks.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 t4(n,e,t){let i=null,r=n.changeByRange(o=>o.empty&&b_(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 n4(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:Ks.of(a.to+e.length),range:$.range(a.anchor+e.length,a.head+e.length)};let l=a.head,c=b_(n.doc,l),u;if(c==e){if(uM(n,l))return{changes:{insert:e+e,from:l},effects:Ks.of(l+e.length),range:$.cursor(l+e.length)};if(vM(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=fM(n,l-2*e.length,r))>-1&&uM(n,u))return{changes:{insert:e+e+e+e,from:l},effects:Ks.of(l+e.length),range:$.cursor(l+e.length)};if(n.charCategorizer(l)(c)!=an.Word&&fM(n,l,r)>-1&&!i4(n,l,e,r))return{changes:{insert:e+e,from:l},effects:Ks.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 uM(n,e){let t=rt(n).resolveInner(e+1);return t.parent&&t.from==e}function i4(n,e,t,i){let r=rt(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 fM(n,e,t){let i=n.charCategorizer(e);if(i(n.sliceDoc(e-1,e))!=an.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))!=an.Word)return o}return-1}function xM(n={}){return[$H,_n,Dt.of(n),BH,o4,pM]}var r4=[{key:"Ctrl-Space",run:i_},{mac:"Alt-`",run:i_},{mac:"Alt-i",run:i_},{key:"Escape",run:DH},{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:PH}],o4=Nr.highest(rc.computeN([Dt],n=>n.facet(Dt).defaultKeymap?[r4]:[]));var s4=n=>{let{state:e}=n,t=e.doc.lineAt(e.selection.main.from),i=O_(n.state,t.from);return i.line?a4(n):i.block?c4(n):!1};function S_(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 a4=S_(h4,0);var l4=S_(TM,0);var c4=S_((n,e)=>TM(n,e,f4(e)),0);function O_(n,e){let t=n.languageDataAt("commentTokens",e,1);return t.length?t[0]:{}}var zh=50;function u4(n,{open:e,close:t},i,r){let o=n.sliceDoc(i-zh,i),s=n.sliceDoc(r,r+zh),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*zh?u=f=n.sliceDoc(i,r):(u=n.sliceDoc(i,i+zh),f=n.sliceDoc(r-zh,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 f4(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 TM(n,e,t=e.selection.ranges){let i=t.map(o=>O_(e,o.from).block);if(!i.every(o=>o))return null;let r=t.map((o,s)=>u4(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 bM=Mn.define();var d4=W.define();var Xs=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&&ln.fromJSON(e.changes),[],e.mapped&&Lr.fromJSON(e.mapped),e.startSelection&&$.fromJSON(e.startSelection),e.selectionsAfter.map($.fromJSON))}static fromTransaction(e,t){let i=li;for(let r of e.startState.facet(d4)){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,li)}static selection(e){return new n(void 0,li,void 0,void 0,e)}};function w_(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 p4(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 m4(n,e){return n.ranges.length==e.ranges.length&&n.ranges.filter((t,i)=>t.empty!=e.ranges[i].empty).length===0}function AM(n,e){return n.length?e.length?n.concat(e):n:e}var li=[],g4=200;function y4(n,e){if(n.length){let t=n[n.length-1],i=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-g4));return i.length&&i[i.length-1].eq(e)?n:(i.push(e),w_(n,n.length-1,1e9,t.setSelAfter(i)))}else return[Xs.selection([e])]}function v4(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 __(n,e){if(!n.length)return n;let t=n.length,i=li;for(;t;){let r=x4(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?[Xs.selection(i)]:li}function x4(n,e,t){let i=AM(n.selectionsAfter.length?n.selectionsAfter.map(a=>a.map(e)):li,t);if(!n.changes)return Xs.selection(i);let r=n.changes.map(e),o=e.mapDesc(n.changes,!0),s=n.mapped?n.mapped.composeDesc(o):o;return new Xs(r,he.mapEffects(n.effects,e),s,n.startSelection.map(o),i)}var b4=/^(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||b4.test(i))&&(!a.selectionsAfter.length&&t-this.prevTime0&&t-this.prevTimet.empty?n.moveByChar(t,e):Cy(t,e))}function Zt(n){return n.textDirectionAt(n.state.selection.main.head)==Ve.LTR}var PM=n=>MM(n,!Zt(n)),DM=n=>MM(n,Zt(n));function IM(n,e){return Si(n,t=>t.empty?n.moveByGroup(t,e):Cy(t,e))}var _4=n=>IM(n,!Zt(n)),w4=n=>IM(n,Zt(n));var Nge=typeof Intl!="undefined"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;function C4(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=rt(n).resolveInner(e.head),r=t?le.closedBy:le.openedBy;for(let l=e.head;;){let c=t?i.childAfter(l):i.childBefore(l);if(!c)break;C4(n,c,r)?i=c:l=t?c.to:c.from}let o=i.type.prop(r),s,a;return o&&(s=t?Ci(n,i.from,1):Ci(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 E4=n=>Si(n,e=>Ey(n.state,e,!Zt(n))),S4=n=>Si(n,e=>Ey(n.state,e,Zt(n)));function LM(n,e){return Si(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 BM=n=>LM(n,!1),NM=n=>LM(n,!0);function $M(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.bottomjM(n,!1),C_=n=>jM(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 O4=n=>Si(n,e=>Vo(n,e,!0)),k4=n=>Si(n,e=>Vo(n,e,!1)),R4=n=>Si(n,e=>Vo(n,e,!Zt(n))),T4=n=>Si(n,e=>Vo(n,e,Zt(n))),A4=n=>Si(n,e=>$.cursor(n.lineBlockAt(e.head).from,1)),M4=n=>Si(n,e=>$.cursor(n.lineBlockAt(e.head).to,-1));function P4(n,e,t){let i=!1,r=dc(n.selection,o=>{let s=Ci(n,o.head,-1)||Ci(n,o.head,1)||o.head>0&&Ci(n,o.head-1,1)||o.headP4(n,e,!1);function ci(n,e){let t=dc(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(Ei(n.state,t)),!0)}function FM(n,e){return ci(n,t=>n.moveByChar(t,e))}var qM=n=>FM(n,!Zt(n)),VM=n=>FM(n,Zt(n));function HM(n,e){return ci(n,t=>n.moveByGroup(t,e))}var I4=n=>HM(n,!Zt(n)),L4=n=>HM(n,Zt(n));var B4=n=>ci(n,e=>Ey(n.state,e,!Zt(n))),N4=n=>ci(n,e=>Ey(n.state,e,Zt(n)));function zM(n,e){return ci(n,t=>n.moveVertically(t,e))}var WM=n=>zM(n,!1),UM=n=>zM(n,!0);function QM(n,e){return ci(n,t=>n.moveVertically(t,e,$M(n).height))}var wM=n=>QM(n,!1),CM=n=>QM(n,!0),$4=n=>ci(n,e=>Vo(n,e,!0)),j4=n=>ci(n,e=>Vo(n,e,!1)),F4=n=>ci(n,e=>Vo(n,e,!Zt(n))),q4=n=>ci(n,e=>Vo(n,e,Zt(n))),V4=n=>ci(n,e=>$.cursor(n.lineBlockAt(e.head).from)),H4=n=>ci(n,e=>$.cursor(n.lineBlockAt(e.head).to)),EM=({state:n,dispatch:e})=>(e(Ei(n,{anchor:0})),!0),SM=({state:n,dispatch:e})=>(e(Ei(n,{anchor:n.doc.length})),!0),OM=({state:n,dispatch:e})=>(e(Ei(n,{anchor:n.selection.main.anchor,head:0})),!0),kM=({state:n,dispatch:e})=>(e(Ei(n,{anchor:n.selection.main.anchor,head:n.doc.length})),!0),z4=({state:n,dispatch:e})=>(e(n.update({selection:{anchor:0,head:n.doc.length},userEvent:"select"})),!0),W4=({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},U4=({state:n,dispatch:e})=>{let t=dc(n.selection,i=>{let r=rt(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(Ei(n,t)),!0)};function KM(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(Ei(t,$.create(r,r.length-1))),!0)}var Q4=n=>KM(n,!1),K4=n=>KM(n,!0),G4=({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(Ei(n,i)),!0):!1};function Wh(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 GM=(n,e,t)=>Wh(n,i=>{let r=i.from,{state:o}=n,s=o.doc.lineAt(r),a,l;if(t&&!e&&r>s.from&&rGM(n,!1,!0);var XM=n=>GM(n,!0,!1),YM=(n,e)=>Wh(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=Mt(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}),ZM=n=>YM(n,!1),X4=n=>YM(n,!0);var Y4=n=>Wh(n,e=>{let t=n.lineBlockAt(e.head).to;return e.headWh(n,e=>{let t=n.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),J4=n=>Wh(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:ye.of(["",""])},range:$.cursor(i.from)}));return e(n.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},tz=({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:Mt(o.text,r-o.from,!1)+o.from,a=r==o.to?r+1:Mt(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 JM(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 nz=({state:n,dispatch:e})=>JM(n,e,!1),iz=({state:n,dispatch:e})=>JM(n,e,!0);function eP(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 rz=({state:n,dispatch:e})=>eP(n,e,!1),oz=({state:n,dispatch:e})=>eP(n,e,!0),sz=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 az(n,e){if(/\(\)|\[\]|\{\}/.test(n.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=rt(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(le.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 RM=tP(!1),lz=tP(!0);function tP(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&&az(e,o);n&&(o=s=(s<=a.to?a:e.doc.lineAt(s)).to);let c=new Qs(e,{simulateBreak:o,simulateDoubleBreak:!!l}),u=hy(c,o);for(u==null&&(u=Ns(/^\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 cz=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=Object.create(null),i=new Qs(n,{overrideIndentation:o=>{let s=t[o];return s==null?-1:s}}),r=k_(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=uc(n,l);(c!=u||a.fromn.readOnly?!1:(e(n.update(k_(n,(t,i)=>{i.push({from:t.from,insert:n.facet(cc)})}),{userEvent:"input.indent"})),!0),fz=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(k_(n,(t,i)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let o=Ns(r,n.tabSize),s=0,a=uc(n,Math.max(0,o-Fh(n)));for(;s(n.setTabFocusMode(),!0);var dz=[{key:"Ctrl-b",run:PM,shift:qM,preventDefault:!0},{key:"Ctrl-f",run:DM,shift:VM},{key:"Ctrl-p",run:BM,shift:WM},{key:"Ctrl-n",run:NM,shift:UM},{key:"Ctrl-a",run:A4,shift:V4},{key:"Ctrl-e",run:M4,shift:H4},{key:"Ctrl-d",run:XM},{key:"Ctrl-h",run:E_},{key:"Ctrl-k",run:Y4},{key:"Ctrl-Alt-h",run:ZM},{key:"Ctrl-o",run:ez},{key:"Ctrl-t",run:tz},{key:"Ctrl-v",run:C_}],pz=[{key:"ArrowLeft",run:PM,shift:qM,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:_4,shift:I4,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:R4,shift:F4,preventDefault:!0},{key:"ArrowRight",run:DM,shift:VM,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:w4,shift:L4,preventDefault:!0},{mac:"Cmd-ArrowRight",run:T4,shift:q4,preventDefault:!0},{key:"ArrowUp",run:BM,shift:WM,preventDefault:!0},{mac:"Cmd-ArrowUp",run:EM,shift:OM},{mac:"Ctrl-ArrowUp",run:_M,shift:wM},{key:"ArrowDown",run:NM,shift:UM,preventDefault:!0},{mac:"Cmd-ArrowDown",run:SM,shift:kM},{mac:"Ctrl-ArrowDown",run:C_,shift:CM},{key:"PageUp",run:_M,shift:wM},{key:"PageDown",run:C_,shift:CM},{key:"Home",run:k4,shift:j4,preventDefault:!0},{key:"Mod-Home",run:EM,shift:OM},{key:"End",run:O4,shift:$4,preventDefault:!0},{key:"Mod-End",run:SM,shift:kM},{key:"Enter",run:RM,shift:RM},{key:"Mod-a",run:z4},{key:"Backspace",run:E_,shift:E_,preventDefault:!0},{key:"Delete",run:XM,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:ZM,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:X4,preventDefault:!0},{mac:"Mod-Backspace",run:Z4,preventDefault:!0},{mac:"Mod-Delete",run:J4,preventDefault:!0}].concat(dz.map(n=>({mac:n.key,run:n.run,shift:n.shift}))),nP=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:E4,shift:B4},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:S4,shift:N4},{key:"Alt-ArrowUp",run:nz},{key:"Shift-Alt-ArrowUp",run:rz},{key:"Alt-ArrowDown",run:iz},{key:"Shift-Alt-ArrowDown",run:oz},{key:"Mod-Alt-ArrowUp",run:Q4},{key:"Mod-Alt-ArrowDown",run:K4},{key:"Escape",run:G4},{key:"Mod-Enter",run:lz},{key:"Alt-l",mac:"Ctrl-l",run:W4},{key:"Mod-i",run:U4,preventDefault:!0},{key:"Mod-[",run:fz},{key:"Mod-]",run:uz},{key:"Mod-Alt-\\",run:cz},{key:"Shift-Mod-k",run:sz},{key:"Shift-Mod-\\",run:D4},{key:"Mod-/",run:s4},{key:"Alt-A",run:l4},{key:"Ctrl-m",mac:"Shift-Alt-m",run:hz}].concat(pz);var ky=class{constructor(e,t,i){this.from=e,this.to=t,this.diagnostic=i}},Ys=class n{constructor(e,t,i){this.diagnostics=e,this.panel=t,this.selected=i}static init(e,t,i){let r=i.facet(rr).markerFilter;r&&(e=r(e,i));let o=e.slice().sort((d,p)=>d.from-p.from||d.to-p.to),s=new Br,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 w=Oz(a);if(b)s.add(m,m,fe.widget({widget:new R_(w),diagnostics:a.slice()}));else{let v=a.reduce((x,_)=>_.markClass?x+" "+_.markClass:x,"");s.add(m,g,fe.mark({class:"cm-lintRange cm-lintRange-"+w+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 mz(n,e){let t=e.pos,i=e.end||t,r=n.state.facet(rr).hideOn(n,t,i);if(r!=null)return r;let o=n.startState.doc.lineAt(e.pos);return!!(n.effects.some(s=>s.is(Uh))||n.changes.touchesRange(o.from,Math.max(o.to,i)))}function gz(n,e){return n.field(Oi,!1)?e:e.concat(he.appendConfig.of(uP))}function yz(n,e){return{effects:gz(n,[Uh.of(e)])}}var Uh=he.define(),oP=he.define(),sP=he.define(),Oi=jt.define({create(){return new Ys(fe.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=pc(t,n.selected.diagnostic,o)||pc(t,null,o)}!t.size&&r&&e.state.facet(rr).autoPanel&&(r=null),n=new Ys(t,r,i)}for(let t of e.effects)if(t.is(Uh)){let i=e.state.facet(rr).autoPanel?t.value.length?Ty.open:null:n.panel;n=Ys.init(t.value,i,e.state)}else t.is(oP)?n=new Ys(n.diagnostics,t.value?Ty.open:null,n.selected):t.is(sP)&&(n=new Ys(n.diagnostics,n.panel,t.value));return n},provide:n=>[Zg.from(n,e=>e.panel),U.decorations.from(n,e=>e.diagnostics)]});var vz=fe.mark({class:"cm-lintRange cm-lintRange-active"});function xz(n,e,t){let{diagnostics:i}=n.state.field(Oi),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)&&(ecP(n,t,!1)))}var iP=n=>{let e=n.state.field(Oi,!1);return!e||!e.panel?!1:(n.dispatch({effects:oP.of(!1)}),!0)};var _z=Xt.fromClass(class{constructor(n){this.view=n,this.timeout=-1,this.set=!0;let{delay:e}=n.state.facet(rr);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(yz(this.view.state,i.reduce((r,o)=>r.concat(o))))},i=>{Pt(this.view.state,i)})}}update(n){let e=n.state.facet(rr);(n.docChanged||e!=n.startState.facet(rr)||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 wz(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 rr=W.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:rP,tooltipFilter:rP,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 rP(n,e){return n?e?(t,i)=>e(n(t,i),i):n:e}function aP(n,e={}){return[rr.of({source:n,config:e}),_z,uP]}function lP(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 cP(n,e,t){var i;let r=t?lP(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=pc(n.state.field(Oi).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 R_=class extends si{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=cP(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)iP(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=lP(o.actions);for(let a=0;a{for(let o=0;oiP(this.view)},"\xD7")),this.update()}get selectedIndex(){let e=this.view.state.field(Oi).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(Oi),i=pc(t.diagnostics,this.items[e].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:sP.of(i)})}static open(e){return new n(e)}};function Cz(n,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,${encodeURIComponent(n)}')`}function Oy(n){return Cz(``,'width="6" height="3"')}var Ez=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("#d11")},".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 Sz(n){return n=="error"?4:n=="warning"?3:n=="info"?2:1}function Oz(n){let e="hint",t=1;for(let i of n){let r=Sz(i.severity);r>t&&(t=r,e=i.severity)}return e}var uP=[Oi,U.decorations.compute([Oi],n=>{let{selected:e,panel:t}=n.field(Oi);return!e||!t||e.from==e.to?fe.none:fe.set([vz.range(e.from,e.to)])}),MA(xz,{hideOn:mz}),Ez];function fP(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 M_=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 P_(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}},P_=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}},D_=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 Qh(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 mc=class{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}},hP=new mc,I_=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=hP,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=hP,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;yP(this.data,e,t,this.id,i.data,i.tokenPrecTable)}};Ho.prototype.contextual=Ho.prototype.fallback=Ho.prototype.extend=!1;var L_=class{constructor(e,t,i){this.precTable=t,this.elseToken=i,this.data=typeof e=="string"?Qh(e):e}token(e,t){let i=e.pos,r=0;for(;;){let o=e.next<0,s=e.resolveOffset(1,1);if(yP(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))}};L_.prototype.contextual=Ho.prototype.fallback=Ho.prototype.extend=!1;var gc=class{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}};function yP(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||Rz(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 dP(n,e,t){for(let i=e,r;(r=n[i])!=65535;i++)if(r==t)return i-e;return-1}function Rz(n,e,t,i){let r=dP(t,i,e);return r<0||dP(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 B_=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?pP(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?pP(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 ht){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}}},N_=class{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(i=>new mc)}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 mc,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 mc,{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 B_(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&&Tz(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(le.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 ht)||f.children.length==0||f.positions[0]>0)break;let d=f.children[0];if(d instanceof ht&&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 mP(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)})`),mP(a,i)):(!r||r.scoren,My=class{constructor(e){this.start=e.start,this.shift=e.shift||A_,this.reduce=e.reduce||A_,this.reuse=e.reuse||A_,this.hash=e.hash||(()=>0),this.strict=e.strict!==!1}},Py=class n extends oc{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 Dh(t.map((a,l)=>Yt.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=Qh(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 $_(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=Hr(this.data,o+2);else break;r=t(Hr(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=Hr(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]=gP(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 Az=121,V_=122,EP=123,Mz=124,vP=128,Pz=4,Dz=131,Iz=7,Lz=8,Bz=9,Nz=10,$z=139,SP=19,jz=140,Fz=23,qz=141,Vz=27,Hz=37,zz=41,Wz=144,Uz=145,Qz=146,Kz=147,Gz=47,Xz=68,OP=153,kP=70,RP=154,TP=72,Yz=155,Zz=76,Jz=160,eW=79,tW=80,nW=81,iW=167,AP=89,rW=90,oW=169,sW=97,aW=171,lW=98,cW=100,uW=101,H_=typeof process!="undefined"&&process.env&&/\bfparse(:dbg)?\b/.test(process.env.LOG),z_=typeof process!="undefined"&&process.env&&/\bfparse:dbg\b/.test(process.env.LOG),zr=typeof process!="undefined"&&process.env&&/\bcontext\b/.test(process.env.LOG),MP=[9,11,12,32,133,160,5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8232,8233,8239,8287,12288],fW=PP(` \r`),xP=42,hW=PP("'./-+*^");function PP(n){return Array.from(n).map(e=>e.charCodeAt(0))}function dW(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 pW(n){return hW.includes(n)}function mW(n){return n>=48&&n<=57||n===183||n>=768&&n<=879||n>=8255&&n<=8256}function gW(n){return MP.includes(n)}function bP(n,e){return e.concat(n.split(/\n/g).join(` `+e))}function yW(n,e=0){let t=n.peek(e);return t===xP&&n.peek(e+1)===xP?{offset:2,token:"**"}:pW(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(dW(s)||(i||t)&&mW(s))i||(i=!0),r.push(s);else return r.length?{token:String.fromCharCode(...r),offset:o}:null}}function DP(n,e){for(let t=!1,i=0;;i++){let r=n.peek(e+i);if(gW(r))t||(t=!0);else return t?{token:" ",offset:i}:null}}function vW(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&&yW(n,o)||c&&DP(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:EP}}if(!i.has(d)){if(_P.some(p=>p===d)){let p=s[0];a={token:p,offset:p.length,term:V_}}if(!_P.some(p=>p.startsWith(d)))return a}}}var xW={[V_]:"identifier",[EP]:"nameIdentifier"},bW=new gc((n,e)=>{z_&&console.log("%s: T ",n.pos);let t=vW(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:V_),H_&&console.log("%s: MATCH <%s> <%s>",n.pos,t?xW[t.term]:"identifier",r.token))},{contextual:!0}),_W=new gc((n,e)=>{z_&&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(Az),H_&&console.log("%s: MATCH <%s>",n.pos,i.token))}),wW=new gc((n,e)=>{z_&&console.log("%s: T ",n.pos);let t,i=!1;for(t=0;;t++){let r=n.peek(t);if(!MP.includes(r)){fW.includes(r)&&(i=!0);break}}if(i){let r=Dy(n,t+1);if(DP(n,t+1)||r&&/^(then|else|return|satisfies)$/.test(r.token))return;H_&&console.log("%s: MATCH ",n.pos),n.acceptToken(Mz)}}),CW={[Yz]:"FunctionInvocation",[RP]:"FilterExpression",[OP]:"PathExpression"},EW={[aW]:"Context",[oW]:"FunctionDefinition",[Dz]:"ForExpression",[iW]:"List",[jz]:"IfExpression",[qz]:"QuantifiedExpression"},SW={[sW]:"Context",[rW]:"FunctionDefinition",[Pz]:"ForExpression",[AP]:"List",[SP]:"IfExpression",[Fz]:"QuantifiedExpression",[Xz]:"PathExpression",[TP]:"FunctionInvocation",[kP]:"FilterExpression",[zz]:"ArithmeticExpression"},vc=class n{constructor(e){this.fn=e}get(e){return this.fn(e)}static of(e){return new n(e)}},OW={"date and time":1,date:1,time:1,duration:1},_P=Object.keys(OW);function kW(n){let e=[];for(let t=1;t<=n.length;t++)e.push(n.substring(0,t));return e}function IP(n,e){let t=W_(n),i=kW(t);e.keys.add(t);for(let r of i)e.prefixes.add(r);return e.originalMap.set(t,n),e}function wP(n){let e=LP();for(let t of n.getKeys())IP(t,e);return e}function LP(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 F_=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 vc||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 vc){i[r]=o;continue}if(Yr(i,r)){i[r]=this.__merge(i[r],o);continue}i[r]=o}return i}},q_=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 zr&&console.log("[%s] enter",t.path,t.context),t}exitScope(e){return this.parent?(zr&&console.log(`[%s] exit %o %s`,this.path,this.context,bP(e," ")),this.parent.pushChild(this)):(zr&&console.log(`[%s] NO exit %o %s`,this.path,this.context,bP(e," ")),this)}token(e){return zr&&console.log("[%s] token <%s> + <%s>",this.path,this.tokens.join(" "),e),this.assign({tokens:[...this.tokens,e]})}literal(e){return zr&&console.log("[%s] literal %o",this.path,e),this.pushChild(this.of({name:"Literal",value:e}))}computedValue(){for(let e=this;;e=yc(e.children)){if(!e)return null;if(!Xr(e.value))return e.value}}contextCache(){let e=this.cache.get(this.context);return e||(e=wP(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&&W_(e),i=this.contextCache().originalMap.get(t);if(typeof i=="undefined")return;let r=this.context.get(i);return r instanceof vc?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 zr&&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 zr&&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 zr&&console.log("[%s] no define <%s=%s>",this.path,e,t),this;zr&&console.log("[%s] define <%s=%s>",this.path,e,t);let i=this.context,r=i.set(e,t),o=this.cache.get(i)||wP(i),s=IP(e,LP(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 W_(n){return n.replace(/\s*([./\-'+]|\*\*?)\s*/g," $1 ").replace(/\s{2,}/g," ").trim()}function CP(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 U_(n={},e=F_){let t=q_.of({context:e.of(n)});return new My({start:t,reduce(i,r,o,s){if(r===SP){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===AP&&(i=i.assign({value:e.of(...i.children.map(f=>f==null?void 0:f.computedValue()))})),r===kP){let[f,h]=i.children.slice(-2);i=i.assign({value:f==null?void 0:f.computedValue()})}if(r===TP){let[f,...h]=i.children;(f==null?void 0:f.raw)==="get value"?i=TW(i,h):i=i.assign({value:(f==null?void 0:f.computedValue())||e.of(void 0)})}let a=EW[r];if(a)return i.enterScope(a);let l=CW[r];if(l){let{children:f,context:h}=i,d=f.slice(0,-1),p=yc(f),m=null;return r===OP&&(m=e.of(p==null?void 0:p.computedValue())),r===RP&&(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(SW[r])return i.exitScope(c);if(r===lW){let f=i.children.filter(p=>p.name!=="ContextEntry"),h=f[0],d=yc(f);return CP(i,"ContextEntry",c).assign({value:e.of(i.value).set(h==null?void 0:h.computedValue(),d==null?void 0:d.computedValue())})}if(r===Iz||r===Vz)return CP(i,"InExpression",c);if(r===$z)return i.define("partial",vc.of(f=>{var h;return(h=yc(f.children))==null?void 0:h.computedValue()}));if(r===Zz){let f=yc(i.children).computedValue();return i.define(f,1)}if(r===Wz||r===Uz||r===Qz){let f=i.children.slice(0,-1),h=yc(i.children);return i.assign({children:f}).enterScope("ArithmeticExpression").pushChild(h)}if(r===Kz)return i.enterScope("ArithmeticExpression");if(r===Bz||r===Nz||r===uW)return i.token(c);if(r===tW)return i.literal(c.replace(/^"|"$/g,"").replace(/\\(["\\])/g,"$1"));if(r===nW)return i.literal(c==="true");if(r===eW)return i.literal(parseFloat(c));if(r===Jz)return i.literal(null);if(r===Gz)return i.resolveName();if(r===Lz||r===cW)return i.declareName();if((r===vP||r===Hz)&&i.tokens.length>0)throw new Error("uncleared name");if(r===vP){let f=i;for(;f.parent;)f=f.exitScope(c);return f}return i}})}var RW=U_({});function TW(n,e){if(!e.length)return n.assign({value:null});if(e[0].name==="Name"&&(e=AW(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:[W_(r),r].reduce((s,a)=>o.get(a)||s,null)})}function AW(n,e){let t={};for(let i=0;it[i])}function yc(n){return n[n.length-1]}var MW=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 satisfies between return":B.controlKeyword,"in instance of and or":B.operatorKeyword,function:B.definitionKeyword,as:B.keyword,"Type/...":B.typeName,Wildcard:B.special(B.variableName),null:B.null,LineComment:B.lineComment,BlockComment:B.blockComment,'VariableName! "?"':B.variableName,"DateTimeConstructor! SpecialFunctionName!":B.function(B.special(B.variableName)),"List Interval":B.list,Context:B.definition(B.literal),"Name!":B.definition(B.variableName),"Key/Name! ContextEntryType/Name!":B.definition(B.propertyName),"PathExpression/VariableName!":B.function(B.propertyName),"FormalParameter/ParameterName!":B.function(B.definition(B.variableName)),"( )":B.paren,"[ ]":B.squareBracket,"{ }":B.brace,".":B.derefOperator,", ;":B.separator,"..":B.punctuation}),PW={__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},BP=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:RW,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:[MW],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:[_W,bW,wW,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=>PW[n]||-1}],tokenPrec:2567});function DW(n){let e=[];return n.iterate({enter:t=>{let i=t.node;if(!i.type.isError)return;let r=i.parent,o=$P(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 $P(n){return n?n.nextSibling||$P(n.parent):null}var IW="first-item",LW={create(n){return{enter(e){if(e.name!=="FilterExpression")return;let t=n.readContent(e.from,e.to);if(NP().test(t)){let{from:i,to:r}=e;n.report({from:i,to:r,message:"First item is accessed via [1]",severity:"warning",type:IW,actions:[{name:"fix",apply(o,s=i,a=r){n.updateContent(s,a,t.replace(NP(),"[1]"))}}]})}}}}};function NP(){return/\[\s*0\s*\]$/}var BW=[LW];function NW(n){let{readContent:e,syntaxTree:t,updateContent:i}=n,r=[],o={readContent:e,report:a=>{r.push(a)},updateContent:i},s=BW.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 $W(n){return[...DW(n.syntaxTree),...NW(n)]}var jP=()=>n=>{if(n.state.doc.length===0)return[];let e=rt(n.state);return $W({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 K_=[ai("function(${params}) ${body}",{label:"function",detail:"definition",type:"keyword"}),ai("for ${var} in ${collection} return ${value}",{label:"for",detail:"expression",type:"keyword"}),ai("every ${var} in ${collection} satisfies ${condition}",{label:"every",detail:"quantified expression",type:"keyword"}),ai("some ${var} in ${collection} satisfies ${condition}",{label:"some",detail:"quantified expression",type:"keyword"}),ai("if ${condition} then ${value} else ${other value}",{label:"if",detail:"block",type:"keyword"}),ai("{ ${key}: ${value} }",{label:"context",detail:"block",type:"keyword"}),ai("null",{label:"null",detail:"literal",type:"keyword"}),ai("true",{label:"true",detail:"literal",type:"keyword"}),ai("false",{label:"false",detail:"literal",type:"keyword"})];function Q_(){return Q_=Object.assign?Object.assign.bind():function(n){for(var e=1;e{let{state:i,pos:r}=t,o=HP(rt(i).resolveInner(r,-1),e);if(o){let[s,a]=o;if(FP.includes(a))return null}return n(t)}}function qW(n){return FW(hc(n.map(e=>Q_({},e,{type:"text"}))))}function qP(n,e,t){return VP(n,e,t,-1)}function VW(n,e,t){return VP(n,e,t,1)}function VP(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 HP(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 HW(n,e){let{nodes:t,before:i,after:r,keyword:o}=n;return s=>{let{state:a,pos:l}=s,c=HP(rt(a).resolveInner(l,-1),t);if(!c)return null;let[u]=c;return qP(u,l,[o,i])||VW(u,l,[o,r])||r&&!qP(u,l,[r])?null:e(s)}}var zP=uy.define({parser:BP.configure({props:[e_.add({Context:t_({closing:"}"}),"List FilterExpression":t_({closing:"]"}),"ParenthesizedExpression FunctionInvocation":dy({except:/^\s*\)/}),"ForExpression QuantifiedExpression IfExpression":dy({except:/^\s*(then|else|return|satisfies)\b/}),FunctionDefinition:dy({except:/^\s*(\(|\))/})}),YA.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:"*/"}}}}),zW=zP.configure({top:"UnaryTests"},"FEEL unary tests"),WW=zP.configure({top:"Expression"},"FEEL expression");function WP(n={}){let e=n.dialect==="unaryTests"?zW:WW,t=n.parserDialect,i=U_(n.context),r=e.configure({contextTracker:i,dialect:t}),o=n.completions||[qW(K_),G_].flat();return new fy(r,[...o.map(s=>r.data.of({autocomplete:s}))])}var UW=[{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")
    
    `}],QW=[{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"}}],UP=[...UW,...QW];var KW=[aP(jP())],GW=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}}),XW=U.baseTheme({"& .variableName":{color:"#10f"},"& .number":{color:"#164"},"& .string":{color:"#a11"},"& .bool":{color:"#219"},"& .function":{color:"#aa3731",fontWeight:"bold"},"& .control":{color:"#708"}}),YW=JA(lc.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"}])),ZW=[GW,XW,YW];function QP(n){return n&&n.from===n.to}function JW(n,e){let t=n.nextSibling;return QP(n)||t&&t.from===e&&QP(t)}function e6(n){return n&&n.parent&&n.parent.name==="VariableName"}function X_(n){return n?n.name==="PathExpression"?!0:X_(n.parent):!1}function t6({variables:n}){return e=>{let t=rt(e.state).resolve(e.pos,-1);if(!X_(t))return null;let i=n6(t),r=t===i?e.pos:t.from,o=Y_(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 n6(n){for(;n;){if(n.name==="PathExpression")return n;n=n.parent}}function Y_(n,e){let t=[];for(let i=n.firstChild;i;i=i.nextSibling)i.name==="PathExpression"?t.push(...Y_(i,e)):i.name==="FilterExpression"?t.push(...i6(i,e)):t.push({name:GP(i,e),isList:!1});return t}function i6(n,e){let t=n.firstChild;if(t.name==="PathExpression"){let i=Y_(t,e),r=i[i.length-1];return r.isList=!0,i}return[{name:GP(t,e),isList:!0}]}function GP(n,e){return e.state.sliceDoc(n.from,n.to)}function r6({variables:n=[],builtins:e=[]}){let t=o6(n,e),i=/^[\w ]*$/;return t.length?r=>{let{pos:o,state:s}=r,a=rt(s).resolve(o,-1);if(JW(a,o))return r.explicit?{from:o,options:t,validFor:i}:null;if(!e6(a)||X_(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 o6(n,e){return[].concat(n.map(t=>KP(t)),e.map(t=>KP(t)))}function KP(n,e){return n.type==="function"?s6(n,e):{label:n.name,type:"variable",info:n.info,detail:n.detail,boost:e}}function s6(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 ai(a,{label:c,type:"function",info:i,detail:r,boost:e})}function a6({variables:n=[],builtins:e=[]}){return[t6({variables:n}),r6({variables:n,builtins:e}),hc(K_),...G_]}function l6(n){return WP(n)}function c6(n){return n.slice().reverse().reduce((e,t)=>(e[t.name]=()=>{},e),{})}var XP=W.define(),YP=W.define(),ZP=W.define(),JP=W.define();function eD({dialect:n="expression",parserDialect:e,variables:t=[],builtins:i=[],completions:r=a6({builtins:i,variables:t})}){let o=c6([...t,...i]);return[ZP.of(n),XP.of(i),YP.of(t),JP.of(e),l6({dialect:n,parserDialect:e,context:o,completions:r})]}function u6(n){let e=n.facet(XP)[0],t=n.facet(YP)[0],i=n.facet(ZP)[0],r=n.facet(JP)[0];return{builtins:e,variables:t,dialect:i,parserDialect:r}}var f6=UP.map(n=>({...n,info:()=>te(n.info)})),tD=new Bs,nD=new Bs;function Wr({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=f6,variables:d=[]}){this._events=fP();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(Uh));if(!x.length)return;let _=x.flatMap(E=>E.value);this._events.emit("lint",{diagnostics:_})}),g=U.domEventObservers({keydown:a});typeof o=="string"&&(o=document.querySelector(o));let b=o?AA({tooltipSpace:function(){return o.getBoundingClientRect()}}):[],w=[xM(),tD.of(eD({dialect:e,builtins:h,variables:d,parserDialect:t})),iM(),XA(),yM(),U.contentAttributes.of(r),p,g,rc.of([...nP]),KW,m,b,nD.of(Tb(c)),ZW,...n];return u&&w.push(U.editable.of(!1)),this.on("lint",({diagnostics:v})=>l(v)),this._cmEditor=new U({state:Ke.create({doc:f,extensions:w}),parent:i}),this}Wr.prototype.setValue=function(n){this._cmEditor.dispatch({changes:{from:0,to:this._cmEditor.state.doc.length,insert:n}})};Wr.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}})}};Wr.prototype.on=function(n,e){this._events.on(n,e)};Wr.prototype.off=function(n,e){this._events.off(n,e)};Wr.prototype.getSelection=function(){return this._cmEditor.state.selection};Wr.prototype.setVariables=function(n){let e=u6(this._cmEditor.state);this._cmEditor.dispatch({effects:[tD.reconfigure(eD({...e,variables:n}))]})};Wr.prototype.setPlaceholder=function(n){this._cmEditor.dispatch({effects:nD.reconfigure(Tb(n))})};var ki=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(d6(this.node)){t.triggeredFromAutocomplete=!0;return}this.props.ctrlForNewline&&!h6(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 Wr({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)}),p6(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 h6(n){return n.metaKey||n.ctrlKey}function d6(n){return n.querySelector(".cm-tooltip-autocomplete")}function p6(n,e){return JSON.stringify(n)===JSON.stringify(e)}var Gh=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:ki}_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 xc=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),m6(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={},xe(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,Gh,{label:this.getValue("label"),text:this.getValue("text"),element:this.props.context.input,onChange:this.handleChange})}};xc.$inject=["debounceInput","modeling","injector"];function m6(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 bc=class{constructor(e,t,i,r){e.onGetComponent("cell",({cellType:o})=>{if(o==="input-header")return ch}),e.onGetComponent("context-menu",(o={})=>{if(o.contextMenuType==="input-edit")return xc}),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=Me(a,"th",!0),{left:c,top:u}=l.getBoundingClientRect();t.open({x:c,y:u,align:"bottom-right"},{contextMenuType:"input-edit",input:s})})}};bc.$inject=["components","contextMenu","eventBus","renderer"];var de=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});xe(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",iD)}removePortalEl(){this._portalEl&&(this._portalEl.removeEventListener("mousedown",iD),He(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)}};de.$inject=["keyboard","renderer"];function iD(n){n.stopPropagation()}var Xh=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;ne(r)?o={inputExpression:{typeRef:t}}:Se(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,de,{className:"type-ref-edit-select",label:o,onChange:this.onTypeChange,options:r,value:i})],4),2)}};var g6=750,_c=class{constructor(e){e.onGetComponent("context-menu",g6,(t={})=>{let{contextMenuType:i}=t;if(i==="input-edit"||i==="output-edit")return Xh})}};_c.$inject=["components"];var rD={__depends__:[Kt,Gi],__init__:["typeRefEditingProvider"],typeRefEditingProvider:["type",_c]};var wc=class extends se{constructor(e,t){super(e),this.postExecuted("element.updateProperties",i=>{let{element:r,properties:o}=i.context,s=ne(r)?o.inputExpression:o;if(s&&s.typeRef&&s.typeRef!=="string"){let a=O(r,"dmn:LiteralExpression")?r.$parent:r;t.editAllowedValues(a,null)}})}};wc.$inject=["eventBus","modeling"];var y6="radio",v6="remove dmn-icon-clear",Zs=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===y6&&(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=cr(i,"group"),l=x6(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",v6,null,1,{title:"Remove item",onClick:this.getRemoveClickHandler(h)})],0)),0)],0)}),0)}};function x6(n){let e=[];for(let t in n)e.push([t,n[t]]);return e}var tt=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,Ct,{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||b6(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 b6(n){return n===""}function oD(n){return n.map(e=>e.value)}var Yh=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&&oD(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(w6(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",[!Z_(r)&&r.length>0&&P(2,Zs,{labelComponent:_6,items:r,onChange:this.onListChange}),!Z_(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),!Z_(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,tt,{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 _6(n){return y(1,"label","dms-label",n,0)}function w6(n){return n===13}function Z_(n){return n===null}var C6=500,Cc=class{constructor(e){e.onGetComponent("context-menu",C6,(t={})=>{let{contextMenuType:i}=t;if(i==="input-edit"||i==="output-edit")return Yh})}};Cc.$inject=["components"];var sD={__init__:["allowedValuesUpdateBehavior","allowedValuesEditingProvider"],allowedValuesUpdateBehavior:["type",wc],allowedValuesEditingProvider:["type",Cc]};var Zh=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 Jh=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 Zh;if(r==="output-cell"&&o===a-1)return Jh}),t.on("addInput",()=>{e.trigger("addInput")}),t.on("addOutput",()=>{e.trigger("addOutput")})}By.$inject=["components","editorActions","eventBus"];var aD={__depends__:[Zn],__init__:["addInputOutputProvider"],addInputOutputProvider:["type",By]};var lD="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",Ec=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(lD)),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(lD)),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(Dr(c)&&!Ir(c)&&l===90)return t.trigger("undo"),!0}function o(l,c){if(Dr(c)&&(l===89||l===90&&Ir(c)))return t.trigger("redo"),!0}e.push(r),e.push(o);function s(l,c){if(!(l!==13||Dr(c)||!Ir(c))&&sh(c.target))return t.trigger("selectCellAbove"),!0}e.push(s);function a(l,c){if(l!==13||Dr(c)||Ir(c)||!sh(c.target))return;let u=t.trigger("selectCellBelow"),f=i.getCellSelection();if(!u&&f&&!E6(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)}};Ec.$inject=["config.keyboard","eventBus","editorActions","cellSelection","renderer"];function E6(n){return n==="__decisionProperties_name"}var It={__depends__:[Zn],__init__:["keyboard"],keyboard:["type",Ec]};var cD={__depends__:[aD,sD,Kt,Qt,Ut,Xn,It,rD],__init__:["inputEditingProvider","outputEditingProvider"],inputEditingProvider:["type",bc],outputEditingProvider:["type",Fl]};function J_(n,e,t){return(e=S6(e))in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function S6(n){var e=O6(n,"string");return typeof e=="symbol"?e:e+""}function O6(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 k6=`.dmn-decision-table-container td, .dmn-decision-table-container th`,Sc=class{constructor(e,t,i,r){J_(this,"handleDragOver",o=>{Ny(o);let s=o.target,a=Me(s,k6,!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"}),J_(this,"handleDrop",o=>{Ny(o);let s=this._emit("dragAndDrop.drop",o);if(s){let{draggedElement:a}=this._dragContext;if(a instanceof ut){let{rows:l}=this._sheet.getRoot(),c=l.indexOf(s);this._modeling.moveRow(a,c)}else if(a instanceof ft){let{cols:l}=this._sheet.getRoot(),c=l.indexOf(s);this._modeling.moveCol(a,c)}}this.handleDragEnd(o)}),J_(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)}};Sc.$inject=["eventBus","renderer","modeling","sheet"];function Ny(n,e){n.stopPropagation(),e!==!0&&n.preventDefault()}var uD={__init__:["dragAndDrop"],dragAndDrop:["type",Sc]};var tw="top",R6="right",T6="bottom",nw="left",Oc=class{constructor(e,t,i,r,o,s,a,l){M(this,"_cleanup",()=>{let e=this._renderer.getContainer();ew(e),D6(e),this._dragImage&&(He(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 ${ne(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 ut)return!0;if(f instanceof ft){let d=A6(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();ew(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 ut&&(g=pD(f,p)),h instanceof ft&&(g=dD(f,p)),d===g||(ew(m),h instanceof ut&&(g===tw?fD(p,m,"top"):fD(p,m,"bottom")),h instanceof ft&&(g===nw?hD(p,m,"left"):hD(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 ut){let p=pD(f,d),m=d.dataset.rowId,g=this._elementRegistry.get(m);if(!g||g===h)return;let b=I6(h,g,p,this._sheet.getRoot().rows);return b===h?void 0:b}if(h instanceof ft){let p=dD(f,d),m=d.dataset.colId,g=this._elementRegistry.get(m);if(!g||g===h)return;let b=L6(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 ut?M6(e,i):e instanceof ft&&P6(e,i),this._dragAndDrop.startDrag(e,t)}};Oc.$inject=["components","elementRegistry","eventBus","dragAndDrop","renderer","rules","sheet","translate"];function A6(n,e,t){let i=e.get(n.dataset.colId);if(!i)return-1;let{cols:r}=t.getRoot();return r.indexOf(i)}function fD(n,e,t){let i=n.dataset.rowId;if(!i)return;let r=dn(`[data-row-id=${i}]`,e);k(r,o=>{kc(o)&&(ee(o).add("dragover"),ee(o).add(t))})}function hD(n,e,t){let i=n.dataset.colId;if(!i)return;let r=dn(`[data-col-id=${i}]`,e);k(r,o=>{kc(o)&&(ee(o).add("dragover"),ee(o).add(t))})}function ew(n){let e=dn(".dragover",n);k(e,t=>{kc(t)&&(ee(t).remove("dragover"),ee(t).remove("top"),ee(t).remove("right"),ee(t).remove("bottom"),ee(t).remove("left"))})}function M6(n,e){let t=dn(`[data-row-id=${n.id}]`,e);k(t,i=>{kc(i)&&ee(i).add("dragged")})}function P6(n,e){let t=dn(`[data-col-id=${n.id}]`,e);k(t,i=>{kc(i)&&ee(i).add("dragged")})}function D6(n){let e=dn(".dragged",n);k(e,t=>{kc(t)&&ee(t).remove("dragged")})}function dD(n,e){let t=e.getBoundingClientRect();return n.clientXi.indexOf(e)&&(e=N6(e,i)),t===tw?B6(e,i):e}function L6(n,e,t,i){return i.indexOf(n)>i.indexOf(e)&&(e=j6(e,i)),t===nw?$6(e,i):e}function B6(n,e){let t=e.indexOf(n);return e[Math.max(0,t-1)]}function N6(n,e){let t=e.indexOf(n);return e[Math.min(e.length-1,t+1)]}function $6(n,e){let t=e.indexOf(n);if(Se(n)){let i=e.filter(o=>Se(o))[0],r=e.indexOf(i);return e[Math.max(r,t-1)]}return e[Math.max(0,t-1)]}function j6(n,e){let t=e.indexOf(n);if(ne(n)){let i=e.filter(s=>ne(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 kc(n){return n&&(n.nodeType===1||n.nodeType==11)}var mD={__depends__:[uD,wl],__init__:["dmnDragAndDrop"],dmnDragAndDrop:["type",Oc]};var ed=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&&F6(this.node).focus()}componentWillUnmount(){if(this._element){this._changeSupport.offElementsChanged(this._element.id,this.onElementsChanged);let{businessObject:t}=this._element,{description:i}=t;Pe(i)&&!i.length&&this.changeDescription(null)}}render(){if(!this._element)return;let{businessObject:t}=this._element,{description:i}=t;if(Pe(i))return y(1,"div","context-menu-container description-editor",P(2,iw,{className:"dms-input",onChange:this.changeDescription,value:i}),2,null,null,r=>this.node=r)}},iw=class extends sn{render(){return y(1,"div",this.getClassName(),this.getEditor(),0)}};function F6(n){return X(".content-editable",n)}var q6=500,V6=750,gD=26,Rc=class{constructor(e,t,i,r,o,s,a){M(this,"addDescription",e=>{this._modeling.updateProperties(e,{description:""});let t=this._renderer.getContainer(),r=Ki(e.id,t).getBoundingClientRect(),o=yD(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",V6,l=>{if(l.defaultPrevented)return;let{target:c,id:u}=l,f=i.get(u);if(!We(f,["dmn:UnaryTests","dmn:LiteralExpression"]))return;vD(f)||l.preventDefault();let d=s.getContainer(),p=c.getBoundingClientRect(),m=yD(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=vD(c);if(Pe(u))return ed}}),e.onGetComponent("context-menu-cell-additional",q6,(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=Pe(h),p=d?"remove-description":"add-description",m=d?()=>this.removeDescription(u):()=>this.addDescription(u);return y(1,"div",`context-menu-group-entry ${p}`,Pe(h)?this._translate("Remove cell description"):this._translate("Add cell description"),0,{onClick:m})}})}};Rc.$inject=["components","contextMenu","elementRegistry","eventBus","modeling","renderer","translate"];function yD(n,e){let{top:t,left:i,width:r,height:o}=e;return{x:i+n.parentNode.scrollLeft-gD,y:t+n.parentNode.scrollTop,width:r+2*gD,height:o}}function vD(n){return n&&n.businessObject&&n.businessObject.description}var xD={__depends__:[Kt,xl],__init__:["description"],description:["type",Rc]};var Tc=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,de,{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,de,{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 ze(e).expressionLanguage||this._getDefaultElementExpressionLanguage(e)}_getDefaultElementExpressionLanguage(e){return this._expressionLanguages.getDefault(ne(e.col)?"inputCell":"outputCell").value}};Tc.$inject=["components","elementRegistry","modeling","expressionLanguages","translate","contextMenu"];var bD={__depends__:[Ut],__init__:["expressionLanguage"],expressionLanguage:["type",Tc]};var Ac=class extends L{constructor(t,i){super(t,i);M(this,"onElementsChanged",()=>{this.forceUpdate()});M(this,"setDecisionTableName",t=>{this.modeling.editDecisionTableName(t)});xe(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")||H6;return y(1,"div","decision-table-properties",[P(2,rw,{label:this.translate("Decision name"),className:"decision-table-name",value:i,ctrlForNewline:!0,onBlur:z6,onChange:this.setDecisionTableName,elementId:"__decisionProperties_name",coords:"0:__decisionProperties"}),y(1,"div","decision-table-header-separator"),P(2,r)],4)}};Ac.$inject=["sheet","modeling","changeSupport","components","translate"];var rw=class extends sn{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),Wt(this,Gf)}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 H6(){return null}function z6(n){n.target.scroll(0,0)}var W6=500,Mc=class{constructor(e){e.onGetComponent("table.before",W6,()=>Ac)}};Mc.$inject=["components"];var _D={__depends__:[Qt],__init__:["decisionTableProperties"],decisionTableProperties:["type",Mc]};var Pc=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"),xe(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=me(ih,a=>U6(a.value,{aggregation:r,hitPolicy:o}));return y(1,"div","hit-policy",[y(1,"label","dms-label",this._translate("Hit policy:"),0),P(2,de,{className:"hit-policy-edit-policy-select",label:this._translate("Hit policy"),onChange:this.onChange,options:ih.map(a=>({...a,label:this._translate(a.label)})),value:s.value,"data-hit-policy":"true",noInput:!0})],4,{title:this._translate(s.explanation)})}};Pc.$inject=["changeSupport","sheet","modeling"];function U6(n,e){return n.hitPolicy===e.hitPolicy&&n.aggregation===e.aggregation}function $y(n){n.onGetComponent("hit-policy",()=>Pc)}$y.$inject=["components"];var wD={__depends__:[Kt],__init__:["hitPolicyProvider"],hitPolicyProvider:["type",$y]};var Dc=class extends se{constructor(e,t){super(e),this.executed(["row.add","row.remove","col.add","col.remove"],CD(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"],CD(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)}};Dc.$inject=["eventBus","sheet"];function CD(n){return function(e){var t=e.context,i=t.row||t.col;O(i,"dmn:DMNElement")&&n(e)}}var Ic=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))}};Ic.$inject=["moddle"];var Lc=class extends Ts{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})}};Lc.$inject=["dmnFactory"];var Bc=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()}};Bc.$inject=["sheet","elementFactory"];var Nc=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()}};Nc.$inject=["sheet"];var $c=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)}};$c.$inject=["modeling"];var jc=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()}};jc.$inject=["sheet","elementFactory"];var Fc=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()}};Fc.$inject=["sheet","elementFactory"];var qc=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)}};qc.$inject=["modeling"];var td=class{execute(e){let{cell:t}=e;return t}revert(e){let{cell:t}=e;return t}};var Vc=class n{constructor(e,t,i){this._eventBus=e,this._elementFactory=t,this._commandStack=i,e.on("table.init",()=>{Q6(this.getHandlers(),i)})}getHandlers(){return n._getHandlers()}static _getHandlers(){return{"row.add":Bc,"row.remove":Nc,"row.move":$c,"col.add":jc,"col.remove":Fc,"col.move":qc,"cell.edit":td}}_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)}};Vc.$inject=["eventBus","elementFactory","commandStack"];function Q6(n,e){k(n,function(t,i){e.registerHandler(i,t)})}var Hc=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}};Hc.$inject=["dmnFactory","moddle","modeling"];function jy(n){return n===null}var ow="id",or=class{constructor(e,t){this._elementRegistry=e,this._moddle=t}execute(e){let{element:t,properties:i}=e,r=ze(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=ze(t),{changed:o}=this.updateProperties(r,i);return[...o,t]}updateProperties(e,t){let i=this._moddle.ids;return nt(t,(r,o,s)=>{let a=e.get(s);if(ED(o)){if(!ED(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===ow&&K6(e,o)&&(i.unclaim(e[ow]),this._elementRegistry.updateId(e,o),i.claim(o,e)),e.set(s,o),{changed:r.changed,oldProperties:{...r.oldProperties,[s]:a}}},{changed:[],oldProperties:{}})}};or.$inject=["elementRegistry","moddle"];function K6(n,e){return n[ow]!==e}function ED(n){return Te(n)&&Ae(n)}var zc=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)}};zc.$inject=["moddle"];var Wc=class n extends Vc{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:Hc,"element.updateProperties":or,"id.updateClaim":zc})}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)}};Wc.$inject=["eventBus","elementFactory","commandStack","sheet"];var Uc=class extends se{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))})}};Uc.$inject=["eventBus","moddle","modeling"];var Qc=class extends se{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))})}};Qc.$inject=["eventBus","modeling"];var SD={__init__:["idClaimBehavior","idUnclaimBehavior"],idClaimBehavior:["type",Uc],idUnclaimBehavior:["type",Qc]};var OD={__init__:["dmnUpdater","idChangeBehavior","nameChangeBehavior","modeling"],__depends__:[SD,vs],dmnUpdater:["type",Dc],dmnFactory:["type",Ic],elementFactory:["type",Lc],idChangeBehavior:["type",Kn],nameChangeBehavior:["type",qi],modeling:["type",Wc]};var nd=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,aw,{placeholder:s?"-":"",onChange:this.changeCellValue,value:a.text,businessObject:a})})}},sw=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,ki,{...this.props,autoFocus:!0,onBlur:this.onBlur})),En(P(2,Tn,{...this.props,onInput:()=>{},onFocus:this.onFocus}))],0,{onClick:this.onFocus})}},aw=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()?sw: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",[Pe(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 G6=1500,Kc=class{constructor(e){e.onGetComponent("cell",G6,({cellType:t})=>{if(t==="rule")return nd})}};Kc.$inject=["components"];var kD={__depends__:[Qt,tg],__init__:["decisionRulesEditor"],decisionRulesEditor:["type",Kc]};var Fy=4,Gc=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},xe(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=X6(o),a=!Y6(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=Ki(e.id,r).getBoundingClientRect(),l=this.node.getBoundingClientRect(),{scrollLeft:c,scrollTop:u}=J6(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:Ki(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}};Gc.$inject=["debounceInput","elementRegistry","eventBus","expressionLanguages","renderer","selection","simpleMode"];function X6(n){return n.businessObject.expressionLanguage}function Y6(n,e,t){return!e||e===Z6(n,t)}function Z6(n,e){if(ne(n.col))return e.getDefault("inputCell").value;if(Se(n.col))return e.getDefault("outputCell").value}function J6(n){let e=Me(n,".tjs-table-container");if(!e)return{scrollTop:0,scrollLeft:0};let{scrollLeft:t,scrollTop:i}=e;return{scrollTop:i,scrollLeft:t}}var Xc=class{constructor(e,t,i,r,o){this._providers=[],e.onGetComponent("table.before",()=>Gc),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(e8(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)}};Xc.$inject=["components","contextMenu","elementRegistry","eventBus","renderer"];function e8(n){return n.altKey?!1:n.ctrlKey||n.metaKey}var Jt={__depends__:[Kt,Po,Ut],__init__:["simpleMode"],simpleMode:["type",Xc]};function RD(n){if(!n||t8(n))return"none";if(n.trim()==="true")return"true";if(n.trim()==="false")return"false"}function t8(n){return n===""}var n8="true",i8="false",lw="none",id=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=RD(i.businessObject.text);this.state={value:r||lw},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===lw?"":e),this.setState({value:e})}render(){let{value:e}=this.state,t=[{label:"-",value:lw},{label:this._translate("Yes"),value:n8},{label:this._translate("No"),value:i8}];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,de,{label:this._translate("Boolean value"),noInput:!0,className:"dms-block",onChange:this.onChange,options:t,value:e})],4)}};var Yc=class{constructor(e,t){t.registerProvider(i=>(ne(i.col)||Se(i.col))&&TD(i)==="boolean"),e.onGetComponent("context-menu",(i={})=>{if(i.contextMenuType&&i.contextMenuType==="simple-mode-edit"){if(!i.element)return;if(TD(i.element)==="boolean")return id}})}};Yc.$inject=["components","simpleMode"];function TD(n){return ne(n.col)?n.col&&n.col.businessObject.inputExpression.typeRef:n.col&&n.col.businessObject.typeRef}var AD={__depends__:[It,Jt],__init__:["simpleBooleanEdit"],simpleBooleanEdit:["type",Yc]};var r8=/^\d{4}(?:-\d\d){2}$/,o8=/^\[date\("([^"]*)"\)..date\("([^"]*)"\)\]$/,s8=/^(<|>)\s*date\("([^"]*)"\)$/,a8=/^date\("([^"]*)"\)$/,l8="exact",c8="before",u8="after",f8="between";function zo(n){if(!r8.test(n.trim()))return"Date must match pattern yyyy-MM-dd"}function Ur(n,e){if(n===l8)return`date("${e[0]}")`;if(n===c8)return`< date("${e[0]}")`;if(n===u8)return`> date("${e[0]}")`;if(n===f8)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 Js(n){if(!n||n.trim()==="")return{type:"exact",date:""};let e=n.match(o8);if(e)return{type:"between",dates:[e[1],e[2]]};if(e=n.match(s8),e)return{type:e[1]==="<"?"before":"after",date:e[2]};if(e=n.match(a8),e)return{type:"exact",date:e[1]}}var MD="exact",h8="before",d8="after",rd="between",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=Js(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:MD,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}),Js(Ur(e,i))&&this.editCell(t.businessObject,Ur(e,i))}onSetStartDateTodayClick(){let{element:e}=this.props.context,{dates:t,type:i}=this.state,r=Bn();this.setState({dates:[r,t[1]]}),Js(Ur(i,[r,t[1]]))&&this.editCell(e.businessObject,Ur(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]}),Js(Ur(i,[t[0],r]))&&this.editCell(e.businessObject,Ur(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,Ur(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,Ur(r,[i[0],e]))}render(){let{dates:e,type:t}=this.state,i=[{label:this._translate("Exactly"),value:MD},{label:this._translate("Before"),value:h8},{label:this._translate("After"),value:d8},{label:this._translate("Between"),value:rd}];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,de,{label:this._translate("Test type"),noInput:!0,onChange:this.onTypeChange,options:i,value:t}),2),y(1,"h4","dms-heading",t===rd?this._translate("Edit start date"):this._translate("Set date"),0),y(1,"div",null,[P(2,tt,{label:t===rd?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===rd&&y(1,"h4","dms-heading",this._translate("Edit end date"),0),t===rd&&y(1,"div",null,[P(2,tt,{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 sd=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=Js(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,tt,{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 Zc=class{constructor(e,t){t.registerProvider(i=>{let r=PD(i);return(ne(i.col)||Se(i.col))&&DD(r)}),e.onGetComponent("context-menu",(i={})=>{if(i.contextMenuType&&i.contextMenuType==="simple-mode-edit"){if(!i.element)return;let r=PD(i.element);if(DD(r)){if(ne(i.element.col))return od;if(Se(i.element.col))return sd}}})}};Zc.$inject=["components","simpleMode"];function PD(n){return ne(n.col)?n.col&&n.col.businessObject.inputExpression.typeRef:n.col&&n.col.businessObject.typeRef}function DD(n){return n==="date"}var ID={__depends__:[It,Jt],__init__:["simpleDateEdit"],simpleDateEdit:["type",Zc]};var p8=/^\d{4}(?:-\d\d){2}T(?:\d\d:){2}\d\d(?:Z|(?:[@+-][^")]+))?$/,m8=/^\[date and time\("([^"]*)"\)..date and time\("([^"]*)"\)\]$/,g8=/^(<|>)\s*date and time\("([^"]*)"\)$/,y8=/^date and time\("([^"]*)"\)$/,v8="exact",x8="before",b8="after",_8="between";function Wo(n){if(!p8.test(n.trim()))return"Date and time must match pattern yyyy-MM-ddTHH:mm:ss[time zone]"}function Qr(n,e){if(n===v8)return`date and time("${e[0]}")`;if(n===x8)return`< date and time("${e[0]}")`;if(n===b8)return`> date and time("${e[0]}")`;if(n===_8)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 ea(n){if(!n||n.trim()==="")return{type:"exact",date:""};let e=n.match(m8);if(e)return{type:"between",dates:[e[1],e[2]]};if(e=n.match(g8),e)return{type:e[1]==="<"?"before":"after",date:e[2]};if(e=n.match(y8),e)return{type:"exact",date:e[1]}}var LD="exact",w8="before",C8="after",ad="between",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);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:LD,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=Uo();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=Uo();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:LD},{label:this._translate("Before"),value:w8},{label:this._translate("After"),value:C8},{label:this._translate("Between"),value:ad}];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,de,{label:this._translate("Test type"),noInput:!0,onChange:this.onTypeChange,options:i,value:t}),2),y(1,"h4","dms-heading",t===ad?this._translate("Edit start date and time"):this._translate("Set date and time"),0),y(1,"div",null,[P(2,tt,{label:t===ad?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===ad&&y(1,"h4","dms-heading",this._translate("Edit end date and time"),0),t===ad&&y(1,"div",null,[P(2,tt,{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 cd=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=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,tt,{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 Jc=class{constructor(e,t){t.registerProvider(i=>{let r=BD(i);return(ne(i.col)||Se(i.col))&&ND(r)}),e.onGetComponent("context-menu",(i={})=>{if(i.contextMenuType&&i.contextMenuType==="simple-mode-edit"){if(!i.element)return;let r=BD(i.element);if(ND(r)){if(ne(i.element.col))return ld;if(Se(i.element.col))return cd}}})}};Jc.$inject=["components","simpleMode"];function BD(n){return ne(n.col)?n.col&&n.col.businessObject.inputExpression.typeRef:n.col&&n.col.businessObject.typeRef}function ND(n){return n==="dateTime"}var $D={__depends__:[It,Jt],__init__:["simpleDateTimeEdit"],simpleDateTimeEdit:["type",Jc]};var cw={equals:"=",less:"<",lessEquals:"<=",greater:">",greaterEquals:">="};function E8(n){return hi(cw).filter(e=>n===cw[e])[0]}function jD(n){if(!n||S8(n.trim()))return{type:"comparison",values:[]};let e=R8(n);if(e)return e;let t=T8(n);if(t)return t}function S8(n){return n===""}function qy(n,e){return n==="equals"?`duration("${e}")`:`${cw[n]} duration("${e}")`}function eu(n,e,t,i){return`${t==="exclude"?"]":"["}duration("${n}")..duration("${e}")${i==="exclude"?"[":"]"}`}function FD(n,e){if(n==="yearMonthDuration")return O8(e);if(n==="dayTimeDuration")return k8(e)}function O8(n){return/^P(\d+Y\d+M|\d+Y|\d+M)$/.test(n)}function k8(n){return/^P(\d+DT\d+H|\d+D|T\d+H)$/.test(n)}function uw(n){let e=/^duration\("([^"]*)"\)$/.exec(n);return e&&e[1]}function R8(n){let e=uw(n);if(e)return{type:"comparison",operator:"equals",values:[e]};let{operator:t,value:i}=qD(/^(?=|(:?<|>)=?)\s*duration\("(?[^"]*)"\)$/,n);if(t&&i)return{type:"comparison",values:[i],operator:E8(t)}}function T8(n){let{start:e,end:t,firstValue:i,secondValue:r}=qD(/^(?[[\]])duration\("(?[^"]*)"\)\.\.duration\("(?[^"]*)"\)(?[[\]])$/,n);if(e&&t)return{type:"range",values:[i,r],start:e==="]"?"exclude":"include",end:t==="["?"exclude":"include"}}function qD(n,e){let{groups:t}=n.exec(e)||{groups:{}};return t}var A8={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(!FD(this._type,e))return this._translate(A8[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,tt,{label:this.props.label,type:"text",onInput:this.onInput,placeholder:this._getPlaceholder(),validate:this.validate,value:this.state.value,className:this.props.className})}};var tu="comparison",nu="range",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;this._type=M8(i);let r=jD(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:tu,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===tu?this.editCell(t.businessObject,qy(i,r)):this.editCell(t.businessObject,eu(r,o,s,a)),this.setState({type:e})}onComparisonOperatorChange(e){let{element:t}=this.props.context,{type:i,startValue:r}=this.state;i===tu&&(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===tu&&(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===nu&&(this.editCell(t.businessObject,eu(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===nu&&(this.editCell(t.businessObject,eu(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===nu&&(this.editCell(t.businessObject,eu(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===nu&&(this.editCell(t.businessObject,eu(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,de,{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,de,{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,de,{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:tu},{label:this._translate("Range"),value:nu}];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,de,{label:this._translate("Test type"),noInput:!0,onChange:this.onTypeChange,options:a,value:e}),2),e===tu&&this.renderComparison(t,i),e===nu&&this.renderRange(i,r,o,s)],0)}};function M8(n){return n.col.businessObject.inputExpression.typeRef}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;this._type=P8(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=uw(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 P8(n){return n.col.businessObject.typeRef}var iu=class{constructor(e,t){t.registerProvider(i=>{let r=VD(i);return(ne(i.col)||Se(i.col))&&HD(r)}),e.onGetComponent("context-menu",(i={})=>{if(i.contextMenuType&&i.contextMenuType==="simple-mode-edit"){if(!i.element)return;let r=VD(i.element);if(HD(r)){if(ne(i.element.col))return ud;if(Se(i.element.col))return fd}}})}};iu.$inject=["components","simpleMode"];function VD(n){return ne(n.col)?n.col&&n.col.businessObject.inputExpression.typeRef:n.col&&n.col.businessObject.typeRef}var D8=["yearMonthDuration","dayTimeDuration"];function HD(n){return D8.includes(n)}var zD={__depends__:[It,Jt],__init__:["simpleDurationEdit"],simpleDurationEdit:["type",iu]};var I8=/^(-?(?:[0-9]|\.[0-9])+)$|^((?:<|>|=){0,2})\s*(-?(?:[0-9]|\.[0-9])+)$/,L8=/^(\[|\]){1}(-?(?:[0-9]|\.[0-9])+){1,}\.\.(-?(?:[0-9]|\.[0-9])+){1,}(\[|\]){1}$/,fw={equals:"=",less:"<",lessEquals:"<=",greater:">",greaterEquals:">="};function B8(n){return hi(fw).filter(e=>n===fw[e])[0]}function Vy(n){if(!n||N8(n.trim()))return{type:"comparison"};let e=n.match(I8),t=n.match(L8);if(e){if($8(e))return{type:"comparison",value:parseFloat(e[1]),operator:"equals"};if(j8(e))return{type:"comparison",value:parseFloat(e[3]),operator:B8(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 N8(n){return n===""}function $8(n){return n[0]&&n[1]&&!n[2]&&!n[3]}function j8(n){return n[0]&&!n[1]&&n[2]&&n[3]}function Hy(n,e){return n==="equals"?`${e}`:`${fw[n]} ${e}`}function ru(n,e,t,i){return`${t==="exclude"?"]":"["}${n}..${e}${i==="exclude"?"[":"]"}`}var ou="comparison",su="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,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:ou,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===ou?this.editCell(t.businessObject,Hy(i,r)):this.editCell(t.businessObject,ru(o,s,a,l)),this.setState({type:e})}onComparisonOperatorChange(e){let{element:t}=this.props.context,{type:i,comparisonValue:r}=this.state;i===ou&&(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===ou&&(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===su&&(this.editCell(t.businessObject,ru(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===su&&(this.editCell(t.businessObject,ru(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===su&&(this.editCell(t.businessObject,ru(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===su&&(this.editCell(t.businessObject,ru(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,de,{label:this._translate("Comparison operator"),noInput:!0,onChange:this.onComparisonOperatorChange,options:i,value:e}),Z("\xA0"),P(2,Ct,{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,de,{label:this._translate("Start value"),noInput:!0,onChange:this.onRangeStartTypeChange,options:o,value:i}),Z("\xA0"),P(2,Ct,{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,de,{label:this._translate("End value"),noInput:!0,onChange:this.onRangeEndTypeChange,options:o,value:r}),Z("\xA0"),P(2,Ct,{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:ou},{label:this._translate("Range"),value:su}];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,de,{label:this._translate("Test type"),noInput:!0,onChange:this.onTypeChange,options:l,value:e}),2),e===ou&&this.renderComparison(t,i),e===su&&this.renderRange(r,o,s,a)],0)}};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,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,Ct,{onInput:this.onInput,type:"number",value:e})],4)}};var au=class{constructor(e,t){t.registerProvider(i=>{let r=WD(i);return(ne(i.col)||Se(i.col))&&UD(r)}),e.onGetComponent("context-menu",(i={})=>{if(i.contextMenuType&&i.contextMenuType==="simple-mode-edit"){if(!i.element)return;let r=WD(i.element);if(UD(r)){if(ne(i.element.col))return hd;if(Se(i.element.col))return dd}}})}};au.$inject=["components","simpleMode"];function WD(n){return ne(n.col)?n.col&&n.col.businessObject.inputExpression.typeRef:n.col&&n.col.businessObject.typeRef}var F8=["number","integer","long","double"];function UD(n){return F8.includes(n)}var QD={__depends__:[It,Jt],__init__:["simpleNumberEdit"],simpleNumberEdit:["type",au]};function pd(n){if(!n||GD(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 KD(n){let e=ne(n)?n.inputValues:n.outputValues;return!e||GD(e.text)?[]:e.text.split(",").map(t=>t.trim())}function GD(n){return n===""}var ta="disjunction",zy="negation",q8="Predefined values",V8="Predefined values",H8="Custom values",md=class extends L{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),this._modeling=t.injector.get("modeling");let i=pd(e.context.element.businessObject.text);i||(i={values:[],type:ta});let r=KD(e.context.element.col.businessObject),o=i.values.filter(u=>!dw(r,u)),s=ne(e.context.element.col),a=r.map(u=>({value:u,isChecked:dw(i.values,u),isRemovable:!1,group:s?this._translate(q8):this._translate(V8)}));s&&(a=a.concat(o.map(u=>({value:u,isChecked:!0,isRemovable:!0,group:this._translate(H8)}))));let l="";!s&&i.values.length&&!dw(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=hw(t),{element:r}=this.props.context;e===ta?(this.editCell(r.businessObject,i.join(",")),this.setState({unaryTestsType:ta})):(this.editCell(r.businessObject,`not(${i.join(",")})`),this.setState({unaryTestsType:zy}))}onUnaryTestsListChanged(e){let t=hw(e),{element:i}=this.props.context,{unaryTestsType:r}=this.state;r===ta?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=pd(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;!ne(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=ne(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=pd(e);if(!r)return;let{element:o}=this.props.context,s=hw(t),a=[].concat(s,r.values);i===ta?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:ta},{label:this._translate("Match none"),value:zy}],a=ne(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,de,{label:this._translate("String value"),noInput:!0,onChange:this.onUnaryTestsTypeChange,options:s,value:l?zy:ta},null,u=>this.selectNode=u),2),P(2,Zs,{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,tt,{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(!pd(u))return this._translate("Strings must be in double quotes")},value:t})],0)],0)}};function z8(n){return n===13}function hw(n){return n.filter(e=>e.isChecked).map(e=>e.value)}function dw(n,e){return n.indexOf(e)!==-1}var lu=class{constructor(e,t){t.registerProvider(i=>(ne(i.col)||Se(i.col))&&XD(i)==="string"),e.onGetComponent("context-menu",(i={})=>{if(i.contextMenuType&&i.contextMenuType==="simple-mode-edit"){if(!i.element)return;if(XD(i.element)==="string")return md}})}};lu.$inject=["components","simpleMode"];function XD(n){return ne(n.col)?n.col&&n.col.businessObject.inputExpression.typeRef:n.col&&n.col.businessObject.typeRef}var YD={__depends__:[It,Jt],__init__:["simpleStringEdit"],simpleStringEdit:["type",lu]};var W8=/^(?:\d\d:){2}\d\d(?:Z|(?:[@+-][^")]+))?$/,U8=/^\[time\("([^"]*)"\)..time\("([^"]*)"\)\]$/,Q8=/^(<|>)\s*time\("([^"]*)"\)$/,K8=/^time\("([^"]*)"\)$/,G8="exact",X8="before",Y8="after",Z8="between";function Ko(n){if(!W8.test(n.trim()))return"Time must match pattern hh:mm:ss[time zone]"}function Kr(n,e){if(n===G8)return`time("${e[0]}")`;if(n===X8)return`< time("${e[0]}")`;if(n===Y8)return`> time("${e[0]}")`;if(n===Z8)return`[time("${e[0]}")..time("${e[1]}")]`}function gd(){return new Date().toISOString().slice(11,-5)+"Z"}function na(n){if(!n||n.trim()==="")return{type:"exact",time:""};let e=n.match(U8);if(e)return{type:"between",times:[e[1],e[2]]};if(e=n.match(Q8),e)return{type:e[1]==="<"?"before":"after",time:e[2]};if(e=n.match(K8),e)return{type:"exact",time:e[1]}}var ZD="exact",J8="before",e9="after",Wy="between",yd=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=na(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:ZD,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}),na(Kr(e,i))&&this.editCell(t.businessObject,Kr(e,i))}onSetStartTimeNowClick(){let{element:e}=this.props.context,{times:t,type:i}=this.state,r=gd();this.setState({times:[r,t[1]]}),na(Kr(i,[r,t[1]]))&&this.editCell(e.businessObject,Kr(i,[r,t[1]]))}onSetEndTimeNowClick(){let{element:e}=this.props.context,{times:t,type:i}=this.state,r=gd();this.setState({times:[t[0],r]}),na(Kr(i,[t[0],r]))&&this.editCell(e.businessObject,Kr(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,Kr(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,Kr(r,[i[0],e]))}render(){let{times:e,type:t}=this.state,i=[{label:this._translate("Exactly"),value:ZD},{label:this._translate("Before"),value:J8},{label:this._translate("After"),value:e9},{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,de,{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,tt,{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,tt,{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 vd=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=na(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=gd();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,tt,{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 cu=class{constructor(e,t){t.registerProvider(i=>{let r=JD(i);return(ne(i.col)||Se(i.col))&&e2(r)}),e.onGetComponent("context-menu",(i={})=>{if(i.contextMenuType&&i.contextMenuType==="simple-mode-edit"){if(!i.element)return;let r=JD(i.element);if(e2(r)){if(ne(i.element.col))return yd;if(Se(i.element.col))return vd}}})}};cu.$inject=["components","simpleMode"];function JD(n){return ne(n.col)?n.col&&n.col.businessObject.inputExpression.typeRef:n.col&&n.col.businessObject.typeRef}function e2(n){return n==="time"}var t2={__depends__:[It,Jt],__init__:["simpleTimeEdit"],simpleTimeEdit:["type",cu]};var uu=class extends L{constructor(t,i){super(t,i);M(this,"onElementsChanged",()=>{this.forceUpdate()});M(this,"handleMouseDown",t=>{let i=Me(t.target,"th",!1);t9({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)});xe(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=ze(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})}};uu.$inject=["sheet","changeSupport","translate","modeling"];function t9({node:n,event:e,minWidth:t,onEnd:i=n9}){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 n9(){}function Uy(n){n.onGetComponent("cell-inner",(e={})=>{let{cellType:t}=e;if(t==="input-cell"||t==="output-cell"||t==="annotations")return uu})}Uy.$inject=["components"];var n2={__init__:["columnResizeProvider"],columnResizeProvider:["type",Uy]};var xd=class n extends Ao{getModules(){return[...Ao._getModules(),...n._getModules()]}static _getModules(){return[SR,AR,Po,Kt,lg,PR,DR,Gi,IR,Zn,cD,n2,mD,xD,bD,Ut,Xn,It,_D,cg,wD,xl,OD,kD,Mo,Jt,AD,ID,$D,zD,QD,YD,t2,Ja]}};var fu=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 hu=class{constructor(e,t,i,r,o){let{container:s}=i;this._container=s,r.on("renderer.mount",()=>{va(P(2,_d,{injector:o}),s)}),r.on("renderer.unmount",()=>{va(null,s)})}getContainer(){return this._container}};hu.$inject=["changeSupport","components","config.renderer","eventBus","injector"];var i2={__init__:["changeSupport","components","renderer"],changeSupport:["type",fu],components:["type",bd],eventBus:["type",st],renderer:["type",hu]};var ia=class{constructor(e={}){let{injector:t}=e;if(!t){let{modules:i,config:r}=this._init(e);t=r9(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 r9(n,e){let t=[{config:["value",n]},i2].concat(e||[]),i=new os(t);return i.init(),i}var du=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}};du.$inject=["viewer","eventBus"];var r2={__init__:["elementRegistry"],elementRegistry:["type",du]};var wd=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 o9=1500,pu=class{constructor(e){e.onGetComponent("viewer",o9,()=>wd)}};pu.$inject=["components"];var o2={__init__:["decisionProperties"],decisionProperties:["type",pu]};var Cd=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 s9=500,mu=class{constructor(e){e.onGetComponent("viewer",s9,()=>Cd)}};mu.$inject=["components"];var s2={__depends__:[],__init__:["literalExpressionProperties"],literalExpressionProperties:["type",mu]};var a9=2e3,gu=class{constructor(e){e.onGetComponent("viewer",a9,()=>co)}};gu.$inject=["components"];var a2={__init__:["poweredBy"],poweredBy:["type",gu]};var Ed=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 yu=class{constructor(e){e.onGetComponent("viewer",()=>Ed)}};yu.$inject=["components"];var l2={__init__:["textarea"],textarea:["type",yu]};var vu=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)}};vu.$inject=["translate"];var l9=2e3,xu=class{constructor(e,t,i,r){this._injector=r,this._viewer=t,e.onGetComponent("viewer",l9,()=>{if(this.canViewDrd())return vu}),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 c9(this._viewer.getDecision())}};xu.$inject=["components","viewer","eventBus","injector"];function c9(n){return n.$parent}var c2={__init__:["viewDrd"],viewDrd:["type",xu]};var Go=class n extends ia{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",{}),He(e))}destroy(){super.destroy(),this.detach()}getModules(){return n._getModules()}static _getModules(){return[r2,$e,o2,s2,a2,l2,c2]}static _createContainer(){return te('
    ')}};var Sd=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,pw,{label:this._translate("Decision name"),className:"decision-name editor",value:t,onBlur:u9,onChange:this.setDecisionName}),2)}},pw=class extends sn{render(){return y(1,"h3",this.getClassName(),this.getEditor(),0)}};function u9(n){n.target.scroll(0,0)}var f9=1500,bu=class{constructor(e){e.onGetComponent("viewer",f9,()=>Sd)}};bu.$inject=["components"];var u2={__depends__:[Qt,$e],__init__:["decisionProperties"],decisionProperties:["type",bu]};var f2="is not a registered action",h9="is already registered",_u=class{constructor(e,t){this._actions={undo(){e.undo()},redo(){e.redo()}}}trigger(e,t){if(!this._actions[e])throw mw(e,f2);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 mw(e,h9);this._actions[e]=t}unregister(e){if(!this.isRegistered(e))throw mw(e,f2);this._actions[e]=void 0}isRegistered(e){return!!this._actions[e]}};_u.$inject=["commandStack","eventBus"];function mw(n,e){return new Error(n+" "+e)}var h2={__init__:["editorActions"],editorActions:["type",_u]};function gw(n){return n.altKey?!1:n.ctrlKey||n.metaKey}function yw(n){return n.shiftKey}var d2="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",wu=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(d2)),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(d2)),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(gw(s)&&!yw(s)&&o===90)return t.trigger("undo"),!0}function r(o,s){if(gw(s)&&(o===89||o===90&&yw(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)}};wu.$inject=["config.keyboard","eventBus","editorActions","renderer"];var Qy={__depends__:[h2],__init__:["keyboard"],keyboard:["type",wu]};var Od=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,Ct,{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,de,{label:this._translate("Variable type"),onChange:this.setVariableType,options:r,value:i,className:"variable-type-select dms-block"}),2),2)],4),P(2,vw)],4),2)}},vw=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,de,{label:this._translate("Expression language"),onChange:this.setExpressionLanguage,options:t,value:e,className:"expression-language-select dms-block"}),2),2)],4)}};var d9=500,Cu=class{constructor(e){e.onGetComponent("viewer",d9,()=>Od)}};Cu.$inject=["components"];var p2={__depends__:[Qt,Qy,Ut,Xn,Gi],__init__:["literalExpressionProperties"],literalExpressionProperties:["type",Cu]};var Eu=class n{constructor(e,t,i){this._commandStack=e,this._viewer=t,this._eventBus=i,i.on("viewer.init",()=>{p9(this.getHandlers(),e)})}getHandlers(){return n._getHandlers()}static _getHandlers(){return{"element.updateProperties":or}}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)}};Eu.$inject=["commandStack","viewer","eventBus"];function p9(n,e){k(n,function(t,i){e.registerHandler(i,t)})}var m2={__init__:["idChangeBehavior","nameChangeBehavior","modeling"],commandStack:["type",Ee],idChangeBehavior:["type",Kn],nameChangeBehavior:["type",qi],modeling:["type",Eu]};var kd=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()?xw:bw}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})}},xw=class extends L{render(){return P(2,ki,{label:this.props.label,className:this.props.className,value:this.props.value,onInput:this.props.onChange,variables:this.props.variables})}},bw=class extends sn{render(){return y(1,"div",this.getClassName(),this.getEditor(),0)}};var Su=class{constructor(e){e.onGetComponent("viewer",()=>kd)}};Su.$inject=["components"];var g2={__depends__:[Qt,$e],__init__:["textarea"],textarea:["type",Su]};var Rd=class n extends Go{getModules(){return[...Go._getModules(),...n._getModules()]}static _getModules(){return[u2,Qy,p2,m2,Ut,Xn,Gi,g2,Ja]}};var Td=class{constructor(e){e.onGetComponent("viewer",()=>m9),e.onGetComponent("viewer",()=>g9),e.onGetComponent("viewer",()=>y9)}};M(Td,"$inject",["components"]);function m9(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 g9(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 y9(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 Ad=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(Ad,"$inject",["components"]);var y2={__init__:["viewRenderer","tableJsSupport"],viewRenderer:["type",Td],tableJsSupport:["type",Ad]};var v9=2e3,Ou=class{constructor(e){e.onGetComponent("viewer",v9,()=>co)}};Ou.$inject=["components"];var v2={__init__:["poweredBy"],poweredBy:["type",Ou]};var Md=class{constructor(e){e.onGetComponent("expression",({expression:t})=>{if(O(t,"dmn:LiteralExpression"))return x9})}};M(Md,"$inject",["components"]);function x9({expression:n},e){let i=e.injector.get("literalExpression").getText(n);return y(1,"div","textarea",y(1,"div","content",i,0),2)}var ra=class{getText(e){return e.get("text")}};var x2={__init__:["literalExpressionComponent"],literalExpressionComponent:["type",Md],literalExpression:["type",ra]};var ku=class{getParameters(e){return e.get("formalParameter")}getBody(e){return e.get("body")}getKind(e){return e.get("kind")||"FEEL"}};var Pd=class{constructor(e){e.onGetComponent("expression",({expression:t})=>{if(O(t,"dmn:FunctionDefinition"))return b9})}};M(Pd,"$inject",["components"]);function b9({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,w9,{kind:i}),P(2,C9,{parameters:r}),P(2,S9,{expression:o})],4)}var _9={FEEL:"F",Java:"J",PMML:"P"};function w9({kind:n},e){let t=e.injector.get("translate");return y(1,"div","function-definition-kind",_9[n],0,{title:t("Function kind: {kind}",{kind:n})})}function C9({parameters:n}){return y(1,"div","function-definition-parameters",y(1,"div",null,[Z("("),n.reduce((e,t)=>e.concat(P(2,E9,{parameter:t}),", "),[]).slice(0,-1),Z(")")],0),2)}function E9({parameter:n}){let{name:e,typeRef:t}=n,i=e||"";return y(1,"span",null,t?`${i}: ${t}`:i,0)}function S9({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 b2={__init__:["functionDefinitionComponent"],functionDefinition:["type",ku],functionDefinitionComponent:["type",Pd]};var Ru=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)}};Ru.$inject=["translate"];var O9=2e3,Tu=class{constructor(e,t,i){this._injector=i,e.onGetComponent("viewer",O9,()=>{if(this.canViewDrd())return Ru}),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)}};Tu.$inject=["components","eventBus","injector"];var _2={__init__:["viewDrd"],viewDrd:["type",Tu]};function _w(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 Au=class{constructor(e){e.onGetComponent("header",()=>_w)}};Au.$inject=["components"];var w2={__init__:["elementProperties"],elementProperties:["type",Au]};var k9=100,Mu=class{constructor(e){e.onGetComponent("body",()=>R9),e.onGetComponent("expression",k9,()=>A9)}};M(Mu,"$inject",["components"]);function R9(n,{injector:e}){let t=e.get("components"),r=e.get("viewer").getRootElement(),o=T9(r),s=t.getComponent("expression",{expression:o});return P(2,s,{expression:o})}function T9(n){if(O(n,"dmn:Decision"))return n.get("decisionLogic");if(O(n,"dmn:BusinessKnowledgeModel"))return n.get("encapsulatedLogic")}function A9({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 C2={__init__:["elementLogic"],elementLogic:["type",Mu]};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 Pu=class{constructor(e){e.onGetComponent("footer",()=>M9)}};M(Pu,"$inject",["components"]);function M9(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 E2={__init__:["elementVariableComponent"],elementVariable:["type",Xo],elementVariableComponent:["type",Pu]};var oa=class n extends ia{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",{}),He(e))}destroy(){super.destroy(),this.detach()}getModules(){return[y2,$e,v2,_2,w2,C2,b2,x2,E2]}static _createContainer(){return te('
    ')}};var Dd=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(Rp(o))return t.trigger("undo"),!0}),i("redo",function(r){let o=r.keyEvent;if(Tp(o))return t.trigger("redo"),!0})}};M(Dd,"$inject",["editorActions","keyboard"]);var S2={__depends__:[_o],__init__:["keyboardBindings"],keyboardBindings:["type",Dd]};var Du=class extends se{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=O2(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=O2(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(Du,"$inject",["eventBus","modeling"]);function O2(n){return n.$parent}var Iu=class{constructor(e,t,i){this._commandStack=e,this._viewer=t,this._eventBus=i,P9(this._getHandlers(),e)}_getHandlers(){return{"element.updateProperties":or}}updateProperties(e,t){let i={element:e,properties:t};this._commandStack.execute("element.updateProperties",i)}};Iu.$inject=["commandStack","viewer","eventBus"];function P9(n,e){k(n,function(t,i){e.registerHandler(i,t)})}var k2={__init__:["idChangeBehavior","modeling","nameChangeBehavior"],commandStack:["type",Ee],idChangeBehavior:["type",Kn],modeling:["type",Iu],nameChangeBehavior:["type",Du]};function Nn(n,e){return function(t){return En(P(2,ww,{...t,_component:n,_selectDependencies:e}))}}var ww=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 Cw=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()?D9:Ew}isFeel(){let t=this.getLiteralExpression();return f1(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 D9(n){return En(P(2,ki,{...n,onChange:n.onChange}))}var Ew=class extends sn{render(){return y(1,"div",this.getClassName(),this.getEditor(),0)}},I9=Nn(Cw,n=>[n.expression]),Id=class{constructor(e){e.onGetComponent("expression",({expression:t})=>{if(O(t,"dmn:LiteralExpression"))return I9})}};M(Id,"$inject",["components"]);var Lu=class extends ra{constructor(e){super(),this._modeling=e}setText(e,t){this._modeling.updateProperties(e,{text:t})}};Lu.$inject=["modeling"];var R2={__init__:["literalExpressionComponent"],literalExpressionComponent:["type",Id],literalExpression:["type",Lu]};var Ld=class extends ku{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(Ld,"$inject",["modeling","dmnFactory"]);function Sw({label:n,onClick:e}){return y(1,"button","edit-button dmn-icon-edit",null,1,{"aria-label":n,type:"button",onClick:e})}var Bd=class{constructor(e){e.onGetComponent("expression",({expression:t})=>{if(O(t,"dmn:FunctionDefinition"))return L9})}};M(Bd,"$inject",["components"]);var L9=Nn(B9,n=>[n.expression]);function B9({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=T2(c);i.open(u,{contextMenuType:"kind-editor",expression:n})},l=c=>{let u=T2(c);i.open(u,{contextMenuType:"formal-parameters-editor",expression:n})};return y(1,"div","function-definition",[P(2,$9,{kind:r,openEditor:a}),P(2,j9,{parameters:o,openEditor:l}),P(2,V9,{expression:s,parameters:o})],4)}var N9={FEEL:"F",Java:"J",PMML:"P"};function $9({kind:n,openEditor:e},t){let i=t.injector.get("translate");return y(1,"div","function-definition-kind",[N9[n],P(2,Sw,{label:i("Edit function kind"),onClick:e})],0)}function j9({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,F9,{parameter:o}),", "),[]).slice(0,-1),Z(")")],0),P(2,Sw,{label:i("Edit formal parameters"),onClick:n})],4)}var F9=Nn(q9,n=>[n.parameter]);function q9({parameter:n}){let{name:e,typeRef:t}=n,i=e||"";return y(1,"span",null,t?`${i}: ${t}`:i,0)}var V9=Nn(H9,n=>n.parameters);function H9({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 T2(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"}],Nd=class{constructor(e){e.onGetComponent("context-menu",(t={})=>{if(t.contextMenuType&&t.contextMenuType==="kind-editor")return W9})}};M(Nd,"$inject",["components"]);function W9({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,de,{label:i("Kind"),options:z9,value:r,onChange:o,noInput:!0})],4)}var $d=class{constructor(e){e.onGetComponent("context-menu",(t={})=>{if(t.contextMenuType&&t.contextMenuType==="formal-parameters-editor")return U9})}};M($d,"$inject",["components"]);var U9=Nn(Q9,n=>[n.context.expression]);function Q9({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,K9,{parameter:a,remove:()=>o(a)},l)),0)],4):null,y(1,"button","add-parameter",i("Add parameter"),0,{type:"button",onClick:s})],0)}var K9=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,Ct,{onChange:l,value:s}),2),y(1,"td",null,P(2,de,{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 A2={__init__:["formalParametersEditorComponent","functionDefinitionComponent","kindEditorComponent"],__depends__:[Kt],formalParametersEditorComponent:["type",$d],functionDefinition:["type",Ld],functionDefinitionComponent:["type",Bd],kindEditorComponent:["type",Nd]};var G9=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,Ct,{label:r("Element name"),className:"element-name editor",value:o,onChange:s})},n=>[n.element]);function Ow(n,e){let i=e.injector.get("viewer").getRootElement();return y(1,"div","element-properties",P(2,G9,{element:i}),2)}var Bu=class{constructor(e){e.onGetComponent("header",()=>Ow)}};Bu.$inject=["components"];var M2={__depends__:[Qt],__init__:["elementProperties"],elementProperties:["type",Bu]};var Nu=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}};Nu.$inject=["viewer","eventBus"];var jd=class{constructor(e){this._moddle=e}create(e,t={}){return this._moddle.create(e,t)}};M(jd,"$inject",["moddle"]);var P2={__init__:["elementRegistry"],elementRegistry:["type",Nu],dmnFactory:["type",jd]};var $u=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();this._modeling.updateProperties(i,{variable:this._dmnFactory.create("dmn:InformationItem",{name:i.get("name"),typeRef:e})});return}this._modeling.updateProperties(t,{typeRef:e})}};M($u,"$inject",["viewer","modeling","dmnFactory"]);var D2="dmn-boxed-expression-variable-type",ju=class{constructor(e,t){let i=Nn(X9,()=>[t.getVariable()]);e.onGetComponent("footer",()=>i)}};M(ju,"$inject",["components","elementVariable"]);function X9(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:D2}),P(2,Y9)],4)],4)}function Y9(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,de,{value:o,onChange:s,options:a,id:D2})}var I2={__init__:["elementVariableComponent"],elementVariable:["type",$u],elementVariableComponent:["type",ju]};var L2="is not a registered action",Z9="is already registered",Fu=class{constructor(e,t){this._actions={undo(){e.undo()},redo(){e.redo()}}}trigger(e,t){if(!this._actions[e])throw kw(e,L2);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 kw(e,Z9);this._actions[e]=t}unregister(e){if(!this.isRegistered(e))throw kw(e,L2);this._actions[e]=void 0}isRegistered(e){return!!this._actions[e]}};Fu.$inject=["commandStack","eventBus"];function kw(n,e){return new Error(n+" "+e)}var B2={__init__:["editorActions"],editorActions:["type",Fu]};var Fd=class extends oa{getModules(){return[...super.getModules(),P2,k2,B2,M2,A2,Ut,Xn,R2,S2,Gi,I2,Ja]}};var Yo=class extends Ku{_getViewProviders(){return[{id:"drd",constructor:So,opens:"dmn:Definitions"},{id:"decisionTable",constructor:xd,opens(e){return O(e,"dmn:Decision")&&O(e.decisionLogic,"dmn:DecisionTable")}},{id:"literalExpression",constructor:Rd,opens(e){return O(e,"dmn:Decision")&&O(e.decisionLogic,"dmn:LiteralExpression")}},{id:"boxedExpression",constructor:Fd,opens(e){return O(e,"dmn:BusinessKnowledgeModel")&&fr(e)}}]}_getInitialView(e,...t){let i=super._getInitialView(e,...t);if(!i)return;let r=i.element;return O(r,"dmn:Definitions")&&!Da(r)&&(i=me(e,o=>!O(o.element,"dmn:Definitions"))||i),i}};var qd=class extends rs{_getViewProviders(){return[{id:"drd",constructor:wt,opens(e){return O(e,"dmn:Definitions")&&Da(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:oa,opens(e){return O(e,"dmn:BusinessKnowledgeModel")&&fr(e)}}]}};var J9=globalThis;Object.assign(Yo,{Modeler:Yo,Viewer:qd});J9.DmnJS=Yo;var LTe=Yo;})();